From 159a1e978409aac8cfeb859bc1435c1f212ec84b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C4=8Curda?= Date: Fri, 3 May 2024 12:45:24 +0200 Subject: [PATCH] BREAKING CHANGE(web-react): Refactor types in Tabs #DS-935 --- packages/web-react/src/components/Tabs/Tabs.tsx | 11 ++--------- .../src/components/Tabs/stories/Tabs.stories.tsx | 5 ++--- packages/web-react/src/types/tabs.ts | 7 +++++++ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/web-react/src/components/Tabs/Tabs.tsx b/packages/web-react/src/components/Tabs/Tabs.tsx index 0259b7efe8..d1081b4e44 100644 --- a/packages/web-react/src/components/Tabs/Tabs.tsx +++ b/packages/web-react/src/components/Tabs/Tabs.tsx @@ -1,13 +1,6 @@ import React from 'react'; -import { ChildrenProps, TabId, TransferProps } from '../../types'; -import { TabsProvider, TabsToggler } from './TabContext'; - -export interface TabsProps extends ChildrenProps, TransferProps { - selectedTab: TabId; - toggle: TabsToggler; - // eslint-disable-next-line react/require-default-props - onSelectionChange?: (tabId: TabId) => void; -} +import { TabsProvider } from './TabContext'; +import { TabsProps } from '../../types'; const Tabs = ({ children, selectedTab, toggle: selectTab, onSelectionChange }: TabsProps): JSX.Element => ( {children} diff --git a/packages/web-react/src/components/Tabs/stories/Tabs.stories.tsx b/packages/web-react/src/components/Tabs/stories/Tabs.stories.tsx index 89d07c48dc..68fc581fbf 100644 --- a/packages/web-react/src/components/Tabs/stories/Tabs.stories.tsx +++ b/packages/web-react/src/components/Tabs/stories/Tabs.stories.tsx @@ -1,10 +1,9 @@ import React, { useCallback, useState } from 'react'; import { Markdown } from '@storybook/blocks'; import type { Meta, StoryObj } from '@storybook/react'; - -import { TabId } from '../../../types'; +import { TabId, TabsProps } from '../../../types'; import ReadMe from '../README.md'; -import { TabContent, TabItem, TabList, TabPane, Tabs, TabsProps } from '..'; +import { TabContent, TabItem, TabList, TabPane, Tabs } from '..'; const meta: Meta = { title: 'Components/Tabs', diff --git a/packages/web-react/src/types/tabs.ts b/packages/web-react/src/types/tabs.ts index 9bca2dfc7b..ae2e0918a5 100644 --- a/packages/web-react/src/types/tabs.ts +++ b/packages/web-react/src/types/tabs.ts @@ -1,5 +1,6 @@ import { ElementType } from 'react'; import { ChildrenProps, SpiritPolymorphicElementPropsWithRef, StyleProps, TransferProps } from './shared'; +import { TabsToggler } from '../components'; export type TabId = string | number; @@ -12,6 +13,12 @@ export interface SpiritTabsProps { forTab?: TabId; } +export interface TabsProps extends ChildrenProps, TransferProps { + selectedTab: TabId; + toggle: TabsToggler; + onSelectionChange?: (tabId: TabId) => void; +} + export type TabLinkItemProps = StyleProps & React.HTMLProps; export interface TabLinkBaseProps extends ChildrenProps, StyleProps, TransferProps {