@digigov/nextjs 1.1.5-85c27c19 → 1.1.5-b4cd6916
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/Link/index.js +2 -2
- package/Link.js.map +2 -2
- package/cjs/Link/index.js +2 -2
- package/cjs/Link.js.map +2 -2
- package/index.js +1 -1
- package/package.json +3 -3
- package/src/Link.tsx +6 -3
package/Link/index.js
CHANGED
|
@@ -5,8 +5,8 @@ import { LinkBase } from "@digigov/ui/navigation/Link";
|
|
|
5
5
|
const NextLink = (props, ref) => {
|
|
6
6
|
const { href, ...other } = props;
|
|
7
7
|
const isExternalLink = (
|
|
8
|
-
//check if url has a file extension
|
|
9
|
-
/^(?:[a-z]+:)
|
|
8
|
+
//check if url has a file extension or starts with mailto
|
|
9
|
+
/^(?:[a-z]+:)?\/\/|\.pdf|\.docx?|\.xlsx?|^mailto:/i.test(href || "") || // or if props has a target or rel
|
|
10
10
|
other.target === "_blank"
|
|
11
11
|
);
|
|
12
12
|
const router = useRouter();
|
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/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]+:)
|
|
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\n const isExternalLink =\n //check if url has a file extension or starts with mailto\n /^(?:[a-z]+:)?\\/\\/|\\.pdf|\\.docx?|\\.xlsx?|^mailto:/i.test(href || '') ||\n // or if props has a target or rel\n other.target === '_blank';\n\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\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,SAAS,gBAAgB;AAGzB,MAAM,WAAyE,CAC7E,OACA,QACG;AACH,QAAM,EAAE,MAAM,GAAG,MAAM,IAAI;AAE3B,QAAM;AAAA;AAAA,IAEJ,oDAAoD,KAAK,QAAQ,EAAE;AAAA,IAEnE,MAAM,WAAW;AAAA;AAEnB,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;AAEA,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/Link/index.js
CHANGED
|
@@ -37,8 +37,8 @@ var import_Link = require("@digigov/ui/navigation/Link");
|
|
|
37
37
|
const NextLink = (props, ref) => {
|
|
38
38
|
const { href, ...other } = props;
|
|
39
39
|
const isExternalLink = (
|
|
40
|
-
//check if url has a file extension
|
|
41
|
-
/^(?:[a-z]+:)
|
|
40
|
+
//check if url has a file extension or starts with mailto
|
|
41
|
+
/^(?:[a-z]+:)?\/\/|\.pdf|\.docx?|\.xlsx?|^mailto:/i.test(href || "") || // or if props has a target or rel
|
|
42
42
|
other.target === "_blank"
|
|
43
43
|
);
|
|
44
44
|
const router = (0, import_router.useRouter)();
|
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/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]+:)
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAiC;AACjC,kBAAiB;AACjB,oBAA0B;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\n const isExternalLink =\n //check if url has a file extension or starts with mailto\n /^(?:[a-z]+:)?\\/\\/|\\.pdf|\\.docx?|\\.xlsx?|^mailto:/i.test(href || '') ||\n // or if props has a target or rel\n other.target === '_blank';\n\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\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,kBAAyB;AAGzB,MAAM,WAAyE,CAC7E,OACA,QACG;AACH,QAAM,EAAE,MAAM,GAAG,MAAM,IAAI;AAE3B,QAAM;AAAA;AAAA,IAEJ,oDAAoD,KAAK,QAAQ,EAAE;AAAA,IAEnE,MAAM,WAAW;AAAA;AAEnB,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;AAEA,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
6
|
"names": ["React", "Link"]
|
|
7
7
|
}
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digigov/nextjs",
|
|
3
|
-
"version": "1.1.5-
|
|
3
|
+
"version": "1.1.5-b4cd6916",
|
|
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": "2.0.0-
|
|
11
|
-
"@digigov/react-core": "2.0.0-
|
|
10
|
+
"@digigov/ui": "2.0.0-b4cd6916",
|
|
11
|
+
"@digigov/react-core": "2.0.0-b4cd6916",
|
|
12
12
|
"clsx": "1.1.1",
|
|
13
13
|
"i18next": "19.1.0",
|
|
14
14
|
"react": ">=16.8.0 <19.0.0",
|
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/ui/navigation/Link';
|
|
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> = (
|
|
@@ -9,11 +9,13 @@ const NextLink: React.ForwardRefRenderFunction<HTMLAnchorElement, LinkProps> = (
|
|
|
9
9
|
ref
|
|
10
10
|
) => {
|
|
11
11
|
const { href, ...other } = props;
|
|
12
|
+
|
|
12
13
|
const isExternalLink =
|
|
13
|
-
//check if url has a file extension
|
|
14
|
-
/^(?:[a-z]+:)
|
|
14
|
+
//check if url has a file extension or starts with mailto
|
|
15
|
+
/^(?:[a-z]+:)?\/\/|\.pdf|\.docx?|\.xlsx?|^mailto:/i.test(href || '') ||
|
|
15
16
|
// or if props has a target or rel
|
|
16
17
|
other.target === '_blank';
|
|
18
|
+
|
|
17
19
|
const router = useRouter();
|
|
18
20
|
|
|
19
21
|
useEffect(() => {
|
|
@@ -40,6 +42,7 @@ const NextLink: React.ForwardRefRenderFunction<HTMLAnchorElement, LinkProps> = (
|
|
|
40
42
|
</LinkBase>
|
|
41
43
|
);
|
|
42
44
|
}
|
|
45
|
+
|
|
43
46
|
return (
|
|
44
47
|
<Link href={href || '#'} {...other}>
|
|
45
48
|
<LinkBase ref={ref} {...other}>
|