@robosystems/core 0.9.3 → 0.9.5
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/README.md
CHANGED
|
@@ -35,12 +35,12 @@ import { useToast } from '@robosystems/core/hooks/use-toast'
|
|
|
35
35
|
|
|
36
36
|
- [RoboSystems Platform](https://robosystems.ai)
|
|
37
37
|
- [GitHub Repository](https://github.com/RoboFinSystems/robosystems-core)
|
|
38
|
-
- [API
|
|
38
|
+
- [API Reference](https://robosystems.ai/docs/api)
|
|
39
39
|
|
|
40
40
|
## Support
|
|
41
41
|
|
|
42
42
|
- [Issues](https://github.com/RoboFinSystems/robosystems-core/issues)
|
|
43
|
-
- [
|
|
43
|
+
- [Documentation](https://robosystems.ai/docs/technical)
|
|
44
44
|
- [Projects](https://github.com/orgs/RoboFinSystems/projects)
|
|
45
45
|
- [Discussions](https://github.com/orgs/RoboFinSystems/discussions)
|
|
46
46
|
|
package/package.json
CHANGED
|
@@ -4,6 +4,12 @@ export interface CoreNavbarProps {
|
|
|
4
4
|
currentApp: 'roboledger' | 'roboinvestor' | 'robosystems';
|
|
5
5
|
apiUrl?: string;
|
|
6
6
|
homeHref?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Where the user menu's Documentation item points. Defaults to this app's own
|
|
9
|
+
* `/docs`; an app without docs of its own passes an absolute URL. `null` drops
|
|
10
|
+
* the item.
|
|
11
|
+
*/
|
|
12
|
+
docsHref?: string | null;
|
|
7
13
|
logoAltText?: string;
|
|
8
14
|
additionalComponents?: React.ReactNode;
|
|
9
15
|
className?: string;
|
|
@@ -11,4 +17,4 @@ export interface CoreNavbarProps {
|
|
|
11
17
|
useCustomThemeToggle?: boolean;
|
|
12
18
|
showAppSwitcherFirst?: boolean;
|
|
13
19
|
}
|
|
14
|
-
export declare function CoreNavbar({ appName, currentApp, apiUrl, homeHref, logoAltText, additionalComponents, className, borderColorClass, useCustomThemeToggle, showAppSwitcherFirst, }: CoreNavbarProps): React.JSX.Element;
|
|
20
|
+
export declare function CoreNavbar({ appName, currentApp, apiUrl, homeHref, docsHref, logoAltText, additionalComponents, className, borderColorClass, useCustomThemeToggle, showAppSwitcherFirst, }: CoreNavbarProps): React.JSX.Element;
|
|
@@ -12,7 +12,7 @@ import { LogoBadge } from '../Logo';
|
|
|
12
12
|
import { useAccountSettingsLink } from './account-settings';
|
|
13
13
|
import { ThemeToggle } from './ThemeToggle';
|
|
14
14
|
export function CoreNavbar({ appName, currentApp, apiUrl = process.env.NEXT_PUBLIC_ROBOSYSTEMS_API_URL ||
|
|
15
|
-
'http://localhost:8000', homeHref = '/home', logoAltText, additionalComponents, className = '', borderColorClass = 'dark:border-gray-700', useCustomThemeToggle = true, showAppSwitcherFirst = false, }) {
|
|
15
|
+
'http://localhost:8000', homeHref = '/home', docsHref = '/docs', logoAltText, additionalComponents, className = '', borderColorClass = 'dark:border-gray-700', useCustomThemeToggle = true, showAppSwitcherFirst = false, }) {
|
|
16
16
|
const sidebar = useSidebarContext();
|
|
17
17
|
const isDesktop = useMediaQuery('(min-width: 1024px)');
|
|
18
18
|
const { user } = useUser();
|
|
@@ -44,13 +44,18 @@ export function CoreNavbar({ appName, currentApp, apiUrl = process.env.NEXT_PUBL
|
|
|
44
44
|
return (_jsxs(_Fragment, { children: [_jsx("div", { className: "hidden dark:block", children: _jsx(Tooltip, { content: "Toggle light mode", theme: customTheme.tooltip, children: _jsx(DarkThemeToggle, {}) }) }), _jsx("div", { className: "dark:hidden", children: _jsx(Tooltip, { content: "Toggle dark mode", theme: customTheme.tooltip, children: _jsx(DarkThemeToggle, {}) }) })] }));
|
|
45
45
|
};
|
|
46
46
|
const renderAppSwitcher = () => (_jsx(Tooltip, { content: "Switch apps", theme: customTheme.tooltip, children: _jsx(AppSwitcher, { apiUrl: apiUrl, currentApp: currentApp }) }));
|
|
47
|
-
return (_jsx(FlowbiteNavbar, { fluid: true, theme: customTheme.navbar, className: `fixed top-0 z-30 w-full border-b border-gray-200 p-0 ${borderColorClass} bg-white sm:p-0 dark:bg-black ${className}`, children: _jsx("div", { className: "w-full p-3 pr-4", children: _jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { className: "flex items-center", children: [_jsxs("button", { onClick: handleToggleSidebar, className: "mr-3 cursor-pointer rounded-sm p-2 text-gray-600 hover:bg-zinc-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-zinc-700 dark:hover:text-white", children: [_jsx("span", { className: "sr-only", children: "Toggle sidebar" }), _jsx("div", { className: "lg:hidden", children: sidebar.mobile.isOpen ? (_jsx(HiX, { className: "h-6 w-6" })) : (_jsx(HiMenuAlt1, { className: "h-6 w-6" })) }), _jsx("div", { className: "hidden lg:block", children: _jsx(HiMenuAlt1, { className: "h-6 w-6" }) })] }), _jsxs(NavbarBrand, { as: Link, href: homeHref, className: "mr-14", children: [_jsx(LogoBadge, { app: currentApp, animate: "once", className: "mr-2 h-10 w-10" }), _jsx("span", { className: "font-heading mt-2 ml-1 self-center text-2xl font-semibold whitespace-nowrap text-gray-900 dark:text-white", children: appName })] })] }), _jsx("div", { className: "flex items-center lg:gap-3", children: _jsxs("div", { className: "flex items-center", children: [additionalComponents && (_jsx("div", { className: "mr-2 hidden md:block", children: additionalComponents })), _jsxs("div", { className: "flex items-center space-x-2", children: [showAppSwitcherFirst && renderAppSwitcher(), renderThemeToggle(), !showAppSwitcherFirst && renderAppSwitcher(), _jsx(UserDropdown, { user: user, apiUrl: apiUrl, onLogout: handleLogout })] })] }) })] }) }) }));
|
|
47
|
+
return (_jsx(FlowbiteNavbar, { fluid: true, theme: customTheme.navbar, className: `fixed top-0 z-30 w-full border-b border-gray-200 p-0 ${borderColorClass} bg-white sm:p-0 dark:bg-black ${className}`, children: _jsx("div", { className: "w-full p-3 pr-4", children: _jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { className: "flex items-center", children: [_jsxs("button", { onClick: handleToggleSidebar, className: "mr-3 cursor-pointer rounded-sm p-2 text-gray-600 hover:bg-zinc-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-zinc-700 dark:hover:text-white", children: [_jsx("span", { className: "sr-only", children: "Toggle sidebar" }), _jsx("div", { className: "lg:hidden", children: sidebar.mobile.isOpen ? (_jsx(HiX, { className: "h-6 w-6" })) : (_jsx(HiMenuAlt1, { className: "h-6 w-6" })) }), _jsx("div", { className: "hidden lg:block", children: _jsx(HiMenuAlt1, { className: "h-6 w-6" }) })] }), _jsxs(NavbarBrand, { as: Link, href: homeHref, className: "mr-14", children: [_jsx(LogoBadge, { app: currentApp, animate: "once", className: "mr-2 h-10 w-10" }), _jsx("span", { className: "font-heading mt-2 ml-1 self-center text-2xl font-semibold whitespace-nowrap text-gray-900 dark:text-white", children: appName })] })] }), _jsx("div", { className: "flex items-center lg:gap-3", children: _jsxs("div", { className: "flex items-center", children: [additionalComponents && (_jsx("div", { className: "mr-2 hidden md:block", children: additionalComponents })), _jsxs("div", { className: "flex items-center space-x-2", children: [showAppSwitcherFirst && renderAppSwitcher(), renderThemeToggle(), !showAppSwitcherFirst && renderAppSwitcher(), _jsx(UserDropdown, { user: user, apiUrl: apiUrl, docsHref: docsHref, onLogout: handleLogout })] })] }) })] }) }) }));
|
|
48
48
|
}
|
|
49
|
-
function UserDropdown({ user, apiUrl, onLogout }) {
|
|
49
|
+
function UserDropdown({ user, apiUrl, docsHref, onLogout }) {
|
|
50
50
|
const settings = useAccountSettingsLink(apiUrl);
|
|
51
51
|
return (_jsx("div", { className: "relative", children: _jsxs(Dropdown, { theme: Object.assign(Object.assign({}, customTheme.dropdown), { floating: Object.assign(Object.assign({}, customTheme.dropdown.floating), { base: `${customTheme.dropdown.floating.base} z-50! w-64` }) }), arrowIcon: false, inline: true, label: _jsxs("span", { className: "inline-flex h-10 w-10 items-center justify-center rounded-lg text-sm text-gray-500 hover:bg-zinc-100 focus:ring-2 focus:ring-gray-200 focus:outline-hidden dark:text-gray-400 dark:hover:bg-zinc-700 dark:focus:ring-gray-600", children: [_jsx("span", { className: "sr-only", children: "User menu" }), _jsx(HiUserCircle, { className: "h-6 w-6" })] }), children: [_jsxs(DropdownHeader, { theme: { header: customTheme.dropdown.floating.header }, className: "px-4 py-3", children: [_jsx("div", { className: "block text-sm font-medium text-gray-900 dark:text-white", children: (user === null || user === void 0 ? void 0 : user.name) || 'User' }), (user === null || user === void 0 ? void 0 : user.email) && (_jsx("div", { className: "block truncate text-sm text-gray-500 dark:text-gray-400", children: user.email }))] }), settings.isCrossApp ? (_jsxs(DropdownItem, { theme: customTheme.dropdown.floating.item, onClick: () => {
|
|
52
52
|
void settings.open();
|
|
53
|
-
}, title: settings.description, className: "flex w-full items-center justify-between p-3", children: [_jsx("span", { children: "User Settings" }), _jsx(HiExternalLink, { "aria-hidden": "true", className: "ml-3 h-4 w-4 shrink-0 text-gray-400 dark:text-gray-500" }), _jsx("span", { className: "sr-only", children: ` (opens ${settings.hostAppName} in a new tab)` })] })) : (_jsx(DropdownItem, { theme: customTheme.dropdown.floating.item, as: Link, href: settings.href, className: "flex w-full items-center space-x-3 p-3", children: "User Settings" })),
|
|
53
|
+
}, title: settings.description, className: "flex w-full items-center justify-between p-3", children: [_jsx("span", { children: "User Settings" }), _jsx(HiExternalLink, { "aria-hidden": "true", className: "ml-3 h-4 w-4 shrink-0 text-gray-400 dark:text-gray-500" }), _jsx("span", { className: "sr-only", children: ` (opens ${settings.hostAppName} in a new tab)` })] })) : (_jsx(DropdownItem, { theme: customTheme.dropdown.floating.item, as: Link, href: settings.href, className: "flex w-full items-center space-x-3 p-3", children: "User Settings" })), docsHref && (
|
|
54
|
+
// The docs wear the public site's chrome, so they open in a new tab and
|
|
55
|
+
// the app keeps its place. This is the app's only global route to them:
|
|
56
|
+
// a signed-in visitor to / is sent to /home and never sees the public
|
|
57
|
+
// header's links.
|
|
58
|
+
_jsxs(DropdownItem, { theme: customTheme.dropdown.floating.item, as: Link, href: docsHref, target: "_blank", rel: "noopener noreferrer", className: "flex w-full items-center justify-between p-3", children: [_jsx("span", { children: "Documentation" }), _jsx(HiExternalLink, { "aria-hidden": "true", className: "ml-3 h-4 w-4 shrink-0 text-gray-400 dark:text-gray-500" }), _jsx("span", { className: "sr-only", children: " (opens in a new tab)" })] })), _jsx(DropdownDivider, { theme: { divider: customTheme.dropdown.floating.divider } }), _jsx(DropdownItem, { theme: customTheme.dropdown.floating.item, onClick: () => {
|
|
54
59
|
onLogout();
|
|
55
60
|
}, className: "flex w-full items-center space-x-3 p-3", children: "Sign out" })] }) }));
|
|
56
61
|
}
|