@digigov/nextjs 1.0.0-266e80f3 → 1.0.0-3bfc7d37

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 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
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports["default"] = void 0;
11
9
 
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,20 +29,28 @@ var _Link = require("@digigov/ui/navigation/Link");
29
29
 
30
30
  var _Link2 = _interopRequireDefault(require("@digigov/nextjs/Link"));
31
31
 
32
- var _App2 = _interopRequireWildcard(require("@digigov/ui/app/App"));
32
+ var _dynamic = _interopRequireDefault(require("next/dynamic"));
33
33
 
34
34
  var _i18n = require("@digigov/ui/i18n");
35
35
 
36
36
  var _reactI18next = require("react-i18next");
37
37
 
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); }
39
-
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; }
41
-
42
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); }; }
43
39
 
44
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; } }
45
41
 
42
+ 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
+
44
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || (0, _typeof2["default"])(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
+
46
+ var DigiGOVApp = (0, _dynamic["default"])(function () {
47
+ return Promise.resolve().then(function () {
48
+ return _interopRequireWildcard(require('@digigov/ui/app/App'));
49
+ });
50
+ }, {
51
+ ssr: false
52
+ });
53
+
46
54
  var _ref = /*#__PURE__*/_react["default"].createElement(_head["default"], null, /*#__PURE__*/_react["default"].createElement("meta", {
47
55
  name: "viewport",
48
56
  content: "minimum-scale=1, initial-scale=1, width=device-width"
@@ -59,15 +67,35 @@ var DigiGOVNextApp = /*#__PURE__*/function (_App) {
59
67
  }
60
68
 
61
69
  (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
+ }, {
62
92
  key: "render",
63
93
  value: function render() {
64
94
  var _this$props = this.props,
65
95
  Component = _this$props.Component,
66
96
  pageProps = _this$props.pageProps,
67
97
  _t = _this$props.t,
68
- i18n = _this$props.i18n,
69
- _this$props$ssr = _this$props.ssr,
70
- ssr = _this$props$ssr === void 0 ? false : _this$props$ssr;
98
+ i18n = _this$props.i18n;
71
99
  return /*#__PURE__*/_react["default"].createElement(_i18n.I18NProvider, {
72
100
  t: function t(str) {
73
101
  return typeof str === 'string' ? _t(str) : str;
@@ -75,7 +103,7 @@ var DigiGOVNextApp = /*#__PURE__*/function (_App) {
75
103
  i18n: i18n
76
104
  }, /*#__PURE__*/_react["default"].createElement(_Link.LinkProvider, {
77
105
  component: _Link2["default"]
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))));
106
+ }, _ref, /*#__PURE__*/_react["default"].createElement(DigiGOVApp, null, /*#__PURE__*/_react["default"].createElement(Component, pageProps))));
79
107
  }
80
108
  }]);
81
109
  return DigiGOVNextApp;
package/es/App.js CHANGED
@@ -13,9 +13,14 @@ 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 DigiGOVApp, { StaticApp } from '@digigov/ui/app/App';
16
+ import dynamic from 'next/dynamic';
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
+ });
19
24
 
20
25
  var _ref = /*#__PURE__*/React.createElement(Head, null, /*#__PURE__*/React.createElement("meta", {
21
26
  name: "viewport",
@@ -34,15 +39,35 @@ var DigiGOVNextApp = /*#__PURE__*/function (_App) {
34
39
  }
35
40
 
36
41
  _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
+ }, {
37
64
  key: "render",
38
65
  value: function render() {
39
66
  var _this$props = this.props,
40
67
  Component = _this$props.Component,
41
68
  pageProps = _this$props.pageProps,
42
69
  _t = _this$props.t,
43
- i18n = _this$props.i18n,
44
- _this$props$ssr = _this$props.ssr,
45
- ssr = _this$props$ssr === void 0 ? false : _this$props$ssr;
70
+ i18n = _this$props.i18n;
46
71
  return /*#__PURE__*/React.createElement(I18NProvider, {
47
72
  t: function t(str) {
48
73
  return typeof str === 'string' ? _t(str) : str;
@@ -50,7 +75,7 @@ var DigiGOVNextApp = /*#__PURE__*/function (_App) {
50
75
  i18n: i18n
51
76
  }, /*#__PURE__*/React.createElement(LinkProvider, {
52
77
  component: NextLink
53
- }, _ref, ssr ? /*#__PURE__*/React.createElement(DigiGOVApp, null, /*#__PURE__*/React.createElement(Component, pageProps)) : /*#__PURE__*/React.createElement(StaticApp, null, /*#__PURE__*/React.createElement(Component, pageProps))));
78
+ }, _ref, /*#__PURE__*/React.createElement(DigiGOVApp, null, /*#__PURE__*/React.createElement(Component, pageProps))));
54
79
  }
55
80
  }]);
56
81
 
package/esm/App.js CHANGED
@@ -13,9 +13,14 @@ 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 DigiGOVApp, { StaticApp } from '@digigov/ui/app/App';
16
+ import dynamic from 'next/dynamic';
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
+ });
19
24
 
20
25
  var _ref = /*#__PURE__*/React.createElement(Head, null, /*#__PURE__*/React.createElement("meta", {
21
26
  name: "viewport",
@@ -34,15 +39,35 @@ var DigiGOVNextApp = /*#__PURE__*/function (_App) {
34
39
  }
35
40
 
36
41
  _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
+ }, {
37
64
  key: "render",
38
65
  value: function render() {
39
66
  var _this$props = this.props,
40
67
  Component = _this$props.Component,
41
68
  pageProps = _this$props.pageProps,
42
69
  _t = _this$props.t,
43
- i18n = _this$props.i18n,
44
- _this$props$ssr = _this$props.ssr,
45
- ssr = _this$props$ssr === void 0 ? false : _this$props$ssr;
70
+ i18n = _this$props.i18n;
46
71
  return /*#__PURE__*/React.createElement(I18NProvider, {
47
72
  t: function t(str) {
48
73
  return typeof str === 'string' ? _t(str) : str;
@@ -50,7 +75,7 @@ var DigiGOVNextApp = /*#__PURE__*/function (_App) {
50
75
  i18n: i18n
51
76
  }, /*#__PURE__*/React.createElement(LinkProvider, {
52
77
  component: NextLink
53
- }, _ref, ssr ? /*#__PURE__*/React.createElement(DigiGOVApp, null, /*#__PURE__*/React.createElement(Component, pageProps)) : /*#__PURE__*/React.createElement(StaticApp, null, /*#__PURE__*/React.createElement(Component, pageProps))));
78
+ }, _ref, /*#__PURE__*/React.createElement(DigiGOVApp, null, /*#__PURE__*/React.createElement(Component, pageProps))));
54
79
  }
55
80
  }]);
56
81
 
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Digigov v1.0.0-266e80f3
1
+ /** @license Digigov v1.0.0-3bfc7d37
2
2
  *
3
3
  * This source code is licensed under the BSD-2-Clause license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -1,12 +1,11 @@
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, TFunction } from 'i18next';
4
+ import { i18n } from 'i18next';
5
5
  export interface DigiGOVNextAppProps extends AppProps, WithTranslation {
6
6
  children?: React.ReactNode;
7
- t: TFunction;
7
+ t: (string: any) => string;
8
8
  i18n: i18n;
9
- ssr: boolean;
10
9
  }
11
10
  declare const DigiGOVNextAppWithTranslation: React.ComponentType<import("react-i18next").Omit<DigiGOVNextAppProps & import("next/app").AppInitialProps & {
12
11
  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-266e80f3",
3
+ "version": "1.0.0-3bfc7d37",
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-266e80f3",
13
+ "@digigov/ui": "1.0.0-3bfc7d37",
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,21 +3,40 @@ 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 DigiGOVApp, { StaticApp } from '@digigov/ui/app/App';
6
+ import dynamic from 'next/dynamic';
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, TFunction } from 'i18next';
10
+ import { i18n } from 'i18next';
11
11
 
12
+ const DigiGOVApp = dynamic(() => import('@digigov/ui/app/App'), {
13
+ ssr: false,
14
+ }) as React.FC<AppProps>;
12
15
  export interface DigiGOVNextAppProps extends AppProps, WithTranslation {
13
16
  children?: React.ReactNode;
14
- t: TFunction;
17
+ t: (string) => string;
15
18
  i18n: i18n;
16
- ssr: boolean;
17
19
  }
18
20
  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
+
19
38
  render(): React.ReactElement {
20
- const { Component, pageProps, t, i18n, ssr = false } = this.props;
39
+ const { Component, pageProps, t, i18n } = this.props;
21
40
  return (
22
41
  <I18NProvider
23
42
  t={(str) => (typeof str === 'string' ? t(str) : str)}
@@ -30,16 +49,9 @@ class DigiGOVNextApp extends App<DigiGOVNextAppProps> {
30
49
  content="minimum-scale=1, initial-scale=1, width=device-width"
31
50
  />
32
51
  </Head>
33
- {
34
- ssr ?
35
- <DigiGOVApp>
36
- <Component {...pageProps} />
37
- </DigiGOVApp>
38
- : <StaticApp>
39
- <Component {...pageProps} />
40
- </StaticApp>
41
-
42
- }
52
+ <DigiGOVApp>
53
+ <Component {...pageProps} />
54
+ </DigiGOVApp>
43
55
  </LinkProvider>
44
56
  </I18NProvider>
45
57
  );