@auriel/peppertino 0.3.0 → 0.4.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/CHANGELOG.txt CHANGED
@@ -1,136 +1,136 @@
1
1
  PeppertinoCSS — Changelog
2
2
  =========================
3
3
 
4
- v0.3.0 — 2026-06-05
5
- --------------------
6
-
7
- New components
4
+ All notable changes are documented here in reverse chronological order.
5
+ Versioning follows semver. Dates are YYYY-MM-DD.
8
6
 
9
- Carousel (carousel.scss + carousel.js)
10
- - CSS scroll-snap driven, no JS required for motion
11
- - Variants: default, --peek-2, --peek-3, --dark, --flush
12
- - Prev/next controls, animated pill dots, gradient caption overlay
13
- - Autoplay toggle button (UI state only)
14
- - JS shim: ARIA region/slide/group roles, IntersectionObserver sync,
15
- roving tabindex on dots, polite live region announcements
16
- - ppCarousel.get(id) public API
7
+ ─────────────────────────────────────────────────────────────────────────────
8
+ v0.4.0 — 2026-06-11
9
+ ─────────────────────────────────────────────────────────────────────────────
17
10
 
18
- Footer (footer.scss)
19
- - CSS only, no JS
20
- - Brand column + up to 4 nav columns, collapses to 2-col then 1-col
21
- - Bottom bar: copyright + social icon links
22
- - Variants: --dark, --accent (gradient top border)
23
- - All links have :focus-visible outlines
11
+ New components
12
+ - Accordion CSS max-height transition; variants: --flush, --dark, --primary.
13
+ JS shim adds aria-expanded, aria-hidden, keyboard navigation
14
+ (↑ ↓ Home End), and data-allow-multiple for multi-open mode.
15
+ - Alert Inline feedback messages; variants: --info, --success,
16
+ --warning, --error, --primary, --neutral; modifier: --filled.
17
+ .is-dismissible + .pp-alert__dismiss button; .is-dismissing
18
+ triggers slide-out animation before DOM removal.
19
+
20
+ Utilities
21
+ - New utilities layer (utilities.scss) — single-purpose classes with no JS:
22
+ Display .d-{block|inline|inline-block|flex|inline-flex|
23
+ grid|inline-grid|none|contents}
24
+ Visibility .visible .invisible .sr-only .not-sr-only
25
+ Opacity .opacity-{0|25|50|75|100}
26
+ Margin .m-* .mt-* .mb-* .ml-* .mr-* .mx-* .my-* (keys 0-32, auto)
27
+ Padding .p-* .pt-* .pb-* .pl-* .pr-* .px-* .py-* (keys 0-32)
28
+ Gap .gap-* .gap-x-* .gap-y-* (keys 0-32)
29
+ Flex direction, wrap, grow/shrink, justify-content, align-items,
30
+ align-self
31
+ Grid .grid-cols-{1-6,12}, .grid-rows-{1-4}, .col-span-*,
32
+ .row-span-*
33
+ Width .w-full .w-screen .w-auto .w-fit .w-min .w-max .w-half
34
+ Height .h-full .h-screen .h-auto .h-fit
35
+ Overflow .overflow-{auto|hidden|visible|scroll}, x/y variants
36
+ Position .static .relative .absolute .fixed .sticky
37
+ Z-index .z-{below|base|raised|overlay|modal|toast|tooltip}
38
+ Border-radius .rounded-{none|sm|base|md|lg|xl|2xl|full}
39
+ Shadow .shadow-{none|sm|md|lg|xl}
40
+ Cursor .cursor-{default|pointer|not-allowed|grab|text}
41
+ Pointer .pointer-events-{none|auto}
42
+ User-select .select-{none|text|all|auto}
43
+ Responsive .sm-d-* .md-d-* .lg-d-* .xl-d-* .w2xl-d-* (display only)
44
+
45
+ Dark mode
46
+ - Class-based dark mode via .dark on <html> or any ancestor.
47
+ Never prefers-color-scheme. JS toggle persists preference to localStorage.
48
+ - All design tokens in base.scss now exposed as CSS custom properties on :root
49
+ (--pp-neutral-*, --pp-surface, --pp-on-surface, --pp-border,
50
+ --pp-bg-card, --pp-bg-input, --pp-bg-select*, --pp-bg-header*,
51
+ --pp-bg-footer, --pp-bg-dropdown, --pp-glass-border, --pp-glass-hover,
52
+ --pp-shadow-*, --pp-label-*, --pp-section-muted-bg, etc.).
53
+ - dark-mode.scss overrides all tokens under .dark: neutral scale fully
54
+ inverted (50 <-> 900), surface/on-surface swapped, shadows strengthened,
55
+ glass values darkened.
56
+ - Component SCSS updated to consume CSS vars instead of hardcoded literals:
57
+ card, accordion, table, header, footer, section, select, forms/fieldset,
58
+ forms/text-field, forms/validation.
59
+ - Demo page: moon/sun toggle added to header. Every component section now
60
+ shows a .dark-wrapped preview pane alongside the light demo.
61
+
62
+ Bug fixes / polish
63
+ - Table row borders: were using static $color-neutral-200 SCSS var (light
64
+ only); replaced with var(--pp-border) so they flip correctly in dark mode.
65
+ - Utilities demo: inline code chips and container backgrounds were hardcoded
66
+ #f4f4f5; replaced with var(--pp-neutral-100) / var(--pp-neutral-200).
67
+ - Changelog section: hardcoded text colors replaced with CSS vars.
68
+ - dark-mode.scss: attribute selector overrides for inline-style colors
69
+ (#71717a, #52525b, #18181b) used on section labels in the demo page.
70
+
71
+ ─────────────────────────────────────────────────────────────────────────────
72
+ v0.3.0 — 2026-06-05
73
+ ─────────────────────────────────────────────────────────────────────────────
24
74
 
25
- Forms (forms.scss + src/scss/forms/)
26
- - Fieldset & Legend (fieldset.scss)
27
- - Variants: default, --ghost, --filled, --primary, --error
28
- - disabled / aria-disabled support
29
- - Legend modifiers: --sm, --lg, --inline (icon + text)
30
- - Form Instructions (form-instructions.scss)
31
- - Pre-form block (place before <form> for screen reader Forms Mode)
32
- - Variants: default, --neutral, --warning, --error (role="alert")
33
- - In-form hint (.pp-form-hint) and required-field note
34
- - Label (label.scss)
35
- - Four importance tiers: primary, secondary, tertiary, quaternary
36
- - Apple Dynamic Type scale: headline, subheadline, body, callout,
37
- footnote, caption
38
- - --selectable, --truncate modifiers
39
- - .pp-label-row for icon + label pairing
40
- - Text Field (text-field.scss)
41
- - .pp-field wrapper: label, input/textarea, hint, message
42
- - Required <abbr aria-label="required"> marker
43
- - Optional badge
44
- - Validation states: --error, --success, --warning
45
- - Sizes: --sm, --lg
46
- - Icon wrap (.pp-field__input-wrap + .pp-field__icon)
47
- - Character counter (.pp-field__count) with --warn / --over states
48
- - Validation (validation.scss + validation.js)
49
- - .pp-field--validate opt-in for :valid/:invalid pseudo-class styling
50
- - aria-invalid attribute selectors (work without JS)
51
- - .pp-field--validating spinner state for async checks
52
- - .pp-validation-summary with role="alert", linked error items
53
- - .pp-confirm confirmation checkbox, --destructive variant
54
- - .pp-submit--gated: CSS :has() disables submit until confirmed
55
- - JS shim: setError, clearError, setSuccess, setValidating, setSummary
56
- - Auto-wires aria-describedby on init
75
+ New components
76
+ - Carousel CSS scroll-snap driven; variants: --peek-2, --peek-3,
77
+ --dark, --flush; ppCarousel JS API (goTo, prev, next).
78
+ - Footer Multi-column layout; variants: --dark, --accent; CSS only.
79
+ - Forms Five new form partials:
80
+ Fieldset .pp-fieldset + .pp-legend; variants: --ghost, --filled,
81
+ --primary, --error; legend modifiers: --sm, --lg, --inline.
82
+ Form Instr. .pp-form-instructions -- pre-form block for screen reader
83
+ Forms Mode; variants: --neutral, --warning, --error.
84
+ .pp-form-hint and .pp-form-required-note helpers.
85
+ Label .pp-label -- four-tier importance system (primary to
86
+ quaternary); Apple Dynamic Type scale (headline to caption);
87
+ --selectable, --truncate, icon row.
88
+ Text Field .pp-field -- label + input/textarea + hint + required abbr +
89
+ validation states (--error, --success, --warning,
90
+ --validating); sizes --sm / --lg; icon wrap; char counter.
91
+ Validation :valid/:invalid opt-in, aria-invalid selectors, async
92
+ spinner, .pp-validation-summary with role="alert",
93
+ .pp-confirm CSS :has() gated submit; ppValidation JS API.
57
94
 
58
95
  Breakpoints
59
- - Tailwind-compatible map: sm/md/lg/xl/2xl
60
- - Apple device map: iphone-se through imac (12 named breakpoints)
61
- - respond-to() mixin (min-width)
62
- - respond-below() and respond-between() mixins
96
+ - Added respond-below() and respond-between() mixins.
97
+ - Apple device breakpoint map: 12 named entries from iphone-se to imac.
63
98
 
64
99
  Icons
65
- - Switched from Feather Icons to Lucide Icons (CDN + createIcons())
66
- - Brand/logo icons in footer use inline SVG (Lucide has no brand icons)
67
-
68
- Demo (index.html)
69
- - Installation section with npm, CDN, SCSS import, clone instructions
70
- - Carousel, Footer, and Forms sections added
71
- - Nav dropdowns for Components and Forms
72
- - Changelog section
73
- - All external links use jsdelivr CDN
100
+ - Switched from Feather Icons to Lucide Icons (lucide.createIcons()).
74
101
 
102
+ Demo
103
+ - Installation, Carousel, Footer, and Forms sections added to index.html.
104
+ - Header nav: Components and Forms dropdowns; A-to-Z component ordering.
105
+ - Changelog section added to demo page.
75
106
 
107
+ ─────────────────────────────────────────────────────────────────────────────
76
108
  v0.2.0 — 2026-06-01
77
- --------------------
78
- Accessibility (ARIA) — full pass across all components.
79
-
80
- Header
81
- - role="menubar" on nav list
82
- - role="menu" on dropdowns, role="menuitem" on all links
83
- - role="none" on <li> wrappers
84
- - aria-haspopup + aria-expanded on dropdown triggers
85
- - aria-controls wired to dropdown IDs
86
- - aria-hidden toggled on mobile nav drawer
87
- - aria-label on <nav>
88
-
89
- Modal
90
- - role="dialog" + aria-modal="true" on backdrop
91
- - aria-labelledby + aria-describedby auto-wired to title/description IDs
92
- - aria-label="Close" on close button
93
- - Focus trap: Tab/Shift+Tab stays inside open modal
94
- - Focus restored to triggering element on close
95
-
96
- Select
97
- - role="combobox" on trigger
98
- - role="listbox" on panel
99
- - role="option" + aria-selected on every option
100
- - aria-controls + aria-activedescendant kept in sync on selection
101
- - aria-disabled CSS hook for disabled state
102
-
103
- Tabs
104
- - role="tablist" on container (enforced by JS if missing)
105
- - role="tab" on items
106
- - aria-controls wired to panel IDs
107
- - role="tabpanel" + aria-labelledby on panels
108
- - Home / End keyboard shortcuts added
109
-
110
- CSS
111
- - ARIA attribute selectors (aria-expanded, aria-hidden, aria-selected,
112
- aria-disabled) are now first-class CSS hooks — visual state is driven
113
- by ARIA, not just class names
114
-
115
- HTML demo
116
- - All modal backdrops updated with role, aria-modal, aria-labelledby,
117
- aria-describedby, aria-hidden in markup
118
- - Nav updated with full menubar / menu / menuitem semantics
119
-
120
- Page structure
121
- - Section order updated: Hero → Colors → Typography → Components (A→Z)
122
-
123
-
109
+ ─────────────────────────────────────────────────────────────────────────────
110
+
111
+ Accessibility -- full ARIA pass across all components
112
+ - Header role="menubar" / "menu" / "menuitem"; aria-haspopup +
113
+ aria-expanded on dropdown triggers; aria-hidden on mobile drawer.
114
+ - Modal role="dialog" + aria-modal; aria-labelledby + aria-describedby
115
+ auto-wired by JS; focus trap on open; focus restored on close.
116
+ - Select role="combobox" / "listbox" / "option" + aria-selected;
117
+ aria-activedescendant kept in sync with keyboard focus.
118
+ - Tabs role="tablist"; aria-controls to panel ids; Home / End keyboard
119
+ shortcuts.
120
+ - CSS ARIA attribute states are first-class selectors -- visual state
121
+ driven by aria-expanded / aria-selected / aria-hidden rather
122
+ than class names alone.
123
+ - Demo Section order updated: Hero -> Colors -> Typography ->
124
+ Components (A-to-Z).
125
+
126
+ ─────────────────────────────────────────────────────────────────────────────
124
127
  v0.1.1 — initial release
125
- -------------------------
126
- - Reset, base design tokens, button, card, gradient text
127
- - Header: glassmorphism sticky, mobile hamburger drawer
128
- - Modal: glassmorphic backdrop, native <dialog> support
129
- - Section: full-viewport sections, custom gradient scrollbar
130
- - Select: native <select> restyling + .pp-select custom dropdown
131
- - Table: Apple-style clean tables
132
- - Tabs: pill-style, icon + label, four variants, sm/lg sizes
133
- - Typography: Inter + Kode Mono, weight/size/spacing utility classes
134
- - Progressive enhancement: CSS-only baseline for all interactive components
135
- - esbuild bundler: per-component files + peppertino.js aggregator
136
- - MIT license
128
+ ─────────────────────────────────────────────────────────────────────────────
129
+
130
+ - Reset, base tokens, button, card, gradient text, header, modal, section,
131
+ select, table, tabs, typography.
132
+ - Progressive enhancement -- CSS-only baseline; JS adds keyboard navigation,
133
+ animations, and outside-click close.
134
+ - Inter + Kode Mono via Google Fonts.
135
+ - esbuild bundler with per-component JS files + peppertino.js aggregator.
136
+ - Tailwind-compatible breakpoint map (sm / md / lg / xl / 2xl).
package/README.md CHANGED
@@ -116,10 +116,13 @@ The skill's `skill.md` enforces ARIA and WCAG AA compliance rules and instructs
116
116
  | File | Purpose |
117
117
  |---|---|
118
118
  | `reset.scss` | Opinionated modern reset |
119
- | `base.scss` | Design tokens, helper functions, base element styles |
119
+ | `base.scss` | Design tokens, CSS custom properties, helper functions, base element styles |
120
+ | `accordion.scss` | `.pp-accordion` — collapsible panels; variants: `--flush`, `--dark`, `--primary` |
121
+ | `alert.scss` | `.pp-alert` — inline feedback; variants: `--info/success/warning/error/primary/neutral`, `--filled` |
120
122
  | `button.scss` | `.button`, `.button-outline`, semantic variants |
121
123
  | `card.scss` | `.pp-card` and variants |
122
124
  | `carousel.scss` | `.pp-carousel` — CSS scroll-snap carousel |
125
+ | `dark-mode.scss` | `.dark` overrides for all `--pp-*` tokens — applied last |
123
126
  | `footer.scss` | `.pp-footer` — multi-column footer |
124
127
  | `forms.scss` | Aggregator for all form partials |
125
128
  | `forms/fieldset.scss` | `.pp-fieldset` + `.pp-legend` |
@@ -135,18 +138,22 @@ The skill's `skill.md` enforces ARIA and WCAG AA compliance rules and instructs
135
138
  | `table.scss` | `.pp-table` — clean Apple-style data tables |
136
139
  | `tabs.scss` | `.pp-tabs` — pill-style tabs with icon + label |
137
140
  | `typography.scss` | Utility classes for font, size, weight, spacing |
141
+ | `utilities.scss` | Single-purpose layout/spacing/display/visibility classes |
138
142
 
139
143
  ### JS components (`src/js/`)
140
144
 
145
+ Each file is a self-contained IIFE. Import only what you need, or include `peppertino.js` for everything.
146
+
141
147
  | File | Purpose |
142
148
  |---|---|
149
+ | `accordion.js` | `aria-expanded`/`aria-hidden`, keyboard nav (↑ ↓ Home End), `data-allow-multiple` |
143
150
  | `carousel.js` | ARIA wiring, IntersectionObserver sync, `ppCarousel` API |
144
151
  | `header.js` | Mobile drawer, dropdown ARIA wiring for `.pp-header` |
145
152
  | `modal.js` | Open/close, focus trap, focus restore, ARIA for `.pp-modal` |
146
153
  | `select.js` | Keyboard nav, ARIA listbox/option for `.pp-select` |
147
154
  | `tabs.js` | Click + arrow key activation, ARIA tablist for `.pp-tabs` |
148
155
  | `validation.js` | `aria-invalid` wiring, summary focus, `ppValidation` API |
149
- | `peppertino.js` | Single-file bundle of all the above |
156
+ | `peppertino.js` | Aggregator — imports all of the above |
150
157
 
151
158
  All JS follows progressive enhancement — CSS provides the full visual baseline without JS. JS adds keyboard navigation, focus management, and ARIA state.
152
159
 
@@ -222,6 +229,53 @@ Apple device breakpoints: `iphone-se` · `iphone` · `iphone-plus` · `iphone-pr
222
229
 
223
230
  ## Components
224
231
 
232
+ ### Accordion
233
+
234
+ ```html
235
+ <div class="pp-accordion" data-allow-multiple>
236
+ <div class="pp-accordion__item">
237
+ <button class="pp-accordion__trigger" aria-expanded="false" aria-controls="acc-1">
238
+ Question
239
+ <svg class="pp-accordion__icon" viewBox="0 0 24 24" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg>
240
+ </button>
241
+ <div class="pp-accordion__panel" id="acc-1" aria-hidden="true">
242
+ <p class="pp-accordion__content">Answer text.</p>
243
+ </div>
244
+ </div>
245
+ </div>
246
+ <script src="dist/accordion.js" defer></script>
247
+ ```
248
+
249
+ Variants: `--flush` · `--dark` · `--primary`
250
+ Attribute: `data-allow-multiple` — allow multiple panels open at once
251
+ Keyboard: `↑` / `↓` arrows, `Home`, `End`
252
+
253
+ ### Alert
254
+
255
+ ```html
256
+ <div class="pp-alert pp-alert--info" role="note">
257
+ <span class="pp-alert__icon"><i data-lucide="info" aria-hidden="true"></i></span>
258
+ <div class="pp-alert__body">
259
+ <p class="pp-alert__title">Heads up</p>
260
+ <p class="pp-alert__message">Your session expires in 10 minutes.</p>
261
+ </div>
262
+ </div>
263
+
264
+ <!-- Dismissible -->
265
+ <div class="pp-alert pp-alert--success is-dismissible" role="status" id="a1">
266
+ <span class="pp-alert__icon"><i data-lucide="circle-check" aria-hidden="true"></i></span>
267
+ <div class="pp-alert__body"><p class="pp-alert__message">Saved.</p></div>
268
+ <button class="pp-alert__dismiss" aria-label="Dismiss"
269
+ onclick="const e=document.getElementById('a1');e.classList.add('is-dismissing');setTimeout(()=>e.remove(),200);">
270
+ <i data-lucide="x" aria-hidden="true"></i>
271
+ </button>
272
+ </div>
273
+ ```
274
+
275
+ Variants: `--info` · `--success` · `--warning` · `--error` · `--primary` · `--neutral`
276
+ Modifier: `--filled` (solid background instead of tint)
277
+ States: `.is-dismissible` · `.is-dismissing` (slide-out before removal)
278
+
225
279
  ### Button
226
280
 
227
281
  ```html
@@ -505,6 +559,54 @@ Variants: `--primary` · `--dark` · `--muted` · `--gradient`
505
559
 
506
560
  ---
507
561
 
562
+ ## Utilities
563
+
564
+ Single-purpose classes — no JavaScript required. Import `utilities.scss` or use the compiled CSS.
565
+
566
+ | Group | Classes |
567
+ |---|---|
568
+ | Display | `.d-{block\|inline\|inline-block\|flex\|inline-flex\|grid\|inline-grid\|none\|contents}` |
569
+ | Visibility | `.visible` `.invisible` `.sr-only` `.not-sr-only` |
570
+ | Opacity | `.opacity-{0\|25\|50\|75\|100}` |
571
+ | Margin | `.m-*` `.mt-*` `.mb-*` `.ml-*` `.mr-*` `.mx-*` `.my-*` (keys 0–32, `auto`) |
572
+ | Padding | `.p-*` `.pt-*` `.pb-*` `.pl-*` `.pr-*` `.px-*` `.py-*` (keys 0–32) |
573
+ | Gap | `.gap-*` `.gap-x-*` `.gap-y-*` (keys 0–32) |
574
+ | Flex | direction, wrap, grow/shrink, justify-content, align-items, align-self |
575
+ | Grid | `.grid-cols-{1–6,12}` `.grid-rows-{1–4}` `.col-span-*` `.row-span-*` |
576
+ | Width | `.w-full` `.w-screen` `.w-auto` `.w-fit` `.w-min` `.w-max` `.w-half` |
577
+ | Height | `.h-full` `.h-screen` `.h-auto` `.h-fit` |
578
+ | Overflow | `.overflow-{auto\|hidden\|visible\|scroll}`, x/y variants |
579
+ | Position | `.static` `.relative` `.absolute` `.fixed` `.sticky` |
580
+ | Z-index | `.z-{below\|base\|raised\|overlay\|modal\|toast\|tooltip}` |
581
+ | Border-radius | `.rounded-{none\|sm\|base\|md\|lg\|xl\|2xl\|full}` |
582
+ | Shadow | `.shadow-{none\|sm\|md\|lg\|xl}` |
583
+ | Cursor | `.cursor-{default\|pointer\|not-allowed\|grab\|text}` |
584
+ | Responsive | `.sm-d-*` `.md-d-*` `.lg-d-*` `.xl-d-*` `.w2xl-d-*` (display only) |
585
+
586
+ ---
587
+
588
+ ## Dark mode
589
+
590
+ Add `class="dark"` to `<html>` (or any ancestor element). All component tokens flip automatically via CSS custom properties — no extra classes needed on individual components.
591
+
592
+ ```html
593
+ <html class="dark">
594
+ <!-- everything inside uses dark surface tokens -->
595
+ </html>
596
+ ```
597
+
598
+ Toggle from JS:
599
+
600
+ ```js
601
+ document.documentElement.classList.toggle('dark');
602
+ // persist across sessions:
603
+ localStorage.setItem('pp-dark', document.documentElement.classList.contains('dark'));
604
+ ```
605
+
606
+ All `--pp-*` tokens are defined on `:root` as light defaults. `dark-mode.scss` overrides them under `.dark`. The neutral scale is fully inverted (50 ↔ 900), surfaces swap, and glass/shadow values are strengthened for dark backgrounds.
607
+
608
+ ---
609
+
508
610
  ## Changelog
509
611
 
510
612
  See [CHANGELOG.txt](CHANGELOG.txt)
@@ -0,0 +1,51 @@
1
+ (() => {
2
+ (function() {
3
+ document.querySelectorAll(".pp-accordion").forEach((accordion) => {
4
+ const allowMultiple = accordion.hasAttribute("data-allow-multiple");
5
+ accordion.querySelectorAll(".pp-accordion__trigger").forEach((trigger) => {
6
+ const panelId = trigger.getAttribute("aria-controls");
7
+ const panel = panelId ? document.getElementById(panelId) : trigger.nextElementSibling;
8
+ if (!panel) return;
9
+ const isOpen = trigger.getAttribute("aria-expanded") === "true";
10
+ panel.setAttribute("aria-hidden", isOpen ? "false" : "true");
11
+ if (isOpen) panel.classList.add("is-open");
12
+ trigger.addEventListener("click", () => {
13
+ const expanded = trigger.getAttribute("aria-expanded") === "true";
14
+ if (!allowMultiple) {
15
+ accordion.querySelectorAll(".pp-accordion__trigger").forEach((t) => {
16
+ if (t === trigger) return;
17
+ t.setAttribute("aria-expanded", "false");
18
+ const p = t.getAttribute("aria-controls") ? document.getElementById(t.getAttribute("aria-controls")) : t.nextElementSibling;
19
+ if (p) {
20
+ p.setAttribute("aria-hidden", "true");
21
+ p.classList.remove("is-open");
22
+ }
23
+ });
24
+ }
25
+ const next = !expanded;
26
+ trigger.setAttribute("aria-expanded", String(next));
27
+ panel.setAttribute("aria-hidden", String(!next));
28
+ panel.classList.toggle("is-open", next);
29
+ });
30
+ trigger.addEventListener("keydown", (e) => {
31
+ const triggers = [...accordion.querySelectorAll(".pp-accordion__trigger")];
32
+ const idx = triggers.indexOf(trigger);
33
+ if (e.key === "ArrowDown") {
34
+ e.preventDefault();
35
+ triggers[(idx + 1) % triggers.length].focus();
36
+ } else if (e.key === "ArrowUp") {
37
+ e.preventDefault();
38
+ triggers[(idx - 1 + triggers.length) % triggers.length].focus();
39
+ } else if (e.key === "Home") {
40
+ e.preventDefault();
41
+ triggers[0].focus();
42
+ } else if (e.key === "End") {
43
+ e.preventDefault();
44
+ triggers[triggers.length - 1].focus();
45
+ }
46
+ });
47
+ });
48
+ });
49
+ })();
50
+ })();
51
+ //# sourceMappingURL=accordion.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/js/accordion.js"],
4
+ "sourcesContent": ["(function () {\n document.querySelectorAll('.pp-accordion').forEach((accordion) => {\n const allowMultiple = accordion.hasAttribute('data-allow-multiple');\n\n accordion.querySelectorAll('.pp-accordion__trigger').forEach((trigger) => {\n const panelId = trigger.getAttribute('aria-controls');\n const panel = panelId\n ? document.getElementById(panelId)\n : trigger.nextElementSibling;\n\n if (!panel) return;\n\n // Ensure ARIA state matches DOM on init\n const isOpen = trigger.getAttribute('aria-expanded') === 'true';\n panel.setAttribute('aria-hidden', isOpen ? 'false' : 'true');\n if (isOpen) panel.classList.add('is-open');\n\n trigger.addEventListener('click', () => {\n const expanded = trigger.getAttribute('aria-expanded') === 'true';\n\n if (!allowMultiple) {\n accordion.querySelectorAll('.pp-accordion__trigger').forEach((t) => {\n if (t === trigger) return;\n t.setAttribute('aria-expanded', 'false');\n const p = t.getAttribute('aria-controls')\n ? document.getElementById(t.getAttribute('aria-controls'))\n : t.nextElementSibling;\n if (p) {\n p.setAttribute('aria-hidden', 'true');\n p.classList.remove('is-open');\n }\n });\n }\n\n const next = !expanded;\n trigger.setAttribute('aria-expanded', String(next));\n panel.setAttribute('aria-hidden', String(!next));\n panel.classList.toggle('is-open', next);\n });\n\n // Keyboard: Home/End focus management within accordion\n trigger.addEventListener('keydown', (e) => {\n const triggers = [...accordion.querySelectorAll('.pp-accordion__trigger')];\n const idx = triggers.indexOf(trigger);\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n triggers[(idx + 1) % triggers.length].focus();\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n triggers[(idx - 1 + triggers.length) % triggers.length].focus();\n } else if (e.key === 'Home') {\n e.preventDefault();\n triggers[0].focus();\n } else if (e.key === 'End') {\n e.preventDefault();\n triggers[triggers.length - 1].focus();\n }\n });\n });\n });\n})();\n"],
5
+ "mappings": ";AAAA,GAAC,WAAY;AACX,aAAS,iBAAiB,eAAe,EAAE,QAAQ,CAAC,cAAc;AAChE,YAAM,gBAAgB,UAAU,aAAa,qBAAqB;AAElE,gBAAU,iBAAiB,wBAAwB,EAAE,QAAQ,CAAC,YAAY;AACxE,cAAM,UAAU,QAAQ,aAAa,eAAe;AACpD,cAAM,QAAQ,UACV,SAAS,eAAe,OAAO,IAC/B,QAAQ;AAEZ,YAAI,CAAC,MAAO;AAGZ,cAAM,SAAS,QAAQ,aAAa,eAAe,MAAM;AACzD,cAAM,aAAa,eAAe,SAAS,UAAU,MAAM;AAC3D,YAAI,OAAQ,OAAM,UAAU,IAAI,SAAS;AAEzC,gBAAQ,iBAAiB,SAAS,MAAM;AACtC,gBAAM,WAAW,QAAQ,aAAa,eAAe,MAAM;AAE3D,cAAI,CAAC,eAAe;AAClB,sBAAU,iBAAiB,wBAAwB,EAAE,QAAQ,CAAC,MAAM;AAClE,kBAAI,MAAM,QAAS;AACnB,gBAAE,aAAa,iBAAiB,OAAO;AACvC,oBAAM,IAAI,EAAE,aAAa,eAAe,IACpC,SAAS,eAAe,EAAE,aAAa,eAAe,CAAC,IACvD,EAAE;AACN,kBAAI,GAAG;AACL,kBAAE,aAAa,eAAe,MAAM;AACpC,kBAAE,UAAU,OAAO,SAAS;AAAA,cAC9B;AAAA,YACF,CAAC;AAAA,UACH;AAEA,gBAAM,OAAO,CAAC;AACd,kBAAQ,aAAa,iBAAiB,OAAO,IAAI,CAAC;AAClD,gBAAM,aAAa,eAAe,OAAO,CAAC,IAAI,CAAC;AAC/C,gBAAM,UAAU,OAAO,WAAW,IAAI;AAAA,QACxC,CAAC;AAGD,gBAAQ,iBAAiB,WAAW,CAAC,MAAM;AACzC,gBAAM,WAAW,CAAC,GAAG,UAAU,iBAAiB,wBAAwB,CAAC;AACzE,gBAAM,MAAM,SAAS,QAAQ,OAAO;AACpC,cAAI,EAAE,QAAQ,aAAa;AACzB,cAAE,eAAe;AACjB,sBAAU,MAAM,KAAK,SAAS,MAAM,EAAE,MAAM;AAAA,UAC9C,WAAW,EAAE,QAAQ,WAAW;AAC9B,cAAE,eAAe;AACjB,sBAAU,MAAM,IAAI,SAAS,UAAU,SAAS,MAAM,EAAE,MAAM;AAAA,UAChE,WAAW,EAAE,QAAQ,QAAQ;AAC3B,cAAE,eAAe;AACjB,qBAAS,CAAC,EAAE,MAAM;AAAA,UACpB,WAAW,EAAE,QAAQ,OAAO;AAC1B,cAAE,eAAe;AACjB,qBAAS,SAAS,SAAS,CAAC,EAAE,MAAM;AAAA,UACtC;AAAA,QACF,CAAC;AAAA,MACH,CAAC;AAAA,IACH,CAAC;AAAA,EACH,GAAG;",
6
+ "names": []
7
+ }