@auriel/peppertino 0.4.0 → 0.6.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 (139) hide show
  1. package/CHANGELOG.txt +242 -136
  2. package/LICENSE +21 -21
  3. package/MIGRATION.md +52 -0
  4. package/README.md +773 -622
  5. package/agents/peppertino/SKILL.md +76 -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 +81 -0
  14. package/agents/peppertino/dark-mode.md +152 -0
  15. package/agents/peppertino/footer.md +109 -0
  16. package/agents/peppertino/forms-fieldset.md +85 -0
  17. package/agents/peppertino/forms-form-instructions.md +94 -0
  18. package/agents/peppertino/forms-label.md +110 -0
  19. package/agents/peppertino/forms-text-field.md +134 -0
  20. package/agents/peppertino/forms-validation.md +153 -0
  21. package/agents/peppertino/gradient.md +41 -0
  22. package/agents/peppertino/header.md +105 -0
  23. package/agents/peppertino/modal.md +123 -0
  24. package/agents/peppertino/section.md +56 -0
  25. package/agents/peppertino/select.md +110 -0
  26. package/agents/peppertino/switch.md +72 -0
  27. package/agents/peppertino/table.md +69 -0
  28. package/agents/peppertino/tabs.md +115 -0
  29. package/agents/peppertino/toast.md +96 -0
  30. package/agents/peppertino/tooltip.md +111 -0
  31. package/agents/peppertino/typography.md +118 -0
  32. package/agents/peppertino/utilities.md +194 -0
  33. package/agents/skill.md +65 -0
  34. package/build.js +53 -53
  35. package/dist/accordion.js +41 -4
  36. package/dist/accordion.js.map +2 -2
  37. package/dist/alert.js +26 -0
  38. package/dist/alert.js.map +7 -0
  39. package/dist/carousel.js +4 -0
  40. package/dist/carousel.js.map +2 -2
  41. package/dist/header.js +1 -0
  42. package/dist/header.js.map +2 -2
  43. package/dist/main.css +3610 -1343
  44. package/dist/main.css.map +1 -1
  45. package/dist/main.min.css +1 -0
  46. package/dist/modal.js +2 -0
  47. package/dist/modal.js.map +2 -2
  48. package/dist/peppertino.js +244 -15
  49. package/dist/peppertino.js.map +3 -3
  50. package/dist/select.js +2 -4
  51. package/dist/select.js.map +2 -2
  52. package/dist/switch.js +29 -0
  53. package/dist/switch.js.map +7 -0
  54. package/dist/tabs.js +27 -7
  55. package/dist/tabs.js.map +2 -2
  56. package/dist/theme.js +47 -0
  57. package/dist/theme.js.map +7 -0
  58. package/dist/toast.js +69 -0
  59. package/dist/toast.js.map +7 -0
  60. package/dist/validation.js.map +1 -1
  61. package/icon.svg +4 -0
  62. package/index.html +2172 -1902
  63. package/package.json +28 -26
  64. package/scripts/hex-to-hsl.mjs +75 -0
  65. package/scripts/lint-bem.mjs +53 -0
  66. package/scripts/lint-colors.mjs +87 -0
  67. package/site.webmanifest +18 -0
  68. package/src/js/accordion.js +105 -61
  69. package/src/js/alert.js +28 -0
  70. package/src/js/carousel.js +153 -148
  71. package/src/js/header.js +85 -84
  72. package/src/js/modal.js +138 -134
  73. package/src/js/peppertino.js +15 -11
  74. package/src/js/select.js +101 -103
  75. package/src/js/switch.js +28 -0
  76. package/src/js/tabs.js +104 -94
  77. package/src/js/theme.js +47 -0
  78. package/src/js/toast.js +79 -0
  79. package/src/js/validation.js +132 -132
  80. package/src/scss/accordion.scss +190 -156
  81. package/src/scss/activity.scss +17 -0
  82. package/src/scss/alert.scss +203 -204
  83. package/src/scss/badge.scss +90 -0
  84. package/src/scss/base.scss +511 -305
  85. package/src/scss/button.scss +119 -121
  86. package/src/scss/card.scss +121 -121
  87. package/src/scss/carousel.scss +303 -313
  88. package/src/scss/code-block.scss +22 -0
  89. package/src/scss/counter.scss +5 -0
  90. package/src/scss/dark-mode.scss +514 -474
  91. package/src/scss/duration.scss +26 -0
  92. package/src/scss/folder.scss +27 -0
  93. package/src/scss/footer.scss +224 -224
  94. package/src/scss/forms/fieldset.scss +127 -127
  95. package/src/scss/forms/form-instructions.scss +133 -133
  96. package/src/scss/forms/label.scss +115 -115
  97. package/src/scss/forms/text-field.scss +240 -240
  98. package/src/scss/forms/validation.scss +215 -215
  99. package/src/scss/forms.scss +8 -8
  100. package/src/scss/gradient.scss +11 -11
  101. package/src/scss/gravity-letters.scss +7 -0
  102. package/src/scss/header.scss +257 -238
  103. package/src/scss/helpers/color.scss +9 -0
  104. package/src/scss/helpers/flex.scss +14 -0
  105. package/src/scss/helpers/index.scss +6 -0
  106. package/src/scss/helpers/layout.scss +14 -0
  107. package/src/scss/helpers/spacing.scss +14 -0
  108. package/src/scss/helpers/typography.scss +11 -0
  109. package/src/scss/helpers/visibility.scss +9 -0
  110. package/src/scss/main.scss +49 -20
  111. package/src/scss/modal.scss +188 -188
  112. package/src/scss/model-picker.scss +5 -0
  113. package/src/scss/notification.scss +5 -0
  114. package/src/scss/orb.scss +7 -0
  115. package/src/scss/otp.scss +5 -0
  116. package/src/scss/pill-nav.scss +10 -0
  117. package/src/scss/prompt.scss +28 -0
  118. package/src/scss/rail.scss +7 -0
  119. package/src/scss/reactions.scss +5 -0
  120. package/src/scss/reset.scss +84 -84
  121. package/src/scss/response.scss +11 -0
  122. package/src/scss/reveal.scss +5 -0
  123. package/src/scss/scroll-progress.scss +4 -0
  124. package/src/scss/search-results.scss +13 -0
  125. package/src/scss/section.scss +87 -79
  126. package/src/scss/select.scss +210 -210
  127. package/src/scss/sidebar.scss +8 -0
  128. package/src/scss/status.scss +5 -0
  129. package/src/scss/step-list.scss +13 -0
  130. package/src/scss/switch.scss +121 -0
  131. package/src/scss/table.scss +89 -89
  132. package/src/scss/tabs.scss +156 -156
  133. package/src/scss/task-list.scss +18 -0
  134. package/src/scss/theme-picker.scss +5 -0
  135. package/src/scss/toast.scss +170 -0
  136. package/src/scss/tooltip.scss +126 -0
  137. package/src/scss/typography.scss +58 -58
  138. package/src/scss/utilities.scss +243 -243
  139. package/src/scss/voice-note.scss +5 -0
package/package.json CHANGED
@@ -1,26 +1,28 @@
1
- {
2
- "name": "@auriel/peppertino",
3
- "version": "0.4.0",
4
- "description": "An Apple-inspired CSS framework with a spicy red accent. Clean geometry, restrained elegance, zero Cupertino lawsuits.",
5
- "repository": {
6
- "type": "git",
7
- "url": "https://codeberg.org/debaditya/Peppertino"
8
- },
9
- "license": "MIT",
10
- "scripts": {
11
- "build:css": "sass src/scss/main.scss dist/main.css --style=expanded --source-map",
12
- "build:css:min": "sass src/scss/main.scss dist/main.min.css --style=compressed --no-source-map",
13
- "build:js": "node build.js",
14
- "build": "bun run build:css && bun run build:js",
15
- "watch:css": "sass --watch src/scss/main.scss:dist/main.css --style=expanded --source-map",
16
- "watch:js": "node build.js --watch",
17
- "serve": "bunx --bun serve . --port 3000",
18
- "dev": "bun run build && concurrently \"bun run watch:css\" \"bun run watch:js\" \"bun run serve\""
19
- },
20
- "devDependencies": {
21
- "concurrently": "^9.1.2",
22
- "esbuild": "^0.25.4",
23
- "sass": "^1.89.0",
24
- "serve": "^14.2.4"
25
- }
26
- }
1
+ {
2
+ "name": "@auriel/peppertino",
3
+ "version": "0.6.0",
4
+ "description": "An Apple-inspired CSS framework with a spicy red accent. Clean geometry, restrained elegance, zero Cupertino lawsuits.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://codeberg.org/debaditya/Peppertino"
8
+ },
9
+ "license": "MIT",
10
+ "scripts": {
11
+ "build:css": "sass src/scss/main.scss dist/main.css --style=expanded --source-map",
12
+ "build:css:min": "sass src/scss/main.scss dist/main.min.css --style=compressed --no-source-map",
13
+ "build:js": "bun build.js",
14
+ "lint:colors": "bun scripts/lint-colors.mjs",
15
+ "lint:bem": "bun scripts/lint-bem.mjs",
16
+ "build": "bun run build:css && bun run build:css:min && bun run build:js && bun run lint:colors && bun run lint:bem",
17
+ "watch:css": "sass --watch src/scss/main.scss:dist/main.css --style=expanded --source-map",
18
+ "watch:js": "bun build.js --watch",
19
+ "serve": "bunx --bun serve . --port 3000",
20
+ "dev": "bun run build && concurrently \"bun run watch:css\" \"bun run watch:js\" \"bun run serve\""
21
+ },
22
+ "devDependencies": {
23
+ "concurrently": "^9.1.2",
24
+ "esbuild": "^0.25.4",
25
+ "sass": "^1.89.0",
26
+ "serve": "^14.2.4"
27
+ }
28
+ }
@@ -0,0 +1,75 @@
1
+ // One-off script: converts all base.scss hex color tokens to decomposed HSL triplets.
2
+ // Run: node scripts/hex-to-hsl.mjs
3
+ // Output is printed to stdout — copy into base.scss and dark-mode.scss.
4
+
5
+ function hexToHsl(hex) {
6
+ hex = hex.replace('#', '');
7
+ if (hex.length === 3) hex = hex.split('').map(c => c + c).join('');
8
+ const r = parseInt(hex.slice(0, 2), 16) / 255;
9
+ const g = parseInt(hex.slice(2, 4), 16) / 255;
10
+ const b = parseInt(hex.slice(4, 6), 16) / 255;
11
+
12
+ const max = Math.max(r, g, b), min = Math.min(r, g, b);
13
+ let h, s, l = (max + min) / 2;
14
+
15
+ if (max === min) {
16
+ h = s = 0;
17
+ } else {
18
+ const d = max - min;
19
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
20
+ switch (max) {
21
+ case r: h = ((g - b) / d + (g < b ? 6 : 0)) / 6; break;
22
+ case g: h = ((b - r) / d + 2) / 6; break;
23
+ case b: h = ((r - g) / d + 4) / 6; break;
24
+ }
25
+ }
26
+
27
+ return {
28
+ h: Math.round(h * 360),
29
+ s: Math.round(s * 1000) / 10,
30
+ l: Math.round(l * 1000) / 10,
31
+ };
32
+ }
33
+
34
+ const tokens = {
35
+ 'primary': '#e90111',
36
+ 'primary-light': '#ff4d5a',
37
+ 'primary-dark': '#a8000c',
38
+ 'accent': '#f77f00',
39
+ 'gradient-start': '#ffcf67',
40
+ 'gradient-end': '#ea5753',
41
+ 'neutral-50': '#fafafa',
42
+ 'neutral-100': '#f4f4f5',
43
+ 'neutral-200': '#e4e4e7',
44
+ 'neutral-300': '#d4d4d8',
45
+ 'neutral-400': '#a1a1aa',
46
+ 'neutral-500': '#71717a',
47
+ 'neutral-600': '#52525b',
48
+ 'neutral-700': '#3f3f46',
49
+ 'neutral-800': '#27272a',
50
+ 'neutral-900': '#18181b',
51
+ 'success': '#22c55e',
52
+ 'warning': '#f59e0b',
53
+ 'error': '#ef4444',
54
+ 'info': '#3b82f6',
55
+ // Button variant shades (needed for button.scss tokens)
56
+ 'success-600': '#16a34a',
57
+ 'success-700': '#15803d',
58
+ 'success-800': '#166534',
59
+ 'warning-600': '#d97706',
60
+ 'warning-700': '#b45309',
61
+ 'warning-800': '#92400e',
62
+ 'error-600': '#dc2626',
63
+ 'error-700': '#b91c1c',
64
+ };
65
+
66
+ console.log(':root {');
67
+ for (const [name, hex] of Object.entries(tokens)) {
68
+ const { h, s, l } = hexToHsl(hex);
69
+ console.log(` --pp-${name}-h: ${h};`);
70
+ console.log(` --pp-${name}-s: ${s}%;`);
71
+ console.log(` --pp-${name}-l: ${l}%;`);
72
+ console.log(` --pp-${name}: hsl(var(--pp-${name}-h) var(--pp-${name}-s) var(--pp-${name}-l));`);
73
+ console.log('');
74
+ }
75
+ console.log('}');
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env bun
2
+ // Checks compiled dist/main.css for .pp-* class selectors that violate BEM.
3
+ // Valid: .pp-button, .pp-button__icon, .pp-button--outline, .pp-button--outline.pp-button--success
4
+ // Invalid: .pp-button-success (compound hyphen — should be .pp-button--success)
5
+ // .pp-buttonIcon (camelCase)
6
+ // Usage: bun run scripts/lint-bem.mjs
7
+
8
+ import { readFile } from 'fs/promises';
9
+ import { join } from 'path';
10
+
11
+ const cssPath = join(import.meta.dir, '..', 'dist', 'main.css');
12
+
13
+ let css;
14
+ try {
15
+ css = await readFile(cssPath, 'utf8');
16
+ } catch {
17
+ console.error('✖ lint-bem: dist/main.css not found. Run build:css first.');
18
+ process.exit(1);
19
+ }
20
+
21
+ // Extract all .pp-* class tokens from selectors
22
+ // Match class selectors: .pp-something (stop at space/:/./[/{})
23
+ const CLASS_PATTERN = /\.pp-[\w-]+/g;
24
+
25
+ // BEM-valid patterns for .pp-* classes:
26
+ // Block only: .pp-[block]
27
+ // Block + element: .pp-[block]__[element]
28
+ // Block + modifier: .pp-[block]--[modifier]
29
+ // (double hyphen is modifier, double underscore is element — single hyphens within a segment are fine)
30
+ const BEM_VALID = /^\.pp-[a-z][a-z0-9]*(-[a-z0-9]+)*(__[a-z0-9][a-z0-9]*(-[a-z0-9]+)*)?(--[a-z0-9][a-z0-9]*(-[a-z0-9]+)*)?$/;
31
+
32
+ const seen = new Set();
33
+ const violations = [];
34
+
35
+ let match;
36
+ while ((match = CLASS_PATTERN.exec(css)) !== null) {
37
+ const cls = match[0];
38
+ if (seen.has(cls)) continue;
39
+ seen.add(cls);
40
+
41
+ if (!BEM_VALID.test(cls)) {
42
+ violations.push(cls);
43
+ }
44
+ }
45
+
46
+ if (violations.length > 0) {
47
+ console.error('✖ lint-bem: The following .pp-* classes violate BEM naming:');
48
+ violations.forEach((v) => console.error(` ${v}`));
49
+ console.error('\nExpected: .pp-block, .pp-block__element, .pp-block--modifier\n');
50
+ process.exit(1);
51
+ } else {
52
+ console.log(`✔ lint-bem: All ${seen.size} .pp-* selectors pass BEM naming check.`);
53
+ }
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env bun
2
+ // Fails if any SCSS component file contains literal color values that should
3
+ // be CSS custom properties. Structural white/black overlays are allowed.
4
+ // Usage: bun run scripts/lint-colors.mjs
5
+
6
+ import { readdir, readFile } from 'fs/promises';
7
+ import { join, relative } from 'path';
8
+
9
+ const EXEMPT = new Set(['base.scss', 'dark-mode.scss']);
10
+
11
+ // Patterns that are ALLOWED in component files (structural design choices):
12
+ // - Pure white/black with opacity: rgb(255...), rgb(0...), rgba(#fff,...), rgba(0,0,0,...)
13
+ // - Transparent keyword
14
+ const ALLOWED_PATTERNS = [
15
+ /rgba?\(255[^)]*\)/, // white with alpha
16
+ /rgba?\(0,\s*0,\s*0[^)]*\)/, // black with alpha
17
+ /rgba?\(#fff[^)]*\)/, // #fff with alpha
18
+ /rgba?\(#000[^)]*\)/, // #000 with alpha
19
+ /rgb\(255\s+255\s+255[^)]*\)/, // modern white syntax
20
+ /rgb\(0\s+0\s+0[^)]*\)/, // modern black syntax
21
+ /^#fff$/i, // pure white
22
+ /^#000$/i, // pure black
23
+ ];
24
+
25
+ // Patterns that are BANNED (should use CSS vars instead):
26
+ const BANNED = [
27
+ { pattern: /rgba?\(\s*\$color[-_\w]+\s*,/g, desc: 'rgba() with SCSS color variable — use hsl(var(--pp-*-h) ... / alpha)' },
28
+ { pattern: /rgba?\(\s*\$gradient[-_\w]*\s*,/g, desc: 'rgba() with SCSS gradient variable — use hsl(var(--pp-gradient-*-h) ... / alpha)' },
29
+ { pattern: /#[0-9a-fA-F]{6}(?!\s*[}|;,\n]?\s*!|[0-9a-fA-F])/g, desc: '6-digit hex color — use var(--pp-*)' },
30
+ ];
31
+
32
+ // Allowed 6-digit hexes (structural white/black variants):
33
+ const ALLOWED_HEX = new Set(['#ffffff', '#000000', '#ffb3b3']);
34
+
35
+ async function scanDir(dir) {
36
+ const entries = await readdir(dir, { withFileTypes: true });
37
+ const files = [];
38
+ for (const entry of entries) {
39
+ if (entry.isDirectory()) {
40
+ files.push(...await scanDir(join(dir, entry.name)));
41
+ } else if (entry.name.endsWith('.scss') && !EXEMPT.has(entry.name)) {
42
+ files.push(join(dir, entry.name));
43
+ }
44
+ }
45
+ return files;
46
+ }
47
+
48
+ const scssDir = join(import.meta.dir, '..', 'src', 'scss');
49
+ const files = await scanDir(scssDir);
50
+
51
+ let totalViolations = 0;
52
+
53
+ for (const file of files) {
54
+ const src = await readFile(file, 'utf8');
55
+ const lines = src.split('\n');
56
+ const relPath = relative(join(import.meta.dir, '..'), file);
57
+
58
+ lines.forEach((line, i) => {
59
+ const lineNum = i + 1;
60
+ const trimmed = line.trim();
61
+ if (trimmed.startsWith('//')) return; // skip comments
62
+
63
+ for (const { pattern, desc } of BANNED) {
64
+ const regex = new RegExp(pattern.source, pattern.flags);
65
+ let match;
66
+ while ((match = regex.exec(line)) !== null) {
67
+ const hit = match[0].toLowerCase();
68
+ // Skip if it matches an allowed pattern
69
+ if (ALLOWED_PATTERNS.some((p) => p.test(match[0]))) continue;
70
+ if (ALLOWED_HEX.has(hit)) continue;
71
+ // Skip obvious structural #fff patterns
72
+ if (hit === '#fff' || hit === '#000') continue;
73
+
74
+ console.error(` ${relPath}:${lineNum} ${desc}`);
75
+ console.error(` → ${line.trim()}`);
76
+ totalViolations++;
77
+ }
78
+ }
79
+ });
80
+ }
81
+
82
+ if (totalViolations > 0) {
83
+ console.error(`\n✖ lint-colors: ${totalViolations} violation(s) found. Replace with var(--pp-*) tokens.\n`);
84
+ process.exit(1);
85
+ } else {
86
+ console.log('✔ lint-colors: No literal color tokens found in component files.');
87
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "PeppertinoCSS",
3
+ "short_name": "Peppertino",
4
+ "description": "An Apple-inspired CSS framework with a spicy red accent.",
5
+ "start_url": "./",
6
+ "scope": "./",
7
+ "display": "standalone",
8
+ "background_color": "#ffffff",
9
+ "theme_color": "#e90111",
10
+ "icons": [
11
+ {
12
+ "src": "./icon.svg",
13
+ "sizes": "any",
14
+ "type": "image/svg+xml",
15
+ "purpose": "any"
16
+ }
17
+ ]
18
+ }
@@ -1,61 +1,105 @@
1
- (function () {
2
- document.querySelectorAll('.pp-accordion').forEach((accordion) => {
3
- const allowMultiple = accordion.hasAttribute('data-allow-multiple');
4
-
5
- accordion.querySelectorAll('.pp-accordion__trigger').forEach((trigger) => {
6
- const panelId = trigger.getAttribute('aria-controls');
7
- const panel = panelId
8
- ? document.getElementById(panelId)
9
- : trigger.nextElementSibling;
10
-
11
- if (!panel) return;
12
-
13
- // Ensure ARIA state matches DOM on init
14
- const isOpen = trigger.getAttribute('aria-expanded') === 'true';
15
- panel.setAttribute('aria-hidden', isOpen ? 'false' : 'true');
16
- if (isOpen) panel.classList.add('is-open');
17
-
18
- trigger.addEventListener('click', () => {
19
- const expanded = trigger.getAttribute('aria-expanded') === 'true';
20
-
21
- if (!allowMultiple) {
22
- accordion.querySelectorAll('.pp-accordion__trigger').forEach((t) => {
23
- if (t === trigger) return;
24
- t.setAttribute('aria-expanded', 'false');
25
- const p = t.getAttribute('aria-controls')
26
- ? document.getElementById(t.getAttribute('aria-controls'))
27
- : t.nextElementSibling;
28
- if (p) {
29
- p.setAttribute('aria-hidden', 'true');
30
- p.classList.remove('is-open');
31
- }
32
- });
33
- }
34
-
35
- const next = !expanded;
36
- trigger.setAttribute('aria-expanded', String(next));
37
- panel.setAttribute('aria-hidden', String(!next));
38
- panel.classList.toggle('is-open', next);
39
- });
40
-
41
- // Keyboard: Home/End focus management within accordion
42
- trigger.addEventListener('keydown', (e) => {
43
- const triggers = [...accordion.querySelectorAll('.pp-accordion__trigger')];
44
- const idx = triggers.indexOf(trigger);
45
- if (e.key === 'ArrowDown') {
46
- e.preventDefault();
47
- triggers[(idx + 1) % triggers.length].focus();
48
- } else if (e.key === 'ArrowUp') {
49
- e.preventDefault();
50
- triggers[(idx - 1 + triggers.length) % triggers.length].focus();
51
- } else if (e.key === 'Home') {
52
- e.preventDefault();
53
- triggers[0].focus();
54
- } else if (e.key === 'End') {
55
- e.preventDefault();
56
- triggers[triggers.length - 1].focus();
57
- }
58
- });
59
- });
60
- });
61
- })();
1
+ (function () {
2
+ const registry = {};
3
+
4
+ document.querySelectorAll('.pp-accordion').forEach((accordion, accordionIdx) => {
5
+ const allowMultiple = accordion.hasAttribute('data-allow-multiple');
6
+ const id = accordion.id || `pp-accordion-${accordionIdx}`;
7
+ if (!accordion.id) accordion.id = id;
8
+
9
+ // Native summary elements already toggle their details without a shim.
10
+ const triggers = [...accordion.querySelectorAll('.pp-accordion__trigger')]
11
+ .filter((trigger) => !trigger.matches('summary'));
12
+
13
+ triggers.forEach((trigger, i) => {
14
+ const panelId = trigger.getAttribute('aria-controls');
15
+ const panel = panelId
16
+ ? document.getElementById(panelId)
17
+ : trigger.nextElementSibling;
18
+
19
+ if (!panel) return;
20
+
21
+ const isOpen = trigger.getAttribute('aria-expanded') === 'true';
22
+ panel.setAttribute('aria-hidden', isOpen ? 'false' : 'true');
23
+ if (isOpen) panel.classList.add('is-open');
24
+
25
+ trigger.addEventListener('click', () => {
26
+ const expanded = trigger.getAttribute('aria-expanded') === 'true';
27
+
28
+ if (!allowMultiple) {
29
+ triggers.forEach((t) => {
30
+ if (t === trigger) return;
31
+ t.setAttribute('aria-expanded', 'false');
32
+ const p = t.getAttribute('aria-controls')
33
+ ? document.getElementById(t.getAttribute('aria-controls'))
34
+ : t.nextElementSibling;
35
+ if (p) {
36
+ p.setAttribute('aria-hidden', 'true');
37
+ p.classList.remove('is-open');
38
+ }
39
+ });
40
+ }
41
+
42
+ const next = !expanded;
43
+ trigger.setAttribute('aria-expanded', String(next));
44
+ panel.setAttribute('aria-hidden', String(!next));
45
+ panel.classList.toggle('is-open', next);
46
+
47
+ accordion.dispatchEvent(new CustomEvent(next ? 'pp:accordion:open' : 'pp:accordion:close', {
48
+ bubbles: true,
49
+ detail: { index: i, trigger, panel },
50
+ }));
51
+ });
52
+
53
+ trigger.addEventListener('keydown', (e) => {
54
+ const idx = triggers.indexOf(trigger);
55
+ if (e.key === 'ArrowDown') {
56
+ e.preventDefault();
57
+ triggers[(idx + 1) % triggers.length].focus();
58
+ } else if (e.key === 'ArrowUp') {
59
+ e.preventDefault();
60
+ triggers[(idx - 1 + triggers.length) % triggers.length].focus();
61
+ } else if (e.key === 'Home') {
62
+ e.preventDefault();
63
+ triggers[0].focus();
64
+ } else if (e.key === 'End') {
65
+ e.preventDefault();
66
+ triggers[triggers.length - 1].focus();
67
+ }
68
+ });
69
+ });
70
+
71
+ function setItem(index, open) {
72
+ const trigger = triggers[index];
73
+ if (!trigger) return;
74
+ const panelId = trigger.getAttribute('aria-controls');
75
+ const panel = panelId ? document.getElementById(panelId) : trigger.nextElementSibling;
76
+ if (!panel) return;
77
+ trigger.setAttribute('aria-expanded', String(open));
78
+ panel.setAttribute('aria-hidden', String(!open));
79
+ panel.classList.toggle('is-open', open);
80
+ accordion.dispatchEvent(new CustomEvent(open ? 'pp:accordion:open' : 'pp:accordion:close', {
81
+ bubbles: true,
82
+ detail: { index, trigger, panel },
83
+ }));
84
+ }
85
+
86
+ const api = {
87
+ open: (index) => setItem(index, true),
88
+ close: (index) => setItem(index, false),
89
+ toggleAll() {
90
+ const anyOpen = triggers.some((t) => t.getAttribute('aria-expanded') === 'true');
91
+ triggers.forEach((_, i) => setItem(i, !anyOpen));
92
+ },
93
+ };
94
+
95
+ registry[id] = api;
96
+ });
97
+
98
+ window.ppAccordion = {
99
+ get(ref) {
100
+ if (typeof ref === 'string') return registry[ref];
101
+ if (ref instanceof Element) return registry[ref.id];
102
+ return null;
103
+ },
104
+ };
105
+ })();
@@ -0,0 +1,28 @@
1
+ (function () {
2
+ function dismiss(alertEl) {
3
+ if (alertEl._dismissed) return;
4
+ alertEl._dismissed = true;
5
+ alertEl.classList.add('is-dismissing');
6
+ alertEl.dispatchEvent(new CustomEvent('pp:alert:dismiss', { bubbles: true }));
7
+ alertEl.addEventListener('animationend', () => alertEl.remove(), { once: true });
8
+ setTimeout(() => alertEl.remove(), 250);
9
+ }
10
+
11
+ window.ppAlert = {
12
+ dismiss(idOrEl) {
13
+ const el = typeof idOrEl === 'string'
14
+ ? document.getElementById(idOrEl)
15
+ : idOrEl;
16
+ if (el) dismiss(el);
17
+ },
18
+ };
19
+
20
+ // Auto-wire [data-alert-dismiss] buttons
21
+ document.addEventListener('click', (e) => {
22
+ const btn = e.target.closest('[data-alert-dismiss]');
23
+ if (btn) {
24
+ const alert = btn.closest('.pp-alert');
25
+ if (alert) dismiss(alert);
26
+ }
27
+ });
28
+ })();