@gridui/site-navigation 1.1.5 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +196 -140
- package/dist/index.js.map +4 -4
- package/dist/site-navigation/desktop-site-navigation.d.ts +10 -0
- package/dist/site-navigation/mobile-site-navigation.d.ts +13 -0
- package/dist/site-navigation/site-navigation-types.d.ts +31 -0
- package/dist/site-navigation/site-navigation.d.ts +3 -19
- package/dist/styles.css +2 -2
- package/docs/catalog.json +1 -1
- package/package.json +10 -10
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
* @namespace Root
|
|
5
5
|
* @description Index
|
|
6
6
|
*/
|
|
7
|
-
export type { SiteNavigationLink } from "./site-navigation/site-navigation";
|
|
8
7
|
export type { SiteNavigationProps } from "./site-navigation/site-navigation";
|
|
9
8
|
export { SiteNavigation } from "./site-navigation/site-navigation";
|
|
9
|
+
export type { SiteNavigationLink } from "./site-navigation/site-navigation-types";
|
package/dist/index.js
CHANGED
|
@@ -3,20 +3,181 @@ import { cn } from "@gridui/style-utils";
|
|
|
3
3
|
import { cva } from "class-variance-authority";
|
|
4
4
|
var navigationActionsStyles = cva(cn(
|
|
5
5
|
"gridui-navigation-actions",
|
|
6
|
-
"gridui-u-ms-auto"
|
|
6
|
+
"gridui-u-site-navigation--ms-auto"
|
|
7
7
|
));
|
|
8
8
|
|
|
9
|
-
// src/site-navigation/site-navigation.tsx
|
|
9
|
+
// src/site-navigation/desktop-site-navigation.tsx
|
|
10
|
+
import { NavigationLinks } from "@gridui/menu";
|
|
11
|
+
import { DesktopNavigation } from "@gridui/responsive-navigation";
|
|
12
|
+
import { cn as cn2 } from "@gridui/style-utils";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { createElement } from "react";
|
|
15
|
+
var DesktopSiteNavigation = (props) => {
|
|
16
|
+
const { label, links, preferences, desktopContent } = props;
|
|
17
|
+
return /* @__PURE__ */ jsxs(DesktopNavigation, { children: [
|
|
18
|
+
/* @__PURE__ */ jsxs(
|
|
19
|
+
NavigationLinks,
|
|
20
|
+
{
|
|
21
|
+
"aria-label": label,
|
|
22
|
+
children: [
|
|
23
|
+
links.map((link) => {
|
|
24
|
+
const { label: linkLabel, current, ...anchorProps } = link;
|
|
25
|
+
return /* @__PURE__ */ createElement(
|
|
26
|
+
"a",
|
|
27
|
+
{
|
|
28
|
+
...anchorProps,
|
|
29
|
+
key: link.href,
|
|
30
|
+
"aria-current": current ? "page" : void 0
|
|
31
|
+
},
|
|
32
|
+
linkLabel
|
|
33
|
+
);
|
|
34
|
+
}),
|
|
35
|
+
desktopContent
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
/* @__PURE__ */ jsx(
|
|
40
|
+
"div",
|
|
41
|
+
{
|
|
42
|
+
className: cn2(navigationActionsStyles()),
|
|
43
|
+
children: preferences
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
] });
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// src/site-navigation/mobile-site-navigation.tsx
|
|
10
50
|
import { Button } from "@gridui/button";
|
|
11
51
|
import { DrawerBody, DrawerCloseButton, DrawerFooter, DrawerHeader, DrawerPanel, DrawerTitle, DrawerTrigger } from "@gridui/drawer";
|
|
12
52
|
import { getNavigationActivation } from "@gridui/interaction";
|
|
13
|
-
import { MenuGroup, MenuItemContent, MenuItemLabel, MenuLabel, MenuLink, MenuSeparator
|
|
14
|
-
import {
|
|
15
|
-
import { cn as cn2 } from "@gridui/style-utils";
|
|
53
|
+
import { MenuGroup, MenuItemContent, MenuItemLabel, MenuLabel, MenuLink, MenuSeparator } from "@gridui/menu";
|
|
54
|
+
import { MobileNavigation, ResponsiveDrawer } from "@gridui/responsive-navigation";
|
|
16
55
|
import { Menu } from "lucide-react";
|
|
17
|
-
import { useId
|
|
18
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
19
|
-
import { createElement } from "react";
|
|
56
|
+
import { useId } from "react";
|
|
57
|
+
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
58
|
+
import { createElement as createElement2 } from "react";
|
|
59
|
+
var MobileSiteNavigation = (props) => {
|
|
60
|
+
const {
|
|
61
|
+
label,
|
|
62
|
+
links,
|
|
63
|
+
menuLabel,
|
|
64
|
+
closeLabel,
|
|
65
|
+
settingsLabel,
|
|
66
|
+
mobilePreferences,
|
|
67
|
+
mobileContent,
|
|
68
|
+
mobileFooter,
|
|
69
|
+
onMobileCloseAutoFocus,
|
|
70
|
+
anchorNavigation,
|
|
71
|
+
closeDrawer
|
|
72
|
+
} = props;
|
|
73
|
+
const id = useId();
|
|
74
|
+
return /* @__PURE__ */ jsx2(MobileNavigation, { children: /* @__PURE__ */ jsxs2(ResponsiveDrawer, { children: [
|
|
75
|
+
/* @__PURE__ */ jsx2(
|
|
76
|
+
DrawerTrigger,
|
|
77
|
+
{
|
|
78
|
+
asChild: true,
|
|
79
|
+
children: /* @__PURE__ */ jsx2(
|
|
80
|
+
Button,
|
|
81
|
+
{
|
|
82
|
+
variant: "quiet",
|
|
83
|
+
size: "standard",
|
|
84
|
+
layout: "icon",
|
|
85
|
+
"aria-label": menuLabel,
|
|
86
|
+
title: menuLabel,
|
|
87
|
+
children: /* @__PURE__ */ jsx2(
|
|
88
|
+
Menu,
|
|
89
|
+
{
|
|
90
|
+
"aria-hidden": "true"
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
),
|
|
97
|
+
/* @__PURE__ */ jsxs2(
|
|
98
|
+
DrawerPanel,
|
|
99
|
+
{
|
|
100
|
+
onCloseAutoFocus: (event) => {
|
|
101
|
+
const preserveAnchor = anchorNavigation.current;
|
|
102
|
+
anchorNavigation.current = false;
|
|
103
|
+
onMobileCloseAutoFocus?.(event);
|
|
104
|
+
if (preserveAnchor) {
|
|
105
|
+
event.preventDefault();
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
children: [
|
|
109
|
+
/* @__PURE__ */ jsxs2(DrawerHeader, { children: [
|
|
110
|
+
/* @__PURE__ */ jsx2(DrawerTitle, { children: menuLabel }),
|
|
111
|
+
/* @__PURE__ */ jsx2(
|
|
112
|
+
DrawerCloseButton,
|
|
113
|
+
{
|
|
114
|
+
"aria-label": closeLabel
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
] }),
|
|
118
|
+
/* @__PURE__ */ jsxs2(DrawerBody, { children: [
|
|
119
|
+
/* @__PURE__ */ jsxs2(
|
|
120
|
+
"nav",
|
|
121
|
+
{
|
|
122
|
+
"aria-label": label,
|
|
123
|
+
children: [
|
|
124
|
+
links.map((link) => {
|
|
125
|
+
const { label: linkLabel, current, onClick, ...anchorProps } = link;
|
|
126
|
+
return /* @__PURE__ */ createElement2(
|
|
127
|
+
MenuLink,
|
|
128
|
+
{
|
|
129
|
+
...anchorProps,
|
|
130
|
+
key: link.href,
|
|
131
|
+
"aria-current": current ? "page" : void 0,
|
|
132
|
+
onClick: (event) => {
|
|
133
|
+
onClick?.(event);
|
|
134
|
+
const activation = getNavigationActivation(event);
|
|
135
|
+
if (!activation) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
anchorNavigation.current = activation === "anchor";
|
|
139
|
+
closeDrawer();
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
/* @__PURE__ */ jsx2(MenuItemContent, { children: /* @__PURE__ */ jsx2(MenuItemLabel, { children: linkLabel }) })
|
|
143
|
+
);
|
|
144
|
+
}),
|
|
145
|
+
mobileContent && /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
146
|
+
/* @__PURE__ */ jsx2(MenuSeparator, {}),
|
|
147
|
+
mobileContent
|
|
148
|
+
] })
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
),
|
|
152
|
+
/* @__PURE__ */ jsx2(MenuSeparator, {}),
|
|
153
|
+
/* @__PURE__ */ jsxs2(
|
|
154
|
+
MenuGroup,
|
|
155
|
+
{
|
|
156
|
+
"aria-labelledby": `${id}-settings`,
|
|
157
|
+
children: [
|
|
158
|
+
/* @__PURE__ */ jsx2(
|
|
159
|
+
MenuLabel,
|
|
160
|
+
{
|
|
161
|
+
id: `${id}-settings`,
|
|
162
|
+
children: settingsLabel
|
|
163
|
+
}
|
|
164
|
+
),
|
|
165
|
+
mobilePreferences
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
)
|
|
169
|
+
] }),
|
|
170
|
+
mobileFooter && /* @__PURE__ */ jsx2(DrawerFooter, { children: mobileFooter })
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
] }) });
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// src/site-navigation/site-navigation.tsx
|
|
178
|
+
import { ResponsiveNavigation } from "@gridui/responsive-navigation";
|
|
179
|
+
import { useRef, useState } from "react";
|
|
180
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
20
181
|
var SiteNavigation = (props) => {
|
|
21
182
|
const {
|
|
22
183
|
className,
|
|
@@ -32,13 +193,12 @@ var SiteNavigation = (props) => {
|
|
|
32
193
|
mobileFooter,
|
|
33
194
|
onMobileCloseAutoFocus
|
|
34
195
|
} = props;
|
|
35
|
-
const id = useId();
|
|
36
196
|
const anchorNavigation = useRef(false);
|
|
37
197
|
const [
|
|
38
198
|
mobileOpen,
|
|
39
199
|
setMobileOpen
|
|
40
200
|
] = useState(false);
|
|
41
|
-
return /* @__PURE__ */
|
|
201
|
+
return /* @__PURE__ */ jsxs3(
|
|
42
202
|
ResponsiveNavigation,
|
|
43
203
|
{
|
|
44
204
|
className,
|
|
@@ -50,137 +210,33 @@ var SiteNavigation = (props) => {
|
|
|
50
210
|
setMobileOpen(open);
|
|
51
211
|
},
|
|
52
212
|
children: [
|
|
53
|
-
/* @__PURE__ */
|
|
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
|
-
className: cn2(navigationActionsStyles()),
|
|
79
|
-
children: preferences
|
|
80
|
-
}
|
|
81
|
-
)
|
|
82
|
-
] }),
|
|
83
|
-
/* @__PURE__ */ jsx(MobileNavigation, { children: /* @__PURE__ */ jsxs(ResponsiveDrawer, { children: [
|
|
84
|
-
/* @__PURE__ */ jsx(
|
|
85
|
-
DrawerTrigger,
|
|
86
|
-
{
|
|
87
|
-
asChild: true,
|
|
88
|
-
children: /* @__PURE__ */ jsx(
|
|
89
|
-
Button,
|
|
90
|
-
{
|
|
91
|
-
variant: "quiet",
|
|
92
|
-
size: "standard",
|
|
93
|
-
layout: "icon",
|
|
94
|
-
"aria-label": menuLabel,
|
|
95
|
-
title: menuLabel,
|
|
96
|
-
children: /* @__PURE__ */ jsx(
|
|
97
|
-
Menu,
|
|
98
|
-
{
|
|
99
|
-
"aria-hidden": "true"
|
|
100
|
-
}
|
|
101
|
-
)
|
|
102
|
-
}
|
|
103
|
-
)
|
|
104
|
-
}
|
|
105
|
-
),
|
|
106
|
-
/* @__PURE__ */ jsxs(
|
|
107
|
-
DrawerPanel,
|
|
108
|
-
{
|
|
109
|
-
onCloseAutoFocus: (event) => {
|
|
110
|
-
const preserveAnchor = anchorNavigation.current;
|
|
111
|
-
anchorNavigation.current = false;
|
|
112
|
-
onMobileCloseAutoFocus?.(event);
|
|
113
|
-
if (preserveAnchor) {
|
|
114
|
-
event.preventDefault();
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
children: [
|
|
118
|
-
/* @__PURE__ */ jsxs(DrawerHeader, { children: [
|
|
119
|
-
/* @__PURE__ */ jsx(DrawerTitle, { children: menuLabel }),
|
|
120
|
-
/* @__PURE__ */ jsx(
|
|
121
|
-
DrawerCloseButton,
|
|
122
|
-
{
|
|
123
|
-
"aria-label": closeLabel
|
|
124
|
-
}
|
|
125
|
-
)
|
|
126
|
-
] }),
|
|
127
|
-
/* @__PURE__ */ jsxs(DrawerBody, { children: [
|
|
128
|
-
/* @__PURE__ */ jsxs(
|
|
129
|
-
"nav",
|
|
130
|
-
{
|
|
131
|
-
"aria-label": label,
|
|
132
|
-
children: [
|
|
133
|
-
links.map((link) => {
|
|
134
|
-
const { label: linkLabel, current, onClick, ...anchorProps } = link;
|
|
135
|
-
return /* @__PURE__ */ createElement(
|
|
136
|
-
MenuLink,
|
|
137
|
-
{
|
|
138
|
-
...anchorProps,
|
|
139
|
-
key: link.href,
|
|
140
|
-
"aria-current": current ? "page" : void 0,
|
|
141
|
-
onClick: (event) => {
|
|
142
|
-
onClick?.(event);
|
|
143
|
-
const activation = getNavigationActivation(event);
|
|
144
|
-
if (!activation) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
anchorNavigation.current = activation === "anchor";
|
|
148
|
-
setMobileOpen(false);
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
/* @__PURE__ */ jsx(MenuItemContent, { children: /* @__PURE__ */ jsx(MenuItemLabel, { children: linkLabel }) })
|
|
152
|
-
);
|
|
153
|
-
}),
|
|
154
|
-
mobileContent && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
155
|
-
/* @__PURE__ */ jsx(MenuSeparator, {}),
|
|
156
|
-
mobileContent
|
|
157
|
-
] })
|
|
158
|
-
]
|
|
159
|
-
}
|
|
160
|
-
),
|
|
161
|
-
/* @__PURE__ */ jsx(MenuSeparator, {}),
|
|
162
|
-
/* @__PURE__ */ jsxs(
|
|
163
|
-
MenuGroup,
|
|
164
|
-
{
|
|
165
|
-
"aria-labelledby": `${id}-settings`,
|
|
166
|
-
children: [
|
|
167
|
-
/* @__PURE__ */ jsx(
|
|
168
|
-
MenuLabel,
|
|
169
|
-
{
|
|
170
|
-
id: `${id}-settings`,
|
|
171
|
-
children: settingsLabel
|
|
172
|
-
}
|
|
173
|
-
),
|
|
174
|
-
mobilePreferences
|
|
175
|
-
]
|
|
176
|
-
}
|
|
177
|
-
)
|
|
178
|
-
] }),
|
|
179
|
-
mobileFooter && /* @__PURE__ */ jsx(DrawerFooter, { children: mobileFooter })
|
|
180
|
-
]
|
|
213
|
+
/* @__PURE__ */ jsx3(
|
|
214
|
+
DesktopSiteNavigation,
|
|
215
|
+
{
|
|
216
|
+
label,
|
|
217
|
+
links,
|
|
218
|
+
preferences,
|
|
219
|
+
desktopContent
|
|
220
|
+
}
|
|
221
|
+
),
|
|
222
|
+
/* @__PURE__ */ jsx3(
|
|
223
|
+
MobileSiteNavigation,
|
|
224
|
+
{
|
|
225
|
+
label,
|
|
226
|
+
links,
|
|
227
|
+
menuLabel,
|
|
228
|
+
closeLabel,
|
|
229
|
+
settingsLabel,
|
|
230
|
+
mobilePreferences,
|
|
231
|
+
mobileContent,
|
|
232
|
+
mobileFooter,
|
|
233
|
+
onMobileCloseAutoFocus,
|
|
234
|
+
anchorNavigation,
|
|
235
|
+
closeDrawer: () => {
|
|
236
|
+
setMobileOpen(false);
|
|
181
237
|
}
|
|
182
|
-
|
|
183
|
-
|
|
238
|
+
}
|
|
239
|
+
)
|
|
184
240
|
]
|
|
185
241
|
}
|
|
186
242
|
);
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/site-navigation/style.ts", "../src/site-navigation/site-navigation.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * @author WMXPY\n * @package Site Navigation\n * @namespace SiteNavigation\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const navigationActionsStyles = cva(cn(\n \"gridui-navigation-actions\",\n \"gridui-u-ms-auto\",\n));\n", "/**\n * @author WMXPY\n * @package Site Navigation\n * @namespace SiteNavigation\n * @description Site Navigation\n */\n\nimport {
|
|
5
|
-
"mappings": ";AAOA,SAAS,UAAU;AACnB,SAAS,WAAW;AAEb,IAAM,0BAA0B,IAAI;AAAA,EACvC;AAAA,EACA;AACJ,CAAC;;;
|
|
6
|
-
"names": ["cn"]
|
|
3
|
+
"sources": ["../src/site-navigation/style.ts", "../src/site-navigation/desktop-site-navigation.tsx", "../src/site-navigation/mobile-site-navigation.tsx", "../src/site-navigation/site-navigation.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * @author WMXPY\n * @package Site Navigation\n * @namespace SiteNavigation\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva } from \"class-variance-authority\";\n\nexport const navigationActionsStyles = cva(cn(\n \"gridui-navigation-actions\",\n \"gridui-u-site-navigation--ms-auto\",\n));\n", "/**\n * @author WMXPY\n * @package Site Navigation\n * @namespace SiteNavigation\n * @description Desktop Site Navigation\n */\n\nimport type { DesktopNavigationOptions } from \"./site-navigation-types\";\nimport { navigationActionsStyles } from \"./style\";\nimport { NavigationLinks } from \"@gridui/menu\";\nimport { DesktopNavigation } from \"@gridui/responsive-navigation\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { FC } from \"react\";\n\nexport type DesktopSiteNavigationProps = DesktopNavigationOptions;\n\nexport const DesktopSiteNavigation: FC<DesktopSiteNavigationProps> = (props: DesktopSiteNavigationProps) => {\n const { label, links, preferences, desktopContent } = props;\n return (<DesktopNavigation>\n <NavigationLinks\n aria-label={label}\n >\n {links.map((link) => {\n const { label: linkLabel, current, ...anchorProps } = link;\n return (<a\n {...anchorProps}\n key={link.href}\n aria-current={current ? \"page\" : undefined}\n >\n {linkLabel}\n </a>);\n })}\n {desktopContent}\n </NavigationLinks>\n <div\n className={cn(navigationActionsStyles())}\n >\n {preferences}\n </div>\n </DesktopNavigation>);\n};\n", "/**\n * @author WMXPY\n * @package Site Navigation\n * @namespace SiteNavigation\n * @description Mobile Site Navigation\n */\n\nimport type { MobileNavigationOptions } from \"./site-navigation-types\";\nimport { Button } from \"@gridui/button\";\nimport { DrawerBody, DrawerCloseButton, DrawerFooter, DrawerHeader, DrawerPanel, DrawerTitle, DrawerTrigger } from \"@gridui/drawer\";\nimport { getNavigationActivation } from \"@gridui/interaction\";\nimport { MenuGroup, MenuItemContent, MenuItemLabel, MenuLabel, MenuLink, MenuSeparator } from \"@gridui/menu\";\nimport { MobileNavigation, ResponsiveDrawer } from \"@gridui/responsive-navigation\";\nimport { Menu } from \"lucide-react\";\nimport { type FC, type RefObject, useId } from \"react\";\n\nexport type MobileSiteNavigationProps = MobileNavigationOptions & {\n readonly anchorNavigation: RefObject<boolean>;\n readonly closeDrawer: () => void;\n};\n\nexport const MobileSiteNavigation: FC<MobileSiteNavigationProps> = (props: MobileSiteNavigationProps) => {\n const { label, links, menuLabel, closeLabel, settingsLabel, mobilePreferences, mobileContent, mobileFooter,\n onMobileCloseAutoFocus, anchorNavigation, closeDrawer } = props;\n const id = useId();\n return (<MobileNavigation>\n <ResponsiveDrawer>\n <DrawerTrigger\n asChild\n >\n <Button\n variant=\"quiet\"\n size=\"standard\"\n layout=\"icon\"\n aria-label={menuLabel}\n title={menuLabel}\n >\n <Menu\n aria-hidden=\"true\"\n />\n </Button>\n </DrawerTrigger>\n <DrawerPanel\n onCloseAutoFocus={(event) => {\n const preserveAnchor = anchorNavigation.current;\n anchorNavigation.current = false;\n onMobileCloseAutoFocus?.(event);\n if (preserveAnchor) {\n event.preventDefault();\n }\n }}\n >\n <DrawerHeader>\n <DrawerTitle >\n {menuLabel}\n </DrawerTitle>\n <DrawerCloseButton\n aria-label={closeLabel}\n />\n </DrawerHeader>\n <DrawerBody>\n <nav\n aria-label={label}\n >\n {links.map((link) => {\n const { label: linkLabel, current, onClick, ...anchorProps } = link;\n return (<MenuLink\n {...anchorProps}\n key={link.href}\n aria-current={current ? \"page\" : undefined}\n onClick={(event) => {\n onClick?.(event);\n const activation = getNavigationActivation(event);\n if (!activation) {\n return;\n }\n anchorNavigation.current = activation === \"anchor\";\n closeDrawer();\n }}\n >\n <MenuItemContent>\n <MenuItemLabel>\n {linkLabel}\n </MenuItemLabel>\n </MenuItemContent>\n </MenuLink>);\n })}\n {mobileContent && (<>\n <MenuSeparator />\n {mobileContent}\n </>)}\n </nav>\n <MenuSeparator />\n <MenuGroup\n aria-labelledby={`${id}-settings`}\n >\n <MenuLabel\n id={`${id}-settings`}\n >\n {settingsLabel}\n </MenuLabel>\n {mobilePreferences}\n </MenuGroup>\n </DrawerBody>\n {mobileFooter && (<DrawerFooter>\n {mobileFooter}\n </DrawerFooter>)}\n </DrawerPanel>\n </ResponsiveDrawer>\n </MobileNavigation>);\n};\n", "/**\n * @author WMXPY\n * @package Site Navigation\n * @namespace SiteNavigation\n * @description Site Navigation\n */\n\nimport { DesktopSiteNavigation } from \"./desktop-site-navigation\";\nimport { MobileSiteNavigation } from \"./mobile-site-navigation\";\nimport type { DesktopNavigationOptions, MobileNavigationOptions } from \"./site-navigation-types\";\nimport { ResponsiveNavigation } from \"@gridui/responsive-navigation\";\nimport { type FC, useRef, useState } from \"react\";\n\nexport type SiteNavigationProps = DesktopNavigationOptions & MobileNavigationOptions & {\n readonly className?: string;\n};\n\nexport const SiteNavigation: FC<SiteNavigationProps> = (props: SiteNavigationProps) => {\n const {\n className,\n label,\n links,\n menuLabel,\n closeLabel,\n settingsLabel,\n preferences,\n mobilePreferences,\n desktopContent,\n mobileContent,\n mobileFooter,\n onMobileCloseAutoFocus,\n } = props;\n const anchorNavigation = useRef(false);\n const [\n mobileOpen,\n setMobileOpen,\n ] = useState(false);\n return (<ResponsiveNavigation\n className={className}\n drawerOpen={mobileOpen}\n onDrawerOpenChange={(open) => {\n if (open) {\n anchorNavigation.current = false;\n }\n setMobileOpen(open);\n }}\n >\n <DesktopSiteNavigation\n label={label}\n links={links}\n preferences={preferences}\n desktopContent={desktopContent}\n />\n <MobileSiteNavigation\n label={label}\n links={links}\n menuLabel={menuLabel}\n closeLabel={closeLabel}\n settingsLabel={settingsLabel}\n mobilePreferences={mobilePreferences}\n mobileContent={mobileContent}\n mobileFooter={mobileFooter}\n onMobileCloseAutoFocus={onMobileCloseAutoFocus}\n anchorNavigation={anchorNavigation}\n closeDrawer={() => {\n setMobileOpen(false);\n }}\n />\n </ResponsiveNavigation>);\n};\n"],
|
|
5
|
+
"mappings": ";AAOA,SAAS,UAAU;AACnB,SAAS,WAAW;AAEb,IAAM,0BAA0B,IAAI;AAAA,EACvC;AAAA,EACA;AACJ,CAAC;;;ACJD,SAAS,uBAAuB;AAChC,SAAS,yBAAyB;AAClC,SAAS,MAAAA,WAAU;AAQX,SAeA,KAfA;AAKgB;AARjB,IAAM,wBAAwD,CAAC,UAAsC;AACxG,QAAM,EAAE,OAAO,OAAO,aAAa,eAAe,IAAI;AACtD,SAAQ,qBAAC,qBACL;AAAA;AAAA,MAAC;AAAA;AAAA,QACG,cAAY;AAAA,QAEX;AAAA,gBAAM,IAAI,CAAC,SAAS;AACjB,kBAAM,EAAE,OAAO,WAAW,SAAS,GAAG,YAAY,IAAI;AACtD,mBAAQ;AAAA,cAAC;AAAA;AAAA,gBACJ,GAAG;AAAA,gBACJ,KAAK,KAAK;AAAA,gBACV,gBAAc,UAAU,SAAS;AAAA;AAAA,cAEhC;AAAA,YACL;AAAA,UACJ,CAAC;AAAA,UACA;AAAA;AAAA;AAAA,IACL;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACG,WAAWA,IAAG,wBAAwB,CAAC;AAAA,QAEtC;AAAA;AAAA,IACL;AAAA,KACJ;AACJ;;;AChCA,SAAS,cAAc;AACvB,SAAS,YAAY,mBAAmB,cAAc,cAAc,aAAa,aAAa,qBAAqB;AACnH,SAAS,+BAA+B;AACxC,SAAS,WAAW,iBAAiB,eAAe,WAAW,UAAU,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,QAAM;AAAA,IACF;AAAA,IACA;AAAA,EACJ,IAAI,SAAS,KAAK;AAClB,SAAQ,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACL;AAAA,MACA,YAAY;AAAA,MACZ,oBAAoB,CAAC,SAAS;AAC1B,YAAI,MAAM;AACN,2BAAiB,UAAU;AAAA,QAC/B;AACA,sBAAc,IAAI;AAAA,MACtB;AAAA,MAEA;AAAA,wBAAAD;AAAA,UAAC;AAAA;AAAA,YACG;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA;AAAA,QACJ;AAAA,QACA,gBAAAA;AAAA,UAAC;AAAA;AAAA,YACG;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,aAAa,MAAM;AACf,4BAAc,KAAK;AAAA,YACvB;AAAA;AAAA,QACJ;AAAA;AAAA;AAAA,EACJ;AACJ;",
|
|
6
|
+
"names": ["cn", "jsx", "jsxs", "createElement", "jsx", "jsxs"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @package Site Navigation
|
|
4
|
+
* @namespace SiteNavigation
|
|
5
|
+
* @description Desktop Site Navigation
|
|
6
|
+
*/
|
|
7
|
+
import type { DesktopNavigationOptions } from "./site-navigation-types";
|
|
8
|
+
import type { FC } from "react";
|
|
9
|
+
export type DesktopSiteNavigationProps = DesktopNavigationOptions;
|
|
10
|
+
export declare const DesktopSiteNavigation: FC<DesktopSiteNavigationProps>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @package Site Navigation
|
|
4
|
+
* @namespace SiteNavigation
|
|
5
|
+
* @description Mobile Site Navigation
|
|
6
|
+
*/
|
|
7
|
+
import type { MobileNavigationOptions } from "./site-navigation-types";
|
|
8
|
+
import { type FC, type RefObject } from "react";
|
|
9
|
+
export type MobileSiteNavigationProps = MobileNavigationOptions & {
|
|
10
|
+
readonly anchorNavigation: RefObject<boolean>;
|
|
11
|
+
readonly closeDrawer: () => void;
|
|
12
|
+
};
|
|
13
|
+
export declare const MobileSiteNavigation: FC<MobileSiteNavigationProps>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @package Site Navigation
|
|
4
|
+
* @namespace SiteNavigation
|
|
5
|
+
* @description Site Navigation Types
|
|
6
|
+
*/
|
|
7
|
+
import type { DrawerPanelProps } from "@gridui/drawer";
|
|
8
|
+
import type { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
9
|
+
export type SiteNavigationLink = Omit<ComponentPropsWithoutRef<"a">, "children" | "dangerouslySetInnerHTML" | "href" | "aria-current"> & {
|
|
10
|
+
readonly href: string;
|
|
11
|
+
readonly label: string;
|
|
12
|
+
readonly current?: boolean;
|
|
13
|
+
};
|
|
14
|
+
type SiteNavigationLinks = {
|
|
15
|
+
readonly label: string;
|
|
16
|
+
readonly links: readonly SiteNavigationLink[];
|
|
17
|
+
};
|
|
18
|
+
export type DesktopNavigationOptions = SiteNavigationLinks & {
|
|
19
|
+
readonly preferences: ReactNode;
|
|
20
|
+
readonly desktopContent?: ReactNode;
|
|
21
|
+
};
|
|
22
|
+
export type MobileNavigationOptions = SiteNavigationLinks & {
|
|
23
|
+
readonly menuLabel: string;
|
|
24
|
+
readonly closeLabel: string;
|
|
25
|
+
readonly settingsLabel: string;
|
|
26
|
+
readonly mobilePreferences: ReactNode;
|
|
27
|
+
readonly mobileContent?: ReactNode;
|
|
28
|
+
readonly mobileFooter?: ReactNode;
|
|
29
|
+
readonly onMobileCloseAutoFocus?: DrawerPanelProps["onCloseAutoFocus"];
|
|
30
|
+
};
|
|
31
|
+
export {};
|
|
@@ -4,25 +4,9 @@
|
|
|
4
4
|
* @namespace SiteNavigation
|
|
5
5
|
* @description Site Navigation
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
import { type
|
|
9
|
-
export type
|
|
10
|
-
readonly href: string;
|
|
11
|
-
readonly label: string;
|
|
12
|
-
readonly current?: boolean;
|
|
13
|
-
};
|
|
14
|
-
export type SiteNavigationProps = {
|
|
7
|
+
import type { DesktopNavigationOptions, MobileNavigationOptions } from "./site-navigation-types";
|
|
8
|
+
import { type FC } from "react";
|
|
9
|
+
export type SiteNavigationProps = DesktopNavigationOptions & MobileNavigationOptions & {
|
|
15
10
|
readonly className?: string;
|
|
16
|
-
readonly label: string;
|
|
17
|
-
readonly links: readonly SiteNavigationLink[];
|
|
18
|
-
readonly menuLabel: string;
|
|
19
|
-
readonly closeLabel: string;
|
|
20
|
-
readonly settingsLabel: string;
|
|
21
|
-
readonly preferences: ReactNode;
|
|
22
|
-
readonly mobilePreferences: ReactNode;
|
|
23
|
-
readonly desktopContent?: ReactNode;
|
|
24
|
-
readonly mobileContent?: ReactNode;
|
|
25
|
-
readonly mobileFooter?: ReactNode;
|
|
26
|
-
readonly onMobileCloseAutoFocus?: DrawerPanelProps["onCloseAutoFocus"];
|
|
27
11
|
};
|
|
28
12
|
export declare const SiteNavigation: FC<SiteNavigationProps>;
|
package/dist/styles.css
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! tailwindcss v4.3.
|
|
1
|
+
/*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */
|
|
2
2
|
@layer theme, base, components, utilities;
|
|
3
3
|
@layer utilities {
|
|
4
|
-
.gridui-u-ms-auto {
|
|
4
|
+
.gridui-u-site-navigation--ms-auto {
|
|
5
5
|
margin-inline-start: auto;
|
|
6
6
|
}
|
|
7
7
|
}
|
package/docs/catalog.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"name": "@gridui/site-navigation",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.7",
|
|
5
5
|
"category": "landing",
|
|
6
6
|
"description": "GridUI React site navigation",
|
|
7
7
|
"usage": "SiteNavigation combines `@gridui/responsive-navigation`, `@gridui/menu`, `@gridui/drawer`, and `@gridui/button`. Applications supply links, localized labels, preferences, desktop content, and optional mobile content/footer slots.",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gridui/site-navigation",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"description": "GridUI React site navigation",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -27,21 +27,21 @@
|
|
|
27
27
|
"react-dom": "^19.2.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@gridui/button": "^
|
|
31
|
-
"@gridui/drawer": "^1.1.
|
|
30
|
+
"@gridui/button": "^4.0.0",
|
|
31
|
+
"@gridui/drawer": "^1.1.7",
|
|
32
32
|
"@gridui/interaction": "^1.2.1",
|
|
33
|
-
"@gridui/menu": "^
|
|
34
|
-
"@gridui/responsive-navigation": "^1.1.
|
|
35
|
-
"@gridui/style-utils": "^
|
|
33
|
+
"@gridui/menu": "^3.0.0",
|
|
34
|
+
"@gridui/responsive-navigation": "^1.1.6",
|
|
35
|
+
"@gridui/style-utils": "^3.0.0",
|
|
36
36
|
"@gridui/theme": "^2.5.3",
|
|
37
37
|
"class-variance-authority": "0.7.1",
|
|
38
|
-
"lucide-react": "1.
|
|
38
|
+
"lucide-react": "1.70.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@gridui-internal/configuration": "0.0.0-internal",
|
|
42
|
-
"@gridui/brand-link": "1.0.
|
|
43
|
-
"@gridui/grid": "2.3.
|
|
44
|
-
"@gridui/preferences": "1.0.
|
|
42
|
+
"@gridui/brand-link": "1.0.5",
|
|
43
|
+
"@gridui/grid": "2.3.6",
|
|
44
|
+
"@gridui/preferences": "1.0.8",
|
|
45
45
|
"@jest/globals": "30.5.2",
|
|
46
46
|
"@storybook/react-vite": "10.6.6",
|
|
47
47
|
"@types/jest": "30.0.0",
|