@djangocfg/ui-core 2.1.308 → 2.1.309
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/ui-core",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.309",
|
|
4
4
|
"description": "Pure React UI component library without Next.js dependencies - for Electron, Vite, CRA apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ui-components",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"playground": "playground dev"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
|
-
"@djangocfg/i18n": "^2.1.
|
|
94
|
+
"@djangocfg/i18n": "^2.1.309",
|
|
95
95
|
"consola": "^3.4.2",
|
|
96
96
|
"lucide-react": "^0.545.0",
|
|
97
97
|
"moment": "^2.30.1",
|
|
@@ -160,9 +160,9 @@
|
|
|
160
160
|
"vaul": "1.1.2"
|
|
161
161
|
},
|
|
162
162
|
"devDependencies": {
|
|
163
|
-
"@djangocfg/i18n": "^2.1.
|
|
163
|
+
"@djangocfg/i18n": "^2.1.309",
|
|
164
164
|
"@djangocfg/playground": "workspace:*",
|
|
165
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
165
|
+
"@djangocfg/typescript-config": "^2.1.309",
|
|
166
166
|
"@types/node": "^24.7.2",
|
|
167
167
|
"@types/react": "^19.1.0",
|
|
168
168
|
"@types/react-dom": "^19.1.0",
|
|
@@ -32,7 +32,14 @@
|
|
|
32
32
|
* never resolved.
|
|
33
33
|
*/
|
|
34
34
|
|
|
35
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
forwardRef,
|
|
37
|
+
useMemo,
|
|
38
|
+
type AnchorHTMLAttributes,
|
|
39
|
+
type ComponentType,
|
|
40
|
+
type ReactNode,
|
|
41
|
+
type Ref,
|
|
42
|
+
} from 'react';
|
|
36
43
|
import { useRouter as useNextRouter } from 'next/navigation';
|
|
37
44
|
import NextLink from 'next/link';
|
|
38
45
|
|
|
@@ -138,3 +145,54 @@ export interface NextLinkProviderProps {
|
|
|
138
145
|
export function NextLinkProvider({ children }: NextLinkProviderProps) {
|
|
139
146
|
return <LinkProvider value={NextLinkAdapter}>{children}</LinkProvider>;
|
|
140
147
|
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Minimal shape of the `Link` returned by next-intl's `createNavigation()`.
|
|
151
|
+
* Typed structurally so we don't take a peer dep on `next-intl`.
|
|
152
|
+
*/
|
|
153
|
+
type NextIntlLinkLike = ComponentType<
|
|
154
|
+
AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
155
|
+
href: string;
|
|
156
|
+
locale?: string;
|
|
157
|
+
replace?: boolean;
|
|
158
|
+
scroll?: boolean;
|
|
159
|
+
prefetch?: boolean | null;
|
|
160
|
+
ref?: Ref<HTMLAnchorElement>;
|
|
161
|
+
}
|
|
162
|
+
>;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Wraps next-intl's `Link` (from `createNavigation()`) into our generic
|
|
166
|
+
* `LinkComponent`, so apps using `next-intl` get locale-prefixed hrefs on
|
|
167
|
+
* every `<Link>` rendered through `@djangocfg/ui-core`.
|
|
168
|
+
*
|
|
169
|
+
* Pass the result as `baseApp.linkAdapter` to `AppLayout` / `BaseApp` —
|
|
170
|
+
* it overrides the default `next/link` adapter for the whole subtree.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* import { createNextIntlLinkAdapter } from '@djangocfg/ui-core/adapters/nextjs';
|
|
174
|
+
* import { Link as IntlLink } from '@/i18n/navigation';
|
|
175
|
+
*
|
|
176
|
+
* const linkAdapter = useMemo(() => createNextIntlLinkAdapter(IntlLink), []);
|
|
177
|
+
* <AppLayout baseApp={{ ..., linkAdapter }} />
|
|
178
|
+
*/
|
|
179
|
+
export function createNextIntlLinkAdapter(
|
|
180
|
+
NextIntlLink: NextIntlLinkLike,
|
|
181
|
+
): LinkComponent {
|
|
182
|
+
return forwardRef<HTMLAnchorElement, LinkComponentProps>(
|
|
183
|
+
function NextIntlLinkAdapter({ href, replace, scroll, prefetch, children, ...rest }, ref) {
|
|
184
|
+
return (
|
|
185
|
+
<NextIntlLink
|
|
186
|
+
href={href}
|
|
187
|
+
replace={replace}
|
|
188
|
+
scroll={scroll}
|
|
189
|
+
prefetch={prefetch}
|
|
190
|
+
ref={ref}
|
|
191
|
+
{...rest}
|
|
192
|
+
>
|
|
193
|
+
{children}
|
|
194
|
+
</NextIntlLink>
|
|
195
|
+
);
|
|
196
|
+
},
|
|
197
|
+
);
|
|
198
|
+
}
|