@massimo-cassandro/minimo 1.11.0 → 1.11.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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@massimo-cassandro/minimo",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.1",
|
|
4
4
|
"description": "Light css framework & utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"url": "git+https://github.com/massimo-cassandro/minimo.git"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
|
-
"test": "node --test \"test/**/*.test.mjs\"",
|
|
35
34
|
"UPD-version": "npx update-version # --config=./dev-utilities.config.mjs",
|
|
36
35
|
"npm-publish": "npm publish",
|
|
37
36
|
"upd@m": "npx upd@m",
|
|
38
37
|
"build-tokens": "node ./design-tokens/utilities/build-tokens.mjs --config ./design-tokens/tokens-config.mjs",
|
|
39
38
|
"check unresolved props": "node ./design-tokens/utilities/check-unresolved-custom-props.mjs --config ./design-tokens/tokens-config.mjs",
|
|
39
|
+
"test": "node --test \"test/**/*.test.mjs\"",
|
|
40
40
|
"checkJS": "npx tsc --noEmit -p jsconfig.json",
|
|
41
41
|
"checkJS ./src": "npx tsc --noEmit --allowJs --checkJs --target ES2023 --module ESNext --allowSyntheticDefaultImports --moduleResolution bundler declarations.d.ts src/**/*.js"
|
|
42
42
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// import './form.css'; // included in the main CSS entry point
|
|
2
|
-
import { enableSubmitBtns } from '
|
|
2
|
+
import { enableSubmitBtns } from '../utilities/enable-submit-btns.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Wires up submit validation and button-disabling behaviour on all forms.
|
|
@@ -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
|
-
|
|
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
|
|
66
|
-
|
|
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 => {
|