react-alp-connection-state 4.1.3 → 6.0.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.
@@ -1,37 +0,0 @@
1
- import React, { useContext, useRef, useEffect } from 'react';
2
- import ReactAlpContext from 'react-alp-context';
3
- import { T } from 'react-alp-translate';
4
-
5
- function ConnectionState({
6
- state
7
- }) {
8
- const ctx = useContext(ReactAlpContext);
9
- const notLoggedIn = !ctx.sanitizedState.user;
10
- const unloadingRef = useRef(false);
11
- const currentStateRef = useRef(state);
12
-
13
- if (unloadingRef.current === false) {
14
- currentStateRef.current = state;
15
- }
16
-
17
- const currentState = currentStateRef.current;
18
- useEffect(() => {
19
- const beforeUnloadHandler = () => {
20
- unloadingRef.current = true;
21
- };
22
-
23
- window.addEventListener('beforeunload', beforeUnloadHandler);
24
- return () => {
25
- window.removeEventListener('beforeunload', beforeUnloadHandler);
26
- };
27
- }, []);
28
- return /*#__PURE__*/React.createElement("div", {
29
- hidden: !state || notLoggedIn || currentState === 'connected',
30
- className: "alp-connection-state"
31
- }, !state || notLoggedIn ? null : /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(T, {
32
- id: `connectionState.${currentState}`
33
- })));
34
- }
35
-
36
- export default ConnectionState;
37
- //# sourceMappingURL=index-node12-dev.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-node12-dev.mjs","sources":["../src/index.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useRef } from 'react';\nimport ReactAlpContext from 'react-alp-context';\nimport { T } from 'react-alp-translate';\nimport '../ConnectionState.global.scss';\n\ntype State = null | 'connecting' | 'connected' | 'disconnected';\n\ninterface ConnectionStateProps {\n state: State;\n}\n\nexport default function ConnectionState({\n state,\n}: ConnectionStateProps): ReactElement {\n const ctx = useContext(ReactAlpContext);\n const notLoggedIn = !(ctx.sanitizedState as { user?: unknown }).user;\n\n const unloadingRef = useRef<boolean>(false);\n const currentStateRef = useRef(state);\n if (unloadingRef.current === false) {\n currentStateRef.current = state;\n }\n const currentState = currentStateRef.current;\n\n useEffect((): (() => void) => {\n const beforeUnloadHandler = (): void => {\n unloadingRef.current = true;\n };\n window.addEventListener('beforeunload', beforeUnloadHandler);\n\n return (): void => {\n window.removeEventListener('beforeunload', beforeUnloadHandler);\n };\n }, []);\n\n return (\n <div\n hidden={!state || notLoggedIn || currentState === 'connected'}\n className=\"alp-connection-state\"\n >\n {!state || notLoggedIn ? null : (\n <div>\n <T id={`connectionState.${currentState as string}`} />\n </div>\n )}\n </div>\n );\n}\n"],"names":["ConnectionState","state","ctx","useContext","ReactAlpContext","notLoggedIn","sanitizedState","user","unloadingRef","useRef","currentStateRef","current","currentState","useEffect","beforeUnloadHandler","window","addEventListener","removeEventListener"],"mappings":";;;;AAYe,SAASA,eAAT,CAAyB;AACtCC,EAAAA;AADsC,CAAzB,EAEwB;AACrC,QAAMC,GAAG,GAAGC,UAAU,CAACC,eAAD,CAAtB;AACA,QAAMC,WAAW,GAAG,CAAEH,GAAG,CAACI,cAAL,CAA2CC,IAAhE;AAEA,QAAMC,YAAY,GAAGC,MAAM,CAAU,KAAV,CAA3B;AACA,QAAMC,eAAe,GAAGD,MAAM,CAACR,KAAD,CAA9B;;AACA,MAAIO,YAAY,CAACG,OAAb,KAAyB,KAA7B,EAAoC;AAClCD,IAAAA,eAAe,CAACC,OAAhB,GAA0BV,KAA1B;AACD;;AACD,QAAMW,YAAY,GAAGF,eAAe,CAACC,OAArC;AAEAE,EAAAA,SAAS,CAAC,MAAoB;AAC5B,UAAMC,mBAAmB,GAAG,MAAY;AACtCN,MAAAA,YAAY,CAACG,OAAb,GAAuB,IAAvB;AACD,KAFD;;AAGAI,IAAAA,MAAM,CAACC,gBAAP,CAAwB,cAAxB,EAAwCF,mBAAxC;AAEA,WAAO,MAAY;AACjBC,MAAAA,MAAM,CAACE,mBAAP,CAA2B,cAA3B,EAA2CH,mBAA3C;AACD,KAFD;AAGD,GATQ,EASN,EATM,CAAT;AAWA,sBACE;AACE,IAAA,MAAM,EAAE,CAACb,KAAD,IAAUI,WAAV,IAAyBO,YAAY,KAAK,WADpD;AAEE,IAAA,SAAS,EAAC;AAFZ,KAIG,CAACX,KAAD,IAAUI,WAAV,GAAwB,IAAxB,gBACC,8CACE,oBAAC,CAAD;AAAG,IAAA,EAAE,EAAG,mBAAkBO,YAAuB;AAAjD,IADF,CALJ,CADF;AAYD;;;;"}
@@ -1,46 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const React = require('react');
6
- const ReactAlpContext = require('react-alp-context');
7
- const reactAlpTranslate = require('react-alp-translate');
8
-
9
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
10
-
11
- const React__default = /*#__PURE__*/_interopDefaultLegacy(React);
12
- const ReactAlpContext__default = /*#__PURE__*/_interopDefaultLegacy(ReactAlpContext);
13
-
14
- function ConnectionState({
15
- state
16
- }) {
17
- const ctx = React.useContext(ReactAlpContext__default);
18
- const notLoggedIn = !ctx.sanitizedState.user;
19
- const unloadingRef = React.useRef(false);
20
- const currentStateRef = React.useRef(state);
21
-
22
- if (unloadingRef.current === false) {
23
- currentStateRef.current = state;
24
- }
25
-
26
- const currentState = currentStateRef.current;
27
- React.useEffect(() => {
28
- const beforeUnloadHandler = () => {
29
- unloadingRef.current = true;
30
- };
31
-
32
- window.addEventListener('beforeunload', beforeUnloadHandler);
33
- return () => {
34
- window.removeEventListener('beforeunload', beforeUnloadHandler);
35
- };
36
- }, []);
37
- return /*#__PURE__*/React__default.createElement("div", {
38
- hidden: !state || notLoggedIn || currentState === 'connected',
39
- className: "alp-connection-state"
40
- }, !state || notLoggedIn ? null : /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(reactAlpTranslate.T, {
41
- id: `connectionState.${currentState}`
42
- })));
43
- }
44
-
45
- exports.default = ConnectionState;
46
- //# sourceMappingURL=index-node12.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-node12.cjs.js","sources":["../src/index.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useRef } from 'react';\nimport ReactAlpContext from 'react-alp-context';\nimport { T } from 'react-alp-translate';\nimport '../ConnectionState.global.scss';\n\ntype State = null | 'connecting' | 'connected' | 'disconnected';\n\ninterface ConnectionStateProps {\n state: State;\n}\n\nexport default function ConnectionState({\n state,\n}: ConnectionStateProps): ReactElement {\n const ctx = useContext(ReactAlpContext);\n const notLoggedIn = !(ctx.sanitizedState as { user?: unknown }).user;\n\n const unloadingRef = useRef<boolean>(false);\n const currentStateRef = useRef(state);\n if (unloadingRef.current === false) {\n currentStateRef.current = state;\n }\n const currentState = currentStateRef.current;\n\n useEffect((): (() => void) => {\n const beforeUnloadHandler = (): void => {\n unloadingRef.current = true;\n };\n window.addEventListener('beforeunload', beforeUnloadHandler);\n\n return (): void => {\n window.removeEventListener('beforeunload', beforeUnloadHandler);\n };\n }, []);\n\n return (\n <div\n hidden={!state || notLoggedIn || currentState === 'connected'}\n className=\"alp-connection-state\"\n >\n {!state || notLoggedIn ? null : (\n <div>\n <T id={`connectionState.${currentState as string}`} />\n </div>\n )}\n </div>\n );\n}\n"],"names":["ConnectionState","state","ctx","useContext","ReactAlpContext","notLoggedIn","sanitizedState","user","unloadingRef","useRef","currentStateRef","current","currentState","useEffect","beforeUnloadHandler","window","addEventListener","removeEventListener","React","T"],"mappings":";;;;;;;;;;;;;AAYe,SAASA,eAAT,CAAyB;AACtCC,EAAAA;AADsC,CAAzB,EAEwB;AACrC,QAAMC,GAAG,GAAGC,gBAAU,CAACC,wBAAD,CAAtB;AACA,QAAMC,WAAW,GAAG,CAAEH,GAAG,CAACI,cAAL,CAA2CC,IAAhE;AAEA,QAAMC,YAAY,GAAGC,YAAM,CAAU,KAAV,CAA3B;AACA,QAAMC,eAAe,GAAGD,YAAM,CAACR,KAAD,CAA9B;;AACA,MAAIO,YAAY,CAACG,OAAb,KAAyB,KAA7B,EAAoC;AAClCD,IAAAA,eAAe,CAACC,OAAhB,GAA0BV,KAA1B;AACD;;AACD,QAAMW,YAAY,GAAGF,eAAe,CAACC,OAArC;AAEAE,EAAAA,eAAS,CAAC,MAAoB;AAC5B,UAAMC,mBAAmB,GAAG,MAAY;AACtCN,MAAAA,YAAY,CAACG,OAAb,GAAuB,IAAvB;AACD,KAFD;;AAGAI,IAAAA,MAAM,CAACC,gBAAP,CAAwB,cAAxB,EAAwCF,mBAAxC;AAEA,WAAO,MAAY;AACjBC,MAAAA,MAAM,CAACE,mBAAP,CAA2B,cAA3B,EAA2CH,mBAA3C;AACD,KAFD;AAGD,GATQ,EASN,EATM,CAAT;AAWA,sBACEI;AACE,IAAA,MAAM,EAAE,CAACjB,KAAD,IAAUI,WAAV,IAAyBO,YAAY,KAAK,WADpD;AAEE,IAAA,SAAS,EAAC;AAFZ,KAIG,CAACX,KAAD,IAAUI,WAAV,GAAwB,IAAxB,gBACCa,uDACEA,6BAACC,mBAAD;AAAG,IAAA,EAAE,EAAG,mBAAkBP,YAAuB;AAAjD,IADF,CALJ,CADF;AAYD;;;;"}
@@ -1,37 +0,0 @@
1
- import React, { useContext, useRef, useEffect } from 'react';
2
- import ReactAlpContext from 'react-alp-context';
3
- import { T } from 'react-alp-translate';
4
-
5
- function ConnectionState({
6
- state
7
- }) {
8
- const ctx = useContext(ReactAlpContext);
9
- const notLoggedIn = !ctx.sanitizedState.user;
10
- const unloadingRef = useRef(false);
11
- const currentStateRef = useRef(state);
12
-
13
- if (unloadingRef.current === false) {
14
- currentStateRef.current = state;
15
- }
16
-
17
- const currentState = currentStateRef.current;
18
- useEffect(() => {
19
- const beforeUnloadHandler = () => {
20
- unloadingRef.current = true;
21
- };
22
-
23
- window.addEventListener('beforeunload', beforeUnloadHandler);
24
- return () => {
25
- window.removeEventListener('beforeunload', beforeUnloadHandler);
26
- };
27
- }, []);
28
- return /*#__PURE__*/React.createElement("div", {
29
- hidden: !state || notLoggedIn || currentState === 'connected',
30
- className: "alp-connection-state"
31
- }, !state || notLoggedIn ? null : /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(T, {
32
- id: `connectionState.${currentState}`
33
- })));
34
- }
35
-
36
- export default ConnectionState;
37
- //# sourceMappingURL=index-node12.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-node12.mjs","sources":["../src/index.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useRef } from 'react';\nimport ReactAlpContext from 'react-alp-context';\nimport { T } from 'react-alp-translate';\nimport '../ConnectionState.global.scss';\n\ntype State = null | 'connecting' | 'connected' | 'disconnected';\n\ninterface ConnectionStateProps {\n state: State;\n}\n\nexport default function ConnectionState({\n state,\n}: ConnectionStateProps): ReactElement {\n const ctx = useContext(ReactAlpContext);\n const notLoggedIn = !(ctx.sanitizedState as { user?: unknown }).user;\n\n const unloadingRef = useRef<boolean>(false);\n const currentStateRef = useRef(state);\n if (unloadingRef.current === false) {\n currentStateRef.current = state;\n }\n const currentState = currentStateRef.current;\n\n useEffect((): (() => void) => {\n const beforeUnloadHandler = (): void => {\n unloadingRef.current = true;\n };\n window.addEventListener('beforeunload', beforeUnloadHandler);\n\n return (): void => {\n window.removeEventListener('beforeunload', beforeUnloadHandler);\n };\n }, []);\n\n return (\n <div\n hidden={!state || notLoggedIn || currentState === 'connected'}\n className=\"alp-connection-state\"\n >\n {!state || notLoggedIn ? null : (\n <div>\n <T id={`connectionState.${currentState as string}`} />\n </div>\n )}\n </div>\n );\n}\n"],"names":["ConnectionState","state","ctx","useContext","ReactAlpContext","notLoggedIn","sanitizedState","user","unloadingRef","useRef","currentStateRef","current","currentState","useEffect","beforeUnloadHandler","window","addEventListener","removeEventListener"],"mappings":";;;;AAYe,SAASA,eAAT,CAAyB;AACtCC,EAAAA;AADsC,CAAzB,EAEwB;AACrC,QAAMC,GAAG,GAAGC,UAAU,CAACC,eAAD,CAAtB;AACA,QAAMC,WAAW,GAAG,CAAEH,GAAG,CAACI,cAAL,CAA2CC,IAAhE;AAEA,QAAMC,YAAY,GAAGC,MAAM,CAAU,KAAV,CAA3B;AACA,QAAMC,eAAe,GAAGD,MAAM,CAACR,KAAD,CAA9B;;AACA,MAAIO,YAAY,CAACG,OAAb,KAAyB,KAA7B,EAAoC;AAClCD,IAAAA,eAAe,CAACC,OAAhB,GAA0BV,KAA1B;AACD;;AACD,QAAMW,YAAY,GAAGF,eAAe,CAACC,OAArC;AAEAE,EAAAA,SAAS,CAAC,MAAoB;AAC5B,UAAMC,mBAAmB,GAAG,MAAY;AACtCN,MAAAA,YAAY,CAACG,OAAb,GAAuB,IAAvB;AACD,KAFD;;AAGAI,IAAAA,MAAM,CAACC,gBAAP,CAAwB,cAAxB,EAAwCF,mBAAxC;AAEA,WAAO,MAAY;AACjBC,MAAAA,MAAM,CAACE,mBAAP,CAA2B,cAA3B,EAA2CH,mBAA3C;AACD,KAFD;AAGD,GATQ,EASN,EATM,CAAT;AAWA,sBACE;AACE,IAAA,MAAM,EAAE,CAACb,KAAD,IAAUI,WAAV,IAAyBO,YAAY,KAAK,WADpD;AAEE,IAAA,SAAS,EAAC;AAFZ,KAIG,CAACX,KAAD,IAAUI,WAAV,GAAwB,IAAxB,gBACC,8CACE,oBAAC,CAAD;AAAG,IAAA,EAAE,EAAG,mBAAkBO,YAAuB;AAAjD,IADF,CALJ,CADF;AAYD;;;;"}
package/index.js DELETED
@@ -1,6 +0,0 @@
1
- /* eslint-disable import/no-dynamic-require */
2
-
3
- 'use strict';
4
-
5
- const production = process.env.NODE_ENV === 'production';
6
- module.exports = require(`./dist/index-node12${production ? '' : '-dev'}.cjs`);