@vuu-ui/vuu-data-react 0.13.104 → 0.13.105

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.
@@ -0,0 +1,51 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var vuuDataRemote = require('@vuu-ui/vuu-data-remote');
5
+ var react = require('react');
6
+ var vuuNotifications = require('@vuu-ui/vuu-notifications');
7
+ var LostConnectionIndicator = require('../lost-connection-indicator/LostConnectionIndicator.js');
8
+
9
+ const useRemoteConnection = ({
10
+ serverUrl,
11
+ user
12
+ }) => {
13
+ const { hideNotification, showNotification } = vuuNotifications.useNotifications();
14
+ const isConnectedRef = react.useRef(false);
15
+ const handleConnectionStatusChange = react.useCallback(
16
+ (message) => {
17
+ const { current: wasConnected } = isConnectedRef;
18
+ isConnectedRef.current = vuuDataRemote.isConnected(message.connectionStatus);
19
+ if (wasConnected && message.connectionStatus === "disconnected") {
20
+ showNotification({
21
+ content: /* @__PURE__ */ jsxRuntime.jsx(LostConnectionIndicator.LostConnectionIndicator, {}),
22
+ status: "error",
23
+ type: vuuNotifications.NotificationType.Workspace
24
+ });
25
+ } else if (!wasConnected && isConnectedRef.current) {
26
+ hideNotification();
27
+ }
28
+ },
29
+ [hideNotification, showNotification]
30
+ );
31
+ react.useMemo(async () => {
32
+ if (serverUrl) {
33
+ vuuDataRemote.ConnectionManager.on("connection-status", handleConnectionStatusChange);
34
+ const connectionResult = await vuuDataRemote.ConnectionManager.connect({
35
+ token: user.token,
36
+ url: serverUrl
37
+ });
38
+ if (connectionResult === "rejected") {
39
+ showNotification({
40
+ status: "error",
41
+ content: "Unable to connect to VUU Server",
42
+ header: "Error",
43
+ type: vuuNotifications.NotificationType.Toast
44
+ });
45
+ }
46
+ }
47
+ }, [handleConnectionStatusChange, showNotification, serverUrl, user.token]);
48
+ };
49
+
50
+ exports.useRemoteConnection = useRemoteConnection;
51
+ //# sourceMappingURL=useRemoteConnection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRemoteConnection.js","sources":["../../../../packages/vuu-data-react/src/hooks/useRemoteConnection.tsx"],"sourcesContent":["import {\n ConnectionManager,\n WebSocketConnectionState,\n isConnected,\n} from \"@vuu-ui/vuu-data-remote\";\nimport type { VuuUser } from \"@vuu-ui/vuu-utils\";\nimport { useCallback, useMemo, useRef } from \"react\";\nimport { NotificationType, useNotifications } from \"@vuu-ui/vuu-notifications\";\nimport { LostConnectionIndicator } from \"../lost-connection-indicator/LostConnectionIndicator\";\n\nexport interface RemoteConnectionHookProps {\n serverUrl?: string;\n user: VuuUser;\n}\nexport const useRemoteConnection = ({\n serverUrl,\n user,\n}: RemoteConnectionHookProps) => {\n const { hideNotification, showNotification } = useNotifications();\n\n const isConnectedRef = useRef(false);\n\n const handleConnectionStatusChange = useCallback(\n (message: WebSocketConnectionState) => {\n const { current: wasConnected } = isConnectedRef;\n isConnectedRef.current = isConnected(message.connectionStatus);\n\n if (wasConnected && message.connectionStatus === \"disconnected\") {\n showNotification({\n content: <LostConnectionIndicator />,\n status: \"error\",\n type: NotificationType.Workspace,\n });\n } else if (!wasConnected && isConnectedRef.current) {\n hideNotification();\n }\n },\n [hideNotification, showNotification],\n );\n\n useMemo(async () => {\n if (serverUrl) {\n ConnectionManager.on(\"connection-status\", handleConnectionStatusChange);\n const connectionResult = await ConnectionManager.connect({\n token: user.token,\n url: serverUrl,\n });\n if (connectionResult === \"rejected\") {\n showNotification({\n status: \"error\",\n content: \"Unable to connect to VUU Server\",\n header: \"Error\",\n type: NotificationType.Toast,\n });\n }\n }\n }, [handleConnectionStatusChange, showNotification, serverUrl, user.token]);\n};\n"],"names":["useNotifications","useRef","useCallback","isConnected","LostConnectionIndicator","NotificationType","useMemo","ConnectionManager"],"mappings":";;;;;;;;AAcO,MAAM,sBAAsB,CAAC;AAAA,EAClC,SAAA;AAAA,EACA;AACF,CAAiC,KAAA;AAC/B,EAAA,MAAM,EAAE,gBAAA,EAAkB,gBAAiB,EAAA,GAAIA,iCAAiB,EAAA;AAEhE,EAAM,MAAA,cAAA,GAAiBC,aAAO,KAAK,CAAA;AAEnC,EAAA,MAAM,4BAA+B,GAAAC,iBAAA;AAAA,IACnC,CAAC,OAAsC,KAAA;AACrC,MAAM,MAAA,EAAE,OAAS,EAAA,YAAA,EAAiB,GAAA,cAAA;AAClC,MAAe,cAAA,CAAA,OAAA,GAAUC,yBAAY,CAAA,OAAA,CAAQ,gBAAgB,CAAA;AAE7D,MAAI,IAAA,YAAA,IAAgB,OAAQ,CAAA,gBAAA,KAAqB,cAAgB,EAAA;AAC/D,QAAiB,gBAAA,CAAA;AAAA,UACf,OAAA,iCAAUC,+CAAwB,EAAA,EAAA,CAAA;AAAA,UAClC,MAAQ,EAAA,OAAA;AAAA,UACR,MAAMC,iCAAiB,CAAA;AAAA,SACxB,CAAA;AAAA,OACQ,MAAA,IAAA,CAAC,YAAgB,IAAA,cAAA,CAAe,OAAS,EAAA;AAClD,QAAiB,gBAAA,EAAA;AAAA;AACnB,KACF;AAAA,IACA,CAAC,kBAAkB,gBAAgB;AAAA,GACrC;AAEA,EAAAC,aAAA,CAAQ,YAAY;AAClB,IAAA,IAAI,SAAW,EAAA;AACb,MAAkBC,+BAAA,CAAA,EAAA,CAAG,qBAAqB,4BAA4B,CAAA;AACtE,MAAM,MAAA,gBAAA,GAAmB,MAAMA,+BAAA,CAAkB,OAAQ,CAAA;AAAA,QACvD,OAAO,IAAK,CAAA,KAAA;AAAA,QACZ,GAAK,EAAA;AAAA,OACN,CAAA;AACD,MAAA,IAAI,qBAAqB,UAAY,EAAA;AACnC,QAAiB,gBAAA,CAAA;AAAA,UACf,MAAQ,EAAA,OAAA;AAAA,UACR,OAAS,EAAA,iCAAA;AAAA,UACT,MAAQ,EAAA,OAAA;AAAA,UACR,MAAMF,iCAAiB,CAAA;AAAA,SACxB,CAAA;AAAA;AACH;AACF,KACC,CAAC,4BAAA,EAA8B,kBAAkB,SAAW,EAAA,IAAA,CAAK,KAAK,CAAC,CAAA;AAC5E;;;;"}
package/cjs/index.js CHANGED
@@ -8,12 +8,12 @@ var useEditForm = require('./data-editing/useEditForm.js');
8
8
  var formEditState = require('./data-editing/form-edit-state.js');
9
9
  var VuuDataSourceProvider = require('./datasource-provider/VuuDataSourceProvider.js');
10
10
  var useLookupValues = require('./hooks/useLookupValues.js');
11
+ var useRemoteConnection = require('./hooks/useRemoteConnection.js');
11
12
  var useSessionDataSource = require('./hooks/useSessionDataSource.js');
12
13
  var useTypeaheadSuggestions = require('./hooks/useTypeaheadSuggestions.js');
13
14
  var useVisualLinks = require('./hooks/useVisualLinks.js');
14
15
  var useVuuMenuActions = require('./hooks/useVuuMenuActions.js');
15
16
  var useVuuTables = require('./hooks/useVuuTables.js');
16
- var useLostConnection = require('./lost-connection-indicator/useLostConnection.js');
17
17
  var SessionEditingForm = require('./session-editing-form/SessionEditingForm.js');
18
18
 
19
19
 
@@ -29,6 +29,7 @@ exports.CLEAN_FORM = formEditState.CLEAN_FORM;
29
29
  exports.buildFormEditState = formEditState.buildFormEditState;
30
30
  exports.VuuDataSourceProvider = VuuDataSourceProvider.VuuDataSourceProvider;
31
31
  exports.useLookupValues = useLookupValues.useLookupValues;
32
+ exports.useRemoteConnection = useRemoteConnection.useRemoteConnection;
32
33
  exports.useSessionDataSource = useSessionDataSource.useSessionDataSource;
33
34
  exports.getTypeaheadParams = useTypeaheadSuggestions.getTypeaheadParams;
34
35
  exports.useTypeaheadSuggestions = useTypeaheadSuggestions.useTypeaheadSuggestions;
@@ -37,6 +38,5 @@ exports.isRowMenu = useVuuMenuActions.isRowMenu;
37
38
  exports.isSelectionMenu = useVuuMenuActions.isSelectionMenu;
38
39
  exports.useVuuMenuActions = useVuuMenuActions.useVuuMenuActions;
39
40
  exports.useVuuTables = useVuuTables.useVuuTables;
40
- exports.useLostConnection = useLostConnection.useLostConnection;
41
41
  exports.SessionEditingForm = SessionEditingForm.SessionEditingForm;
42
42
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,49 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { isConnected, ConnectionManager } from '@vuu-ui/vuu-data-remote';
3
+ import { useRef, useCallback, useMemo } from 'react';
4
+ import { useNotifications, NotificationType } from '@vuu-ui/vuu-notifications';
5
+ import { LostConnectionIndicator } from '../lost-connection-indicator/LostConnectionIndicator.js';
6
+
7
+ const useRemoteConnection = ({
8
+ serverUrl,
9
+ user
10
+ }) => {
11
+ const { hideNotification, showNotification } = useNotifications();
12
+ const isConnectedRef = useRef(false);
13
+ const handleConnectionStatusChange = useCallback(
14
+ (message) => {
15
+ const { current: wasConnected } = isConnectedRef;
16
+ isConnectedRef.current = isConnected(message.connectionStatus);
17
+ if (wasConnected && message.connectionStatus === "disconnected") {
18
+ showNotification({
19
+ content: /* @__PURE__ */ jsx(LostConnectionIndicator, {}),
20
+ status: "error",
21
+ type: NotificationType.Workspace
22
+ });
23
+ } else if (!wasConnected && isConnectedRef.current) {
24
+ hideNotification();
25
+ }
26
+ },
27
+ [hideNotification, showNotification]
28
+ );
29
+ useMemo(async () => {
30
+ if (serverUrl) {
31
+ ConnectionManager.on("connection-status", handleConnectionStatusChange);
32
+ const connectionResult = await ConnectionManager.connect({
33
+ token: user.token,
34
+ url: serverUrl
35
+ });
36
+ if (connectionResult === "rejected") {
37
+ showNotification({
38
+ status: "error",
39
+ content: "Unable to connect to VUU Server",
40
+ header: "Error",
41
+ type: NotificationType.Toast
42
+ });
43
+ }
44
+ }
45
+ }, [handleConnectionStatusChange, showNotification, serverUrl, user.token]);
46
+ };
47
+
48
+ export { useRemoteConnection };
49
+ //# sourceMappingURL=useRemoteConnection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRemoteConnection.js","sources":["../../../../packages/vuu-data-react/src/hooks/useRemoteConnection.tsx"],"sourcesContent":["import {\n ConnectionManager,\n WebSocketConnectionState,\n isConnected,\n} from \"@vuu-ui/vuu-data-remote\";\nimport type { VuuUser } from \"@vuu-ui/vuu-utils\";\nimport { useCallback, useMemo, useRef } from \"react\";\nimport { NotificationType, useNotifications } from \"@vuu-ui/vuu-notifications\";\nimport { LostConnectionIndicator } from \"../lost-connection-indicator/LostConnectionIndicator\";\n\nexport interface RemoteConnectionHookProps {\n serverUrl?: string;\n user: VuuUser;\n}\nexport const useRemoteConnection = ({\n serverUrl,\n user,\n}: RemoteConnectionHookProps) => {\n const { hideNotification, showNotification } = useNotifications();\n\n const isConnectedRef = useRef(false);\n\n const handleConnectionStatusChange = useCallback(\n (message: WebSocketConnectionState) => {\n const { current: wasConnected } = isConnectedRef;\n isConnectedRef.current = isConnected(message.connectionStatus);\n\n if (wasConnected && message.connectionStatus === \"disconnected\") {\n showNotification({\n content: <LostConnectionIndicator />,\n status: \"error\",\n type: NotificationType.Workspace,\n });\n } else if (!wasConnected && isConnectedRef.current) {\n hideNotification();\n }\n },\n [hideNotification, showNotification],\n );\n\n useMemo(async () => {\n if (serverUrl) {\n ConnectionManager.on(\"connection-status\", handleConnectionStatusChange);\n const connectionResult = await ConnectionManager.connect({\n token: user.token,\n url: serverUrl,\n });\n if (connectionResult === \"rejected\") {\n showNotification({\n status: \"error\",\n content: \"Unable to connect to VUU Server\",\n header: \"Error\",\n type: NotificationType.Toast,\n });\n }\n }\n }, [handleConnectionStatusChange, showNotification, serverUrl, user.token]);\n};\n"],"names":[],"mappings":";;;;;;AAcO,MAAM,sBAAsB,CAAC;AAAA,EAClC,SAAA;AAAA,EACA;AACF,CAAiC,KAAA;AAC/B,EAAA,MAAM,EAAE,gBAAA,EAAkB,gBAAiB,EAAA,GAAI,gBAAiB,EAAA;AAEhE,EAAM,MAAA,cAAA,GAAiB,OAAO,KAAK,CAAA;AAEnC,EAAA,MAAM,4BAA+B,GAAA,WAAA;AAAA,IACnC,CAAC,OAAsC,KAAA;AACrC,MAAM,MAAA,EAAE,OAAS,EAAA,YAAA,EAAiB,GAAA,cAAA;AAClC,MAAe,cAAA,CAAA,OAAA,GAAU,WAAY,CAAA,OAAA,CAAQ,gBAAgB,CAAA;AAE7D,MAAI,IAAA,YAAA,IAAgB,OAAQ,CAAA,gBAAA,KAAqB,cAAgB,EAAA;AAC/D,QAAiB,gBAAA,CAAA;AAAA,UACf,OAAA,sBAAU,uBAAwB,EAAA,EAAA,CAAA;AAAA,UAClC,MAAQ,EAAA,OAAA;AAAA,UACR,MAAM,gBAAiB,CAAA;AAAA,SACxB,CAAA;AAAA,OACQ,MAAA,IAAA,CAAC,YAAgB,IAAA,cAAA,CAAe,OAAS,EAAA;AAClD,QAAiB,gBAAA,EAAA;AAAA;AACnB,KACF;AAAA,IACA,CAAC,kBAAkB,gBAAgB;AAAA,GACrC;AAEA,EAAA,OAAA,CAAQ,YAAY;AAClB,IAAA,IAAI,SAAW,EAAA;AACb,MAAkB,iBAAA,CAAA,EAAA,CAAG,qBAAqB,4BAA4B,CAAA;AACtE,MAAM,MAAA,gBAAA,GAAmB,MAAM,iBAAA,CAAkB,OAAQ,CAAA;AAAA,QACvD,OAAO,IAAK,CAAA,KAAA;AAAA,QACZ,GAAK,EAAA;AAAA,OACN,CAAA;AACD,MAAA,IAAI,qBAAqB,UAAY,EAAA;AACnC,QAAiB,gBAAA,CAAA;AAAA,UACf,MAAQ,EAAA,OAAA;AAAA,UACR,OAAS,EAAA,iCAAA;AAAA,UACT,MAAQ,EAAA,OAAA;AAAA,UACR,MAAM,gBAAiB,CAAA;AAAA,SACxB,CAAA;AAAA;AACH;AACF,KACC,CAAC,4BAAA,EAA8B,kBAAkB,SAAW,EAAA,IAAA,CAAK,KAAK,CAAC,CAAA;AAC5E;;;;"}
package/esm/index.js CHANGED
@@ -6,11 +6,11 @@ export { useEditForm } from './data-editing/useEditForm.js';
6
6
  export { CLEAN_FORM, buildFormEditState } from './data-editing/form-edit-state.js';
7
7
  export { VuuDataSourceProvider } from './datasource-provider/VuuDataSourceProvider.js';
8
8
  export { useLookupValues } from './hooks/useLookupValues.js';
9
+ export { useRemoteConnection } from './hooks/useRemoteConnection.js';
9
10
  export { useSessionDataSource } from './hooks/useSessionDataSource.js';
10
11
  export { getTypeaheadParams, useTypeaheadSuggestions } from './hooks/useTypeaheadSuggestions.js';
11
12
  export { useVisualLinks } from './hooks/useVisualLinks.js';
12
13
  export { isRowMenu, isSelectionMenu, useVuuMenuActions } from './hooks/useVuuMenuActions.js';
13
14
  export { useVuuTables } from './hooks/useVuuTables.js';
14
- export { useLostConnection } from './lost-connection-indicator/useLostConnection.js';
15
15
  export { SessionEditingForm } from './session-editing-form/SessionEditingForm.js';
16
16
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,23 +1,23 @@
1
1
  {
2
- "version": "0.13.104",
2
+ "version": "0.13.105",
3
3
  "author": "heswell",
4
4
  "license": "Apache-2.0",
5
5
  "devDependencies": {
6
- "@vuu-ui/vuu-data-types": "0.13.104",
7
- "@vuu-ui/vuu-filter-types": "0.13.104",
8
- "@vuu-ui/vuu-protocol-types": "0.13.104",
9
- "@vuu-ui/vuu-table-types": "0.13.104"
6
+ "@vuu-ui/vuu-data-types": "0.13.105",
7
+ "@vuu-ui/vuu-filter-types": "0.13.105",
8
+ "@vuu-ui/vuu-protocol-types": "0.13.105",
9
+ "@vuu-ui/vuu-table-types": "0.13.105"
10
10
  },
11
11
  "dependencies": {
12
- "@vuu-ui/vuu-context-menu": "0.13.104",
13
- "@vuu-ui/vuu-data-remote": "0.13.104",
14
- "@vuu-ui/vuu-filter-parser": "0.13.104",
15
- "@vuu-ui/vuu-filters": "0.13.104",
16
- "@vuu-ui/vuu-layout": "0.13.104",
17
- "@vuu-ui/vuu-notifications": "0.13.104",
18
- "@vuu-ui/vuu-ui-controls": "0.13.104",
19
- "@vuu-ui/vuu-utils": "0.13.104",
20
- "@vuu-ui/vuu-table": "0.13.104",
12
+ "@vuu-ui/vuu-context-menu": "0.13.105",
13
+ "@vuu-ui/vuu-data-remote": "0.13.105",
14
+ "@vuu-ui/vuu-filter-parser": "0.13.105",
15
+ "@vuu-ui/vuu-filters": "0.13.105",
16
+ "@vuu-ui/vuu-layout": "0.13.105",
17
+ "@vuu-ui/vuu-notifications": "0.13.105",
18
+ "@vuu-ui/vuu-ui-controls": "0.13.105",
19
+ "@vuu-ui/vuu-utils": "0.13.105",
20
+ "@vuu-ui/vuu-table": "0.13.105",
21
21
  "@salt-ds/core": "1.48.0",
22
22
  "@salt-ds/styles": "0.2.1",
23
23
  "@salt-ds/window": "0.1.1"
@@ -0,0 +1,6 @@
1
+ import { WebSocketConnectionState } from "@vuu-ui/vuu-data-remote";
2
+ export interface ConnectionStatusHookProps {
3
+ connectionState?: WebSocketConnectionState;
4
+ }
5
+ export declare const getConnectinStateDisplayText: (connectionState: WebSocketConnectionState) => "Unable to connect to data service" | "Failed to connect" | "Failed to re-connect" | "Attempting to connect to data service" | "Attempting to reconnect to data service" | undefined;
6
+ export declare const useConnectionStatus: ({ connectionState: connectionStateProp, }: ConnectionStatusHookProps) => WebSocketConnectionState<import("@vuu-ui/vuu-data-remote/src/WebSocketConnection").ConnectionStatus>;
@@ -0,0 +1,6 @@
1
+ import type { VuuUser } from "@vuu-ui/vuu-utils";
2
+ export interface RemoteConnectionHookProps {
3
+ serverUrl?: string;
4
+ user: VuuUser;
5
+ }
6
+ export declare const useRemoteConnection: ({ serverUrl, user, }: RemoteConnectionHookProps) => void;
package/types/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  export * from "./data-editing";
2
2
  export * from "./datasource-provider";
3
3
  export { useLookupValues } from "./hooks/useLookupValues";
4
+ export { useRemoteConnection } from "./hooks/useRemoteConnection";
4
5
  export { useSessionDataSource } from "./hooks/useSessionDataSource";
5
6
  export { getTypeaheadParams, useTypeaheadSuggestions, } from "./hooks/useTypeaheadSuggestions";
6
7
  export { useVisualLinks } from "./hooks/useVisualLinks";
7
- export { isRowMenu, isSelectionMenu, useVuuMenuActions, type MenuActionConfig, } from "./hooks/useVuuMenuActions";
8
+ export { type MenuActionConfig, isRowMenu, isSelectionMenu, useVuuMenuActions, } from "./hooks/useVuuMenuActions";
8
9
  export { useVuuTables } from "./hooks/useVuuTables";
9
- export { useLostConnection } from "./lost-connection-indicator/useLostConnection";
10
10
  export * from "./session-editing-form";
@@ -1,34 +0,0 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var vuuDataRemote = require('@vuu-ui/vuu-data-remote');
5
- var react = require('react');
6
- var vuuNotifications = require('@vuu-ui/vuu-notifications');
7
- var LostConnectionIndicator = require('./LostConnectionIndicator.js');
8
-
9
- const useLostConnection = () => {
10
- const { hideNotification, showNotification } = vuuNotifications.useNotifications();
11
- const isConnectedRef = react.useRef(vuuDataRemote.ConnectionManager.connected);
12
- const handleConnectionStatusChange = react.useCallback(
13
- (connectionStatus) => {
14
- const { current: wasConnected } = isConnectedRef;
15
- isConnectedRef.current = vuuDataRemote.isConnected(connectionStatus);
16
- if (wasConnected && connectionStatus === "disconnected") {
17
- showNotification({
18
- content: /* @__PURE__ */ jsxRuntime.jsx(LostConnectionIndicator.LostConnectionIndicator, {}),
19
- status: "error",
20
- type: vuuNotifications.NotificationType.Workspace
21
- });
22
- } else if (!wasConnected && isConnectedRef.current) {
23
- hideNotification();
24
- }
25
- },
26
- [hideNotification, showNotification]
27
- );
28
- react.useMemo(async () => {
29
- vuuDataRemote.ConnectionManager.on("connection-status", handleConnectionStatusChange);
30
- }, [handleConnectionStatusChange]);
31
- };
32
-
33
- exports.useLostConnection = useLostConnection;
34
- //# sourceMappingURL=useLostConnection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLostConnection.js","sources":["../../../../packages/vuu-data-react/src/lost-connection-indicator/useLostConnection.tsx"],"sourcesContent":["import {\n ConnectionManager,\n ConnectionStatus,\n isConnected,\n} from \"@vuu-ui/vuu-data-remote\";\nimport { useCallback, useMemo, useRef } from \"react\";\nimport { NotificationType, useNotifications } from \"@vuu-ui/vuu-notifications\";\nimport { LostConnectionIndicator } from \"../lost-connection-indicator/LostConnectionIndicator\";\n\nexport const useLostConnection = () => {\n const { hideNotification, showNotification } = useNotifications();\n\n const isConnectedRef = useRef(ConnectionManager.connected);\n\n const handleConnectionStatusChange = useCallback(\n (connectionStatus: ConnectionStatus) => {\n const { current: wasConnected } = isConnectedRef;\n isConnectedRef.current = isConnected(connectionStatus);\n\n if (wasConnected && connectionStatus === \"disconnected\") {\n showNotification({\n content: <LostConnectionIndicator />,\n status: \"error\",\n type: NotificationType.Workspace,\n });\n } else if (!wasConnected && isConnectedRef.current) {\n hideNotification();\n }\n },\n [hideNotification, showNotification],\n );\n\n useMemo(async () => {\n ConnectionManager.on(\"connection-status\", handleConnectionStatusChange);\n }, [handleConnectionStatusChange]);\n};\n"],"names":["useNotifications","useRef","ConnectionManager","useCallback","isConnected","LostConnectionIndicator","NotificationType","useMemo"],"mappings":";;;;;;;;AASO,MAAM,oBAAoB,MAAM;AACrC,EAAA,MAAM,EAAE,gBAAA,EAAkB,gBAAiB,EAAA,GAAIA,iCAAiB,EAAA;AAEhE,EAAM,MAAA,cAAA,GAAiBC,YAAO,CAAAC,+BAAA,CAAkB,SAAS,CAAA;AAEzD,EAAA,MAAM,4BAA+B,GAAAC,iBAAA;AAAA,IACnC,CAAC,gBAAuC,KAAA;AACtC,MAAM,MAAA,EAAE,OAAS,EAAA,YAAA,EAAiB,GAAA,cAAA;AAClC,MAAe,cAAA,CAAA,OAAA,GAAUC,0BAAY,gBAAgB,CAAA;AAErD,MAAI,IAAA,YAAA,IAAgB,qBAAqB,cAAgB,EAAA;AACvD,QAAiB,gBAAA,CAAA;AAAA,UACf,OAAA,iCAAUC,+CAAwB,EAAA,EAAA,CAAA;AAAA,UAClC,MAAQ,EAAA,OAAA;AAAA,UACR,MAAMC,iCAAiB,CAAA;AAAA,SACxB,CAAA;AAAA,OACQ,MAAA,IAAA,CAAC,YAAgB,IAAA,cAAA,CAAe,OAAS,EAAA;AAClD,QAAiB,gBAAA,EAAA;AAAA;AACnB,KACF;AAAA,IACA,CAAC,kBAAkB,gBAAgB;AAAA,GACrC;AAEA,EAAAC,aAAA,CAAQ,YAAY;AAClB,IAAkBL,+BAAA,CAAA,EAAA,CAAG,qBAAqB,4BAA4B,CAAA;AAAA,GACxE,EAAG,CAAC,4BAA4B,CAAC,CAAA;AACnC;;;;"}
@@ -1,32 +0,0 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { ConnectionManager, isConnected } from '@vuu-ui/vuu-data-remote';
3
- import { useRef, useCallback, useMemo } from 'react';
4
- import { useNotifications, NotificationType } from '@vuu-ui/vuu-notifications';
5
- import { LostConnectionIndicator } from './LostConnectionIndicator.js';
6
-
7
- const useLostConnection = () => {
8
- const { hideNotification, showNotification } = useNotifications();
9
- const isConnectedRef = useRef(ConnectionManager.connected);
10
- const handleConnectionStatusChange = useCallback(
11
- (connectionStatus) => {
12
- const { current: wasConnected } = isConnectedRef;
13
- isConnectedRef.current = isConnected(connectionStatus);
14
- if (wasConnected && connectionStatus === "disconnected") {
15
- showNotification({
16
- content: /* @__PURE__ */ jsx(LostConnectionIndicator, {}),
17
- status: "error",
18
- type: NotificationType.Workspace
19
- });
20
- } else if (!wasConnected && isConnectedRef.current) {
21
- hideNotification();
22
- }
23
- },
24
- [hideNotification, showNotification]
25
- );
26
- useMemo(async () => {
27
- ConnectionManager.on("connection-status", handleConnectionStatusChange);
28
- }, [handleConnectionStatusChange]);
29
- };
30
-
31
- export { useLostConnection };
32
- //# sourceMappingURL=useLostConnection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLostConnection.js","sources":["../../../../packages/vuu-data-react/src/lost-connection-indicator/useLostConnection.tsx"],"sourcesContent":["import {\n ConnectionManager,\n ConnectionStatus,\n isConnected,\n} from \"@vuu-ui/vuu-data-remote\";\nimport { useCallback, useMemo, useRef } from \"react\";\nimport { NotificationType, useNotifications } from \"@vuu-ui/vuu-notifications\";\nimport { LostConnectionIndicator } from \"../lost-connection-indicator/LostConnectionIndicator\";\n\nexport const useLostConnection = () => {\n const { hideNotification, showNotification } = useNotifications();\n\n const isConnectedRef = useRef(ConnectionManager.connected);\n\n const handleConnectionStatusChange = useCallback(\n (connectionStatus: ConnectionStatus) => {\n const { current: wasConnected } = isConnectedRef;\n isConnectedRef.current = isConnected(connectionStatus);\n\n if (wasConnected && connectionStatus === \"disconnected\") {\n showNotification({\n content: <LostConnectionIndicator />,\n status: \"error\",\n type: NotificationType.Workspace,\n });\n } else if (!wasConnected && isConnectedRef.current) {\n hideNotification();\n }\n },\n [hideNotification, showNotification],\n );\n\n useMemo(async () => {\n ConnectionManager.on(\"connection-status\", handleConnectionStatusChange);\n }, [handleConnectionStatusChange]);\n};\n"],"names":[],"mappings":";;;;;;AASO,MAAM,oBAAoB,MAAM;AACrC,EAAA,MAAM,EAAE,gBAAA,EAAkB,gBAAiB,EAAA,GAAI,gBAAiB,EAAA;AAEhE,EAAM,MAAA,cAAA,GAAiB,MAAO,CAAA,iBAAA,CAAkB,SAAS,CAAA;AAEzD,EAAA,MAAM,4BAA+B,GAAA,WAAA;AAAA,IACnC,CAAC,gBAAuC,KAAA;AACtC,MAAM,MAAA,EAAE,OAAS,EAAA,YAAA,EAAiB,GAAA,cAAA;AAClC,MAAe,cAAA,CAAA,OAAA,GAAU,YAAY,gBAAgB,CAAA;AAErD,MAAI,IAAA,YAAA,IAAgB,qBAAqB,cAAgB,EAAA;AACvD,QAAiB,gBAAA,CAAA;AAAA,UACf,OAAA,sBAAU,uBAAwB,EAAA,EAAA,CAAA;AAAA,UAClC,MAAQ,EAAA,OAAA;AAAA,UACR,MAAM,gBAAiB,CAAA;AAAA,SACxB,CAAA;AAAA,OACQ,MAAA,IAAA,CAAC,YAAgB,IAAA,cAAA,CAAe,OAAS,EAAA;AAClD,QAAiB,gBAAA,EAAA;AAAA;AACnB,KACF;AAAA,IACA,CAAC,kBAAkB,gBAAgB;AAAA,GACrC;AAEA,EAAA,OAAA,CAAQ,YAAY;AAClB,IAAkB,iBAAA,CAAA,EAAA,CAAG,qBAAqB,4BAA4B,CAAA;AAAA,GACxE,EAAG,CAAC,4BAA4B,CAAC,CAAA;AACnC;;;;"}
@@ -1 +0,0 @@
1
- export declare const useLostConnection: () => void;