@auriel/peppertino 0.5.0 → 0.6.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 (134) hide show
  1. package/CHANGELOG.txt +249 -224
  2. package/LICENSE +21 -21
  3. package/MIGRATION.md +52 -52
  4. package/README.md +811 -764
  5. package/agents/peppertino/SKILL.md +84 -0
  6. package/agents/peppertino/accordion.md +134 -0
  7. package/agents/peppertino/alert.md +116 -0
  8. package/agents/peppertino/badge.md +74 -0
  9. package/agents/peppertino/base.md +252 -0
  10. package/agents/peppertino/button.md +65 -0
  11. package/agents/peppertino/card.md +82 -0
  12. package/agents/peppertino/carousel.md +147 -0
  13. package/agents/peppertino/catalog.md +83 -0
  14. package/agents/peppertino/components-ai-search.md +10 -0
  15. package/agents/peppertino/components-display.md +19 -0
  16. package/agents/peppertino/components-inputs.md +15 -0
  17. package/agents/peppertino/components-navigation.md +12 -0
  18. package/agents/peppertino/dark-mode.md +152 -0
  19. package/agents/peppertino/footer.md +109 -0
  20. package/agents/peppertino/forms-fieldset.md +85 -0
  21. package/agents/peppertino/forms-form-instructions.md +94 -0
  22. package/agents/peppertino/forms-label.md +110 -0
  23. package/agents/peppertino/forms-text-field.md +134 -0
  24. package/agents/peppertino/forms-validation.md +153 -0
  25. package/agents/peppertino/gradient.md +41 -0
  26. package/agents/peppertino/header.md +105 -0
  27. package/agents/peppertino/modal.md +123 -0
  28. package/agents/peppertino/section.md +56 -0
  29. package/agents/peppertino/select.md +110 -0
  30. package/agents/peppertino/switch.md +72 -0
  31. package/agents/peppertino/table.md +69 -0
  32. package/agents/peppertino/tabs.md +115 -0
  33. package/agents/peppertino/toast.md +96 -0
  34. package/agents/peppertino/tooltip.md +111 -0
  35. package/agents/peppertino/typography.md +118 -0
  36. package/agents/peppertino/utilities.md +194 -0
  37. package/agents/skill.md +65 -0
  38. package/build.js +53 -53
  39. package/dist/accordion.js +1 -1
  40. package/dist/accordion.js.map +2 -2
  41. package/dist/alert.js.map +1 -1
  42. package/dist/carousel.js.map +1 -1
  43. package/dist/header.js.map +1 -1
  44. package/dist/main.css +2566 -1008
  45. package/dist/main.css.map +1 -1
  46. package/dist/main.min.css +1 -0
  47. package/dist/modal.js.map +1 -1
  48. package/dist/peppertino.js +1 -1
  49. package/dist/peppertino.js.map +2 -2
  50. package/dist/select.js.map +1 -1
  51. package/dist/switch.js.map +1 -1
  52. package/dist/tabs.js.map +1 -1
  53. package/dist/theme.js.map +1 -1
  54. package/dist/toast.js.map +1 -1
  55. package/dist/validation.js.map +1 -1
  56. package/icon.svg +4 -0
  57. package/index.html +2177 -2098
  58. package/package.json +28 -28
  59. package/scripts/hex-to-hsl.mjs +75 -75
  60. package/scripts/lint-bem.mjs +53 -53
  61. package/scripts/lint-colors.mjs +87 -87
  62. package/site.webmanifest +18 -0
  63. package/src/js/accordion.js +105 -103
  64. package/src/js/alert.js +28 -28
  65. package/src/js/carousel.js +153 -153
  66. package/src/js/header.js +85 -85
  67. package/src/js/modal.js +138 -138
  68. package/src/js/peppertino.js +15 -15
  69. package/src/js/select.js +101 -101
  70. package/src/js/switch.js +28 -28
  71. package/src/js/tabs.js +104 -104
  72. package/src/js/theme.js +47 -47
  73. package/src/js/toast.js +79 -79
  74. package/src/js/validation.js +132 -132
  75. package/src/scss/accordion.scss +190 -156
  76. package/src/scss/activity.scss +17 -0
  77. package/src/scss/alert.scss +203 -203
  78. package/src/scss/badge.scss +90 -90
  79. package/src/scss/base.scss +511 -506
  80. package/src/scss/button.scss +119 -119
  81. package/src/scss/card.scss +121 -121
  82. package/src/scss/carousel.scss +303 -303
  83. package/src/scss/code-block.scss +22 -0
  84. package/src/scss/counter.scss +5 -0
  85. package/src/scss/dark-mode.scss +514 -514
  86. package/src/scss/duration.scss +26 -0
  87. package/src/scss/folder.scss +27 -0
  88. package/src/scss/footer.scss +224 -224
  89. package/src/scss/forms/fieldset.scss +127 -127
  90. package/src/scss/forms/form-instructions.scss +133 -133
  91. package/src/scss/forms/label.scss +115 -115
  92. package/src/scss/forms/text-field.scss +240 -240
  93. package/src/scss/forms/validation.scss +215 -215
  94. package/src/scss/forms.scss +8 -8
  95. package/src/scss/gradient.scss +11 -11
  96. package/src/scss/gravity-letters.scss +7 -0
  97. package/src/scss/header.scss +257 -238
  98. package/src/scss/helpers/color.scss +9 -0
  99. package/src/scss/helpers/flex.scss +14 -0
  100. package/src/scss/helpers/index.scss +6 -0
  101. package/src/scss/helpers/layout.scss +14 -0
  102. package/src/scss/helpers/spacing.scss +14 -0
  103. package/src/scss/helpers/typography.scss +11 -0
  104. package/src/scss/helpers/visibility.scss +9 -0
  105. package/src/scss/main.scss +49 -24
  106. package/src/scss/modal.scss +188 -188
  107. package/src/scss/model-picker.scss +5 -0
  108. package/src/scss/notification.scss +5 -0
  109. package/src/scss/orb.scss +7 -0
  110. package/src/scss/otp.scss +5 -0
  111. package/src/scss/pill-nav.scss +10 -0
  112. package/src/scss/prompt.scss +28 -0
  113. package/src/scss/rail.scss +7 -0
  114. package/src/scss/reactions.scss +5 -0
  115. package/src/scss/reset.scss +84 -84
  116. package/src/scss/response.scss +11 -0
  117. package/src/scss/reveal.scss +5 -0
  118. package/src/scss/scroll-progress.scss +4 -0
  119. package/src/scss/search-results.scss +13 -0
  120. package/src/scss/section.scss +87 -79
  121. package/src/scss/select.scss +210 -210
  122. package/src/scss/sidebar.scss +8 -0
  123. package/src/scss/status.scss +5 -0
  124. package/src/scss/step-list.scss +13 -0
  125. package/src/scss/switch.scss +121 -121
  126. package/src/scss/table.scss +89 -89
  127. package/src/scss/tabs.scss +156 -156
  128. package/src/scss/task-list.scss +18 -0
  129. package/src/scss/theme-picker.scss +5 -0
  130. package/src/scss/toast.scss +170 -170
  131. package/src/scss/tooltip.scss +126 -126
  132. package/src/scss/typography.scss +58 -58
  133. package/src/scss/utilities.scss +243 -243
  134. package/src/scss/voice-note.scss +5 -0
package/src/js/toast.js CHANGED
@@ -1,79 +1,79 @@
1
- (function () {
2
- const ICON_SVG = {
3
- info: '<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',
4
- success: '<svg viewBox="0 0 24 24"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/></svg>',
5
- warning: '<svg viewBox="0 0 24 24"><path d="m10.29 3.86-8.61 14.88A2 2 0 0 0 3.4 22h17.2a2 2 0 0 0 1.72-3l-8.6-15a2 2 0 0 0-3.43 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',
6
- error: '<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',
7
- neutral: '<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',
8
- };
9
-
10
- function getOrCreateContainer(position) {
11
- const cls = `pp-toast-container--${position}`;
12
- let container = document.querySelector(`.pp-toast-container.${cls}`);
13
- if (!container) {
14
- container = document.createElement('div');
15
- container.className = `pp-toast-container ${cls}`;
16
- container.setAttribute('aria-live', 'polite');
17
- container.setAttribute('aria-atomic', 'false');
18
- document.body.appendChild(container);
19
- }
20
- return container;
21
- }
22
-
23
- function dismiss(toastEl) {
24
- if (toastEl._dismissed) return;
25
- toastEl._dismissed = true;
26
- toastEl.classList.add('is-dismissing');
27
- toastEl.dispatchEvent(new CustomEvent('pp:toast:dismiss', { bubbles: true }));
28
- toastEl.addEventListener('animationend', () => toastEl.remove(), { once: true });
29
- setTimeout(() => toastEl.remove(), 300);
30
- }
31
-
32
- window.ppToast = {
33
- show({ message = '', title = '', variant = 'neutral', duration = 4000, position = 'top-right' } = {}) {
34
- const container = getOrCreateContainer(position);
35
-
36
- const toast = document.createElement('div');
37
- toast.className = `pp-toast pp-toast--${variant}`;
38
- toast.setAttribute('role', 'status');
39
-
40
- const icon = ICON_SVG[variant] || ICON_SVG.neutral;
41
-
42
- toast.innerHTML = `
43
- <span class="pp-toast__icon" aria-hidden="true">${icon}</span>
44
- <div class="pp-toast__body">
45
- ${title ? `<div class="pp-toast__title">${title}</div>` : ''}
46
- <div class="pp-toast__message">${message}</div>
47
- </div>
48
- <button class="pp-toast__dismiss" aria-label="Dismiss">
49
- <svg viewBox="0 0 24 24"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
50
- </button>
51
- ${duration > 0 ? `<span class="pp-toast__progress" style="--pp-toast-duration:${duration}ms"></span>` : ''}
52
- `.trim();
53
-
54
- toast.querySelector('.pp-toast__dismiss').addEventListener('click', () => dismiss(toast));
55
-
56
- container.appendChild(toast);
57
-
58
- toast.dispatchEvent(new CustomEvent('pp:toast:show', {
59
- bubbles: true,
60
- detail: { message, title, variant, duration },
61
- }));
62
-
63
- if (duration > 0) {
64
- setTimeout(() => dismiss(toast), duration);
65
- }
66
-
67
- return { dismiss: () => dismiss(toast) };
68
- },
69
- };
70
-
71
- // Auto-wire any [data-toast-dismiss] buttons in static markup
72
- document.addEventListener('click', (e) => {
73
- const btn = e.target.closest('[data-toast-dismiss]');
74
- if (btn) {
75
- const toast = btn.closest('.pp-toast');
76
- if (toast) dismiss(toast);
77
- }
78
- });
79
- })();
1
+ (function () {
2
+ const ICON_SVG = {
3
+ info: '<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',
4
+ success: '<svg viewBox="0 0 24 24"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/></svg>',
5
+ warning: '<svg viewBox="0 0 24 24"><path d="m10.29 3.86-8.61 14.88A2 2 0 0 0 3.4 22h17.2a2 2 0 0 0 1.72-3l-8.6-15a2 2 0 0 0-3.43 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',
6
+ error: '<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',
7
+ neutral: '<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',
8
+ };
9
+
10
+ function getOrCreateContainer(position) {
11
+ const cls = `pp-toast-container--${position}`;
12
+ let container = document.querySelector(`.pp-toast-container.${cls}`);
13
+ if (!container) {
14
+ container = document.createElement('div');
15
+ container.className = `pp-toast-container ${cls}`;
16
+ container.setAttribute('aria-live', 'polite');
17
+ container.setAttribute('aria-atomic', 'false');
18
+ document.body.appendChild(container);
19
+ }
20
+ return container;
21
+ }
22
+
23
+ function dismiss(toastEl) {
24
+ if (toastEl._dismissed) return;
25
+ toastEl._dismissed = true;
26
+ toastEl.classList.add('is-dismissing');
27
+ toastEl.dispatchEvent(new CustomEvent('pp:toast:dismiss', { bubbles: true }));
28
+ toastEl.addEventListener('animationend', () => toastEl.remove(), { once: true });
29
+ setTimeout(() => toastEl.remove(), 300);
30
+ }
31
+
32
+ window.ppToast = {
33
+ show({ message = '', title = '', variant = 'neutral', duration = 4000, position = 'top-right' } = {}) {
34
+ const container = getOrCreateContainer(position);
35
+
36
+ const toast = document.createElement('div');
37
+ toast.className = `pp-toast pp-toast--${variant}`;
38
+ toast.setAttribute('role', 'status');
39
+
40
+ const icon = ICON_SVG[variant] || ICON_SVG.neutral;
41
+
42
+ toast.innerHTML = `
43
+ <span class="pp-toast__icon" aria-hidden="true">${icon}</span>
44
+ <div class="pp-toast__body">
45
+ ${title ? `<div class="pp-toast__title">${title}</div>` : ''}
46
+ <div class="pp-toast__message">${message}</div>
47
+ </div>
48
+ <button class="pp-toast__dismiss" aria-label="Dismiss">
49
+ <svg viewBox="0 0 24 24"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
50
+ </button>
51
+ ${duration > 0 ? `<span class="pp-toast__progress" style="--pp-toast-duration:${duration}ms"></span>` : ''}
52
+ `.trim();
53
+
54
+ toast.querySelector('.pp-toast__dismiss').addEventListener('click', () => dismiss(toast));
55
+
56
+ container.appendChild(toast);
57
+
58
+ toast.dispatchEvent(new CustomEvent('pp:toast:show', {
59
+ bubbles: true,
60
+ detail: { message, title, variant, duration },
61
+ }));
62
+
63
+ if (duration > 0) {
64
+ setTimeout(() => dismiss(toast), duration);
65
+ }
66
+
67
+ return { dismiss: () => dismiss(toast) };
68
+ },
69
+ };
70
+
71
+ // Auto-wire any [data-toast-dismiss] buttons in static markup
72
+ document.addEventListener('click', (e) => {
73
+ const btn = e.target.closest('[data-toast-dismiss]');
74
+ if (btn) {
75
+ const toast = btn.closest('.pp-toast');
76
+ if (toast) dismiss(toast);
77
+ }
78
+ });
79
+ })();
@@ -1,132 +1,132 @@
1
- // PeppertinoCSS — Validation
2
-
3
- (function () {
4
- function getField(input) { return input.closest('.pp-field'); }
5
- function getMessageEl(field) { return field ? field.querySelector('.pp-field__message') : null; }
6
- function getHintEl(field) { return field ? field.querySelector('.pp-field__hint') : null; }
7
-
8
- function buildDescribedBy(field) {
9
- const ids = [];
10
- const hint = getHintEl(field);
11
- const msg = getMessageEl(field);
12
- if (hint && hint.id) ids.push(hint.id);
13
- if (msg && msg.id) ids.push(msg.id);
14
- return ids.join(' ');
15
- }
16
-
17
- function ensureIds(field, input) {
18
- const base = input.id || `pp-field-${Math.random().toString(36).slice(2, 7)}`;
19
- const hint = getHintEl(field);
20
- const msg = getMessageEl(field);
21
- if (hint && !hint.id) hint.id = `${base}-hint`;
22
- if (msg && !msg.id) msg.id = `${base}-msg`;
23
- }
24
-
25
- function setError(input, message) {
26
- const field = getField(input);
27
- if (!field) return;
28
- ensureIds(field, input);
29
- field.classList.remove('pp-field--success', 'pp-field--warning', 'pp-field--validating');
30
- field.classList.add('pp-field--error');
31
- input.setAttribute('aria-invalid', 'true');
32
- let msg = getMessageEl(field);
33
- if (!msg) {
34
- msg = document.createElement('span');
35
- msg.className = 'pp-field__message';
36
- msg.id = `${input.id || 'field'}-msg`;
37
- msg.setAttribute('role', 'alert');
38
- field.appendChild(msg);
39
- }
40
- msg.textContent = message;
41
- input.setAttribute('aria-describedby', buildDescribedBy(field));
42
- field.dispatchEvent(new CustomEvent('pp-field:error', { bubbles: true, detail: { input, message } }));
43
- }
44
-
45
- function clearError(input) {
46
- const field = getField(input);
47
- if (!field) return;
48
- field.classList.remove('pp-field--error', 'pp-field--validating');
49
- input.setAttribute('aria-invalid', 'false');
50
- const msg = getMessageEl(field);
51
- if (msg) msg.textContent = '';
52
- input.setAttribute('aria-describedby', buildDescribedBy(field));
53
- field.dispatchEvent(new CustomEvent('pp-field:clear', { bubbles: true, detail: { input } }));
54
- }
55
-
56
- function setSuccess(input, message) {
57
- const field = getField(input);
58
- if (!field) return;
59
- ensureIds(field, input);
60
- field.classList.remove('pp-field--error', 'pp-field--warning', 'pp-field--validating');
61
- field.classList.add('pp-field--success');
62
- input.setAttribute('aria-invalid', 'false');
63
- let msg = getMessageEl(field);
64
- if (message) {
65
- if (!msg) {
66
- msg = document.createElement('span');
67
- msg.className = 'pp-field__message';
68
- msg.id = `${input.id || 'field'}-msg`;
69
- field.appendChild(msg);
70
- }
71
- msg.textContent = message;
72
- }
73
- input.setAttribute('aria-describedby', buildDescribedBy(field));
74
- }
75
-
76
- function setValidating(input) {
77
- const field = getField(input);
78
- if (!field) return;
79
- field.classList.remove('pp-field--error', 'pp-field--success', 'pp-field--warning');
80
- field.classList.add('pp-field--validating');
81
- input.removeAttribute('aria-invalid');
82
- }
83
-
84
- function setSummary(errors, summaryEl) {
85
- if (!summaryEl) return;
86
- const list = summaryEl.querySelector('.pp-validation-summary__list');
87
- if (!list) return;
88
- list.innerHTML = '';
89
- if (!errors || errors.length === 0) {
90
- summaryEl.classList.remove('is-visible');
91
- summaryEl.setAttribute('aria-hidden', 'true');
92
- return;
93
- }
94
- errors.forEach(({ input, message }) => {
95
- const inputEl = typeof input === 'string' ? document.getElementById(input) : input;
96
- const li = document.createElement('li');
97
- li.className = 'pp-validation-summary__item';
98
- if (inputEl && inputEl.id) {
99
- const a = document.createElement('a');
100
- a.href = `#${inputEl.id}`;
101
- a.textContent = message;
102
- a.addEventListener('click', (e) => {
103
- e.preventDefault();
104
- inputEl.focus();
105
- inputEl.scrollIntoView({ behavior: 'smooth', block: 'center' });
106
- });
107
- li.appendChild(a);
108
- } else {
109
- li.textContent = message;
110
- }
111
- list.appendChild(li);
112
- });
113
- summaryEl.classList.add('is-visible');
114
- summaryEl.setAttribute('aria-hidden', 'false');
115
- summaryEl.setAttribute('tabindex', '-1');
116
- summaryEl.focus();
117
- }
118
-
119
- document.querySelectorAll('.pp-field').forEach((field) => {
120
- const input = field.querySelector('.pp-field__input, .pp-field__textarea');
121
- if (!input) return;
122
- ensureIds(field, input);
123
- const refs = buildDescribedBy(field);
124
- if (refs) {
125
- const existing = input.getAttribute('aria-describedby') || '';
126
- const merged = [...new Set([...existing.split(' '), ...refs.split(' ')].filter(Boolean))].join(' ');
127
- input.setAttribute('aria-describedby', merged);
128
- }
129
- });
130
-
131
- window.ppValidation = { setError, clearError, setSuccess, setValidating, setSummary };
132
- })();
1
+ // PeppertinoCSS — Validation
2
+
3
+ (function () {
4
+ function getField(input) { return input.closest('.pp-field'); }
5
+ function getMessageEl(field) { return field ? field.querySelector('.pp-field__message') : null; }
6
+ function getHintEl(field) { return field ? field.querySelector('.pp-field__hint') : null; }
7
+
8
+ function buildDescribedBy(field) {
9
+ const ids = [];
10
+ const hint = getHintEl(field);
11
+ const msg = getMessageEl(field);
12
+ if (hint && hint.id) ids.push(hint.id);
13
+ if (msg && msg.id) ids.push(msg.id);
14
+ return ids.join(' ');
15
+ }
16
+
17
+ function ensureIds(field, input) {
18
+ const base = input.id || `pp-field-${Math.random().toString(36).slice(2, 7)}`;
19
+ const hint = getHintEl(field);
20
+ const msg = getMessageEl(field);
21
+ if (hint && !hint.id) hint.id = `${base}-hint`;
22
+ if (msg && !msg.id) msg.id = `${base}-msg`;
23
+ }
24
+
25
+ function setError(input, message) {
26
+ const field = getField(input);
27
+ if (!field) return;
28
+ ensureIds(field, input);
29
+ field.classList.remove('pp-field--success', 'pp-field--warning', 'pp-field--validating');
30
+ field.classList.add('pp-field--error');
31
+ input.setAttribute('aria-invalid', 'true');
32
+ let msg = getMessageEl(field);
33
+ if (!msg) {
34
+ msg = document.createElement('span');
35
+ msg.className = 'pp-field__message';
36
+ msg.id = `${input.id || 'field'}-msg`;
37
+ msg.setAttribute('role', 'alert');
38
+ field.appendChild(msg);
39
+ }
40
+ msg.textContent = message;
41
+ input.setAttribute('aria-describedby', buildDescribedBy(field));
42
+ field.dispatchEvent(new CustomEvent('pp-field:error', { bubbles: true, detail: { input, message } }));
43
+ }
44
+
45
+ function clearError(input) {
46
+ const field = getField(input);
47
+ if (!field) return;
48
+ field.classList.remove('pp-field--error', 'pp-field--validating');
49
+ input.setAttribute('aria-invalid', 'false');
50
+ const msg = getMessageEl(field);
51
+ if (msg) msg.textContent = '';
52
+ input.setAttribute('aria-describedby', buildDescribedBy(field));
53
+ field.dispatchEvent(new CustomEvent('pp-field:clear', { bubbles: true, detail: { input } }));
54
+ }
55
+
56
+ function setSuccess(input, message) {
57
+ const field = getField(input);
58
+ if (!field) return;
59
+ ensureIds(field, input);
60
+ field.classList.remove('pp-field--error', 'pp-field--warning', 'pp-field--validating');
61
+ field.classList.add('pp-field--success');
62
+ input.setAttribute('aria-invalid', 'false');
63
+ let msg = getMessageEl(field);
64
+ if (message) {
65
+ if (!msg) {
66
+ msg = document.createElement('span');
67
+ msg.className = 'pp-field__message';
68
+ msg.id = `${input.id || 'field'}-msg`;
69
+ field.appendChild(msg);
70
+ }
71
+ msg.textContent = message;
72
+ }
73
+ input.setAttribute('aria-describedby', buildDescribedBy(field));
74
+ }
75
+
76
+ function setValidating(input) {
77
+ const field = getField(input);
78
+ if (!field) return;
79
+ field.classList.remove('pp-field--error', 'pp-field--success', 'pp-field--warning');
80
+ field.classList.add('pp-field--validating');
81
+ input.removeAttribute('aria-invalid');
82
+ }
83
+
84
+ function setSummary(errors, summaryEl) {
85
+ if (!summaryEl) return;
86
+ const list = summaryEl.querySelector('.pp-validation-summary__list');
87
+ if (!list) return;
88
+ list.innerHTML = '';
89
+ if (!errors || errors.length === 0) {
90
+ summaryEl.classList.remove('is-visible');
91
+ summaryEl.setAttribute('aria-hidden', 'true');
92
+ return;
93
+ }
94
+ errors.forEach(({ input, message }) => {
95
+ const inputEl = typeof input === 'string' ? document.getElementById(input) : input;
96
+ const li = document.createElement('li');
97
+ li.className = 'pp-validation-summary__item';
98
+ if (inputEl && inputEl.id) {
99
+ const a = document.createElement('a');
100
+ a.href = `#${inputEl.id}`;
101
+ a.textContent = message;
102
+ a.addEventListener('click', (e) => {
103
+ e.preventDefault();
104
+ inputEl.focus();
105
+ inputEl.scrollIntoView({ behavior: 'smooth', block: 'center' });
106
+ });
107
+ li.appendChild(a);
108
+ } else {
109
+ li.textContent = message;
110
+ }
111
+ list.appendChild(li);
112
+ });
113
+ summaryEl.classList.add('is-visible');
114
+ summaryEl.setAttribute('aria-hidden', 'false');
115
+ summaryEl.setAttribute('tabindex', '-1');
116
+ summaryEl.focus();
117
+ }
118
+
119
+ document.querySelectorAll('.pp-field').forEach((field) => {
120
+ const input = field.querySelector('.pp-field__input, .pp-field__textarea');
121
+ if (!input) return;
122
+ ensureIds(field, input);
123
+ const refs = buildDescribedBy(field);
124
+ if (refs) {
125
+ const existing = input.getAttribute('aria-describedby') || '';
126
+ const merged = [...new Set([...existing.split(' '), ...refs.split(' ')].filter(Boolean))].join(' ');
127
+ input.setAttribute('aria-describedby', merged);
128
+ }
129
+ });
130
+
131
+ window.ppValidation = { setError, clearError, setSuccess, setValidating, setSummary };
132
+ })();