diff --git a/apps/web/src/app/features/demo/demo-feature-tab-routes.tsx b/apps/web/src/app/features/demo/demo-feature-tab-routes.tsx index 8b2240f..5f6de49 100644 --- a/apps/web/src/app/features/demo/demo-feature-tab-routes.tsx +++ b/apps/web/src/app/features/demo/demo-feature-tab-routes.tsx @@ -5,30 +5,30 @@ export function DemoFeatureTabRoutes() { return ( Overview ), }, { - value: 'content', + path: 'content', label: 'Content', - component: ( + element: ( Content ), }, { - value: 'settings', + path: 'settings', label: 'Settings', - component: ( + element: ( Settings diff --git a/packages/core/src/lib/ui-tab-routes/ui-tab-routes.tsx b/packages/core/src/lib/ui-tab-routes/ui-tab-routes.tsx index 7b7336f..0566bff 100644 --- a/packages/core/src/lib/ui-tab-routes/ui-tab-routes.tsx +++ b/packages/core/src/lib/ui-tab-routes/ui-tab-routes.tsx @@ -3,40 +3,40 @@ import { ReactElement, ReactNode } from 'react' import { Navigate, Route, Routes, useLocation, useNavigate } from 'react-router-dom' export interface UiTabRoute { - component: ReactNode + element: ReactNode label: ReactElement | string - value: string + path: string } export function UiTabRoutes({ grow = false, tabs, - baseUrl, + basePath, ...props }: Omit & { children?: ReactNode - baseUrl?: string + basePath?: string grow?: boolean tabs: UiTabRoute[] }) { const navigate = useNavigate() const location = useLocation() - // Set the active tab based on matching the location pathname with the tab value - const activeTab = tabs.find((tab) => location.pathname.includes(`/${tab.value}`))?.value + // Set the active tab based on matching the location pathname with the tab path + const activeTab = tabs.find((tab) => location.pathname.includes(`/${tab.path}`))?.path // Set default redirect route to the first tab - const redirect = tabs.length && tabs[0].value !== '' ? tabs[0].value : undefined + const redirect = tabs.length && tabs[0].path !== '' ? tabs[0].path : undefined return ( navigate(`${baseUrl ? `${baseUrl}/${value}` : value}`)} + onChange={(value) => navigate(`${basePath ? `${basePath}/${value}` : value}`)} mb="md" {...props} > {tabs.map((tab) => ( - + {tab.label} ))} @@ -45,7 +45,7 @@ export function UiTabRoutes({ {redirect ? } /> : null} {tabs.map((tab) => ( - + ))} } /> diff --git a/packages/generators/src/generators/component/files/tab-routes/__prefixFileName__-tab-routes.tsx.template b/packages/generators/src/generators/component/files/tab-routes/__prefixFileName__-tab-routes.tsx.template index f99b764..9e3cc3c 100644 --- a/packages/generators/src/generators/component/files/tab-routes/__prefixFileName__-tab-routes.tsx.template +++ b/packages/generators/src/generators/component/files/tab-routes/__prefixFileName__-tab-routes.tsx.template @@ -3,40 +3,40 @@ import { ReactElement, ReactNode } from 'react' import { Navigate, Route, Routes, useLocation, useNavigate } from 'react-router-dom' export interface <%= prefix.className %>TabRoute { - component: ReactNode + element: ReactNode label: ReactElement | string - value: string + path: string } export function <%= prefix.className %>TabRoutes({ grow = false, tabs, - baseUrl, + basePath, ...props }: Omit & { children?: ReactNode - baseUrl?: string + basePath?: string grow?: boolean tabs: <%= prefix.className %>TabRoute[] }) { const navigate = useNavigate() const location = useLocation() - // Set the active tab based on matching the location pathname with the tab value - const activeTab = tabs.find((tab) => location.pathname.includes(`/${tab.value}`))?.value + // Set the active tab based on matching the location pathname with the tab path + const activeTab = tabs.find((tab) => location.pathname.includes(`/${tab.path}`))?.path // Set default redirect route to the first tab - const redirect = tabs.length && tabs[0].value !== '' ? tabs[0].value : undefined + const redirect = tabs.length && tabs[0].path !== '' ? tabs[0].path : undefined return ( navigate(`${baseUrl ? `${baseUrl}/${value}` : value}`)} + onChange={(value) => navigate(`${basePath ? `${basePath}/${value}` : value}`)} mb="md" {...props} > {tabs.map((tab) => ( - + {tab.label} ))} @@ -45,7 +45,7 @@ export function <%= prefix.className %>TabRoutes({ {redirect ? } /> : null} {tabs.map((tab) => ( - + ))} } /> diff --git a/packages/generators/src/generators/feature/files/demo/demo-feature-tab-routes.tsx.template b/packages/generators/src/generators/feature/files/demo/demo-feature-tab-routes.tsx.template index 869539e..026ed70 100644 --- a/packages/generators/src/generators/feature/files/demo/demo-feature-tab-routes.tsx.template +++ b/packages/generators/src/generators/feature/files/demo/demo-feature-tab-routes.tsx.template @@ -5,30 +5,30 @@ export function DemoFeatureTabRoutes() { return ( <<%= prefix.className %>Card title="Tab Routes"> <<%= prefix.className %>TabRoutes - baseUrl="/demo/tab-routes" + basePath="/demo/tab-routes" tabs={[ { - value: 'overview', + path: 'overview', label: 'Overview', - component: ( + element: ( <<%= prefix.className %>Card title="Overview">OverviewCard> ), }, { - value: 'content', + path: 'content', label: 'Content', - component: ( + element: ( <<%= prefix.className %>Card title="Content">ContentCard> ), }, { - value: 'settings', + path: 'settings', label: 'Settings', - component: ( + element: ( <<%= prefix.className %>Card title="Settings">SettingsCard>