@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,165 @@
1
+ /* eslint-disable no-console */
2
+ import jsonTable from '@src/index.js';
3
+
4
+ const container = document.getElementById('ajax-table-demo');
5
+
6
+ // Register listener BEFORE instantiation so it can catch the event
7
+ // TODO verificare funzionamento
8
+ container.addEventListener('jt:ready', e => {
9
+ console.log('Static table ready');
10
+ console.log(e.detail);
11
+ });
12
+
13
+ new jsonTable(
14
+ // params
15
+ {
16
+ debug: true,
17
+ container: container,
18
+ useZeroAltChar: false,
19
+
20
+ // true: => use the standard parameters (similar to datatable ones), object: customize parameters
21
+ // see ajax_config_default in `src/js/defaults.js`
22
+ ajax: {
23
+
24
+ // https://github.com/typicode/json-server
25
+ urlParams: {
26
+ startItem: `_page`,
27
+ perPage : '_per_page',
28
+ // TODO search param
29
+ // search : 'search[value]',
30
+ // TODO columns + order
31
+ },
32
+
33
+ // Config for returned object keys: uses default
34
+ // jsonKeys: {}
35
+ },
36
+ ajaxUrl: 'http://localhost:3004',
37
+
38
+ addRowIndex: true,
39
+ searchInputClassName: 'form-control',
40
+ infoExtraClassName: 'border border-secondary rounded p-2', // some classes from the used framework (bootstrap)
41
+ tableClassName: 'table table-striped table-hover table-bordered',
42
+ defaultSorting: {date: 'asc', perc: 'desc'},
43
+
44
+ // add a red background to each number cell whose content is a number and less than 3000
45
+ trCallback: (tr/* , row_data, params */) => {
46
+
47
+ tr.querySelectorAll('td').forEach(cell => {
48
+
49
+ const raw_value = +cell.dataset.raw;
50
+ if(!isNaN(raw_value) && raw_value < 3000 && cell.dataset.type === 'num') {
51
+ cell.classList.add('text-bg-danger');
52
+ }
53
+ });
54
+ },
55
+
56
+ caption: 'Ajax table demo',
57
+
58
+ // using some bootstrap classes
59
+ // tableClassName: 'table table-striped table-hover table-bordered', // overrides the default class
60
+ inlineEndAlignClassName : 'text-end',
61
+ nowrapClassName : 'text-nowrap',
62
+
63
+ columns: [
64
+ {
65
+ title : 'ID',
66
+ key : 'id',
67
+ // dataType : 'string', // dataType can be omitted if it's `string`
68
+ className : 'small text-center',
69
+ rowHeading : true,
70
+ tfoot : false // avoid rendering these values inside the tfoot element
71
+ },
72
+ {
73
+ title : 'Boolean',
74
+ key : 'bool',
75
+ dataType : 'bool',
76
+ // parse : row => !!row.isActive // if the original data contains other values besides true or false and you need to force them all to boolean
77
+ },
78
+ {
79
+ title : 'Boolean (customized)',
80
+ key : 'boolCustomized',
81
+ dataType : 'boolWithNull' // custom dataType, see below
82
+ },
83
+ {
84
+ title : 'Text column',
85
+ key : 'text',
86
+ dataType : 'string'
87
+ },
88
+ {
89
+ title : 'Number #1',
90
+ key : 'number1',
91
+ dataType : 'num',
92
+ },
93
+ {
94
+ title : 'Number #2',
95
+ key : 'number2',
96
+ dataType : 'num',
97
+ render : cell_data => { // custom render function
98
+ const [int, dec] = cell_data.toFixed(2).split('.');
99
+ return `${int}.<small>${dec}</small>`;
100
+ }
101
+ },
102
+ {
103
+ key : 'sum',
104
+ title : 'Sum #1 + #2',
105
+ dataType : 'num',
106
+ parse : (row) => row.number1 + row.number2 // parsed value
107
+ },
108
+ {
109
+ title : 'Date',
110
+ key : 'date',
111
+ dataType : 'date'
112
+ },
113
+ {
114
+ title : 'Datetime (obj)',
115
+ key : 'sfDatetime',
116
+ dataType : 'datetime',
117
+ },
118
+ {
119
+ title : 'Perc',
120
+ key : 'perc',
121
+ dataType : 'perc'
122
+ },
123
+ {
124
+ title : 'Perc. (dec.)',
125
+ key : 'percDecimal',
126
+ dataType : 'percDecimal'
127
+ },
128
+ {
129
+ title : 'Perc. (dec.)',
130
+ key : 'euro',
131
+ dataType : 'euro'
132
+ },
133
+
134
+ ],
135
+
136
+ }, // end params
137
+
138
+ // custom dataTypes
139
+ {
140
+ // redefine the default `string` dataType
141
+ string: {
142
+ // inheritsFrom: 'string', // inherits properties from the default dataType, if needed
143
+ className: 'fst-italic' // from bootstrap css
144
+ },
145
+
146
+ // new dataType
147
+ // similar to the default dataType `bool`, but also renders null values with a different style
148
+ // SVG icons are replaced with text symbols
149
+ boolWithNull: {
150
+ inheritsFrom : 'bool', // inherits properties from the default dataType, if needed
151
+ className : 'text-center', // from bootstrap css
152
+
153
+ render : function (val /* , params */) { // you can access the global params object if you need
154
+ if(val == null) {
155
+ return '<span class="text-bg-warning py-1 px-3 small rounded">null</span>';
156
+
157
+ } else {
158
+ return val
159
+ ? '<span class="text-success lead">&check;</span>'
160
+ : '<span class="text-danger lead">&#x2715;</span>';
161
+ }
162
+ }
163
+ }
164
+ } // end custom dataTypes
165
+ );
@@ -0,0 +1,180 @@
1
+ /* eslint-disable no-console */
2
+ import jsonTable from '@src/index.js';
3
+ import static_demo_data from '../demo-data/json-static-table-demo-data.js';
4
+
5
+ /*
6
+ data:
7
+ [
8
+ {
9
+ 'id': 350,
10
+ 'isActive': true,
11
+ 'number1': 1081.55,
12
+ 'number2': 4411.51,
13
+ 'date': '2017-06-20',
14
+ 'datetime': '2015-02-21T01:23:49',
15
+ 'text': 'sit officia in',
16
+ 'perc': 42.33,
17
+ 'percDecimal': 0.19,
18
+ 'euro': 879.21
19
+ },
20
+ ]
21
+ */
22
+
23
+ // Register listener BEFORE instantiation so it can catch the event
24
+ const container = document.getElementById('static-table-demo');
25
+ container.addEventListener('jt:ready', e => {
26
+ console.log('Static table ready');
27
+ console.log(e.detail);
28
+ });
29
+
30
+ new jsonTable(
31
+ // params
32
+ {
33
+ debug: true,
34
+ container: container,
35
+ useZeroAltChar: false,
36
+ ajax: false,
37
+ data: static_demo_data,
38
+ addRowIndex: true,
39
+ searchInputClassName: 'form-control',
40
+ infoExtraClassName: 'border border-secondary rounded p-2', // some classes from the used framework (bootstrap)
41
+ tableClassName: 'table table-striped table-hover table-bordered',
42
+ defaultSorting: {date: 'asc', perc: 'desc'},
43
+
44
+ // add a red background to each number cell whose content is a number and less than 3000
45
+ trCallback: (tr/* , row_data, params */) => {
46
+
47
+ tr.querySelectorAll('td').forEach(cell => {
48
+
49
+ const raw_value = +cell.dataset.raw;
50
+ if(!isNaN(raw_value) && raw_value < 3000 && cell.dataset.type === 'num') {
51
+ cell.classList.add('text-bg-danger');
52
+ }
53
+ });
54
+ },
55
+
56
+ caption: 'Static table demo',
57
+
58
+ // using some bootstrap classes
59
+ // tableClassName: 'table table-striped table-hover table-bordered', // overrides the default class
60
+ inlineEndAlignClassName : 'text-end',
61
+ nowrapClassName : 'text-nowrap',
62
+
63
+ columns: [
64
+ {
65
+ title : 'ID',
66
+ key : 'id',
67
+ // dataType : 'string', // dataType can be omitted if it's `string`
68
+ className : 'small text-center',
69
+ rowHeading : true,
70
+ tfoot : false // avoid rendering these values inside the tfoot element
71
+ },
72
+ {
73
+ title : 'Boolean',
74
+ key : 'bool',
75
+ dataType : 'bool',
76
+ // parse : row => !!row.isActive // if the original data contains other values besides true or false and you need to force them all to boolean
77
+ },
78
+ {
79
+ title : 'Boolean (customized)',
80
+ key : 'boolCustomized',
81
+ dataType : 'boolWithNull' // custom dataType, see below
82
+ },
83
+ {
84
+ title : 'Text column',
85
+ key : 'text',
86
+ dataType : 'string'
87
+ },
88
+ {
89
+ title : 'Number #1',
90
+ key : 'number1',
91
+ dataType : 'num',
92
+ },
93
+ {
94
+ title : 'Number #2',
95
+ key : 'number2',
96
+ dataType : 'num',
97
+ render : cell_data => { // custom render function
98
+ const [int, dec] = cell_data.toFixed(2).split('.');
99
+ return `${int}.<small>${dec}</small>`;
100
+ }
101
+ },
102
+ {
103
+ key : 'sum',
104
+ title : 'Sum #1 + #2',
105
+ dataType : 'num',
106
+ parse : (row) => row.number1 + row.number2 // parsed value
107
+ },
108
+ {
109
+ title : 'Date',
110
+ key : 'date',
111
+ dataType : 'date'
112
+ },
113
+ {
114
+ title : 'Datetime (obj)',
115
+ key : 'sfDatetime',
116
+ dataType : 'datetime',
117
+ },
118
+ {
119
+ title : 'Perc',
120
+ key : 'perc',
121
+ dataType : 'perc'
122
+ },
123
+ {
124
+ title : 'Perc. (dec.)',
125
+ key : 'percDecimal',
126
+ dataType : 'percDecimal'
127
+ },
128
+ {
129
+ title : 'Perc. (dec.)',
130
+ key : 'euro',
131
+ dataType : 'euro'
132
+ },
133
+
134
+ ],
135
+ footerData: [
136
+ {
137
+ 'id': 'this will not be rendered, sice the the `tfoot` option in `columns` is set to false',
138
+ 'isActive': null,
139
+ 'number1': static_demo_data.reduce((prev, curr) => prev + curr.number1, 0),
140
+ 'number2': static_demo_data.reduce((prev, curr) => prev + curr.number2, 0),
141
+ 'sum:': static_demo_data.reduce((prev, curr) => prev + curr.number1 + curr.number2, 0),
142
+ 'date': null,
143
+ 'datetime': null,
144
+ 'text': null,
145
+ 'perc': null,
146
+ 'percDecimal': null,
147
+ 'euro': static_demo_data.reduce((prev, curr) => prev + curr.euro, 0),
148
+ }
149
+
150
+ ]
151
+ }, // end params
152
+
153
+ // custom dataTypes
154
+ {
155
+ // redefine the default `string` dataType
156
+ string: {
157
+ // inheritsFrom: 'string', // inherits properties from the default dataType, if needed
158
+ className: 'fst-italic' // from bootstrap css
159
+ },
160
+
161
+ // new dataType
162
+ // similar to the default dataType `bool`, but also renders null values with a different style
163
+ // SVG icons are replaced with text symbols
164
+ boolWithNull: {
165
+ inheritsFrom : 'bool', // inherits properties from the default dataType, if needed
166
+ className : 'text-center', // from bootstrap css
167
+
168
+ render : function (val /* , params */) { // you can access the global params object if you need
169
+ if(val == null) {
170
+ return '<span class="text-bg-warning py-1 px-3 small rounded">null</span>';
171
+
172
+ } else {
173
+ return val
174
+ ? '<span class="text-success lead">&check;</span>'
175
+ : '<span class="text-danger lead">&#x2715;</span>';
176
+ }
177
+ }
178
+ }
179
+ } // end custom dataTypes
180
+ );
@@ -0,0 +1,122 @@
1
+ import MiniCssExtractPlugin from 'mini-css-extract-plugin';
2
+
3
+ export function cssRules({
4
+ isDevelopment = false,
5
+ useSass = false,
6
+ inlineCssInDevMode = true
7
+ }) {
8
+ const configOptions = { isDevelopment, useSass, inlineCssInDevMode };
9
+
10
+ return [
11
+ // CSS modules
12
+ {
13
+ test: /\.module\.(sass|scss|css)$/i,
14
+ oneOf: [
15
+ // inserimento critical css con tag style al momento della build
16
+ {
17
+ test: /\.critical\.module\./i,
18
+ use: css_loaders({ ...configOptions, critical: true, css_modules: true }),
19
+ },
20
+
21
+ // inserimento css con tag style nel runtime
22
+ {
23
+ resourceQuery: /inline/,
24
+ use: css_loaders({ ...configOptions, inline: true, css_modules: true }),
25
+ },
26
+ // comportamento standard
27
+ {
28
+ use: css_loaders({ ...configOptions, css_modules: true }),
29
+ },
30
+ ]
31
+ },
32
+ // CSS standard
33
+ {
34
+ test: /\.(sass|scss|css)$/i,
35
+ exclude: /\.module\.(sass|scss|css)$/i,
36
+ sideEffects: true,
37
+ oneOf: [
38
+ {
39
+ test: /\.critical\.(sass|scss|css)$/i,
40
+ use: css_loaders({ ...configOptions, critical: true }),
41
+ },
42
+ {
43
+ resourceQuery: /inline/,
44
+ use: css_loaders({ ...configOptions, inline: true }),
45
+ },
46
+ {
47
+
48
+ use: css_loaders({ ...configOptions }),
49
+ }
50
+ ]
51
+ }
52
+ ];
53
+ }
54
+
55
+ function css_loaders({
56
+ isDevelopment = false,
57
+ useSass = false,
58
+ inlineCssInDevMode = true,
59
+ css_modules = false,
60
+ critical = false, // Iniezione statica nell'HTML
61
+ inline = false // Iniezione dinamica via JS
62
+ }) {
63
+
64
+ let mainLoader;
65
+
66
+ if (inline) {
67
+ // usa style-loader per la query string ?inline
68
+ mainLoader = {
69
+ loader: 'style-loader',
70
+ options: { injectType: 'singletonStyleTag' }
71
+ };
72
+
73
+ } else if (critical) {
74
+ // usa MiniCssExtractPlugin per permettere al plugin HTML di leggerlo
75
+ mainLoader = MiniCssExtractPlugin.loader;
76
+
77
+ } else {
78
+ // compartamento stabdard
79
+ mainLoader = (isDevelopment && inlineCssInDevMode)
80
+ ? { loader: 'style-loader', options: { injectType: 'singletonStyleTag' } }
81
+ : MiniCssExtractPlugin.loader;
82
+ }
83
+
84
+
85
+ return [
86
+ mainLoader,
87
+
88
+ {
89
+ loader: 'css-loader',
90
+ options: {
91
+ modules: css_modules
92
+ ? {
93
+ auto: true,
94
+ localIdentName: isDevelopment ? '[local]_[hash:base64:6]' : '[hash:base64]',
95
+ exportLocalsConvention: 'as-is',
96
+ }
97
+ : false,
98
+ sourceMap: isDevelopment,
99
+ importLoaders: useSass ? 2 : 1,
100
+ }
101
+ },
102
+ {
103
+ loader: 'postcss-loader',
104
+ options: {
105
+ postcssOptions: { sourceMap: isDevelopment }
106
+ }
107
+ },
108
+ ...(useSass
109
+ ? [ {
110
+ loader: 'sass-loader',
111
+ options: {
112
+ sourceMap: isDevelopment,
113
+ sassOptions: {
114
+ quietDeps: true,
115
+ silenceDeprecations: [ 'legacy-js-api', 'mixed-decls', 'color-functions', 'global-builtin', 'import' ],
116
+ }
117
+ }
118
+ } ]
119
+ : []
120
+ )
121
+ ];
122
+ }
@@ -0,0 +1,33 @@
1
+ import path from 'path';
2
+ import fs from 'fs';
3
+
4
+ /**
5
+ * Funzione per ottenere gli alias direttamente leggendo il file jsconfig.json
6
+ * @param {string} jsconfigAbsPath - Il percorso assoluto del file jsconfig.json
7
+ * @returns {Record<string, string>}
8
+ */
9
+
10
+ export function getJsConfigAliases(jsconfigAbsPath) {
11
+
12
+ const baseDir = path.dirname(jsconfigAbsPath);
13
+
14
+ const fileContent = fs.readFileSync(jsconfigAbsPath, 'utf-8');
15
+ const jsconfig = JSON.parse(fileContent);
16
+
17
+ const aliases = {};
18
+ const paths = jsconfig.compilerOptions?.paths || {};
19
+
20
+ for (const item in paths) {
21
+ // Rimuove la wildcard /* alla fine della chiave (alias)
22
+ const key = item.replace(/(\/\*)$/, '');
23
+
24
+ // Prende il primo valore (path) e rimuove la wildcard /*
25
+ const targetPath = paths[item][0].replace(/(\/\*)$/, '');
26
+
27
+ const absolutePath = path.resolve(baseDir, targetPath);
28
+
29
+ aliases[key] = absolutePath;
30
+ }
31
+
32
+ return aliases;
33
+ }
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Funzione per definire le regole per SVG
3
+ * @returns {import('webpack').RuleSetRule[]}
4
+ */
5
+
6
+
7
+ import path from 'path';
8
+ import { fileURLToPath } from 'url';
9
+
10
+
11
+ export function svgRules({
12
+ useSvgo = true,
13
+ useSvgr = false,
14
+ svgoConfig = null,
15
+ favicons_path_regexp = null,
16
+ }) {
17
+
18
+ const this_filename = fileURLToPath(import.meta.url)
19
+ ,this_dirname = path.dirname(this_filename);
20
+
21
+ if(svgoConfig == null) {
22
+ useSvgo = false;
23
+ }
24
+
25
+ return [{
26
+ test: /(\.svg)$/i,
27
+ exclude: favicons_path_regexp?? undefined,
28
+ oneOf: [
29
+ // 1. svg inline dataUri per css (con `?cssInline`)
30
+ {
31
+ resourceQuery: /cssInline/, // ex inline-dataURI
32
+ type: 'asset/source',
33
+ use: [
34
+ // Loader di ottimizzazione SVGO
35
+ ...(useSvgo? [ {
36
+ loader: 'svgo-loader',
37
+ options: svgoConfig,
38
+ } ] : []),
39
+
40
+ // Loader wrapper per Data URI compatto (Mini-SVG-Data-URI-Loader)
41
+ {
42
+ loader: path.resolve(this_dirname, './mini-svg-data-uri-loader.cjs'),
43
+ },
44
+ ],
45
+ },
46
+
47
+ // as react component -> https://react-svgr.com/docs/webpack/
48
+ ...(useSvgr
49
+ ? [{
50
+ resourceQuery: /react/,
51
+ issuer: /\.[jt]sx?$/,
52
+ use: [
53
+ {
54
+ loader: '@svgr/webpack',
55
+ options: {
56
+ ...(useSvgo
57
+ ? {
58
+ svgo: true, // false: Disable SVGO inside SVGR if svgo-loader already ran
59
+ svgoConfig: svgoConfig,
60
+ }
61
+ : {
62
+ svgo: false
63
+ }
64
+
65
+ )
66
+ // Altre opzioni utili di SVGR
67
+ // titleProp: true,
68
+ // ref: true,
69
+ }
70
+ },
71
+ // {
72
+ // loader: 'svgo-loader',
73
+ // options: svgoConfig,
74
+ // },
75
+ ],
76
+ }]
77
+ : []
78
+ ),
79
+
80
+ // svg inline (con `?inline`)
81
+ {
82
+ resourceQuery: /inline/,
83
+ type: 'asset/source',
84
+ // Ottimizzazione SVGO
85
+ use: useSvgo ? [ { loader: 'svgo-loader', options: svgoConfig } ] : [],
86
+ },
87
+
88
+ // svg file (copy image files to build folder)
89
+ {
90
+ type: 'asset/resource',
91
+ exclude: [ /cssInline/, /inline/ ],
92
+ sideEffects: true,
93
+ generator: {
94
+ filename: 'imgs/[name].[contenthash][ext]'
95
+ },
96
+
97
+ // TODO presumibilmente errore sui file già ottimizzati
98
+ // Ottimizzazione SVGO
99
+ // use: useSvgo ? [
100
+ // {
101
+ // loader: 'svgo-loader',
102
+ // options: svgoConfig,
103
+ // },
104
+ // ] : []
105
+ }
106
+ ]
107
+ }];
108
+ }
@@ -0,0 +1,26 @@
1
+ // svgo.config.js
2
+ import addViewBox from 'svgo-add-viewbox';
3
+
4
+ // https://svgo.dev/docs/plugins/
5
+ export default {
6
+ multipass: true,
7
+ plugins: [
8
+ 'removeDoctype'
9
+ , { ...addViewBox, params: { overwrite: false } }
10
+ , { name: 'cleanupIds', params: { remove: true, minify: true } }
11
+ , 'removeComments'
12
+ , 'removeTitle'
13
+ , 'removeDimensions'
14
+ , 'collapseGroups'
15
+ , { name: 'cleanupNumericValues', params: { floatPrecision: 4 } }
16
+ , { name: 'convertColors', params: { names2hex: true, rgb2hex: true } }
17
+ , 'removeStyleElement'
18
+ , 'removeEmptyContainers'
19
+ , { name: 'removeAttrs', params: { attrs: ['(filter|fill|stroke|class|style|data.*)'/* , 'svg:(width|height)' */] } }
20
+ // , { name: 'removeAttrs', params: { attrs: [ '(filter|fill|stroke|fill-rule|clip-rule|stroke-linecap|stroke-linejoin|stroke-width|transform|style|class|data.*)', 'svg:(width|height)' ] } }
21
+ , 'removeUselessDefs',
22
+ //, { name: 'addAttributesToSVGElement0, params: {attribute: "#{$attr}"}}
23
+ // , { name: 'addClassesToSVGElement', params: { className: 'line-icon' } }
24
+ 'removeUselessStrokeAndFill',
25
+ ]
26
+ };