@gridui/site-navigation 1.0.0 → 1.1.2
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/README.md +46 -1
- package/dist/index.js +139 -93
- package/dist/index.js.map +2 -2
- package/dist/site-navigation/site-navigation.d.ts +5 -2
- package/dist/styles.css +1 -1
- package/package.json +15 -10
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Landing family. Public API: `SiteNavigation`, `SiteNavigationLink`, `SiteNavigat
|
|
|
5
5
|
Import components from `@gridui/site-navigation` and load `@gridui/site-navigation/styles.css` after Theme.
|
|
6
6
|
Load styles for any composed dependency used by this family. Applications own routes, labels, state persistence, and branding.
|
|
7
7
|
|
|
8
|
-
See [component ownership](
|
|
8
|
+
See [component ownership](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/docs/component-ownership.md) and [release history](https://github.com/sudo-ui/GridUI-React-Monorepo/tree/main/packages-landing/site-navigation/.changeset/history).
|
|
9
9
|
|
|
10
10
|
## Rich navigation menus
|
|
11
11
|
|
|
@@ -22,3 +22,48 @@ with caller-owned branding.
|
|
|
22
22
|
Set `columns={1}` on a MenuGrid passed as mobile content; the composition does
|
|
23
23
|
not select its private descendants. Load rendered dependency styles before
|
|
24
24
|
SiteNavigation styles.
|
|
25
|
+
|
|
26
|
+
`className` styles the ResponsiveNavigation root. For a header whose links and
|
|
27
|
+
preferences form one compact group at the far end, use an application utility
|
|
28
|
+
class that disables the root's default flex growth:
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
<SiteHeader justify="between" gap={16} padding={{ base: 24, lg: 32 }}>
|
|
32
|
+
<BrandLink href="/">Product</BrandLink>
|
|
33
|
+
<SiteNavigation className="flex-none" {...localizedNavigation} />
|
|
34
|
+
</SiteHeader>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Without that class, the navigation keeps its existing flexible width, placing
|
|
38
|
+
its preferences at the opposite edge of the available navigation region.
|
|
39
|
+
|
|
40
|
+
## Native navigation and drawer dismissal
|
|
41
|
+
|
|
42
|
+
`links` accepts native anchor attributes and handlers in addition to `href`,
|
|
43
|
+
`label`, and `current`. A caller's `onClick` runs first on both desktop and
|
|
44
|
+
mobile. Calling `preventDefault()` keeps the mobile drawer open. Modified clicks,
|
|
45
|
+
non-primary clicks, downloads, and links targeting another browsing context
|
|
46
|
+
retain their native behavior and also leave the drawer open.
|
|
47
|
+
|
|
48
|
+
An ordinary same-context mobile link closes the drawer. If its destination has a
|
|
49
|
+
fragment and matches the current origin, path, and query, native anchor navigation
|
|
50
|
+
keeps the destination focus and scroll position rather than returning focus to
|
|
51
|
+
the menu trigger. Close-button and Escape dismissal continue to restore trigger
|
|
52
|
+
focus. `onMobileCloseAutoFocus` exposes the underlying DrawerPanel event when an
|
|
53
|
+
application needs another focus policy; calling `preventDefault()` suppresses the
|
|
54
|
+
normal trigger restoration. It does not cancel navigation or drawer dismissal.
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
<SiteNavigation
|
|
58
|
+
links={[
|
|
59
|
+
{ href: "#features", label: "Features" },
|
|
60
|
+
{ href: "/guide/", label: "Guide", target: "_blank", rel: "noreferrer" },
|
|
61
|
+
{ href: "/report.csv", label: "Download report", download: true },
|
|
62
|
+
]}
|
|
63
|
+
{...navigationLabelsAndPreferences}
|
|
64
|
+
/>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Caller-owned `mobileContent`, `mobilePreferences`, and `mobileFooter` slots retain
|
|
68
|
+
their own activation policy. Compose their controls with public Drawer parts
|
|
69
|
+
when they should dismiss the panel.
|
package/dist/index.js
CHANGED
|
@@ -3,20 +3,23 @@ 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
|
-
"ms-auto"
|
|
6
|
+
"gridui-u-ms-auto"
|
|
7
7
|
));
|
|
8
8
|
|
|
9
9
|
// src/site-navigation/site-navigation.tsx
|
|
10
10
|
import { Button } from "@gridui/button";
|
|
11
11
|
import { DrawerBody, DrawerCloseButton, DrawerFooter, DrawerHeader, DrawerPanel, DrawerTitle, DrawerTrigger } from "@gridui/drawer";
|
|
12
|
+
import { getNavigationActivation } from "@gridui/interaction";
|
|
12
13
|
import { MenuGroup, MenuItemContent, MenuItemLabel, MenuLabel, MenuLink, MenuSeparator, NavigationLinks } from "@gridui/menu";
|
|
13
14
|
import { DesktopNavigation, MobileNavigation, ResponsiveDrawer, ResponsiveNavigation } from "@gridui/responsive-navigation";
|
|
14
15
|
import { cn as cn2 } from "@gridui/style-utils";
|
|
15
16
|
import { Menu } from "lucide-react";
|
|
16
|
-
import { useId } from "react";
|
|
17
|
+
import { useId, useRef, useState } from "react";
|
|
17
18
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
19
|
+
import { createElement } from "react";
|
|
18
20
|
var SiteNavigation = (props) => {
|
|
19
21
|
const {
|
|
22
|
+
className,
|
|
20
23
|
label,
|
|
21
24
|
links,
|
|
22
25
|
menuLabel,
|
|
@@ -26,118 +29,161 @@ var SiteNavigation = (props) => {
|
|
|
26
29
|
mobilePreferences,
|
|
27
30
|
desktopContent,
|
|
28
31
|
mobileContent,
|
|
29
|
-
mobileFooter
|
|
32
|
+
mobileFooter,
|
|
33
|
+
onMobileCloseAutoFocus
|
|
30
34
|
} = props;
|
|
31
35
|
const id = useId();
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
children: link.label
|
|
46
|
-
},
|
|
47
|
-
link.href
|
|
48
|
-
);
|
|
49
|
-
}),
|
|
50
|
-
desktopContent
|
|
51
|
-
]
|
|
52
|
-
}
|
|
53
|
-
),
|
|
54
|
-
/* @__PURE__ */ jsx(
|
|
55
|
-
"div",
|
|
56
|
-
{
|
|
57
|
-
className: cn2(navigationActionsStyles()),
|
|
58
|
-
children: preferences
|
|
59
|
-
}
|
|
60
|
-
)
|
|
61
|
-
] }),
|
|
62
|
-
/* @__PURE__ */ jsx(MobileNavigation, { children: /* @__PURE__ */ jsxs(ResponsiveDrawer, { children: [
|
|
63
|
-
/* @__PURE__ */ jsx(
|
|
64
|
-
DrawerTrigger,
|
|
65
|
-
{
|
|
66
|
-
asChild: true,
|
|
67
|
-
children: /* @__PURE__ */ jsx(
|
|
68
|
-
Button,
|
|
69
|
-
{
|
|
70
|
-
variant: "quiet",
|
|
71
|
-
size: "standard",
|
|
72
|
-
layout: "icon",
|
|
73
|
-
"aria-label": menuLabel,
|
|
74
|
-
title: menuLabel,
|
|
75
|
-
children: /* @__PURE__ */ jsx(
|
|
76
|
-
Menu,
|
|
77
|
-
{
|
|
78
|
-
"aria-hidden": "true"
|
|
79
|
-
}
|
|
80
|
-
)
|
|
81
|
-
}
|
|
82
|
-
)
|
|
36
|
+
const anchorNavigation = useRef(false);
|
|
37
|
+
const [
|
|
38
|
+
mobileOpen,
|
|
39
|
+
setMobileOpen
|
|
40
|
+
] = useState(false);
|
|
41
|
+
return /* @__PURE__ */ jsxs(
|
|
42
|
+
ResponsiveNavigation,
|
|
43
|
+
{
|
|
44
|
+
className,
|
|
45
|
+
drawerOpen: mobileOpen,
|
|
46
|
+
onDrawerOpenChange: (open) => {
|
|
47
|
+
if (open) {
|
|
48
|
+
anchorNavigation.current = false;
|
|
83
49
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
/* @__PURE__ */ jsx(
|
|
89
|
-
DrawerCloseButton,
|
|
90
|
-
{
|
|
91
|
-
"aria-label": closeLabel
|
|
92
|
-
}
|
|
93
|
-
)
|
|
94
|
-
] }),
|
|
95
|
-
/* @__PURE__ */ jsxs(DrawerBody, { children: [
|
|
50
|
+
setMobileOpen(open);
|
|
51
|
+
},
|
|
52
|
+
children: [
|
|
53
|
+
/* @__PURE__ */ jsxs(DesktopNavigation, { children: [
|
|
96
54
|
/* @__PURE__ */ jsxs(
|
|
97
|
-
|
|
55
|
+
NavigationLinks,
|
|
98
56
|
{
|
|
99
57
|
"aria-label": label,
|
|
100
58
|
children: [
|
|
101
59
|
links.map((link) => {
|
|
102
|
-
|
|
103
|
-
|
|
60
|
+
const { label: linkLabel, current, ...anchorProps } = link;
|
|
61
|
+
return /* @__PURE__ */ createElement(
|
|
62
|
+
"a",
|
|
104
63
|
{
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
64
|
+
...anchorProps,
|
|
65
|
+
key: link.href,
|
|
66
|
+
"aria-current": current ? "page" : void 0
|
|
108
67
|
},
|
|
109
|
-
|
|
68
|
+
linkLabel
|
|
110
69
|
);
|
|
111
70
|
}),
|
|
112
|
-
|
|
113
|
-
/* @__PURE__ */ jsx(MenuSeparator, {}),
|
|
114
|
-
mobileContent
|
|
115
|
-
] })
|
|
71
|
+
desktopContent
|
|
116
72
|
]
|
|
117
73
|
}
|
|
118
74
|
),
|
|
119
|
-
/* @__PURE__ */ jsx(
|
|
75
|
+
/* @__PURE__ */ jsx(
|
|
76
|
+
"div",
|
|
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
|
+
),
|
|
120
106
|
/* @__PURE__ */ jsxs(
|
|
121
|
-
|
|
107
|
+
DrawerPanel,
|
|
122
108
|
{
|
|
123
|
-
|
|
109
|
+
onCloseAutoFocus: (event) => {
|
|
110
|
+
const preserveAnchor = anchorNavigation.current;
|
|
111
|
+
anchorNavigation.current = false;
|
|
112
|
+
onMobileCloseAutoFocus?.(event);
|
|
113
|
+
if (preserveAnchor) {
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
}
|
|
116
|
+
},
|
|
124
117
|
children: [
|
|
125
|
-
/* @__PURE__ */
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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 })
|
|
133
180
|
]
|
|
134
181
|
}
|
|
135
182
|
)
|
|
136
|
-
] })
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
] });
|
|
183
|
+
] }) })
|
|
184
|
+
]
|
|
185
|
+
}
|
|
186
|
+
);
|
|
141
187
|
};
|
|
142
188
|
export {
|
|
143
189
|
SiteNavigation
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 \"ms-auto\",\n));\n", "/**\n * @author WMXPY\n * @package Site Navigation\n * @namespace SiteNavigation\n * @description Site Navigation\n */\n\nimport { navigationActionsStyles } from \"./style\";\nimport { Button } from \"@gridui/button\";\nimport { DrawerBody, DrawerCloseButton, DrawerFooter, DrawerHeader, DrawerPanel, DrawerTitle, DrawerTrigger } from \"@gridui/drawer\";\nimport { MenuGroup, MenuItemContent, MenuItemLabel, MenuLabel, MenuLink, MenuSeparator, NavigationLinks } from \"@gridui/menu\";\nimport { DesktopNavigation, MobileNavigation, ResponsiveDrawer, ResponsiveNavigation } from \"@gridui/responsive-navigation\";\nimport { cn } from \"@gridui/style-utils\";\nimport { Menu } from \"lucide-react\";\nimport { type FC, type ReactNode, useId } from \"react\";\n\nexport type SiteNavigationLink = {\n readonly href: string;\n readonly label: string;\n readonly current?: boolean;\n};\n\nexport type SiteNavigationProps = {\n readonly label: string;\n readonly links: readonly SiteNavigationLink[];\n readonly menuLabel: string;\n readonly closeLabel: string;\n readonly settingsLabel: string;\n readonly preferences: ReactNode;\n readonly mobilePreferences: ReactNode;\n readonly desktopContent?: ReactNode;\n readonly mobileContent?: ReactNode;\n readonly mobileFooter?: ReactNode;\n};\n\nexport const SiteNavigation: FC<SiteNavigationProps> = (props: SiteNavigationProps) => {\n const {\n label,\n links,\n menuLabel,\n closeLabel,\n settingsLabel,\n preferences,\n mobilePreferences,\n desktopContent,\n mobileContent,\n mobileFooter,\n } = props;\n const id = useId();\n return (<ResponsiveNavigation>\n <DesktopNavigation>\n <NavigationLinks\n aria-label={label}\n >\n {links.map((link) => {\n return (<a\n
|
|
5
|
-
"mappings": ";AAOA,SAAS,UAAU;AACnB,SAAS,WAAW;AAEb,IAAM,0BAA0B,IAAI;AAAA,EACvC;AAAA,EACA;AACJ,CAAC;;;ACLD,SAAS,cAAc;AACvB,SAAS,YAAY,mBAAmB,cAAc,cAAc,
|
|
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 { navigationActionsStyles } from \"./style\";\nimport { Button } from \"@gridui/button\";\nimport { DrawerBody, DrawerCloseButton, DrawerFooter, DrawerHeader, DrawerPanel, type DrawerPanelProps, DrawerTitle, DrawerTrigger } from \"@gridui/drawer\";\nimport { getNavigationActivation } from \"@gridui/interaction\";\nimport { MenuGroup, MenuItemContent, MenuItemLabel, MenuLabel, MenuLink, MenuSeparator, NavigationLinks } from \"@gridui/menu\";\nimport { DesktopNavigation, MobileNavigation, ResponsiveDrawer, ResponsiveNavigation } from \"@gridui/responsive-navigation\";\nimport { cn } from \"@gridui/style-utils\";\nimport { Menu } from \"lucide-react\";\nimport { type ComponentPropsWithoutRef, type FC, type ReactNode, useId, useRef, useState } from \"react\";\n\nexport type SiteNavigationLink = Omit<ComponentPropsWithoutRef<\"a\">, \"children\" | \"dangerouslySetInnerHTML\" | \"href\" | \"aria-current\"> & {\n readonly href: string;\n readonly label: string;\n readonly current?: boolean;\n};\n\nexport type SiteNavigationProps = {\n readonly className?: string;\n readonly label: string;\n readonly links: readonly SiteNavigationLink[];\n readonly menuLabel: string;\n readonly closeLabel: string;\n readonly settingsLabel: string;\n readonly preferences: ReactNode;\n readonly mobilePreferences: ReactNode;\n readonly desktopContent?: ReactNode;\n readonly mobileContent?: ReactNode;\n readonly mobileFooter?: ReactNode;\n readonly onMobileCloseAutoFocus?: DrawerPanelProps[\"onCloseAutoFocus\"];\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 id = useId();\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 <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 <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 setMobileOpen(false);\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 </ResponsiveNavigation>);\n};\n"],
|
|
5
|
+
"mappings": ";AAOA,SAAS,UAAU;AACnB,SAAS,WAAW;AAEb,IAAM,0BAA0B,IAAI;AAAA,EACvC;AAAA,EACA;AACJ,CAAC;;;ACLD,SAAS,cAAc;AACvB,SAAS,YAAY,mBAAmB,cAAc,cAAc,aAAoC,aAAa,qBAAqB;AAC1I,SAAS,+BAA+B;AACxC,SAAS,WAAW,iBAAiB,eAAe,WAAW,UAAU,eAAe,uBAAuB;AAC/G,SAAS,mBAAmB,kBAAkB,kBAAkB,4BAA4B;AAC5F,SAAS,MAAAA,WAAU;AACnB,SAAS,YAAY;AACrB,SAAiE,OAAO,QAAQ,gBAAgB;AAuDpF,SAmFmC,UApEnC,KAfA;AAKgB;AArCrB,IAAM,iBAA0C,CAAC,UAA+B;AACnF,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ,IAAI;AACJ,QAAM,KAAK,MAAM;AACjB,QAAM,mBAAmB,O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teNavigation
|
|
5
5
|
* @description Site Navigation
|
|
6
6
|
*/
|
|
7
|
-
import { type
|
|
8
|
-
|
|
7
|
+
import { type DrawerPanelProps } from "@gridui/drawer";
|
|
8
|
+
import { type ComponentPropsWithoutRef, type FC, type ReactNode } from "react";
|
|
9
|
+
export type SiteNavigationLink = Omit<ComponentPropsWithoutRef<"a">, "children" | "dangerouslySetInnerHTML" | "href" | "aria-current"> & {
|
|
9
10
|
readonly href: string;
|
|
10
11
|
readonly label: string;
|
|
11
12
|
readonly current?: boolean;
|
|
12
13
|
};
|
|
13
14
|
export type SiteNavigationProps = {
|
|
15
|
+
readonly className?: string;
|
|
14
16
|
readonly label: string;
|
|
15
17
|
readonly links: readonly SiteNavigationLink[];
|
|
16
18
|
readonly menuLabel: string;
|
|
@@ -21,5 +23,6 @@ export type SiteNavigationProps = {
|
|
|
21
23
|
readonly desktopContent?: ReactNode;
|
|
22
24
|
readonly mobileContent?: ReactNode;
|
|
23
25
|
readonly mobileFooter?: ReactNode;
|
|
26
|
+
readonly onMobileCloseAutoFocus?: DrawerPanelProps["onCloseAutoFocus"];
|
|
24
27
|
};
|
|
25
28
|
export declare const SiteNavigation: FC<SiteNavigationProps>;
|
package/dist/styles.css
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gridui/site-navigation",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "GridUI React site navigation",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -26,20 +26,25 @@
|
|
|
26
26
|
"react-dom": "^19.2.0"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@gridui/button": "^2.
|
|
30
|
-
"@gridui/drawer": "^1.
|
|
31
|
-
"@gridui/
|
|
32
|
-
"@gridui/
|
|
33
|
-
"@gridui/
|
|
34
|
-
"@gridui/
|
|
29
|
+
"@gridui/button": "^2.2.0",
|
|
30
|
+
"@gridui/drawer": "^1.1.2",
|
|
31
|
+
"@gridui/interaction": "^1.1.2",
|
|
32
|
+
"@gridui/menu": "^2.0.2",
|
|
33
|
+
"@gridui/responsive-navigation": "^1.1.2",
|
|
34
|
+
"@gridui/style-utils": "^2.1.4",
|
|
35
|
+
"@gridui/theme": "^2.3.2",
|
|
35
36
|
"class-variance-authority": "0.7.1",
|
|
36
|
-
"lucide-react": "1.
|
|
37
|
+
"lucide-react": "1.65.0"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
|
-
"@gridui-internal/configuration": "0.0.0",
|
|
40
|
+
"@gridui-internal/configuration": "0.0.0-internal",
|
|
41
|
+
"@gridui/brand-link": "1.0.2",
|
|
42
|
+
"@gridui/preferences": "1.0.3",
|
|
43
|
+
"@gridui/site-header": "1.1.2",
|
|
40
44
|
"@jest/globals": "30.5.2",
|
|
45
|
+
"@storybook/react-vite": "10.6.5",
|
|
41
46
|
"@types/jest": "30.0.0",
|
|
42
|
-
"@types/node": "26.6.
|
|
47
|
+
"@types/node": "26.6.6",
|
|
43
48
|
"@types/react": "19.3.0",
|
|
44
49
|
"@types/react-dom": "19.3.0",
|
|
45
50
|
"jest": "30.5.2",
|