1 | import { createComponent } from "reakit-system/createComponent";
|
2 | import { createHook } from "reakit-system/createHook";
|
3 | import { RoleOptions, RoleHTMLProps, useRole } from "../Role/Role";
|
4 | import { SEPARATOR_KEYS } from "./__keys";
|
5 |
|
6 | export type SeparatorOptions = RoleOptions & {
|
7 | |
8 |
|
9 |
|
10 | orientation?: "horizontal" | "vertical";
|
11 | };
|
12 |
|
13 | export type SeparatorHTMLProps = RoleHTMLProps;
|
14 |
|
15 | export type SeparatorProps = SeparatorOptions & SeparatorHTMLProps;
|
16 |
|
17 | export const useSeparator = createHook<SeparatorOptions, SeparatorHTMLProps>({
|
18 | name: "Separator",
|
19 | compose: useRole,
|
20 | keys: SEPARATOR_KEYS,
|
21 |
|
22 | useOptions({ orientation = "horizontal", ...options }) {
|
23 | return { orientation, ...options };
|
24 | },
|
25 |
|
26 | useProps(options, htmlProps) {
|
27 | return {
|
28 | role: "separator",
|
29 | "aria-orientation": options.orientation,
|
30 | ...htmlProps,
|
31 | };
|
32 | },
|
33 | });
|
34 |
|
35 | export const Separator = createComponent({
|
36 | as: "hr",
|
37 | memo: true,
|
38 | useHook: useSeparator,
|
39 | });
|