Skip to content

Commit b4f657d

Browse files
authored
refactor: deprecate tabs shorthand API (#995)
1 parent 2f7bcd0 commit b4f657d

File tree

5 files changed

+9
-40
lines changed

5 files changed

+9
-40
lines changed

.changeset/dirty-foxes-glow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@qwik-ui/headless': minor
3+
---
4+
5+
We deprecated the Tabs shorthand API as it was less composable and more maintenance. We might add that API as copy/paste in the future.

apps/website/src/routes/docs/headless/tabs/index.mdx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,6 @@ const CustomTabs = (props: PropsOf<typeof Tabs.Root>) => (
215215
description:
216216
'A signal that binds the selected tabId. This is a more efficient version of `selectedTabId` + `onSelectedTabIdChange$`',
217217
},
218-
{
219-
name: 'tabClass',
220-
type: 'string',
221-
description: 'The class name to apply to tabs',
222-
},
223-
{
224-
name: 'panelClass',
225-
type: 'string',
226-
description: 'The class name to apply to panels',
227-
},
228218
]}
229219
/>
230220

@@ -260,11 +250,6 @@ const CustomTabs = (props: PropsOf<typeof Tabs.Root>) => (
260250

261251
<APITable
262252
propDescriptors={[
263-
{
264-
name: 'label',
265-
type: 'element',
266-
description: 'Shorthand for `<Tab>{label}</Tab>`',
267-
},
268253
{
269254
name: 'selected',
270255
type: 'boolean',

packages/kit-headless/src/components/tabs/tab-panel.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { tabsContextId } from './tabs-context-id';
55

66
export type TabPanelProps = {
77
/** Optional tab contents. */
8+
/** @deprecated This prop was used for the shorthand API that we decided to no longer support as part of the headless kit */
89
label?: PropsOf<'div'>['children'];
910
selected?: boolean;
1011
disabled?: boolean;

packages/kit-headless/src/components/tabs/tabs.test.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -480,21 +480,6 @@ test.describe('Disabled tabs', () => {
480480
});
481481
});
482482

483-
test.skip('Shorthand API', () => {
484-
test(`GIVEN 3 tabs written using shorthand
485-
WHEN clicking the middle one
486-
THEN render the middle panel`, async ({ page }) => {
487-
const { driver: d } = await setup(page, 'shorthand-api-tabs');
488-
489-
await expect(d.getAllTabs()).toHaveCount(3);
490-
491-
await expect(d.getTabPanel()).toContainText('Panel 3');
492-
await d.getTab(1).click();
493-
await expect(d.getTabPanel()).toContainText('Panel 2');
494-
await expect(d.getTabList()).toBeVisible();
495-
});
496-
});
497-
498483
test.describe.skip('User-defined reusable TabList/Tab/TabPanel components', () => {
499484
test(`GIVEN a user-defined TabList to Tabs
500485
WHEN clicking the middle Tab

packages/kit-headless/src/components/tabs/tabs.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ import { HTabList as InternalTabList } from './tabs-list';
3535
* NOTE: scrolling support? or multiple lines? (probably not for headless but for tailwind / material )
3636
* Add ability to close tabs with an ❌ icon (and keyboard support)
3737
38-
* TO DISCUSS
39-
- name of the components, e.g. Tabs, Tabs.Trigger, Tabs.Panel
40-
- selectedClassname => selectedClass
41-
- do we keep all current props (tabId callbacks?)
42-
- shorthand for tab: "label" or "tab"?
43-
- the TODOs
4438
*
4539
*/
4640

@@ -55,7 +49,9 @@ export type TabsProps = PropsOf<'div'> & {
5549
onSelectedTabIdChange$?: (tabId: string) => void;
5650
'bind:selectedIndex'?: Signal<number | undefined>;
5751
'bind:selectedTabId'?: Signal<string | undefined>;
52+
/** @deprecated was for the shorthand API that we decided to no longer support as part of the headless kit */
5853
tabClass?: PropsOf<'div'>['class'];
54+
/** @deprecated was for the shorthand API that we decided to no longer support as part of the headless kit */
5955
panelClass?: PropsOf<'div'>['class'];
6056

6157
tabListComponent?: typeof InternalTabList;
@@ -76,8 +72,6 @@ export type TabInfo = {
7672
export const HTabs: FunctionComponent<TabsProps> = (props) => {
7773
const {
7874
children,
79-
tabClass,
80-
panelClass,
8175
tabListComponent: UserTabList,
8276
tabComponent: UserTab,
8377
tabPanelComponent: UserTabPanel,
@@ -134,6 +128,7 @@ export const HTabs: FunctionComponent<TabsProps> = (props) => {
134128
(matchedTabComponent?.props as TabProps).tabId || matchedTabComponent?.key;
135129
const tabId: string = tabIdFromTabMaybe || child.key || `${panelIndex}`;
136130

131+
// This will be removed on v1 release
137132
if (label) {
138133
tabComponents.push((<Tab>{label}</Tab>) as JSXNode<typeof Tab>);
139134
}
@@ -146,7 +141,6 @@ export const HTabs: FunctionComponent<TabsProps> = (props) => {
146141
child.key = tabId;
147142
// Add props but don't replace the object
148143
child.props._tabId = tabId;
149-
child.props._extraClass = panelClass;
150144

151145
panelComponents.push(child);
152146
tabInfoList.push({
@@ -175,7 +169,6 @@ export const HTabs: FunctionComponent<TabsProps> = (props) => {
175169
const tabId = tabInfoList[index]?.tabId;
176170
tab.key = tabId;
177171
tab.props.tabId = tabId;
178-
tab.props._extraClass = tabClass;
179172
if (
180173
tabInfoList[index].panelProps.disabled !== undefined &&
181174
tab.props.disabled === undefined

0 commit comments

Comments
 (0)