Files
WorkRoot-WRNexusJSComponent/app/pages/components/accordion.wrn
T
ClintchizandClaude Opus 5.5 c0ac38c572 feat: sync showcase with WRNexusJS 0.8.72 and @wrnexus/ui 0.8.88
- Sync app, public, scripts, test and examples from the framework's
  component-showcase: redesigned component demos, marketing blocks under
  /blocks, template and preview galleries, distinct Timeline/Section
  variants, Chat Bubble receipts, a top-placement Drawer demo, and the
  playground code panel fix (objects in array props no longer blank out).
- Standalone adaptations kept: the generator and tests read
  component-reference.json from the published @wrnexus/ui, and tests use
  the published @wrnexus/compiler and @wrnexus/syntax.
- Dependencies: every @wrnexus/* package to its latest release (ui 0.8.88,
  styles 0.8.26, core 0.8.16, cli 0.8.72, ...), happy-dom for the
  playground tests, Tailwind 4.3; bun.lock and package-lock.json refreshed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 16:50:22 +05:30

282 lines
25 KiB
Plaintext

// Generated by scripts/generate-showcase.mjs. Do not edit directly.
page AccordionDetail {
layout = "showcase"
state playground_size = ctx.url.searchParams.get("pg_size") ?? "default"
state playground_color = ctx.url.searchParams.get("pg_color") ?? "primary"
state playground_variant = ctx.url.searchParams.get("pg_variant") ?? "default"
state playground_class = ctx.url.searchParams.get("pg_class") ?? "showcase-instance showcase-instance--1"
state playground_id = ctx.url.searchParams.get("pg_id") ?? "accordion"
state playground_items = JSON.parse(ctx.url.searchParams.get("pg_items") ?? "[{\"value\":\"workspace\",\"label\":\"How do I create a workspace?\",\"content\":\"Choose Create workspace, add a name, and invite your team. You can update the details any time in Settings.\"},{\"value\":\"billing\",\"label\":\"Can I change my plan later?\",\"content\":\"Yes. Open Billing to compare plans and choose the one that suits your team.\"},{\"value\":\"security\",\"label\":\"How is my account protected?\",\"content\":\"Enable two-step verification and add a recovery method to keep your account secure.\"}]")
state playground_defaultOpen = JSON.parse(ctx.url.searchParams.get("pg_defaultOpen") ?? "[\"workspace\"]")
state playground_multiple = (ctx.url.searchParams.get("pg_multiple") ?? "false") === "true"
state playground_alwaysOpen = (ctx.url.searchParams.get("pg_alwaysOpen") ?? "false") === "true"
state playground_disabled = (ctx.url.searchParams.get("pg_disabled") ?? "false") === "true"
state playground_indicator = ctx.url.searchParams.get("pg_indicator") ?? "chevron"
state playground_indicatorPosition = ctx.url.searchParams.get("pg_indicatorPosition") ?? "end"
state playground_showIndicator = (ctx.url.searchParams.get("pg_showIndicator") ?? "true") === "true"
state playground_bordered = (ctx.url.searchParams.get("pg_bordered") ?? "false") === "true"
state playground_separated = (ctx.url.searchParams.get("pg_separated") ?? "false") === "true"
state playground_flush = (ctx.url.searchParams.get("pg_flush") ?? "false") === "true"
state playground_contentItalic = (ctx.url.searchParams.get("pg_contentItalic") ?? "false") === "true"
seo {
title = "Accordion"
description = "Theme-aware, responsive accordion component."
}
view {
<nav class="docs-breadcrumbs" aria-label="Breadcrumb">
<a href="/">Components</a><span aria-hidden="true">/</span><a href="/base">Base</a><span aria-hidden="true">/</span><span>Accordion</span>
</nav>
<header class="detail-hero">
<div class="detail-hero-copy">
<span class="showcase-eyebrow">Base component</span>
<h1>Accordion</h1>
<p>Theme-aware, responsive accordion component.</p>
<div class="detail-badges"><span>17 props</span><span>0 slots</span><span>3 outputs</span><span>Theme ready</span><span>Responsive</span></div>
</div>
<div class="detail-hero-icon"><span class="icon-[lucide--component] size-10" aria-hidden="true"></span></div>
</header>
<section id="playground" class="detail-section playground-section" data-playground data-playground-component="Accordion" data-playground-public-tag="true" data-playground-has-slot="false" data-playground-events="change,open,close">
<div class="detail-section-heading"><span>Interactive playground</span><h2>Configure Accordion</h2><p>Change any prop and inspect the server-rendered component immediately.</p></div>
<div class="playground-workbench">
<div class="playground-preview">
<div class="demo-browser-chrome"><span></span><span></span><span></span><small>Live preview</small></div>
<div class="playground-preview-source" data-playground-preview><Accordion size='{playground_size}' color='{playground_color}' variant='{playground_variant}' class='{playground_class}' id='{playground_id}' items='{playground_items}' defaultOpen='{playground_defaultOpen}' multiple='{playground_multiple}' alwaysOpen='{playground_alwaysOpen}' disabled='{playground_disabled}' indicator='{playground_indicator}' indicatorPosition='{playground_indicatorPosition}' showIndicator='{playground_showIndicator}' bordered='{playground_bordered}' separated='{playground_separated}' flush='{playground_flush}' contentItalic='{playground_contentItalic}' /></div>
<section class="playground-code" aria-label="Current component code">
<header><span><span class="icon-[lucide--code-2] size-4" aria-hidden="true"></span>Component code</span><button type="button" data-playground-copy><span class="icon-[lucide--copy] size-4" aria-hidden="true"></span>Copy</button></header>
<pre><code data-playground-code>page AccordionExample <span>&#123;</span>
state items = [
<span>&#123;</span>
"value": "workspace",
"label": "How do I create a workspace?",
"content": "Choose Create workspace, add a name, and invite your team. You can update the details any time in Settings."
<span>&#125;</span>,
<span>&#123;</span>
"value": "billing",
"label": "Can I change my plan later?",
"content": "Yes. Open Billing to compare plans and choose the one that suits your team."
<span>&#125;</span>,
<span>&#123;</span>
"value": "security",
"label": "How is my account protected?",
"content": "Enable two-step verification and add a recovery method to keep your account secure."
<span>&#125;</span>
]
state defaultOpen = [
"workspace"
]
view <span>&#123;</span>
&lt;Accordion
items="<span>&#123;</span>items<span>&#125;</span>"
defaultOpen="<span>&#123;</span>defaultOpen<span>&#125;</span>"
indicator="chevron"
indicatorPosition="end"
/&gt;
<span>&#125;</span>
<span>&#125;</span></code></pre>
</section>
<div class="playground-status" data-playground-status aria-live="polite"></div>
<div class="playground-event-log" data-playground-event-log aria-live="polite"><strong>Event output</strong><span>Interact with the preview to inspect the typed <code>payload</code>.</span></div>
</div>
<form class="playground-controls" data-playground-form>
<header><div><span>Component props</span><strong>17 controls</strong></div><button type="reset"><span class="icon-[lucide--rotate-ccw] size-4" aria-hidden="true"></span>Reset</button></header>
<div class="playground-fields"><label class="playground-field" for="playground-accordion-size"><span><strong>size</strong><small>string</small></span><select id="playground-accordion-size" name="pg_size"><option value="default" selected>default</option><option value="xs">xs</option><option value="sm">sm</option><option value="md">md</option><option value="lg">lg</option><option value="xl">xl</option><option value="icon">icon</option><option value="icon-xs">icon-xs</option><option value="icon-sm">icon-sm</option><option value="icon-lg">icon-lg</option></select></label><label class="playground-field" for="playground-accordion-color"><span><strong>color</strong><small>string</small></span><select id="playground-accordion-color" name="pg_color"><option value="primary" selected>primary</option><option value="secondary">secondary</option><option value="success">success</option><option value="warning">warning</option><option value="danger">danger</option><option value="info">info</option></select></label><label class="playground-field" for="playground-accordion-variant"><span><strong>variant</strong><small>string</small></span><input id="playground-accordion-variant" name="pg_variant" type="text" value="default" /></label><label class="playground-field" for="playground-accordion-class"><span><strong>class</strong><small>string</small></span><input id="playground-accordion-class" name="pg_class" type="text" value="showcase-instance showcase-instance--1" /></label><label class="playground-field" for="playground-accordion-id"><span><strong>id</strong><small>string</small></span><input id="playground-accordion-id" name="pg_id" type="text" value="accordion" /></label><label class="playground-field" for="playground-accordion-items"><span><strong>items</strong><small>unknown[]</small></span><textarea id="playground-accordion-items" name="pg_items" rows="5" spellcheck="false" data-playground-json>[
&#123;
"value": "workspace",
"label": "How do I create a workspace?",
"content": "Choose Create workspace, add a name, and invite your team. You can update the details any time in Settings."
&#125;,
&#123;
"value": "billing",
"label": "Can I change my plan later?",
"content": "Yes. Open Billing to compare plans and choose the one that suits your team."
&#125;,
&#123;
"value": "security",
"label": "How is my account protected?",
"content": "Enable two-step verification and add a recovery method to keep your account secure."
&#125;
]</textarea><em data-playground-error></em></label><label class="playground-field" for="playground-accordion-defaultOpen"><span><strong>default Open</strong><small>unknown[]</small></span><textarea id="playground-accordion-defaultOpen" name="pg_defaultOpen" rows="5" spellcheck="false" data-playground-json>[
"workspace"
]</textarea><em data-playground-error></em></label><label class="playground-toggle" for="playground-accordion-multiple"><span><strong>multiple</strong><small>boolean</small></span><input id="playground-accordion-multiple" name="pg_multiple" type="checkbox" value="true" data-playground-boolean /><i aria-hidden="true"></i></label><label class="playground-toggle" for="playground-accordion-alwaysOpen"><span><strong>always Open</strong><small>boolean</small></span><input id="playground-accordion-alwaysOpen" name="pg_alwaysOpen" type="checkbox" value="true" data-playground-boolean /><i aria-hidden="true"></i></label><label class="playground-toggle" for="playground-accordion-disabled"><span><strong>disabled</strong><small>boolean</small></span><input id="playground-accordion-disabled" name="pg_disabled" type="checkbox" value="true" data-playground-boolean /><i aria-hidden="true"></i></label><label class="playground-field" for="playground-accordion-indicator"><span><strong>indicator</strong><small>string</small></span><input id="playground-accordion-indicator" name="pg_indicator" type="text" value="chevron" /></label><label class="playground-field" for="playground-accordion-indicatorPosition"><span><strong>indicator Position</strong><small>string</small></span><input id="playground-accordion-indicatorPosition" name="pg_indicatorPosition" type="text" value="end" /></label><label class="playground-toggle" for="playground-accordion-showIndicator"><span><strong>show Indicator</strong><small>boolean</small></span><input id="playground-accordion-showIndicator" name="pg_showIndicator" type="checkbox" value="true" checked data-playground-boolean /><i aria-hidden="true"></i></label><label class="playground-toggle" for="playground-accordion-bordered"><span><strong>bordered</strong><small>boolean</small></span><input id="playground-accordion-bordered" name="pg_bordered" type="checkbox" value="true" data-playground-boolean /><i aria-hidden="true"></i></label><label class="playground-toggle" for="playground-accordion-separated"><span><strong>separated</strong><small>boolean</small></span><input id="playground-accordion-separated" name="pg_separated" type="checkbox" value="true" data-playground-boolean /><i aria-hidden="true"></i></label><label class="playground-toggle" for="playground-accordion-flush"><span><strong>flush</strong><small>boolean</small></span><input id="playground-accordion-flush" name="pg_flush" type="checkbox" value="true" data-playground-boolean /><i aria-hidden="true"></i></label><label class="playground-toggle" for="playground-accordion-contentItalic"><span><strong>content Italic</strong><small>boolean</small></span><input id="playground-accordion-contentItalic" name="pg_contentItalic" type="checkbox" value="true" data-playground-boolean /><i aria-hidden="true"></i></label></div>
</form>
</div>
</section>
<div class="detail-layout">
<main class="detail-content">
<section class="detail-section"><div class="detail-section-heading"><span>Live examples</span><h2>Designed for real product surfaces</h2><p>Compare configurations and resize the browser to check responsive behavior.</p></div><div class="demo-list">
<article class="demo-case">
<header class="demo-case-header">
<div><span class="demo-case-eyebrow">Recommended</span><h2>Plain disclosure rows</h2><p>Unframed questions with trailing chevrons and aligned answers.</p></div>
<span class="demo-case-number">01</span>
</header>
<div class="demo-workbench">
<div id="accordion-demo-1" class="demo-canvas demo-canvas--1">
<div class="demo-browser-chrome"><span></span><span></span><span></span><small>Live preview</small></div>
<div class="demo-render"><Accordion size="default" variant="default" class="showcase-instance showcase-instance--1" items='[{"value":"workspace","label":"How do I create a workspace?","content":"Choose Create workspace, add a name, and invite your team. You can update the details any time in Settings."},{"value":"billing","label":"Can I change my plan later?","content":"Yes. Open Billing to compare plans and choose the one that suits your team."},{"value":"security","label":"How is my account protected?","content":"Enable two-step verification and add a recovery method to keep your account secure."}]' defaultOpen='["workspace"]' multiple="false" alwaysOpen="false" disabled="false" indicator="chevron" indicatorPosition="end" showIndicator="true" bordered="false" separated="false" flush="false" contentItalic="false" /></div>
</div>
<section class="demo-code" aria-label="Plain disclosure rows usage">
<header><span><span class="icon-[lucide--code-2] size-4" aria-hidden="true"></span>Component usage</span><small>.wrn</small></header>
<pre><code>page AccordionExample <span>&#123;</span>
state items = [
<span>&#123;</span>
"value": "workspace",
"label": "How do I create a workspace?",
"content": "Choose Create workspace, add a name, and invite your team. You can update the details any time in Settings."
<span>&#125;</span>,
<span>&#123;</span>
"value": "billing",
"label": "Can I change my plan later?",
"content": "Yes. Open Billing to compare plans and choose the one that suits your team."
<span>&#125;</span>,
<span>&#123;</span>
"value": "security",
"label": "How is my account protected?",
"content": "Enable two-step verification and add a recovery method to keep your account secure."
<span>&#125;</span>
]
state defaultOpen = [
"workspace"
]
view <span>&#123;</span>
&lt;Accordion
items="<span>&#123;</span>items<span>&#125;</span>"
defaultOpen="<span>&#123;</span>defaultOpen<span>&#125;</span>"
indicator="chevron"
indicatorPosition="end"
/&gt;
<span>&#125;</span>
<span>&#125;</span></code></pre>
</section>
</div>
</article>
<article class="demo-case">
<header class="demo-case-header">
<div><span class="demo-case-eyebrow">Compact</span><h2>Bordered group</h2><p>One shared border with leading indicators.</p></div>
<span class="demo-case-number">02</span>
</header>
<div class="demo-workbench">
<div id="accordion-demo-2" class="demo-canvas demo-canvas--2">
<div class="demo-browser-chrome"><span></span><span></span><span></span><small>Live preview</small></div>
<div class="demo-render"><Accordion size="sm" variant="secondary" class="showcase-instance showcase-instance--2" items='[{"value":"workspace","label":"How do I create a workspace?","content":"Choose Create workspace, add a name, and invite your team. You can update the details any time in Settings."},{"value":"billing","label":"Can I change my plan later?","content":"Yes. Open Billing to compare plans and choose the one that suits your team."},{"value":"security","label":"How is my account protected?","content":"Enable two-step verification and add a recovery method to keep your account secure."}]' defaultOpen='["workspace"]' multiple="false" alwaysOpen="false" disabled="false" indicator="plus" indicatorPosition="start" showIndicator="true" bordered="true" separated="false" flush="false" contentItalic="false" /></div>
</div>
<section class="demo-code" aria-label="Bordered group usage">
<header><span><span class="icon-[lucide--code-2] size-4" aria-hidden="true"></span>Component usage</span><small>.wrn</small></header>
<pre><code>page AccordionExample <span>&#123;</span>
state items = [
<span>&#123;</span>
"value": "workspace",
"label": "How do I create a workspace?",
"content": "Choose Create workspace, add a name, and invite your team. You can update the details any time in Settings."
<span>&#125;</span>,
<span>&#123;</span>
"value": "billing",
"label": "Can I change my plan later?",
"content": "Yes. Open Billing to compare plans and choose the one that suits your team."
<span>&#125;</span>,
<span>&#123;</span>
"value": "security",
"label": "How is my account protected?",
"content": "Enable two-step verification and add a recovery method to keep your account secure."
<span>&#125;</span>
]
state defaultOpen = [
"workspace"
]
view <span>&#123;</span>
&lt;Accordion
size="sm"
variant="secondary"
items="<span>&#123;</span>items<span>&#125;</span>"
defaultOpen="<span>&#123;</span>defaultOpen<span>&#125;</span>"
bordered="true"
/&gt;
<span>&#125;</span>
<span>&#125;</span></code></pre>
</section>
</div>
</article>
<article class="demo-case">
<header class="demo-case-header">
<div><span class="demo-case-eyebrow">Advanced</span><h2>Separate panels</h2><p>Individually framed rows; multiple answers can stay open.</p></div>
<span class="demo-case-number">03</span>
</header>
<div class="demo-workbench">
<div id="accordion-demo-3" class="demo-canvas demo-canvas--3">
<div class="demo-browser-chrome"><span></span><span></span><span></span><small>Live preview</small></div>
<div class="demo-render"><Accordion size="lg" variant="success" class="showcase-instance showcase-instance--3" items='[{"value":"workspace","label":"How do I create a workspace?","content":"Choose Create workspace, add a name, and invite your team. You can update the details any time in Settings."},{"value":"billing","label":"Can I change my plan later?","content":"Yes. Open Billing to compare plans and choose the one that suits your team."},{"value":"security","label":"How is my account protected?","content":"Enable two-step verification and add a recovery method to keep your account secure."}]' defaultOpen='["workspace"]' multiple="true" alwaysOpen="false" disabled="false" indicator="chevron" indicatorPosition="end" showIndicator="true" bordered="true" separated="true" flush="false" contentItalic="false" /></div>
</div>
<section class="demo-code" aria-label="Separate panels usage">
<header><span><span class="icon-[lucide--code-2] size-4" aria-hidden="true"></span>Component usage</span><small>.wrn</small></header>
<pre><code>page AccordionExample <span>&#123;</span>
state items = [
<span>&#123;</span>
"value": "workspace",
"label": "How do I create a workspace?",
"content": "Choose Create workspace, add a name, and invite your team. You can update the details any time in Settings."
<span>&#125;</span>,
<span>&#123;</span>
"value": "billing",
"label": "Can I change my plan later?",
"content": "Yes. Open Billing to compare plans and choose the one that suits your team."
<span>&#125;</span>,
<span>&#123;</span>
"value": "security",
"label": "How is my account protected?",
"content": "Enable two-step verification and add a recovery method to keep your account secure."
<span>&#125;</span>
]
state defaultOpen = [
"workspace"
]
view <span>&#123;</span>
&lt;Accordion
size="lg"
variant="success"
items="<span>&#123;</span>items<span>&#125;</span>"
defaultOpen="<span>&#123;</span>defaultOpen<span>&#125;</span>"
multiple="true"
indicator="chevron"
indicatorPosition="end"
bordered="true"
separated="true"
/&gt;
<span>&#125;</span>
<span>&#125;</span></code></pre>
</section>
</div>
</article></div></section>
<section id="events" class="detail-section"><div class="detail-section-heading"><span>Component outputs</span><h2>Receive every typed component output</h2><p>Use declarative output handlers in <code>.wrn</code> files or register a direct output handler from JavaScript. The canonical API exposes <code>payload</code> and does not require <code>event.detail</code>.</p></div><div class="detail-events-grid"><div class="detail-events-list"><div><code>@change</code><span>Fires when the component's committed value or selection changes.</span></div><div><code>@open</code><span>Fires after the component opens.</span></div><div><code>@close</code><span>Fires after the component closes.</span></div></div><div class="detail-event-examples"><section class="demo-code"><header><span><span class="icon-[lucide--braces] size-4" aria-hidden="true"></span>Declarative handlers</span><small>.wrn</small></header><pre><code>&lt;Accordion
@change='console.log(payload)'
@open='console.log(payload)'
@close='console.log(payload)'
/&gt;</code></pre></section><section class="demo-code"><header><span><span class="icon-[lucide--radio] size-4" aria-hidden="true"></span>Direct output handlers</span><small>.js</small></header><pre><code>import <span>&#123;</span> registerOutputHandler <span>&#125;</span> from "@wrnexus/csr/outputs"
const component = document.querySelector("[data-ui-component=\"Accordion\"], [data-component=\"Accordion\"]")
if (component) registerOutputHandler(component, "change", (payload) =&gt; <span>&#123;</span>
console.log("change", payload)
<span>&#125;</span>)
if (component) registerOutputHandler(component, "open", (payload) =&gt; <span>&#123;</span>
console.log("open", payload)
<span>&#125;</span>)
if (component) registerOutputHandler(component, "close", (payload) =&gt; <span>&#123;</span>
console.log("close", payload)
<span>&#125;</span>)</code></pre></section></div></div></section>
<section id="api" class="detail-section"><div class="detail-section-heading"><span>Component API</span><h2>Props and configuration</h2><p>All content and behavior shown above is supplied through these props and slots.</p></div><div class="docs-table-wrap"><table class="docs-table"><thead><tr><th>Prop</th><th>Type</th><th>Default</th><th>Required</th></tr></thead><tbody><tr><td><code>size</code></td><td>string</td><td><code>"default"</code></td><td>No</td></tr><tr><td><code>color</code></td><td>string</td><td><code>"primary"</code></td><td>No</td></tr><tr><td><code>variant</code></td><td>string</td><td><code>"default"</code></td><td>No</td></tr><tr><td><code>class</code></td><td>string</td><td><code>""</code></td><td>No</td></tr><tr><td><code>id</code></td><td>string</td><td><code>"accordion"</code></td><td>No</td></tr><tr><td><code>items</code></td><td>unknown[]</td><td><code>[]</code></td><td>No</td></tr><tr><td><code>defaultOpen</code></td><td>unknown[]</td><td><code>[]</code></td><td>No</td></tr><tr><td><code>multiple</code></td><td>boolean</td><td><code>false</code></td><td>No</td></tr><tr><td><code>alwaysOpen</code></td><td>boolean</td><td><code>false</code></td><td>No</td></tr><tr><td><code>disabled</code></td><td>boolean</td><td><code>false</code></td><td>No</td></tr><tr><td><code>indicator</code></td><td>string</td><td><code>"plus"</code></td><td>No</td></tr><tr><td><code>indicatorPosition</code></td><td>string</td><td><code>"start"</code></td><td>No</td></tr><tr><td><code>showIndicator</code></td><td>boolean</td><td><code>true</code></td><td>No</td></tr><tr><td><code>bordered</code></td><td>boolean</td><td><code>false</code></td><td>No</td></tr><tr><td><code>separated</code></td><td>boolean</td><td><code>false</code></td><td>No</td></tr><tr><td><code>flush</code></td><td>boolean</td><td><code>false</code></td><td>No</td></tr><tr><td><code>contentItalic</code></td><td>boolean</td><td><code>false</code></td><td>No</td></tr></tbody></table></div></section>
</main>
<aside class="detail-aside">
<div class="detail-toc"><strong>On this page</strong><a href="#playground">Playground</a><a href="#accordion-demo-1">Plain disclosure rows</a><a href="#accordion-demo-2">Bordered group</a><a href="#accordion-demo-3">Separate panels</a><a href="#events">Outputs</a><a href="#api">Props API</a></div>
</aside>
</div>
<nav class="detail-pagination">
<span></span>
<a href="/components/alert"><small>Next</small><strong>Alert →</strong></a>
</nav>
}
}