-
-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathnavigation-menu.api.ts
141 lines (132 loc) · 4.21 KB
/
navigation-menu.api.ts
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import type {
NavigationMenuContentPropsWithoutHTML,
NavigationMenuIndicatorPropsWithoutHTML,
NavigationMenuItemPropsWithoutHTML,
NavigationMenuLinkPropsWithoutHTML,
NavigationMenuListPropsWithoutHTML,
NavigationMenuRootPropsWithoutHTML,
NavigationMenuTriggerPropsWithoutHTML,
NavigationMenuViewportPropsWithoutHTML,
} from "bits-ui";
import {
createApiSchema,
createBooleanProp,
createEnumProp,
createFunctionProp,
createNumberProp,
createStringProp,
dirProp,
dismissibleLayerProps,
escapeLayerProps,
forceMountProp,
withChildProps,
} from "./helpers.js";
import { OnStringValueChangeProp, OrientationProp } from "./extended-types/shared/index.js";
import * as C from "$lib/content/constants.js";
export const root = createApiSchema<NavigationMenuRootPropsWithoutHTML>({
title: "Root",
description:
"The root navigation menu component which manages & scopes the state of the navigation menu.",
props: {
value: createStringProp({
description: "The value of the currently active menu.",
bindable: true,
}),
onValueChange: createFunctionProp({
definition: OnStringValueChangeProp,
description: "A callback function called when the active menu value changes.",
}),
dir: dirProp,
skipDelayDuration: createNumberProp({
default: "300",
description:
"How much time a user has to enter another trigger without incurring a delay again.",
}),
delayDuration: createNumberProp({
default: "200",
description:
"The duration from when the mouse enters a trigger until the content opens.",
}),
orientation: createEnumProp({
options: ["horizontal", "vertical"],
default: "horizontal",
description: "The orientation of the menu.",
definition: OrientationProp,
}),
...withChildProps({ elType: "HTMLDivElement" }),
},
});
export const list = createApiSchema<NavigationMenuListPropsWithoutHTML>({
title: "List",
description: "A menu within the menubar.",
props: withChildProps({ elType: "HTMLUListElement" }),
});
export const item = createApiSchema<NavigationMenuItemPropsWithoutHTML>({
title: "Item",
description: "A list item within the navigation menu.",
props: {
value: createStringProp({
description: "The value of the item.",
}),
openOnHover: createBooleanProp({
default: C.TRUE,
description: "Whether or not the content belonging to the item should open on hover.",
}),
...withChildProps({ elType: "HTMLLiElement" }),
},
});
export const trigger = createApiSchema<NavigationMenuTriggerPropsWithoutHTML>({
title: "Trigger",
description: "The button element which toggles the dropdown menu.",
props: {
disabled: createBooleanProp({
default: C.FALSE,
description: "Whether or not the trigger is disabled.",
}),
...withChildProps({ elType: "HTMLButtonElement" }),
},
});
export const content = createApiSchema<NavigationMenuContentPropsWithoutHTML>({
title: "Content",
description: "The content displayed when the dropdown menu is open.",
props: {
...dismissibleLayerProps,
...escapeLayerProps,
forceMount: forceMountProp,
...withChildProps({ elType: "HTMLDivElement" }),
},
});
export const link = createApiSchema<NavigationMenuLinkPropsWithoutHTML>({
title: "Link",
description: "A link within the navigation menu.",
props: {
active: createBooleanProp({
default: C.FALSE,
description: "Whether or not the link is active.",
}),
onSelect: createFunctionProp({
definition: "() => void",
description: "A callback function called when the link is selected.",
}),
...withChildProps({ elType: "HTMLAnchorElement" }),
},
});
export const indicator = createApiSchema<NavigationMenuIndicatorPropsWithoutHTML>({
title: "Indicator",
description:
"The indicator element for the navigation menu, which is used to indicate the current active item.",
props: {
forceMount: forceMountProp,
...withChildProps({ elType: "HTMLSpanElement" }),
},
});
export const viewport = createApiSchema<NavigationMenuViewportPropsWithoutHTML>({
title: "Viewport",
description:
"The viewport element for the navigation menu, which is used to contain the menu items.",
props: {
forceMount: forceMountProp,
...withChildProps({ elType: "HTMLDivElement" }),
},
});
export const navigationMenu = [root, list, item, trigger, content, link, viewport, indicator];