@elice/material-runbox 1.260825.0-runboxusability.0 → 1.260825.0-runboxusability.1

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.
@@ -3,3 +3,4 @@ export * from './useRunboxSessionEndWarning';
3
3
  export * from './useRunboxTimer';
4
4
  export * from './useInfiniteRunboxRunboxIdGrade';
5
5
  export * from './useMaterialRunboxRunboxIdStarterGet';
6
+ export * from './useOnlineState';
@@ -5,6 +5,7 @@ var useRunboxSessionEndWarning = require('./useRunboxSessionEndWarning.js');
5
5
  var useRunboxTimer = require('./useRunboxTimer.js');
6
6
  var useInfiniteRunboxRunboxIdGrade = require('./useInfiniteRunboxRunboxIdGrade.js');
7
7
  var useMaterialRunboxRunboxIdStarterGet = require('./useMaterialRunboxRunboxIdStarterGet.js');
8
+ var useOnlineState = require('./useOnlineState.js');
8
9
 
9
10
 
10
11
 
@@ -19,3 +20,4 @@ exports.useRunboxSessionEndWarning = useRunboxSessionEndWarning.useRunboxSession
19
20
  exports.useRunboxTimer = useRunboxTimer.useRunboxTimer;
20
21
  exports.useInfiniteRunboxRunboxIdGrade = useInfiniteRunboxRunboxIdGrade.useInfiniteRunboxRunboxIdGrade;
21
22
  exports.useMaterialRunboxRunboxIdStarterGet = useMaterialRunboxRunboxIdStarterGet.useMaterialRunboxRunboxIdStarterGet;
23
+ exports.useOnlineState = useOnlineState.useOnlineState;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Whether the browser currently has a network connection.
3
+ *
4
+ * NOTICE: this deliberately does not use `react-use`'s `useNetworkState`.
5
+ * That hook only exists in react-use v17, and consumers of this package do not
6
+ * agree on the major — elice-web still resolves v13, which breaks the build at
7
+ * link time. Reading `navigator.onLine` keeps this working on both.
8
+ *
9
+ * `undefined` means "not known yet" (server render, or no `navigator`), which
10
+ * callers should treat as online rather than as offline.
11
+ */
12
+ export declare const useOnlineState: () => boolean | undefined;
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
4
+ var React = require('react');
5
+
6
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
7
+
8
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
9
+
10
+ //
11
+ //
12
+ //
13
+ /**
14
+ * Whether the browser currently has a network connection.
15
+ *
16
+ * NOTICE: this deliberately does not use `react-use`'s `useNetworkState`.
17
+ * That hook only exists in react-use v17, and consumers of this package do not
18
+ * agree on the major — elice-web still resolves v13, which breaks the build at
19
+ * link time. Reading `navigator.onLine` keeps this working on both.
20
+ *
21
+ * `undefined` means "not known yet" (server render, or no `navigator`), which
22
+ * callers should treat as online rather than as offline.
23
+ */
24
+ var useOnlineState = function useOnlineState() {
25
+ var _React$useState = React__default.default.useState(function () {
26
+ return typeof navigator === 'undefined' ? undefined : navigator.onLine;
27
+ }),
28
+ _React$useState2 = _rollupPluginBabelHelpers.slicedToArray(_React$useState, 2),
29
+ online = _React$useState2[0],
30
+ setOnline = _React$useState2[1];
31
+ React__default.default.useEffect(function () {
32
+ var handleOnline = function handleOnline() {
33
+ return setOnline(true);
34
+ };
35
+ var handleOffline = function handleOffline() {
36
+ return setOnline(false);
37
+ };
38
+ window.addEventListener('online', handleOnline);
39
+ window.addEventListener('offline', handleOffline);
40
+ // Catch a change that happened between the initial state and this effect.
41
+ setOnline(navigator.onLine);
42
+ return function () {
43
+ window.removeEventListener('online', handleOnline);
44
+ window.removeEventListener('offline', handleOffline);
45
+ };
46
+ }, []);
47
+ return online;
48
+ };
49
+
50
+ exports.useOnlineState = useOnlineState;
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tslib = require('tslib');
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
- var reactUse = require('react-use');
8
7
  var intl = require('@elice/intl');
9
8
  var muiElements = require('@elice/mui-elements');
10
9
  var runboxClient = require('@elice/runbox-client');
@@ -12,6 +11,7 @@ var proSolidSvgIcons = require('@fortawesome/pro-solid-svg-icons');
12
11
  var material = require('@mui/material');
13
12
  var MaterialRunboxStatusConnectionItem = require('./MaterialRunboxStatusConnectionItem.js');
14
13
  var MaterialRunboxStatusResourceItem = require('./MaterialRunboxStatusResourceItem.js');
14
+ var useOnlineState = require('../hooks/useOnlineState.js');
15
15
 
16
16
  //
17
17
  //
@@ -28,8 +28,7 @@ var MaterialRunboxStatusPopover = function MaterialRunboxStatusPopover(_a) {
28
28
  var intl$1 = intl.useRawEliceIntl();
29
29
  var _useEliceRunboxRunnin = runboxClient.useEliceRunboxRunning(),
30
30
  status = _useEliceRunboxRunnin.status;
31
- var _useNetworkState = reactUse.useNetworkState(),
32
- online = _useNetworkState.online;
31
+ var online = useOnlineState.useOnlineState();
33
32
  var contStats = runboxClient.useEliceRunboxContainerStats();
34
33
  var stats = contStats ? contStats[contStats.length - 1] : null;
35
34
  var isRunboxRunning = status === 'running';
@@ -3,3 +3,4 @@ export * from './useRunboxSessionEndWarning';
3
3
  export * from './useRunboxTimer';
4
4
  export * from './useInfiniteRunboxRunboxIdGrade';
5
5
  export * from './useMaterialRunboxRunboxIdStarterGet';
6
+ export * from './useOnlineState';
@@ -3,3 +3,4 @@ export { QUOTA_ALMOST_END_MINUTES, QUOTA_PER_SESSION_ALMOST_END_MINUTES, useRunb
3
3
  export { useRunboxTimer } from './useRunboxTimer.js';
4
4
  export { useInfiniteRunboxRunboxIdGrade } from './useInfiniteRunboxRunboxIdGrade.js';
5
5
  export { useMaterialRunboxRunboxIdStarterGet } from './useMaterialRunboxRunboxIdStarterGet.js';
6
+ export { useOnlineState } from './useOnlineState.js';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Whether the browser currently has a network connection.
3
+ *
4
+ * NOTICE: this deliberately does not use `react-use`'s `useNetworkState`.
5
+ * That hook only exists in react-use v17, and consumers of this package do not
6
+ * agree on the major — elice-web still resolves v13, which breaks the build at
7
+ * link time. Reading `navigator.onLine` keeps this working on both.
8
+ *
9
+ * `undefined` means "not known yet" (server render, or no `navigator`), which
10
+ * callers should treat as online rather than as offline.
11
+ */
12
+ export declare const useOnlineState: () => boolean | undefined;
@@ -0,0 +1,44 @@
1
+ import { slicedToArray as _slicedToArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React from 'react';
3
+
4
+ //
5
+ //
6
+ //
7
+ /**
8
+ * Whether the browser currently has a network connection.
9
+ *
10
+ * NOTICE: this deliberately does not use `react-use`'s `useNetworkState`.
11
+ * That hook only exists in react-use v17, and consumers of this package do not
12
+ * agree on the major — elice-web still resolves v13, which breaks the build at
13
+ * link time. Reading `navigator.onLine` keeps this working on both.
14
+ *
15
+ * `undefined` means "not known yet" (server render, or no `navigator`), which
16
+ * callers should treat as online rather than as offline.
17
+ */
18
+ var useOnlineState = function useOnlineState() {
19
+ var _React$useState = React.useState(function () {
20
+ return typeof navigator === 'undefined' ? undefined : navigator.onLine;
21
+ }),
22
+ _React$useState2 = _slicedToArray(_React$useState, 2),
23
+ online = _React$useState2[0],
24
+ setOnline = _React$useState2[1];
25
+ React.useEffect(function () {
26
+ var handleOnline = function handleOnline() {
27
+ return setOnline(true);
28
+ };
29
+ var handleOffline = function handleOffline() {
30
+ return setOnline(false);
31
+ };
32
+ window.addEventListener('online', handleOnline);
33
+ window.addEventListener('offline', handleOffline);
34
+ // Catch a change that happened between the initial state and this effect.
35
+ setOnline(navigator.onLine);
36
+ return function () {
37
+ window.removeEventListener('online', handleOnline);
38
+ window.removeEventListener('offline', handleOffline);
39
+ };
40
+ }, []);
41
+ return online;
42
+ };
43
+
44
+ export { useOnlineState };
@@ -1,6 +1,5 @@
1
1
  import { __rest } from 'tslib';
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
- import { useNetworkState } from 'react-use';
4
3
  import { useRawEliceIntl } from '@elice/intl';
5
4
  import { EliceIcon } from '@elice/mui-elements';
6
5
  import { useEliceRunboxRunning, useEliceRunboxContainerStats } from '@elice/runbox-client';
@@ -8,6 +7,7 @@ import { faWifiSlash, faWifi, faLinkSimple, faLinkSimpleSlash, faMicrochip, faMe
8
7
  import { Popover, Stack, Divider } from '@mui/material';
9
8
  import MaterialRunboxStatusConnectionItem from './MaterialRunboxStatusConnectionItem.js';
10
9
  import MaterialRunboxStatusResourceItem from './MaterialRunboxStatusResourceItem.js';
10
+ import { useOnlineState } from '../hooks/useOnlineState.js';
11
11
 
12
12
  //
13
13
  //
@@ -24,8 +24,7 @@ var MaterialRunboxStatusPopover = function MaterialRunboxStatusPopover(_a) {
24
24
  var intl = useRawEliceIntl();
25
25
  var _useEliceRunboxRunnin = useEliceRunboxRunning(),
26
26
  status = _useEliceRunboxRunnin.status;
27
- var _useNetworkState = useNetworkState(),
28
- online = _useNetworkState.online;
27
+ var online = useOnlineState();
29
28
  var contStats = useEliceRunboxContainerStats();
30
29
  var stats = contStats ? contStats[contStats.length - 1] : null;
31
30
  var isRunboxRunning = status === 'running';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elice/material-runbox",
3
- "version": "1.260825.0-runboxusability.0",
3
+ "version": "1.260825.0-runboxusability.1",
4
4
  "description": "User view and editing components of Elice material runbox",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,8 +20,8 @@
20
20
  "peerDependencies": {
21
21
  "@elice/api-client": "^1",
22
22
  "@elice/intl": "^0",
23
- "@elice/material-shared-types": "1.260825.0-runboxusability.0",
24
- "@elice/material-shared-utils": "1.260825.0-runboxusability.0",
23
+ "@elice/material-shared-types": "1.260825.0-runboxusability.1",
24
+ "@elice/material-shared-utils": "1.260825.0-runboxusability.1",
25
25
  "@elice/mui-elements": "^5",
26
26
  "@elice/mui-system": "^5",
27
27
  "@elice/mui-x-snackbar": "^5",
@@ -51,8 +51,8 @@
51
51
  "devDependencies": {
52
52
  "@elice/api-client": "1.260529.0",
53
53
  "@elice/intl": "0.260526.0",
54
- "@elice/material-shared-types": "1.260825.0-runboxusability.0",
55
- "@elice/material-shared-utils": "1.260825.0-runboxusability.0",
54
+ "@elice/material-shared-types": "1.260825.0-runboxusability.1",
55
+ "@elice/material-shared-utils": "1.260825.0-runboxusability.1",
56
56
  "@elice/mui-elements": "5.251204.0",
57
57
  "@elice/mui-system": "5.251204.0",
58
58
  "@elice/mui-x-snackbar": "^5.250108.0-controllabel.0",