@hanzo/app 0.3.2 → 0.3.3

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.
@@ -8,6 +8,16 @@ export interface OrganizationItem {
8
8
  role?: string;
9
9
  isPersonal?: boolean;
10
10
  }
11
+ /**
12
+ * The organizations a person belongs to (the account's and IAM's, merged by
13
+ * id), the one this page works in, and how to choose another. The dropdown and
14
+ * the rooms' org rail read the same list.
15
+ */
16
+ export declare function useOrgList(): {
17
+ orgs: OrganizationItem[];
18
+ active: string;
19
+ choose: (id: string) => void;
20
+ };
11
21
  export declare function OrgSwitcherDropdown({ open, onClose, activeOrgId, onSelect, align, side, triggerRef, }: {
12
22
  open: boolean;
13
23
  onClose: () => void;
@@ -30,3 +40,11 @@ export declare function OrgSwitcherDropdown({ open, onClose, activeOrgId, onSele
30
40
  * IAM answered, which is also the id a press would have switched to.
31
41
  */
32
42
  export declare function TopOrgSelector(): import("react").JSX.Element;
43
+ /**
44
+ * The organizations as tiles down the far left, as a team chat draws them:
45
+ * each its logo, or its initial in its own hue (@hanzo/ui `Avatar` seeded on its
46
+ * id, as the org chooser and the landing's preview draw it), the one this page
47
+ * works in ringed, and "+" under them for the chooser, where another is made or
48
+ * joined. A press works in that organization.
49
+ */
50
+ export declare function Tiles(): import("react").JSX.Element;
@@ -5,10 +5,10 @@ import { useI18n } from '@hanzo/i18n/react';
5
5
  import { Check, ChevronDown, Plus, Settings } from 'lucide-react';
6
6
  import { HanzoMark } from '@hanzogui/shell';
7
7
  import { useOrganizations } from '@hanzo/iam/react';
8
- import { Button } from '@hanzo/ui';
8
+ import { Avatar, Button } from '@hanzo/ui';
9
9
  import { useAccount } from './lib/account.js';
10
10
  import { iam } from './lib/api.js';
11
- import { pick } from './lib/session.js';
11
+ import { CHOOSE, pick } from './lib/session.js';
12
12
  import { Text, View, XStack, YStack } from '@hanzo/gui';
13
13
  import { site } from './where.js';
14
14
  import { settings } from './lib/host.js';
@@ -16,10 +16,46 @@ import { settings } from './lib/host.js';
16
16
  const FLOOR = 10;
17
17
  /** A row at the foot of the menu that leaves for another page: a ghost Button, label at the start. */
18
18
  const LINK = { variant: 'ghost', size: 'sm', width: '100%', justify: 'flex-start' };
19
+ /**
20
+ * The organizations a person belongs to (the account's and IAM's, merged by
21
+ * id), the one this page works in, and how to choose another. The dropdown and
22
+ * the rooms' org rail read the same list.
23
+ */
24
+ export function useOrgList() {
25
+ const { organizations: iamOrgs, switchOrg, currentOrg, currentOrgId } = useOrganizations() || {};
26
+ const { organizations: accountOrgs, switchOrganization, currentOrganization } = useAccount() || {};
27
+ const orgs = useMemo(() => {
28
+ const map = new Map();
29
+ for (const o of [...(accountOrgs ?? []), ...(iamOrgs ?? [])]) {
30
+ const item = o;
31
+ const id = item.id || item.name;
32
+ if (id && !map.has(id)) {
33
+ map.set(id, {
34
+ id,
35
+ name: item.name || id,
36
+ displayName: item.displayName || item.name || id,
37
+ logo: item.logo || item.avatar,
38
+ role: item.role || 'member',
39
+ isPersonal: Boolean(item.isPersonal),
40
+ });
41
+ }
42
+ }
43
+ return Array.from(map.values());
44
+ }, [accountOrgs, iamOrgs]);
45
+ const current = (currentOrganization || currentOrg);
46
+ const active = current?.name || current?.id || currentOrgId || '';
47
+ const choose = (id) => {
48
+ pick(id);
49
+ if (switchOrg)
50
+ switchOrg(id);
51
+ if (switchOrganization)
52
+ switchOrganization(id);
53
+ };
54
+ return { orgs, active, choose };
55
+ }
19
56
  export function OrgSwitcherDropdown({ open, onClose, activeOrgId, onSelect, align = 'left', side = 'below', triggerRef, }) {
20
57
  const { t } = useI18n();
21
- const { organizations: iamOrgs, switchOrg } = useOrganizations() || {};
22
- const { organizations: accountOrgs, switchOrganization } = useAccount() || {};
58
+ const { orgs, choose } = useOrgList();
23
59
  const menuRef = useRef(null);
24
60
  useEffect(() => {
25
61
  if (!open)
@@ -45,40 +81,6 @@ export function OrgSwitcherDropdown({ open, onClose, activeOrgId, onSelect, alig
45
81
  document.removeEventListener('keydown', handleKeyDown);
46
82
  };
47
83
  }, [open, onClose, triggerRef]);
48
- const orgs = useMemo(() => {
49
- const map = new Map();
50
- // Add detected account orgs
51
- for (const o of (accountOrgs ?? [])) {
52
- const item = o;
53
- const id = item.id || item.name;
54
- if (id) {
55
- map.set(id, {
56
- id,
57
- name: item.name || id,
58
- displayName: item.displayName || item.name || id,
59
- logo: item.logo || item.avatar,
60
- role: item.role || 'member',
61
- isPersonal: Boolean(item.isPersonal),
62
- });
63
- }
64
- }
65
- // Add detected IAM orgs
66
- for (const o of (iamOrgs ?? [])) {
67
- const item = o;
68
- const id = item.id || item.name;
69
- if (id && !map.has(id)) {
70
- map.set(id, {
71
- id,
72
- name: item.name || id,
73
- displayName: item.displayName || item.name || id,
74
- logo: item.logo || item.avatar,
75
- role: item.role || 'member',
76
- isPersonal: Boolean(item.isPersonal),
77
- });
78
- }
79
- }
80
- return Array.from(map.values());
81
- }, [accountOrgs, iamOrgs]);
82
84
  if (!open)
83
85
  return null;
84
86
  // Where it opens. The offset rides a margin, so each edge is a plain length gui can take.
@@ -92,11 +94,7 @@ export function OrgSwitcherDropdown({ open, onClose, activeOrgId, onSelect, alig
92
94
  return (_jsxs(YStack, { ref: menuRef, position: "absolute", ...position, width: 260, maxW: "calc(100vw - 24px)", bg: "var(--popover)", rounded: 12, borderWidth: 1, borderColor: "$borderColor", boxShadow: "var(--shadow-lg)", z: "var(--z-dropdown)", p: 6, gap: 2, children: [_jsx(Text, { pt: 6, px: 10, pb: 4, fontSize: "$1", fontWeight: "600", color: "$faint", textTransform: "uppercase", letterSpacing: 0.6, children: t('Workspaces') }), orgs.length === 0 ? (_jsx(Text, { pt: 6, px: 10, pb: 10, fontSize: "$2", color: "$faint", children: t('No workspaces on this account yet.') })) : null, orgs.map((o) => {
93
95
  const isSelected = o.id === activeOrgId || o.name === activeOrgId;
94
96
  return (_jsxs(Button, { variant: "ghost", onClick: () => {
95
- pick(o.id);
96
- if (switchOrg)
97
- switchOrg(o.id);
98
- if (switchOrganization)
99
- switchOrganization(o.id);
97
+ choose(o.id);
100
98
  onSelect(o.id);
101
99
  onClose();
102
100
  }, width: "100%", justify: "space-between", px: 10, py: 6, bg: isSelected ? '$hover' : 'transparent', children: [_jsxs(XStack, { items: "center", gap: 10, minW: 0, shrink: 1, children: [_jsx(Text, { width: 24, height: 24, rounded: 6, bg: "$raised", display: "flex", items: "center", justify: "center", fontSize: "$2", fontWeight: "700", color: "$ink", shrink: 0, overflow: "hidden", children: o.logo ? (_jsx(View, { render: _jsx("img", { src: o.logo, alt: "" }), width: "100%", height: "100%", objectFit: "cover" })) : (o.displayName.toLowerCase().includes('hanzo') || o.name.toLowerCase().includes('hanzo')) ? (_jsx(HanzoMark, { size: 14 })) : (o.name.slice(0, 3).toUpperCase()) }), _jsxs(YStack, { minW: 0, shrink: 1, items: "flex-start", children: [_jsx(Text, { fontSize: "$2", fontWeight: isSelected ? '600' : '500', color: "$ink", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", children: o.displayName }), o.role ? (_jsx(Text, { fontSize: FLOOR, color: "$faint", children: o.role })) : null] })] }), isSelected ? _jsx(Check, { size: 14, color: "currentColor" }) : null] }, o.id));
@@ -124,3 +122,20 @@ export function TopOrgSelector() {
124
122
  const activeOrgName = activeOrg?.displayName || activeOrg?.name || 'hanzo';
125
123
  return (_jsxs(XStack, { position: "relative", display: "inline-flex", items: "center", children: [_jsxs(Button, { ref: buttonRef, size: "sm", variant: open ? 'secondary' : 'default', onClick: () => setOpen((v) => !v), gap: 6, paddingInlineStart: 6, paddingInlineEnd: 8, "aria-label": t('Switch organization'), children: [_jsx(XStack, { width: 20, height: 20, rounded: 9999, bg: "$raised", items: "center", justify: "center", overflow: "hidden", children: face ? (_jsx(View, { render: _jsx("img", { src: face, alt: "", width: 20, height: 20 }), width: "100%", height: "100%", objectFit: "cover" })) : (_jsx(HanzoMark, { size: 13 })) }), _jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$ink", maxW: 140, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", children: activeOrgName }), _jsx(ChevronDown, { size: 13, opacity: 0.65 })] }), _jsx(OrgSwitcherDropdown, { open: open, onClose: () => setOpen(false), activeOrgId: activeOrgId, onSelect: () => setOpen(false), triggerRef: buttonRef })] }));
126
124
  }
125
+ /**
126
+ * The organizations as tiles down the far left, as a team chat draws them:
127
+ * each its logo, or its initial in its own hue (@hanzo/ui `Avatar` seeded on its
128
+ * id, as the org chooser and the landing's preview draw it), the one this page
129
+ * works in ringed, and "+" under them for the chooser, where another is made or
130
+ * joined. A press works in that organization.
131
+ */
132
+ export function Tiles() {
133
+ const { t } = useI18n();
134
+ const { orgs, active, choose } = useOrgList();
135
+ if (orgs.length === 0)
136
+ return null;
137
+ return (_jsxs(YStack, { "data-slot": "org-tiles", role: "group", "aria-label": t('Organizations'), items: "center", gap: 10, pt: 10, pb: 6, children: [orgs.map((o) => {
138
+ const on = o.id === active || o.name === active;
139
+ return (_jsxs(XStack, { position: "relative", items: "center", justify: "center", children: [_jsx(View, { position: "absolute", insetInlineStart: -10, width: 4, height: on ? 26 : 0, rounded: 9999, bg: "$color" }), _jsx(XStack, { render: "button", "aria-pressed": on, "aria-label": t('Open {org}', { org: o.displayName }), ...{ title: o.displayName }, onClick: () => choose(o.id), p: 2, rounded: 10, borderWidth: 2, borderColor: on ? '$color' : 'transparent', bg: "transparent", cursor: "pointer", opacity: on ? 1 : 0.8, hoverStyle: { opacity: 1 }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' }, children: _jsx(Avatar, { size: "lg", shape: "rounded", src: o.logo || null, name: o.displayName, colorSeed: o.id, variant: on ? 'outline' : 'soft', alt: "" }) })] }, o.id));
140
+ }), _jsx(XStack, { render: "button", "aria-label": t('Organizations'), ...{ title: t('Organizations') }, onClick: () => void window.dispatchEvent(new Event(CHOOSE)), width: 32, height: 32, rounded: 8, items: "center", justify: "center", borderWidth: 1, borderColor: "$borderColor", bg: "transparent", cursor: "pointer", hoverStyle: { bg: '$backgroundHover' }, children: _jsx(Plus, { size: 15, "aria-hidden": true }) })] }));
141
+ }
package/dist/Shell.js CHANGED
@@ -123,6 +123,7 @@ import { getStoredPeople, getStoredAgents, getCustomThreads, createDirectChat, }
123
123
  import { bare } from './lib/bare.js';
124
124
  import { BAD } from './lib/mix.js';
125
125
  import { brand, site, where, wordmark } from './where.js';
126
+ import { Tiles } from './OrgSwitcher.js';
126
127
  /** The pane while a settings row is open, loaded when one is: none of it is an app's first screen. */
127
128
  const SettingsPane = lazy(() => import('./SettingsPane.js').then((m) => ({ default: m.SettingsPane })));
128
129
  /**
@@ -999,7 +1000,7 @@ function Leave({ href, children }) {
999
1000
  }
1000
1001
  function Rail({ mode, places, team, open, navigate, onSettings, onMore, }) {
1001
1002
  const { t } = useI18n();
1002
- return (_jsxs(YStack, { "data-slot": "rail", render: "nav", "aria-label": t("Places"), ...sheet(0), gridArea: "rail", minH: 0, borderInlineEndWidth: 1, borderInlineEndStyle: "solid", borderColor: "var(--edge, var(--white-06))", $md: open ? { display: "none" } : undefined, "$max-md": {
1003
+ return (_jsxs(YStack, { "data-slot": "rail", render: "nav", "aria-label": t("Places"), ...sheet(0), gridArea: "rail", minH: 0, borderInlineEndWidth: 1, borderInlineEndStyle: "solid", borderColor: "var(--edge, var(--white-06))", "$max-md": {
1003
1004
  flexDirection: "row",
1004
1005
  items: "center",
1005
1006
  borderInlineEndWidth: 0,
@@ -1007,7 +1008,7 @@ function Rail({ mode, places, team, open, navigate, onSettings, onMore, }) {
1007
1008
  borderTopColor: "var(--border)",
1008
1009
  },
1009
1010
  // Clear of the home indicator on a phone; zero on a flat screen.
1010
- pb: HOME_INDICATOR, children: [_jsxs(YStack, { "data-slot": "places", ...bare, items: "center", gap: "$0.5", flex: 1, minW: 0, minH: 0, overflowY: "auto", pt: "$2", "$max-md": {
1011
+ pb: HOME_INDICATOR, children: [_jsx(YStack, { "$max-md": { display: "none" }, borderBottomWidth: 1, borderColor: "var(--edge, var(--white-06))", mx: "$2", children: _jsx(Tiles, {}) }), _jsxs(YStack, { "data-slot": "places", ...bare, items: "center", gap: "$0.5", flex: 1, minW: 0, minH: 0, overflowY: "auto", pt: "$2", $md: open ? { display: "none" } : undefined, "$max-md": {
1011
1012
  display: "grid",
1012
1013
  gridAutoFlow: "column",
1013
1014
  gridAutoColumns: "minmax(0, 1fr)",
@@ -1016,7 +1017,7 @@ function Rail({ mode, places, team, open, navigate, onSettings, onMore, }) {
1016
1017
  }, children: [places.map((place, i) => {
1017
1018
  const here = place.id === mode;
1018
1019
  return (_jsxs(Box, { render: "button", onClick: () => navigate?.(place.route), "aria-label": t(place.label), "aria-current": here ? "page" : undefined, title: place.name ?? (place.title ? t(place.title) : t(place.label)), display: "flex", "$max-md": { display: i < 4 ? "flex" : "none", width: "auto", minW: 0 }, flexDirection: "column", width: 56, minH: 44, py: "$1", rounded: "$2", items: "center", justify: "center", gap: 2, bg: here ? "$edge" : undefined, hoverStyle: { bg: here ? "$edge" : "$hover" }, children: [_jsx(place.icon, { size: 18, "aria-hidden": true }), _jsx(Text, { fontSize: 12, lineHeight: 14, color: here ? "$ink" : "$quiet", numberOfLines: 1, children: t(place.label) })] }, place.id));
1019
- }), team ? (_jsx(XStack, { "$max-md": { display: places.length < 4 ? "flex" : "none", width: "auto", minW: 0 }, children: _jsx(Text, { render: _jsx("a", { href: team, "aria-label": t("Workspace"), title: "Hanzo Team" }), display: "flex", width: 56, color: "inherit", children: _jsxs(Box, { display: "flex", flex: 1, flexDirection: "column", minH: 44, py: "$1", rounded: "$2", items: "center", justify: "center", gap: 2, hoverStyle: { bg: "$hover" }, children: [_jsx(LayoutGrid, { size: 18, "aria-hidden": true }), _jsx(Text, { fontSize: 12, lineHeight: 14, color: "$quiet", numberOfLines: 1, children: t("Workspace") })] }) }) })) : null, _jsxs(Box, { "data-slot": "more", render: "button", onClick: onMore, "aria-label": t("More places"), title: t("More"), display: "none", "$max-md": { display: "flex", width: "auto", minW: 0 }, flexDirection: "column", width: 56, minH: 44, py: "$1", rounded: "$2", items: "center", justify: "center", gap: 2, hoverStyle: { bg: "$hover" }, children: [_jsx(SearchIcon, { size: 18, "aria-hidden": true }), _jsx(Text, { fontSize: 12, lineHeight: 14, color: "$quiet", children: t("More") })] })] }), _jsx(YStack, { items: "center", pb: "$2", children: _jsxs(Box, { render: "button", onClick: onSettings, "aria-label": t("Settings"), title: t("Settings"), display: "flex", flexDirection: "column", width: 56, minH: 44, py: "$1", rounded: "$2", items: "center", justify: "center", gap: 2, hoverStyle: { bg: "$hover" }, children: [_jsx(Settings2, { size: 18, "aria-hidden": true }), _jsx(Text, { fontSize: 12, lineHeight: 14, color: "$quiet", children: t("Settings") })] }) })] }));
1020
+ }), team ? (_jsx(XStack, { "$max-md": { display: places.length < 4 ? "flex" : "none", width: "auto", minW: 0 }, children: _jsx(Text, { render: _jsx("a", { href: team, "aria-label": t("Workspace"), title: "Hanzo Team" }), display: "flex", width: 56, color: "inherit", children: _jsxs(Box, { display: "flex", flex: 1, flexDirection: "column", minH: 44, py: "$1", rounded: "$2", items: "center", justify: "center", gap: 2, hoverStyle: { bg: "$hover" }, children: [_jsx(LayoutGrid, { size: 18, "aria-hidden": true }), _jsx(Text, { fontSize: 12, lineHeight: 14, color: "$quiet", numberOfLines: 1, children: t("Workspace") })] }) }) })) : null, _jsxs(Box, { "data-slot": "more", render: "button", onClick: onMore, "aria-label": t("More places"), title: t("More"), display: "none", "$max-md": { display: "flex", width: "auto", minW: 0 }, flexDirection: "column", width: 56, minH: 44, py: "$1", rounded: "$2", items: "center", justify: "center", gap: 2, hoverStyle: { bg: "$hover" }, children: [_jsx(SearchIcon, { size: 18, "aria-hidden": true }), _jsx(Text, { fontSize: 12, lineHeight: 14, color: "$quiet", children: t("More") })] })] }), _jsx(YStack, { items: "center", pb: "$2", $md: open ? { display: "none" } : undefined, children: _jsxs(Box, { render: "button", onClick: onSettings, "aria-label": t("Settings"), title: t("Settings"), display: "flex", flexDirection: "column", width: 56, minH: 44, py: "$1", rounded: "$2", items: "center", justify: "center", gap: 2, hoverStyle: { bg: "$hover" }, children: [_jsx(Settings2, { size: 18, "aria-hidden": true }), _jsx(Text, { fontSize: 12, lineHeight: 14, color: "$quiet", children: t("Settings") })] }) })] }));
1020
1021
  }
1021
1022
  /**
1022
1023
  * Chat's column: start a chat, the projects, then every conversation. The app
@@ -1311,7 +1312,7 @@ function Frame({ mode, children, navigate, back, forward, }) {
1311
1312
  navigate?.(site("/referral"));
1312
1313
  dismiss();
1313
1314
  }, children: t("Share Hanzo") }), _jsxs(XStack, { items: "center", gap: "$1", px: "$1.5", py: "$1", borderTopWidth: 1, borderColor: "$borderColor", children: [_jsx(YStack, { flex: 1, minW: 0, children: _jsx(Account, { host: who, onOrg: (o) => (choose(o), window.location.reload()) }) }), _jsx(Box, { render: "button", onClick: toggle, "aria-label": t("Collapse sidebar"), p: "$2", rounded: "$2", hoverStyle: { bg: "$hover" }, cursor: "pointer", children: _jsx(PanelLeftClose, { size: 16, "aria-hidden": true, "data-i18n-mirror": "" }) })] })] })) : null) : null] }));
1314
- return (_jsxs(YStack, { "data-slot": "workspace", "data-hydrated": settled ? "true" : undefined, "data-sidebar": asked ? "open" : "shut", display: "grid", gridTemplateColumns: `${asked ? 0 : 64}px auto minmax(0, 1fr) auto`, gridTemplateRows: "44px minmax(0, 1fr)", gridTemplateAreas: '"rail bar bar bar" "rail list pane side"', "$max-md": {
1315
+ return (_jsxs(YStack, { "data-slot": "workspace", "data-hydrated": settled ? "true" : undefined, "data-sidebar": asked ? "open" : "shut", display: "grid", gridTemplateColumns: "64px auto minmax(0, 1fr) auto", gridTemplateRows: "44px minmax(0, 1fr)", gridTemplateAreas: '"rail bar bar bar" "rail list pane side"', "$max-md": {
1315
1316
  gridTemplateColumns: "minmax(0, 1fr)",
1316
1317
  gridTemplateRows: `44px minmax(0, 1fr) ${TABS_HEIGHT}`,
1317
1318
  gridTemplateAreas: '"bar" "pane" "rail"',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/app",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Hanzo's app: the shell and its apps (Home, Chat, Inbox, Contacts, Meet, Calendar, Drive, Board, Work, Bots), once, for every Hanzo surface.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",