@massimo-cassandro/minimo 1.33.0 → 1.33.1

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 (84) hide show
  1. package/README.md +2 -1
  2. package/dev-tools/starter-kit/source_files/{CLAUDE-frontend.md → app/CLAUDE.md} +1 -1
  3. package/dev-tools/starter-kit/source_files/app/assets/api_htaccess +20 -0
  4. package/dev-tools/starter-kit/source_files/{layout-critical.css → app/css/layout.critical.css} +1 -1
  5. package/dev-tools/starter-kit/source_files/app/css/layout.css +0 -0
  6. package/dev-tools/starter-kit/source_files/app/index.js +1 -0
  7. package/dev-tools/starter-kit/source_files/root/webpack-config-modules/inline-critical-css.mjs +41 -0
  8. package/dev-tools/starter-kit/{webpack-config-modules → source_files/root/webpack-config-modules}/purgecss-setup.mjs +1 -1
  9. package/dev-tools/starter-kit/{webpack.config.mjs → source_files/root/webpack.config.mjs} +50 -24
  10. package/dev-tools/starter-kit/starter-install.sh +141 -83
  11. package/dev-tools/stylelint-config/test/test.module.scss +9 -0
  12. package/package.json +1 -1
  13. package/snippets/php/iviewer.php +488 -0
  14. package/snippets/twig-symfony/ViewerController.php +549 -0
  15. package/src/custom-properties.css +29 -0
  16. package/src/minimo.css +3 -0
  17. package/src/utilities/dom-builder/dom-builder.js +9 -5
  18. package/src/web-components/json-table/json-table-component.js +387 -38
  19. package/src/web-components/json-table/json-table-component.module.css +190 -0
  20. package/src/web-components/json-table/json-table.minimo.tokens.mjs +195 -0
  21. package/src/web-components/json-table/readme.md +603 -82
  22. package/src/web-components/json-table/src/cell-content.js +136 -0
  23. package/src/web-components/json-table/src/content-utils.js +103 -0
  24. package/src/web-components/json-table/src/data-types.js +280 -0
  25. package/src/web-components/json-table/src/defaults.js +377 -58
  26. package/src/web-components/json-table/src/get-data.js +105 -10
  27. package/src/web-components/json-table/src/icons.js +80 -0
  28. package/src/web-components/json-table/src/info-section.js +85 -50
  29. package/src/web-components/json-table/src/main-builder.js +175 -52
  30. package/src/web-components/json-table/src/pagination.js +253 -0
  31. package/src/web-components/json-table/src/parse-cols.js +113 -0
  32. package/src/web-components/json-table/src/parse-rows.js +81 -0
  33. package/src/web-components/json-table/src/resolve-params.js +102 -32
  34. package/src/web-components/json-table/src/search.js +71 -0
  35. package/src/web-components/json-table/src/sorting.js +111 -0
  36. package/src/web-components/json-table/src/table-body.js +109 -0
  37. package/src/web-components/json-table/src/table-builder.js +152 -0
  38. package/src/web-components/json-table/src/table-tfoot.js +56 -0
  39. package/src/web-components/json-table/src/table-thead.js +183 -0
  40. package/src/web-components/json-table/src/update-info.js +43 -24
  41. package/src/web-components/s-datatable-component/{docs.md → readme.md} +5 -3
  42. package/src/web-components/s-datatable-component/s-datatable-component.js +1 -1
  43. package/types/global.d.ts +17 -3
  44. package/dev-tools/starter-kit/source_files/app_index.js +0 -1
  45. package/snippets/config-templates/_htaccess +0 -69
  46. package/snippets/config-templates/robots.txt +0 -5
  47. package/snippets/config-templates/rollup.config.mjs +0 -115
  48. /package/dev-tools/starter-kit/source_files/{_root_robots.txt → app/assets/robots.txt} +0 -0
  49. /package/dev-tools/starter-kit/source_files/{_root_htaccess → app/assets/root_htaccess} +0 -0
  50. /package/{src → dev-tools/starter-kit/source_files/app/css}/fonts.css +0 -0
  51. /package/dev-tools/starter-kit/source_files/{favicons-readme.md → app/favicons/favicons-readme.md} +0 -0
  52. /package/dev-tools/starter-kit/{webpack-template.ejs → source_files/app/tpl/index.ejs} +0 -0
  53. /package/dev-tools/starter-kit/source_files/{__project__.code-workspace → root/__project__.code-workspace} +0 -0
  54. /package/dev-tools/starter-kit/source_files/{_browserslistrc → root/_browserslistrc} +0 -0
  55. /package/dev-tools/starter-kit/source_files/{_editorconfig → root/_editorconfig} +0 -0
  56. /package/dev-tools/starter-kit/source_files/{_gitignore → root/_gitignore} +0 -0
  57. /package/dev-tools/starter-kit/source_files/{_prettierrc → root/_prettierrc} +0 -0
  58. /package/dev-tools/starter-kit/source_files/{eslint.config.mjs → root/eslint.config.mjs} +0 -0
  59. /package/dev-tools/starter-kit/source_files/{jsconfig.json → root/jsconfig.json} +0 -0
  60. /package/dev-tools/starter-kit/{package-tpl.json → source_files/root/package-tpl.json} +0 -0
  61. /package/dev-tools/starter-kit/source_files/{stylelint.config.mjs → root/stylelint.config.mjs} +0 -0
  62. /package/dev-tools/starter-kit/{webpack-config-modules → source_files/root/webpack-config-modules}/css-rules.mjs +0 -0
  63. /package/dev-tools/starter-kit/{webpack-config-modules → source_files/root/webpack-config-modules}/get-jsConfig-aliases.mjs +0 -0
  64. /package/dev-tools/starter-kit/{webpack-config-modules → source_files/root/webpack-config-modules}/mini-svg-data-uri-loader.cjs +0 -0
  65. /package/dev-tools/starter-kit/{webpack-config-modules → source_files/root/webpack-config-modules}/postcss.config.mjs +0 -0
  66. /package/dev-tools/starter-kit/{webpack-config-modules → source_files/root/webpack-config-modules}/purgecss-variables-safelist.mjs +0 -0
  67. /package/dev-tools/starter-kit/{webpack-config-modules → source_files/root/webpack-config-modules}/svg-rules.mjs +0 -0
  68. /package/dev-tools/starter-kit/{webpack-config-modules → source_files/root/webpack-config-modules}/svgo.config.mjs +0 -0
  69. /package/snippets/{config-templates/_github → _github}/dependabot.yml +0 -0
  70. /package/snippets/{error-pages/error-pages.js → error-pages.js} +0 -0
  71. /package/snippets/{config-templates/react → react}/offcanvas/offcanvas.jsx +0 -0
  72. /package/snippets/{config-templates/react → react}/offcanvas/offcanvas.module.scss +0 -0
  73. /package/snippets/{config-templates → root}/_hintrc.cjs +0 -0
  74. /package/snippets/{config-templates → root}/_npmignore +0 -0
  75. /package/snippets/{config-templates → root}/_npmrc +0 -0
  76. /package/snippets/{config-templates → root}/_stylelintignore +0 -0
  77. /package/snippets/{config-templates → root}/babel.config--react.json +0 -0
  78. /package/snippets/{config-templates → root}/babel.config--solidJS.json +0 -0
  79. /package/snippets/{ImgViewerController.php → twig-symfony/ImgViewerController.php} +0 -0
  80. /package/snippets/{UnsplashController.php → twig-symfony/UnsplashController.php} +0 -0
  81. /package/snippets/{config-templates → twig-symfony}/_env.local +0 -0
  82. /package/snippets/{error-pages → twig-symfony}/bundles/TwigBundle/Exception/error.html.twig +0 -0
  83. /package/snippets/{flash-messages.html.twig → twig-symfony/flash-messages.html.twig} +0 -0
  84. /package/snippets/{minimo-form-layout.html.twig → twig-symfony/minimo-form-layout.html.twig} +0 -0
@@ -1,48 +1,67 @@
1
1
  /*! minimo - json-table: info text update */
2
2
 
3
- /** @typedef {import('./defaults.js').JsonTableParams} JsonTableParams */
4
- /** @typedef {import('./main-builder.js').JsonTableElements} JsonTableElements */
3
+ import { setContent } from './content-utils.js';
4
+
5
+ /** @typedef {import('../json-table-component.js').JsonTable} JsonTable */
5
6
 
6
7
  /**
7
- * Updates the info text (`elements.resultInfo`) using `params.infoText(shown, total)`.
8
+ * Updates the info text (`elements.resultInfo`) from the current state.
9
+ *
10
+ * Content resolution:
11
+ * - `params.infoText` function → `infoText(start, end, totRec, filteredRec, page, totPages)`
12
+ * - no rows → `labels.noResults` (search active) or `labels.noRows`
13
+ * - otherwise the mustache-like template `params.infoText` (string) or `labels.info`, with the
14
+ * placeholders `{start}`, `{end}`, `{totRec}`, `{filteredRec}`, `{page}`, `{totPages}` replaced
15
+ * by the locale-formatted numbers
8
16
  *
9
- * The returned value can be a Node (appended as-is), a plain string (set as `textContent`)
10
- * or an HTML string (sanitized via `Element.setHTML` where supported, `innerHTML` otherwise,
11
- * consistently with domBuilder).
17
+ * `start`/`end` are the 1-based indexes of the first/last row of the current page within the
18
+ * filtered set (0 when there are no rows).
12
19
  *
13
- * @param {JsonTableElements} elements - Generated elements (see `main-builder.js`)
14
- * @param {JsonTableParams} params - Resolved params
15
- * @param {number} shown - Number of rows currently displayed
16
- * @param {number} total - Total number of rows in the data set
20
+ * @param {JsonTable} jt - The component instance
17
21
  * @returns {void}
18
22
  *
19
23
  * @example
20
- * updateInfo(elements, params, 25, 100);
21
- * // with the default `infoText` → "Visualizzate <strong>25</strong> righe su <strong>100</strong>"
24
+ * updateInfo(jt);
25
+ * // default `labels.info`, page 2 of 25 rows per page, 60 rows → "Stai visualizzando le righe da 26 a 50, su un totale di 60 record trovati"
22
26
  */
23
- export function updateInfo(elements, params, shown, total) {
27
+ export function updateInfo(jt) {
24
28
 
29
+ const { params, elements, state } = jt;
25
30
  const target = elements.resultInfo;
31
+
26
32
  if (!target) {
27
33
  return;
28
34
  }
29
35
 
30
- const content = params.infoText(shown, total);
36
+ const shown = state.pageRows.length;
37
+ const perPage = params.perPage > 0 ? params.perPage : shown;
38
+ const start = shown ? (state.page - 1) * perPage + 1 : 0;
31
39
 
32
- if (content instanceof Node) {
33
- target.replaceChildren(content);
34
- return;
35
- }
40
+ /** @type {Record<string, number>} */
41
+ const values = {
42
+ start,
43
+ end: shown ? start + shown - 1 : 0,
44
+ totRec: state.totRec,
45
+ filteredRec: state.filteredRec,
46
+ page: state.page,
47
+ totPages: state.totPages
48
+ };
36
49
 
37
- const text = String(content ?? '');
50
+ let content;
38
51
 
39
- if (!text.includes('<')) {
40
- target.textContent = text;
52
+ if (typeof params.infoText === 'function') {
53
+ content = params.infoText(values.start, values.end, values.totRec, values.filteredRec, values.page, values.totPages);
41
54
 
42
- } else if (typeof target.setHTML === 'function') {
43
- target.setHTML(text);
55
+ } else if (values.filteredRec === 0) {
56
+ content = state.searchTerm ? params.labels.noResults : params.labels.noRows;
44
57
 
45
58
  } else {
46
- target.innerHTML = text;
59
+ const tpl = params.infoText ?? params.labels.info ?? '';
60
+ content = String(tpl).replace(
61
+ /\{(start|end|totRec|filteredRec|page|totPages)\}/g,
62
+ (_, key) => values[key].toLocaleString(params.locale)
63
+ );
47
64
  }
65
+
66
+ setContent(target, content);
48
67
  }
@@ -1,6 +1,8 @@
1
- # `s-datatable` web-component per simple-datatables
1
+ # `s-datatable` web-component per [simple-datatables](https://fiduswriter.github.io/simple-datatables/documentation/)
2
+
3
+
4
+ >**NB: deprecato, utilizzare [json-table](../json-table/readme.md)**
2
5
 
3
- <https://fiduswriter.github.io/simple-datatables/documentation/>
4
6
 
5
7
  ## Installazione
6
8
 
@@ -279,7 +281,7 @@ cols: [
279
281
  // 'sf_datetime' – data e ora da oggetto Symfony ({ date, timezone }),
280
282
  // pre-elaborato in _load
281
283
  // 'sf_date' – come 'sf_datetime', ma mostra solo la data
282
- // 'datetime' – data e ora da stringa/valore parsabile da `new Date()`
284
+ // 'datetime' – data e ora da stringa/valore elaborabile da `new Date()`
283
285
  // 'date' – come 'datetime', ma mostra solo la data
284
286
  // (date/datetime: formato it-IT, allineamento a destra,
285
287
  // data-order impostato per l'ordinamento; null → '—')
@@ -502,7 +502,7 @@ class SimpleDatatableAdapter extends HTMLElement {
502
502
  * Se presente e !== undefined sovrascrive sempre l'attributo.
503
503
  * Passare esplicitamente `null` per ignorare l'attributo e
504
504
  * ricevere il defaultValue.
505
- * 2. Attributo HTML – se il valore inizia con [ o { viene auto-parsato
505
+ * 2. Attributo HTML – se il valore inizia con [ o { viene auto-elaborato
506
506
  * da JSON (utile per cols, che può stare nell'attributo).
507
507
  * 3. defaultValue – fallback finale.
508
508
  *
package/types/global.d.ts CHANGED
@@ -3,9 +3,23 @@
3
3
  // The canonical definition lives in dom-builder.js — this only re-exports it.
4
4
  type DomBuilderItem = import('../src/utilities/dom-builder/dom-builder.js').DomBuilderItem;
5
5
 
6
- // Sanitizer API (Element.setHTML / getHTML) — not yet in TypeScript's lib.dom.d.ts.
6
+ // Global alias for the `<json-table>` web component class, so consumer scripts can write
7
+ // `/** @type {JsonTable} */` without importing the type. The tag name map augmentation makes
8
+ // `document.querySelector('json-table')` / `document.createElement('json-table')` return a
9
+ // `JsonTable` instance without casts. Consumers get both by adding this file to their
10
+ // jsconfig/tsconfig `include` (e.g. "node_modules/@massimo-cassandro/minimo/types/global.d.ts").
11
+ type JsonTable = import('../src/web-components/json-table/json-table-component.js').JsonTable;
12
+
13
+ interface HTMLElementTagNameMap {
14
+ 'json-table': JsonTable;
15
+ }
16
+
17
+ // Sanitizer API (Element.setHTML / getHTML). Declared as required members (not optional) so
18
+ // the augmentation stays compatible with the lib.dom versions that already include them
19
+ // (overload signatures must all be optional or all required); the runtime code still checks
20
+ // `typeof el.setHTML === 'function'` before using it.
7
21
  // https://developer.mozilla.org/en-US/docs/Web/API/Element/setHTML
8
22
  interface Element {
9
- setHTML?(input: string, options?: { sanitizer?: unknown }): void;
10
- getHTML?(options?: { serializableShadowRoots?: boolean; shadowRoots?: ShadowRoot[] }): string;
23
+ setHTML(input: string, options?: { sanitizer?: unknown }): void;
24
+ getHTML(options?: { serializableShadowRoots?: boolean; shadowRoots?: ShadowRoot[] }): string;
11
25
  }
@@ -1 +0,0 @@
1
- import './index.css';
@@ -1,69 +0,0 @@
1
-
2
- # no cache
3
- # <IfModule mod_headers.c>
4
- # Header set Cache-Control "no-cache, no-store, must-revalidate"
5
- # Header set Pragma "no-cache"
6
- # Header set Expires 0
7
- # </IfModule>
8
-
9
- # blocco iframe
10
- # "deny" = tutti siti
11
- # "sameorigin" tutti tranne quelli che vengono dalla stessa origine
12
- # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
13
- Header set X-Frame-Options "sameorigin"
14
-
15
-
16
- <IfModule mod_expires.c>
17
- ExpiresActive On
18
- AddType application/vnd.ms-fontobject .eot
19
- AddType application/x-font-ttf .ttf
20
- AddType application/x-font-opentype .otf
21
- AddType application/x-font-woff .woff
22
- AddType application/x-font-woff2 .woff2
23
- AddType application/font-sfnt otf ttf
24
- AddType application/font-woff woff
25
- AddType application/font-woff2 woff2
26
- AddType image/svg+xml .svg
27
-
28
- ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
29
- ExpiresByType application/x-font-ttf "access plus 1 year"
30
- ExpiresByType application/x-font-opentype "access plus 1 year"
31
- ExpiresByType application/x-font-woff "access plus 1 year"
32
- ExpiresByType application/x-font-woff2 "access plus 1 year"
33
- ExpiresByType application/font-sfnt "access plus 1 year"
34
- ExpiresByType application/font-woff "access plus 1 year"
35
- ExpiresByType application/font-woff2 "access plus 1 year"
36
-
37
- ExpiresByType text/html "access plus 1 hour"
38
- ExpiresByType text/css "access plus 1 year"
39
- ExpiresByType text/x-javascript "access plus 1 year"
40
- ExpiresByType application/javascript "access plus 1 year"
41
- ExpiresByType application/x-javascript "access plus 1 year"
42
-
43
- ExpiresByType image/svg+xml "access plus 1 year"
44
- ExpiresByType image/gif "access plus 1 year"
45
- ExpiresByType image/png "access plus 1 year"
46
- ExpiresByType image/jpeg "access plus 1 year"
47
- ExpiresByType image/pjpeg "access plus 1 year"
48
- ExpiresByType image/webp "access plus 1 year"
49
- ExpiresByType image/avif "access plus 1 year"
50
-
51
- ExpiresByType application/pdf "access plus 1 year"
52
-
53
- ExpiresByType video/mp4 "access plus 1 year"
54
- ExpiresByType video/webm "access plus 1 year"
55
- ExpiresByType video/x-m4v "access plus 1 year"
56
- ExpiresByType video/quicktime "access plus 1 year"
57
- ExpiresByType audio/mpeg "access plus 1 year"
58
- ExpiresByType audio/x-wav "access plus 1 year"
59
-
60
- ExpiresByType image/x-icon "access plus 1 year"
61
- ExpiresDefault "access plus 1 year"
62
- </IfModule>
63
-
64
- <IfModule !mod_expires.c>
65
- <IfModule mod_headers.c>
66
- # 1 year
67
- Header set Cache-Control 'public, max-age 31536000'
68
- </IfModule>
69
- </IfModule>
@@ -1,5 +0,0 @@
1
- User-agent: *
2
- Allow: /
3
- # Disallow: /
4
-
5
- Sitemap: https://www.example.com/sitemap.xml
@@ -1,115 +0,0 @@
1
- import terser from '@rollup/plugin-terser';
2
- import fs from 'fs';
3
- import node_resolve from '@rollup/plugin-node-resolve';
4
- import commonjs from '@rollup/plugin-commonjs';
5
-
6
- // https://github.com/hyhappy/rollup-plugin-string-html
7
- // import htmlString from 'rollup-plugin-string-html';
8
-
9
- // https://github.com/exuanbo/rollup-plugin-minify-html-template-literals
10
- // https://github.com/asyncLiz/minify-html-literals
11
- // https://github.com/kangax/html-minifier#options-quick-reference
12
- // import minifyHTML from 'rollup-plugin-minify-html-template-literals';
13
-
14
- import p from '../package.json'; // assert { type: 'json' };
15
-
16
- const terserOptions = {
17
- compress: {
18
- passes: 2
19
- }
20
- },
21
- anno = new Date().getFullYear(),
22
- dirs = [
23
- {source_dir: './front-end/js', output_dir: './AppBundle/Resources/public/js'}
24
- ];
25
-
26
- let config = [];
27
-
28
- // lettura subdir apps e aggiunta a `dirs`
29
- fs.readdirSync('./front-end/apps').forEach(item => {
30
- let stats = fs.statSync(`./front-end/apps/${item}`); // stats.isFile() / stats.isDirectory()
31
- if(stats.isDirectory()) {
32
- dirs.push({
33
- source_dir: `./front-end/apps/${item}`,
34
- output_dir: `./AppBundle/Resources/public/apps/${item}`
35
- });
36
- }
37
- });
38
-
39
- dirs.forEach(dir => {
40
-
41
- fs.readdirSync(dir.source_dir)
42
- .filter(f => /\.js$/.test(f))
43
- .filter(f => /^[^_]/.test(f)) // ignore files starting with _
44
- .forEach(file => {
45
-
46
- let format = 'iife',
47
- name = null;
48
-
49
- if(/(-umd\.js)$/.test(file)) {
50
- format = 'umd';
51
- name = file.replace('-umd.js', '').replace(/-/g, '_');
52
- }
53
-
54
- config.push(
55
- {
56
- // preserveEntrySignatures: false,
57
- input: `${dir.source_dir}/${file}`,
58
- plugins: [
59
- // deve essere il primo
60
- // minifyHTML({
61
- // options: {
62
- // minifyOptions: {
63
- // html5: true,
64
- // collapseWhitespace: true,
65
- // collapseInlineTagWhitespace: true,
66
- // conservativeCollapse: true,
67
- // decodeEntities: true
68
- // },
69
- // shouldMinify: () => true
70
- // },
71
- // }),
72
- node_resolve(),
73
- commonjs(),
74
- terser(terserOptions),
75
- ],
76
- output: [{
77
- file: `${dir.output_dir}/${file.replace('.js', '-min.js')}`,
78
- format: format,
79
- sourcemap: true,
80
- name: name,
81
- banner: `/*! xxxx v.${p.version} - Massimo Cassandro ${anno} */`,
82
- // footer: `//! Released on ${new Date().toLocaleString('it-IT', { year: 'numeric', month: 'short', day: '2-digit', hour12: false, hour:'2-digit', minute:'2-digit' })}`
83
- }]
84
- }
85
- );
86
-
87
- });
88
- });
89
-
90
- export default config;
91
-
92
-
93
- // versione statica
94
-
95
- // export default [
96
- // {
97
- // input: 'input.js',
98
- // plugins: [
99
- // node_resolve(),
100
- // // commonjs(),
101
- // terser({ compress: { passes: 2 } }),
102
- // ],
103
- // output: [
104
- // {
105
- // file: 'output.min.js',
106
- // format: 'iife',
107
- // sourcemap: true,
108
-
109
- // banner: `/*! xxxx v.${p.version} - Massimo Cassandro ${anno} */`,
110
- // // footer: `//! Released on ${new Date().toLocaleString('it-IT', { year: 'numeric', month: 'short', day: '2-digit', hour12: false, hour:'2-digit', minute:'2-digit' })}`
111
- // }
112
- // ]
113
- // },
114
- // ...
115
- // ];
File without changes
File without changes
File without changes