@digigov/nextjs 0.4.4 → 0.5.0
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.js +108 -0
- package/CHANGELOG.md +20 -1
- package/Document.js +152 -0
- package/{dist/libs/nextjs/src/index.d.ts → LICENSE} +0 -0
- package/Link.js +44 -0
- package/es/App.js +79 -0
- package/es/Document.js +129 -0
- package/es/Link.js +29 -0
- package/es/i18n.js +16 -0
- package/{src/index.ts → es/index.js} +0 -0
- package/esm/App.js +79 -0
- package/esm/Document.js +129 -0
- package/esm/Link.js +29 -0
- package/esm/i18n.js +16 -0
- package/esm/index.js +5 -0
- package/i18n.js +27 -0
- package/index.js +1 -0
- package/{dist/libs → libs}/nextjs/src/App.d.ts +0 -0
- package/{dist/libs → libs}/nextjs/src/Document.d.ts +0 -0
- package/{dist/libs → libs}/nextjs/src/Link.d.ts +0 -0
- package/{dist/libs → libs}/nextjs/src/i18n.d.ts +0 -0
- package/libs/nextjs/src/index.d.ts +0 -0
- package/{dist/libs → libs}/ui/src/app/App.d.ts +0 -0
- package/{dist/libs → libs}/ui/src/app/i18n.d.ts +2 -0
- package/{dist/libs → libs}/ui/src/core/Link/index.d.ts +0 -0
- package/{dist/libs → libs}/ui/src/locales/el.d.ts +7 -0
- package/{dist/libs → libs}/ui/src/themes/govgr.d.ts +0 -0
- package/{dist/libs-ui → libs-ui}/react-core/src/Link/index.d.ts +0 -0
- package/package.json +25 -38
- package/.eslintrc.js +0 -3
- package/.prettierrc.js +0 -3
- package/.rush/temp/shrinkwrap-deps.json +0 -263
- package/CHANGELOG.json +0 -753
- package/dist/node_modules/.pnpm-debug.log +0 -16
- package/nextjs.build.error.log +0 -3
- package/nextjs.build.log +0 -16
- package/src/App.tsx +0 -55
- package/src/Document.tsx +0 -86
- package/src/Link.tsx +0 -30
- package/src/i18n.tsx +0 -18
- package/tsconfig.json +0 -14
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"0 debug pnpm:scope": {
|
|
3
|
-
"selected": 1
|
|
4
|
-
},
|
|
5
|
-
"1 error pnpm": {
|
|
6
|
-
"message": {
|
|
7
|
-
"code": "ERR_PNPM_NO_IMPORTER_MANIFEST_FOUND"
|
|
8
|
-
},
|
|
9
|
-
"err": {
|
|
10
|
-
"name": "Error",
|
|
11
|
-
"message": "No package.json (or package.yaml, or package.json5) was found in \"/Users/dimitristsironis/grnet/digigov-sdk/libs/nextjs/dist\".",
|
|
12
|
-
"code": "ERR_PNPM_NO_IMPORTER_MANIFEST_FOUND",
|
|
13
|
-
"stack": "Error: No package.json (or package.yaml, or package.json5) was found in \"/Users/dimitristsironis/grnet/digigov-sdk/libs/nextjs/dist\".\n at Object.readProjectManifest [as default] (/Users/dimitristsironis/.rush/node-v14.18.1/pnpm-5.18.1/node_modules/pnpm/dist/pnpm.js:43067:11)\n at async Object.readProjectManifest (/Users/dimitristsironis/.rush/node-v14.18.1/pnpm-5.18.1/node_modules/pnpm/dist/pnpm.js:43280:56)\n at async fakeRegularManifest (/Users/dimitristsironis/.rush/node-v14.18.1/pnpm-5.18.1/node_modules/pnpm/dist/pnpm.js:118210:56)\n at async Object.handler [as publish] (/Users/dimitristsironis/.rush/node-v14.18.1/pnpm-5.18.1/node_modules/pnpm/dist/pnpm.js:118161:5)\n at async Timeout._onTimeout (/Users/dimitristsironis/.rush/node-v14.18.1/pnpm-5.18.1/node_modules/pnpm/dist/pnpm.js:123063:22)"
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
package/nextjs.build.error.log
DELETED
package/nextjs.build.log
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
Invoking: digigov build --subpackages
|
|
2
|
-
|
|
3
|
-
Debugger attached.
|
|
4
|
-
Running /Users/dimitristsironis/grnet/digigov-sdk/tooling/cli-build/node_modules/.bin/rimraf dist
|
|
5
|
-
Debugger attached.
|
|
6
|
-
Running /Users/dimitristsironis/grnet/digigov-sdk/tooling/cli-build/node_modules/.bin/tsc --emitDeclarationOnly --outDir dist
|
|
7
|
-
Debugger attached.
|
|
8
|
-
src/Link.tsx(12,26): error TS1109: Expression expected.
|
|
9
|
-
src/Link.tsx(12,28): error TS1109: Expression expected.
|
|
10
|
-
src/Link.tsx(12,29): error TS1109: Expression expected.
|
|
11
|
-
src/Link.tsx(12,36): error TS1109: Expression expected.
|
|
12
|
-
src/Link.tsx(12,37): error TS1134: Variable declaration expected.
|
|
13
|
-
src/Link.tsx(12,38): error TS1134: Variable declaration expected.
|
|
14
|
-
src/Link.tsx(12,39): error TS1127: Invalid character.
|
|
15
|
-
src/Link.tsx(12,40): error TS1134: Variable declaration expected.
|
|
16
|
-
src/Link.tsx(12,41): error TS1161: Unterminated regular expression literal.
|
package/src/App.tsx
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import App from 'next/app';
|
|
3
|
-
import Head from 'next/head';
|
|
4
|
-
import { Theme } from '@material-ui/core/styles';
|
|
5
|
-
import { LinkProvider } from '@digigov/ui/core/Link';
|
|
6
|
-
import NextLink from '@digigov/nextjs/Link';
|
|
7
|
-
import GovGRTheme from '@digigov/ui/themes/govgr';
|
|
8
|
-
import dynamic from 'next/dynamic';
|
|
9
|
-
import type { AppProps } from '@digigov/ui/app/App';
|
|
10
|
-
import { I18NProvider } from '@digigov/ui/app/i18n';
|
|
11
|
-
import { withTranslation, WithTranslation } from 'react-i18next';
|
|
12
|
-
import { i18n } from 'i18next';
|
|
13
|
-
|
|
14
|
-
const DigiGOVApp = dynamic(() => import('@digigov/ui/app/App'), {
|
|
15
|
-
ssr: false,
|
|
16
|
-
}) as React.FC<AppProps>;
|
|
17
|
-
export interface DigiGOVNextAppProps extends AppProps, WithTranslation {
|
|
18
|
-
children?: React.ReactNode;
|
|
19
|
-
theme: Theme;
|
|
20
|
-
t: (string) => string;
|
|
21
|
-
i18n: i18n;
|
|
22
|
-
}
|
|
23
|
-
class DigiGOVNextApp extends App<DigiGOVNextAppProps> {
|
|
24
|
-
componentDidMount(): void {
|
|
25
|
-
// Remove the server-side injected CSS.
|
|
26
|
-
const jssStyles = document.querySelector('#jss-server-side');
|
|
27
|
-
if (jssStyles && jssStyles.parentElement) {
|
|
28
|
-
jssStyles.parentElement.removeChild(jssStyles);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
render(): React.ReactElement {
|
|
33
|
-
const { Component, pageProps, theme, t, i18n } = this.props;
|
|
34
|
-
return (
|
|
35
|
-
<I18NProvider t={t} i18n={i18n}>
|
|
36
|
-
<LinkProvider component={NextLink}>
|
|
37
|
-
<Head>
|
|
38
|
-
<meta
|
|
39
|
-
name="viewport"
|
|
40
|
-
content="minimum-scale=1, initial-scale=1, width=device-width"
|
|
41
|
-
/>
|
|
42
|
-
</Head>
|
|
43
|
-
<DigiGOVApp theme={theme}>
|
|
44
|
-
<Component {...pageProps} />
|
|
45
|
-
</DigiGOVApp>
|
|
46
|
-
</LinkProvider>
|
|
47
|
-
</I18NProvider>
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
const DigiGOVNextAppWithTranslation = withTranslation()(DigiGOVNextApp);
|
|
52
|
-
DigiGOVNextAppWithTranslation.defaultProps = {
|
|
53
|
-
theme: GovGRTheme,
|
|
54
|
-
};
|
|
55
|
-
export default DigiGOVNextAppWithTranslation;
|
package/src/Document.tsx
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import Document, { Html, Head, Main, NextScript } from 'next/document';
|
|
4
|
-
import { ServerStyleSheets } from '@material-ui/core/styles';
|
|
5
|
-
|
|
6
|
-
export function Fonts() {
|
|
7
|
-
return (
|
|
8
|
-
<>
|
|
9
|
-
<link
|
|
10
|
-
rel="stylesheet"
|
|
11
|
-
href="https://fonts.googleapis.com/icon?family=Material+Icons"
|
|
12
|
-
/>
|
|
13
|
-
<link
|
|
14
|
-
rel="stylesheet"
|
|
15
|
-
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"
|
|
16
|
-
/>
|
|
17
|
-
</>
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
export default class DigiGOVDocument extends Document {
|
|
21
|
-
render() {
|
|
22
|
-
return (
|
|
23
|
-
<Html>
|
|
24
|
-
<Head>
|
|
25
|
-
<script
|
|
26
|
-
type="text/javascript"
|
|
27
|
-
dangerouslySetInnerHTML={{
|
|
28
|
-
__html: `if (window.document.documentMode) alert('Internet Explorer is not supported. Please use a modern browser!');
|
|
29
|
-
`,
|
|
30
|
-
}}
|
|
31
|
-
></script>
|
|
32
|
-
{/* PWA primary color */}
|
|
33
|
-
<Fonts />
|
|
34
|
-
</Head>
|
|
35
|
-
<body>
|
|
36
|
-
<Main />
|
|
37
|
-
<NextScript />
|
|
38
|
-
</body>
|
|
39
|
-
</Html>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
DigiGOVDocument.getInitialProps = async (ctx) => {
|
|
45
|
-
// Resolution order
|
|
46
|
-
//
|
|
47
|
-
// On the server:
|
|
48
|
-
// 1. app.getInitialProps
|
|
49
|
-
// 2. page.getInitialProps
|
|
50
|
-
// 3. document.getInitialProps
|
|
51
|
-
// 4. app.render
|
|
52
|
-
// 5. page.render
|
|
53
|
-
// 6. document.render
|
|
54
|
-
//
|
|
55
|
-
// On the server with error:
|
|
56
|
-
// 1. document.getInitialProps
|
|
57
|
-
// 2. app.render
|
|
58
|
-
// 3. page.render
|
|
59
|
-
// 4. document.render
|
|
60
|
-
//
|
|
61
|
-
// On the client
|
|
62
|
-
// 1. app.getInitialProps
|
|
63
|
-
// 2. page.getInitialProps
|
|
64
|
-
// 3. app.render
|
|
65
|
-
// 4. page.render
|
|
66
|
-
|
|
67
|
-
// Render app and page and get the context of the page with collected side effects.
|
|
68
|
-
const sheets = new ServerStyleSheets();
|
|
69
|
-
const originalRenderPage = ctx.renderPage;
|
|
70
|
-
|
|
71
|
-
ctx.renderPage = () =>
|
|
72
|
-
originalRenderPage({
|
|
73
|
-
enhanceApp: (App) => (props) => sheets.collect(<App {...props} />),
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
const initialProps = await Document.getInitialProps(ctx);
|
|
77
|
-
|
|
78
|
-
return {
|
|
79
|
-
...initialProps,
|
|
80
|
-
// Styles fragment is rendered after the app and page rendering finish.
|
|
81
|
-
styles: [
|
|
82
|
-
...React.Children.toArray(initialProps.styles),
|
|
83
|
-
sheets.getStyleElement(),
|
|
84
|
-
],
|
|
85
|
-
};
|
|
86
|
-
};
|
package/src/Link.tsx
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
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
|
-
//check if url has a domain
|
|
12
|
-
const isExternalLink = ^(?:[a-z]+:)?\/\/|.pdf|.docx?|.xlsx?i.test(href || '');
|
|
13
|
-
|
|
14
|
-
if (isExternalLink) {
|
|
15
|
-
return (
|
|
16
|
-
<CoreLink ref={ref} href={href || '#'} {...other}>
|
|
17
|
-
{props.children}
|
|
18
|
-
</CoreLink>
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
return (
|
|
22
|
-
<Link href={href || '#'} {...other}>
|
|
23
|
-
<CoreLink ref={ref} {...other}>
|
|
24
|
-
{props.children}
|
|
25
|
-
</CoreLink>
|
|
26
|
-
</Link>
|
|
27
|
-
);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export default React.forwardRef(NextLink);
|
package/src/i18n.tsx
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
}
|