@djangocfg/layouts 2.1.279 → 2.1.281
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 +1 -1
- package/package.json +18 -18
- package/src/layouts/AppLayout/AppLayout.tsx +2 -10
- package/src/layouts/PrivateLayout/PrivateLayout.tsx +2 -1
- package/src/layouts/PrivateLayout/components/PrivateSidebar.tsx +1 -1
- package/src/layouts/PublicLayout/README.md +69 -1
- package/src/layouts/PublicLayout/footers/DefaultFooter/DefaultFooter.tsx +8 -7
- package/src/layouts/PublicLayout/footers/DefaultFooter/FooterBottom.tsx +4 -3
- package/src/layouts/PublicLayout/footers/DefaultFooter/FooterMenuSections.tsx +4 -3
- package/src/layouts/PublicLayout/footers/DefaultFooter/types.ts +1 -2
- package/src/layouts/PublicLayout/index.ts +7 -7
- package/src/layouts/PublicLayout/navbars/FloatingNavbar/FloatingNavbar.tsx +18 -11
- package/src/layouts/PublicLayout/navbars/FlushNavbar/FlushNavbar.tsx +18 -11
- package/src/layouts/PublicLayout/navbars/MinimalNavbar/MinimalNavbar.tsx +22 -12
- package/src/layouts/PublicLayout/primitives/LinkComponentContext.tsx +50 -0
- package/src/layouts/PublicLayout/primitives/NavActionItem.tsx +4 -3
- package/src/layouts/PublicLayout/primitives/NavActions.tsx +8 -0
- package/src/layouts/PublicLayout/primitives/NavBrand.tsx +5 -3
- package/src/layouts/PublicLayout/primitives/NavControls.tsx +114 -0
- package/src/layouts/PublicLayout/primitives/NavDesktopItems.tsx +8 -7
- package/src/layouts/PublicLayout/primitives/index.ts +9 -9
- package/src/layouts/PublicLayout/shared/MobileDrawerShell.tsx +32 -8
- package/src/layouts/PublicLayout/shared/NavbarShell.tsx +33 -0
- package/src/layouts/_components/PrivateSidebarAccount.tsx +1 -1
- package/src/layouts/types/index.ts +1 -1
- package/src/layouts/types/layout.types.ts +13 -0
- package/src/layouts/PublicLayout/primitives/ExternalPrefixesContext.tsx +0 -69
- package/src/layouts/PublicLayout/primitives/SmartNavLink.tsx +0 -81
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SmartNavLink
|
|
3
|
-
*
|
|
4
|
-
* Drop-in replacement for `next/link` used inside PublicLayout navbars/footers.
|
|
5
|
-
*
|
|
6
|
-
* If the `href` is a string that starts with one of the prefixes configured
|
|
7
|
-
* via `ExternalPrefixesProvider`, renders a plain `<a>` (full page navigation).
|
|
8
|
-
* This is required for routes owned by a catch-all handler outside App Router
|
|
9
|
-
* (e.g. Nextra `/docs/*`), where `next/link` client navigation asks for an
|
|
10
|
-
* RSC payload the route cannot produce — resulting in a hard error banner.
|
|
11
|
-
*
|
|
12
|
-
* Otherwise falls back to `next/link` so existing behaviour is preserved.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
'use client';
|
|
16
|
-
|
|
17
|
-
import Link, { type LinkProps } from 'next/link';
|
|
18
|
-
import React, { forwardRef, type AnchorHTMLAttributes, type ReactNode } from 'react';
|
|
19
|
-
|
|
20
|
-
import {
|
|
21
|
-
isExternalPrefixHref,
|
|
22
|
-
useExternalPrefixes,
|
|
23
|
-
type ExternalPrefixes,
|
|
24
|
-
} from './ExternalPrefixesContext';
|
|
25
|
-
|
|
26
|
-
type AnchorProps = Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>;
|
|
27
|
-
|
|
28
|
-
export interface SmartNavLinkProps
|
|
29
|
-
extends Omit<LinkProps, 'href' | 'passHref' | 'legacyBehavior'>,
|
|
30
|
-
AnchorProps {
|
|
31
|
-
href: LinkProps['href'];
|
|
32
|
-
children?: ReactNode;
|
|
33
|
-
/** Optional override — falls back to context value. */
|
|
34
|
-
externalPrefixes?: ExternalPrefixes;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const SmartNavLink = forwardRef<HTMLAnchorElement, SmartNavLinkProps>(
|
|
38
|
-
function SmartNavLink(props, ref) {
|
|
39
|
-
const {
|
|
40
|
-
href,
|
|
41
|
-
children,
|
|
42
|
-
externalPrefixes,
|
|
43
|
-
// LinkProps-specific fields we should NOT forward to a plain <a>.
|
|
44
|
-
prefetch,
|
|
45
|
-
replace,
|
|
46
|
-
scroll,
|
|
47
|
-
shallow,
|
|
48
|
-
locale,
|
|
49
|
-
// Rest are anchor-compatible attributes.
|
|
50
|
-
...anchorProps
|
|
51
|
-
} = props;
|
|
52
|
-
|
|
53
|
-
const contextPrefixes = useExternalPrefixes();
|
|
54
|
-
const prefixes = externalPrefixes ?? contextPrefixes;
|
|
55
|
-
|
|
56
|
-
const shouldUseAnchor = isExternalPrefixHref(href, prefixes);
|
|
57
|
-
|
|
58
|
-
if (shouldUseAnchor) {
|
|
59
|
-
return (
|
|
60
|
-
<a ref={ref} href={href} {...anchorProps}>
|
|
61
|
-
{children}
|
|
62
|
-
</a>
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<Link
|
|
68
|
-
ref={ref}
|
|
69
|
-
href={href}
|
|
70
|
-
prefetch={prefetch}
|
|
71
|
-
replace={replace}
|
|
72
|
-
scroll={scroll}
|
|
73
|
-
shallow={shallow}
|
|
74
|
-
locale={locale}
|
|
75
|
-
{...anchorProps}
|
|
76
|
-
>
|
|
77
|
-
{children}
|
|
78
|
-
</Link>
|
|
79
|
-
);
|
|
80
|
-
},
|
|
81
|
-
);
|