-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtabs.tsx
More file actions
47 lines (46 loc) · 1.47 KB
/
tabs.tsx
File metadata and controls
47 lines (46 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { ComponentRegistry } from '@object-ui/core';
import type { TabsSchema } from '@object-ui/types';
import { renderChildren } from '../../lib/utils';
import {
Tabs,
TabsList,
TabsTrigger,
TabsContent
} from '@/ui';
ComponentRegistry.register('tabs',
({ schema, className, ...props }: { schema: TabsSchema; className?: string; [key: string]: any }) => (
<Tabs defaultValue={schema.defaultValue} className={className} {...props}>
<TabsList>
{schema.items?.map((item) => (
<TabsTrigger key={item.value} value={item.value}>{item.label}</TabsTrigger>
))}
</TabsList>
{schema.items?.map((item) => (
<TabsContent key={item.value} value={item.value}>
{renderChildren((item as any).body)}
</TabsContent>
))}
</Tabs>
),
{
label: 'Tabs',
inputs: [
{ name: 'defaultValue', type: 'string', label: 'Default Value', required: true },
{ name: 'className', type: 'string', label: 'CSS Class' },
{
name: 'items',
type: 'array',
label: 'Items'
}
],
defaultProps: {
defaultValue: 'tab1',
items: [
{ label: 'Tab 1', value: 'tab1', body: [{ type: 'text', content: 'Content for Tab 1' }] },
{ label: 'Tab 2', value: 'tab2', body: [{ type: 'text', content: 'Content for Tab 2' }] },
{ label: 'Tab 3', value: 'tab3', body: [{ type: 'text', content: 'Content for Tab 3' }] }
],
className: 'w-full'
}
}
);