mypgs 1.6.0 → 2.1.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.
- package/AGENTS.md +2 -2
- package/README.md +25 -25
- package/assets/javascript/components/_accordion.js +2 -2
- package/assets/javascript/components/_modals.js +159 -136
- package/assets/javascript/components/_notifications.js +19 -9
- package/assets/javascript/components/_search.js +2 -2
- package/assets/javascript/components/_slides.js +66 -32
- package/assets/javascript/components/_stepTabs.js +4 -4
- package/assets/javascript/components/_steps.js +2 -2
- package/assets/javascript/components/_summary.js +2 -2
- package/assets/javascript/functions/_formValidate.js +97 -53
- package/assets/javascript/functions/_scrollY.js +10 -10
- package/assets/javascript/layout/_header.js +3 -0
- package/assets/scss/base/_html.scss +2 -2
- package/assets/scss/base/_variables.scss +2 -2
- package/assets/scss/components/_accordion.scss +0 -2
- package/assets/scss/components/_button.scss +1 -1
- package/assets/scss/components/_form.scss +2 -18
- package/assets/scss/components/_formAddon.scss +18 -0
- package/assets/scss/components/_modals.scss +5 -3
- package/assets/scss/components/_notification.scss +23 -30
- package/assets/scss/components/_search.scss +29 -23
- package/assets/scss/components/_slides.scss +0 -1
- package/assets/scss/components/_tooltip.scss +0 -1
- package/assets/scss/index.scss +1 -0
- package/assets/scss/layout/_footer.scss +0 -2
- package/assets/scss/layout/_header.scss +9 -1
- package/assets/scss/layout/_pageShell.scss +24 -17
- package/assets/scss/mixin/_mx-button.scss +30 -76
- package/assets/scss/mixin/_mx-card.scss +11 -9
- package/assets/scss/mixin/_mx-form.scss +10 -12
- package/assets/scss/mixin/{_mx-form-addon.scss → _mx-formAddon.scss} +23 -26
- package/assets/scss/mixin/_mx-hover.scss +75 -0
- package/assets/scss/mixin/_settings.scss +2 -1
- package/assets/scss/mixin/mixin.scss +2 -1
- package/{templates/html → demo}/demo.html +1 -1
- package/demo/demo.js +241 -0
- package/dist/css/index.css +1317 -1674
- package/dist/css/index.css.map +1 -1
- package/dist/css/index.min.css +1 -1
- package/dist/javascript/index.js +356 -255
- package/dist/javascript/index.js.map +1 -1
- package/dist/javascript/index.min.js +1 -1
- package/docs/componenti-e-markup.md +32 -32
- package/docs/components/accordion.md +61 -0
- package/docs/components/badges.md +67 -0
- package/docs/components/breadcumbs.md +43 -0
- package/docs/components/button.md +59 -0
- package/docs/components/card.md +50 -0
- package/docs/components/dropdown.md +135 -0
- package/docs/components/form.md +136 -0
- package/docs/components/formAddon.md +79 -0
- package/docs/components/logo.md +36 -0
- package/docs/components/menu.md +90 -0
- package/docs/components/modal.md +131 -0
- package/docs/components/notification.md +81 -0
- package/docs/components/search.md +118 -0
- package/docs/components/slides.md +85 -0
- package/docs/components/stepTabs.md +93 -0
- package/docs/components/steps.md +56 -0
- package/docs/components/summary.md +49 -0
- package/docs/components/table.md +42 -0
- package/docs/components/tooltip.md +53 -0
- package/docs/convenzioni.md +11 -11
- package/docs/export-e-sviluppo.md +3 -3
- package/docs/helper-javascript.md +73 -8
- package/docs/layout/body.md +41 -0
- package/docs/layout/flex.md +116 -0
- package/docs/layout/footer.md +71 -0
- package/docs/layout/grid.md +116 -0
- package/docs/layout/header.md +116 -0
- package/docs/layout/pageShell.md +94 -0
- package/docs/layout/section.md +69 -0
- package/docs/patterns/cookieConsent.md +89 -0
- package/docs/utilizzo-css-scss.md +8 -8
- package/package.json +2 -1
- package/scripts/generate-component-docs.js +557 -0
- package/templates/html/components/accordion.html +36 -7
- package/templates/html/components/badges.html +28 -5
- package/templates/html/components/breadcumbs.html +15 -1
- package/templates/html/components/button.html +28 -6
- package/templates/html/components/card.html +28 -8
- package/templates/html/components/dropdown.html +42 -8
- package/templates/html/components/form.html +110 -9
- package/templates/html/components/formAddon.html +72 -0
- package/templates/html/components/logo.html +22 -1
- package/templates/html/components/menu.html +33 -6
- package/templates/html/components/modal.html +58 -14
- package/templates/html/components/notification.html +68 -32
- package/templates/html/components/search.html +85 -8
- package/templates/html/components/slides.html +46 -3
- package/templates/html/components/stepTabs.html +55 -8
- package/templates/html/components/steps.html +24 -0
- package/templates/html/components/summary.html +30 -3
- package/templates/html/components/table.html +14 -2
- package/templates/html/components/tooltip.html +35 -0
- package/templates/html/layout/body.html +20 -6
- package/templates/html/layout/flex.html +53 -33
- package/templates/html/layout/footer.html +32 -4
- package/templates/html/layout/grid.html +53 -33
- package/templates/html/layout/header.html +47 -6
- package/templates/html/layout/pageShell.html +19 -0
- package/templates/html/layout/section.html +41 -19
- package/templates/html/patterns/cookieConsent.html +44 -13
- package/templates/react/components/accordion.jsx +4 -4
- package/templates/react/components/breadcumbs.jsx +1 -1
- package/templates/react/components/button.jsx +5 -5
- package/templates/react/components/card.jsx +4 -4
- package/templates/react/components/dropdown.jsx +8 -8
- package/templates/react/components/form.jsx +5 -5
- package/templates/react/components/modal.jsx +14 -14
- package/templates/react/components/notification.jsx +7 -7
- package/templates/react/components/search.jsx +5 -5
- package/templates/react/components/slides.jsx +3 -3
- package/templates/react/components/stepTabs.jsx +8 -8
- package/templates/react/components/summary.jsx +3 -3
- package/templates/react/components/table.jsx +2 -2
- package/templates/react/layout/flex.jsx +8 -8
- package/templates/react/layout/grid.jsx +8 -8
- package/templates/react/layout/section.jsx +12 -12
- package/templates/react/patterns/cookieConsent.jsx +8 -8
- package/templates/react/patterns/footer.jsx +4 -4
- package/templates/react/patterns/header.jsx +3 -3
- package/templates/html/demo.js +0 -130
- /package/{templates/html → demo}/demo.css +0 -0
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
//== checked
|
|
21
21
|
&:has(input:checked) {
|
|
22
22
|
background-color: var(--color-primary-soft);
|
|
23
|
-
color: var(--color-black);
|
|
24
23
|
|
|
24
|
+
// color: var(--color-black);
|
|
25
25
|
i {
|
|
26
|
-
--fa-primary-color: var(--color-black);
|
|
27
|
-
--fa-secondary-color: var(--color-black);
|
|
28
|
-
color: var(--color-black);
|
|
26
|
+
// --fa-primary-color: var(--color-black);
|
|
27
|
+
// --fa-secondary-color: var(--color-black);
|
|
28
|
+
// color: var(--color-black);
|
|
29
29
|
opacity: 1;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -33,36 +33,33 @@
|
|
|
33
33
|
|
|
34
34
|
//= TWOSTATE
|
|
35
35
|
@mixin twoState() {
|
|
36
|
+
//== label
|
|
36
37
|
position: relative;
|
|
37
38
|
isolation: isolate;
|
|
38
|
-
--button-background-active: var(--color-primary
|
|
39
|
+
--button-background-active: var(--color-primary);
|
|
39
40
|
--button-color-active: var(--color-white);
|
|
41
|
+
@include button();
|
|
42
|
+
flex-wrap: wrap;
|
|
43
|
+
display: flex !important;
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
|
|
46
|
+
i {
|
|
47
|
+
opacity: 0.4;
|
|
48
|
+
min-width: 1.4rem;
|
|
49
|
+
transition: 300ms;
|
|
50
|
+
}
|
|
40
51
|
|
|
41
|
-
|
|
42
|
-
label {
|
|
43
|
-
@include button();
|
|
44
|
-
flex-wrap: wrap;
|
|
45
|
-
display: flex !important;
|
|
46
|
-
cursor: pointer;
|
|
47
|
-
|
|
52
|
+
&:hover {
|
|
48
53
|
i {
|
|
49
|
-
|
|
50
|
-
opacity: 0.4;
|
|
51
|
-
min-width: 1.4rem;
|
|
52
|
-
transition: 300ms;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
&:hover {
|
|
56
|
-
i {
|
|
57
|
-
opacity: 1;
|
|
58
|
-
}
|
|
54
|
+
opacity: 1;
|
|
59
55
|
}
|
|
60
56
|
}
|
|
61
57
|
|
|
62
58
|
//== checked
|
|
63
|
-
&:has(input:checked)
|
|
59
|
+
&:has(input:checked) {
|
|
64
60
|
--button-background: var(--button-background-active);
|
|
65
|
-
|
|
61
|
+
--button-color: var(--button-color-active);
|
|
62
|
+
|
|
66
63
|
@supports not (color: contrast-color(red)) {
|
|
67
64
|
--button-color: var(--button-color-active);
|
|
68
65
|
}
|
|
@@ -178,6 +175,6 @@
|
|
|
178
175
|
|
|
179
176
|
label {
|
|
180
177
|
outline: unset;
|
|
181
|
-
--button-background:
|
|
178
|
+
--button-background: var(--color-box-transparent);
|
|
182
179
|
}
|
|
183
|
-
}
|
|
180
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
@mixin _hoverColor() {
|
|
2
|
+
$color: var(--color-primary-strong);
|
|
3
|
+
$colorTxtSafari: var(--color-white);
|
|
4
|
+
--hover-color: #{$colorTxtSafari};
|
|
5
|
+
--hover-background: #{$color};
|
|
6
|
+
color: var(--hover-color);
|
|
7
|
+
--fa-primary-color: var(--hover-color);
|
|
8
|
+
--fa-secondary-color: var(--hover-color);
|
|
9
|
+
background: var(--hover-background);
|
|
10
|
+
|
|
11
|
+
:is(h1, h2, h3, h4, h5, h6, p) {
|
|
12
|
+
color: var(--hover-color);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//+ HOVER
|
|
17
|
+
@mixin _hoverContent1() {
|
|
18
|
+
@media (hover: hover) and (pointer: fine) {
|
|
19
|
+
|
|
20
|
+
&:focus-visible,
|
|
21
|
+
&:hover {
|
|
22
|
+
box-shadow: 0px 0px 38px 0px var(--hover-shadow-color);
|
|
23
|
+
// outline-color: var(--color-primary);
|
|
24
|
+
@include _hoverColor();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@mixin _hoverContent2() {
|
|
30
|
+
@media (hover: hover) and (pointer: fine) {
|
|
31
|
+
|
|
32
|
+
&:focus-visible,
|
|
33
|
+
&:hover {
|
|
34
|
+
$n: var(--hover-shadow-displacement);
|
|
35
|
+
$-n: calc(var(--hover-shadow-displacement) * -1);
|
|
36
|
+
box-shadow: $-n $n 0 var(--color-black);
|
|
37
|
+
transform: translate($n, $-n);
|
|
38
|
+
outline-color: transparent;
|
|
39
|
+
@include _hoverColor();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//= HOVER
|
|
45
|
+
@mixin hover() {
|
|
46
|
+
transition: all 200ms;
|
|
47
|
+
cursor: pointer;
|
|
48
|
+
text-decoration: none;
|
|
49
|
+
--hover-shadow-color: var(--color-primary);
|
|
50
|
+
--hover-shadow-displacement: 0.25rem;
|
|
51
|
+
$color: var(--color-primary-strong);
|
|
52
|
+
$colorTxtSafari: var(--color-whiteFixed);
|
|
53
|
+
|
|
54
|
+
&:not(:disabled) {
|
|
55
|
+
&:not([pgs-option~=buttonStyle-2]) {
|
|
56
|
+
@include _hoverContent1();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&[pgs-option~=buttonStyle-2] {
|
|
60
|
+
@include _hoverContent2();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&:hover {
|
|
64
|
+
--fa-secondary-opacity: 0.5;
|
|
65
|
+
--hover-color: var(--color-whiteFixed);
|
|
66
|
+
color: var(--hover-color);
|
|
67
|
+
--fa-primary-color: var(--hover-color);
|
|
68
|
+
--fa-secondary-color: var(--hover-color);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
&:is(a):hover {
|
|
73
|
+
text-decoration: none;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
10
10
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Urbanist:ital,wght@0,100..900;1,100..900&display=swap">
|
|
11
11
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">
|
|
12
|
-
<link rel="stylesheet" href="
|
|
12
|
+
<link rel="stylesheet" href="../dist/css/index.css">
|
|
13
13
|
<link rel="stylesheet" href="demo.css">
|
|
14
14
|
</head>
|
|
15
15
|
|
package/demo/demo.js
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
//# DEMO PAGE
|
|
2
|
+
|
|
3
|
+
//= demo Renderer HTML
|
|
4
|
+
const demoRenderer = {
|
|
5
|
+
templateFiles: [
|
|
6
|
+
"components/form.html",
|
|
7
|
+
"components/formAddon.html",
|
|
8
|
+
"components/search.html",
|
|
9
|
+
"components/summary.html",
|
|
10
|
+
"components/menu.html",
|
|
11
|
+
"components/tooltip.html",
|
|
12
|
+
"components/modal.html",
|
|
13
|
+
"components/stepTabs.html",
|
|
14
|
+
"components/accordion.html",
|
|
15
|
+
"components/badges.html",
|
|
16
|
+
"components/breadcumbs.html",
|
|
17
|
+
"components/button.html",
|
|
18
|
+
"components/card.html",
|
|
19
|
+
"components/dropdown.html",
|
|
20
|
+
"components/tooltip.html",
|
|
21
|
+
"components/logo.html",
|
|
22
|
+
"components/slides.html",
|
|
23
|
+
"components/steps.html",
|
|
24
|
+
"components/table.html",
|
|
25
|
+
"components/notification.html",
|
|
26
|
+
"patterns/cookieConsent.html",
|
|
27
|
+
"layout/body.html",
|
|
28
|
+
"layout/flex.html",
|
|
29
|
+
"layout/grid.html",
|
|
30
|
+
"layout/footer.html",
|
|
31
|
+
"layout/header.html",
|
|
32
|
+
"layout/section.html",
|
|
33
|
+
"layout/pageShell.html",
|
|
34
|
+
],
|
|
35
|
+
|
|
36
|
+
getTemplateTitle(path) {
|
|
37
|
+
return path.replace(".html", "").replace("/", " / ");
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
stripTemplateDocumentation(html) {
|
|
41
|
+
return html.replace(/^\uFEFF?<!--[\t\r\n ]*\/\*\*[\s\S]*?\*\/[\t\r\n ]*-->[\t\r\n ]*/, "");
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
renderSourceTemplate(section, html) {
|
|
45
|
+
const pre = document.createElement("pre");
|
|
46
|
+
const code = document.createElement("code");
|
|
47
|
+
code.textContent = html.trim();
|
|
48
|
+
pre.append(code);
|
|
49
|
+
section.append(pre);
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
renderTemplate(section, path, html) {
|
|
53
|
+
const content = document.createElement("div");
|
|
54
|
+
content.setAttribute("pgs", "container flexColumnElements");
|
|
55
|
+
content.innerHTML = html;
|
|
56
|
+
section.append(content);
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
renderLayout(root, path, html) {
|
|
60
|
+
const template = document.createElement("template");
|
|
61
|
+
template.innerHTML = html.trim();
|
|
62
|
+
root.append(template.content.cloneNode(true));
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
renderTitle(section, path) {
|
|
66
|
+
const title = document.createElement("p");
|
|
67
|
+
title.classList.add("template-title");
|
|
68
|
+
title.innerHTML = "<strong>" + this.getTemplateTitle(path) + "</strong>";
|
|
69
|
+
section.append(title);
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
async loadTemplate(path) {
|
|
73
|
+
const response = await fetch(`../templates/html/${path}`);
|
|
74
|
+
if (!response.ok) throw new Error(`${path}: ${response.status}`);
|
|
75
|
+
return this.stripTemplateDocumentation(await response.text());
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
loadPgsJavascript() {
|
|
79
|
+
return new Promise((resolve, reject) => {
|
|
80
|
+
const script = document.createElement("script");
|
|
81
|
+
script.src = "../dist/javascript/index.js";
|
|
82
|
+
script.addEventListener("load", resolve, { once: true });
|
|
83
|
+
script.addEventListener("error", () => reject(new Error("Bundle PGS non caricato")), { once: true });
|
|
84
|
+
document.body.append(script);
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
async boot() {
|
|
89
|
+
const BEEFORE = document.getElementById("templates-demo-before");
|
|
90
|
+
const MAIN = document.getElementById("templates-demo-main");
|
|
91
|
+
const AFTER = document.getElementById("templates-demo-after");
|
|
92
|
+
|
|
93
|
+
for (const path of this.templateFiles) {
|
|
94
|
+
const isHeader = path === "layout/header.html";
|
|
95
|
+
const isfooter = path === "layout/footer.html";
|
|
96
|
+
const isBody = path === "layout/body.html";
|
|
97
|
+
|
|
98
|
+
if (isHeader || isfooter) {
|
|
99
|
+
try {
|
|
100
|
+
const html = await this.loadTemplate(path);
|
|
101
|
+
this.renderLayout(isHeader ? BEEFORE : AFTER, path, html);
|
|
102
|
+
} catch (error) {
|
|
103
|
+
const message = document.createElement("p");
|
|
104
|
+
message.textContent = `Template non caricato: ${error.message}`;
|
|
105
|
+
(isHeader ? BEEFORE : AFTER).append(message);
|
|
106
|
+
}
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
let section;
|
|
111
|
+
const isSection = path !== "layout/section.html" && path !== "layout/pageShell.html"
|
|
112
|
+
isSection ? section = document.createElement("section") : section = document.createElement("div");
|
|
113
|
+
|
|
114
|
+
if (isSection) section.setAttribute("pgs", "section flexColumnElements");
|
|
115
|
+
|
|
116
|
+
section.dataset.template = path;
|
|
117
|
+
this.renderTitle(section, path);
|
|
118
|
+
|
|
119
|
+
if (isBody) {
|
|
120
|
+
const html = await this.loadTemplate(path);
|
|
121
|
+
this.renderSourceTemplate(section, html);
|
|
122
|
+
MAIN.append(section);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
try {
|
|
127
|
+
const html = await this.loadTemplate(path);
|
|
128
|
+
this.renderTemplate(section, path, html);
|
|
129
|
+
} catch (error) {
|
|
130
|
+
const message = document.createElement("p");
|
|
131
|
+
message.textContent = `Template non caricato: ${error.message}`;
|
|
132
|
+
section.append(message);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
MAIN.append(section);
|
|
136
|
+
if (!isSection) {
|
|
137
|
+
section.style.display = "contents";
|
|
138
|
+
Array.from(section.children).forEach(child => child.style.width = "100%");
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
try {
|
|
143
|
+
//+ ADD FUNCTION
|
|
144
|
+
await this.loadPgsJavascript();
|
|
145
|
+
configureSearchDemo();
|
|
146
|
+
configureFormDemo();
|
|
147
|
+
} catch (error) {
|
|
148
|
+
console.error("Demo PGS non inizializzata.", error);
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
//= Search Demo
|
|
154
|
+
function configureSearchDemo() {
|
|
155
|
+
const pgsApi = globalThis.pgs;
|
|
156
|
+
const section = document.querySelector('[data-template="components/search.html"]');
|
|
157
|
+
if (!pgsApi?.search || !section) return;
|
|
158
|
+
|
|
159
|
+
pgsApi(section).querySelectorAll("search").forEach(search => {
|
|
160
|
+
pgsApi.search.api(search)?.configure({
|
|
161
|
+
minLength: 2,
|
|
162
|
+
debounce: 250,
|
|
163
|
+
source: async ({ query, signal, limit }) => {
|
|
164
|
+
const url = new URL("https://it.wikipedia.org/w/api.php");
|
|
165
|
+
url.search = new URLSearchParams({
|
|
166
|
+
action: "opensearch",
|
|
167
|
+
search: query,
|
|
168
|
+
limit: String(limit),
|
|
169
|
+
namespace: "0",
|
|
170
|
+
format: "json",
|
|
171
|
+
origin: "*",
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
const response = await fetch(url, { signal });
|
|
175
|
+
if (!response.ok) throw new Error(`Wikipedia HTTP ${response.status}`);
|
|
176
|
+
|
|
177
|
+
const payload = await response.json();
|
|
178
|
+
const suggestions = Array.isArray(payload?.[1]) ? payload[1] : [];
|
|
179
|
+
const descriptions = Array.isArray(payload?.[2]) ? payload[2] : [];
|
|
180
|
+
const links = Array.isArray(payload?.[3]) ? payload[3] : [];
|
|
181
|
+
|
|
182
|
+
return suggestions.map((suggestion, index) => ({
|
|
183
|
+
label: suggestion,
|
|
184
|
+
value: suggestion,
|
|
185
|
+
data: {
|
|
186
|
+
description: descriptions[index] ?? "",
|
|
187
|
+
url: links[index] ?? "",
|
|
188
|
+
},
|
|
189
|
+
}));
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const note = document.createElement("small");
|
|
195
|
+
note.append("Suggerimenti dimostrativi forniti da ");
|
|
196
|
+
const link = document.createElement("a");
|
|
197
|
+
link.href = "https://www.mediawiki.org/wiki/API:Opensearch/it";
|
|
198
|
+
link.target = "_blank";
|
|
199
|
+
link.rel = "noopener noreferrer";
|
|
200
|
+
link.textContent = "Wikipedia OpenSearch";
|
|
201
|
+
note.append(link, ". Prova a scrivere prodotti di o come fare.");
|
|
202
|
+
section.append(note);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
//= Form Demo
|
|
206
|
+
function configureFormDemo() {
|
|
207
|
+
const pgsApi = globalThis.pgs;
|
|
208
|
+
const section = document.querySelector('[data-template="components/form.html"]');
|
|
209
|
+
const form = section?.querySelector('[pgs~="form"]');
|
|
210
|
+
if (!form) return;
|
|
211
|
+
|
|
212
|
+
const password = form.querySelector('input[name="password"]');
|
|
213
|
+
const confirmPassword = form.querySelector('input[name="confirmPassword"]');
|
|
214
|
+
if (!password || !confirmPassword) return;
|
|
215
|
+
|
|
216
|
+
const formValidate = new pgsApi.formValidate(form, {
|
|
217
|
+
message: {
|
|
218
|
+
fieldError: "Please complete this field",
|
|
219
|
+
fieldsError: "Please complete all required fields",
|
|
220
|
+
success: "Sent successfully"
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
//== new roules
|
|
225
|
+
formValidate.addNewRule(() => {
|
|
226
|
+
if (password.value && confirmPassword.value && password.value !== confirmPassword.value) {
|
|
227
|
+
pgsApi(confirmPassword).option.setValueBrackets("message", "Le password non coincidono");
|
|
228
|
+
return [confirmPassword, password];
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
//== validate
|
|
233
|
+
formValidate.validator(event => {
|
|
234
|
+
const values = Object.fromEntries(new FormData(form));
|
|
235
|
+
|
|
236
|
+
//// Sostituisci questo log con l'invio dei dati al tuo backend.
|
|
237
|
+
console.log(values);
|
|
238
|
+
}, "submit");
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
demoRenderer.boot();
|