-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathresizable.tsx
More file actions
53 lines (52 loc) · 1.9 KB
/
resizable.tsx
File metadata and controls
53 lines (52 loc) · 1.9 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
48
49
50
51
52
53
import React from 'react';
import { ComponentRegistry } from '../../registry';
import {
ResizablePanelGroup,
ResizablePanel,
ResizableHandle
} from '@object-ui/ui';
import { renderChildren } from '../../utils';
ComponentRegistry.register('resizable',
({ schema, className, ...props }) => (
<ResizablePanelGroup
direction={schema.direction || 'horizontal'}
className={className}
{...props}
style={{ minHeight: schema.minHeight || '200px' }}
>
{schema.panels?.map((panel: any, index: number) => (
<React.Fragment key={index}>
<ResizablePanel defaultSize={panel.defaultSize} minSize={panel.minSize} maxSize={panel.maxSize}>
{renderChildren(panel.content)}
</ResizablePanel>
{index < schema.panels.length - 1 && <ResizableHandle withHandle={schema.withHandle} />}
</React.Fragment>
))}
</ResizablePanelGroup>
),
{
label: 'Resizable Panel Group',
inputs: [
{ name: 'direction', type: 'enum', enum: ['horizontal', 'vertical'], defaultValue: 'horizontal', label: 'Direction' },
{ name: 'minHeight', type: 'string', label: 'Min Height' },
{ name: 'withHandle', type: 'boolean', label: 'Show Handle Icon', defaultValue: true },
{
name: 'panels',
type: 'array',
label: 'Panels',
description: 'Array of { defaultSize, minSize, maxSize, content }'
},
{ name: 'className', type: 'string', label: 'CSS Class' }
],
defaultProps: {
direction: 'horizontal',
minHeight: '200px',
withHandle: true,
panels: [
{ defaultSize: 50, content: [{ type: 'div', className: 'p-4', body: [{ type: 'text', content: 'Panel 1' }] }] },
{ defaultSize: 50, content: [{ type: 'div', className: 'p-4', body: [{ type: 'text', content: 'Panel 2' }] }] }
],
className: 'rounded-lg border'
}
}
);