Repository navigation
Expand file tree
/
Copy pathseparator.tsx
More file actions
58 lines (54 loc) · 1.71 KB
/
Copy pathseparator.tsx
File metadata and controls
58 lines (54 loc) · 1.71 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
54
55
56
57
58
/**
* ObjectUI
* Copyright (c) 2024-present ObjectStack Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { ComponentRegistry } from '@object-ui/core';
import type { SeparatorSchema } from '@object-ui/types';
import { Separator } from '../../ui';
import { forwardRef } from 'react';
import type { RendererHostProps } from '../../lib/renderer-host-props';
// Index signature on the parameter annotation, not on the `forwardRef` type
// argument — mechanism note on `action:bar` (objectui#4422), pinned by
// `__tests__/forwardref-props-annotation.guard.test.ts`.
const SeparatorRenderer = forwardRef<HTMLDivElement, { schema: SeparatorSchema; className?: string }>(
({ schema, className, ...props }: { schema: SeparatorSchema; className?: string; [key: string]: unknown } & RendererHostProps, ref) => {
// Extract designer-related props
const {
'data-obj-id': dataObjId,
'data-obj-type': dataObjType,
style,
...separatorProps
} = props;
return (
<Separator
ref={ref}
orientation={schema.orientation}
className={className}
{...separatorProps}
// Apply designer props
{...{ 'data-obj-id': dataObjId, 'data-obj-type': dataObjType, style }}
/>
);
}
);
ComponentRegistry.register('separator',
SeparatorRenderer,
{
namespace: 'ui',
label: 'Separator',
inputs: [
{
name: 'orientation',
type: 'enum',
enum: ['horizontal', 'vertical'] },
{ name: 'className', type: 'string' }
],
defaultProps: {
orientation: 'horizontal',
className: 'my-2 sm:my-4'
}
}
);