@digigov/nextjs 0.6.2 → 0.6.3-alpha

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.
Files changed (53) hide show
  1. package/.eslintrc.js +3 -0
  2. package/.prettierrc.js +3 -0
  3. package/.rush/temp/package-deps_build.json +21 -0
  4. package/.rush/temp/shrinkwrap-deps.json +334 -0
  5. package/CHANGELOG.json +918 -0
  6. package/{App.js → dist/App.js} +0 -0
  7. package/dist/CHANGELOG.md +248 -0
  8. package/{Document.js → dist/Document.js} +0 -0
  9. package/{Image.js → dist/Image.js} +0 -0
  10. package/{LICENSE → dist/LICENSE} +0 -0
  11. package/{Link.js → dist/Link.js} +0 -0
  12. package/dist/README.md +52 -0
  13. package/{es → dist/es}/App.js +0 -0
  14. package/{es → dist/es}/Document.js +0 -0
  15. package/{es → dist/es}/Image.js +0 -0
  16. package/{es → dist/es}/Link.js +0 -0
  17. package/{es → dist/es}/hooks.js +0 -0
  18. package/{es → dist/es}/i18n.js +0 -0
  19. package/{es → dist/es}/index.js +0 -0
  20. package/{esm → dist/esm}/App.js +0 -0
  21. package/{esm → dist/esm}/Document.js +0 -0
  22. package/{esm → dist/esm}/Image.js +0 -0
  23. package/{esm → dist/esm}/Link.js +0 -0
  24. package/{esm → dist/esm}/hooks.js +0 -0
  25. package/{esm → dist/esm}/i18n.js +0 -0
  26. package/{esm → dist/esm}/index.js +0 -0
  27. package/{hooks.js → dist/hooks.js} +0 -0
  28. package/{i18n.js → dist/i18n.js} +0 -0
  29. package/{index.js → dist/index.js} +0 -0
  30. package/{libs → dist/libs}/nextjs/src/App.d.ts +0 -0
  31. package/{libs → dist/libs}/nextjs/src/Document.d.ts +0 -0
  32. package/{libs → dist/libs}/nextjs/src/Image.d.ts +0 -0
  33. package/{libs → dist/libs}/nextjs/src/Link.d.ts +0 -0
  34. package/{libs → dist/libs}/nextjs/src/hooks.d.ts +0 -0
  35. package/{libs → dist/libs}/nextjs/src/i18n.d.ts +0 -0
  36. package/{libs → dist/libs}/nextjs/src/index.d.ts +0 -0
  37. package/{libs → dist/libs}/ui/src/app/App.d.ts +0 -0
  38. package/{libs → dist/libs}/ui/src/app/i18n.d.ts +0 -0
  39. package/{libs → dist/libs}/ui/src/core/Link/index.d.ts +0 -0
  40. package/{libs → dist/libs}/ui/src/locales/el.d.ts +1 -1
  41. package/{libs-ui → dist/libs-ui}/react-core/src/Base/index.d.ts +0 -0
  42. package/{libs-ui → dist/libs-ui}/react-core/src/Link/index.d.ts +0 -0
  43. package/dist/package.json +26 -0
  44. package/nextjs.build.log +17 -0
  45. package/package.json +38 -25
  46. package/src/App.tsx +52 -0
  47. package/src/Document.tsx +86 -0
  48. package/src/Image.tsx +10 -0
  49. package/src/Link.tsx +33 -0
  50. package/src/hooks.ts +6 -0
  51. package/src/i18n.tsx +18 -0
  52. package/src/index.ts +0 -0
  53. package/tsconfig.json +14 -0
package/src/Link.tsx ADDED
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { LinkProps } from '@digigov/ui/core/Link';
3
+ import Link from 'next/link';
4
+ import CoreLink from '@digigov/react-core/Link';
5
+
6
+ const NextLink: React.ForwardRefRenderFunction<HTMLAnchorElement, LinkProps> = (
7
+ props,
8
+ ref
9
+ ) => {
10
+ const { href, ...other } = props;
11
+ const isExternalLink =
12
+ //check if url has a file extension
13
+ /^(?:[a-z]+:)?\/\/|.pdf|.docx?|.xlsx?/i.test(href || '') ||
14
+ // or if props has a target or rel
15
+ other.target === '_blank';
16
+
17
+ if (isExternalLink) {
18
+ return (
19
+ <CoreLink ref={ref} href={href || '#'} {...other}>
20
+ {props.children}
21
+ </CoreLink>
22
+ );
23
+ }
24
+ return (
25
+ <Link href={href || '#'} {...other}>
26
+ <CoreLink ref={ref} {...other}>
27
+ {props.children}
28
+ </CoreLink>
29
+ </Link>
30
+ );
31
+ };
32
+
33
+ export default React.forwardRef(NextLink);
package/src/hooks.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { useRouter } from 'next/router';
2
+
3
+ export function useBasePath(src: string): string {
4
+ const router = useRouter();
5
+ return router.basePath + src;
6
+ }
package/src/i18n.tsx ADDED
@@ -0,0 +1,18 @@
1
+ import i18n, { Resource, TFunction } from 'i18next';
2
+ import { initReactI18next } from 'react-i18next';
3
+
4
+ export default function initI18n(
5
+ resources: Resource,
6
+ language = 'el'
7
+ ): Promise<TFunction> {
8
+ return i18n
9
+ .use(initReactI18next) // passes i18n down to react-i18next
10
+ .init({
11
+ resources: resources,
12
+ lng: language,
13
+ keySeparator: '.', // we use keys in form messages.welcome
14
+ interpolation: {
15
+ escapeValue: false, // react already safes from xss
16
+ },
17
+ });
18
+ }
package/src/index.ts ADDED
File without changes
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "@digigov/cli-build/tsconfig.base",
3
+ "compilerOptions": {
4
+ "outDir": "dist"
5
+ },
6
+ "include": [
7
+ "./src"
8
+ ],
9
+ "exclude": [
10
+ "node_modules",
11
+ "dist",
12
+ "*.svg"
13
+ ]
14
+ }