@massimo-cassandro/minimo 1.11.0 → 1.12.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 (32) hide show
  1. package/dev-tools/README.md +1 -1
  2. package/dev-tools/update-version/index.mjs +1 -1
  3. package/dev-tools/update-version/src/chooser-inquirer.mjs +1 -1
  4. package/dev-tools/webpack-setup/starter-install.sh +149 -0
  5. package/dev-tools/webpack-setup/templates/__project__.code-workspace +93 -0
  6. package/dev-tools/webpack-setup/templates/_browserslistrc +27 -0
  7. package/dev-tools/webpack-setup/templates/_editorconfig +17 -0
  8. package/dev-tools/webpack-setup/templates/_gitignore +21 -0
  9. package/dev-tools/webpack-setup/templates/_prettierrc +9 -0
  10. package/dev-tools/webpack-setup/templates/eslint.config.mjs +31 -0
  11. package/dev-tools/webpack-setup/templates/jsconfig.json +22 -0
  12. package/dev-tools/webpack-setup/templates/package-tpl.json +37 -0
  13. package/dev-tools/webpack-setup/templates/stylelint.config.mjs +32 -0
  14. package/dev-tools/webpack-setup/webpack-modules/css-rules.mjs +177 -0
  15. package/dev-tools/webpack-setup/webpack-modules/get-jsConfig-aliases.mjs +33 -0
  16. package/dev-tools/webpack-setup/webpack-modules/postcss.config.mjs +77 -0
  17. package/dev-tools/webpack-setup/webpack-modules/svg-rules.mjs +154 -0
  18. package/dev-tools/webpack-setup/webpack-modules/svgo.config.mjs +26 -0
  19. package/dev-tools/webpack-setup/webpack-template.ejs +20 -0
  20. package/dev-tools/webpack-setup/webpack.config.mjs +585 -0
  21. package/package.json +6 -3
  22. package/snippets/ImgViewerController.php +403 -0
  23. package/snippets/UnsplashController.php +74 -0
  24. package/snippets/controllo-codice-fiscale-IT.js +48 -0
  25. package/snippets/controllo-partita-iva-IT.js +32 -0
  26. package/snippets/email-antispam.js +108 -0
  27. package/snippets/error-pages/bundles/TwigBundle/Exception/error.html.twig +33 -0
  28. package/snippets/error-pages/error-pages.js +37 -0
  29. package/snippets/festivita.js +101 -0
  30. package/snippets/minimo-form-layout.html.twig +446 -0
  31. package/src/components/form-reset-submit.js +1 -1
  32. package/src/utilities/better-text.js +39 -30
@@ -1,5 +1,41 @@
1
1
  // @ts-check
2
2
 
3
+ // Italian particles/articles (plus a few English and topographic terms) whose casing is
4
+ // enforced and after which spaces are turned into non-breaking spaces. Hoisted to module
5
+ // scope with the regexes/lookup built from it below, since none of this depends on the
6
+ // function's arguments and was previously rebuilt on every single betterText() call.
7
+ const PARTICELLE = [
8
+ 'e', 'ed',
9
+ 'di', 'a', 'da', 'in', 'per', 'con', 'su', 'per', 'tra', 'fra',
10
+ 'il', 'lo', 'la', 'i', 'gli', 'le',
11
+ 'un', 'uno', 'una',
12
+ 'del', 'dello', 'della', 'dei', 'degli', 'delle',
13
+ 'al', 'allo', 'alla', 'ai', 'agli', 'alle',
14
+ 'dal', 'dallo', 'dalla', 'dai', 'dagli', 'dalle',
15
+ 'nel', 'nello', 'nella', 'nei', 'negli', 'nelle',
16
+ 'col', 'collo', 'colla', 'con', 'coi', 'cogli', 'colle',
17
+ 'sul', 'sullo', 'sulla', 'sui', 'sugli', 'sulle',
18
+
19
+ // topographic terms
20
+ 'C.so', 'Corso', 'Via', 'P.za', 'Piazza', 'L.go', 'Largo', 'V.le', 'Viale',
21
+ 'De', 'San', 'c/o', 'Loc.',
22
+
23
+ // English
24
+ 'the', 'a', 'an', 'at', 'out', 'of',
25
+
26
+ // words used in geonames
27
+ 'isola', 'isole'
28
+ ];
29
+
30
+ // matches a particle followed by one-or-more spaces, to be turned into non-breaking spaces
31
+ const NBSP_AFTER_PARTICLE_REGEX = new RegExp('\\b(' + PARTICELLE.join('|') + ')\\b +', 'gmi');
32
+
33
+ // matches any particle regardless of case, to enforce its exact casing in a single pass
34
+ const PARTICLE_CASING_REGEX = new RegExp('\\b(' + PARTICELLE.join('|') + ')\\b', 'gmi');
35
+
36
+ // lowercased particle → its exact casing, for the replacer used with PARTICLE_CASING_REGEX
37
+ const PARTICLE_CASING_MAP = new Map(PARTICELLE.map(term => [term.toLowerCase(), term]));
38
+
3
39
  /**
4
40
  * Improves a text string by fixing punctuation spacing, multiple spaces,
5
41
  * typographic quotes, non-breaking spaces after Italian particles/articles,
@@ -11,29 +47,6 @@
11
47
  */
12
48
  export function betterText(str, custom_words = []) {
13
49
 
14
- const particelle = [
15
- 'e', 'ed',
16
- 'di', 'a', 'da', 'in', 'per', 'con', 'su', 'per', 'tra', 'fra',
17
- 'il', 'lo', 'la', 'i', 'gli', 'le',
18
- 'un', 'uno', 'una',
19
- 'del', 'dello', 'della', 'dei', 'degli', 'delle',
20
- 'al', 'allo', 'alla', 'ai', 'agli', 'alle',
21
- 'dal', 'dallo', 'dalla', 'dai', 'dagli', 'dalle',
22
- 'nel', 'nello', 'nella', 'nei', 'negli', 'nelle',
23
- 'col', 'collo', 'colla', 'con', 'coi', 'cogli', 'colle',
24
- 'sul', 'sullo', 'sulla', 'sui', 'sugli', 'sulle',
25
-
26
- // topographic terms
27
- 'C.so', 'Corso', 'Via', 'P.za', 'Piazza', 'L.go', 'Largo', 'V.le', 'Viale',
28
- 'De', 'San', 'c/o', 'Loc.',
29
-
30
- // English
31
- 'the', 'a', 'an', 'at', 'out', 'of',
32
-
33
- // words used in geonames
34
- 'isola', 'isole'
35
- ];
36
-
37
50
  if(str) {
38
51
  str = str.trim();
39
52
 
@@ -57,16 +70,12 @@ export function betterText(str, custom_words = []) {
57
70
  str = str.replace(/((^| )(l|un|d|all|dell|nell|sull)('|')) /gi, '$1' );
58
71
 
59
72
  // replace regular spaces with non-breaking spaces after Italian particles/articles
60
- var re = new RegExp('\\b(' + particelle.join('|') + ')\\b +', 'gmi');
61
- str = str.replace(re, function (match) {
73
+ str = str.replace(NBSP_AFTER_PARTICLE_REGEX, function (match) {
62
74
  return match.replace(/ +/g, '\u00A0');
63
75
  });
64
76
 
65
- // enforce exact casing of each particle
66
- particelle.forEach(term => {
67
- const re = new RegExp('\\b(' + term + ')\\b', 'gmi');
68
- str = str.replace(re, term);
69
- });
77
+ // enforce exact casing of every particle in a single pass
78
+ str = str.replace(PARTICLE_CASING_REGEX, match => PARTICLE_CASING_MAP.get(match.toLowerCase()) ?? match);
70
79
 
71
80
  if(custom_words.length) {
72
81
  custom_words.forEach(item => {