@sme.up/doc-alchemist 1.1.0-SNAPSHOT-20250623155458 → 1.2.0-20250805123329

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 (136) hide show
  1. package/README.md +278 -30
  2. package/dist/assets/gfx-data.d.ts +1 -0
  3. package/dist/assets/gfx-data.js +2 -0
  4. package/dist/assets/gfx-data.js.map +1 -0
  5. package/dist/converters/excel/commons.d.ts +43 -0
  6. package/dist/converters/excel/commons.js +232 -0
  7. package/dist/converters/excel/commons.js.map +1 -0
  8. package/dist/{src/excel/excel-generator.types.d.ts → converters/excel/excel-converter.types.d.ts} +2 -0
  9. package/dist/{src/excel/excel-generator.types.js → converters/excel/excel-converter.types.js} +5 -2
  10. package/dist/converters/excel/excel-converter.types.js.map +1 -0
  11. package/dist/{src/excel/matrix-generator.d.ts → converters/excel/matrix-converter.d.ts} +4 -2
  12. package/dist/{src/excel/matrix-generator.js → converters/excel/matrix-converter.js} +35 -38
  13. package/dist/converters/excel/matrix-converter.js.map +1 -0
  14. package/dist/{src/excel/tree-generator.d.ts → converters/excel/tree-converter.d.ts} +2 -2
  15. package/dist/{src/excel/tree-generator.js → converters/excel/tree-converter.js} +5 -5
  16. package/dist/converters/excel/tree-converter.js.map +1 -0
  17. package/dist/{src/excel/excel-generator.d.ts → converters/excel-converter.d.ts} +2 -1
  18. package/dist/{src/excel/excel-generator.js → converters/excel-converter.js} +4 -4
  19. package/dist/converters/excel-converter.js.map +1 -0
  20. package/dist/converters/images/charts-generator.d.ts +9 -0
  21. package/dist/converters/images/charts-generator.js +250 -0
  22. package/dist/converters/images/charts-generator.js.map +1 -0
  23. package/dist/converters/pdf/autotable-renderer.d.ts +4 -0
  24. package/dist/converters/pdf/autotable-renderer.js +83 -0
  25. package/dist/converters/pdf/autotable-renderer.js.map +1 -0
  26. package/dist/converters/pdf/cover-renderer.d.ts +1 -0
  27. package/dist/converters/pdf/cover-renderer.js +50 -0
  28. package/dist/converters/pdf/cover-renderer.js.map +1 -0
  29. package/dist/converters/pdf/formulas-helper.d.ts +40 -0
  30. package/dist/converters/pdf/formulas-helper.js +227 -0
  31. package/dist/converters/pdf/formulas-helper.js.map +1 -0
  32. package/dist/converters/pdf/matrix-converter.d.ts +17 -0
  33. package/dist/converters/pdf/matrix-converter.js +200 -0
  34. package/dist/converters/pdf/matrix-converter.js.map +1 -0
  35. package/dist/converters/pdf/pdf-converter.types.d.ts +13 -0
  36. package/dist/converters/pdf/pdf-converter.types.js +2 -0
  37. package/dist/converters/pdf/pdf-converter.types.js.map +1 -0
  38. package/dist/converters/pdf/sch-converter.d.ts +3 -0
  39. package/dist/converters/pdf/sch-converter.js +99 -0
  40. package/dist/converters/pdf/sch-converter.js.map +1 -0
  41. package/dist/converters/pdf-converter.d.ts +8 -0
  42. package/dist/converters/pdf-converter.js +54 -0
  43. package/dist/converters/pdf-converter.js.map +1 -0
  44. package/dist/index.d.ts +7 -4
  45. package/dist/index.js +4 -2
  46. package/dist/index.js.map +1 -1
  47. package/dist/types/component-props.d.ts +8 -0
  48. package/dist/types/component-props.js +7 -0
  49. package/dist/types/component-props.js.map +1 -0
  50. package/dist/types/component.d.ts +53 -0
  51. package/dist/types/component.js +53 -0
  52. package/dist/types/component.js.map +1 -0
  53. package/dist/types/converter.d.ts +8 -0
  54. package/dist/types/converter.js +2 -0
  55. package/dist/types/converter.js.map +1 -0
  56. package/dist/types/data-structures/smeupDataStructure.d.ts +215 -0
  57. package/dist/types/data-structures/smeupDataStructure.js +99 -0
  58. package/dist/types/data-structures/smeupDataStructure.js.map +1 -0
  59. package/dist/types/data-structures/smeupDataTable.d.ts +125 -0
  60. package/dist/types/data-structures/smeupDataTable.js +43 -0
  61. package/dist/types/data-structures/smeupDataTable.js.map +1 -0
  62. package/dist/types/data-structures/smeupDataTree.d.ts +13 -0
  63. package/dist/types/data-structures/smeupDataTree.js +2 -0
  64. package/dist/types/data-structures/smeupDataTree.js.map +1 -0
  65. package/dist/types/data-structures/smeupSch.d.ts +72 -0
  66. package/dist/types/data-structures/smeupSch.js +11 -0
  67. package/dist/types/data-structures/smeupSch.js.map +1 -0
  68. package/dist/types/dynamism.d.ts +45 -0
  69. package/dist/types/dynamism.js +30 -0
  70. package/dist/types/dynamism.js.map +1 -0
  71. package/dist/types/general.d.ts +22 -0
  72. package/dist/types/general.js +24 -0
  73. package/dist/types/general.js.map +1 -0
  74. package/dist/types/helpers.d.ts +4 -0
  75. package/dist/types/helpers.js +6 -0
  76. package/dist/types/helpers.js.map +1 -0
  77. package/dist/{src/types → types}/index.d.ts +9 -2
  78. package/dist/{src/types → types}/index.js +2 -0
  79. package/dist/types/index.js.map +1 -0
  80. package/dist/utils/commons-utility.d.ts +61 -0
  81. package/dist/{src/utils/generator-utility.js → utils/commons-utility.js} +100 -10
  82. package/dist/utils/commons-utility.js.map +1 -0
  83. package/dist/utils/datastructure-utility.d.ts +2 -0
  84. package/dist/utils/datastructure-utility.js +5 -0
  85. package/dist/utils/datastructure-utility.js.map +1 -0
  86. package/dist/{src/utils → utils}/dates-utility.d.ts +9 -0
  87. package/dist/{src/utils → utils}/dates-utility.js +18 -0
  88. package/dist/utils/dates-utility.js.map +1 -0
  89. package/dist/utils/formatter-utility.d.ts +4 -0
  90. package/dist/utils/formatter-utility.js +41 -0
  91. package/dist/utils/formatter-utility.js.map +1 -0
  92. package/dist/utils/image-utils.d.ts +7 -0
  93. package/dist/utils/image-utils.js +32 -0
  94. package/dist/utils/image-utils.js.map +1 -0
  95. package/dist/{src/utils → utils}/math-utility.d.ts +1 -0
  96. package/dist/{src/utils → utils}/math-utility.js +10 -0
  97. package/dist/utils/math-utility.js.map +1 -0
  98. package/dist/utils/objects-utility.js.map +1 -0
  99. package/dist/utils/regex-utility.js.map +1 -0
  100. package/package.json +14 -11
  101. package/dist/assets/sample-data.d.ts +0 -48
  102. package/dist/assets/sample-data.js +0 -372
  103. package/dist/assets/sample-data.js.map +0 -1
  104. package/dist/debug.d.ts +0 -1
  105. package/dist/debug.js +0 -29
  106. package/dist/debug.js.map +0 -1
  107. package/dist/src/excel/commons.d.ts +0 -21
  108. package/dist/src/excel/commons.js +0 -120
  109. package/dist/src/excel/commons.js.map +0 -1
  110. package/dist/src/excel/excel-generator.js.map +0 -1
  111. package/dist/src/excel/excel-generator.types.js.map +0 -1
  112. package/dist/src/excel/matrix-generator.js.map +0 -1
  113. package/dist/src/excel/tree-generator.js.map +0 -1
  114. package/dist/src/index.d.ts +0 -1
  115. package/dist/src/index.js +0 -2
  116. package/dist/src/index.js.map +0 -1
  117. package/dist/src/pdf/pdf-generator.d.ts +0 -7
  118. package/dist/src/pdf/pdf-generator.js +0 -28
  119. package/dist/src/pdf/pdf-generator.js.map +0 -1
  120. package/dist/src/types/index.js.map +0 -1
  121. package/dist/src/utils/datastructure-utility.d.ts +0 -2
  122. package/dist/src/utils/datastructure-utility.js +0 -5
  123. package/dist/src/utils/datastructure-utility.js.map +0 -1
  124. package/dist/src/utils/dates-utility.js.map +0 -1
  125. package/dist/src/utils/generator-utility.d.ts +0 -34
  126. package/dist/src/utils/generator-utility.js.map +0 -1
  127. package/dist/src/utils/math-utility.js.map +0 -1
  128. package/dist/src/utils/objects-utility.js.map +0 -1
  129. package/dist/src/utils/regex-utility.js.map +0 -1
  130. package/dist/tests/excel-generator.test.d.ts +0 -1
  131. package/dist/tests/excel-generator.test.js +0 -406
  132. package/dist/tests/excel-generator.test.js.map +0 -1
  133. /package/dist/{src/utils → utils}/objects-utility.d.ts +0 -0
  134. /package/dist/{src/utils → utils}/objects-utility.js +0 -0
  135. /package/dist/{src/utils → utils}/regex-utility.d.ts +0 -0
  136. /package/dist/{src/utils → utils}/regex-utility.js +0 -0
@@ -0,0 +1,45 @@
1
+ import { SmeupVariable } from "./data-structures/smeupDataStructure.js";
2
+ /**
3
+ * Raw Dynamism
4
+ */
5
+ export interface RawDynamism {
6
+ /** Event type */
7
+ event: string;
8
+ /** Fun or Action */
9
+ exec?: string;
10
+ /** Component ids */
11
+ targets?: string[];
12
+ /** Declared variables */
13
+ variables?: SmeupVariable[];
14
+ /** Enable conditions */
15
+ enabled?: string;
16
+ /** Load method */
17
+ Load?: LoadType;
18
+ }
19
+ /**
20
+ * Dynamism Event
21
+ */
22
+ export declare enum DynamismEvents {
23
+ ALL = "*all",
24
+ BTN_CLICK = "btnclick",
25
+ CHANGE = "change",
26
+ CHANGE_MONTH = "changemonth",
27
+ CHANGE_ROW = "changerow",
28
+ CHANGE_VAL = "changeval",
29
+ CLICK = "click",
30
+ DBLCLICK = "dblclick",
31
+ DETAIL_CLICK = "detailclick",
32
+ EXPAND = "expand",
33
+ RESIZE = "resize",
34
+ DATESELECT = "dateselect",
35
+ DROP = "drop",
36
+ SELECT = "select",
37
+ UPDATE = "update",
38
+ CHECK = "check",
39
+ INIT = "init",
40
+ CLOSE = "close",
41
+ UNMOUNT = "unmount"
42
+ }
43
+ export declare enum LoadType {
44
+ D = "D"
45
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Dynamism Event
3
+ */
4
+ export var DynamismEvents;
5
+ (function (DynamismEvents) {
6
+ DynamismEvents["ALL"] = "*all";
7
+ DynamismEvents["BTN_CLICK"] = "btnclick";
8
+ DynamismEvents["CHANGE"] = "change";
9
+ DynamismEvents["CHANGE_MONTH"] = "changemonth";
10
+ DynamismEvents["CHANGE_ROW"] = "changerow";
11
+ DynamismEvents["CHANGE_VAL"] = "changeval";
12
+ DynamismEvents["CLICK"] = "click";
13
+ DynamismEvents["DBLCLICK"] = "dblclick";
14
+ DynamismEvents["DETAIL_CLICK"] = "detailclick";
15
+ DynamismEvents["EXPAND"] = "expand";
16
+ DynamismEvents["RESIZE"] = "resize";
17
+ DynamismEvents["DATESELECT"] = "dateselect";
18
+ DynamismEvents["DROP"] = "drop";
19
+ DynamismEvents["SELECT"] = "select";
20
+ DynamismEvents["UPDATE"] = "update";
21
+ DynamismEvents["CHECK"] = "check";
22
+ DynamismEvents["INIT"] = "init";
23
+ DynamismEvents["CLOSE"] = "close";
24
+ DynamismEvents["UNMOUNT"] = "unmount";
25
+ })(DynamismEvents || (DynamismEvents = {}));
26
+ export var LoadType;
27
+ (function (LoadType) {
28
+ LoadType["D"] = "D";
29
+ })(LoadType || (LoadType = {}));
30
+ //# sourceMappingURL=dynamism.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamism.js","sourceRoot":"","sources":["../../src/types/dynamism.ts"],"names":[],"mappings":"AAoBA;;GAEG;AACH,MAAM,CAAN,IAAY,cAoBX;AApBD,WAAY,cAAc;IACxB,8BAAY,CAAA;IACZ,wCAAsB,CAAA;IACtB,mCAAiB,CAAA;IACjB,8CAA4B,CAAA;IAC5B,0CAAwB,CAAA;IACxB,0CAAwB,CAAA;IACxB,iCAAe,CAAA;IACf,uCAAqB,CAAA;IACrB,8CAA4B,CAAA;IAC5B,mCAAiB,CAAA;IACjB,mCAAiB,CAAA;IACjB,2CAAyB,CAAA;IACzB,+BAAa,CAAA;IACb,mCAAiB,CAAA;IACjB,mCAAiB,CAAA;IACjB,iCAAe,CAAA;IACf,+BAAa,CAAA;IACb,iCAAe,CAAA;IACf,qCAAmB,CAAA;AACrB,CAAC,EApBW,cAAc,KAAd,cAAc,QAoBzB;AAED,MAAM,CAAN,IAAY,QAEX;AAFD,WAAY,QAAQ;IAClB,mBAAO,CAAA;AACT,CAAC,EAFW,QAAQ,KAAR,QAAQ,QAEnB","sourcesContent":["import { SmeupVariable } from \"./data-structures/smeupDataStructure.js\";\n\n/**\n * Raw Dynamism\n */\nexport interface RawDynamism {\n /** Event type */\n event: string;\n /** Fun or Action */\n exec?: string;\n /** Component ids */\n targets?: string[];\n /** Declared variables */\n variables?: SmeupVariable[];\n /** Enable conditions */\n enabled?: string;\n /** Load method */\n Load?: LoadType;\n}\n\n/**\n * Dynamism Event\n */\nexport enum DynamismEvents {\n ALL = \"*all\",\n BTN_CLICK = \"btnclick\",\n CHANGE = \"change\",\n CHANGE_MONTH = \"changemonth\",\n CHANGE_ROW = \"changerow\",\n CHANGE_VAL = \"changeval\",\n CLICK = \"click\",\n DBLCLICK = \"dblclick\",\n DETAIL_CLICK = \"detailclick\",\n EXPAND = \"expand\",\n RESIZE = \"resize\",\n DATESELECT = \"dateselect\",\n DROP = \"drop\",\n SELECT = \"select\",\n UPDATE = \"update\",\n CHECK = \"check\",\n INIT = \"init\",\n CLOSE = \"close\",\n UNMOUNT = \"unmount\",\n}\n\nexport enum LoadType {\n D = \"D\",\n}\n"]}
@@ -0,0 +1,22 @@
1
+ export declare class FunObject {
2
+ t: string;
3
+ p: string;
4
+ k: string;
5
+ }
6
+ /**
7
+ * Fun
8
+ */
9
+ export declare class Fun {
10
+ component: string;
11
+ service: string;
12
+ function: string;
13
+ obj1?: FunObject;
14
+ obj2?: FunObject;
15
+ obj3?: FunObject;
16
+ obj4?: FunObject;
17
+ obj5?: FunObject;
18
+ obj6?: FunObject;
19
+ P?: string;
20
+ INPUT?: string;
21
+ SS?: string;
22
+ }
@@ -0,0 +1,24 @@
1
+ export class FunObject {
2
+ t;
3
+ p;
4
+ k;
5
+ }
6
+ /**
7
+ * Fun
8
+ */
9
+ export class Fun {
10
+ component;
11
+ service;
12
+ function;
13
+ obj1;
14
+ obj2;
15
+ obj3;
16
+ obj4;
17
+ obj5;
18
+ obj6;
19
+ P;
20
+ INPUT;
21
+ // The implementation of java FunDTO expects SS to be uppercased
22
+ SS;
23
+ }
24
+ //# sourceMappingURL=general.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"general.js","sourceRoot":"","sources":["../../src/types/general.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,SAAS;IACpB,CAAC,CAAU;IAEX,CAAC,CAAU;IAEX,CAAC,CAAU;CACZ;AAED;;GAEG;AACH,MAAM,OAAO,GAAG;IACd,SAAS,CAAU;IACnB,OAAO,CAAU;IACjB,QAAQ,CAAU;IAElB,IAAI,CAAa;IACjB,IAAI,CAAa;IACjB,IAAI,CAAa;IACjB,IAAI,CAAa;IACjB,IAAI,CAAa;IACjB,IAAI,CAAa;IAEjB,CAAC,CAAU;IACX,KAAK,CAAU;IAEf,gEAAgE;IAChE,EAAE,CAAU;CACb","sourcesContent":["export class FunObject {\n t!: string;\n\n p!: string;\n\n k!: string;\n}\n\n/**\n * Fun\n */\nexport class Fun {\n component!: string;\n service!: string;\n function!: string;\n\n obj1?: FunObject;\n obj2?: FunObject;\n obj3?: FunObject;\n obj4?: FunObject;\n obj5?: FunObject;\n obj6?: FunObject;\n\n P?: string;\n INPUT?: string;\n\n // The implementation of java FunDTO expects SS to be uppercased\n SS?: string;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export declare enum YesNo {
2
+ Yes = "Yes",
3
+ No = "No"
4
+ }
@@ -0,0 +1,6 @@
1
+ export var YesNo;
2
+ (function (YesNo) {
3
+ YesNo["Yes"] = "Yes";
4
+ YesNo["No"] = "No";
5
+ })(YesNo || (YesNo = {}));
6
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/types/helpers.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,KAGX;AAHD,WAAY,KAAK;IACf,oBAAW,CAAA;IACX,kBAAS,CAAA;AACX,CAAC,EAHW,KAAK,KAAL,KAAK,QAGhB","sourcesContent":["export enum YesNo {\n Yes = \"Yes\",\n No = \"No\",\n}\n"]}
@@ -1,5 +1,6 @@
1
- import { SmeupDataCell } from "@sme.up/kokos-sdk-node";
2
1
  import type { Properties as CSSProperties } from "csstype";
2
+ import { ComponentOptions } from "./component.js";
3
+ import { SmeupDataCell } from "./data-structures/smeupDataTable.js";
3
4
  export interface SmeupDataObj {
4
5
  t: string;
5
6
  p: string;
@@ -34,5 +35,11 @@ export declare enum SupportedExportFormats {
34
35
  XLSX = "xlsx",
35
36
  CSV = "csv",
36
37
  TXT = "txt",
37
- PDF_SCHEDA = "pdf_scheda"
38
+ FILE = "file",
39
+ PDF_SCHEDA = "pdf_scheda",
40
+ PDF = "pdf"
41
+ }
42
+ export interface ChartOptions extends ComponentOptions {
43
+ Width: string;
44
+ Height: string;
38
45
  }
@@ -10,6 +10,8 @@ export var SupportedExportFormats;
10
10
  SupportedExportFormats["XLSX"] = "xlsx";
11
11
  SupportedExportFormats["CSV"] = "csv";
12
12
  SupportedExportFormats["TXT"] = "txt";
13
+ SupportedExportFormats["FILE"] = "file";
13
14
  SupportedExportFormats["PDF_SCHEDA"] = "pdf_scheda";
15
+ SupportedExportFormats["PDF"] = "pdf";
14
16
  })(SupportedExportFormats || (SupportedExportFormats = {}));
15
17
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAUA,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,uCAAuB,CAAA;IACvB,qDAAqC,CAAA;IACrC,qCAAqB,CAAA;IACrB,kDAAkC,CAAA;AACpC,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AAwBD,MAAM,CAAN,IAAY,sBAOX;AAPD,WAAY,sBAAsB;IAChC,uCAAa,CAAA;IACb,qCAAW,CAAA;IACX,qCAAW,CAAA;IACX,uCAAa,CAAA;IACb,mDAAyB,CAAA;IACzB,qCAAW,CAAA;AACb,CAAC,EAPW,sBAAsB,KAAtB,sBAAsB,QAOjC","sourcesContent":["import type { Properties as CSSProperties } from \"csstype\";\nimport { ComponentOptions } from \"./component.js\";\nimport { SmeupDataCell } from \"./data-structures/smeupDataTable.js\";\n\nexport interface SmeupDataObj {\n t: string;\n p: string;\n k: string;\n}\n\nexport enum DatesFormats {\n ISO_DATE = \"YYYY-MM-DD\",\n ISO_DATE_TIME = \"YYYY-MM-DD HH:mm:ss\",\n ISO_TIME = \"HH:mm:ss\",\n ISO_TIME_WITHOUT_SECONDS = \"HH:mm\",\n}\n\nexport interface GenericObject {\n [index: string]: unknown;\n}\n\nexport interface WebupManagerData {\n mathLocale: string;\n datesLocale: string;\n themeBackground: string;\n}\n\n/**\n * Applies dataTable filters to the excel table rows\n */\nexport type ColumnFilter = {\n checkBoxes?: { value: string }[];\n // add other properties if needed\n};\n\nexport interface SmeupDataCellStyled extends SmeupDataCell {\n style?: CSSProperties;\n}\n\nexport enum SupportedExportFormats {\n XLSX = \"xlsx\",\n CSV = \"csv\",\n TXT = \"txt\",\n FILE = \"file\",\n PDF_SCHEDA = \"pdf_scheda\",\n PDF = \"pdf\",\n}\n\nexport interface ChartOptions extends ComponentOptions {\n Width: string;\n Height: string;\n}\n"]}
@@ -0,0 +1,61 @@
1
+ import { SortObject } from "../types/component-props.js";
2
+ import { SmeupDataColumn, SmeupDataTable, SmeupDataCell, SmeupDataRow } from "../types/data-structures/smeupDataTable.js";
3
+ import { ColumnFilter, WebupManagerData, SupportedExportFormats, GenericObject } from "../types/index.js";
4
+ export declare const getFilteredColumns: (columns: SmeupDataColumn[], props: GenericObject, groupsArray?: {
5
+ column: string;
6
+ visible: boolean;
7
+ }[]) => SmeupDataColumn[];
8
+ /**
9
+ * By passing the map, length value and column name
10
+ * creates or updates a map record with
11
+ * @param map Contains columnNames and their longest cell's length
12
+ * @param text The text to use in length calculation
13
+ * @param colName The column to check
14
+ */
15
+ export declare const updateMaxValueLength: (map: {
16
+ [key: string]: number;
17
+ }, text: string | undefined | null, colName: string) => void;
18
+ export declare const filterRows: (smeupDataTable: SmeupDataTable, filteredColumns: SmeupDataColumn[], filters: {
19
+ [key: string]: ColumnFilter;
20
+ }) => SmeupDataRow[];
21
+ export declare const sortRows: (rows: SmeupDataRow[], sortObject: SortObject[], activeGroups?: string[]) => void;
22
+ /**
23
+ * Returns a converted and formatted cell value (string, date, number)
24
+ * @param cell - SmeupDataCell
25
+ * @param bookType - SupportedExportFormats
26
+ * @param webupManagerData - WebupManagerData
27
+ * @returns
28
+ */
29
+ export declare const calculateCellValue: (cell: SmeupDataCell, bookType: SupportedExportFormats, webupManagerData: WebupManagerData) => string | number | Date;
30
+ /**
31
+ * Calculates and formats a value based on its type and export format.
32
+ *
33
+ * - If the value is a date and the object indicates a date type, it returns a formatted date string or a Date object,
34
+ * depending on the export format.
35
+ * - If the value is a number and the object indicates a number type, it returns a formatted number string or a numeric value,
36
+ * depending on the export format.
37
+ * - Otherwise, it returns the original value or an empty string if the value is null or undefined.
38
+ *
39
+ * @param bookType - The export format type.
40
+ * @param webupManagerData - Data containing locale and formatting information.
41
+ * @param value - The value to be calculated and formatted.
42
+ * @param obj - Optional object describing the type of the value.
43
+ * @returns The formatted value, a Date object, a number, or the original value as a string.
44
+ */
45
+ export declare const calculateValue: (value: string, obj: {
46
+ t: string;
47
+ p: string;
48
+ k: string;
49
+ }, bookType: SupportedExportFormats, webupManagerData: WebupManagerData) => string | number | Date;
50
+ /**
51
+ * Conversion from Hexadecimal color to an AlphaRGB
52
+ * @param hex string - Hexadecimal value, it can bot have and don't have the # prefix
53
+ * @returns ARGB string code
54
+ */
55
+ export declare const hexToArgb: (hex: string) => string;
56
+ export declare const convertToBuffer: (arrayBuffer: ArrayBuffer | Uint8Array) => Buffer | Uint8Array;
57
+ export declare const loadImageAsBase64: (imageUrl: string) => Promise<string | null>;
58
+ /**
59
+ * Converts a hexadecimal color string (e.g., "#RRGGBB" or "0xRRGGBB") to an RGB tuple.
60
+ */
61
+ export declare const convertColorToRgb: (color: string) => [number, number, number];
@@ -1,5 +1,7 @@
1
- import { exportTypeSupportsFormatting } from "../excel/excel-generator.types.js";
1
+ import { exportTypeSupportsFormatting } from "../converters/excel/excel-converter.types.js";
2
+ import { SortMode } from "../types/component-props.js";
2
3
  import { datesIsIsoDate, datesToDate, datesFormat } from "./dates-utility.js";
4
+ import { sanitizeString } from "./formatter-utility.js";
3
5
  import { mathNumberStringToFormattedString, mathCountDecimals, } from "./math-utility.js";
4
6
  import { objectsIsVoCodVer, objectsIsDate, objectsIsNumber, } from "./objects-utility.js";
5
7
  export const getFilteredColumns = (columns, props, groupsArray = []) => {
@@ -73,6 +75,41 @@ export const filterRows = (smeupDataTable, filteredColumns, filters) => {
73
75
  return smeupDataTable.rows;
74
76
  }
75
77
  };
78
+ export const sortRows = (rows, sortObject, activeGroups) => {
79
+ const sort = sortObject?.[0];
80
+ if (!sort && !activeGroups) {
81
+ return;
82
+ }
83
+ if (!sort && activeGroups) {
84
+ rows.sort((a, b) => {
85
+ for (const group of activeGroups) {
86
+ const valA = a.cells?.[group]?.value ?? "";
87
+ const valB = b.cells?.[group]?.value ?? "";
88
+ if (valA !== valB) {
89
+ return valA.localeCompare(valB);
90
+ }
91
+ }
92
+ return 0;
93
+ });
94
+ return;
95
+ }
96
+ rows.sort((a, b) => {
97
+ const valA = a.cells?.[sort.column]?.value ?? "";
98
+ const valB = b.cells?.[sort.column]?.value ?? "";
99
+ switch (sort.sortMode) {
100
+ case SortMode.A:
101
+ if (valA !== valB) {
102
+ return valA.localeCompare(valB);
103
+ }
104
+ return 0;
105
+ case SortMode.D:
106
+ if (valA !== valB) {
107
+ return -valA.localeCompare(valB);
108
+ }
109
+ return 0;
110
+ }
111
+ });
112
+ };
76
113
  /**
77
114
  * Returns a converted and formatted cell value (string, date, number)
78
115
  * @param cell - SmeupDataCell
@@ -81,19 +118,39 @@ export const filterRows = (smeupDataTable, filteredColumns, filters) => {
81
118
  * @returns
82
119
  */
83
120
  export const calculateCellValue = (cell, bookType, webupManagerData) => {
84
- if (cell.obj && objectsIsDate(cell.obj) && datesIsIsoDate(cell.value)) {
121
+ return calculateValue(cell.value, cell.obj ?? { t: "", p: "", k: "" }, bookType, webupManagerData);
122
+ };
123
+ /**
124
+ * Calculates and formats a value based on its type and export format.
125
+ *
126
+ * - If the value is a date and the object indicates a date type, it returns a formatted date string or a Date object,
127
+ * depending on the export format.
128
+ * - If the value is a number and the object indicates a number type, it returns a formatted number string or a numeric value,
129
+ * depending on the export format.
130
+ * - Otherwise, it returns the original value or an empty string if the value is null or undefined.
131
+ *
132
+ * @param bookType - The export format type.
133
+ * @param webupManagerData - Data containing locale and formatting information.
134
+ * @param value - The value to be calculated and formatted.
135
+ * @param obj - Optional object describing the type of the value.
136
+ * @returns The formatted value, a Date object, a number, or the original value as a string.
137
+ */
138
+ export const calculateValue = (value, obj, bookType, webupManagerData) => {
139
+ if (obj && objectsIsDate(obj) && datesIsIsoDate(value)) {
85
140
  return exportTypeSupportsFormatting[bookType]
86
- ? new Date(datesToDate(cell.value, webupManagerData.datesLocale))
87
- : datesFormat(cell.value, webupManagerData.datesLocale);
141
+ ? new Date(datesToDate(value, webupManagerData.datesLocale))
142
+ : datesFormat(value, webupManagerData.datesLocale);
88
143
  }
89
- if (cell.obj && objectsIsNumber(cell.obj)) {
144
+ if (obj && objectsIsNumber(obj)) {
90
145
  if (!exportTypeSupportsFormatting[bookType]) {
91
- return (mathNumberStringToFormattedString(cell.value, mathCountDecimals(Number(cell.value) || 0), "", webupManagerData.mathLocale) || "");
146
+ return (mathNumberStringToFormattedString(value, mathCountDecimals(Number(value) || 0), "", webupManagerData.mathLocale) || "");
92
147
  }
93
- const numValue = Number(cell.value);
94
- return !isNaN(numValue) ? numValue : "";
148
+ const numValue = Number(value);
149
+ return !isNaN(numValue) && !(Math.abs(numValue) === Infinity)
150
+ ? numValue
151
+ : "";
95
152
  }
96
- return cell?.value ?? "";
153
+ return sanitizeString(value) ?? "";
97
154
  };
98
155
  /**
99
156
  * Conversion from Hexadecimal color to an AlphaRGB
@@ -125,6 +182,9 @@ const isBufferAvailable = () => {
125
182
  };
126
183
  // Utility function to convert ArrayBuffer to Buffer or Uint8Array
127
184
  export const convertToBuffer = (arrayBuffer) => {
185
+ if (arrayBuffer instanceof Uint8Array) {
186
+ return arrayBuffer;
187
+ }
128
188
  if (isBufferAvailable()) {
129
189
  return Buffer.from(arrayBuffer);
130
190
  }
@@ -132,4 +192,34 @@ export const convertToBuffer = (arrayBuffer) => {
132
192
  return new Uint8Array(arrayBuffer);
133
193
  }
134
194
  };
135
- //# sourceMappingURL=generator-utility.js.map
195
+ // Function to load an image as base64 (browser version, async)
196
+ export const loadImageAsBase64 = async (imageUrl) => {
197
+ try {
198
+ const response = await fetch(imageUrl);
199
+ if (!response.ok)
200
+ return null;
201
+ const blob = await response.blob();
202
+ return await new Promise((resolve, reject) => {
203
+ const reader = new FileReader();
204
+ reader.onloadend = () => {
205
+ resolve(reader.result);
206
+ };
207
+ reader.onerror = () => reject(null);
208
+ reader.readAsDataURL(blob);
209
+ });
210
+ }
211
+ catch (error) {
212
+ console.warn("Unable to load asset image:", error);
213
+ return null;
214
+ }
215
+ };
216
+ /**
217
+ * Converts a hexadecimal color string (e.g., "#RRGGBB" or "0xRRGGBB") to an RGB tuple.
218
+ */
219
+ export const convertColorToRgb = (color) => {
220
+ const r = parseInt(color.substring(2, 4), 16);
221
+ const g = parseInt(color.substring(4, 6), 16);
222
+ const b = parseInt(color.substring(6, 8), 16);
223
+ return [r, g, b];
224
+ };
225
+ //# sourceMappingURL=commons-utility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commons-utility.js","sourceRoot":"","sources":["../../src/utils/commons-utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,8CAA8C,CAAC;AAC5F,OAAO,EAAE,QAAQ,EAAc,MAAM,6BAA6B,CAAC;AAcnE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EACL,iCAAiC,EACjC,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,OAA0B,EAC1B,KAAoB,EACpB,cAAsD,EAAE,EACxD,EAAE;IACF,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IAExB,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAC/B,IAAI,CA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AAC,QAAQ,CAAC,EAAE;YAAE,OAAO,IAAI,CAAC;QAC9B,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,OAAO,MAAM,IAAI,OAAO,CAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC1D,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;YAChC,MAAM,CAAC,SAAS,GAAG,GAAG,EAAE;gBACtB,OAAO,CAAC,MAAM,CAAC,MAAgB,CAAC,CAAC;YACnC,CAAC,CAAC;YACF,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACpC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAa,EAA4B,EAAE;IAC3E,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC9C,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC9C,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC9C,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import { exportTypeSupportsFormatting } from \"../converters/excel/excel-converter.types.js\";\nimport { SortMode, SortObject } from \"../types/component-props.js\";\nimport {\n SmeupDataColumn,\n SmeupDataTable,\n SmeupDataCell,\n SmeupDataRow,\n} from \"../types/data-structures/smeupDataTable.js\";\nimport {\n SmeupDataObj,\n ColumnFilter,\n WebupManagerData,\n SupportedExportFormats,\n GenericObject,\n} from \"../types/index.js\";\nimport { datesIsIsoDate, datesToDate, datesFormat } from \"./dates-utility.js\";\nimport { sanitizeString } from \"./formatter-utility.js\";\nimport {\n mathNumberStringToFormattedString,\n mathCountDecimals,\n} from \"./math-utility.js\";\nimport {\n objectsIsVoCodVer,\n objectsIsDate,\n objectsIsNumber,\n} from \"./objects-utility.js\";\n\nexport const getFilteredColumns = (\n columns: SmeupDataColumn[],\n props: GenericObject,\n groupsArray: { column: string; visible: boolean }[] = [],\n) => {\n if (!columns) return [];\n\n const mutableColumns = JSON.parse(\n JSON.stringify(columns),\n ) as SmeupDataColumn[];\n\n const filteredColumns: SmeupDataColumn[] = [];\n\n if (props.visibleColumns && (props.visibleColumns as string[]).length > 0) {\n (props.visibleColumns as string[]).forEach((col: string) => {\n const foundColumn = mutableColumns.find(c => c.name === col);\n if (foundColumn) {\n filteredColumns.push({ ...foundColumn });\n }\n });\n } else {\n filteredColumns.push(...mutableColumns);\n }\n\n // Set the visibility of columns based on groups and props\n filteredColumns.forEach((col: SmeupDataColumn) => {\n const isGroupedColumn = groupsArray.filter(g => g.column === col.name);\n col.visible = props.visibleColumns\n ? (props.visibleColumns as string[]).includes(col.name)\n : col.visible;\n col.visible =\n isGroupedColumn.length > 0 ? isGroupedColumn[0].visible : col.visible;\n });\n\n return filteredColumns.filter(column => {\n const dataObject = {\n ...column.obj,\n k: \"\",\n } as SmeupDataObj;\n return column.obj?.t !== \"J4\" && !objectsIsVoCodVer(dataObject);\n });\n};\n\n/**\n * By passing the map, length value and column name\n * creates or updates a map record with\n * @param map Contains columnNames and their longest cell's length\n * @param text The text to use in length calculation\n * @param colName The column to check\n */\nexport const updateMaxValueLength = (\n map: { [key: string]: number },\n text: string | undefined | null,\n colName: string,\n) => {\n if (!map || !text || !colName) return;\n\n const value = Math.max(...text.split(\"\\n\").map(line => line.length));\n if (map[colName]) {\n if (map[colName] < value) {\n map[colName] = value;\n }\n } else {\n map[colName] = value;\n }\n};\n\nexport const filterRows = (\n smeupDataTable: SmeupDataTable,\n filteredColumns: SmeupDataColumn[],\n filters: { [key: string]: ColumnFilter },\n) => {\n if (filters) {\n return smeupDataTable.rows.filter(row => {\n return filteredColumns.every(col => {\n const cellValue = row.cells?.[col.name]?.value;\n const columnFilter = filters[col.name];\n if (columnFilter?.checkBoxes?.length) {\n const allowedValues = columnFilter.checkBoxes.map(item => item.value);\n return (\n typeof cellValue === \"string\" && allowedValues.includes(cellValue)\n );\n }\n return true;\n });\n });\n } else {\n return smeupDataTable.rows;\n }\n};\n\nexport const sortRows = (\n rows: SmeupDataRow[],\n sortObject: SortObject[],\n activeGroups?: string[],\n) => {\n const sort = sortObject?.[0];\n\n if (!sort && !activeGroups) {\n return;\n }\n\n if (!sort && activeGroups) {\n rows.sort((a, b) => {\n for (const group of activeGroups) {\n const valA = a.cells?.[group]?.value ?? \"\";\n const valB = b.cells?.[group]?.value ?? \"\";\n\n if (valA !== valB) {\n return valA.localeCompare(valB);\n }\n }\n return 0;\n });\n return;\n }\n\n rows.sort((a, b) => {\n const valA = a.cells?.[sort.column]?.value ?? \"\";\n const valB = b.cells?.[sort.column]?.value ?? \"\";\n\n switch (sort.sortMode) {\n case SortMode.A:\n if (valA !== valB) {\n return valA.localeCompare(valB);\n }\n return 0;\n case SortMode.D:\n if (valA !== valB) {\n return -valA.localeCompare(valB);\n }\n return 0;\n }\n });\n};\n\n/**\n * Returns a converted and formatted cell value (string, date, number)\n * @param cell - SmeupDataCell\n * @param bookType - SupportedExportFormats\n * @param webupManagerData - WebupManagerData\n * @returns\n */\nexport const calculateCellValue = (\n cell: SmeupDataCell,\n bookType: SupportedExportFormats,\n webupManagerData: WebupManagerData,\n) => {\n return calculateValue(\n cell.value,\n cell.obj ?? ({ t: \"\", p: \"\", k: \"\" } as SmeupDataObj),\n bookType,\n webupManagerData,\n );\n};\n\n/**\n * Calculates and formats a value based on its type and export format.\n *\n * - If the value is a date and the object indicates a date type, it returns a formatted date string or a Date object,\n * depending on the export format.\n * - If the value is a number and the object indicates a number type, it returns a formatted number string or a numeric value,\n * depending on the export format.\n * - Otherwise, it returns the original value or an empty string if the value is null or undefined.\n *\n * @param bookType - The export format type.\n * @param webupManagerData - Data containing locale and formatting information.\n * @param value - The value to be calculated and formatted.\n * @param obj - Optional object describing the type of the value.\n * @returns The formatted value, a Date object, a number, or the original value as a string.\n */\nexport const calculateValue = (\n value: string,\n obj: {\n t: string;\n p: string;\n k: string;\n },\n bookType: SupportedExportFormats,\n webupManagerData: WebupManagerData,\n) => {\n if (obj && objectsIsDate(obj) && datesIsIsoDate(value)) {\n return exportTypeSupportsFormatting[bookType]\n ? new Date(datesToDate(value, webupManagerData.datesLocale))\n : datesFormat(value, webupManagerData.datesLocale);\n }\n\n if (obj && objectsIsNumber(obj)) {\n if (!exportTypeSupportsFormatting[bookType]) {\n return (\n mathNumberStringToFormattedString(\n value,\n mathCountDecimals(Number(value) || 0),\n \"\",\n webupManagerData.mathLocale,\n ) || \"\"\n );\n }\n\n const numValue = Number(value);\n return !isNaN(numValue) && !(Math.abs(numValue) === Infinity)\n ? numValue\n : \"\";\n }\n\n return sanitizeString(value) ?? \"\";\n};\n\n/**\n * Conversion from Hexadecimal color to an AlphaRGB\n * @param hex string - Hexadecimal value, it can bot have and don't have the # prefix\n * @returns ARGB string code\n */\nexport const hexToArgb = (hex: string): string => {\n // Hex validation\n if (hex.startsWith(\"#\")) hex = hex.slice(1);\n if (hex.length !== 6) return \"\";\n\n // Value Parse and return\n const red = parseInt(hex.slice(0, 2), 16);\n const green = parseInt(hex.slice(2, 4), 16);\n const blue = parseInt(hex.slice(4, 6), 16);\n return `FF${red.toString(16).padStart(2, \"0\")}${green\n .toString(16)\n .padStart(2, \"0\")}${blue.toString(16).padStart(2, \"0\")}`;\n};\n\n// Utility function to detect if Buffer is available\nconst isBufferAvailable = (): boolean => {\n try {\n return typeof Buffer !== \"undefined\" && typeof Buffer.from === \"function\";\n } catch {\n return false;\n }\n};\n\n// Utility function to convert ArrayBuffer to Buffer or Uint8Array\nexport const convertToBuffer = (\n arrayBuffer: ArrayBuffer | Uint8Array,\n): Buffer | Uint8Array => {\n if (arrayBuffer instanceof Uint8Array) {\n return arrayBuffer;\n }\n if (isBufferAvailable()) {\n return Buffer.from(arrayBuffer);\n } else {\n return new Uint8Array(arrayBuffer);\n }\n};\n\n// Function to load an image as base64 (browser version, async)\nexport const loadImageAsBase64 = async (\n imageUrl: string,\n): Promise<string | null> => {\n try {\n const response = await fetch(imageUrl);\n if (!response.ok) return null;\n const blob = await response.blob();\n return await new Promise<string | null>((resolve, reject) => {\n const reader = new FileReader();\n reader.onloadend = () => {\n resolve(reader.result as string);\n };\n reader.onerror = () => reject(null);\n reader.readAsDataURL(blob);\n });\n } catch (error) {\n console.warn(\"Unable to load asset image:\", error);\n return null;\n }\n};\n\n/**\n * Converts a hexadecimal color string (e.g., \"#RRGGBB\" or \"0xRRGGBB\") to an RGB tuple.\n */\nexport const convertColorToRgb = (color: string): [number, number, number] => {\n const r = parseInt(color.substring(2, 4), 16);\n const g = parseInt(color.substring(4, 6), 16);\n const b = parseInt(color.substring(6, 8), 16);\n return [r, g, b];\n};\n"]}
@@ -0,0 +1,2 @@
1
+ import { SmeupDataColumn } from "../types/data-structures/smeupDataTable.js";
2
+ export declare const isColumnHidden: (column: SmeupDataColumn) => boolean;
@@ -0,0 +1,5 @@
1
+ export const isColumnHidden = (column) => {
2
+ return (Object.prototype.hasOwnProperty.call(column, "visible") &&
3
+ column.visible === false);
4
+ };
5
+ //# sourceMappingURL=datastructure-utility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datastructure-utility.js","sourceRoot":"","sources":["../../src/utils/datastructure-utility.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAuB,EAAW,EAAE;IACjE,OAAO,CACL,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC;QACvD,MAAM,CAAC,OAAO,KAAK,KAAK,CACzB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { SmeupDataColumn } from \"../types/data-structures/smeupDataTable.js\";\n\nexport const isColumnHidden = (column: SmeupDataColumn): boolean => {\n return (\n Object.prototype.hasOwnProperty.call(column, \"visible\") &&\n column.visible === false\n );\n};\n"]}
@@ -5,6 +5,15 @@ import "dayjs/locale/it.js";
5
5
  import "dayjs/locale/pl.js";
6
6
  import "dayjs/locale/ru.js";
7
7
  import "dayjs/locale/zh.js";
8
+ import ExcelJS from "exceljs";
8
9
  export declare const datesFormat: (input: dayjs.ConfigType, locale: string, format?: string) => string;
9
10
  export declare const datesIsIsoDate: (dateString: string) => boolean;
10
11
  export declare const datesToDate: (input: dayjs.ConfigType, locale: string, format?: string) => Date;
12
+ /**
13
+ * Checks if all ExcelJS.Cell values in the array are dates (ExcelJS.ValueType.Date).
14
+ * Accepts an array of ExcelJS.Cell and returns true if all are dates.
15
+ *
16
+ * @param values - Array of ExcelJS.Cell
17
+ * @returns true if all values are dates, false otherwise
18
+ */
19
+ export declare function areAllValuesDates(values: ExcelJS.Cell[]): boolean;
@@ -10,6 +10,7 @@ import "dayjs/locale/pl.js";
10
10
  import "dayjs/locale/ru.js";
11
11
  import "dayjs/locale/zh.js";
12
12
  import { DatesFormats } from "../types/index.js";
13
+ import ExcelJS from "exceljs";
13
14
  dayjs.extend(utc);
14
15
  dayjs.extend(customParseFormat);
15
16
  dayjs.extend(localizedFormat);
@@ -52,4 +53,21 @@ export const datesToDate = (input, locale, format) => {
52
53
  return _dayjs.utc(input).toDate();
53
54
  }
54
55
  };
56
+ /**
57
+ * Checks if all ExcelJS.Cell values in the array are dates (ExcelJS.ValueType.Date).
58
+ * Accepts an array of ExcelJS.Cell and returns true if all are dates.
59
+ *
60
+ * @param values - Array of ExcelJS.Cell
61
+ * @returns true if all values are dates, false otherwise
62
+ */
63
+ export function areAllValuesDates(values) {
64
+ const filteredValues = values.filter(cell => cell && cell.type && cell.value);
65
+ if (!Array.isArray(filteredValues) || filteredValues.length === 0)
66
+ return false;
67
+ return filteredValues.every(cell => {
68
+ if (!cell || typeof cell !== "object")
69
+ return false;
70
+ return cell.type === ExcelJS.ValueType.Date;
71
+ });
72
+ }
55
73
  //# sourceMappingURL=dates-utility.js.map
@@ -0,0 +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,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAClB,KAAK,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAChC,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;AAC9B,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAErB,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,KAAuB,EACvB,MAAc,EACd,MAAe,EACP,EAAE;IACV,MAAM,MAAM,GAAG,KAAK,CAAC;IACrB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,IAAI,CAAC,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C,KAAK,EAAE,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;IAC5C,CAAC;SAAM,CAAC;QACN,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;IACpC,CAAC;AACH,CAAC,CAAC;AAEF;;;;;;GAMG;AAEH,MAAM,UAAU,iBAAiB,CAAC,MAAsB;IACtD,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,IAAI,IAAI,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,OAAO,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.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"]}
@@ -0,0 +1,4 @@
1
+ import { WebupManagerData } from "../types/index.js";
2
+ export declare const formatDate: (date: Date, webupManagerData: WebupManagerData) => string;
3
+ export declare const formatNumber: (value: number, numFmt: string, webupManagerData: WebupManagerData) => string;
4
+ export declare const sanitizeString: (input: string) => string;
@@ -0,0 +1,41 @@
1
+ export const formatDate = (date, webupManagerData) => {
2
+ if (webupManagerData?.datesLocale === "it-IT" ||
3
+ webupManagerData?.datesLocale === "it") {
4
+ return date.toLocaleDateString("it-IT", {
5
+ day: "2-digit",
6
+ month: "2-digit",
7
+ year: "numeric",
8
+ });
9
+ }
10
+ else {
11
+ return date.toLocaleDateString("en-US", {
12
+ month: "2-digit",
13
+ day: "2-digit",
14
+ year: "numeric",
15
+ });
16
+ }
17
+ };
18
+ export const formatNumber = (value, numFmt, webupManagerData) => {
19
+ try {
20
+ const locale = webupManagerData?.mathLocale || "it-IT";
21
+ const positiveFmt = numFmt.split(";")[0] || numFmt;
22
+ const decimalMatch = positiveFmt.match(/\.(0+)/);
23
+ const decimals = decimalMatch ? decimalMatch[1].length : 0;
24
+ const formatter = new Intl.NumberFormat(locale, {
25
+ minimumFractionDigits: decimals,
26
+ maximumFractionDigits: decimals,
27
+ });
28
+ return formatter.format(value);
29
+ }
30
+ catch {
31
+ return value.toString();
32
+ }
33
+ };
34
+ export const sanitizeString = (input) => {
35
+ // Remove HTML tags and multiple spaces
36
+ return input
37
+ .replace(/<[^>]*>/g, " ")
38
+ .replace(/\s+/g, " ")
39
+ .trim();
40
+ };
41
+ //# sourceMappingURL=formatter-utility.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,7 @@
1
+ import type { jsPDFDocument } from "jspdf-autotable";
2
+ export declare const getLogoPositionAndDimension: (doc: jsPDFDocument, logo: string) => {
3
+ logoWidth: number;
4
+ logoHeight: number;
5
+ logoX: number;
6
+ logoY: number;
7
+ };
@@ -0,0 +1,32 @@
1
+ import sizeOf from "image-size";
2
+ export const getLogoPositionAndDimension = (doc, logo) => {
3
+ const pageWidth = doc.internal.pageSize.getWidth();
4
+ const logoHeight = 10; // Logo height in mm
5
+ const logoWidth = calcAutoWidth(logo, logoHeight); // Logo width in mm
6
+ const logoX = pageWidth - logoWidth - 10; // 10mm from the right margin
7
+ const logoY = 5; // 5mm from the top margin
8
+ return {
9
+ logoWidth,
10
+ logoHeight,
11
+ logoX,
12
+ logoY,
13
+ };
14
+ };
15
+ const calcAutoWidth = (imageData, desiredHeight) => {
16
+ try {
17
+ const binaryString = atob(imageData);
18
+ const buffer = new Uint8Array(binaryString.length);
19
+ for (let i = 0; i < binaryString.length; i++) {
20
+ buffer[i] = binaryString.charCodeAt(i);
21
+ }
22
+ const dimensions = sizeOf(buffer);
23
+ const aspectRatio = dimensions.width / dimensions.height;
24
+ const calculatedWidth = desiredHeight * aspectRatio;
25
+ return calculatedWidth;
26
+ }
27
+ catch (error) {
28
+ console.warn("Error calculating auto width:", error);
29
+ return 50;
30
+ }
31
+ };
32
+ //# sourceMappingURL=image-utils.js.map
@@ -0,0 +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"]}
@@ -8,3 +8,4 @@ export declare const mathGroupSeparator: (locale: string) => string;
8
8
  export declare const mathFormat: (input: string | number, locale: string, format?: string, inputIsLocalized?: boolean) => string;
9
9
  export declare const mathCreateFormatPattern: (thousandPoint?: boolean, decimals?: number) => string;
10
10
  export declare const mathGetNumericValueSuffix: (type: string) => string;
11
+ export declare const calculateExpression: (expression: string) => number | string;