@hanzo/rooms 0.1.38 → 0.1.39

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
@@ -11,13 +11,13 @@ import { CalScheduler } from '@hanzo/rooms/CalScheduler'
11
11
 
12
12
  configure({ site: '', home: '/home', signUp: '/signup' })
13
13
 
14
- <Rooms router={router} search={search} path={pathname} route={route} Link={Link}>
14
+ <Rooms router={router} path={pathname} route={route} Link={Link}>
15
15
  <Room mode="cal"><CalScheduler /></Room>
16
16
  </Rooms>
17
17
  ```
18
18
 
19
19
  `configure()` names the host's addresses (where its own pages live, the
20
20
  gateway and IAM, the plan catalogue to paint first). `<Rooms>` carries what
21
- moves: the router, the query, the path, the route and the link component. The rooms
21
+ moves: the router, the path, the route and the link component. The rooms
22
22
  import nothing from a host, and their look comes from `@hanzo/appearance` and
23
23
  `@hanzo/design` through `@hanzo/ui`.
package/dist/Account.js CHANGED
@@ -3,22 +3,28 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  /**
4
4
  * WHO YOU ARE, at the foot of the sidebar: the person, and the person's menu.
5
5
  *
6
- * Profile, appearance, usage, API keys, security and sign out — the account, and
7
- * nothing that belongs to the workspace. Which workspace you stand in is the
8
- * switcher at the TOP of the sidebar, and what it may spend is its Billing, so
9
- * this card shows neither: a balance here read as the person's money when it is
10
- * the workspace's.
6
+ * The plan leads it — @hanzo/build's `Meter`, the block every account menu opens
7
+ * with: the plan by its family and its windows as shares, the free allowance on
8
+ * Free, the balance only with no plan. Then profile, appearance, usage, billing,
9
+ * API keys, security and sign out — the account, and nothing that belongs to the
10
+ * workspace. Which workspace you stand in is the switcher at the TOP of the
11
+ * sidebar, and what it may spend is its Billing: a plan never sits beside a
12
+ * balance here.
11
13
  */
12
- import { useEffect, useRef, useState } from 'react';
13
- import { Activity, ChevronsUpDown, KeyRound, LogOut, PanelLeftClose, Palette, Shield, UserRound } from 'lucide-react';
14
+ import { useEffect, useMemo, useRef, useState } from 'react';
15
+ import { Activity, ChevronsUpDown, CreditCard, KeyRound, LogOut, PanelLeftClose, Palette, Shield, UserRound } from 'lucide-react';
16
+ import { Meter, useStanding } from '@hanzo/build';
14
17
  import { XStack, YStack, Text, Box } from '@hanzo/ui';
15
18
  import { sheet } from '@hanzo/ui/glass';
16
19
  import { useIam } from '@hanzo/iam/react';
17
20
  import { useSignOut } from './lib/signout.js';
18
21
  import { useAccount } from './lib/account.js';
19
22
  import { Face } from './cast.js';
20
- import { iam } from './lib/api.js';
23
+ import { api, iam } from './lib/api.js';
24
+ import { bearer, org } from './lib/session.js';
21
25
  import { link } from './lib/tags.js';
26
+ import { showSettings } from './open.js';
27
+ import { site } from './where.js';
22
28
  function Row({ icon, onPress, children, }) {
23
29
  return (_jsx(Box, { render: "button", onClick: onPress, width: "100%", px: "$3", py: "$2", rounded: "$2", hoverStyle: { bg: '$hover' }, children: _jsxs(XStack, { items: "center", gap: "$2", children: [icon, _jsx(Text, { fontSize: "$2", color: "$ink", children: children })] }) }));
24
30
  }
@@ -29,6 +35,9 @@ export function Account({ onToggleCollapse, onProfile, onAppearance, onUsage, on
29
35
  const { user: account } = useAccount();
30
36
  const [open, setOpen] = useState(false);
31
37
  const holder = useRef(null);
38
+ const scoped = org();
39
+ const target = useMemo(() => ({ api: api(), token: bearer, org: scoped }), [scoped]);
40
+ const plan = useStanding(target, open);
32
41
  useEffect(() => {
33
42
  if (!open)
34
43
  return;
@@ -55,5 +64,5 @@ export function Account({ onToggleCollapse, onProfile, onAppearance, onUsage, on
55
64
  // @ts-expect-error — ref is forwarded to the DOM node by the primitive.
56
65
  , {
57
66
  // @ts-expect-error — ref is forwarded to the DOM node by the primitive.
58
- ref: holder, position: "relative", borderTopWidth: 1, borderColor: "$borderColor", children: [open ? (_jsxs(YStack, { role: "menu", "aria-label": "Account", position: "absolute", b: "calc(100% + 6px)", l: "$2", r: "$2", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", ...sheet(2), py: "$2", gap: "$1", z: "var(--z-modal)", children: [_jsx(Row, { icon: _jsx(UserRound, { size: 15, "aria-hidden": true }), onPress: act(() => (onProfile ? onProfile() : window.location.assign(link(`${iam()}/account`)))), children: "Profile" }), onAppearance ? (_jsx(Row, { icon: _jsx(Palette, { size: 15, "aria-hidden": true }), onPress: act(onAppearance), children: "Appearance" })) : null, onUsage ? (_jsx(Row, { icon: _jsx(Activity, { size: 15, "aria-hidden": true }), onPress: act(onUsage), children: "Usage" })) : null, onKeys ? (_jsx(Row, { icon: _jsx(KeyRound, { size: 15, "aria-hidden": true }), onPress: act(onKeys), children: "API keys" })) : null, _jsx(Row, { icon: _jsx(Shield, { size: 15, "aria-hidden": true }), onPress: act(() => window.location.assign(link(`${iam()}/account/security`))), children: "Security" }), _jsx(Box, { height: 1, bg: "$borderColor", my: "$1" }), _jsx(Row, { icon: _jsx(LogOut, { size: 15, "aria-hidden": true }), onPress: act(() => void logout()), children: "Sign out" })] })) : null, _jsxs(XStack, { items: "center", width: "100%", children: [_jsx(Box, { render: "button", onClick: () => setOpen((v) => !v), "aria-expanded": open, "aria-haspopup": "menu", "aria-label": "Account", flex: 1, minW: 0, px: "$3", py: "$2", hoverStyle: { bg: '$hover' }, children: _jsxs(XStack, { items: "center", gap: "$2", minW: 0, children: [_jsx(Face, { src: face, name: called, size: 22 }), _jsxs(YStack, { flex: 1, minW: 0, items: "flex-start", children: [_jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$color", numberOfLines: 1, children: called }), email && email !== called ? (_jsx(Text, { fontSize: "$1", color: "$soft", numberOfLines: 1, children: email })) : null] }), _jsx(ChevronsUpDown, { size: 14, "aria-hidden": true })] }) }), onToggleCollapse ? (_jsx(Box, { render: "button", onClick: onToggleCollapse, "aria-label": "Collapse sidebar", p: "$2", mr: "$1.5", rounded: "$2", hoverStyle: { bg: '$hover' }, cursor: "pointer", children: _jsx(PanelLeftClose, { size: 16, "aria-hidden": true }) })) : null] })] }));
67
+ ref: holder, position: "relative", borderTopWidth: 1, borderColor: "$borderColor", children: [open ? (_jsxs(YStack, { role: "menu", "aria-label": "Account", position: "absolute", b: "calc(100% + 6px)", l: "$2", r: "$2", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", ...sheet(2), py: "$2", gap: "$1", z: "var(--z-modal)", children: [_jsx(Meter, { read: plan, onPlans: act(() => window.location.assign(site('/pricing'))), onBilling: act(() => showSettings('billing')) }), _jsx(Box, { height: 1, bg: "$borderColor", my: "$1" }), _jsx(Row, { icon: _jsx(UserRound, { size: 15, "aria-hidden": true }), onPress: act(() => (onProfile ? onProfile() : window.location.assign(link(`${iam()}/account`)))), children: "Profile" }), onAppearance ? (_jsx(Row, { icon: _jsx(Palette, { size: 15, "aria-hidden": true }), onPress: act(onAppearance), children: "Appearance" })) : null, onUsage ? (_jsx(Row, { icon: _jsx(Activity, { size: 15, "aria-hidden": true }), onPress: act(onUsage), children: "Usage" })) : null, _jsx(Row, { icon: _jsx(CreditCard, { size: 15, "aria-hidden": true }), onPress: act(() => showSettings('billing')), children: "Billing" }), onKeys ? (_jsx(Row, { icon: _jsx(KeyRound, { size: 15, "aria-hidden": true }), onPress: act(onKeys), children: "API keys" })) : null, _jsx(Row, { icon: _jsx(Shield, { size: 15, "aria-hidden": true }), onPress: act(() => window.location.assign(link(`${iam()}/account/security`))), children: "Security" }), _jsx(Box, { height: 1, bg: "$borderColor", my: "$1" }), _jsx(Row, { icon: _jsx(LogOut, { size: 15, "aria-hidden": true }), onPress: act(() => void logout()), children: "Sign out" })] })) : null, _jsxs(XStack, { items: "center", width: "100%", children: [_jsx(Box, { render: "button", onClick: () => setOpen((v) => !v), "aria-expanded": open, "aria-haspopup": "menu", "aria-label": "Account", flex: 1, minW: 0, px: "$3", py: "$2", hoverStyle: { bg: '$hover' }, children: _jsxs(XStack, { items: "center", gap: "$2", minW: 0, children: [_jsx(Face, { src: face, name: called, size: 22 }), _jsxs(YStack, { flex: 1, minW: 0, items: "flex-start", children: [_jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$color", numberOfLines: 1, children: called }), email && email !== called ? (_jsx(Text, { fontSize: "$1", color: "$soft", numberOfLines: 1, children: email })) : null] }), _jsx(ChevronsUpDown, { size: 14, "aria-hidden": true })] }) }), onToggleCollapse ? (_jsx(Box, { render: "button", onClick: onToggleCollapse, "aria-label": "Collapse sidebar", p: "$2", mr: "$1.5", rounded: "$2", hoverStyle: { bg: '$hover' }, cursor: "pointer", children: _jsx(PanelLeftClose, { size: 16, "aria-hidden": true }) })) : null] })] }));
59
68
  }