@digigov/nextjs 1.0.0-8bbf3ef2 → 1.0.0-eb2842b4
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 +11 -39
- package/es/App.js +5 -30
- package/esm/App.js +5 -30
- package/esm/index.js +1 -1
- package/libs/nextjs/src/App.d.ts +3 -2
- package/package.json +2 -2
- package/src/App.tsx +15 -27
package/App.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
8
10
|
exports["default"] = void 0;
|
|
9
11
|
|
|
10
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
-
|
|
12
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
13
|
|
|
14
14
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -29,27 +29,19 @@ var _Link = require("@digigov/ui/navigation/Link");
|
|
|
29
29
|
|
|
30
30
|
var _Link2 = _interopRequireDefault(require("@digigov/nextjs/Link"));
|
|
31
31
|
|
|
32
|
-
var
|
|
32
|
+
var _App2 = _interopRequireWildcard(require("@digigov/ui/app/App"));
|
|
33
33
|
|
|
34
34
|
var _i18n = require("@digigov/ui/i18n");
|
|
35
35
|
|
|
36
36
|
var _reactI18next = require("react-i18next");
|
|
37
37
|
|
|
38
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
39
|
-
|
|
40
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
41
|
-
|
|
42
38
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
43
39
|
|
|
44
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || (
|
|
40
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
45
41
|
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
}, {
|
|
51
|
-
ssr: false
|
|
52
|
-
});
|
|
42
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
43
|
+
|
|
44
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
53
45
|
|
|
54
46
|
var _ref = /*#__PURE__*/_react["default"].createElement(_head["default"], null, /*#__PURE__*/_react["default"].createElement("meta", {
|
|
55
47
|
name: "viewport",
|
|
@@ -67,35 +59,15 @@ var DigiGOVNextApp = /*#__PURE__*/function (_App) {
|
|
|
67
59
|
}
|
|
68
60
|
|
|
69
61
|
(0, _createClass2["default"])(DigiGOVNextApp, [{
|
|
70
|
-
key: "componentDidMount",
|
|
71
|
-
value: function componentDidMount() {
|
|
72
|
-
// Remove the server-side injected CSS.
|
|
73
|
-
var jssStyles = document.querySelector('#jss-server-side');
|
|
74
|
-
|
|
75
|
-
if (jssStyles && jssStyles.parentElement) {
|
|
76
|
-
jssStyles.parentElement.removeChild(jssStyles);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
this.updateHtmlLang();
|
|
80
|
-
}
|
|
81
|
-
}, {
|
|
82
|
-
key: "componentDidUpdate",
|
|
83
|
-
value: function componentDidUpdate() {
|
|
84
|
-
this.updateHtmlLang();
|
|
85
|
-
}
|
|
86
|
-
}, {
|
|
87
|
-
key: "updateHtmlLang",
|
|
88
|
-
value: function updateHtmlLang() {
|
|
89
|
-
document.documentElement.lang = this.props.i18n.language;
|
|
90
|
-
}
|
|
91
|
-
}, {
|
|
92
62
|
key: "render",
|
|
93
63
|
value: function render() {
|
|
94
64
|
var _this$props = this.props,
|
|
95
65
|
Component = _this$props.Component,
|
|
96
66
|
pageProps = _this$props.pageProps,
|
|
97
67
|
_t = _this$props.t,
|
|
98
|
-
i18n = _this$props.i18n
|
|
68
|
+
i18n = _this$props.i18n,
|
|
69
|
+
_this$props$ssr = _this$props.ssr,
|
|
70
|
+
ssr = _this$props$ssr === void 0 ? false : _this$props$ssr;
|
|
99
71
|
return /*#__PURE__*/_react["default"].createElement(_i18n.I18NProvider, {
|
|
100
72
|
t: function t(str) {
|
|
101
73
|
return typeof str === 'string' ? _t(str) : str;
|
|
@@ -103,7 +75,7 @@ var DigiGOVNextApp = /*#__PURE__*/function (_App) {
|
|
|
103
75
|
i18n: i18n
|
|
104
76
|
}, /*#__PURE__*/_react["default"].createElement(_Link.LinkProvider, {
|
|
105
77
|
component: _Link2["default"]
|
|
106
|
-
}, _ref, /*#__PURE__*/_react["default"].createElement(
|
|
78
|
+
}, _ref, ssr ? /*#__PURE__*/_react["default"].createElement(_App2["default"], null, /*#__PURE__*/_react["default"].createElement(Component, pageProps)) : /*#__PURE__*/_react["default"].createElement(_App2.StaticApp, null, /*#__PURE__*/_react["default"].createElement(Component, pageProps))));
|
|
107
79
|
}
|
|
108
80
|
}]);
|
|
109
81
|
return DigiGOVNextApp;
|
package/es/App.js
CHANGED
|
@@ -13,14 +13,9 @@ import App from 'next/app';
|
|
|
13
13
|
import Head from 'next/head';
|
|
14
14
|
import { LinkProvider } from '@digigov/ui/navigation/Link';
|
|
15
15
|
import NextLink from '@digigov/nextjs/Link';
|
|
16
|
-
import
|
|
16
|
+
import DigiGOVApp, { StaticApp } from '@digigov/ui/app/App';
|
|
17
17
|
import { I18NProvider } from '@digigov/ui/i18n';
|
|
18
18
|
import { withTranslation } from 'react-i18next';
|
|
19
|
-
var DigiGOVApp = dynamic(function () {
|
|
20
|
-
return import('@digigov/ui/app/App');
|
|
21
|
-
}, {
|
|
22
|
-
ssr: false
|
|
23
|
-
});
|
|
24
19
|
|
|
25
20
|
var _ref = /*#__PURE__*/React.createElement(Head, null, /*#__PURE__*/React.createElement("meta", {
|
|
26
21
|
name: "viewport",
|
|
@@ -39,35 +34,15 @@ var DigiGOVNextApp = /*#__PURE__*/function (_App) {
|
|
|
39
34
|
}
|
|
40
35
|
|
|
41
36
|
_createClass(DigiGOVNextApp, [{
|
|
42
|
-
key: "componentDidMount",
|
|
43
|
-
value: function componentDidMount() {
|
|
44
|
-
// Remove the server-side injected CSS.
|
|
45
|
-
var jssStyles = document.querySelector('#jss-server-side');
|
|
46
|
-
|
|
47
|
-
if (jssStyles && jssStyles.parentElement) {
|
|
48
|
-
jssStyles.parentElement.removeChild(jssStyles);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
this.updateHtmlLang();
|
|
52
|
-
}
|
|
53
|
-
}, {
|
|
54
|
-
key: "componentDidUpdate",
|
|
55
|
-
value: function componentDidUpdate() {
|
|
56
|
-
this.updateHtmlLang();
|
|
57
|
-
}
|
|
58
|
-
}, {
|
|
59
|
-
key: "updateHtmlLang",
|
|
60
|
-
value: function updateHtmlLang() {
|
|
61
|
-
document.documentElement.lang = this.props.i18n.language;
|
|
62
|
-
}
|
|
63
|
-
}, {
|
|
64
37
|
key: "render",
|
|
65
38
|
value: function render() {
|
|
66
39
|
var _this$props = this.props,
|
|
67
40
|
Component = _this$props.Component,
|
|
68
41
|
pageProps = _this$props.pageProps,
|
|
69
42
|
_t = _this$props.t,
|
|
70
|
-
i18n = _this$props.i18n
|
|
43
|
+
i18n = _this$props.i18n,
|
|
44
|
+
_this$props$ssr = _this$props.ssr,
|
|
45
|
+
ssr = _this$props$ssr === void 0 ? false : _this$props$ssr;
|
|
71
46
|
return /*#__PURE__*/React.createElement(I18NProvider, {
|
|
72
47
|
t: function t(str) {
|
|
73
48
|
return typeof str === 'string' ? _t(str) : str;
|
|
@@ -75,7 +50,7 @@ var DigiGOVNextApp = /*#__PURE__*/function (_App) {
|
|
|
75
50
|
i18n: i18n
|
|
76
51
|
}, /*#__PURE__*/React.createElement(LinkProvider, {
|
|
77
52
|
component: NextLink
|
|
78
|
-
}, _ref, /*#__PURE__*/React.createElement(DigiGOVApp, null, /*#__PURE__*/React.createElement(Component, pageProps))));
|
|
53
|
+
}, _ref, ssr ? /*#__PURE__*/React.createElement(DigiGOVApp, null, /*#__PURE__*/React.createElement(Component, pageProps)) : /*#__PURE__*/React.createElement(StaticApp, null, /*#__PURE__*/React.createElement(Component, pageProps))));
|
|
79
54
|
}
|
|
80
55
|
}]);
|
|
81
56
|
|
package/esm/App.js
CHANGED
|
@@ -13,14 +13,9 @@ import App from 'next/app';
|
|
|
13
13
|
import Head from 'next/head';
|
|
14
14
|
import { LinkProvider } from '@digigov/ui/navigation/Link';
|
|
15
15
|
import NextLink from '@digigov/nextjs/Link';
|
|
16
|
-
import
|
|
16
|
+
import DigiGOVApp, { StaticApp } from '@digigov/ui/app/App';
|
|
17
17
|
import { I18NProvider } from '@digigov/ui/i18n';
|
|
18
18
|
import { withTranslation } from 'react-i18next';
|
|
19
|
-
var DigiGOVApp = dynamic(function () {
|
|
20
|
-
return import('@digigov/ui/app/App');
|
|
21
|
-
}, {
|
|
22
|
-
ssr: false
|
|
23
|
-
});
|
|
24
19
|
|
|
25
20
|
var _ref = /*#__PURE__*/React.createElement(Head, null, /*#__PURE__*/React.createElement("meta", {
|
|
26
21
|
name: "viewport",
|
|
@@ -39,35 +34,15 @@ var DigiGOVNextApp = /*#__PURE__*/function (_App) {
|
|
|
39
34
|
}
|
|
40
35
|
|
|
41
36
|
_createClass(DigiGOVNextApp, [{
|
|
42
|
-
key: "componentDidMount",
|
|
43
|
-
value: function componentDidMount() {
|
|
44
|
-
// Remove the server-side injected CSS.
|
|
45
|
-
var jssStyles = document.querySelector('#jss-server-side');
|
|
46
|
-
|
|
47
|
-
if (jssStyles && jssStyles.parentElement) {
|
|
48
|
-
jssStyles.parentElement.removeChild(jssStyles);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
this.updateHtmlLang();
|
|
52
|
-
}
|
|
53
|
-
}, {
|
|
54
|
-
key: "componentDidUpdate",
|
|
55
|
-
value: function componentDidUpdate() {
|
|
56
|
-
this.updateHtmlLang();
|
|
57
|
-
}
|
|
58
|
-
}, {
|
|
59
|
-
key: "updateHtmlLang",
|
|
60
|
-
value: function updateHtmlLang() {
|
|
61
|
-
document.documentElement.lang = this.props.i18n.language;
|
|
62
|
-
}
|
|
63
|
-
}, {
|
|
64
37
|
key: "render",
|
|
65
38
|
value: function render() {
|
|
66
39
|
var _this$props = this.props,
|
|
67
40
|
Component = _this$props.Component,
|
|
68
41
|
pageProps = _this$props.pageProps,
|
|
69
42
|
_t = _this$props.t,
|
|
70
|
-
i18n = _this$props.i18n
|
|
43
|
+
i18n = _this$props.i18n,
|
|
44
|
+
_this$props$ssr = _this$props.ssr,
|
|
45
|
+
ssr = _this$props$ssr === void 0 ? false : _this$props$ssr;
|
|
71
46
|
return /*#__PURE__*/React.createElement(I18NProvider, {
|
|
72
47
|
t: function t(str) {
|
|
73
48
|
return typeof str === 'string' ? _t(str) : str;
|
|
@@ -75,7 +50,7 @@ var DigiGOVNextApp = /*#__PURE__*/function (_App) {
|
|
|
75
50
|
i18n: i18n
|
|
76
51
|
}, /*#__PURE__*/React.createElement(LinkProvider, {
|
|
77
52
|
component: NextLink
|
|
78
|
-
}, _ref, /*#__PURE__*/React.createElement(DigiGOVApp, null, /*#__PURE__*/React.createElement(Component, pageProps))));
|
|
53
|
+
}, _ref, ssr ? /*#__PURE__*/React.createElement(DigiGOVApp, null, /*#__PURE__*/React.createElement(Component, pageProps)) : /*#__PURE__*/React.createElement(StaticApp, null, /*#__PURE__*/React.createElement(Component, pageProps))));
|
|
79
54
|
}
|
|
80
55
|
}]);
|
|
81
56
|
|
package/esm/index.js
CHANGED
package/libs/nextjs/src/App.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { AppProps } from '@digigov/ui/app/App';
|
|
3
3
|
import { WithTranslation } from 'react-i18next';
|
|
4
|
-
import { i18n } from 'i18next';
|
|
4
|
+
import { i18n, TFunction } from 'i18next';
|
|
5
5
|
export interface DigiGOVNextAppProps extends AppProps, WithTranslation {
|
|
6
6
|
children?: React.ReactNode;
|
|
7
|
-
t:
|
|
7
|
+
t: TFunction;
|
|
8
8
|
i18n: i18n;
|
|
9
|
+
ssr: boolean;
|
|
9
10
|
}
|
|
10
11
|
declare const DigiGOVNextAppWithTranslation: React.ComponentType<import("react-i18next").Omit<DigiGOVNextAppProps & import("next/app").AppInitialProps & {
|
|
11
12
|
Component: import("next").NextComponentType<import("next").NextPageContext, any, {}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digigov/nextjs",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-eb2842b4",
|
|
4
4
|
"description": "next specific utilities for @digigov apps",
|
|
5
5
|
"author": "GRNET Developers <devs@lists.grnet.gr>",
|
|
6
6
|
"license": "BSD-2-Clause",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"main": "dist/index.js"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"@digigov/ui": "1.0.0-
|
|
13
|
+
"@digigov/ui": "1.0.0-eb2842b4",
|
|
14
14
|
"@material-ui/core": "4.11.3",
|
|
15
15
|
"@material-ui/icons": "4.11.2",
|
|
16
16
|
"clsx": "1.1.1",
|
package/src/App.tsx
CHANGED
|
@@ -3,40 +3,21 @@ import App from 'next/app';
|
|
|
3
3
|
import Head from 'next/head';
|
|
4
4
|
import { LinkProvider } from '@digigov/ui/navigation/Link';
|
|
5
5
|
import NextLink from '@digigov/nextjs/Link';
|
|
6
|
-
import
|
|
6
|
+
import DigiGOVApp, { StaticApp } from '@digigov/ui/app/App';
|
|
7
7
|
import type { AppProps } from '@digigov/ui/app/App';
|
|
8
8
|
import { I18NProvider } from '@digigov/ui/i18n';
|
|
9
9
|
import { withTranslation, WithTranslation } from 'react-i18next';
|
|
10
|
-
import { i18n } from 'i18next';
|
|
10
|
+
import { i18n, TFunction } from 'i18next';
|
|
11
11
|
|
|
12
|
-
const DigiGOVApp = dynamic(() => import('@digigov/ui/app/App'), {
|
|
13
|
-
ssr: false,
|
|
14
|
-
}) as React.FC<AppProps>;
|
|
15
12
|
export interface DigiGOVNextAppProps extends AppProps, WithTranslation {
|
|
16
13
|
children?: React.ReactNode;
|
|
17
|
-
t:
|
|
14
|
+
t: TFunction;
|
|
18
15
|
i18n: i18n;
|
|
16
|
+
ssr: boolean;
|
|
19
17
|
}
|
|
20
18
|
class DigiGOVNextApp extends App<DigiGOVNextAppProps> {
|
|
21
|
-
componentDidMount(): void {
|
|
22
|
-
// Remove the server-side injected CSS.
|
|
23
|
-
const jssStyles = document.querySelector('#jss-server-side');
|
|
24
|
-
if (jssStyles && jssStyles.parentElement) {
|
|
25
|
-
jssStyles.parentElement.removeChild(jssStyles);
|
|
26
|
-
}
|
|
27
|
-
this.updateHtmlLang();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
componentDidUpdate(): void {
|
|
31
|
-
this.updateHtmlLang();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
updateHtmlLang(): void {
|
|
35
|
-
document.documentElement.lang = this.props.i18n.language;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
19
|
render(): React.ReactElement {
|
|
39
|
-
const { Component, pageProps, t, i18n } = this.props;
|
|
20
|
+
const { Component, pageProps, t, i18n, ssr = false } = this.props;
|
|
40
21
|
return (
|
|
41
22
|
<I18NProvider
|
|
42
23
|
t={(str) => (typeof str === 'string' ? t(str) : str)}
|
|
@@ -49,9 +30,16 @@ class DigiGOVNextApp extends App<DigiGOVNextAppProps> {
|
|
|
49
30
|
content="minimum-scale=1, initial-scale=1, width=device-width"
|
|
50
31
|
/>
|
|
51
32
|
</Head>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
33
|
+
{
|
|
34
|
+
ssr ?
|
|
35
|
+
<DigiGOVApp>
|
|
36
|
+
<Component {...pageProps} />
|
|
37
|
+
</DigiGOVApp>
|
|
38
|
+
: <StaticApp>
|
|
39
|
+
<Component {...pageProps} />
|
|
40
|
+
</StaticApp>
|
|
41
|
+
|
|
42
|
+
}
|
|
55
43
|
</LinkProvider>
|
|
56
44
|
</I18NProvider>
|
|
57
45
|
);
|