You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(components): add slot API to Tabs + Accordion (#1703)
The old Tabs/Accordion APIs took `tabs: Tab[]` / `items: AccordionItem[]`
where each item's `content` was a HTML string. That blocked every
real-world use — tab/accordion content is almost always a component
tree (a calendar grid, a form, a table). Across all four downstream
apps the components saw zero adoption.
Two new components — `<TabPanel label="…">` and `<AccordionItem title="…">`
— act as slot wrappers. Each renders a `data-stx-*` marker the parent
discovers on mount, so:
<Tabs defaultTab="0" variant="pills">
<TabPanel label="Drivers">
<DriversTable :drivers="drivers()" />
</TabPanel>
<TabPanel label="Notifications">
<NotificationsTable />
</TabPanel>
</Tabs>
<Accordion allowMultiple>
<AccordionItem title="Profile">
<ProfileEditor :user="user()" />
</AccordionItem>
<AccordionItem title="Zones">
<ZonesEditor />
</AccordionItem>
</Accordion>
now both work. Tabs walks `[data-stx-tab-panel]` descendants (with a
`closest('[data-stx-tabs]') === root` guard against nested-Tabs
contamination), builds the tab list from each panel's `data-label`,
and toggles `hidden` as the active tab changes. Accordion walks
`[data-stx-accordion-item]` descendants, wires per-item click +
keydown handlers (with a `__stx_wired` idempotency guard for HMR
re-runs), and syncs `aria-expanded` + chevron rotation as openItems
changes.
The legacy `tabs` / `items` prop APIs still work — the components
branch on `hasPropTabs` / `hasPropItems` at template-eval time so
existing visual snapshots stay byte-identical. Both are marked
optional in the TS interfaces.
11 new tests in `test/integration/tabs-accordion-slot.test.ts` cover
the discovery markers, both render paths, nested scoping, allowMultiple
behavior, and aria/chevron sync. Existing component tests still pass
(50 pass, 0 fail in the non-visual suites).
Closes#1703
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments