@sme.up/doc-alchemist 1.3.0 → 1.4.0-CommonJS-20251015134706

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 (91) hide show
  1. package/README.md +1 -1
  2. package/dist/assets/gfx-data.js +4 -1
  3. package/dist/assets/gfx-data.js.map +1 -1
  4. package/dist/converters/excel/commons.d.ts +2 -2
  5. package/dist/converters/excel/commons.js +49 -33
  6. package/dist/converters/excel/commons.js.map +1 -1
  7. package/dist/converters/excel/excel-converter.types.js +14 -11
  8. package/dist/converters/excel/excel-converter.types.js.map +1 -1
  9. package/dist/converters/excel/matrix-converter.d.ts +3 -3
  10. package/dist/converters/excel/matrix-converter.js +46 -36
  11. package/dist/converters/excel/matrix-converter.js.map +1 -1
  12. package/dist/converters/excel/tree-converter.d.ts +2 -2
  13. package/dist/converters/excel/tree-converter.js +33 -25
  14. package/dist/converters/excel/tree-converter.js.map +1 -1
  15. package/dist/converters/excel-converter.d.ts +3 -3
  16. package/dist/converters/excel-converter.js +18 -13
  17. package/dist/converters/excel-converter.js.map +1 -1
  18. package/dist/converters/images/charts-generator.d.ts +2 -2
  19. package/dist/converters/images/charts-generator.js +41 -4
  20. package/dist/converters/images/charts-generator.js.map +1 -1
  21. package/dist/converters/pdf/autotable-renderer.d.ts +2 -2
  22. package/dist/converters/pdf/autotable-renderer.js +7 -3
  23. package/dist/converters/pdf/autotable-renderer.js.map +1 -1
  24. package/dist/converters/pdf/cover-renderer.js +41 -4
  25. package/dist/converters/pdf/cover-renderer.js.map +1 -1
  26. package/dist/converters/pdf/formulas-helper.d.ts +2 -2
  27. package/dist/converters/pdf/formulas-helper.js +37 -28
  28. package/dist/converters/pdf/formulas-helper.js.map +1 -1
  29. package/dist/converters/pdf/matrix-converter.d.ts +2 -2
  30. package/dist/converters/pdf/matrix-converter.js +52 -12
  31. package/dist/converters/pdf/matrix-converter.js.map +1 -1
  32. package/dist/converters/pdf/pdf-converter.types.js +2 -1
  33. package/dist/converters/pdf/pdf-converter.types.js.map +1 -1
  34. package/dist/converters/pdf/sch-converter.d.ts +1 -1
  35. package/dist/converters/pdf/sch-converter.js +43 -6
  36. package/dist/converters/pdf/sch-converter.js.map +1 -1
  37. package/dist/converters/pdf-converter.d.ts +3 -3
  38. package/dist/converters/pdf-converter.js +23 -18
  39. package/dist/converters/pdf-converter.js.map +1 -1
  40. package/dist/index.d.ts +7 -7
  41. package/dist/index.js +13 -4
  42. package/dist/index.js.map +1 -1
  43. package/dist/types/component-props.js +5 -2
  44. package/dist/types/component-props.js.map +1 -1
  45. package/dist/types/component.js +7 -4
  46. package/dist/types/component.js.map +1 -1
  47. package/dist/types/converter.js +2 -1
  48. package/dist/types/converter.js.map +1 -1
  49. package/dist/types/data-structures/smeupDataStructure.d.ts +4 -4
  50. package/dist/types/data-structures/smeupDataStructure.js +16 -12
  51. package/dist/types/data-structures/smeupDataStructure.js.map +1 -1
  52. package/dist/types/data-structures/smeupDataTable.d.ts +1 -1
  53. package/dist/types/data-structures/smeupDataTable.js +4 -1
  54. package/dist/types/data-structures/smeupDataTable.js.map +1 -1
  55. package/dist/types/data-structures/smeupDataTree.d.ts +2 -2
  56. package/dist/types/data-structures/smeupDataTree.js +2 -1
  57. package/dist/types/data-structures/smeupDataTree.js.map +1 -1
  58. package/dist/types/data-structures/smeupSch.d.ts +6 -6
  59. package/dist/types/data-structures/smeupSch.js +5 -2
  60. package/dist/types/data-structures/smeupSch.js.map +1 -1
  61. package/dist/types/dynamism.d.ts +1 -1
  62. package/dist/types/dynamism.js +7 -4
  63. package/dist/types/dynamism.js.map +1 -1
  64. package/dist/types/general.js +7 -2
  65. package/dist/types/general.js.map +1 -1
  66. package/dist/types/helpers.js +5 -2
  67. package/dist/types/helpers.js.map +1 -1
  68. package/dist/types/index.d.ts +3 -2
  69. package/dist/types/index.js +7 -4
  70. package/dist/types/index.js.map +1 -1
  71. package/dist/utils/commons-utility.d.ts +4 -3
  72. package/dist/utils/commons-utility.js +136 -43
  73. package/dist/utils/commons-utility.js.map +1 -1
  74. package/dist/utils/datastructure-utility.d.ts +1 -1
  75. package/dist/utils/datastructure-utility.js +5 -1
  76. package/dist/utils/datastructure-utility.js.map +1 -1
  77. package/dist/utils/dates-utility.js +37 -27
  78. package/dist/utils/dates-utility.js.map +1 -1
  79. package/dist/utils/formatter-utility.d.ts +1 -1
  80. package/dist/utils/formatter-utility.js +9 -3
  81. package/dist/utils/formatter-utility.js.map +1 -1
  82. package/dist/utils/image-utils.js +10 -3
  83. package/dist/utils/image-utils.js.map +1 -1
  84. package/dist/utils/math-utility.js +46 -29
  85. package/dist/utils/math-utility.js.map +1 -1
  86. package/dist/utils/objects-utility.d.ts +1 -1
  87. package/dist/utils/objects-utility.js +9 -3
  88. package/dist/utils/objects-utility.js.map +1 -1
  89. package/dist/utils/regex-utility.js +4 -1
  90. package/dist/utils/regex-utility.js.map +1 -1
  91. package/package.json +1 -2
@@ -1,32 +1,40 @@
1
- import dayjs from "dayjs";
2
- import utc from "dayjs/plugin/utc.js";
3
- import customParseFormat from "dayjs/plugin/customParseFormat.js";
4
- import localizedFormat from "dayjs/plugin/localizedFormat.js";
5
- import minMax from "dayjs/plugin/minMax.js";
6
- import "dayjs/locale/es.js";
7
- import "dayjs/locale/fr.js";
8
- import "dayjs/locale/it.js";
9
- import "dayjs/locale/pl.js";
10
- import "dayjs/locale/ru.js";
11
- import "dayjs/locale/zh.js";
12
- import { DatesFormats } from "../types/index.js";
13
- import ExcelJS from "exceljs";
14
- dayjs.extend(utc);
15
- dayjs.extend(customParseFormat);
16
- dayjs.extend(localizedFormat);
17
- dayjs.extend(minMax);
18
- export const datesFormat = (input, locale, format) => {
19
- const _dayjs = dayjs;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.datesToDate = exports.datesIsIsoDate = exports.datesFormat = void 0;
7
+ exports.areAllValuesDates = areAllValuesDates;
8
+ const dayjs_1 = __importDefault(require("dayjs"));
9
+ const utc_js_1 = __importDefault(require("dayjs/plugin/utc.js"));
10
+ const customParseFormat_js_1 = __importDefault(require("dayjs/plugin/customParseFormat.js"));
11
+ const localizedFormat_js_1 = __importDefault(require("dayjs/plugin/localizedFormat.js"));
12
+ const minMax_js_1 = __importDefault(require("dayjs/plugin/minMax.js"));
13
+ require("dayjs/locale/es.js");
14
+ require("dayjs/locale/fr.js");
15
+ require("dayjs/locale/it.js");
16
+ require("dayjs/locale/pl.js");
17
+ require("dayjs/locale/ru.js");
18
+ require("dayjs/locale/zh.js");
19
+ const index_1 = require("../types/index");
20
+ const exceljs_1 = __importDefault(require("exceljs"));
21
+ dayjs_1.default.extend(utc_js_1.default);
22
+ dayjs_1.default.extend(customParseFormat_js_1.default);
23
+ dayjs_1.default.extend(localizedFormat_js_1.default);
24
+ dayjs_1.default.extend(minMax_js_1.default);
25
+ const datesFormat = (input, locale, format) => {
26
+ const _dayjs = dayjs_1.default;
20
27
  _dayjs.locale(locale);
21
28
  if (!format) {
22
29
  format = "L"; // MM/DD/YYYY, DD/MM/YYYY depending on locale
23
30
  }
24
31
  return _dayjs.utc(input).format(format);
25
32
  };
26
- export const datesIsIsoDate = (dateString) => {
27
- const isoDate = dayjs(dateString, [
28
- DatesFormats.ISO_DATE,
29
- DatesFormats.ISO_DATE_TIME,
33
+ exports.datesFormat = datesFormat;
34
+ const datesIsIsoDate = (dateString) => {
35
+ const isoDate = (0, dayjs_1.default)(dateString, [
36
+ index_1.DatesFormats.ISO_DATE,
37
+ index_1.DatesFormats.ISO_DATE_TIME,
30
38
  "YYYY-MM-DDTHH:mm:ss.SSSZ",
31
39
  ]);
32
40
  if (!isoDate.isValid()) {
@@ -43,8 +51,9 @@ export const datesIsIsoDate = (dateString) => {
43
51
  }
44
52
  return true;
45
53
  };
46
- export const datesToDate = (input, locale, format) => {
47
- const _dayjs = dayjs;
54
+ exports.datesIsIsoDate = datesIsIsoDate;
55
+ const datesToDate = (input, locale, format) => {
56
+ const _dayjs = dayjs_1.default;
48
57
  _dayjs.locale(locale);
49
58
  if (format && format != null) {
50
59
  return _dayjs.utc(input, format).toDate();
@@ -53,6 +62,7 @@ export const datesToDate = (input, locale, format) => {
53
62
  return _dayjs.utc(input).toDate();
54
63
  }
55
64
  };
65
+ exports.datesToDate = datesToDate;
56
66
  /**
57
67
  * Checks if all ExcelJS.Cell values in the array are dates (ExcelJS.ValueType.Date).
58
68
  * Accepts an array of ExcelJS.Cell and returns true if all are dates.
@@ -60,14 +70,14 @@ export const datesToDate = (input, locale, format) => {
60
70
  * @param values - Array of ExcelJS.Cell
61
71
  * @returns true if all values are dates, false otherwise
62
72
  */
63
- export function areAllValuesDates(values) {
73
+ function areAllValuesDates(values) {
64
74
  const filteredValues = values.filter(cell => cell && cell.type && cell.value);
65
75
  if (!Array.isArray(filteredValues) || filteredValues.length === 0)
66
76
  return false;
67
77
  return filteredValues.every(cell => {
68
78
  if (!cell || typeof cell !== "object")
69
79
  return false;
70
- return cell.type === ExcelJS.ValueType.Date;
80
+ return cell.type === exceljs_1.default.ValueType.Date;
71
81
  });
72
82
  }
73
83
  //# sourceMappingURL=dates-utility.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dates-utility.js","sourceRoot":"","sources":["../../src/utils/dates-utility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,qBAAqB,CAAC;AACtC,OAAO,iBAAiB,MAAM,mCAAmC,CAAC;AAClE,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,MAAM,MAAM,wBAAwB,CAAC;AAC5C,OAAO,oBAAoB,CAAC;AAC5B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,oBAAoB,CAAC;AAC5B,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s/plugin/utc.js\";\nimport customParseFormat from \"dayjs/plugin/customParseFormat.js\";\nimport localizedFormat from \"dayjs/plugin/localizedFormat.js\";\nimport minMax from \"dayjs/plugin/minMax.js\";\nimport \"dayjs/locale/es.js\";\nimport \"dayjs/locale/fr.js\";\nimport \"dayjs/locale/it.js\";\nimport \"dayjs/locale/pl.js\";\nimport \"dayjs/locale/ru.js\";\nimport \"dayjs/locale/zh.js\";\nimport { DatesFormats } from \"../types/index.js\";\nimport ExcelJS from \"exceljs\";\n\ndayjs.extend(utc);\ndayjs.extend(customParseFormat);\ndayjs.extend(localizedFormat);\ndayjs.extend(minMax);\n\nexport const datesFormat = (\n input: dayjs.ConfigType,\n locale: string,\n format?: string,\n): string => {\n const _dayjs = dayjs;\n _dayjs.locale(locale);\n if (!format) {\n format = \"L\"; // MM/DD/YYYY, DD/MM/YYYY depending on locale\n }\n return _dayjs.utc(input).format(format);\n};\n\nexport const datesIsIsoDate = (dateString: string): boolean => {\n const isoDate = dayjs(dateString, [\n DatesFormats.ISO_DATE,\n DatesFormats.ISO_DATE_TIME,\n \"YYYY-MM-DDTHH:mm:ss.SSSZ\",\n ]);\n if (!isoDate.isValid()) {\n return false;\n }\n\n if (Number(dateString.substring(0, 4)) != isoDate.year()) {\n return false;\n }\n if (Number(dateString.substring(5, 7)) != isoDate.month() + 1) {\n return false;\n }\n if (Number(dateString.substring(8, 10)) != isoDate.date()) {\n return false;\n }\n return true;\n};\n\nexport const datesToDate = (\n input: dayjs.ConfigType,\n locale: string,\n format?: string,\n): Date => {\n const _dayjs = dayjs;\n _dayjs.locale(locale);\n if (format && format != null) {\n return _dayjs.utc(input, format).toDate();\n } else {\n return _dayjs.utc(input).toDate();\n }\n};\n\n/**\n * Checks if all ExcelJS.Cell values in the array are dates (ExcelJS.ValueType.Date).\n * Accepts an array of ExcelJS.Cell and returns true if all are dates.\n *\n * @param values - Array of ExcelJS.Cell\n * @returns true if all values are dates, false otherwise\n */\n\nexport function areAllValuesDates(values: ExcelJS.Cell[]): boolean {\n const filteredValues = values.filter(cell => cell && cell.type && cell.value);\n if (!Array.isArray(filteredValues) || filteredValues.length === 0)\n return false;\n return filteredValues.every(cell => {\n if (!cell || typeof cell !== \"object\") return false;\n return cell.type === ExcelJS.ValueType.Date;\n });\n}\n"]}
1
+ {"version":3,"file":"dates-utility.js","sourceRoot":"","sources":["../../src/utils/dates-utility.ts"],"names":[],"mappings":";;;;;;AA4EA,8CAQC;AApFD,kDAA0B;AAC1B,iEAAsC;AACtC,6FAAkE;AAClE,yFAA8D;AAC9D,uEAA4C;AAC5C,8BAA4B;AAC5B,8BAA4B;AAC5B,8BAA4B;AAC5B,8BAA4B;AAC5B,8BAA4B;AAC5B,8BAA4B;AAC5B,0CAA8C;AAC9C,sDAA8B;AAE9B,eAAK,CAAC,MAAM,CAAC,gBAAG,CAAC,CAAC;AAClB,eAAK,CAAC,MAAM,CAAC,8BAAiB,CAAC,CAAC;AAChC,eAAK,CAAC,MAAM,CAAC,4BAAe,CAAC,CAAC;AAC9B,eAAK,CAAC,MAAM,CAAC,mBAAM,CAAC,CAAC;AAEd,MAAM,WAAW,GAAG,CACzB,KAAuB,EACvB,MAAc,EACd,MAAe,EACP,EAAE;IACV,MAAM,MAAM,GAAG,eAAK,CAAC;IACrB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,GAAG,CAAC,CAAC,6CAA6C;IAC7D,CAAC;IACD,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC1C,CAAC,CAAC;AAXW,QAAA,WAAW,eAWtB;AAEK,MAAM,cAAc,GAAG,CAAC,UAAkB,EAAW,EAAE;IAC5D,MAAM,OAAO,GAAG,IAAA,eAAK,EAAC,UAAU,EAAE;QAChC,oBAAY,CAAC,QAAQ;QACrB,oBAAY,CAAC,aAAa;QAC1B,0BAA0B;KAC3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,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9E,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC;QAC/D,OAAO,KAAK,CAAC;IACf,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;QACjC,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QACpD,OAAO,IAAI,CAAC,IAAI,KAAK,iBAAO,CAAC,SAAS,CAAC,IAAI,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import dayjs from \"dayjs\";\nimport utc from \"dayjs/plugin/utc.js\";\nimport customParseFormat from \"dayjs/plugin/customParseFormat.js\";\nimport localizedFormat from \"dayjs/plugin/localizedFormat.js\";\nimport minMax from \"dayjs/plugin/minMax.js\";\nimport \"dayjs/locale/es.js\";\nimport \"dayjs/locale/fr.js\";\nimport \"dayjs/locale/it.js\";\nimport \"dayjs/locale/pl.js\";\nimport \"dayjs/locale/ru.js\";\nimport \"dayjs/locale/zh.js\";\nimport { DatesFormats } from \"../types/index\";\nimport ExcelJS from \"exceljs\";\n\ndayjs.extend(utc);\ndayjs.extend(customParseFormat);\ndayjs.extend(localizedFormat);\ndayjs.extend(minMax);\n\nexport const datesFormat = (\n input: dayjs.ConfigType,\n locale: string,\n format?: string,\n): string => {\n const _dayjs = dayjs;\n _dayjs.locale(locale);\n if (!format) {\n format = \"L\"; // MM/DD/YYYY, DD/MM/YYYY depending on locale\n }\n return _dayjs.utc(input).format(format);\n};\n\nexport const datesIsIsoDate = (dateString: string): boolean => {\n const isoDate = dayjs(dateString, [\n DatesFormats.ISO_DATE,\n DatesFormats.ISO_DATE_TIME,\n \"YYYY-MM-DDTHH:mm:ss.SSSZ\",\n ]);\n if (!isoDate.isValid()) {\n return false;\n }\n\n if (Number(dateString.substring(0, 4)) != isoDate.year()) {\n return false;\n }\n if (Number(dateString.substring(5, 7)) != isoDate.month() + 1) {\n return false;\n }\n if (Number(dateString.substring(8, 10)) != isoDate.date()) {\n return false;\n }\n return true;\n};\n\nexport const datesToDate = (\n input: dayjs.ConfigType,\n locale: string,\n format?: string,\n): Date => {\n const _dayjs = dayjs;\n _dayjs.locale(locale);\n if (format && format != null) {\n return _dayjs.utc(input, format).toDate();\n } else {\n return _dayjs.utc(input).toDate();\n }\n};\n\n/**\n * Checks if all ExcelJS.Cell values in the array are dates (ExcelJS.ValueType.Date).\n * Accepts an array of ExcelJS.Cell and returns true if all are dates.\n *\n * @param values - Array of ExcelJS.Cell\n * @returns true if all values are dates, false otherwise\n */\n\nexport function areAllValuesDates(values: ExcelJS.Cell[]): boolean {\n const filteredValues = values.filter(cell => cell && cell.type && cell.value);\n if (!Array.isArray(filteredValues) || filteredValues.length === 0)\n return false;\n return filteredValues.every(cell => {\n if (!cell || typeof cell !== \"object\") return false;\n return cell.type === ExcelJS.ValueType.Date;\n });\n}\n\n"]}
@@ -1,4 +1,4 @@
1
- import { WebupManagerData } from "../types/index.js";
1
+ import { WebupManagerData } from "../types/index";
2
2
  export declare const formatDate: (date: Date, webupManagerData: WebupManagerData) => string;
3
3
  export declare const formatNumber: (value: number, numFmt: string, webupManagerData: WebupManagerData) => string;
4
4
  export declare const sanitizeString: (input: string) => string;
@@ -1,4 +1,7 @@
1
- export const formatDate = (date, webupManagerData) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sanitizeString = exports.formatNumber = exports.formatDate = void 0;
4
+ const formatDate = (date, webupManagerData) => {
2
5
  if (webupManagerData?.datesLocale === "it-IT" ||
3
6
  webupManagerData?.datesLocale === "it") {
4
7
  return date.toLocaleDateString("it-IT", {
@@ -15,7 +18,8 @@ export const formatDate = (date, webupManagerData) => {
15
18
  });
16
19
  }
17
20
  };
18
- export const formatNumber = (value, numFmt, webupManagerData) => {
21
+ exports.formatDate = formatDate;
22
+ const formatNumber = (value, numFmt, webupManagerData) => {
19
23
  try {
20
24
  const locale = webupManagerData?.mathLocale || "it-IT";
21
25
  const positiveFmt = numFmt.split(";")[0] || numFmt;
@@ -31,11 +35,13 @@ export const formatNumber = (value, numFmt, webupManagerData) => {
31
35
  return value.toString();
32
36
  }
33
37
  };
34
- export const sanitizeString = (input) => {
38
+ exports.formatNumber = formatNumber;
39
+ const sanitizeString = (input) => {
35
40
  // Remove HTML tags and multiple spaces
36
41
  return input
37
42
  .replace(/<[^>]*>/g, " ")
38
43
  .replace(/\s+/g, " ")
39
44
  .trim();
40
45
  };
46
+ exports.sanitizeString = sanitizeString;
41
47
  //# sourceMappingURL=formatter-utility.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatter-utility.js","sourceRoot":"","sources":["../../src/utils/formatter-utility.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,IAAU,EACV,gBAAkC,EAC1B,EAAE;IACV,IACE,gBAAgB,EAAE,WAAW,KAAK,OAAO;QACzC,gBAAgB,EAAE,WAAW,KAAK,IAAI,EACtC,CAAC;QACD,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE;YACtC,GAAG,EAAE,SAAS;YACd,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,SAAS;SAChB,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE;YACtC,KAAK,EAAE,SAAS;YAChB,GAAG,EAAE,SAAS;YACd,IAAI,EAAE,SAAS;SAChB,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,KAAa,EACb,MAAc,EACd,gBAAkC,EAC1B,EAAE;IACV,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,gBAAgB,EAAE,UAAU,IAAI,OAAO,CAAC;QACvD,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC;QACnD,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACjD,MAAM,QAAQ,GAAG,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3D,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;YAC9C,qBAAqB,EAAE,QAAQ;YAC/B,qBAAqB,EAAE,QAAQ;SAChC,CAAC,CAAC;QACH,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAa,EAAU,EAAE;IACtD,uCAAuC;IACvC,OAAO,KAAK;SACT,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;SACxB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,IAAI,EAAE,CAAC;AACZ,CAAC,CAAC","sourcesContent":["import { WebupManagerData } from \"../types/index.js\";\n\nexport const formatDate = (\n date: Date,\n webupManagerData: WebupManagerData,\n): string => {\n if (\n webupManagerData?.datesLocale === \"it-IT\" ||\n webupManagerData?.datesLocale === \"it\"\n ) {\n return date.toLocaleDateString(\"it-IT\", {\n day: \"2-digit\",\n month: \"2-digit\",\n year: \"numeric\",\n });\n } else {\n return date.toLocaleDateString(\"en-US\", {\n month: \"2-digit\",\n day: \"2-digit\",\n year: \"numeric\",\n });\n }\n};\n\nexport const formatNumber = (\n value: number,\n numFmt: string,\n webupManagerData: WebupManagerData,\n): string => {\n try {\n const locale = webupManagerData?.mathLocale || \"it-IT\";\n const positiveFmt = numFmt.split(\";\")[0] || numFmt;\n const decimalMatch = positiveFmt.match(/\\.(0+)/);\n const decimals = decimalMatch ? decimalMatch[1].length : 0;\n const formatter = new Intl.NumberFormat(locale, {\n minimumFractionDigits: decimals,\n maximumFractionDigits: decimals,\n });\n return formatter.format(value);\n } catch {\n return value.toString();\n }\n};\n\nexport const sanitizeString = (input: string): string => {\n // Remove HTML tags and multiple spaces\n return input\n .replace(/<[^>]*>/g, \" \")\n .replace(/\\s+/g, \" \")\n .trim();\n};\n"]}
1
+ {"version":3,"file":"formatter-utility.js","sourceRoot":"","sources":["../../src/utils/formatter-utility.ts"],"names":[],"mappings":";;;AAEO,MAAM,UAAU,GAAG,CACxB,IAAU,EACV,gBAAkC,EAC1B,EAAE;IACV,IACE,gBAAgB,EAAE,WAAW,KAAK,OAAO;QACzC,gBAAgB,EAAE,WAAW,KAAK,IAAI,EACtC,CAAC;QACD,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE;YACtC,GAAG,EAAE,SAAS;YACd,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,SAAS;SAChB,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE;YACtC,KAAK,EAAE,SAAS;YAChB,GAAG,EAAE,SAAS;YACd,IAAI,EAAE,SAAS;SAChB,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC;AApBW,QAAA,UAAU,cAoBrB;AAEK,MAAM,YAAY,GAAG,CAC1B,KAAa,EACb,MAAc,EACd,gBAAkC,EAC1B,EAAE;IACV,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,gBAAgB,EAAE,UAAU,IAAI,OAAO,CAAC;QACvD,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC;QACnD,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACjD,MAAM,QAAQ,GAAG,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3D,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;YAC9C,qBAAqB,EAAE,QAAQ;YAC/B,qBAAqB,EAAE,QAAQ;SAChC,CAAC,CAAC;QACH,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;AACH,CAAC,CAAC;AAlBW,QAAA,YAAY,gBAkBvB;AAEK,MAAM,cAAc,GAAG,CAAC,KAAa,EAAU,EAAE;IACtD,uCAAuC;IACvC,OAAO,KAAK;SACT,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;SACxB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,IAAI,EAAE,CAAC;AACZ,CAAC,CAAC;AANW,QAAA,cAAc,kBAMzB","sourcesContent":["import { WebupManagerData } from \"../types/index\";\n\nexport const formatDate = (\n date: Date,\n webupManagerData: WebupManagerData,\n): string => {\n if (\n webupManagerData?.datesLocale === \"it-IT\" ||\n webupManagerData?.datesLocale === \"it\"\n ) {\n return date.toLocaleDateString(\"it-IT\", {\n day: \"2-digit\",\n month: \"2-digit\",\n year: \"numeric\",\n });\n } else {\n return date.toLocaleDateString(\"en-US\", {\n month: \"2-digit\",\n day: \"2-digit\",\n year: \"numeric\",\n });\n }\n};\n\nexport const formatNumber = (\n value: number,\n numFmt: string,\n webupManagerData: WebupManagerData,\n): string => {\n try {\n const locale = webupManagerData?.mathLocale || \"it-IT\";\n const positiveFmt = numFmt.split(\";\")[0] || numFmt;\n const decimalMatch = positiveFmt.match(/\\.(0+)/);\n const decimals = decimalMatch ? decimalMatch[1].length : 0;\n const formatter = new Intl.NumberFormat(locale, {\n minimumFractionDigits: decimals,\n maximumFractionDigits: decimals,\n });\n return formatter.format(value);\n } catch {\n return value.toString();\n }\n};\n\nexport const sanitizeString = (input: string): string => {\n // Remove HTML tags and multiple spaces\n return input\n .replace(/<[^>]*>/g, \" \")\n .replace(/\\s+/g, \" \")\n .trim();\n};\n\n"]}
@@ -1,5 +1,11 @@
1
- import sizeOf from "image-size";
2
- export const getLogoPositionAndDimension = (doc, logo) => {
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getLogoPositionAndDimension = void 0;
7
+ const image_size_1 = __importDefault(require("image-size"));
8
+ const getLogoPositionAndDimension = (doc, logo) => {
3
9
  const pageWidth = doc.internal.pageSize.getWidth();
4
10
  const logoHeight = 10; // Logo height in mm
5
11
  const logoWidth = calcAutoWidth(logo, logoHeight); // Logo width in mm
@@ -12,6 +18,7 @@ export const getLogoPositionAndDimension = (doc, logo) => {
12
18
  logoY,
13
19
  };
14
20
  };
21
+ exports.getLogoPositionAndDimension = getLogoPositionAndDimension;
15
22
  const calcAutoWidth = (imageData, desiredHeight) => {
16
23
  try {
17
24
  const binaryString = atob(imageData);
@@ -19,7 +26,7 @@ const calcAutoWidth = (imageData, desiredHeight) => {
19
26
  for (let i = 0; i < binaryString.length; i++) {
20
27
  buffer[i] = binaryString.charCodeAt(i);
21
28
  }
22
- const dimensions = sizeOf(buffer);
29
+ const dimensions = (0, image_size_1.default)(buffer);
23
30
  const aspectRatio = dimensions.width / dimensions.height;
24
31
  const calculatedWidth = desiredHeight * aspectRatio;
25
32
  return calculatedWidth;
@@ -1 +1 @@
1
- {"version":3,"file":"image-utils.js","sourceRoot":"","sources":["../../src/utils/image-utils.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,YAAY,CAAC;AAEhC,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,GAAkB,EAClB,IAAY,EACZ,EAAE;IACF,MAAM,SAAS,GAAG,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;IACnD,MAAM,UAAU,GAAG,EAAE,CAAC,CAAC,oBAAoB;IAC3C,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,mBAAmB;IACtE,MAAM,KAAK,GAAG,SAAS,GAAG,SAAS,GAAG,EAAE,CAAC,CAAC,6BAA6B;IACvE,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,0BAA0B;IAE3C,OAAO;QACL,SAAS;QACT,UAAU;QACV,KAAK;QACL,KAAK;KACN,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAE,aAAqB,EAAU,EAAE;IACzE,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;QACrC,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACnD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7C,MAAM,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACzC,CAAC;QACD,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAElC,MAAM,WAAW,GAAG,UAAU,CAAC,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC;QACzD,MAAM,eAAe,GAAG,aAAa,GAAG,WAAW,CAAC;QAEpD,OAAO,eAAe,CAAC;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;QACrD,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { jsPDFDocument } from \"jspdf-autotable\";\nimport sizeOf from \"image-size\";\n\nexport const getLogoPositionAndDimension = (\n doc: jsPDFDocument,\n logo: string,\n) => {\n const pageWidth = doc.internal.pageSize.getWidth();\n const logoHeight = 10; // Logo height in mm\n const logoWidth = calcAutoWidth(logo, logoHeight); // Logo width in mm\n const logoX = pageWidth - logoWidth - 10; // 10mm from the right margin\n const logoY = 5; // 5mm from the top margin\n\n return {\n logoWidth,\n logoHeight,\n logoX,\n logoY,\n };\n};\n\nconst calcAutoWidth = (imageData: string, desiredHeight: number): number => {\n try {\n const binaryString = atob(imageData);\n const buffer = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n buffer[i] = binaryString.charCodeAt(i);\n }\n const dimensions = sizeOf(buffer);\n\n const aspectRatio = dimensions.width / dimensions.height;\n const calculatedWidth = desiredHeight * aspectRatio;\n\n return calculatedWidth;\n } catch (error) {\n console.warn(\"Error calculating auto width:\", error);\n return 50;\n }\n};\n"]}
1
+ {"version":3,"file":"image-utils.js","sourceRoot":"","sources":["../../src/utils/image-utils.ts"],"names":[],"mappings":";;;;;;AACA,4DAAgC;AAEzB,MAAM,2BAA2B,GAAG,CACzC,GAAkB,EAClB,IAAY,EACZ,EAAE;IACF,MAAM,SAAS,GAAG,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;IACnD,MAAM,UAAU,GAAG,EAAE,CAAC,CAAC,oBAAoB;IAC3C,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,mBAAmB;IACtE,MAAM,KAAK,GAAG,SAAS,GAAG,SAAS,GAAG,EAAE,CAAC,CAAC,6BAA6B;IACvE,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,0BAA0B;IAE3C,OAAO;QACL,SAAS;QACT,UAAU;QACV,KAAK;QACL,KAAK;KACN,CAAC;AACJ,CAAC,CAAC;AAhBW,QAAA,2BAA2B,+BAgBtC;AAEF,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAE,aAAqB,EAAU,EAAE;IACzE,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;QACrC,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACnD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7C,MAAM,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACzC,CAAC;QACD,MAAM,UAAU,GAAG,IAAA,oBAAM,EAAC,MAAM,CAAC,CAAC;QAElC,MAAM,WAAW,GAAG,UAAU,CAAC,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC;QACzD,MAAM,eAAe,GAAG,aAAa,GAAG,WAAW,CAAC;QAEpD,OAAO,eAAe,CAAC;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;QACrD,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { jsPDFDocument } from \"jspdf-autotable\";\nimport sizeOf from \"image-size\";\n\nexport const getLogoPositionAndDimension = (\n doc: jsPDFDocument,\n logo: string,\n) => {\n const pageWidth = doc.internal.pageSize.getWidth();\n const logoHeight = 10; // Logo height in mm\n const logoWidth = calcAutoWidth(logo, logoHeight); // Logo width in mm\n const logoX = pageWidth - logoWidth - 10; // 10mm from the right margin\n const logoY = 5; // 5mm from the top margin\n\n return {\n logoWidth,\n logoHeight,\n logoX,\n logoY,\n };\n};\n\nconst calcAutoWidth = (imageData: string, desiredHeight: number): number => {\n try {\n const binaryString = atob(imageData);\n const buffer = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n buffer[i] = binaryString.charCodeAt(i);\n }\n const dimensions = sizeOf(buffer);\n\n const aspectRatio = dimensions.width / dimensions.height;\n const calculatedWidth = desiredHeight * aspectRatio;\n\n return calculatedWidth;\n } catch (error) {\n console.warn(\"Error calculating auto width:\", error);\n return 50;\n }\n};\n\n"]}
@@ -1,6 +1,12 @@
1
- import { getRegExpFromString } from "./regex-utility.js";
2
- import Mexp from "math-expression-evaluator";
3
- export const mathCountDecimals = (value) => {
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.calculateExpression = exports.mathGetNumericValueSuffix = exports.mathCreateFormatPattern = exports.mathFormat = exports.mathGroupSeparator = exports.mathDecimalSeparator = exports.mathNumberifySafe = exports.mathNumberify = exports.mathNumberToFormattedString = exports.mathNumberStringToFormattedString = exports.mathCountDecimals = void 0;
7
+ const regex_utility_1 = require("./regex-utility");
8
+ const math_expression_evaluator_1 = __importDefault(require("math-expression-evaluator"));
9
+ const mathCountDecimals = (value) => {
4
10
  if (Math.floor(value) === value)
5
11
  return 0;
6
12
  const stringValue = value.toString().split(".")[1];
@@ -11,48 +17,51 @@ export const mathCountDecimals = (value) => {
11
17
  return 0;
12
18
  }
13
19
  };
14
- export const mathNumberStringToFormattedString = (input, decimals, type, locale, decSeparator) => {
15
- let value = mathNumberToFormattedString(mathNumberifySafe(input, locale), decimals, type, locale);
20
+ exports.mathCountDecimals = mathCountDecimals;
21
+ const mathNumberStringToFormattedString = (input, decimals, type, locale, decSeparator) => {
22
+ let value = (0, exports.mathNumberToFormattedString)((0, exports.mathNumberifySafe)(input, locale), decimals, type, locale);
16
23
  if (!decSeparator) {
17
24
  return value;
18
25
  }
19
- const browserDecSeparator = mathDecimalSeparator(locale);
26
+ const browserDecSeparator = (0, exports.mathDecimalSeparator)(locale);
20
27
  if (browserDecSeparator == decSeparator) {
21
28
  return value;
22
29
  }
23
- const browserGroupSeparator = mathGroupSeparator(locale);
24
- value = value.replace(getRegExpFromString(browserGroupSeparator, "g"), "");
25
- value = value.replace(getRegExpFromString(browserDecSeparator, "g"), decSeparator);
30
+ const browserGroupSeparator = (0, exports.mathGroupSeparator)(locale);
31
+ value = value.replace((0, regex_utility_1.getRegExpFromString)(browserGroupSeparator, "g"), "");
32
+ value = value.replace((0, regex_utility_1.getRegExpFromString)(browserDecSeparator, "g"), decSeparator);
26
33
  return value;
27
34
  };
28
- export const mathNumberToFormattedString = (input, decimals, type, locale) => {
35
+ exports.mathNumberStringToFormattedString = mathNumberStringToFormattedString;
36
+ const mathNumberToFormattedString = (input, decimals, type, locale) => {
29
37
  if (input == null || isNaN(input)) {
30
38
  return "";
31
39
  }
32
40
  if (decimals == null || decimals == -1) {
33
- decimals = mathCountDecimals(input);
41
+ decimals = (0, exports.mathCountDecimals)(input);
34
42
  }
35
- let nstr = mathFormat(input, locale, mathCreateFormatPattern(true, decimals));
36
- nstr = nstr + mathGetNumericValueSuffix(type);
43
+ let nstr = (0, exports.mathFormat)(input, locale, (0, exports.mathCreateFormatPattern)(true, decimals));
44
+ nstr = nstr + (0, exports.mathGetNumericValueSuffix)(type);
37
45
  return nstr;
38
46
  };
39
- export const mathNumberify = (input, locale, inputIsLocalized, type, decFmt) => {
47
+ exports.mathNumberToFormattedString = mathNumberToFormattedString;
48
+ const mathNumberify = (input, locale, inputIsLocalized, type, decFmt) => {
40
49
  if (typeof input != "number") {
41
50
  if (type) {
42
- const suffix = mathGetNumericValueSuffix(type);
51
+ const suffix = (0, exports.mathGetNumericValueSuffix)(type);
43
52
  if (suffix != "") {
44
53
  input = input
45
- .replace(getRegExpFromString(suffix.trim(), "g"), "")
54
+ .replace((0, regex_utility_1.getRegExpFromString)(suffix.trim(), "g"), "")
46
55
  .trim();
47
56
  }
48
57
  }
49
58
  if (!decFmt) {
50
- decFmt = inputIsLocalized ? mathDecimalSeparator(locale) : ".";
59
+ decFmt = inputIsLocalized ? (0, exports.mathDecimalSeparator)(locale) : ".";
51
60
  }
52
61
  const groupSeparator = decFmt == "." ? "," : ".";
53
- input = input.replace(getRegExpFromString(groupSeparator, "g"), "");
62
+ input = input.replace((0, regex_utility_1.getRegExpFromString)(groupSeparator, "g"), "");
54
63
  if (decFmt != ".") {
55
- input = input.replace(getRegExpFromString(decFmt, "g"), ".");
64
+ input = input.replace((0, regex_utility_1.getRegExpFromString)(decFmt, "g"), ".");
56
65
  }
57
66
  input = Number(input);
58
67
  }
@@ -62,20 +71,23 @@ export const mathNumberify = (input, locale, inputIsLocalized, type, decFmt) =>
62
71
  }
63
72
  return n;
64
73
  };
65
- export const mathNumberifySafe = (input, locale, inputIsLocalized, type, decFmt) => {
74
+ exports.mathNumberify = mathNumberify;
75
+ const mathNumberifySafe = (input, locale, inputIsLocalized, type, decFmt) => {
66
76
  if (!input || input == null || input.trim() == "") {
67
77
  input = "0";
68
78
  }
69
- return mathNumberify(input, locale, inputIsLocalized, type, decFmt);
79
+ return (0, exports.mathNumberify)(input, locale, inputIsLocalized, type, decFmt);
70
80
  };
71
- export const mathDecimalSeparator = (locale) => {
81
+ exports.mathNumberifySafe = mathNumberifySafe;
82
+ const mathDecimalSeparator = (locale) => {
72
83
  const numberWithGroupAndDecimalSeparator = 1000.1;
73
84
  const decimalPart = Intl.NumberFormat(locale)
74
85
  .formatToParts(numberWithGroupAndDecimalSeparator)
75
86
  .find(part => part.type === "decimal");
76
87
  return decimalPart ? decimalPart.value : ".";
77
88
  };
78
- export const mathGroupSeparator = (locale) => {
89
+ exports.mathDecimalSeparator = mathDecimalSeparator;
90
+ const mathGroupSeparator = (locale) => {
79
91
  const numberWithGroupAndDecimalSeparator = 1000.1;
80
92
  const parts = Intl.NumberFormat(locale).formatToParts(numberWithGroupAndDecimalSeparator);
81
93
  const groupPart = parts.find(part => part.type === "group");
@@ -87,8 +99,9 @@ export const mathGroupSeparator = (locale) => {
87
99
  }
88
100
  return groupPart.value;
89
101
  };
90
- export const mathFormat = (input, locale, format, inputIsLocalized) => {
91
- const n = mathNumberify(input, locale, inputIsLocalized);
102
+ exports.mathGroupSeparator = mathGroupSeparator;
103
+ const mathFormat = (input, locale, format, inputIsLocalized) => {
104
+ const n = (0, exports.mathNumberify)(input, locale, inputIsLocalized);
92
105
  if (!format) {
93
106
  const positiveN = Math.abs(n);
94
107
  const decimals = positiveN - Math.floor(positiveN);
@@ -102,6 +115,7 @@ export const mathFormat = (input, locale, format, inputIsLocalized) => {
102
115
  const options = mathParseNumberFormat(format);
103
116
  return new Intl.NumberFormat(locale, options).format(n);
104
117
  };
118
+ exports.mathFormat = mathFormat;
105
119
  const mathParseNumberFormat = (format) => {
106
120
  // Example format strings: '0,0.00', '0,0', '0.000', ...
107
121
  // This parser is simplistic; it only checks for comma group
@@ -129,7 +143,7 @@ const mathParseNumberFormat = (format) => {
129
143
  }
130
144
  return options;
131
145
  };
132
- export const mathCreateFormatPattern = (thousandPoint, decimals) => {
146
+ const mathCreateFormatPattern = (thousandPoint, decimals) => {
133
147
  let format = "0";
134
148
  if (thousandPoint) {
135
149
  format += ",0";
@@ -142,7 +156,8 @@ export const mathCreateFormatPattern = (thousandPoint, decimals) => {
142
156
  }
143
157
  return format;
144
158
  };
145
- export const mathGetNumericValueSuffix = (type) => {
159
+ exports.mathCreateFormatPattern = mathCreateFormatPattern;
160
+ const mathGetNumericValueSuffix = (type) => {
146
161
  type = type.toUpperCase();
147
162
  let nstr = "";
148
163
  if (type == "P") {
@@ -159,13 +174,15 @@ export const mathGetNumericValueSuffix = (type) => {
159
174
  }
160
175
  return nstr;
161
176
  };
162
- export const calculateExpression = (expression) => {
177
+ exports.mathGetNumericValueSuffix = mathGetNumericValueSuffix;
178
+ const calculateExpression = (expression) => {
163
179
  try {
164
- const mexp = new Mexp();
180
+ const mexp = new math_expression_evaluator_1.default();
165
181
  return mexp.eval(expression);
166
182
  }
167
183
  catch {
168
184
  return expression;
169
185
  }
170
186
  };
187
+ exports.calculateExpression = calculateExpression;
171
188
  //# sourceMappingURL=math-utility.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"math-utility.js","sourceRoot":"","sources":["../../src/utils/math-utility.ts"],"names":[],"mappings":"AAAA,OAA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AAG,GAAG,CAAC;IACjB,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,IAAI,IAAI,CAAC;IACjB,CAAC;IACD,IAAI,QAAQ,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,CAAC;QACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC;YAClC,MAAM,IAAI,GAAG,CAAC;QAChB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,IAAY,EAAU,EAAE;IAChE,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAC1B,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,IAAI,IAAI,GAAG,EAAE,CAAC;QAChB,IAAI,GAAG,IAAI,CAAC;IACd,CAAC;SAAM,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,GAAG,IAAI,CAAC;IACd,CAAC;SAAM,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,GAAG,IAAI,CAAC;IACd,CAAC;SAAM,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,GAAG,IAAI,CAAC;IACd,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,UAAkB,EAAmB,EAAE;IACzE,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,UAAU,CAAC;IACpB,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { getRegExpFromString } from \"./regex-utility.js\";\nimport Mexp from \"math-expression-evaluator\";\n\nexport const mathCountDecimals = (value: number): number => {\n if (Math.floor(value) === value) return 0;\n const stringValue = value.toString().split(\".\")[1];\n if (stringValue) {\n return stringValue.length ?? 0;\n } else {\n return 0;\n }\n};\n\nexport const mathNumberStringToFormattedString = (\n input: string,\n decimals: number,\n type: string,\n locale: string,\n decSeparator?: string,\n): string => {\n let value = mathNumberToFormattedString(\n mathNumberifySafe(input, locale),\n decimals,\n type,\n locale,\n );\n\n if (!decSeparator) {\n return value;\n }\n const browserDecSeparator = mathDecimalSeparator(locale);\n if (browserDecSeparator == decSeparator) {\n return value;\n }\n const browserGroupSeparator = mathGroupSeparator(locale);\n value = value.replace(getRegExpFromString(browserGroupSeparator, \"g\"), \"\");\n value = value.replace(\n getRegExpFromString(browserDecSeparator, \"g\"),\n decSeparator,\n );\n\n return value;\n};\n\nexport const mathNumberToFormattedString = (\n input: number,\n decimals: number,\n type: string,\n locale: string,\n): string => {\n if (input == null || isNaN(input)) {\n return \"\";\n }\n if (decimals == null || decimals == -1) {\n decimals = mathCountDecimals(input);\n }\n let nstr = mathFormat(input, locale, mathCreateFormatPattern(true, decimals));\n nstr = nstr + mathGetNumericValueSuffix(type);\n return nstr;\n};\n\nexport const mathNumberify = (\n input: string | number,\n locale: string,\n inputIsLocalized?: boolean,\n type?: string,\n decFmt?: string,\n): number => {\n if (typeof input != \"number\") {\n if (type) {\n const suffix = mathGetNumericValueSuffix(type);\n if (suffix != \"\") {\n input = input\n .replace(getRegExpFromString(suffix.trim(), \"g\"), \"\")\n .trim();\n }\n }\n if (!decFmt) {\n decFmt = inputIsLocalized ? mathDecimalSeparator(locale) : \".\";\n }\n const groupSeparator = decFmt == \".\" ? \",\" : \".\";\n input = input.replace(getRegExpFromString(groupSeparator, \"g\"), \"\");\n if (decFmt != \".\") {\n input = input.replace(getRegExpFromString(decFmt, \"g\"), \".\");\n }\n\n input = Number(input);\n }\n\n const n = Number(input);\n if (isNaN(n)) {\n return NaN;\n }\n return n;\n};\n\nexport const mathNumberifySafe = (\n input: string,\n locale: string,\n inputIsLocalized?: boolean,\n type?: string,\n decFmt?: string,\n): number => {\n if (!input || input == null || input.trim() == \"\") {\n input = \"0\";\n }\n return mathNumberify(input, locale, inputIsLocalized, type, decFmt);\n};\n\nexport const mathDecimalSeparator = (locale: string): string => {\n const numberWithGroupAndDecimalSeparator = 1000.1;\n const decimalPart = Intl.NumberFormat(locale)\n .formatToParts(numberWithGroupAndDecimalSeparator)\n .find(part => part.type === \"decimal\");\n return decimalPart ? decimalPart.value : \".\";\n};\n\nexport const mathGroupSeparator = (locale: string): string => {\n const numberWithGroupAndDecimalSeparator = 1000.1;\n\n const parts = Intl.NumberFormat(locale).formatToParts(\n numberWithGroupAndDecimalSeparator,\n );\n\n const groupPart = parts.find(part => part.type === \"group\");\n\n if (!groupPart) {\n /** for some reason, today 19/03/2025 on US OS (mac and github), group is not present in parts!!! */\n const decimalPart = parts.find(part => part.type === \"decimal\");\n const decimalPartValue = decimalPart ? decimalPart.value : \".\";\n return decimalPartValue === \".\" ? \",\" : \".\";\n }\n return groupPart.value;\n};\n\nexport const mathFormat = (\n input: string | number,\n locale: string,\n format?: string,\n inputIsLocalized?: boolean,\n): string => {\n const n = mathNumberify(input, locale, inputIsLocalized);\n if (!format) {\n const positiveN = Math.abs(n);\n const decimals = positiveN - Math.floor(positiveN);\n if (decimals) {\n format = \"0,0.00\";\n } else {\n format = \"0,0\";\n }\n }\n const options = mathParseNumberFormat(format);\n return new Intl.NumberFormat(locale, options).format(n);\n};\n\nconst mathParseNumberFormat = (format: string): Intl.NumberFormatOptions => {\n // Example format strings: '0,0.00', '0,0', '0.000', ...\n // This parser is simplistic; it only checks for comma group\n // and counts how many 0's come after '.' to set decimal digits.\n const options: Intl.NumberFormatOptions = {};\n\n // If there's a comma in the integer part, enable grouping\n if (format.includes(\",\")) {\n options.useGrouping = true;\n } else {\n options.useGrouping = false;\n }\n\n // Count decimals from the part after '.'\n const decimalIndex = format.indexOf(\".\");\n if (decimalIndex > -1) {\n const decimals = format.substring(decimalIndex + 1);\n const digitCount = (decimals.match(/0/g) || []).length;\n options.minimumFractionDigits = digitCount;\n options.maximumFractionDigits = digitCount;\n } else {\n // If no dot, no decimal digits\n options.minimumFractionDigits = 0;\n options.maximumFractionDigits = 0;\n }\n\n return options;\n};\n\nexport const mathCreateFormatPattern = (\n thousandPoint?: boolean,\n decimals?: number,\n): string => {\n let format = \"0\";\n if (thousandPoint) {\n format += \",0\";\n }\n if (decimals && decimals > 0) {\n format += \".\";\n for (let i = 0; i < decimals; i++) {\n format += \"0\";\n }\n }\n return format;\n};\n\nexport const mathGetNumericValueSuffix = (type: string): string => {\n type = type.toUpperCase();\n let nstr = \"\";\n if (type == \"P\") {\n nstr = \" %\";\n } else if (type == \"VE\") {\n nstr = \" €\";\n } else if (type == \"VL\") {\n nstr = \" £\";\n } else if (type == \"VV\") {\n nstr = \" $\";\n }\n return nstr;\n};\n\nexport const calculateExpression = (expression: string): number | string => {\n try {\n const mexp = new Mexp();\n return mexp.eval(expression);\n } catch {\n return expression;\n }\n};\n"]}
1
+ {"version":3,"file":"math-utility.js","sourceRoot":"","sources":["../../src/utils/math-utility.ts"],"names":[],"mappings":";;;;;;AAAA,mDAAsD;AACtD,0FAA6C;AAEtC,MAAM,iBAAiB,GAAG,CAAC,KAAa,EAAU,EAAE;IACzD,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,KAAK;QAAE,OAAO,CAAC,CAAC;IAC1C,MAAM,WAAW,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,WAAW,CAAC,MAAM,IAAI,CAAC,CAAC;IACjC,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC,CAAC;AARW,QAAA,iBAAiB,qBAQ5B;AAEK,MAAM,iCAAiC,GAAG,CAC/C,KAAa,EACb,QAAgB,EAChB,IAAY,E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C;AAChB,CAAC,CAAC;AAfW,QAAA,uBAAuB,2BAelC;AAEK,MAAM,yBAAyB,GAAG,CAAC,IAAY,EAAU,EAAE;IAChE,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAC1B,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,IAAI,IAAI,GAAG,EAAE,CAAC;QAChB,IAAI,GAAG,IAAI,CAAC;IACd,CAAC;SAAM,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,GAAG,IAAI,CAAC;IACd,CAAC;SAAM,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,GAAG,IAAI,CAAC;IACd,CAAC;SAAM,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,GAAG,IAAI,CAAC;IACd,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAbW,QAAA,yBAAyB,6BAapC;AAEK,MAAM,mBAAmB,GAAG,CAAC,UAAkB,EAAmB,EAAE;IACzE,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,mCAAI,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,UAAU,CAAC;IACpB,CAAC;AACH,CAAC,CAAC;AAPW,QAAA,mBAAmB,uBAO9B","sourcesContent":["import { getRegExpFromString } from \"./regex-utility\";\nimport Mexp from \"math-expression-evaluator\";\n\nexport const mathCountDecimals = (value: number): number => {\n if (Math.floor(value) === value) return 0;\n const stringValue = value.toString().split(\".\")[1];\n if (stringValue) {\n return stringValue.length ?? 0;\n } else {\n return 0;\n }\n};\n\nexport const mathNumberStringToFormattedString = (\n input: string,\n decimals: number,\n type: string,\n locale: string,\n decSeparator?: string,\n): string => {\n let value = mathNumberToFormattedString(\n mathNumberifySafe(input, locale),\n decimals,\n type,\n locale,\n );\n\n if (!decSeparator) {\n return value;\n }\n const browserDecSeparator = mathDecimalSeparator(locale);\n if (browserDecSeparator == decSeparator) {\n return value;\n }\n const browserGroupSeparator = mathGroupSeparator(locale);\n value = value.replace(getRegExpFromString(browserGroupSeparator, \"g\"), \"\");\n value = value.replace(\n getRegExpFromString(browserDecSeparator, \"g\"),\n decSeparator,\n );\n\n return value;\n};\n\nexport const mathNumberToFormattedString = (\n input: number,\n decimals: number,\n type: string,\n locale: string,\n): string => {\n if (input == null || isNaN(input)) {\n return \"\";\n }\n if (decimals == null || decimals == -1) {\n decimals = mathCountDecimals(input);\n }\n let nstr = mathFormat(input, locale, mathCreateFormatPattern(true, decimals));\n nstr = nstr + mathGetNumericValueSuffix(type);\n return nstr;\n};\n\nexport const mathNumberify = (\n input: string | number,\n locale: string,\n inputIsLocalized?: boolean,\n type?: string,\n decFmt?: string,\n): number => {\n if (typeof input != \"number\") {\n if (type) {\n const suffix = mathGetNumericValueSuffix(type);\n if (suffix != \"\") {\n input = input\n .replace(getRegExpFromString(suffix.trim(), \"g\"), \"\")\n .trim();\n }\n }\n if (!decFmt) {\n decFmt = inputIsLocalized ? mathDecimalSeparator(locale) : \".\";\n }\n const groupSeparator = decFmt == \".\" ? \",\" : \".\";\n input = input.replace(getRegExpFromString(groupSeparator, \"g\"), \"\");\n if (decFmt != \".\") {\n input = input.replace(getRegExpFromString(decFmt, \"g\"), \".\");\n }\n\n input = Number(input);\n }\n\n const n = Number(input);\n if (isNaN(n)) {\n return NaN;\n }\n return n;\n};\n\nexport const mathNumberifySafe = (\n input: string,\n locale: string,\n inputIsLocalized?: boolean,\n type?: string,\n decFmt?: string,\n): number => {\n if (!input || input == null || input.trim() == \"\") {\n input = \"0\";\n }\n return mathNumberify(input, locale, inputIsLocalized, type, decFmt);\n};\n\nexport const mathDecimalSeparator = (locale: string): string => {\n const numberWithGroupAndDecimalSeparator = 1000.1;\n const decimalPart = Intl.NumberFormat(locale)\n .formatToParts(numberWithGroupAndDecimalSeparator)\n .find(part => part.type === \"decimal\");\n return decimalPart ? decimalPart.value : \".\";\n};\n\nexport const mathGroupSeparator = (locale: string): string => {\n const numberWithGroupAndDecimalSeparator = 1000.1;\n\n const parts = Intl.NumberFormat(locale).formatToParts(\n numberWithGroupAndDecimalSeparator,\n );\n\n const groupPart = parts.find(part => part.type === \"group\");\n\n if (!groupPart) {\n /** for some reason, today 19/03/2025 on US OS (mac and github), group is not present in parts!!! */\n const decimalPart = parts.find(part => part.type === \"decimal\");\n const decimalPartValue = decimalPart ? decimalPart.value : \".\";\n return decimalPartValue === \".\" ? \",\" : \".\";\n }\n return groupPart.value;\n};\n\nexport const mathFormat = (\n input: string | number,\n locale: string,\n format?: string,\n inputIsLocalized?: boolean,\n): string => {\n const n = mathNumberify(input, locale, inputIsLocalized);\n if (!format) {\n const positiveN = Math.abs(n);\n const decimals = positiveN - Math.floor(positiveN);\n if (decimals) {\n format = \"0,0.00\";\n } else {\n format = \"0,0\";\n }\n }\n const options = mathParseNumberFormat(format);\n return new Intl.NumberFormat(locale, options).format(n);\n};\n\nconst mathParseNumberFormat = (format: string): Intl.NumberFormatOptions => {\n // Example format strings: '0,0.00', '0,0', '0.000', ...\n // This parser is simplistic; it only checks for comma group\n // and counts how many 0's come after '.' to set decimal digits.\n const options: Intl.NumberFormatOptions = {};\n\n // If there's a comma in the integer part, enable grouping\n if (format.includes(\",\")) {\n options.useGrouping = true;\n } else {\n options.useGrouping = false;\n }\n\n // Count decimals from the part after '.'\n const decimalIndex = format.indexOf(\".\");\n if (decimalIndex > -1) {\n const decimals = format.substring(decimalIndex + 1);\n const digitCount = (decimals.match(/0/g) || []).length;\n options.minimumFractionDigits = digitCount;\n options.maximumFractionDigits = digitCount;\n } else {\n // If no dot, no decimal digits\n options.minimumFractionDigits = 0;\n options.maximumFractionDigits = 0;\n }\n\n return options;\n};\n\nexport const mathCreateFormatPattern = (\n thousandPoint?: boolean,\n decimals?: number,\n): string => {\n let format = \"0\";\n if (thousandPoint) {\n format += \",0\";\n }\n if (decimals && decimals > 0) {\n format += \".\";\n for (let i = 0; i < decimals; i++) {\n format += \"0\";\n }\n }\n return format;\n};\n\nexport const mathGetNumericValueSuffix = (type: string): string => {\n type = type.toUpperCase();\n let nstr = \"\";\n if (type == \"P\") {\n nstr = \" %\";\n } else if (type == \"VE\") {\n nstr = \" €\";\n } else if (type == \"VL\") {\n nstr = \" £\";\n } else if (type == \"VV\") {\n nstr = \" $\";\n }\n return nstr;\n};\n\nexport const calculateExpression = (expression: string): number | string => {\n try {\n const mexp = new Mexp();\n return mexp.eval(expression);\n } catch {\n return expression;\n }\n};\n\n"]}
@@ -1,4 +1,4 @@
1
- import { SmeupDataObj } from "../types/index.js";
1
+ import { SmeupDataObj } from "../types/index";
2
2
  export declare const objectsIsDate: (obj: Omit<SmeupDataObj, "k">) => boolean;
3
3
  export declare const objectsIsNumber: (obj: Omit<SmeupDataObj, "k">) => boolean;
4
4
  export declare const objectsIsVoCodVer: (obj: Omit<SmeupDataObj, "k">) => boolean;
@@ -1,16 +1,22 @@
1
- export const objectsIsDate = (obj) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.objectsIsVoCodVer = exports.objectsIsNumber = exports.objectsIsDate = void 0;
4
+ const objectsIsDate = (obj) => {
2
5
  if (!obj)
3
6
  return false;
4
7
  return "D8" === obj.t;
5
8
  };
6
- export const objectsIsNumber = (obj) => {
9
+ exports.objectsIsDate = objectsIsDate;
10
+ const objectsIsNumber = (obj) => {
7
11
  if (!obj)
8
12
  return false;
9
13
  return "NR" === obj.t || "NP" === obj.t;
10
14
  };
11
- export const objectsIsVoCodVer = (obj) => {
15
+ exports.objectsIsNumber = objectsIsNumber;
16
+ const objectsIsVoCodVer = (obj) => {
12
17
  if (!obj)
13
18
  return false;
14
19
  return "VO" == obj.t && "COD_VER" === obj.p;
15
20
  };
21
+ exports.objectsIsVoCodVer = objectsIsVoCodVer;
16
22
  //# sourceMappingURL=objects-utility.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"objects-utility.js","sourceRoot":"","sources":["../../src/utils/objects-utility.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAA4B,EAAW,EAAE;IACrE,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IACvB,OAAO,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;AACxB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAA4B,EAAW,EAAE;IACvE,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IACvB,OAAO,IAAI,KAAK,GAAG,CAAC,CAAC,IAAI,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;AAC1C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAA4B,EAAW,EAAE;IACzE,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IACvB,OAAO,IAAI,IAAI,GAAG,CAAC,CAAC,IAAI,SAAS,KAAK,GAAG,CAAC,CAAC,CAAC;AAC9C,CAAC,CAAC","sourcesContent":["import { SmeupDataObj } from \"../types/index.js\";\n\nexport const objectsIsDate = (obj: Omit<SmeupDataObj, \"k\">): boolean => {\n if (!obj) return false;\n return \"D8\" === obj.t;\n};\n\nexport const objectsIsNumber = (obj: Omit<SmeupDataObj, \"k\">): boolean => {\n if (!obj) return false;\n return \"NR\" === obj.t || \"NP\" === obj.t;\n};\n\nexport const objectsIsVoCodVer = (obj: Omit<SmeupDataObj, \"k\">): boolean => {\n if (!obj) return false;\n return \"VO\" == obj.t && \"COD_VER\" === obj.p;\n};\n"]}
1
+ {"version":3,"file":"objects-utility.js","sourceRoot":"","sources":["../../src/utils/objects-utility.ts"],"names":[],"mappings":";;;AAEO,MAAM,aAAa,GAAG,CAAC,GAA4B,EAAW,EAAE;IACrE,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IACvB,OAAO,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;AACxB,CAAC,CAAC;AAHW,QAAA,aAAa,iBAGxB;AAEK,MAAM,eAAe,GAAG,CAAC,GAA4B,EAAW,EAAE;IACvE,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IACvB,OAAO,IAAI,KAAK,GAAG,CAAC,CAAC,IAAI,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;AAC1C,CAAC,CAAC;AAHW,QAAA,eAAe,mBAG1B;AAEK,MAAM,iBAAiB,GAAG,CAAC,GAA4B,EAAW,EAAE;IACzE,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IACvB,OAAO,IAAI,IAAI,GAAG,CAAC,CAAC,IAAI,SAAS,KAAK,GAAG,CAAC,CAAC,CAAC;AAC9C,CAAC,CAAC;AAHW,QAAA,iBAAiB,qBAG5B","sourcesContent":["import { SmeupDataObj } from \"../types/index\";\n\nexport const objectsIsDate = (obj: Omit<SmeupDataObj, \"k\">): boolean => {\n if (!obj) return false;\n return \"D8\" === obj.t;\n};\n\nexport const objectsIsNumber = (obj: Omit<SmeupDataObj, \"k\">): boolean => {\n if (!obj) return false;\n return \"NR\" === obj.t || \"NP\" === obj.t;\n};\n\nexport const objectsIsVoCodVer = (obj: Omit<SmeupDataObj, \"k\">): boolean => {\n if (!obj) return false;\n return \"VO\" == obj.t && \"COD_VER\" === obj.p;\n};\n\n"]}
@@ -1,4 +1,7 @@
1
- export function getRegExpFromString(s, flags) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRegExpFromString = getRegExpFromString;
4
+ function getRegExpFromString(s, flags) {
2
5
  return new RegExp(s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), flags); // $& means the whole matched string
3
6
  }
4
7
  //# sourceMappingURL=regex-utility.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"regex-utility.js","sourceRoot":"","sources":["../../src/utils/regex-utility.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,mBAAmB,CAAC,CAAS,EAAE,KAAc;IAC3D,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,oCAAoC;AAC1G,CAAC","sourcesContent":["export function getRegExpFromString(s: string, flags?: string): RegExp {\n return new RegExp(s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"), flags); // $& means the whole matched string\n}\n"]}
1
+ {"version":3,"file":"regex-utility.js","sourceRoot":"","sources":["../../src/utils/regex-utility.ts"],"names":[],"mappings":";;AAAA,kDAEC;AAFD,SAAgB,mBAAmB,CAAC,CAAS,EAAE,KAAc;IAC3D,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,oCAAoC;AAC1G,CAAC","sourcesContent":["export function getRegExpFromString(s: string, flags?: string): RegExp {\n return new RegExp(s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"), flags); // $& means the whole matched string\n}\n\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sme.up/doc-alchemist",
3
- "version": "1.3.0",
3
+ "version": "1.4.0-CommonJS-20251015134706",
4
4
  "description": "Library for generating documents in various formats, including Excel and PDF.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Smeup LAB <info@smeup.com> (https://www.smeup.com/)",
@@ -20,7 +20,6 @@
20
20
  "start": "tsx debug.ts"
21
21
  },
22
22
  "keywords": [],
23
- "type": "module",
24
23
  "devDependencies": {
25
24
  "@eslint/js": "^9.28.0",
26
25
  "@types/jest": "^29.5.14",