mypgs 2.0.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/README.md +25 -25
- package/assets/scss/components/_accordion.scss +0 -2
- package/assets/scss/components/_button.scss +1 -1
- package/assets/scss/components/_form.scss +0 -16
- package/assets/scss/components/_formAddon.scss +18 -0
- package/assets/scss/components/_modals.scss +5 -3
- package/assets/scss/components/_search.scss +2 -2
- 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 +6 -2
- 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 +3 -5
- 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/demo/demo.js +4 -3
- package/dist/css/index.css +1166 -1517
- package/dist/css/index.css.map +1 -1
- package/dist/css/index.min.css +1 -1
- package/docs/componenti-e-markup.md +6 -5
- package/docs/components/accordion.md +22 -22
- package/docs/components/badges.md +19 -19
- package/docs/components/breadcumbs.md +8 -8
- package/docs/components/button.md +17 -17
- package/docs/components/card.md +19 -19
- package/docs/components/dropdown.md +29 -29
- package/docs/components/form.md +63 -40
- package/docs/components/formAddon.md +79 -0
- package/docs/components/logo.md +11 -11
- package/docs/components/menu.md +20 -20
- package/docs/components/modal.md +46 -46
- package/docs/components/notification.md +34 -34
- package/docs/components/search.md +51 -50
- package/docs/components/slides.md +39 -39
- package/docs/components/stepTabs.md +41 -41
- package/docs/components/steps.md +16 -16
- package/docs/components/summary.md +20 -20
- package/docs/components/table.md +7 -7
- package/docs/components/tooltip.md +22 -22
- package/docs/convenzioni.md +11 -11
- package/docs/export-e-sviluppo.md +3 -3
- package/docs/helper-javascript.md +7 -7
- package/docs/layout/body.md +11 -11
- package/docs/layout/flex.md +44 -44
- package/docs/layout/footer.md +23 -23
- package/docs/layout/grid.md +44 -44
- package/docs/layout/header.md +34 -34
- package/docs/layout/pageShell.md +11 -11
- package/docs/layout/section.md +26 -26
- package/docs/patterns/cookieConsent.md +38 -38
- package/docs/utilizzo-css-scss.md +8 -8
- package/package.json +1 -1
- package/scripts/generate-component-docs.js +5 -5
- package/templates/html/components/accordion.html +19 -19
- package/templates/html/components/badges.html +17 -17
- package/templates/html/components/breadcumbs.html +6 -6
- package/templates/html/components/button.html +15 -15
- package/templates/html/components/card.html +17 -17
- package/templates/html/components/dropdown.html +25 -25
- package/templates/html/components/form.html +58 -35
- package/templates/html/components/formAddon.html +72 -0
- package/templates/html/components/logo.html +9 -9
- package/templates/html/components/menu.html +16 -16
- package/templates/html/components/modal.html +42 -42
- package/templates/html/components/notification.html +30 -30
- package/templates/html/components/search.html +43 -42
- package/templates/html/components/slides.html +31 -31
- package/templates/html/components/stepTabs.html +37 -37
- package/templates/html/components/steps.html +13 -13
- package/templates/html/components/summary.html +17 -17
- package/templates/html/components/table.html +5 -5
- package/templates/html/components/tooltip.html +18 -18
- package/templates/html/layout/body.html +9 -10
- package/templates/html/layout/flex.html +42 -42
- package/templates/html/layout/footer.html +20 -20
- package/templates/html/layout/grid.html +42 -42
- package/templates/html/layout/header.html +32 -32
- package/templates/html/layout/pageShell.html +8 -8
- package/templates/html/layout/section.html +24 -24
- package/templates/html/patterns/cookieConsent.html +33 -33
- 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 +2 -2
- package/templates/react/components/modal.jsx +14 -14
- package/templates/react/components/notification.jsx +3 -3
- 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 +3 -3
- package/templates/react/patterns/header.jsx +3 -3
|
@@ -18,7 +18,7 @@ const SOURCE_ROOTS = [
|
|
|
18
18
|
const TAG_ORDER = ["title", "description", "pgs", "pgs-option", "pgs-state", "api", "related", "return"];
|
|
19
19
|
const LIST_TAGS = new Set(["pgs", "pgs-option", "pgs-state", "api", "related"]);
|
|
20
20
|
const REQUIRED_TAGS = ["title", "description", "pgs"];
|
|
21
|
-
const GENERATED_MARKER = /^<!-- File generato automaticamente da (templates\/html\/.+\.html)\. Modificare \
|
|
21
|
+
const GENERATED_MARKER = /^<!-- (?:Automatically generated from (templates\/html\/.+\.html)\. Edit \1 and run npm run docs:generate again\.|File generato automaticamente da (templates\/html\/.+\.html)\. Modificare \2 e rieseguire npm run docs:generate\.) -->$/;
|
|
22
22
|
|
|
23
23
|
function toPosix(value) {
|
|
24
24
|
return value.split(path.sep).join("/");
|
|
@@ -441,14 +441,14 @@ function renderList(items) {
|
|
|
441
441
|
|
|
442
442
|
function renderMarkdown(template, documentation, markup) {
|
|
443
443
|
const relativeTemplate = relativeToProject(template);
|
|
444
|
-
const marker = `<!--
|
|
444
|
+
const marker = `<!-- Automatically generated from ${relativeTemplate}. Edit ${relativeTemplate} and run npm run docs:generate again. -->`;
|
|
445
445
|
const sections = [marker, "", `# ${documentation.title}`, "", documentation.description];
|
|
446
446
|
const sectionMap = [
|
|
447
447
|
["PGS", documentation.pgs],
|
|
448
448
|
["PGS Options", documentation["pgs-option"]],
|
|
449
449
|
["PGS States", documentation["pgs-state"]],
|
|
450
|
-
["API
|
|
451
|
-
["
|
|
450
|
+
["JavaScript API", documentation.api],
|
|
451
|
+
["Related elements", documentation.related],
|
|
452
452
|
];
|
|
453
453
|
|
|
454
454
|
sectionMap.forEach(([title, items]) => {
|
|
@@ -460,7 +460,7 @@ function renderMarkdown(template, documentation, markup) {
|
|
|
460
460
|
|
|
461
461
|
const runs = [...markup.matchAll(/`+/g)].map(match => match[0].length);
|
|
462
462
|
const fence = "`".repeat(Math.max(3, (runs.length ? Math.max(...runs) : 0) + 1));
|
|
463
|
-
sections.push("", "##
|
|
463
|
+
sections.push("", "## Example", "", `${fence}html`, markup, fence, "");
|
|
464
464
|
return sections.join("\n");
|
|
465
465
|
}
|
|
466
466
|
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
/**
|
|
3
3
|
* @title Accordion
|
|
4
|
-
* @description
|
|
4
|
+
* @description Interactive component that expands one panel at a time while synchronizing visibility, ARIA attributes, and keyboard navigation.
|
|
5
5
|
*
|
|
6
6
|
* @pgs
|
|
7
|
-
* - accordion:
|
|
8
|
-
* - accordion-button:
|
|
9
|
-
* - accordion-content:
|
|
7
|
+
* - accordion: identifies each expandable element initialized by the JavaScript module.
|
|
8
|
+
* - accordion-button: identifies the control that opens or closes the associated panel.
|
|
9
|
+
* - accordion-content: identifies the content panel managed through the hidden attribute.
|
|
10
10
|
*
|
|
11
11
|
* @pgs-state
|
|
12
|
-
* - open:
|
|
12
|
+
* - open: indicates the accordion element that is currently open and visible.
|
|
13
13
|
*
|
|
14
14
|
* @api
|
|
15
|
-
* - pgs.accordion.init(root):
|
|
16
|
-
* - pgs.accordion.api(element):
|
|
17
|
-
* - instance.open():
|
|
18
|
-
* - instance.close():
|
|
19
|
-
* - instance.toggle():
|
|
20
|
-
* - instance.refresh():
|
|
21
|
-
* - instance.isOpen():
|
|
15
|
+
* - pgs.accordion.init(root): initializes unregistered accordions within the specified Document or Element.
|
|
16
|
+
* - pgs.accordion.api(element): returns the instance associated with an initialized accordion root.
|
|
17
|
+
* - instance.open(): opens the panel and closes any other accordions on the page.
|
|
18
|
+
* - instance.close(): closes the current panel.
|
|
19
|
+
* - instance.toggle(): toggles the panel between its open and closed states.
|
|
20
|
+
* - instance.refresh(): reruns initialization within the accordion container and returns the instance.
|
|
21
|
+
* - instance.isOpen(): returns true when the open state is active.
|
|
22
22
|
*
|
|
23
23
|
* @related
|
|
24
|
-
* - flexColumnTexts:
|
|
24
|
+
* - flexColumnTexts: applies text spacing between the list items.
|
|
25
25
|
*
|
|
26
|
-
* @return
|
|
26
|
+
* @return HTML list of accessible accordion items with an associated button and panel.
|
|
27
27
|
*/
|
|
28
28
|
-->
|
|
29
29
|
|
|
@@ -31,22 +31,22 @@
|
|
|
31
31
|
<li pgs="accordion">
|
|
32
32
|
<button pgs="accordion-button" type="button">
|
|
33
33
|
<i class="fa-solid fa-circle-question" aria-hidden="true"></i>
|
|
34
|
-
<span>
|
|
34
|
+
<span>Frequently asked question</span>
|
|
35
35
|
</button>
|
|
36
36
|
|
|
37
37
|
<div pgs="accordion-content" hidden>
|
|
38
|
-
<p>
|
|
38
|
+
<p>Example answer with reusable text content.</p>
|
|
39
39
|
</div>
|
|
40
40
|
</li>
|
|
41
41
|
|
|
42
42
|
<li pgs="accordion">
|
|
43
43
|
<button pgs="accordion-button" type="button">
|
|
44
44
|
<i class="fa-solid fa-circle-info" aria-hidden="true"></i>
|
|
45
|
-
<span>
|
|
45
|
+
<span>Second section</span>
|
|
46
46
|
</button>
|
|
47
47
|
|
|
48
48
|
<div pgs="accordion-content" hidden>
|
|
49
|
-
<p>
|
|
49
|
+
<p>Additional accordion panel content.</p>
|
|
50
50
|
</div>
|
|
51
51
|
</li>
|
|
52
|
-
</ul>
|
|
52
|
+
</ul>
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
/**
|
|
3
3
|
* @title Badge
|
|
4
|
-
* @description
|
|
4
|
+
* @description Collection of compact indicators for displaying categories, priorities, and visual states with consistent color variants.
|
|
5
5
|
*
|
|
6
6
|
* @pgs
|
|
7
|
-
* - badge:
|
|
8
|
-
* - badgePrimary:
|
|
9
|
-
* - badgeStrong:
|
|
10
|
-
* - badgeSuccess:
|
|
11
|
-
* - badgeDot:
|
|
12
|
-
* - badgeWarning:
|
|
13
|
-
* - badgeError:
|
|
14
|
-
* - badgeInfo:
|
|
15
|
-
* - badgeNeutral:
|
|
7
|
+
* - badge: identifies the base badge variant.
|
|
8
|
+
* - badgePrimary: applies the primary color variant.
|
|
9
|
+
* - badgeStrong: applies the high-contrast variant.
|
|
10
|
+
* - badgeSuccess: represents a successful result.
|
|
11
|
+
* - badgeDot: adds a dot indicator to the badge.
|
|
12
|
+
* - badgeWarning: represents a warning.
|
|
13
|
+
* - badgeError: represents an error.
|
|
14
|
+
* - badgeInfo: represents informational content.
|
|
15
|
+
* - badgeNeutral: applies the neutral variant.
|
|
16
16
|
*
|
|
17
17
|
* @related
|
|
18
|
-
* - flexRow:
|
|
18
|
+
* - flexRow: arranges badges horizontally and allows them to wrap.
|
|
19
19
|
*
|
|
20
|
-
* @return
|
|
20
|
+
* @return HTML examples of the available badge variants.
|
|
21
21
|
*/
|
|
22
22
|
-->
|
|
23
23
|
|
|
@@ -35,17 +35,17 @@
|
|
|
35
35
|
</span>
|
|
36
36
|
|
|
37
37
|
<span pgs="badgeSuccess badgeDot">
|
|
38
|
-
|
|
38
|
+
Active
|
|
39
39
|
</span>
|
|
40
40
|
|
|
41
41
|
<span pgs="badgeWarning">
|
|
42
42
|
<i class="fa-solid fa-triangle-exclamation" aria-hidden="true"></i>
|
|
43
|
-
|
|
43
|
+
Warning
|
|
44
44
|
</span>
|
|
45
45
|
|
|
46
46
|
<span pgs="badgeError">
|
|
47
47
|
<i class="fa-solid fa-xmark" aria-hidden="true"></i>
|
|
48
|
-
|
|
48
|
+
Error
|
|
49
49
|
</span>
|
|
50
50
|
|
|
51
51
|
<span pgs="badgeInfo">
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
</span>
|
|
55
55
|
|
|
56
56
|
<span pgs="badgeNeutral" href="#">
|
|
57
|
-
|
|
57
|
+
Neutral
|
|
58
58
|
</span>
|
|
59
59
|
|
|
60
|
-
</div>
|
|
60
|
+
</div>
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
/**
|
|
3
3
|
* @title Breadcrumb
|
|
4
|
-
* @description
|
|
4
|
+
* @description Hierarchical navigation that shows the current page path with links, separators, and a semantic indication of the active item.
|
|
5
5
|
*
|
|
6
6
|
* @pgs
|
|
7
|
-
* - breadcrumb:
|
|
8
|
-
* - breadcrumb-item:
|
|
9
|
-
* - breadcrumb-item-separator:
|
|
7
|
+
* - breadcrumb: identifies the main navigation path list.
|
|
8
|
+
* - breadcrumb-item: identifies each level in the path.
|
|
9
|
+
* - breadcrumb-item-separator: identifies the decorative separator hidden from assistive technologies.
|
|
10
10
|
*
|
|
11
|
-
* @return
|
|
11
|
+
* @return Semantic breadcrumb HTML structure wrapped in a nav element.
|
|
12
12
|
*/
|
|
13
13
|
-->
|
|
14
14
|
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
|
|
31
31
|
<li pgs="breadcrumb-item">
|
|
32
32
|
<span aria-current="page">
|
|
33
|
-
|
|
33
|
+
Sample article
|
|
34
34
|
</span>
|
|
35
35
|
</li>
|
|
36
36
|
</ul>
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
/**
|
|
3
3
|
* @title Button
|
|
4
|
-
* @description
|
|
4
|
+
* @description Button and action-link variants with sizes, emphasis, and icon-text composition defined by the design system.
|
|
5
5
|
*
|
|
6
6
|
* @pgs
|
|
7
|
-
* - button:
|
|
8
|
-
* - buttonStrong:
|
|
9
|
-
* - buttonIcon:
|
|
10
|
-
* - buttonMini:
|
|
11
|
-
* - buttonBig:
|
|
7
|
+
* - button: identifies the standard button, which can also be used on anchor elements.
|
|
8
|
+
* - buttonStrong: applies the variant with stronger visual emphasis.
|
|
9
|
+
* - buttonIcon: identifies a compact button composed primarily of an icon.
|
|
10
|
+
* - buttonMini: applies the smallest size variant.
|
|
11
|
+
* - buttonBig: applies the large size variant.
|
|
12
12
|
*
|
|
13
13
|
* @pgs-option
|
|
14
|
-
* - buttonReverse:
|
|
14
|
+
* - buttonReverse: reverses the visual order of the text and icon on the button.
|
|
15
15
|
*
|
|
16
16
|
* @related
|
|
17
|
-
* - flexRow:
|
|
17
|
+
* - flexRow: arranges the button examples in a flexible row.
|
|
18
18
|
*
|
|
19
|
-
* @return
|
|
19
|
+
* @return HTML collection of the main button variants.
|
|
20
20
|
*/
|
|
21
21
|
-->
|
|
22
22
|
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
</a>
|
|
28
28
|
|
|
29
29
|
<button pgs="button" type="button" pgs-option="buttonReverse">
|
|
30
|
-
|
|
30
|
+
Next
|
|
31
31
|
<i class="fa-solid fa-arrow-right" aria-hidden="true"></i>
|
|
32
32
|
</button>
|
|
33
33
|
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
Submit
|
|
37
37
|
</button>
|
|
38
38
|
|
|
39
|
-
<button pgs="buttonIcon" type="button" aria-label="
|
|
39
|
+
<button pgs="buttonIcon" type="button" aria-label="Settings">
|
|
40
40
|
<i class="fa-solid fa-gear" aria-hidden="true"></i>
|
|
41
41
|
</button>
|
|
42
42
|
|
|
43
|
-
<button pgs="buttonMini" type="button" aria-label="
|
|
43
|
+
<button pgs="buttonMini" type="button" aria-label="Information">
|
|
44
44
|
<i class="fa-solid fa-info" aria-hidden="true"></i>
|
|
45
45
|
</button>
|
|
46
46
|
|
|
47
|
-
<button pgs="buttonBig" type="button" aria-label="
|
|
47
|
+
<button pgs="buttonBig" type="button" aria-label="Large button">
|
|
48
48
|
<i class="fa-solid fa-rocket" aria-hidden="true"></i>
|
|
49
|
-
|
|
49
|
+
Large button
|
|
50
50
|
</button>
|
|
51
|
-
</div>
|
|
51
|
+
</div>
|
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
/**
|
|
3
3
|
* @title Card
|
|
4
|
-
* @description
|
|
4
|
+
* @description Reusable container for grouping an image, title, text, and actions in responsive previews or collections.
|
|
5
5
|
*
|
|
6
6
|
* @pgs
|
|
7
|
-
* - card:
|
|
8
|
-
* - card-img:
|
|
7
|
+
* - card: identifies the main card container.
|
|
8
|
+
* - card-img: identifies the main card image.
|
|
9
9
|
*
|
|
10
10
|
* @related
|
|
11
|
-
* - flex-2:
|
|
12
|
-
* - flexColumn:
|
|
13
|
-
* - imgCover:
|
|
14
|
-
* - flexColumnTexts:
|
|
15
|
-
* - button:
|
|
11
|
+
* - flex-2: arranges the cards in a responsive two-item layout.
|
|
12
|
+
* - flexColumn: organizes the card or link content vertically.
|
|
13
|
+
* - imgCover: scales the image to fill the available area.
|
|
14
|
+
* - flexColumnTexts: applies vertical spacing to text content.
|
|
15
|
+
* - button: presents the final link as a standard button.
|
|
16
16
|
*
|
|
17
|
-
* @return
|
|
17
|
+
* @return Two card HTML structures, one with a separate action and one that is fully clickable.
|
|
18
18
|
*/
|
|
19
19
|
-->
|
|
20
20
|
|
|
21
21
|
<div pgs="flex-2">
|
|
22
22
|
|
|
23
23
|
<article pgs="card flexColumn">
|
|
24
|
-
<img pgs="card-img imgCover" src="https://placehold.co/800x500" alt="
|
|
24
|
+
<img pgs="card-img imgCover" src="https://placehold.co/800x500" alt="Placeholder image">
|
|
25
25
|
|
|
26
26
|
<div pgs="flexColumnTexts">
|
|
27
|
-
<h3>
|
|
28
|
-
<p>
|
|
29
|
-
<a pgs="button" href="#">
|
|
27
|
+
<h3>Reusable card</h3>
|
|
28
|
+
<p>Descriptive card content suitable for lists, previews, and grids.</p>
|
|
29
|
+
<a pgs="button" href="#">Read more</a>
|
|
30
30
|
</div>
|
|
31
31
|
</article>
|
|
32
32
|
|
|
33
33
|
<article pgs="card">
|
|
34
34
|
<a pgs="flexColumn" href="">
|
|
35
|
-
<img pgs="card-img imgCover" src="https://placehold.co/800x500" alt="
|
|
35
|
+
<img pgs="card-img imgCover" src="https://placehold.co/800x500" alt="Placeholder image">
|
|
36
36
|
|
|
37
37
|
<div pgs="flexColumnTexts">
|
|
38
|
-
<h3>
|
|
39
|
-
<p>
|
|
38
|
+
<h3>Reusable card</h3>
|
|
39
|
+
<p>Descriptive card content suitable for lists, previews, and grids.</p>
|
|
40
40
|
</div>
|
|
41
41
|
</a>
|
|
42
42
|
</article>
|
|
43
|
-
</div>
|
|
43
|
+
</div>
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
/**
|
|
3
3
|
* @title Dropdown
|
|
4
|
-
* @description
|
|
4
|
+
* @description Popup component that connects a control to content positioned relative to its trigger and handles opening, closing, outside clicks, and Escape.
|
|
5
5
|
*
|
|
6
6
|
* @pgs
|
|
7
|
-
* - dropdown:
|
|
8
|
-
* - dropdown-button:
|
|
9
|
-
* - dropdown-content:
|
|
7
|
+
* - dropdown: identifies the container initialized by the dropdown module.
|
|
8
|
+
* - dropdown-button: identifies the control that opens or closes the content.
|
|
9
|
+
* - dropdown-content: identifies the panel positioned relative to the control.
|
|
10
10
|
*
|
|
11
11
|
* @pgs-option
|
|
12
|
-
* - position:
|
|
13
|
-
* - buttonReverse:
|
|
12
|
+
* - position: configures the root as position[side alignment]; side accepts top, right, bottom, or left, while compatible alignment values are top, right, bottom, left, or center. The default is bottom center.
|
|
13
|
+
* - buttonReverse: reverses text and icon on the example buttons and belongs to the button component.
|
|
14
14
|
*
|
|
15
15
|
* @pgs-state
|
|
16
|
-
* - open:
|
|
16
|
+
* - open: indicates that the dropdown is open and its content is visible.
|
|
17
17
|
*
|
|
18
18
|
* @api
|
|
19
|
-
* - pgs.dropdown.init(root):
|
|
20
|
-
* - pgs.dropdown.api(element):
|
|
21
|
-
* - instance.open():
|
|
22
|
-
* - instance.close():
|
|
23
|
-
* - instance.toggle():
|
|
24
|
-
* - instance.refresh():
|
|
25
|
-
* - instance.isOpen():
|
|
19
|
+
* - pgs.dropdown.init(root): initializes unregistered dropdowns within the specified Document or Element.
|
|
20
|
+
* - pgs.dropdown.api(element): returns the instance associated with an initialized dropdown root.
|
|
21
|
+
* - instance.open(): opens the dropdown and closes any other open dropdowns.
|
|
22
|
+
* - instance.close(): closes the current dropdown.
|
|
23
|
+
* - instance.toggle(): toggles between the open and closed states.
|
|
24
|
+
* - instance.refresh(): reinitializes the context and recalculates content positioning.
|
|
25
|
+
* - instance.isOpen(): returns true when the dropdown is open.
|
|
26
26
|
*
|
|
27
27
|
* @related
|
|
28
|
-
* - flexRow:
|
|
29
|
-
* - button:
|
|
28
|
+
* - flexRow: arranges the placement examples on the same flexible row.
|
|
29
|
+
* - button: applies standard styling to dropdown controls.
|
|
30
30
|
*
|
|
31
|
-
* @return
|
|
31
|
+
* @return Series of HTML dropdowns demonstrating the supported placement directions.
|
|
32
32
|
*/
|
|
33
33
|
-->
|
|
34
34
|
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
</button>
|
|
42
42
|
|
|
43
43
|
<div pgs="dropdown-content">
|
|
44
|
-
|
|
44
|
+
bottom center content
|
|
45
45
|
</div>
|
|
46
46
|
</span>
|
|
47
47
|
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
</button>
|
|
53
53
|
|
|
54
54
|
<div pgs="dropdown-content">
|
|
55
|
-
|
|
55
|
+
top left content
|
|
56
56
|
</div>
|
|
57
57
|
</span>
|
|
58
58
|
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
</button>
|
|
64
64
|
|
|
65
65
|
<div pgs="dropdown-content">
|
|
66
|
-
|
|
66
|
+
top center content
|
|
67
67
|
</div>
|
|
68
68
|
</span>
|
|
69
69
|
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
</button>
|
|
75
75
|
|
|
76
76
|
<div pgs="dropdown-content">
|
|
77
|
-
|
|
77
|
+
top right content
|
|
78
78
|
</div>
|
|
79
79
|
</span>
|
|
80
80
|
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
</button>
|
|
86
86
|
|
|
87
87
|
<div pgs="dropdown-content">
|
|
88
|
-
|
|
88
|
+
bottom left content
|
|
89
89
|
</div>
|
|
90
90
|
</span>
|
|
91
91
|
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
</button>
|
|
97
97
|
|
|
98
98
|
<div pgs="dropdown-content">
|
|
99
|
-
|
|
99
|
+
bottom right content
|
|
100
100
|
</div>
|
|
101
101
|
</span>
|
|
102
102
|
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
</button>
|
|
108
108
|
|
|
109
109
|
<div pgs="dropdown-content">
|
|
110
|
-
|
|
110
|
+
left center content
|
|
111
111
|
</div>
|
|
112
112
|
</span>
|
|
113
113
|
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
</button>
|
|
119
119
|
|
|
120
120
|
<div pgs="dropdown-content">
|
|
121
|
-
|
|
121
|
+
right center content
|
|
122
122
|
</div>
|
|
123
123
|
</span>
|
|
124
124
|
|
|
@@ -1,71 +1,94 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
/**
|
|
3
3
|
* @title Form
|
|
4
|
-
* @description
|
|
4
|
+
* @description Form structure with labels, text fields, a textarea, a checkbox, and a radio group compatible with HTML constraints and custom PGS_formValidate rules.
|
|
5
5
|
*
|
|
6
6
|
* @pgs
|
|
7
|
-
* - form:
|
|
8
|
-
* - formValidate:
|
|
9
|
-
* - label:
|
|
10
|
-
* - input:
|
|
11
|
-
* - textarea:
|
|
12
|
-
* -
|
|
7
|
+
* - form: identifies the form container and applies the field layout.
|
|
8
|
+
* - formValidate: enables styles associated with validation states managed by the JavaScript utility.
|
|
9
|
+
* - label: identifies labels associated with controls.
|
|
10
|
+
* - input: applies shared styling to text inputs.
|
|
11
|
+
* - textarea: applies shared styling to the text area.
|
|
12
|
+
* - radio: styles a group of native radio inputs while preserving their shared name and selection behavior.
|
|
13
13
|
*
|
|
14
14
|
* @pgs-option
|
|
15
|
-
* - message:
|
|
16
|
-
* - error:
|
|
17
|
-
* - success:
|
|
15
|
+
* - message: defines a field-specific message with the syntax message[Message text].
|
|
16
|
+
* - error: is applied at runtime to the form and fields that fail validation.
|
|
17
|
+
* - success: is applied at runtime to the form after successful validation.
|
|
18
18
|
*
|
|
19
19
|
* @api
|
|
20
|
-
* - new pgs.formValidate(form, options):
|
|
21
|
-
* - instance.validator(callback, eventName):
|
|
22
|
-
* - instance.validate():
|
|
23
|
-
* - instance.success(text):
|
|
24
|
-
* - instance.addNewRule(rule):
|
|
25
|
-
* - instance.addFieldError(field, index, total):
|
|
26
|
-
* - instance.removeFieldError(field):
|
|
20
|
+
* - new pgs.formValidate(form, options): creates a utility associated directly with the form, automatically adds novalidate, and accepts fieldError, fieldsError, and success in options.message; messages remain editable through instance.message.
|
|
21
|
+
* - instance.validator(callback, eventName): intercepts the specified event, prevents its default behavior, validates the form, shows the success message, and invokes callback only when valid; eventName defaults to submit.
|
|
22
|
+
* - instance.validate(): validates required fields, updates state attributes, and returns true or false.
|
|
23
|
+
* - instance.success(text): validates the form and shows a success toast when there are no errors.
|
|
24
|
+
* - instance.addNewRule(rule): adds a function that returns one or more invalid fields; validate automatically applies addFieldError to each field.
|
|
25
|
+
* - instance.addFieldError(field, index, total): marks a field as invalid; shows the specific message for one error or a summary message for multiple errors.
|
|
26
|
+
* - instance.removeFieldError(field): removes the error state from the specified field.
|
|
27
27
|
*
|
|
28
28
|
* @related
|
|
29
|
-
* - buttonStrong:
|
|
29
|
+
* - buttonStrong: presents form submission as the primary action.
|
|
30
|
+
* - flexColumnTexts: spaces text elements in the radio group.
|
|
30
31
|
*
|
|
31
|
-
* @return
|
|
32
|
+
* @return Complete HTML form with required fields and an example script for a custom rule, validation, and a success message.
|
|
32
33
|
*/
|
|
33
34
|
-->
|
|
34
35
|
|
|
35
36
|
<form pgs="form formValidate" action="#" method="post">
|
|
36
37
|
<label pgs="label" for="form-name">
|
|
37
|
-
|
|
38
|
+
Name
|
|
38
39
|
</label>
|
|
39
|
-
<input id="form-name" pgs="input" pgs-option="message[
|
|
40
|
+
<input id="form-name" pgs="input" pgs-option="message[Enter your name]" type="text" name="name" placeholder="John Smith" required>
|
|
40
41
|
|
|
41
42
|
<label pgs="label" for="form-email">
|
|
42
43
|
Email
|
|
43
44
|
</label>
|
|
44
|
-
<input id="form-email" pgs="input" pgs-option="message[
|
|
45
|
+
<input id="form-email" pgs="input" pgs-option="message[Enter a valid email address]" type="email" name="email" placeholder="name@example.com" required>
|
|
45
46
|
|
|
46
47
|
<label pgs="label" for="form-password">
|
|
47
48
|
Password
|
|
48
49
|
</label>
|
|
49
|
-
<input id="form-password" pgs="input" pgs-option="message[
|
|
50
|
+
<input id="form-password" pgs="input" pgs-option="message[Enter a password]" type="password" name="password" autocomplete="new-password" required>
|
|
50
51
|
|
|
51
52
|
<label pgs="label" for="form-confirm-password">
|
|
52
|
-
|
|
53
|
+
Confirm password
|
|
53
54
|
</label>
|
|
54
|
-
<input id="form-confirm-password" pgs="input" pgs-option="message[
|
|
55
|
+
<input id="form-confirm-password" pgs="input" pgs-option="message[Confirm your password]" type="password" name="confirmPassword" autocomplete="new-password" required>
|
|
55
56
|
|
|
56
57
|
<label pgs="label" for="form-message">
|
|
57
|
-
|
|
58
|
+
Message
|
|
58
59
|
</label>
|
|
59
|
-
<textarea id="form-message" pgs="textarea" name="message" rows="5" placeholder="
|
|
60
|
+
<textarea id="form-message" pgs="textarea" name="message" rows="5" placeholder="Write your message" required></textarea>
|
|
60
61
|
|
|
61
|
-
<
|
|
62
|
-
|
|
62
|
+
<br>
|
|
63
|
+
<fieldset pgs="radio flexColumnTexts">
|
|
64
|
+
<legend>Preferred contact method</legend>
|
|
65
|
+
|
|
66
|
+
<label>
|
|
67
|
+
<input type="radio" name="contactMethod" value="email" pgs-option="message[Choose a contact method]" required>
|
|
68
|
+
<span>Email</span>
|
|
69
|
+
</label>
|
|
70
|
+
|
|
71
|
+
<label>
|
|
72
|
+
<input type="radio" name="contactMethod" value="phone">
|
|
73
|
+
<span>Phone</span>
|
|
74
|
+
</label>
|
|
75
|
+
|
|
76
|
+
<label>
|
|
77
|
+
<input type="radio" name="contactMethod" value="message">
|
|
78
|
+
<span>Direct message</span>
|
|
79
|
+
</label>
|
|
80
|
+
</fieldset>
|
|
81
|
+
<br>
|
|
82
|
+
|
|
83
|
+
<label>
|
|
63
84
|
<input type="checkbox" name="privacy" required>
|
|
85
|
+
<span>I accept the privacy policy</span>
|
|
64
86
|
</label>
|
|
87
|
+
<br>
|
|
65
88
|
|
|
66
89
|
<button pgs="buttonStrong" type="submit">
|
|
67
90
|
<i class="fa-solid fa-paper-plane" aria-hidden="true"></i>
|
|
68
|
-
|
|
91
|
+
Submit
|
|
69
92
|
</button>
|
|
70
93
|
</form>
|
|
71
94
|
|
|
@@ -80,16 +103,16 @@
|
|
|
80
103
|
|
|
81
104
|
const formValidate = new pgs.formValidate(form, {
|
|
82
105
|
message: {
|
|
83
|
-
fieldError: "
|
|
84
|
-
fieldsError: "
|
|
85
|
-
success: "
|
|
106
|
+
fieldError: "Please complete this field",
|
|
107
|
+
fieldsError: "Please complete all required fields",
|
|
108
|
+
success: "Submitted successfully"
|
|
86
109
|
}
|
|
87
110
|
});
|
|
88
111
|
|
|
89
112
|
//== new roules
|
|
90
113
|
formValidate.addNewRule(() => {
|
|
91
114
|
if (password.value && confirmPassword.value && password.value !== confirmPassword.value) {
|
|
92
|
-
pgs(confirmPassword).option.setValueBrackets("message", "
|
|
115
|
+
pgs(confirmPassword).option.setValueBrackets("message", "Passwords do not match");
|
|
93
116
|
return [confirmPassword, password];
|
|
94
117
|
}
|
|
95
118
|
});
|
|
@@ -98,7 +121,7 @@
|
|
|
98
121
|
formValidate.validator(event => {
|
|
99
122
|
const values = Object.fromEntries(new FormData(form));
|
|
100
123
|
|
|
101
|
-
//
|
|
124
|
+
// Replace this log with a request to your backend.
|
|
102
125
|
console.log(values);
|
|
103
126
|
}, "submit");
|
|
104
127
|
</script>
|