@digigov/nextjs 1.1.5-rc.17 → 1.1.6
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/App/index.js +13 -4
- package/App.d.ts +4 -7
- package/App.js.map +2 -2
- package/Document.d.ts +2 -2
- package/Image/index.js +2 -2
- package/Image.js.map +2 -2
- package/Link/index.js +1 -1
- package/Link.d.ts +1 -1
- package/Link.js.map +2 -2
- package/cjs/App/index.js +13 -4
- package/cjs/App.js.map +2 -2
- package/cjs/Image/index.js +2 -2
- package/cjs/Image.js.map +2 -2
- package/cjs/Link/index.js +3 -3
- package/cjs/Link.js.map +3 -3
- package/index.js +1 -1
- package/package.json +6 -14
- package/src/App.tsx +16 -4
- package/src/Image.tsx +4 -2
- package/src/Link.tsx +1 -1
package/App/index.js
CHANGED
|
@@ -6,9 +6,14 @@ import NextLink from "@digigov/nextjs/Link";
|
|
|
6
6
|
import DigiGOVApp, { StaticApp } from "@digigov/ui/app/App";
|
|
7
7
|
import { I18NProvider } from "@digigov/ui/i18n";
|
|
8
8
|
import { LinkProvider } from "@digigov/ui/navigation/Link";
|
|
9
|
-
|
|
9
|
+
import { useRouter } from "next/router";
|
|
10
|
+
class DigiGOVNextAppClass extends App {
|
|
10
11
|
render() {
|
|
11
|
-
const { Component, pageProps, t, i18n: i18n2, ssr = false } = this.props;
|
|
12
|
+
const { Component, pageProps, t, i18n: i18n2, ssr = false, router } = this.props;
|
|
13
|
+
const { locale } = router;
|
|
14
|
+
if (locale && i18n2.language != locale) {
|
|
15
|
+
i18n2.changeLanguage(locale);
|
|
16
|
+
}
|
|
12
17
|
return /* @__PURE__ */ React.createElement(
|
|
13
18
|
I18NProvider,
|
|
14
19
|
{
|
|
@@ -25,8 +30,12 @@ class DigiGOVNextApp extends App {
|
|
|
25
30
|
);
|
|
26
31
|
}
|
|
27
32
|
}
|
|
28
|
-
const DigiGOVNextAppWithTranslation = withTranslation()(
|
|
29
|
-
|
|
33
|
+
const DigiGOVNextAppWithTranslation = withTranslation()(DigiGOVNextAppClass);
|
|
34
|
+
const DigiGOVNextApp = (props) => {
|
|
35
|
+
const router = useRouter();
|
|
36
|
+
return /* @__PURE__ */ React.createElement(DigiGOVNextAppWithTranslation, { ...props, router });
|
|
37
|
+
};
|
|
38
|
+
var App_default = DigiGOVNextApp;
|
|
30
39
|
export {
|
|
31
40
|
App_default as default
|
|
32
41
|
};
|
package/App.d.ts
CHANGED
|
@@ -2,16 +2,13 @@ import React from 'react';
|
|
|
2
2
|
import { i18n, TFunction } from 'i18next';
|
|
3
3
|
import { WithTranslation } from 'react-i18next';
|
|
4
4
|
import type { AppProps } from '@digigov/ui/app/App';
|
|
5
|
+
import { NextRouter } from 'next/router';
|
|
5
6
|
export interface DigiGOVNextAppProps extends AppProps, WithTranslation {
|
|
6
7
|
children?: React.ReactNode;
|
|
7
8
|
t: TFunction;
|
|
8
9
|
i18n: i18n;
|
|
9
10
|
ssr: boolean;
|
|
11
|
+
router: NextRouter;
|
|
10
12
|
}
|
|
11
|
-
declare const
|
|
12
|
-
|
|
13
|
-
router: import("next/router").Router;
|
|
14
|
-
__N_SSG?: boolean | undefined;
|
|
15
|
-
__N_SSP?: boolean | undefined;
|
|
16
|
-
}, keyof WithTranslation> & import("react-i18next").WithTranslationProps>;
|
|
17
|
-
export default DigiGOVNextAppWithTranslation;
|
|
13
|
+
declare const DigiGOVNextApp: (props: any) => React.JSX.Element;
|
|
14
|
+
export default DigiGOVNextApp;
|
package/App.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/App.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport { i18n, TFunction } from 'i18next';\nimport App from 'next/app';\nimport Head from 'next/head';\nimport { withTranslation, WithTranslation } from 'react-i18next';\nimport NextLink from '@digigov/nextjs/Link';\nimport DigiGOVApp, { StaticApp } from '@digigov/ui/app/App';\nimport type { AppProps } from '@digigov/ui/app/App';\nimport { I18NProvider } from '@digigov/ui/i18n';\nimport { LinkProvider } from '@digigov/ui/navigation/Link';\n\nexport interface DigiGOVNextAppProps extends AppProps, WithTranslation {\n children?: React.ReactNode;\n t: TFunction;\n i18n: i18n;\n ssr: boolean;\n}\nclass
|
|
5
|
-
"mappings": "AAAA,OAAO,WAAW;AAElB,OAAO,SAAS;AAChB,OAAO,UAAU;AACjB,SAAS,uBAAwC;AACjD,OAAO,cAAc;AACrB,OAAO,cAAc,iBAAiB;AAEtC,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { i18n, TFunction } from 'i18next';\nimport App from 'next/app';\nimport Head from 'next/head';\nimport { withTranslation, WithTranslation } from 'react-i18next';\nimport NextLink from '@digigov/nextjs/Link';\nimport DigiGOVApp, { StaticApp } from '@digigov/ui/app/App';\nimport type { AppProps } from '@digigov/ui/app/App';\nimport { I18NProvider } from '@digigov/ui/i18n';\nimport { LinkProvider } from '@digigov/ui/navigation/Link';\nimport { NextRouter, useRouter } from 'next/router';\n\nexport interface DigiGOVNextAppProps extends AppProps, WithTranslation {\n children?: React.ReactNode;\n t: TFunction;\n i18n: i18n;\n ssr: boolean;\n router: NextRouter;\n}\nclass DigiGOVNextAppClass extends App<DigiGOVNextAppProps> {\n render(): React.ReactElement {\n const { Component, pageProps, t, i18n, ssr = false, router } = this.props;\n const {locale} = router;\n \n if (locale && i18n.language != locale) { \n i18n.changeLanguage(locale);\n }\n return (\n <I18NProvider\n t={(str) => (typeof str === 'string' ? t(str) : str)}\n i18n={i18n}\n >\n <LinkProvider component={NextLink}>\n <Head>\n <meta\n name=\"viewport\"\n content=\"minimum-scale=1, initial-scale=1, width=device-width\"\n />\n </Head>\n {ssr ? (\n <DigiGOVApp>\n <Component {...pageProps} />\n </DigiGOVApp>\n ) : (\n <StaticApp>\n <Component {...pageProps} />\n </StaticApp>\n )}\n </LinkProvider>\n </I18NProvider>\n );\n }\n}\n\nconst DigiGOVNextAppWithTranslation = withTranslation()(DigiGOVNextAppClass);\nconst DigiGOVNextApp = (props) => {\n const router = useRouter()\n return <DigiGOVNextAppWithTranslation {...props} router={router} />\n}\nexport default DigiGOVNextApp;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,WAAW;AAElB,OAAO,SAAS;AAChB,OAAO,UAAU;AACjB,SAAS,uBAAwC;AACjD,OAAO,cAAc;AACrB,OAAO,cAAc,iBAAiB;AAEtC,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B,SAAqB,iBAAiB;AAStC,MAAM,4BAA4B,IAAyB;AAAA,EACzD,SAA6B;AAC3B,UAAM,EAAE,WAAW,WAAW,GAAG,MAAAA,OAAM,MAAM,OAAO,OAAO,IAAI,KAAK;AACpE,UAAM,EAAC,OAAM,IAAI;AAEjB,QAAI,UAAUA,MAAK,YAAY,QAAQ;AACrC,MAAAA,MAAK,eAAe,MAAM;AAAA,IAC5B;AACA,WACE;AAAA,MAAC;AAAA;AAAA,QACC,GAAG,CAAC,QAAS,OAAO,QAAQ,WAAW,EAAE,GAAG,IAAI;AAAA,QAChD,MAAMA;AAAA;AAAA,MAEN,oCAAC,gBAAa,WAAW,YACvB,oCAAC,YACC;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,SAAQ;AAAA;AAAA,MACV,CACF,GACC,MACC,oCAAC,kBACC,oCAAC,aAAW,GAAG,WAAW,CAC5B,IAEA,oCAAC,iBACC,oCAAC,aAAW,GAAG,WAAW,CAC5B,CAEJ;AAAA,IACF;AAAA,EAEJ;AACF;AAEA,MAAM,gCAAgC,gBAAgB,EAAE,mBAAmB;AAC3E,MAAM,iBAAiB,CAAC,UAAU;AAChC,QAAM,SAAS,UAAU;AACzB,SAAO,oCAAC,iCAA+B,GAAG,OAAO,QAAgB;AACnE;AACA,IAAO,cAAQ;",
|
|
6
6
|
"names": ["i18n"]
|
|
7
7
|
}
|
package/Document.d.ts
CHANGED
package/Image/index.js
CHANGED
|
@@ -2,8 +2,8 @@ import React from "react";
|
|
|
2
2
|
import NextImage from "next/image";
|
|
3
3
|
import { useBasePath } from "@digigov/nextjs/hooks";
|
|
4
4
|
const Image = ({ src, ...rest }) => {
|
|
5
|
-
const basePathSrc = useBasePath(src);
|
|
6
|
-
return /* @__PURE__ */ React.createElement(NextImage, { src: basePathSrc, ...rest });
|
|
5
|
+
const basePathSrc = useBasePath(typeof src === "string" ? src : "");
|
|
6
|
+
return /* @__PURE__ */ React.createElement(NextImage, { src: typeof src === "string" ? basePathSrc : src, ...rest });
|
|
7
7
|
};
|
|
8
8
|
var Image_default = Image;
|
|
9
9
|
export {
|
package/Image.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/Image.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport NextImage, { ImageProps } from 'next/image';\nimport { useBasePath } from '@digigov/nextjs/hooks';\n\nconst Image: React.FC<ImageProps> = ({ src, ...rest }) => {\n const basePathSrc = useBasePath(src);\n return <NextImage src={basePathSrc} {...rest}
|
|
5
|
-
"mappings": "AAAA,OAAO,WAAW;AAClB,OAAO,eAA+B;AACtC,SAAS,mBAAmB;AAE5B,MAAM,QAA8B,CAAC,EAAE,KAAK,GAAG,KAAK,MAAM;AACxD,QAAM,cAAc,YAAY,
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport NextImage, { ImageProps } from 'next/image';\nimport { useBasePath } from '@digigov/nextjs/hooks';\n\nconst Image: React.FC<ImageProps> = ({ src, ...rest }) => {\n const basePathSrc = useBasePath(typeof src === 'string' ? src : '');\n return (\n <NextImage src={typeof src === 'string' ? basePathSrc : src} {...rest} />\n );\n};\n\nexport default Image;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,WAAW;AAClB,OAAO,eAA+B;AACtC,SAAS,mBAAmB;AAE5B,MAAM,QAA8B,CAAC,EAAE,KAAK,GAAG,KAAK,MAAM;AACxD,QAAM,cAAc,YAAY,OAAO,QAAQ,WAAW,MAAM,EAAE;AAClE,SACE,oCAAC,aAAU,KAAK,OAAO,QAAQ,WAAW,cAAc,KAAM,GAAG,MAAM;AAE3E;AAEA,IAAO,gBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/Link/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect } from "react";
|
|
2
2
|
import Link from "next/link";
|
|
3
3
|
import { useRouter } from "next/router";
|
|
4
|
-
import LinkBase from "@digigov/
|
|
4
|
+
import { LinkBase } from "@digigov/ui/navigation/Link";
|
|
5
5
|
const NextLink = (props, ref) => {
|
|
6
6
|
const { href, ...other } = props;
|
|
7
7
|
const isExternalLink = (
|
package/Link.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { LinkProps } from '@digigov/ui/navigation/Link';
|
|
3
|
-
declare const _default: React.ForwardRefExoticComponent<
|
|
3
|
+
declare const _default: React.ForwardRefExoticComponent<Omit<LinkProps, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
|
|
4
4
|
export default _default;
|
package/Link.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/Link.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useEffect } from 'react';\nimport Link from 'next/link';\nimport { useRouter } from 'next/router';\nimport LinkBase from '@digigov/
|
|
5
|
-
"mappings": "AAAA,OAAO,SAAS,iBAAiB;AACjC,OAAO,UAAU;AACjB,SAAS,iBAAiB;AAC1B,
|
|
4
|
+
"sourcesContent": ["import React, { useEffect } from 'react';\nimport Link from 'next/link';\nimport { useRouter } from 'next/router';\nimport {LinkBase} from '@digigov/ui/navigation/Link';\nimport { LinkProps } from '@digigov/ui/navigation/Link';\n\nconst NextLink: React.ForwardRefRenderFunction<HTMLAnchorElement, LinkProps> = (\n props,\n ref\n) => {\n const { href, ...other } = props;\n const isExternalLink =\n //check if url has a file extension\n /^(?:[a-z]+:)?\\/\\/|.pdf|.docx?|.xlsx?/i.test(href || '') ||\n // or if props has a target or rel\n other.target === '_blank';\n const router = useRouter();\n\n useEffect(() => {\n const path = router.asPath;\n if (path && path.includes('#')) {\n setTimeout(() => {\n const id = path.replace('#', '');\n const el = window.document.getElementById(id);\n const r = el?.getBoundingClientRect();\n if (r) {\n window.top?.scroll({\n top: scrollY + r.top,\n behavior: 'smooth',\n });\n }\n }, 600);\n }\n }, [router.asPath]);\n\n if (isExternalLink) {\n return (\n <LinkBase ref={ref} href={href || '#'} {...other}>\n {props.children}\n </LinkBase>\n );\n }\n return (\n <Link href={href || '#'} {...other}>\n <LinkBase ref={ref} {...other}>\n {props.children}\n </LinkBase>\n </Link>\n );\n};\n\nexport default React.forwardRef(NextLink);\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS,iBAAiB;AACjC,OAAO,UAAU;AACjB,SAAS,iBAAiB;AAC1B,SAAQ,gBAAe;AAGvB,MAAM,WAAyE,CAC7E,OACA,QACG;AACH,QAAM,EAAE,MAAM,GAAG,MAAM,IAAI;AAC3B,QAAM;AAAA;AAAA,IAEJ,wCAAwC,KAAK,QAAQ,EAAE;AAAA,IAEvD,MAAM,WAAW;AAAA;AACnB,QAAM,SAAS,UAAU;AAEzB,YAAU,MAAM;AACd,UAAM,OAAO,OAAO;AACpB,QAAI,QAAQ,KAAK,SAAS,GAAG,GAAG;AAC9B,iBAAW,MAAM;AACf,cAAM,KAAK,KAAK,QAAQ,KAAK,EAAE;AAC/B,cAAM,KAAK,OAAO,SAAS,eAAe,EAAE;AAC5C,cAAM,IAAI,IAAI,sBAAsB;AACpC,YAAI,GAAG;AACL,iBAAO,KAAK,OAAO;AAAA,YACjB,KAAK,UAAU,EAAE;AAAA,YACjB,UAAU;AAAA,UACZ,CAAC;AAAA,QACH;AAAA,MACF,GAAG,GAAG;AAAA,IACR;AAAA,EACF,GAAG,CAAC,OAAO,MAAM,CAAC;AAElB,MAAI,gBAAgB;AAClB,WACE,oCAAC,YAAS,KAAU,MAAM,QAAQ,KAAM,GAAG,SACxC,MAAM,QACT;AAAA,EAEJ;AACA,SACE,oCAAC,QAAK,MAAM,QAAQ,KAAM,GAAG,SAC3B,oCAAC,YAAS,KAAW,GAAG,SACrB,MAAM,QACT,CACF;AAEJ;AAEA,IAAO,eAAQ,MAAM,WAAW,QAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/cjs/App/index.js
CHANGED
|
@@ -38,9 +38,14 @@ var import_Link = __toESM(require("@digigov/nextjs/Link"));
|
|
|
38
38
|
var import_App = __toESM(require("@digigov/ui/app/App"));
|
|
39
39
|
var import_i18n = require("@digigov/ui/i18n");
|
|
40
40
|
var import_Link2 = require("@digigov/ui/navigation/Link");
|
|
41
|
-
|
|
41
|
+
var import_router = require("next/router");
|
|
42
|
+
class DigiGOVNextAppClass extends import_app.default {
|
|
42
43
|
render() {
|
|
43
|
-
const { Component, pageProps, t, i18n: i18n2, ssr = false } = this.props;
|
|
44
|
+
const { Component, pageProps, t, i18n: i18n2, ssr = false, router } = this.props;
|
|
45
|
+
const { locale } = router;
|
|
46
|
+
if (locale && i18n2.language != locale) {
|
|
47
|
+
i18n2.changeLanguage(locale);
|
|
48
|
+
}
|
|
44
49
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
45
50
|
import_i18n.I18NProvider,
|
|
46
51
|
{
|
|
@@ -57,6 +62,10 @@ class DigiGOVNextApp extends import_app.default {
|
|
|
57
62
|
);
|
|
58
63
|
}
|
|
59
64
|
}
|
|
60
|
-
const DigiGOVNextAppWithTranslation = (0, import_react_i18next.withTranslation)()(
|
|
61
|
-
|
|
65
|
+
const DigiGOVNextAppWithTranslation = (0, import_react_i18next.withTranslation)()(DigiGOVNextAppClass);
|
|
66
|
+
const DigiGOVNextApp = (props) => {
|
|
67
|
+
const router = (0, import_router.useRouter)();
|
|
68
|
+
return /* @__PURE__ */ import_react.default.createElement(DigiGOVNextAppWithTranslation, { ...props, router });
|
|
69
|
+
};
|
|
70
|
+
var App_default = DigiGOVNextApp;
|
|
62
71
|
//# sourceMappingURL=App.js.map
|
package/cjs/App.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/App.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport { i18n, TFunction } from 'i18next';\nimport App from 'next/app';\nimport Head from 'next/head';\nimport { withTranslation, WithTranslation } from 'react-i18next';\nimport NextLink from '@digigov/nextjs/Link';\nimport DigiGOVApp, { StaticApp } from '@digigov/ui/app/App';\nimport type { AppProps } from '@digigov/ui/app/App';\nimport { I18NProvider } from '@digigov/ui/i18n';\nimport { LinkProvider } from '@digigov/ui/navigation/Link';\n\nexport interface DigiGOVNextAppProps extends AppProps, WithTranslation {\n children?: React.ReactNode;\n t: TFunction;\n i18n: i18n;\n ssr: boolean;\n}\nclass
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,iBAAgB;AAChB,kBAAiB;AACjB,2BAAiD;AACjD,kBAAqB;AACrB,iBAAsC;AAEtC,kBAA6B;AAC7B,IAAAA,eAA6B;
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { i18n, TFunction } from 'i18next';\nimport App from 'next/app';\nimport Head from 'next/head';\nimport { withTranslation, WithTranslation } from 'react-i18next';\nimport NextLink from '@digigov/nextjs/Link';\nimport DigiGOVApp, { StaticApp } from '@digigov/ui/app/App';\nimport type { AppProps } from '@digigov/ui/app/App';\nimport { I18NProvider } from '@digigov/ui/i18n';\nimport { LinkProvider } from '@digigov/ui/navigation/Link';\nimport { NextRouter, useRouter } from 'next/router';\n\nexport interface DigiGOVNextAppProps extends AppProps, WithTranslation {\n children?: React.ReactNode;\n t: TFunction;\n i18n: i18n;\n ssr: boolean;\n router: NextRouter;\n}\nclass DigiGOVNextAppClass extends App<DigiGOVNextAppProps> {\n render(): React.ReactElement {\n const { Component, pageProps, t, i18n, ssr = false, router } = this.props;\n const {locale} = router;\n \n if (locale && i18n.language != locale) { \n i18n.changeLanguage(locale);\n }\n return (\n <I18NProvider\n t={(str) => (typeof str === 'string' ? t(str) : str)}\n i18n={i18n}\n >\n <LinkProvider component={NextLink}>\n <Head>\n <meta\n name=\"viewport\"\n content=\"minimum-scale=1, initial-scale=1, width=device-width\"\n />\n </Head>\n {ssr ? (\n <DigiGOVApp>\n <Component {...pageProps} />\n </DigiGOVApp>\n ) : (\n <StaticApp>\n <Component {...pageProps} />\n </StaticApp>\n )}\n </LinkProvider>\n </I18NProvider>\n );\n }\n}\n\nconst DigiGOVNextAppWithTranslation = withTranslation()(DigiGOVNextAppClass);\nconst DigiGOVNextApp = (props) => {\n const router = useRouter()\n return <DigiGOVNextAppWithTranslation {...props} router={router} />\n}\nexport default DigiGOVNextApp;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,iBAAgB;AAChB,kBAAiB;AACjB,2BAAiD;AACjD,kBAAqB;AACrB,iBAAsC;AAEtC,kBAA6B;AAC7B,IAAAA,eAA6B;AAC7B,oBAAsC;AAStC,MAAM,4BAA4B,WAAAC,QAAyB;AAAA,EACzD,SAA6B;AAC3B,UAAM,EAAE,WAAW,WAAW,GAAG,MAAAC,OAAM,MAAM,OAAO,OAAO,IAAI,KAAK;AACpE,UAAM,EAAC,OAAM,IAAI;AAEjB,QAAI,UAAUA,MAAK,YAAY,QAAQ;AACrC,MAAAA,MAAK,eAAe,MAAM;AAAA,IAC5B;AACA,WACE,6BAAAC,QAAA;AAAA,MAAC;AAAA;AAAA,QACC,GAAG,CAAC,QAAS,OAAO,QAAQ,WAAW,EAAE,GAAG,IAAI;AAAA,QAChD,MAAMD;AAAA;AAAA,MAEN,6BAAAC,QAAA,cAAC,6BAAa,WAAW,YAAAC,WACvB,6BAAAD,QAAA,cAAC,YAAAE,SAAA,MACC,6BAAAF,QAAA;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,SAAQ;AAAA;AAAA,MACV,CACF,GACC,MACC,6BAAAA,QAAA,cAAC,WAAAG,SAAA,MACC,6BAAAH,QAAA,cAAC,aAAW,GAAG,WAAW,CAC5B,IAEA,6BAAAA,QAAA,cAAC,4BACC,6BAAAA,QAAA,cAAC,aAAW,GAAG,WAAW,CAC5B,CAEJ;AAAA,IACF;AAAA,EAEJ;AACF;AAEA,MAAM,oCAAgC,sCAAgB,EAAE,mBAAmB;AAC3E,MAAM,iBAAiB,CAAC,UAAU;AAChC,QAAM,aAAS,yBAAU;AACzB,SAAO,6BAAAA,QAAA,cAAC,iCAA+B,GAAG,OAAO,QAAgB;AACnE;AACA,IAAO,cAAQ;",
|
|
6
6
|
"names": ["import_Link", "App", "i18n", "React", "NextLink", "Head", "DigiGOVApp"]
|
|
7
7
|
}
|
package/cjs/Image/index.js
CHANGED
|
@@ -34,8 +34,8 @@ var import_react = __toESM(require("react"));
|
|
|
34
34
|
var import_image = __toESM(require("next/image"));
|
|
35
35
|
var import_hooks = require("@digigov/nextjs/hooks");
|
|
36
36
|
const Image = ({ src, ...rest }) => {
|
|
37
|
-
const basePathSrc = (0, import_hooks.useBasePath)(src);
|
|
38
|
-
return /* @__PURE__ */ import_react.default.createElement(import_image.default, { src: basePathSrc, ...rest });
|
|
37
|
+
const basePathSrc = (0, import_hooks.useBasePath)(typeof src === "string" ? src : "");
|
|
38
|
+
return /* @__PURE__ */ import_react.default.createElement(import_image.default, { src: typeof src === "string" ? basePathSrc : src, ...rest });
|
|
39
39
|
};
|
|
40
40
|
var Image_default = Image;
|
|
41
41
|
//# sourceMappingURL=Image.js.map
|
package/cjs/Image.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Image.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport NextImage, { ImageProps } from 'next/image';\nimport { useBasePath } from '@digigov/nextjs/hooks';\n\nconst Image: React.FC<ImageProps> = ({ src, ...rest }) => {\n const basePathSrc = useBasePath(src);\n return <NextImage src={basePathSrc} {...rest}
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,mBAAsC;AACtC,mBAA4B;AAE5B,MAAM,QAA8B,CAAC,EAAE,KAAK,GAAG,KAAK,MAAM;AACxD,QAAM,kBAAc,0BAAY,
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport NextImage, { ImageProps } from 'next/image';\nimport { useBasePath } from '@digigov/nextjs/hooks';\n\nconst Image: React.FC<ImageProps> = ({ src, ...rest }) => {\n const basePathSrc = useBasePath(typeof src === 'string' ? src : '');\n return (\n <NextImage src={typeof src === 'string' ? basePathSrc : src} {...rest} />\n );\n};\n\nexport default Image;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,mBAAsC;AACtC,mBAA4B;AAE5B,MAAM,QAA8B,CAAC,EAAE,KAAK,GAAG,KAAK,MAAM;AACxD,QAAM,kBAAc,0BAAY,OAAO,QAAQ,WAAW,MAAM,EAAE;AAClE,SACE,6BAAAA,QAAA,cAAC,aAAAC,SAAA,EAAU,KAAK,OAAO,QAAQ,WAAW,cAAc,KAAM,GAAG,MAAM;AAE3E;AAEA,IAAO,gBAAQ;",
|
|
6
6
|
"names": ["React", "NextImage"]
|
|
7
7
|
}
|
package/cjs/Link/index.js
CHANGED
|
@@ -33,7 +33,7 @@ module.exports = __toCommonJS(Link_exports);
|
|
|
33
33
|
var import_react = __toESM(require("react"));
|
|
34
34
|
var import_link = __toESM(require("next/link"));
|
|
35
35
|
var import_router = require("next/router");
|
|
36
|
-
var
|
|
36
|
+
var import_Link = require("@digigov/ui/navigation/Link");
|
|
37
37
|
const NextLink = (props, ref) => {
|
|
38
38
|
const { href, ...other } = props;
|
|
39
39
|
const isExternalLink = (
|
|
@@ -59,9 +59,9 @@ const NextLink = (props, ref) => {
|
|
|
59
59
|
}
|
|
60
60
|
}, [router.asPath]);
|
|
61
61
|
if (isExternalLink) {
|
|
62
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
62
|
+
return /* @__PURE__ */ import_react.default.createElement(import_Link.LinkBase, { ref, href: href || "#", ...other }, props.children);
|
|
63
63
|
}
|
|
64
|
-
return /* @__PURE__ */ import_react.default.createElement(import_link.default, { href: href || "#", ...other }, /* @__PURE__ */ import_react.default.createElement(
|
|
64
|
+
return /* @__PURE__ */ import_react.default.createElement(import_link.default, { href: href || "#", ...other }, /* @__PURE__ */ import_react.default.createElement(import_Link.LinkBase, { ref, ...other }, props.children));
|
|
65
65
|
};
|
|
66
66
|
var Link_default = import_react.default.forwardRef(NextLink);
|
|
67
67
|
//# sourceMappingURL=Link.js.map
|
package/cjs/Link.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Link.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useEffect } from 'react';\nimport Link from 'next/link';\nimport { useRouter } from 'next/router';\nimport LinkBase from '@digigov/
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAiC;AACjC,kBAAiB;AACjB,oBAA0B;AAC1B,
|
|
6
|
-
"names": ["React", "
|
|
4
|
+
"sourcesContent": ["import React, { useEffect } from 'react';\nimport Link from 'next/link';\nimport { useRouter } from 'next/router';\nimport {LinkBase} from '@digigov/ui/navigation/Link';\nimport { LinkProps } from '@digigov/ui/navigation/Link';\n\nconst NextLink: React.ForwardRefRenderFunction<HTMLAnchorElement, LinkProps> = (\n props,\n ref\n) => {\n const { href, ...other } = props;\n const isExternalLink =\n //check if url has a file extension\n /^(?:[a-z]+:)?\\/\\/|.pdf|.docx?|.xlsx?/i.test(href || '') ||\n // or if props has a target or rel\n other.target === '_blank';\n const router = useRouter();\n\n useEffect(() => {\n const path = router.asPath;\n if (path && path.includes('#')) {\n setTimeout(() => {\n const id = path.replace('#', '');\n const el = window.document.getElementById(id);\n const r = el?.getBoundingClientRect();\n if (r) {\n window.top?.scroll({\n top: scrollY + r.top,\n behavior: 'smooth',\n });\n }\n }, 600);\n }\n }, [router.asPath]);\n\n if (isExternalLink) {\n return (\n <LinkBase ref={ref} href={href || '#'} {...other}>\n {props.children}\n </LinkBase>\n );\n }\n return (\n <Link href={href || '#'} {...other}>\n <LinkBase ref={ref} {...other}>\n {props.children}\n </LinkBase>\n </Link>\n );\n};\n\nexport default React.forwardRef(NextLink);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAiC;AACjC,kBAAiB;AACjB,oBAA0B;AAC1B,kBAAuB;AAGvB,MAAM,WAAyE,CAC7E,OACA,QACG;AACH,QAAM,EAAE,MAAM,GAAG,MAAM,IAAI;AAC3B,QAAM;AAAA;AAAA,IAEJ,wCAAwC,KAAK,QAAQ,EAAE;AAAA,IAEvD,MAAM,WAAW;AAAA;AACnB,QAAM,aAAS,yBAAU;AAEzB,8BAAU,MAAM;AACd,UAAM,OAAO,OAAO;AACpB,QAAI,QAAQ,KAAK,SAAS,GAAG,GAAG;AAC9B,iBAAW,MAAM;AACf,cAAM,KAAK,KAAK,QAAQ,KAAK,EAAE;AAC/B,cAAM,KAAK,OAAO,SAAS,eAAe,EAAE;AAC5C,cAAM,IAAI,IAAI,sBAAsB;AACpC,YAAI,GAAG;AACL,iBAAO,KAAK,OAAO;AAAA,YACjB,KAAK,UAAU,EAAE;AAAA,YACjB,UAAU;AAAA,UACZ,CAAC;AAAA,QACH;AAAA,MACF,GAAG,GAAG;AAAA,IACR;AAAA,EACF,GAAG,CAAC,OAAO,MAAM,CAAC;AAElB,MAAI,gBAAgB;AAClB,WACE,6BAAAA,QAAA,cAAC,wBAAS,KAAU,MAAM,QAAQ,KAAM,GAAG,SACxC,MAAM,QACT;AAAA,EAEJ;AACA,SACE,6BAAAA,QAAA,cAAC,YAAAC,SAAA,EAAK,MAAM,QAAQ,KAAM,GAAG,SAC3B,6BAAAD,QAAA,cAAC,wBAAS,KAAW,GAAG,SACrB,MAAM,QACT,CACF;AAEJ;AAEA,IAAO,eAAQ,aAAAA,QAAM,WAAW,QAAQ;",
|
|
6
|
+
"names": ["React", "Link"]
|
|
7
7
|
}
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,30 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digigov/nextjs",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"description": "next specific utilities for @digigov apps",
|
|
5
5
|
"author": "GRNET Developers <devs@lists.grnet.gr>",
|
|
6
6
|
"license": "BSD-2-Clause",
|
|
7
7
|
"main": "./cjs/index.js",
|
|
8
8
|
"module": "./index.js",
|
|
9
9
|
"peerDependencies": {
|
|
10
|
-
"@digigov/ui": "
|
|
11
|
-
"@digigov/react-core": "2.0
|
|
10
|
+
"@digigov/ui": "1.1.4",
|
|
11
|
+
"@digigov/react-core": "1.2.0",
|
|
12
12
|
"clsx": "1.1.1",
|
|
13
13
|
"i18next": "19.1.0",
|
|
14
|
-
"react": "
|
|
15
|
-
"react-dom": "
|
|
16
|
-
"next": "
|
|
14
|
+
"react": ">=16.8.0 <19.0.0",
|
|
15
|
+
"react-dom": ">=16.8.0 <19.0.0",
|
|
16
|
+
"next": "13.1.1",
|
|
17
17
|
"react-i18next": "11.3.3"
|
|
18
18
|
},
|
|
19
19
|
"gitHead": "7237a2d58c6b30979837579e51251543aff0c240",
|
|
20
|
-
"exports": {
|
|
21
|
-
".": {
|
|
22
|
-
"require": "./index.js"
|
|
23
|
-
},
|
|
24
|
-
"./*": {
|
|
25
|
-
"require": "./cjs/*"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
20
|
"private": false,
|
|
29
21
|
"typings": "./index.d.ts"
|
|
30
22
|
}
|
package/src/App.tsx
CHANGED
|
@@ -8,16 +8,23 @@ import DigiGOVApp, { StaticApp } from '@digigov/ui/app/App';
|
|
|
8
8
|
import type { AppProps } from '@digigov/ui/app/App';
|
|
9
9
|
import { I18NProvider } from '@digigov/ui/i18n';
|
|
10
10
|
import { LinkProvider } from '@digigov/ui/navigation/Link';
|
|
11
|
+
import { NextRouter, useRouter } from 'next/router';
|
|
11
12
|
|
|
12
13
|
export interface DigiGOVNextAppProps extends AppProps, WithTranslation {
|
|
13
14
|
children?: React.ReactNode;
|
|
14
15
|
t: TFunction;
|
|
15
16
|
i18n: i18n;
|
|
16
17
|
ssr: boolean;
|
|
18
|
+
router: NextRouter;
|
|
17
19
|
}
|
|
18
|
-
class
|
|
20
|
+
class DigiGOVNextAppClass extends App<DigiGOVNextAppProps> {
|
|
19
21
|
render(): React.ReactElement {
|
|
20
|
-
const { Component, pageProps, t, i18n, ssr = false } = this.props;
|
|
22
|
+
const { Component, pageProps, t, i18n, ssr = false, router } = this.props;
|
|
23
|
+
const {locale} = router;
|
|
24
|
+
|
|
25
|
+
if (locale && i18n.language != locale) {
|
|
26
|
+
i18n.changeLanguage(locale);
|
|
27
|
+
}
|
|
21
28
|
return (
|
|
22
29
|
<I18NProvider
|
|
23
30
|
t={(str) => (typeof str === 'string' ? t(str) : str)}
|
|
@@ -44,5 +51,10 @@ class DigiGOVNextApp extends App<DigiGOVNextAppProps> {
|
|
|
44
51
|
);
|
|
45
52
|
}
|
|
46
53
|
}
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
|
|
55
|
+
const DigiGOVNextAppWithTranslation = withTranslation()(DigiGOVNextAppClass);
|
|
56
|
+
const DigiGOVNextApp = (props) => {
|
|
57
|
+
const router = useRouter()
|
|
58
|
+
return <DigiGOVNextAppWithTranslation {...props} router={router} />
|
|
59
|
+
}
|
|
60
|
+
export default DigiGOVNextApp;
|
package/src/Image.tsx
CHANGED
|
@@ -3,8 +3,10 @@ import NextImage, { ImageProps } from 'next/image';
|
|
|
3
3
|
import { useBasePath } from '@digigov/nextjs/hooks';
|
|
4
4
|
|
|
5
5
|
const Image: React.FC<ImageProps> = ({ src, ...rest }) => {
|
|
6
|
-
const basePathSrc = useBasePath(src);
|
|
7
|
-
return
|
|
6
|
+
const basePathSrc = useBasePath(typeof src === 'string' ? src : '');
|
|
7
|
+
return (
|
|
8
|
+
<NextImage src={typeof src === 'string' ? basePathSrc : src} {...rest} />
|
|
9
|
+
);
|
|
8
10
|
};
|
|
9
11
|
|
|
10
12
|
export default Image;
|
package/src/Link.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
2
|
import Link from 'next/link';
|
|
3
3
|
import { useRouter } from 'next/router';
|
|
4
|
-
import LinkBase from '@digigov/
|
|
4
|
+
import {LinkBase} from '@digigov/ui/navigation/Link';
|
|
5
5
|
import { LinkProps } from '@digigov/ui/navigation/Link';
|
|
6
6
|
|
|
7
7
|
const NextLink: React.ForwardRefRenderFunction<HTMLAnchorElement, LinkProps> = (
|