@robosystems/core 0.13.1 → 0.13.2
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/components/console/ConsoleDrawer.js +17 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/console-drawer.d.ts +12 -0
- package/lib/console-drawer.js +24 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/package.json +1 -1
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
4
|
import { HiChevronDown, HiChevronUp, HiOutlineArrowsExpand, HiOutlineMinus, HiTerminal, } from 'react-icons/hi';
|
|
5
|
+
import { CONSOLE_DRAWER_STORAGE_KEY, CONSOLE_OPEN_EVENT, } from '../../lib/console-drawer';
|
|
5
6
|
import { ConsoleContent } from './ConsoleContent';
|
|
6
|
-
const STORAGE_KEY =
|
|
7
|
+
const STORAGE_KEY = CONSOLE_DRAWER_STORAGE_KEY;
|
|
7
8
|
/** Height of the closed drawer's bar. */
|
|
8
9
|
export const CONSOLE_DRAWER_BAR_HEIGHT = 32;
|
|
9
10
|
/** Set on <html> to the space the drawer covers; pad page content by it. */
|
|
@@ -77,6 +78,21 @@ export function ConsoleDrawer({ config, className = 'left-0 right-0', }) {
|
|
|
77
78
|
useEffect(() => () => {
|
|
78
79
|
document.documentElement.style.removeProperty(CONSOLE_DRAWER_HEIGHT_VAR);
|
|
79
80
|
}, []);
|
|
81
|
+
// openConsoleDrawer() from any button or page.
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
const onOpen = () => {
|
|
84
|
+
setState((prev) => {
|
|
85
|
+
if (prev.open)
|
|
86
|
+
return prev;
|
|
87
|
+
const merged = Object.assign(Object.assign({}, prev), { open: true });
|
|
88
|
+
writeState(merged);
|
|
89
|
+
return merged;
|
|
90
|
+
});
|
|
91
|
+
setHasOpened(true);
|
|
92
|
+
};
|
|
93
|
+
window.addEventListener(CONSOLE_OPEN_EVENT, onOpen);
|
|
94
|
+
return () => window.removeEventListener(CONSOLE_OPEN_EVENT, onOpen);
|
|
95
|
+
}, []);
|
|
80
96
|
useEffect(() => {
|
|
81
97
|
const onKey = (event) => {
|
|
82
98
|
if (event.ctrlKey && event.key === '`') {
|
package/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { clearUserCookies, clearUserLocalStorage, clearUserSessionStorage, listU
|
|
|
4
4
|
export { AppSwitcher, AuthGuard, AuthProvider, LoginRedirector, SignInForm, SignUpForm, useAuth, } from './auth-components';
|
|
5
5
|
export { useApiError, useGraphWrites, useMediaQuery, useToast, useUser, useUserLimits, type ToastMessage, } from './hooks';
|
|
6
6
|
export { createGraphContext, createGraphProvider, createUseGraphContext, EntityProvider, GraphContext, GraphProvider, OrgProvider, ServiceOfferingsProvider, SidebarProvider, useEntity, useGraphContext, useOrg, useServiceOfferings, useSidebarContext, type EntityContextValue, type EntityProviderProps, type GraphContextValue, type GraphProviderProps, type GraphState, type OrgContextState, type OrgContextValue, type OrgProviderProps, type ServiceOfferings, } from './contexts';
|
|
7
|
-
export { clientGraphCookie, clientSidebarCookie, createMcpConnectorUrl, emitGraphWrites, entityCookie, GRAPH_WRITES_EVENT, graphCookie, readGraphWrites, sidebarCookie, type EntityCookie, type GraphCookie, type GraphWrite, type GraphWritesDetail, type McpConnectorUrl, type SidebarCookie, } from './lib';
|
|
7
|
+
export { clientGraphCookie, clientSidebarCookie, CONSOLE_OPEN_EVENT, createMcpConnectorUrl, emitGraphWrites, entityCookie, GRAPH_WRITES_EVENT, graphCookie, openConsoleDrawer, readGraphWrites, sidebarCookie, type EntityCookie, type GraphCookie, type GraphWrite, type GraphWritesDetail, type McpConnectorUrl, type SidebarCookie, } from './lib';
|
|
8
8
|
export { ApiError, errorStatus, extractErrorDetail, isApiError, isSessionRejection, isTransientError, toApiError, unwrapSdk, type SdkResult, } from './lib/sdk-errors';
|
|
9
9
|
export { generateEntityUri, isUUID, UUID_REGEX } from './utils';
|
|
10
10
|
export { clearGraphSelection, getGraphSelection, persistGraphSelection, } from './actions/graph-actions';
|
package/index.js
CHANGED
|
@@ -20,7 +20,7 @@ OrgProvider,
|
|
|
20
20
|
// Service offerings context
|
|
21
21
|
ServiceOfferingsProvider, SidebarProvider, useEntity, useGraphContext, useOrg, useServiceOfferings, useSidebarContext, } from './contexts';
|
|
22
22
|
// Export lib utilities
|
|
23
|
-
export { clientGraphCookie, clientSidebarCookie, createMcpConnectorUrl, emitGraphWrites, entityCookie, GRAPH_WRITES_EVENT, graphCookie, readGraphWrites, sidebarCookie, } from './lib';
|
|
23
|
+
export { clientGraphCookie, clientSidebarCookie, CONSOLE_OPEN_EVENT, createMcpConnectorUrl, emitGraphWrites, entityCookie, GRAPH_WRITES_EVENT, graphCookie, openConsoleDrawer, readGraphWrites, sidebarCookie, } from './lib';
|
|
24
24
|
// Export the SDK error seam (unwrap an SDK result or throw ApiError)
|
|
25
25
|
export { ApiError, errorStatus, extractErrorDetail, isApiError, isSessionRejection, isTransientError, toApiError, unwrapSdk, } from './lib/sdk-errors';
|
|
26
26
|
// Export utils
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Window event that opens the console drawer from anywhere in an app. */
|
|
2
|
+
export declare const CONSOLE_OPEN_EVENT = "robosystems:console-open";
|
|
3
|
+
/** Where the drawer keeps whether it is open and its height. */
|
|
4
|
+
export declare const CONSOLE_DRAWER_STORAGE_KEY = "robosystems:console-drawer";
|
|
5
|
+
/**
|
|
6
|
+
* Open the console drawer: the one way into the console, from any page.
|
|
7
|
+
*
|
|
8
|
+
* Records the open state as well as signalling it, so a call made before
|
|
9
|
+
* the drawer has mounted (a page's effect runs before its layout's) is
|
|
10
|
+
* still honoured when the drawer reads its state.
|
|
11
|
+
*/
|
|
12
|
+
export declare function openConsoleDrawer(): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Window event that opens the console drawer from anywhere in an app. */
|
|
2
|
+
export const CONSOLE_OPEN_EVENT = 'robosystems:console-open';
|
|
3
|
+
/** Where the drawer keeps whether it is open and its height. */
|
|
4
|
+
export const CONSOLE_DRAWER_STORAGE_KEY = 'robosystems:console-drawer';
|
|
5
|
+
/**
|
|
6
|
+
* Open the console drawer: the one way into the console, from any page.
|
|
7
|
+
*
|
|
8
|
+
* Records the open state as well as signalling it, so a call made before
|
|
9
|
+
* the drawer has mounted (a page's effect runs before its layout's) is
|
|
10
|
+
* still honoured when the drawer reads its state.
|
|
11
|
+
*/
|
|
12
|
+
export function openConsoleDrawer() {
|
|
13
|
+
if (typeof window === 'undefined')
|
|
14
|
+
return;
|
|
15
|
+
try {
|
|
16
|
+
const raw = window.localStorage.getItem(CONSOLE_DRAWER_STORAGE_KEY);
|
|
17
|
+
const state = raw ? JSON.parse(raw) : {};
|
|
18
|
+
window.localStorage.setItem(CONSOLE_DRAWER_STORAGE_KEY, JSON.stringify(Object.assign(Object.assign({}, state), { open: true })));
|
|
19
|
+
}
|
|
20
|
+
catch (_a) {
|
|
21
|
+
// Storage unavailable: the event alone opens a mounted drawer.
|
|
22
|
+
}
|
|
23
|
+
window.dispatchEvent(new Event(CONSOLE_OPEN_EVENT));
|
|
24
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { clientSidebarCookie, sidebarCookie, type SidebarCookie, } from './sidebar-cookie';
|
|
2
2
|
export { clientGraphCookie, graphCookie, type GraphCookie, } from './graph-cookie';
|
|
3
|
+
export { CONSOLE_OPEN_EVENT, openConsoleDrawer } from './console-drawer';
|
|
3
4
|
export { entityCookie, type EntityCookie } from './entity-cookie';
|
|
4
5
|
export { GRAPH_WRITES_EVENT, emitGraphWrites, readGraphWrites, type GraphWrite, type GraphWritesDetail, } from './graph-writes';
|
|
5
6
|
export { createMcpConnectorUrl, type McpConnectorUrl } from './mcp-connector';
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { clientSidebarCookie, sidebarCookie, } from './sidebar-cookie';
|
|
2
2
|
export { clientGraphCookie, graphCookie, } from './graph-cookie';
|
|
3
|
+
export { CONSOLE_OPEN_EVENT, openConsoleDrawer } from './console-drawer';
|
|
3
4
|
export { entityCookie } from './entity-cookie';
|
|
4
5
|
export { GRAPH_WRITES_EVENT, emitGraphWrites, readGraphWrites, } from './graph-writes';
|
|
5
6
|
export { createMcpConnectorUrl } from './mcp-connector';
|
package/package.json
CHANGED