Skip to content

Commit 91cb8e0

Browse files
feat: add Divider rootProps
1 parent 5af33a4 commit 91cb8e0

5 files changed

Lines changed: 36 additions & 24 deletions

File tree

packages/@primereact/headless/src/divider/useDivider.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,19 @@ import { defaultProps } from './useDivider.props';
33

44
export const useDivider = withHeadless({
55
name: 'useDivider',
6-
defaultProps
6+
defaultProps,
7+
setup({ props }) {
8+
// prop getters
9+
const rootProps = {
10+
'data-scope': 'divider',
11+
'data-part': 'root',
12+
'aria-orientation': props.orientation,
13+
'data-orientation': props.orientation,
14+
'data-align': props.align
15+
};
16+
17+
return {
18+
rootProps
19+
};
20+
}
721
});

packages/@primereact/types/src/shared/divider/DividerRoot.types.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,7 @@ export interface DividerRootPassThrough {
3434
/**
3535
* Defines valid properties in Divider component.
3636
*/
37-
export interface DividerRootProps extends BaseComponentProps<DividerRootInstance, useDividerProps, DividerRootPassThrough> {
38-
/**
39-
* Alignment of the content.
40-
*/
41-
align?: 'left' | 'center' | 'right' | 'top' | 'center' | 'bottom' | undefined;
42-
/**
43-
* Specifies the orientation, valid values are 'horizontal' and 'vertical'.
44-
* @default horizontal
45-
*/
46-
orientation?: 'horizontal' | 'vertical' | undefined;
47-
/**
48-
* Border style type.
49-
* @default solid
50-
*/
51-
type?: 'solid' | 'dashed' | 'dotted' | undefined;
52-
}
37+
export interface DividerRootProps extends BaseComponentProps<DividerRootInstance, useDividerProps, DividerRootPassThrough> {}
5338

5439
/**
5540
* Defines valid state in Divider component.

packages/@primereact/types/src/shared/divider/useDivider.types.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,22 @@ import type { HeadlessInstance } from '@primereact/types/core';
1313
/**
1414
* Defines valid properties in useDivider.
1515
*/
16-
export interface useDividerProps {}
16+
export interface useDividerProps {
17+
/**
18+
* Alignment of the content.
19+
*/
20+
align?: 'left' | 'center' | 'right' | 'top' | 'center' | 'bottom' | undefined;
21+
/**
22+
* Specifies the orientation, valid values are 'horizontal' and 'vertical'.
23+
* @default horizontal
24+
*/
25+
orientation?: 'horizontal' | 'vertical' | undefined;
26+
/**
27+
* Border style type.
28+
* @default solid
29+
*/
30+
type?: 'solid' | 'dashed' | 'dotted' | undefined;
31+
}
1732

1833
/**
1934
* Defines valid state in useDivider.

packages/primereact/src/divider/root/DividerRoot.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@ export const DividerRoot = withComponent({
1515
return divider;
1616
},
1717
render(instance) {
18-
const { id, props, ptmi, cx, sx } = instance;
18+
const { id, props, ptmi, cx, sx, rootProps: headlessRootProps } = instance;
1919

2020
const rootProps = mergeProps(
21+
headlessRootProps,
2122
{
2223
id,
2324
className: cx('root'),
2425
style: sx('root'),
25-
role: 'separator',
26-
'aria-orientation': props.orientation,
27-
'data-orientation': props.orientation,
28-
'data-align': props.align
26+
role: 'separator'
2927
},
3028
ptmi('root')
3129
);

packages/primereact/src/inplace/root/InplaceRoot.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const InplaceRoot = withComponent({
1515
return inplace;
1616
},
1717
render(instance) {
18-
const { id, ptmi, cx, rootProps: headlessRootProps } = instance;
18+
const { id, props, ptmi, cx, rootProps: headlessRootProps } = instance;
1919

2020
const rootProps = mergeProps(
2121
headlessRootProps,

0 commit comments

Comments
 (0)