@massimo-cassandro/minimo 1.7.1 → 1.8.0

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 (123) hide show
  1. package/design-tokens/tokens/size.minimo.tokens.jsonc +16 -16
  2. package/index.js +4 -2
  3. package/package.json +1 -1
  4. package/src/components/TODO form-multiselect/form-multiselect.css +40 -0
  5. package/src/components/TODO form-multiselect/form-multiselect.js +83 -0
  6. package/src/components/TODO vanilla-cookie-consent/cookie-consent.css +20 -0
  7. package/src/components/TODO vanilla-cookie-consent/cookie-consent.js +76 -0
  8. package/src/components/TODO vanilla-cookie-consent/render-cookie-list.js +32 -0
  9. package/src/components/TODO vanilla-cookie-consent/src/cookie-list.js +85 -0
  10. package/src/components/TODO vanilla-cookie-consent/src/it-translation.js +38 -0
  11. package/src/components/TODO vanilla-cookie-consent/src/run-analytics.js +54 -0
  12. package/src/components/TODO vanilla-cookie-consent/src/run-recaptcha.js +71 -0
  13. package/src/components/modal-alert/TODO modal-alert-demo/demo.css +63 -0
  14. package/src/components/modal-alert/TODO modal-alert-demo/demo.js +155 -0
  15. package/src/components/modal-popup/modal-popup.js +2 -1
  16. package/src/components/slide-up-down-toggle/slide-up-down-toggle.js +246 -0
  17. package/src/components/slide-up-down-toggle/slide-up-down-toggle.module.css +97 -0
  18. package/src/components/snackbar/snackbar.js +2 -1
  19. package/src/components/spinner/spinner.js +2 -1
  20. package/src/components/unsplash-page/TODO unsplash-page-demo/README.md +194 -0
  21. package/src/components/unsplash-page/TODO unsplash-page-demo/changelog.md +5 -0
  22. package/src/components/unsplash-page/TODO unsplash-page-demo/unsplash-page/demo.js +15 -0
  23. package/src/components/unsplash-page/TODO unsplash-page-demo/unsplash-page/rollup.config.mjs +26 -0
  24. package/src/components/unsplash-page/TODO unsplash-page-demo/unsplash-page/unsplash-page-demo.min.js +3 -0
  25. package/src/utilities/generate-pwd.js +22 -0
  26. package/src/web-components/TODO json-table/README.md +67 -0
  27. package/src/web-components/TODO json-table/TODO.md +12 -0
  28. package/src/web-components/TODO json-table/_work/OLD/docs/custom-props-list.md +69 -0
  29. package/src/web-components/TODO json-table/_work/OLD/script/create-css-custom-props-doc.mjs +113 -0
  30. package/src/web-components/TODO json-table/_work/OLD/script/src/custom-props-end.md +4 -0
  31. package/src/web-components/TODO json-table/_work/OLD/script/src/custom-props-start.md +30 -0
  32. package/src/web-components/TODO json-table/_work/OLD/src/css/icons.module.css +22 -0
  33. package/src/web-components/TODO json-table/_work/OLD/src/css/info.module.css +42 -0
  34. package/src/web-components/TODO json-table/_work/OLD/src/css/main-wrapper.module.css +4 -0
  35. package/src/web-components/TODO json-table/_work/OLD/src/css/table.module.css +154 -0
  36. package/src/web-components/TODO json-table/_work/OLD/src/css/utility.module.css +9 -0
  37. package/src/web-components/TODO json-table/_work/OLD/src/icons/false.svg +1 -0
  38. package/src/web-components/TODO json-table/_work/OLD/src/icons/search-arrows.svg +1 -0
  39. package/src/web-components/TODO json-table/_work/OLD/src/icons/true.svg +1 -0
  40. package/src/web-components/TODO json-table/_work/OLD/src/index.js +56 -0
  41. package/src/web-components/TODO json-table/_work/OLD/src/js/default-columns-data-types.js +172 -0
  42. package/src/web-components/TODO json-table/_work/OLD/src/js/defaults.js +156 -0
  43. package/src/web-components/TODO json-table/_work/OLD/src/js/info-section.js +31 -0
  44. package/src/web-components/TODO json-table/_work/OLD/src/js/listeners.js +17 -0
  45. package/src/web-components/TODO json-table/_work/OLD/src/js/main-builder.js +26 -0
  46. package/src/web-components/TODO json-table/_work/OLD/src/js/parse-params.js +121 -0
  47. package/src/web-components/TODO json-table/_work/OLD/src/js/set-column-classname.js +22 -0
  48. package/src/web-components/TODO json-table/_work/OLD/src/js/table-builder.js +64 -0
  49. package/src/web-components/TODO json-table/_work/OLD/src/js/table-foot.js +8 -0
  50. package/src/web-components/TODO json-table/_work/OLD/src/js/table-head.js +47 -0
  51. package/src/web-components/TODO json-table/_work/OLD/src/js/table-row.js +83 -0
  52. package/src/web-components/TODO json-table/_work/OLD/src/js/utilities.js +5 -0
  53. package/src/web-components/TODO json-table/_work/__json-table-react/index.js +4 -0
  54. package/src/web-components/TODO json-table/_work/__json-table-react/src/build-page-array.js +73 -0
  55. package/src/web-components/TODO json-table/_work/__json-table-react/src/columns-data-types.js +73 -0
  56. package/src/web-components/TODO json-table/_work/__json-table-react/src/defaults.js +50 -0
  57. package/src/web-components/TODO json-table/_work/__json-table-react/src/download-excel.js +156 -0
  58. package/src/web-components/TODO json-table/_work/__json-table-react/src/set-className.js +19 -0
  59. package/src/web-components/TODO json-table/_work/__json-table-react/src/set-download-filename.js +17 -0
  60. package/src/web-components/TODO json-table/_work/__json-table-react/src/table-to-csv.js +48 -0
  61. package/src/web-components/TODO json-table/_work/archived/table-to-csv.js +48 -0
  62. package/src/web-components/TODO json-table/_work/arrow.svg +3 -0
  63. package/src/web-components/TODO json-table/_work/da decidere/get-cell-data.js +18 -0
  64. package/src/web-components/TODO json-table/_work/download-button.js +29 -0
  65. package/src/web-components/TODO json-table/_work/download-excel.js +155 -0
  66. package/src/web-components/TODO json-table/_work/pagination-array-builder.js +73 -0
  67. package/src/web-components/TODO json-table/_work/pagination.js +37 -0
  68. package/src/web-components/TODO json-table/_work/set-download-filename.js +19 -0
  69. package/src/web-components/TODO json-table/_work/table-info.js +24 -0
  70. package/src/web-components/TODO json-table/demo/README.md +66 -0
  71. package/src/web-components/TODO json-table/demo/assets/link-simple.svg +1 -0
  72. package/src/web-components/TODO json-table/demo/demo-data/json-static-table-demo-data.js +512 -0
  73. package/src/web-components/TODO json-table/demo/demo.css +32 -0
  74. package/src/web-components/TODO json-table/demo/demo.js +24 -0
  75. package/src/web-components/TODO json-table/demo/js/demo-ajax-table.js +165 -0
  76. package/src/web-components/TODO json-table/demo/js/demo-static-table.js +180 -0
  77. package/src/web-components/TODO json-table/demo/webpack-modules/css-rules.mjs +122 -0
  78. package/src/web-components/TODO json-table/demo/webpack-modules/get-jsConfig-aliases.mjs +33 -0
  79. package/src/web-components/TODO json-table/demo/webpack-modules/svg-rules.mjs +108 -0
  80. package/src/web-components/TODO json-table/demo/webpack-modules/svgo.config.mjs +26 -0
  81. package/src/web-components/TODO json-table/demo/webpack.config.mjs +333 -0
  82. package/src/web-components/TODO json-table/docs/custom-props-list.md +74 -0
  83. package/src/web-components/TODO json-table/docs-builder/create-css-custom-props-doc.mjs +157 -0
  84. package/src/web-components/TODO json-table/docs-builder/src/custom-props-end.md +6 -0
  85. package/src/web-components/TODO json-table/docs-builder/src/custom-props-start.md +29 -0
  86. package/src/web-components/TODO json-table/src/TODO.md +1 -0
  87. package/src/web-components/TODO json-table/src/__json-table-react/build-page-array.js +73 -0
  88. package/src/web-components/TODO json-table/src/__json-table-react/columns-data-types.js +73 -0
  89. package/src/web-components/TODO json-table/src/__json-table-react/defaults.js +50 -0
  90. package/src/web-components/TODO json-table/src/__json-table-react/download-excel.js +156 -0
  91. package/src/web-components/TODO json-table/src/__json-table-react/set-className.js +19 -0
  92. package/src/web-components/TODO json-table/src/__json-table-react/set-download-filename.js +17 -0
  93. package/src/web-components/TODO json-table/src/__json-table-react/table-to-csv.js +48 -0
  94. package/src/web-components/TODO json-table/src/css/custom-media.css +16 -0
  95. package/src/web-components/TODO json-table/src/css/icons.module.css +22 -0
  96. package/src/web-components/TODO json-table/src/css/info-section.module.css +78 -0
  97. package/src/web-components/TODO json-table/src/css/main-builder.module.css +6 -0
  98. package/src/web-components/TODO json-table/src/css/table.module.css +172 -0
  99. package/src/web-components/TODO json-table/src/css/utility.module.css +9 -0
  100. package/src/web-components/TODO json-table/src/icons/arrow-down-bold.svg +1 -0
  101. package/src/web-components/TODO json-table/src/icons/false.svg +1 -0
  102. package/src/web-components/TODO json-table/src/icons/true.svg +1 -0
  103. package/src/web-components/TODO json-table/src/index.js +125 -0
  104. package/src/web-components/TODO json-table/src/js/default-columns-data-types.js +172 -0
  105. package/src/web-components/TODO json-table/src/js/defaults.js +510 -0
  106. package/src/web-components/TODO json-table/src/js/get-ajax-data.js +72 -0
  107. package/src/web-components/TODO json-table/src/js/info-section.js +39 -0
  108. package/src/web-components/TODO json-table/src/js/init-ajax-table.js +30 -0
  109. package/src/web-components/TODO json-table/src/js/init-static-table.js +18 -0
  110. package/src/web-components/TODO json-table/src/js/main-builder.js +87 -0
  111. package/src/web-components/TODO json-table/src/js/parse-data-row.js +123 -0
  112. package/src/web-components/TODO json-table/src/js/parse-params.js +118 -0
  113. package/src/web-components/TODO json-table/src/js/set-search-listener.js +62 -0
  114. package/src/web-components/TODO json-table/src/js/set-sort-listeners.js +115 -0
  115. package/src/web-components/TODO json-table/src/js/static-data-sorting.js +23 -0
  116. package/src/web-components/TODO json-table/src/js/table-builder.js +45 -0
  117. package/src/web-components/TODO json-table/src/js/table-row.js +43 -0
  118. package/src/web-components/TODO json-table/src/js/table-tfoot.js +9 -0
  119. package/src/web-components/TODO json-table/src/js/table-thead.js +91 -0
  120. package/src/web-components/TODO json-table/src/js/update-info.js +42 -0
  121. package/src/web-components/TODO json-table/src/js/utilities.js +5 -0
  122. package/src/web-components/s-datatable-component/s-datatable-component.js +2 -1
  123. package/src/web-components/s-datatable-component/src/parse-cols.js +2 -1
@@ -0,0 +1,156 @@
1
+ // genera un json ottimizzato per l'esportazione in xslx partendo
2
+ // dai dati assegnati alla tabella
3
+
4
+ // import {data_types} from './columns-data-types';
5
+ import setDownloadFilename from './set-download-filename';
6
+ import { utils as utilsXSLX, writeFileXLSX } from 'xlsx/xlsx.mjs';
7
+
8
+
9
+ export default function (params) {
10
+
11
+
12
+ function excel_sheet(columns, data) {
13
+
14
+ let excel_data = [];
15
+
16
+ const parser = new DOMParser();
17
+ excel_data.push(columns.map(item => {
18
+
19
+ const tit = parser.parseFromString(item.title, 'text/html');
20
+ return tit.documentElement.textContent;
21
+ }));
22
+
23
+ // https://www.codegrepper.com/code-examples/javascript/javascript+convert+number+to+letter+of+alphabet
24
+ // https://docs.sheetjs.com/docs/csf/features/formulae
25
+ // function numToSSColumnLetter(num) {
26
+ // let columnLetter = "",
27
+ // t;
28
+
29
+ // while (num > 0) {
30
+ // t = (num - 1) % 26;
31
+ // columnLetter = String.fromCharCode(65 + t) + columnLetter;
32
+ // num = (num - t) / 26 | 0;
33
+ // }
34
+ // return columnLetter || undefined;
35
+ // }
36
+
37
+ let values_lengths = {};
38
+
39
+ data.forEach(row => {
40
+ let excel_row = [];
41
+
42
+ columns.forEach(col => {
43
+ let cell_value;
44
+ if(col.parse && typeof col.parse === 'function') {
45
+ cell_value = col.parse(row);
46
+ } else {
47
+ cell_value = row[col.key];
48
+ }
49
+ values_lengths[col.key] = Math.max(values_lengths[col.key]?? 0, String(cell_value).length);
50
+
51
+
52
+ // https://docs.sheetjs.com/docs/csf/cell
53
+ // https://docs.sheetjs.com/docs/csf/features/#number-formats
54
+ // https://support.microsoft.com/it-it/office/codici-del-formato-numerico-5026bbd6-04bc-48cd-bf33-80f18b4eae68
55
+ let cell_obj;
56
+ switch (col.dataType) {
57
+ case 'date':
58
+ cell_obj = {
59
+ v: cell_value? new Date(cell_value).toISOString() : undefined,
60
+ t: 'd',
61
+ z: 'd-mmm-yyyy'
62
+ };
63
+ break;
64
+ case 'datetime':
65
+ cell_obj = {
66
+ v: cell_value? new Date(cell_value).toISOString() : undefined,
67
+ t: 'd',
68
+ z: 'd-mmm-yyyy hh:mm'
69
+ };
70
+ break;
71
+ case 'num':
72
+ cell_obj = {
73
+ v: cell_value? +cell_value : 0,
74
+ t: 'n',
75
+ z: '#,##0.00'
76
+ };
77
+ break;
78
+ case 'perc':
79
+ cell_obj = {
80
+ v: (cell_value? +cell_value : 0)/100,
81
+ t: 'n',
82
+ z: '#,##0.00%'
83
+ };
84
+ break;
85
+ case 'percDecimal':
86
+ cell_obj = {
87
+ v: cell_value? +cell_value : 0,
88
+ t: 'n',
89
+ z: '#,##0.00%'
90
+ };
91
+ break;
92
+ case 'euro':
93
+ cell_obj = {
94
+ v: cell_value? +cell_value : 0,
95
+ t: 'n',
96
+ z: '"€"\ #,##0.00' // eslint-disable-line no-useless-escape
97
+ };
98
+ break;
99
+
100
+ default:
101
+ cell_obj = {
102
+ v: cell_value,
103
+ t: 's'
104
+ };
105
+ break;
106
+ }
107
+
108
+ excel_row.push(cell_obj);
109
+ });
110
+ excel_data.push(excel_row);
111
+ });
112
+
113
+ let ws = utilsXSLX.aoa_to_sheet(excel_data); // worksheet
114
+ // larghezza colonne
115
+ ws['!cols'] = [];
116
+ columns.forEach(col => {
117
+ ws['!cols'].push({ wch: values_lengths[col.key] + 4 });
118
+ });
119
+
120
+ return ws;
121
+
122
+ }
123
+
124
+ function setSheetName(str) {
125
+ if(str.length > 31) {
126
+ return str.substring(0, 27) + '...';
127
+ }
128
+
129
+ return str;
130
+ }
131
+
132
+ let wb = utilsXSLX.book_new(); // workbook
133
+
134
+ utilsXSLX.book_append_sheet(
135
+ wb,
136
+ excel_sheet(params.columns, params.data),
137
+ setSheetName(params.downloadFilename)
138
+ );
139
+
140
+ if(params.extraDownloadSheets) {
141
+ params.extraDownloadSheets.forEach(item => {
142
+
143
+ utilsXSLX.book_append_sheet(
144
+ wb,
145
+ utilsXSLX.aoa_to_sheet(item.data),
146
+ setSheetName(item.name)
147
+ );
148
+ });
149
+ }
150
+
151
+ const filename = setDownloadFilename(params.downloadFilename, params.downloadFormat);
152
+ writeFileXLSX(wb, filename, {
153
+ bookType: 'xlsx',
154
+ cellDates: true
155
+ });
156
+ }
@@ -0,0 +1,19 @@
1
+ // Restituisce la stringa delle classi per la colonna data
2
+ import {data_types} from './columns-data-types';
3
+
4
+ export default function setClassName(col, addFormatClass = true) {
5
+ if(col.className) {
6
+ return col.className;
7
+ }
8
+
9
+ if(col.dataType) {
10
+
11
+ return [
12
+ ...(data_types[col.dataType]?.className? [data_types[col.dataType]?.className] : []),
13
+ ...(addFormatClass? [data_types[col.dataType]?.formatClassName] : [])
14
+ ].join(' ');
15
+
16
+ } else {
17
+ return null;
18
+ }
19
+ }
@@ -0,0 +1,17 @@
1
+ import {defaults} from './defaults';
2
+ export default function setDownloadFilename(str, format = 'excel') {
3
+ const ext = format.toLowerCase() === 'excel'? 'xlsx' : 'csv';
4
+ if(str) {
5
+ str = str
6
+ .replace(/(\.csv)$/, '')
7
+ .replace(/(\.xslx?)$/, '')
8
+ .replace(/[/:]/g, '-')
9
+ .replace(/-+/g, '-')
10
+ .replace(/^-/, '')
11
+ .replace(/-$/, '');
12
+
13
+ return str + ' [' + new Date().toISOString().split('T')[0] + `].${ext}`;
14
+ }
15
+
16
+ return defaults.downloadFilename;
17
+ }
@@ -0,0 +1,48 @@
1
+ export default function (tableEl, zeroValuesChar = null) {
2
+
3
+ const normalize = str => {
4
+ let is_number = !isNaN(parseFloat(str));
5
+
6
+ str = str.replace(/;/g, '').replace(/"/g, '""');
7
+ if(is_number) {
8
+ str = str.replace(/\./g, ''); // sep migliaia
9
+ }
10
+ return str;
11
+ };
12
+
13
+ try {
14
+ if(!tableEl) {
15
+ throw new Error( 'table element not present' );
16
+ }
17
+
18
+ // table to array
19
+ let download_array = [];
20
+ tableEl.querySelectorAll('tr').forEach(row => {
21
+ let rowArray = [];
22
+
23
+ row.querySelectorAll('th, td').forEach(item => {
24
+ rowArray.push(normalize(item.innerText));
25
+ });
26
+
27
+ download_array.push(rowArray.join(';'));
28
+ });
29
+
30
+ let csv = download_array.join('\n');
31
+
32
+ if(zeroValuesChar) {
33
+ csv = csv.replaceAll(zeroValuesChar, 0);
34
+ }
35
+
36
+ return csv;
37
+
38
+ // const url = new Blob([download_array.join('\n')], { type: 'text/csv;charset=utf-8;' });
39
+
40
+ // return URL.createObjectURL(url);
41
+
42
+ } catch(e) {
43
+ console.error( e ); // eslint-disable-line
44
+ }
45
+
46
+ }
47
+
48
+
@@ -0,0 +1,48 @@
1
+ export default function (tableEl, zeroAltChar = null) {
2
+
3
+ const normalize = str => {
4
+ let is_number = !isNaN(parseFloat(str));
5
+
6
+ str = str.replace(/;/g, '').replace(/"/g, '""');
7
+ if(is_number) {
8
+ str = str.replace(/\./g, ''); // sep migliaia
9
+ }
10
+ return str;
11
+ };
12
+
13
+ try {
14
+ if(!tableEl) {
15
+ throw new Error( 'table element not present' );
16
+ }
17
+
18
+ // table to array
19
+ let download_array = [];
20
+ tableEl.querySelectorAll('tr').forEach(row => {
21
+ let rowArray = [];
22
+
23
+ row.querySelectorAll('th, td').forEach(item => {
24
+ rowArray.push(normalize(item.innerText));
25
+ });
26
+
27
+ download_array.push(rowArray.join(';'));
28
+ });
29
+
30
+ let csv = download_array.join('\n');
31
+
32
+ if(zeroAltChar) {
33
+ csv = csv.replaceAll(zeroAltChar, 0);
34
+ }
35
+
36
+ return csv;
37
+
38
+ // const url = new Blob([download_array.join('\n')], { type: 'text/csv;charset=utf-8;' });
39
+
40
+ // return URL.createObjectURL(url);
41
+
42
+ } catch(e) {
43
+ console.error( e ); // eslint-disable-line
44
+ }
45
+
46
+ }
47
+
48
+
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="8">
2
+ <path fill="#D8D8D8" fill-rule="evenodd" d="M0 0L16 0 7.959 8z" />
3
+ </svg>
@@ -0,0 +1,18 @@
1
+ // conviene questa strada o è più efficiente continuare a usare gli attributi data-*?
2
+
3
+
4
+ /**
5
+ * Gets the original value and parameters of a static (non-ajax) table cell.
6
+ */
7
+
8
+ export function getCellData(jtId, cell_key){
9
+ const rowData = this.params.data.filter(row => row.jtId === +jtId)?.[0]?? null,
10
+ colParams = this.params.columns.filter(col => col.key === cell_key)?.[0]?? null,
11
+ dataType = this.params.dataTypes[colParams?.dataType]?? null;
12
+
13
+ return {
14
+ data: rowData,
15
+ colParams: colParams,
16
+ dataType: dataType
17
+ };
18
+ }
@@ -0,0 +1,29 @@
1
+ const setDownloadFilename = str => {
2
+ str = str
3
+ .replace(/(\.csv)$/, '')
4
+ .replace(/[/:]/g, '-')
5
+ .replace(/-+/g, '-')
6
+ .replace(/^-/, '')
7
+ .replace(/-$/, '');
8
+
9
+ return str + ' [' + new Date().toISOString().split('T')[0] + '].csv';
10
+ };
11
+ let downloadBtn = '';
12
+ if(params.showDownloadBtn) {
13
+ const btn_id = table_id + '-dwnld-btn';
14
+ downloadBtn =
15
+ `<div class="${params.rightAlignClassName}">
16
+ <button type="button"
17
+ id="${btn_id}"
18
+ class="${params.downloadBtnClassName}"
19
+ >${params.downloadBtnLabel}</button>
20
+ </div>`;
21
+
22
+ document.body.addEventListener('click', e => {
23
+ if(e.target.id === btn_id) {
24
+
25
+ downloadExcel(params);
26
+
27
+ }
28
+ }, false);
29
+ }
@@ -0,0 +1,155 @@
1
+ // genera un json ottimizzato per l'esportazione in xslx partendo
2
+ // dai dati assegnati alla tabella
3
+
4
+ // import {data_types} from './columns-data-types';
5
+ import setDownloadFilename from '../js/set-download-filename';
6
+ import { utils as utilsXSLX, writeFileXLSX } from 'xlsx/xlsx.mjs';
7
+
8
+ export default function (params) {
9
+
10
+
11
+ function excel_sheet(columns, data) {
12
+
13
+ let excel_data = [];
14
+
15
+ const parser = new DOMParser();
16
+ excel_data.push(columns.map(item => {
17
+
18
+ const tit = parser.parseFromString(item.title, 'text/html');
19
+ return tit.documentElement.textContent;
20
+ }));
21
+
22
+ // https://www.codegrepper.com/code-examples/javascript/javascript+convert+number+to+letter+of+alphabet
23
+ // https://docs.sheetjs.com/docs/csf/features/formulae
24
+ // function numToSSColumnLetter(num) {
25
+ // let columnLetter = "",
26
+ // t;
27
+
28
+ // while (num > 0) {
29
+ // t = (num - 1) % 26;
30
+ // columnLetter = String.fromCharCode(65 + t) + columnLetter;
31
+ // num = (num - t) / 26 | 0;
32
+ // }
33
+ // return columnLetter || undefined;
34
+ // }
35
+
36
+ let values_lengths = {};
37
+
38
+ data.forEach(row => {
39
+ let excel_row = [];
40
+
41
+ columns.forEach(col => {
42
+ let cell_value;
43
+ if(col.parse && typeof col.parse === 'function') {
44
+ cell_value = col.parse(row);
45
+ } else {
46
+ cell_value = row[col.key];
47
+ }
48
+ values_lengths[col.key] = Math.max(values_lengths[col.key]?? 0, String(cell_value).length);
49
+
50
+
51
+ // https://docs.sheetjs.com/docs/csf/cell
52
+ // https://docs.sheetjs.com/docs/csf/features/#number-formats
53
+ // https://support.microsoft.com/it-it/office/codici-del-formato-numerico-5026bbd6-04bc-48cd-bf33-80f18b4eae68
54
+ let cell_obj;
55
+ switch (col.dataType) {
56
+ case 'date':
57
+ cell_obj = {
58
+ v: cell_value? new Date(cell_value).toISOString() : undefined,
59
+ t: 'd',
60
+ z: 'd-mmm-yyyy'
61
+ };
62
+ break;
63
+ case 'datetime':
64
+ cell_obj = {
65
+ v: cell_value? new Date(cell_value).toISOString() : undefined,
66
+ t: 'd',
67
+ z: 'd-mmm-yyyy hh:mm'
68
+ };
69
+ break;
70
+ case 'num':
71
+ cell_obj = {
72
+ v: cell_value? +cell_value : 0,
73
+ t: 'n',
74
+ z: '#,##0.00'
75
+ };
76
+ break;
77
+ case 'perc':
78
+ cell_obj = {
79
+ v: (cell_value? +cell_value : 0)/100,
80
+ t: 'n',
81
+ z: '#,##0.00%'
82
+ };
83
+ break;
84
+ case 'percDecimal':
85
+ cell_obj = {
86
+ v: cell_value? +cell_value : 0,
87
+ t: 'n',
88
+ z: '#,##0.00%'
89
+ };
90
+ break;
91
+ case 'euro':
92
+ cell_obj = {
93
+ v: cell_value? +cell_value : 0,
94
+ t: 'n',
95
+ z: '"€"\ #,##0.00' // eslint-disable-line no-useless-escape
96
+ };
97
+ break;
98
+
99
+ default:
100
+ cell_obj = {
101
+ v: cell_value,
102
+ t: 's'
103
+ };
104
+ break;
105
+ }
106
+
107
+ excel_row.push(cell_obj);
108
+ });
109
+ excel_data.push(excel_row);
110
+ });
111
+
112
+ let ws = utilsXSLX.aoa_to_sheet(excel_data); // worksheet
113
+ // larghezza colonne
114
+ ws['!cols'] = [];
115
+ columns.forEach(col => {
116
+ ws['!cols'].push({ wch: values_lengths[col.key] + 4 });
117
+ });
118
+
119
+ return ws;
120
+
121
+ }
122
+
123
+ function setSheetName(str) {
124
+ if(str.length > 31) {
125
+ return str.substring(0, 27) + '...';
126
+ }
127
+
128
+ return str;
129
+ }
130
+
131
+ let wb = utilsXSLX.book_new(); // workbook
132
+
133
+ utilsXSLX.book_append_sheet(
134
+ wb,
135
+ excel_sheet(params.columns, params.data),
136
+ setSheetName(params.downloadFilename)
137
+ );
138
+
139
+ if(params.extraDownloadSheets) {
140
+ params.extraDownloadSheets.forEach(item => {
141
+
142
+ utilsXSLX.book_append_sheet(
143
+ wb,
144
+ utilsXSLX.aoa_to_sheet(item.data),
145
+ setSheetName(item.name)
146
+ );
147
+ });
148
+ }
149
+
150
+ const filename = setDownloadFilename(params.downloadFilename, params.downloadFormat);
151
+ writeFileXLSX(wb, filename, {
152
+ bookType: 'xlsx',
153
+ cellDates: true
154
+ });
155
+ }
@@ -0,0 +1,73 @@
1
+ export function calcTotPages(records, pageRows) {
2
+ return Math.ceil(records / pageRows);
3
+ }
4
+
5
+ export default function (currentPage, pageRows, records, showed_pages = 11) {
6
+
7
+
8
+ const pages = calcTotPages(records, pageRows);
9
+
10
+ let pages_array = [];
11
+
12
+ if (pages <= showed_pages) {
13
+ pages_array = [...Array(pages).fill().map((_, idx) => idx + 1)];
14
+
15
+ } else {
16
+
17
+
18
+ let side_pages = 2, // pagine a dx/sx della pagina corrente
19
+
20
+ step_min = Math.max(1, currentPage - side_pages),
21
+ step_max = Math.min(pages, currentPage + side_pages),
22
+
23
+ // spazi aggiuntibi a dx/sx da lasciare liberi per '1', '...', <pages>
24
+ slots_left = step_min > 2? 2 : step_min - 1,
25
+ slots_right = step_max < pages - 1? 2 : pages - step_max;
26
+
27
+ // console.log(step_min, step_max, slots_left, slots_right);
28
+ // console.log(step_max - step_min + 1 + slots_left + slots_right);
29
+
30
+ // fix per avere sempre il numero prefissato di pagine
31
+ while (step_max - step_min + 1 + slots_left + slots_right < showed_pages) {
32
+ step_min = Math.max(1, step_min - 1);
33
+ step_max = Math.min(pages, step_max + 1);
34
+
35
+ }
36
+
37
+ // console.log(step_max - step_min + 1 + slots_left + slots_right);
38
+
39
+ // if(step_max - step_min + 1 + slots_left + slots_right > showed_pages) {
40
+ // step_min++;
41
+ // }
42
+
43
+ pages_array = [
44
+ ...Array(step_max - step_min + 1)
45
+ .fill()
46
+ .map((_, idx) => step_min + idx)
47
+ ];
48
+
49
+ // console.log(pages_array.slice(0));
50
+
51
+ if(pages_array[0] === 2) {
52
+ pages_array.unshift(1);
53
+
54
+ } else if (pages_array[0] === 3) {
55
+ pages_array.unshift(1, 2);
56
+
57
+ } else if (pages_array[0] > 3) {
58
+ pages_array.unshift(1, null);
59
+ }
60
+
61
+ if(pages_array.at(-1) === pages - 1) {
62
+ pages_array.push(pages);
63
+
64
+ } else if(pages_array.at(-1) === pages - 2) {
65
+ pages_array.push(pages -1, pages);
66
+
67
+ } else if(pages_array.at(-1) < pages - 2) {
68
+ pages_array.push(null, pages);
69
+ }
70
+ }
71
+
72
+ return pages_array;
73
+ }
@@ -0,0 +1,37 @@
1
+ export default function () {
2
+
3
+ if(jsonData?.recordsFiltered) {
4
+
5
+ const page_array = build_page_array(currentPage, props.pageRows, jsonData.recordsFiltered);
6
+
7
+ return (
8
+ <nav id={navBarId} aria-label="Navigazione pagine" className={styles.paginationNav}>
9
+ <ul>
10
+ {page_array.map((pag, i) => {
11
+ let content;
12
+
13
+ if(pag === currentPage) {
14
+ content = <span className={styles.selected}>{pag}</span>;
15
+
16
+ } else if (pag !== null) {
17
+ content = <button
18
+ type="button"
19
+ title={`Vai a pagina ${pag}`}
20
+ onClick={ e => {
21
+ setLoadingOffsetTop(e.target.offsetTop);
22
+ updateUrl(pag);
23
+ }}
24
+ >{pag}</button>;
25
+
26
+ } else {
27
+ content = <span>&hellip;</span>;
28
+ }
29
+
30
+ return <li key={i}>{content}</li>;
31
+ })}
32
+ </ul>
33
+ </nav>
34
+ );
35
+ }
36
+
37
+ }
@@ -0,0 +1,19 @@
1
+ import {defaults} from '../js/defaults';
2
+
3
+ export default function setDownloadFilename(str, format = 'excel') {
4
+
5
+ const ext = format.toLowerCase() === 'excel'? 'xlsx' : 'csv';
6
+ if(str) {
7
+ str = str
8
+ .replace(/(\.csv)$/, '')
9
+ .replace(/(\.xslx?)$/, '')
10
+ .replace(/[/:]/g, '-')
11
+ .replace(/-+/g, '-')
12
+ .replace(/^-/, '')
13
+ .replace(/-$/, '');
14
+
15
+ return str + ' [' + new Date().toISOString().split('T')[0] + `].${ext}`;
16
+ }
17
+
18
+ return defaults.downloadFilename;
19
+ }
@@ -0,0 +1,24 @@
1
+ export default function () {
2
+ updateTableInfo(<>
3
+ {(+jsonData.recordsFiltered).toLocaleString('it-IT', {
4
+ minimumFractionDigits: 0,
5
+ maximumFractionDigits: 0
6
+ })} record trovati
7
+ {jsonData.recordsFiltered < jsonData.recordsTotal?
8
+ ` (su un totale di ${(+jsonData.recordsTotal).toLocaleString('it-IT', {
9
+ minimumFractionDigits: 0,
10
+ maximumFractionDigits: 0
11
+ })})`
12
+ : ''}
13
+ <br />
14
+ <a href={`#${navBarId}`} title="Vai alla navigazione delle pagine"
15
+ onClick={e => {
16
+ e.preventDefault();
17
+ container?.current?.scrollIntoView({behavior: 'smooth', block: 'end', inline: 'end'});
18
+ }}
19
+ >
20
+ Pagina <strong>{currentPage}</strong> di <strong>{calcTotPages(jsonData.recordsFiltered, props.pageRows)}</strong>
21
+ </a>
22
+
23
+ </>);
24
+ }