@hanzo/app 0.3.94 → 0.3.96
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/dist/Account.d.ts +9 -3
- package/dist/Account.js +142 -141
- package/dist/App.js +71 -37
- package/dist/Bar.js +1 -1
- package/dist/Betas.d.ts +1 -1
- package/dist/Betas.js +16 -22
- package/dist/Board.js +114 -48
- package/dist/CalScheduler.d.ts +1 -0
- package/dist/CalScheduler.js +223 -57
- package/dist/Chat.js +432 -153
- package/dist/Contacts.js +35 -31
- package/dist/ContextMenu.js +126 -42
- package/dist/Directory.js +1 -1
- package/dist/Drawer.js +1 -1
- package/dist/Drive.js +351 -119
- package/dist/Gate.js +156 -13
- package/dist/Home.js +31 -53
- package/dist/Inbox.js +29 -15
- package/dist/InlineRename.d.ts +6 -0
- package/dist/InlineRename.js +41 -0
- package/dist/Learning.js +132 -13
- package/dist/Market.js +13 -9
- package/dist/Meet.d.ts +5 -0
- package/dist/Meet.js +75 -51
- package/dist/MoreMenu.d.ts +19 -0
- package/dist/MoreMenu.js +33 -0
- package/dist/NeedMoreUsage.js +2 -2
- package/dist/OrgSwitcher.js +6 -2
- package/dist/PreferencesDialog.js +5 -2
- package/dist/Rail.d.ts +73 -7
- package/dist/Rail.js +372 -111
- package/dist/Recents.js +77 -24
- package/dist/RightPane.js +2 -2
- package/dist/Search.d.ts +13 -1
- package/dist/Search.js +366 -50
- package/dist/Setup.js +34 -5
- package/dist/Shared.js +12 -12
- package/dist/Shell.d.ts +10 -0
- package/dist/Shell.js +258 -158
- package/dist/Sidebar.d.ts +14 -3
- package/dist/Sidebar.js +411 -129
- package/dist/SkipLink.d.ts +8 -0
- package/dist/SkipLink.js +11 -0
- package/dist/Start.js +51 -52
- package/dist/Terminals.js +159 -11
- package/dist/ToBottom.js +1 -1
- package/dist/Upgrade.d.ts +8 -3
- package/dist/Upgrade.js +194 -103
- package/dist/Usage.d.ts +1 -1
- package/dist/Usage.js +186 -82
- package/dist/WalletPill.js +8 -2
- package/dist/Work.js +162 -53
- package/dist/archive.d.ts +8 -0
- package/dist/archive.js +16 -0
- package/dist/bots/Bots.js +16 -1
- package/dist/bots/ComputerDialog.js +53 -26
- package/dist/bots/ConnectorsDialog.js +34 -15
- package/dist/bots/Make.js +5 -1
- package/dist/bots/Panel.js +37 -31
- package/dist/bots/Roster.d.ts +4 -1
- package/dist/bots/Roster.js +71 -25
- package/dist/bots/Thread.js +54 -27
- package/dist/bots/face.js +9 -3
- package/dist/bots/grid.d.ts +36 -0
- package/dist/bots/grid.js +91 -0
- package/dist/bots/ink.d.ts +1 -1
- package/dist/bots/ink.js +1 -1
- package/dist/bots/kit.d.ts +9 -4
- package/dist/bots/kit.js +3 -2
- package/dist/chord.d.ts +13 -0
- package/dist/chord.js +30 -1
- package/dist/crew.js +47 -4
- package/dist/ground.d.ts +2 -2
- package/dist/ground.js +3 -3
- package/dist/help.d.ts +7 -3
- package/dist/help.js +19 -14
- package/dist/keys.d.ts +28 -0
- package/dist/keys.js +58 -0
- package/dist/lib/arrival.d.ts +5 -0
- package/dist/lib/arrival.js +10 -0
- package/dist/lib/betas.d.ts +2 -0
- package/dist/lib/betas.js +10 -0
- package/dist/lib/branch.d.ts +11 -0
- package/dist/lib/branch.js +11 -0
- package/dist/lib/chatPreferences.d.ts +1 -1
- package/dist/lib/chatPreferences.js +1 -1
- package/dist/lib/dev-mode.d.ts +18 -0
- package/dist/lib/dev-mode.js +102 -0
- package/dist/lib/durable.d.ts +1 -1
- package/dist/lib/durable.js +1 -1
- package/dist/lib/info-hint.d.ts +7 -0
- package/dist/lib/info-hint.js +8 -0
- package/dist/lib/model-picker.d.ts +2 -0
- package/dist/lib/model-picker.js +12 -0
- package/dist/lib/owners.d.ts +5 -0
- package/dist/lib/owners.js +15 -0
- package/dist/lib/pay.d.ts +2 -0
- package/dist/lib/pay.js +4 -0
- package/dist/lib/todo.d.ts +7 -1
- package/dist/lib/todo.js +41 -29
- package/dist/look.js +39 -8
- package/dist/rail-open.d.ts +9 -0
- package/dist/rail-open.js +34 -0
- package/dist/renaming.d.ts +10 -0
- package/dist/renaming.js +25 -0
- package/dist/seek.d.ts +6 -1
- package/dist/seek.js +13 -0
- package/dist/thread.d.ts +2 -1
- package/dist/thread.js +85 -44
- package/package.json +11 -11
package/dist/Rail.js
CHANGED
|
@@ -1,60 +1,78 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
// bar, the palette and the landing pages draw from.
|
|
12
|
-
//
|
|
13
|
-
// Studio is the app's third mode (@hanzo/studio at /studio), each of the three
|
|
14
|
-
// opened where the reader left it.
|
|
15
|
-
//
|
|
16
|
-
// Dev, Studio, Tabs and Team are products, named as they are in every
|
|
17
|
-
// language; the rest of the rail's words go through `t`.
|
|
18
|
-
//
|
|
19
|
-
// A mark is a place, and a place owns the sidebar beside the rail: Chat its
|
|
20
|
-
// conversations, Dev its own places (@hanzo/build `own`: New run, Projects,
|
|
21
|
-
// Issues, Templates) and its runs, Studio its own; Library, Scheduled tasks and
|
|
22
|
-
// Customize (@hanzo/build's Artifacts, Automations and Customize) each their
|
|
23
|
-
// own (Sidebar.tsx); Settings is the site's pages at /settings, beside the app
|
|
24
|
-
// (lib/host.ts `settings`). Nothing on the rail is listed inside Dev: one level
|
|
25
|
-
// of the app a place, each lit while the reader is on it.
|
|
26
|
-
//
|
|
27
|
-
// It stands on the frame's floor, never cut as a pane (ground.ts): the rail and
|
|
28
|
-
// the sidebar beside it are the window, and the content is the panel inset in
|
|
29
|
-
// it.
|
|
30
|
-
//
|
|
31
|
-
// The sidebar's toggle leads it (`toggle`) where the host has no bar of its own:
|
|
32
|
-
// a browser tab. A host that is a window draws the toggle in its bar beside Back
|
|
33
|
-
// and Forward (App.tsx `bar`), and its rail starts with Chat. A phone has no
|
|
34
|
-
// rail: its menu (Drawer.tsx) lists the places as rows (`rows`) under the mode's
|
|
35
|
-
// own — Design, Studio, Tabs, then More, which Library, Scheduled tasks and
|
|
36
|
-
// Customize lead there. Chat and Dev are the rail's marks beside them, and the
|
|
37
|
-
// account is the menu's foot.
|
|
3
|
+
// Folded left navigation rail (52px icons-only, shown when the unified sidebar
|
|
4
|
+
// is folded, plus the compact phone drawer rail):
|
|
5
|
+
// - Shared `useNavEntries()` model keeps Hanzo's exact product names & order
|
|
6
|
+
// (`Chat`, `Dev`, `Design`, `Studio` if opened, `Library`, `Scheduled tasks`,
|
|
7
|
+
// `Customize`, `Tabs`, `Betas`, and every hosted app or beta the reader may open;
|
|
8
|
+
// Developer mode hides none of them) across both the unified Sidebar and the 52px folded Rail.
|
|
9
|
+
// - Strictly monochrome active chrome (`bg="$raised"`, `color="$ink"`).
|
|
10
|
+
// - Every `render="button"` element uses `onClick` (never `onPress`).
|
|
38
11
|
import { useI18n } from '@hanzo/i18n/react';
|
|
39
|
-
import { Bot, CircleHelp, Compass, Ellipsis, FlaskConical, PanelLeft, Settings, Sparkles, Users } from 'lucide-react';
|
|
12
|
+
import { Bot, CircleHelp, Compass, Ellipsis, FlaskConical, PanelLeft, PanelLeftOpen, Plus, Settings, Sparkles, Users, Workflow, } from 'lucide-react';
|
|
40
13
|
import { useState } from 'react';
|
|
41
|
-
import {
|
|
14
|
+
import { XStack, YStack, Text } from '@hanzo/gui';
|
|
42
15
|
import { MARKS, route } from '@hanzo/build';
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
16
|
+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from '@hanzo/ui';
|
|
17
|
+
import { MoreMenu } from './MoreMenu.js';
|
|
45
18
|
import { BetasDialog, useBetas } from './Betas.js';
|
|
46
19
|
import { out } from './help.js';
|
|
47
20
|
import { BETAS } from './lib/betas.js';
|
|
48
21
|
import { HOSTED_APPS } from './lib/hosted.js';
|
|
49
22
|
import { Account } from './Account.js';
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
23
|
+
import { useDevMode } from './lib/dev-mode.js';
|
|
24
|
+
import { usePref } from './pref.js';
|
|
25
|
+
import { HEAD, MARK, TOUCH_HEAD } from './ground.js';
|
|
26
|
+
import { apex, app, design, flow, hosted, studio, talk, TERMINALS, WORKSPACE } from './lib/host.js';
|
|
27
|
+
import { site } from './where.js';
|
|
52
28
|
export { MARK };
|
|
29
|
+
export const RAIL_FOLDED = 52;
|
|
53
30
|
/** A mark on a touch screen, px: a thumb's 44. */
|
|
54
31
|
const TOUCH = 44;
|
|
32
|
+
/** Where the pinned apps are kept: on the account (`usePref`), under the key this browser has always used, so earlier pins stay. */
|
|
33
|
+
export const NAV_PINNED_KEY = 'hanzo.nav.pinned';
|
|
34
|
+
export const DEFAULT_PINNED_NAV = ['chat', 'dev', 'design', 'library', 'tabs'];
|
|
35
|
+
const CORE_NAV_SET = new Set(DEFAULT_PINNED_NAV);
|
|
36
|
+
/** The reader's own order, with all 5 core apps (Chat, Dev, Design, Library, Tabs) anchored at the top and never dropped into More. */
|
|
37
|
+
export function normalizePinnedNav(list) {
|
|
38
|
+
const ordered = [...new Set(list.filter(Boolean))];
|
|
39
|
+
return [...DEFAULT_PINNED_NAV.filter((id) => !ordered.includes(id)), ...ordered];
|
|
40
|
+
}
|
|
41
|
+
/** `list` with `id` pinned or unpinned; the core apps stay. */
|
|
42
|
+
export function toggledPinnedNav(list, id) {
|
|
43
|
+
if (!id || CORE_NAV_SET.has(id))
|
|
44
|
+
return normalizePinnedNav(list);
|
|
45
|
+
return normalizePinnedNav(list.includes(id) ? list.filter((item) => item !== id) : [...list, id]);
|
|
46
|
+
}
|
|
47
|
+
/** `list` with `sourceId` moved to where `targetId` stands. */
|
|
48
|
+
export function reorderedPinnedNav(list, sourceId, targetId) {
|
|
49
|
+
if (!sourceId || !targetId || sourceId === targetId)
|
|
50
|
+
return normalizePinnedNav(list);
|
|
51
|
+
const without = list.filter((id) => id !== sourceId);
|
|
52
|
+
const at = without.indexOf(targetId);
|
|
53
|
+
without.splice(at < 0 ? without.length : at, 0, sourceId);
|
|
54
|
+
return normalizePinnedNav(without);
|
|
55
|
+
}
|
|
56
|
+
/** `list` with `id` swapped with its neighbour one place up (-1) or down (1) among `visible`, the pins the reader sees (one may be hidden): the keyboard's way to the order a drag makes. */
|
|
57
|
+
export function shiftedPinnedNav(list, id, delta, visible = list) {
|
|
58
|
+
const next = normalizePinnedNav(list);
|
|
59
|
+
const other = visible[visible.indexOf(id) + delta];
|
|
60
|
+
const from = next.indexOf(id);
|
|
61
|
+
const to = other === undefined ? -1 : next.indexOf(other);
|
|
62
|
+
if (from < 0 || to < 0)
|
|
63
|
+
return next;
|
|
64
|
+
[next[from], next[to]] = [next[to], next[from]];
|
|
65
|
+
return next;
|
|
66
|
+
}
|
|
67
|
+
/** The pinned apps, a toggle for one, a reorder and a move, kept on the account. */
|
|
68
|
+
export function usePinnedNav() {
|
|
69
|
+
const [kept, keep] = usePref(NAV_PINNED_KEY, [...DEFAULT_PINNED_NAV]);
|
|
70
|
+
const pinned = normalizePinnedNav(Array.isArray(kept) ? kept : DEFAULT_PINNED_NAV);
|
|
71
|
+
return [pinned, (id) => keep(toggledPinnedNav(pinned, id)), (src, target) => keep(reorderedPinnedNav(pinned, src, target)), (id, delta, visible) => keep(shiftedPinnedNav(pinned, id, delta, visible))];
|
|
72
|
+
}
|
|
55
73
|
/** The places the rail holds beside the products, by the builder address each opens. */
|
|
56
74
|
export const RAISED = { library: '-/artifacts', scheduled: '-/automations', customize: '-/customize' };
|
|
57
|
-
/** Which of them a builder address stands on, if any, and so takes the sidebar
|
|
75
|
+
/** Which of them a builder address stands on, if any, and so takes the sidebar. */
|
|
58
76
|
export function raised(at) {
|
|
59
77
|
if (at === null)
|
|
60
78
|
return null;
|
|
@@ -67,81 +85,324 @@ export function raised(at) {
|
|
|
67
85
|
return 'customize';
|
|
68
86
|
return null;
|
|
69
87
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
function
|
|
78
|
-
return (_jsx(SidebarItem, { rounded: "$4", minH: 31, py: 0, px: "$2", $touchable: { minH: 44 }, active: on, icon: icon ? (_jsx(XStack, { width: 20, height: 20, items: "center", justify: "center", shrink: 0, children: icon })) : null, onPress: onPress, onKeyDown: (e) => {
|
|
79
|
-
if (!onPress || (e.key !== 'Enter' && e.key !== ' '))
|
|
80
|
-
return;
|
|
81
|
-
e.preventDefault?.();
|
|
82
|
-
onPress();
|
|
83
|
-
}, ...rest, children: _jsx(Text, { fontSize: "$3", color: on ? '$ink' : '$quiet', children: label }) }));
|
|
84
|
-
}
|
|
85
|
-
/** The sidebar's toggle: the same mark wherever a host draws it. Its icon is the sidebar at the start edge, mirrored right to left. */
|
|
86
|
-
export function Toggle({ open, onPress, label }) {
|
|
88
|
+
export const fullNavUrl = (href) => {
|
|
89
|
+
if (/^https?:\/\//.test(href))
|
|
90
|
+
return href;
|
|
91
|
+
if (typeof window === 'undefined')
|
|
92
|
+
return href;
|
|
93
|
+
return new URL(site(href), window.location.href).href;
|
|
94
|
+
};
|
|
95
|
+
export function useNavEntries({ host, mode, at, inside = null, onChat, onDev, onDesign, onStudio, onTabs, go, pins, }) {
|
|
87
96
|
const { t } = useI18n();
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const { t, dir } = useI18n();
|
|
97
|
+
const [devMode] = useDevMode();
|
|
98
|
+
const [pinnedIds, togglePin] = pins;
|
|
99
|
+
const { open: opened } = useBetas();
|
|
92
100
|
const anon = host.person === null;
|
|
93
101
|
const here = mode === 'dev' ? raised(at) : null;
|
|
94
102
|
const to = (p) => () => go(app(p));
|
|
95
|
-
// The products on hosts of their own, behind More; on a phone the raised places lead it.
|
|
96
|
-
// Studio offers no Team, so on a laptop it draws no More.
|
|
97
103
|
const team = mode !== 'studio' && mode !== 'design';
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
// The apps in beta this reader may open, each where it lives; those that draw inside the app have marks of their own.
|
|
101
|
-
const granted = BETAS.filter((b) => b.href && b.embed === undefined && b.id !== 'studio' && opened(b.id));
|
|
102
|
-
const apps = HOSTED_APPS.filter((a) => opened(a.id));
|
|
103
|
-
// A link out of the app, or a place in it.
|
|
104
|
+
const rawGranted = BETAS.filter((b) => b.href && b.embed === undefined && b.id !== 'studio' && b.id !== 'flow' && opened(b.id));
|
|
105
|
+
const rawApps = HOSTED_APPS.filter((a) => opened(a.id));
|
|
104
106
|
const reach = (address) => (address.startsWith('/') ? go(address) : out(address));
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
107
|
+
const pinnedSet = new Set(pinnedIds);
|
|
108
|
+
// Everything Hanzo showed before stays reachable without Developer mode (unpinned ones sit in More).
|
|
109
|
+
const apps = rawApps;
|
|
110
|
+
const granted = rawGranted;
|
|
111
|
+
const localTeamHref = typeof window !== 'undefined' && !apex(window.location.hostname) ? '/home' : WORKSPACE;
|
|
112
|
+
const localBotsHref = typeof window !== 'undefined' && !apex(window.location.hostname) ? '/bots' : 'https://hanzo.bot';
|
|
113
|
+
const allEntries = [
|
|
114
|
+
{
|
|
115
|
+
id: 'chat',
|
|
116
|
+
slot: 'rail-chat',
|
|
117
|
+
label: t('Chat'),
|
|
118
|
+
href: talk(),
|
|
119
|
+
pinnable: false,
|
|
120
|
+
on: mode === 'chat',
|
|
121
|
+
icon: _jsx(MARKS.chat.icon, { size: 17, "aria-hidden": true }),
|
|
122
|
+
onPress: onChat,
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: 'dev',
|
|
126
|
+
slot: 'rail-dev',
|
|
127
|
+
label: 'Dev',
|
|
128
|
+
href: app(''),
|
|
129
|
+
pinnable: false,
|
|
130
|
+
on: mode === 'dev' && !here,
|
|
131
|
+
icon: _jsx(MARKS.dev.icon, { size: 17, "aria-hidden": true }),
|
|
132
|
+
onPress: onDev,
|
|
133
|
+
},
|
|
134
|
+
...(anon
|
|
135
|
+
? []
|
|
136
|
+
: [
|
|
137
|
+
{
|
|
138
|
+
id: 'design',
|
|
139
|
+
slot: 'rail-design',
|
|
140
|
+
label: 'Design',
|
|
141
|
+
href: design(''),
|
|
142
|
+
pinnable: false,
|
|
143
|
+
on: mode === 'design',
|
|
144
|
+
icon: _jsx(MARKS.design.icon, { size: 17, "aria-hidden": true }),
|
|
145
|
+
onPress: () => onDesign?.(),
|
|
146
|
+
},
|
|
147
|
+
]),
|
|
148
|
+
{
|
|
149
|
+
id: 'library',
|
|
150
|
+
slot: 'rail-library',
|
|
151
|
+
label: t('Library'),
|
|
152
|
+
href: app(RAISED.library),
|
|
153
|
+
pinnable: false,
|
|
154
|
+
on: here === 'library',
|
|
155
|
+
icon: _jsx(MARKS.library.icon, { size: 17, "aria-hidden": true }),
|
|
156
|
+
onPress: to(RAISED.library),
|
|
157
|
+
},
|
|
158
|
+
...(anon
|
|
159
|
+
? []
|
|
160
|
+
: [
|
|
161
|
+
{
|
|
162
|
+
id: 'scheduled',
|
|
163
|
+
slot: 'rail-scheduled',
|
|
164
|
+
label: t('Scheduled tasks'),
|
|
165
|
+
href: app(RAISED.scheduled),
|
|
166
|
+
on: here === 'scheduled',
|
|
167
|
+
icon: _jsx(MARKS.scheduled.icon, { size: 17, "aria-hidden": true }),
|
|
168
|
+
onPress: to(RAISED.scheduled),
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
id: 'customize',
|
|
172
|
+
slot: 'rail-customize',
|
|
173
|
+
label: t('Customize'),
|
|
174
|
+
href: app(RAISED.customize),
|
|
175
|
+
on: here === 'customize',
|
|
176
|
+
icon: _jsx(MARKS.customize.icon, { size: 17, "aria-hidden": true }),
|
|
177
|
+
onPress: to(RAISED.customize),
|
|
178
|
+
},
|
|
179
|
+
...(opened('studio')
|
|
180
|
+
? [
|
|
181
|
+
{
|
|
182
|
+
id: 'studio',
|
|
183
|
+
slot: 'rail-studio',
|
|
184
|
+
label: 'Studio',
|
|
185
|
+
href: studio(''),
|
|
186
|
+
on: mode === 'studio',
|
|
187
|
+
icon: _jsx(MARKS.studio.icon, { size: 17, "aria-hidden": true }),
|
|
188
|
+
onPress: onStudio,
|
|
189
|
+
},
|
|
190
|
+
]
|
|
191
|
+
: []),
|
|
192
|
+
...(opened('flow') || mode === 'flow'
|
|
193
|
+
? [
|
|
194
|
+
{
|
|
195
|
+
id: 'flow',
|
|
196
|
+
slot: 'rail-flow',
|
|
197
|
+
label: 'Flow',
|
|
198
|
+
href: flow(''),
|
|
199
|
+
on: mode === 'flow',
|
|
200
|
+
icon: _jsx(Workflow, { size: 17, "aria-hidden": true }),
|
|
201
|
+
onPress: () => go(flow('')),
|
|
202
|
+
},
|
|
203
|
+
]
|
|
204
|
+
: []),
|
|
205
|
+
{
|
|
206
|
+
id: 'tabs',
|
|
207
|
+
slot: 'rail-tabs',
|
|
208
|
+
label: 'Tabs',
|
|
209
|
+
href: TERMINALS,
|
|
210
|
+
pinnable: false,
|
|
211
|
+
on: mode === 'tabs',
|
|
212
|
+
icon: _jsx(MARKS.tabs.icon, { size: 17, "aria-hidden": true }),
|
|
213
|
+
onPress: onTabs,
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
id: 'betas',
|
|
217
|
+
slot: 'rail-betas',
|
|
218
|
+
label: t('Betas'),
|
|
219
|
+
href: '/beta',
|
|
220
|
+
on: mode === 'beta',
|
|
221
|
+
icon: _jsx(FlaskConical, { size: 17, "aria-hidden": true }),
|
|
222
|
+
onPress: () => go('/beta'),
|
|
223
|
+
},
|
|
224
|
+
...apps.map((a) => ({
|
|
225
|
+
id: `app-${a.id}`,
|
|
226
|
+
slot: `rail-app-${a.id}`,
|
|
227
|
+
label: a.name,
|
|
228
|
+
href: hosted(a.id),
|
|
229
|
+
on: inside === a.id,
|
|
230
|
+
icon: _jsx(a.icon, { size: 17, "aria-hidden": true }),
|
|
231
|
+
onPress: () => go(hosted(a.id)),
|
|
232
|
+
})),
|
|
233
|
+
]),
|
|
122
234
|
];
|
|
235
|
+
const externalEntries = !anon && team
|
|
236
|
+
? [
|
|
237
|
+
{
|
|
238
|
+
id: 'ext-team',
|
|
239
|
+
slot: 'rail-ext-team',
|
|
240
|
+
label: 'Team',
|
|
241
|
+
href: localTeamHref,
|
|
242
|
+
external: localTeamHref.startsWith('http'),
|
|
243
|
+
on: false,
|
|
244
|
+
icon: _jsx(Users, { size: 17, "aria-hidden": true }),
|
|
245
|
+
onPress: () => reach(localTeamHref),
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
id: 'ext-bots',
|
|
249
|
+
slot: 'rail-ext-bots',
|
|
250
|
+
label: 'Bot',
|
|
251
|
+
href: localBotsHref,
|
|
252
|
+
external: localBotsHref.startsWith('http'),
|
|
253
|
+
on: false,
|
|
254
|
+
icon: _jsx(Bot, { size: 17, "aria-hidden": true }),
|
|
255
|
+
onPress: () => reach(localBotsHref),
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
id: 'ext-market',
|
|
259
|
+
slot: 'rail-ext-market',
|
|
260
|
+
label: t('Marketplace'),
|
|
261
|
+
href: 'https://hanzo.market',
|
|
262
|
+
external: true,
|
|
263
|
+
on: false,
|
|
264
|
+
icon: _jsx(Compass, { size: 17, "aria-hidden": true }),
|
|
265
|
+
onPress: () => out('https://hanzo.market'),
|
|
266
|
+
},
|
|
267
|
+
...granted.map((b) => ({
|
|
268
|
+
id: `beta-${b.id}`,
|
|
269
|
+
slot: `rail-beta-${b.id}`,
|
|
270
|
+
label: b.name,
|
|
271
|
+
href: b.href,
|
|
272
|
+
external: !b.href.startsWith('/'),
|
|
273
|
+
on: false,
|
|
274
|
+
icon: _jsx(Sparkles, { size: 17, "aria-hidden": true }),
|
|
275
|
+
onPress: () => reach(b.href),
|
|
276
|
+
})),
|
|
277
|
+
]
|
|
278
|
+
: [];
|
|
279
|
+
const combinedById = new Map([...allEntries, ...externalEntries].map((item) => [item.id, item]));
|
|
280
|
+
// Anonymous visitors see the public trio (Chat, Dev, Library).
|
|
281
|
+
const pinnedEntries = anon
|
|
282
|
+
? allEntries
|
|
283
|
+
: pinnedIds.map((id) => combinedById.get(id)).filter((item) => Boolean(item));
|
|
284
|
+
const shownInPrimary = new Set(pinnedEntries.map((item) => item.id));
|
|
285
|
+
const moreEntries = anon
|
|
286
|
+
? []
|
|
287
|
+
: [
|
|
288
|
+
...allEntries.filter((item) => !shownInPrimary.has(item.id)),
|
|
289
|
+
...externalEntries.filter((item) => !shownInPrimary.has(item.id)),
|
|
290
|
+
];
|
|
291
|
+
return {
|
|
292
|
+
anon,
|
|
293
|
+
devMode,
|
|
294
|
+
team,
|
|
295
|
+
here,
|
|
296
|
+
apps,
|
|
297
|
+
granted,
|
|
298
|
+
pinnedIds,
|
|
299
|
+
pinnedSet,
|
|
300
|
+
togglePin,
|
|
301
|
+
allEntries,
|
|
302
|
+
externalEntries,
|
|
303
|
+
pinnedEntries,
|
|
304
|
+
moreEntries,
|
|
305
|
+
shownInPrimary,
|
|
306
|
+
reach,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
/** One mark: an icon button named for where it goes (`label`), with optional instant Tooltip when folded. */
|
|
310
|
+
export function Mark({ label, on = false, tooltip = false, onPress, onClick, children, ...rest }) {
|
|
311
|
+
const handleClick = onClick ?? onPress;
|
|
312
|
+
const button = (_jsx(XStack, { render: "button", "aria-label": label, ...(tooltip ? {} : { title: label }), "aria-current": on ? 'page' : undefined, onClick: handleClick, width: MARK, height: MARK, rounded: 12, items: "center", justify: "center", shrink: 0, cursor: "pointer", opacity: on ? 1 : 0.76, bg: on ? '$raised' : 'transparent', hoverStyle: { bg: on ? '$raised' : '$hover', opacity: 1 }, pressStyle: { bg: '$raised' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' }, $touchable: { width: TOUCH, height: TOUCH }, ...rest, children: children }));
|
|
313
|
+
if (!tooltip)
|
|
314
|
+
return button;
|
|
315
|
+
return (_jsxs(Tooltip, { placement: "right", offset: 8, children: [_jsx(TooltipTrigger, { asChild: true, children: button }), _jsx(TooltipContent, { maxW: 240, px: "$2.5", py: "$1.5", rounded: "$3", bg: "var(--popover)", borderWidth: 1, borderColor: "$edge", z: "var(--z-tooltip)", children: _jsx(Text, { fontFamily: "$body", fontSize: "$1", fontWeight: "500", color: "$ink", children: label }) })] }));
|
|
316
|
+
}
|
|
317
|
+
/** The sidebar's toggle: the same mark wherever a host draws it. */
|
|
318
|
+
export function Toggle({ open, onPress, label }) {
|
|
319
|
+
const { t } = useI18n();
|
|
320
|
+
return (_jsx(Mark, { label: label ?? t(open ? 'Close sidebar' : 'Open sidebar'), "data-slot": "sidebar-toggle", "aria-expanded": open, onClick: onPress, children: _jsx(PanelLeft, { size: 18, "aria-hidden": true, "data-i18n-mirror": true }) }));
|
|
321
|
+
}
|
|
322
|
+
export function Rail({ host, mode, at, open, toggle, onOpen, onNew, compact = false, inside = null, onChat, onDev, onDesign, onStudio, onTabs, go, onOrg, pins, }) {
|
|
323
|
+
const { t, dir } = useI18n();
|
|
324
|
+
const [betas, setBetas] = useState(false);
|
|
325
|
+
const [dragId, setDragId] = useState(null);
|
|
326
|
+
const [dropId, setDropId] = useState(null);
|
|
327
|
+
const nav = useNavEntries({
|
|
328
|
+
host,
|
|
329
|
+
mode,
|
|
330
|
+
at,
|
|
331
|
+
inside,
|
|
332
|
+
onChat,
|
|
333
|
+
onDev,
|
|
334
|
+
onDesign,
|
|
335
|
+
onStudio,
|
|
336
|
+
onTabs,
|
|
337
|
+
go,
|
|
338
|
+
pins,
|
|
339
|
+
});
|
|
340
|
+
const { anon, apps, pinnedEntries, allEntries, externalEntries, shownInPrimary, reach } = nav;
|
|
123
341
|
const betasDialog = _jsx(BetasDialog, { open: betas, onOpenChange: setBetas, go: reach });
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
|
|
342
|
+
const unpinnedActive = allEntries.filter((item) => !shownInPrimary.has(item.id) && item.on);
|
|
343
|
+
const visibleMarks = [...pinnedEntries, ...unpinnedActive];
|
|
344
|
+
const overflowBuiltIn = allEntries.filter((item) => !shownInPrimary.has(item.id) && !item.on);
|
|
345
|
+
const overflowExternal = externalEntries.filter((item) => !shownInPrimary.has(item.id));
|
|
346
|
+
const foldedEntries = [...overflowBuiltIn, ...overflowExternal];
|
|
347
|
+
const expandHandler = onOpen ?? toggle;
|
|
348
|
+
const newLabel = mode === 'dev' ? t('New run') : mode === 'design' ? t('New design') : t('New chat');
|
|
349
|
+
const handleNew = onNew ??
|
|
350
|
+
(() => {
|
|
351
|
+
if (mode === 'dev')
|
|
352
|
+
go(app(''));
|
|
353
|
+
else if (mode === 'design')
|
|
354
|
+
go(design(''));
|
|
355
|
+
else if (mode === 'studio')
|
|
356
|
+
go(studio(''));
|
|
357
|
+
else
|
|
358
|
+
go(talk());
|
|
359
|
+
});
|
|
360
|
+
return (_jsx(TooltipProvider, { delay: 90, children: _jsxs(YStack, { "data-slot": "rail", "data-expanded": "false", render: "nav", "aria-label": t('Products'), width: RAIL_FOLDED, flex: 1, minH: 0, pt: (HEAD - MARK) / 2 + 2, pb: 0, gap: 4, shrink: 0, items: "center", $touchable: { pt: (TOUCH_HEAD - TOUCH) / 2, pb: 0 }, children: [!compact && expandHandler ? (_jsx(Mark, { label: t('Open sidebar'), "data-slot": "rail-expand", tooltip: true, onClick: expandHandler, children: _jsx(PanelLeftOpen, { size: 18, "aria-hidden": true, "data-i18n-mirror": true }) })) : null, !compact && mode !== 'beta' && mode !== 'hosted' ? (_jsx(Mark, { label: newLabel, "data-slot": "rail-new", tooltip: true, onClick: handleNew, children: _jsx(Plus, { size: 18, "aria-hidden": true }) })) : null, _jsxs(YStack, { flex: 1, minH: 0, overflowY: "auto", overflowX: "hidden", items: "center", gap: 4, width: "100%", "$platform-web": { scrollbarWidth: 'none' }, children: [visibleMarks.map((item) => {
|
|
361
|
+
const isDragging = dragId === item.id;
|
|
362
|
+
const isDropTarget = dropId === item.id && dragId !== null && dragId !== item.id;
|
|
363
|
+
return (_jsx(YStack, { width: "100%", items: "center", opacity: isDragging ? 0.4 : 1, borderTopWidth: isDropTarget ? 2 : 0, borderColor: "var(--foreground)", pt: isDropTarget ? 2 : 0, "$platform-web": { cursor: isDragging ? 'grabbing' : 'grab' }, ...{
|
|
364
|
+
draggable: !anon,
|
|
365
|
+
onDragStart: (e) => {
|
|
366
|
+
setDragId(item.id);
|
|
367
|
+
e.dataTransfer?.setData('text/plain', item.id);
|
|
368
|
+
if (e.dataTransfer)
|
|
369
|
+
e.dataTransfer.effectAllowed = 'move';
|
|
370
|
+
},
|
|
371
|
+
onDragOver: (e) => {
|
|
372
|
+
if (!dragId || dragId === item.id)
|
|
373
|
+
return;
|
|
374
|
+
e.preventDefault();
|
|
375
|
+
if (e.dataTransfer)
|
|
376
|
+
e.dataTransfer.dropEffect = 'move';
|
|
377
|
+
if (dropId !== item.id)
|
|
378
|
+
setDropId(item.id);
|
|
379
|
+
},
|
|
380
|
+
onDragLeave: () => {
|
|
381
|
+
if (dropId === item.id)
|
|
382
|
+
setDropId(null);
|
|
383
|
+
},
|
|
384
|
+
onDrop: (e) => {
|
|
385
|
+
e.preventDefault();
|
|
386
|
+
const src = dragId || e.dataTransfer?.getData('text/plain');
|
|
387
|
+
if (src && src !== item.id)
|
|
388
|
+
pins[2](src, item.id);
|
|
389
|
+
setDragId(null);
|
|
390
|
+
setDropId(null);
|
|
391
|
+
},
|
|
392
|
+
onDragEnd: () => {
|
|
393
|
+
setDragId(null);
|
|
394
|
+
setDropId(null);
|
|
395
|
+
},
|
|
396
|
+
}, children: _jsx(Mark, { label: item.label, on: item.on, tooltip: true, onClick: item.onPress, "data-slot": item.slot, "data-nav-id": item.id, children: item.icon }) }, item.id));
|
|
397
|
+
}), !anon && foldedEntries.length > 0 ? (_jsx(MoreMenu, { placement: dir === 'rtl' ? 'left-start' : 'right-start', minWidth: 220, maxHeight: 420, entries: foldedEntries, onPin: nav.togglePin, t: t, trigger: _jsx(XStack, { render: "button", "aria-label": t('More'), ...{ title: t('More') }, "data-slot": "rail-more", width: MARK, height: MARK, rounded: 12, items: "center", justify: "center", cursor: "pointer", opacity: 0.68, hoverStyle: { bg: '$hover', opacity: 1 }, pressStyle: { bg: '$raised' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' }, $touchable: { width: TOUCH, height: TOUCH }, children: _jsx(Ellipsis, { size: 18, "aria-hidden": true }) }) })) : null, betasDialog] }), anon ? (_jsxs(YStack, { gap: 4, items: "center", pb: "$1", children: [_jsx(Mark, { label: t('See plans and pricing'), "data-slot": "anon-pricing", tooltip: true, onClick: () => {
|
|
398
|
+
if (typeof window !== 'undefined')
|
|
399
|
+
window.location.assign('/pricing');
|
|
400
|
+
}, children: _jsx(Sparkles, { size: 18, "aria-hidden": true }) }), _jsx(Mark, { label: t('Help'), "data-slot": "anon-help", tooltip: true, onClick: () => {
|
|
401
|
+
if (typeof window !== 'undefined')
|
|
402
|
+
window.open('https://docs.hanzo.ai', '_blank', 'noopener,noreferrer');
|
|
403
|
+
}, children: _jsx(CircleHelp, { size: 18, "aria-hidden": true }) }), _jsx(Mark, { label: t('Settings'), "data-slot": "anon-settings", tooltip: true, onClick: () => {
|
|
404
|
+
if (typeof window !== 'undefined') {
|
|
405
|
+
window.dispatchEvent(new CustomEvent('hanzo:anon-settings', { detail: { open: true } }));
|
|
406
|
+
}
|
|
407
|
+
}, children: _jsx(Settings, { size: 18, "aria-hidden": true }) })] })) : (_jsx(YStack, { width: "100%", items: "center", pt: "$1", children: _jsx(Account, { host: host, narrow: true, onOrg: onOrg }) }))] }) }));
|
|
147
408
|
}
|