@arbidocs/react 0.5.196 → 0.5.197
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/identity.js +3 -1
- package/dist/account/identity.js.map +2 -2
- package/dist/index.cjs +4 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/workspaces/shell-workspaces.js +1 -1
- package/dist/workspaces/shell-workspaces.js.map +2 -2
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -6174,8 +6174,9 @@ declare function getWorkspaceKind(workspace: Pick<ShellWorkspaceSource, 'is_publ
|
|
|
6174
6174
|
/** Adapt one SDK workspace to the shell and gallery view model. */
|
|
6175
6175
|
declare function toShellWorkspace(workspace: ShellWorkspaceSource): ShellWorkspaceItem;
|
|
6176
6176
|
/**
|
|
6177
|
-
* The workspace the app is in
|
|
6178
|
-
*
|
|
6177
|
+
* The workspace the app is in: the host's selection if it is in the list; else the seed's active one
|
|
6178
|
+
* (demo only). Never the first listed: with nothing selected the user is in no workspace yet (a new
|
|
6179
|
+
* account lists public workspaces it is not a member of), and the shell says so.
|
|
6179
6180
|
*/
|
|
6180
6181
|
declare function resolveActiveWorkspace(items: readonly ShellWorkspaceItem[], selectedId: string | null | undefined, options?: {
|
|
6181
6182
|
isSeed?: boolean;
|
|
@@ -34,7 +34,7 @@ function resolveActiveWorkspace(items, selectedId, options = {}) {
|
|
|
34
34
|
const seeded = items.find((w) => w.id === options.seedActiveId);
|
|
35
35
|
if (seeded) return seeded;
|
|
36
36
|
}
|
|
37
|
-
return
|
|
37
|
+
return void 0;
|
|
38
38
|
}
|
|
39
39
|
function pickRecentWorkspaces(items, activeId, options = {}) {
|
|
40
40
|
const { limit = 4, lastOpened, formatLastSeen } = options;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/workspaces/shell-workspaces.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Pure workspace adapters: an SDK `WorkspaceResponse` (or the host's own copy of it) to the view\n * models the shell and the workspaces gallery show. No React state, no SDK calls, so a host that\n * has no `arbi` in its host can use them too.\n */\n\nimport type { ReactNode } from 'react'\n\n/** Workspace visibility: public = common, several members = shared, else private. */\nexport type ShellWorkspaceKind = 'private' | 'shared' | 'common'\n\n/** One face on a workspace card. */\nexport interface ShellWorkspaceMember {\n name: string\n picture?: string | null\n}\n\n/**\n * The fields of an SDK workspace the adapters read. Every field but the id and the name is\n * optional, so the SDK's `WorkspaceResponse` and a host's own copy of it are both assignable.\n */\nexport interface ShellWorkspaceSource {\n external_id: string\n name: string\n description?: string | null\n is_public?: boolean\n project_name?: string | null\n updated_at?: string\n shared_document_count?: number\n private_document_count?: number\n users?: ReadonlyArray<{\n user?: {\n given_name?: string | null\n family_name?: string | null\n email?: string | null\n picture?: string | null\n }\n /** Set when the member is an agent: agents are not people and are left off the faces. */\n agent_ext_id?: string | null\n }>\n}\n\n/**\n * A workspace as the shell and the gallery see it. Structurally a superset of blocks'\n * `ShellWorkspace` and `WorkspaceSummary`, so it is passed to both unchanged.\n */\nexport interface ShellWorkspaceItem {\n id: string\n name: string\n kind: ShellWorkspaceKind\n description?: string | null\n projectName?: string | null\n /** A rendered project pill; the host supplies it (see `decorate`). */\n projectLine?: ReactNode\n /** Shared plus private documents. */\n docCount: number\n /** People in the workspace (agents excluded). */\n memberCount: number\n members: ShellWorkspaceMember[]\n /** ISO timestamp. */\n updatedAt?: string\n}\n\n/** A workspace offered in the switcher menu. */\nexport interface ShellRecentWorkspaceItem extends ShellWorkspaceItem {\n /** Pre-formatted \"last seen\" text, when the host supplies `formatLastSeen`. */\n lastSeen?: string\n}\n\n/** Public, several members: shared. Otherwise private. */\nexport function getWorkspaceKind(\n workspace: Pick<ShellWorkspaceSource, 'is_public' | 'users'>\n): ShellWorkspaceKind {\n if (workspace.is_public) return 'common'\n if ((workspace.users?.length ?? 0) > 1) return 'shared'\n return 'private'\n}\n\nfunction memberName(user: NonNullable<ShellWorkspaceSource['users']>[number]['user']): string {\n const full = [user?.given_name, user?.family_name].filter(Boolean).join(' ').trim()\n return full || user?.email || ''\n}\n\n/** Adapt one SDK workspace to the shell and gallery view model. */\nexport function toShellWorkspace(workspace: ShellWorkspaceSource): ShellWorkspaceItem {\n const people = (workspace.users ?? []).filter((u) => !u.agent_ext_id)\n return {\n id: workspace.external_id,\n name: workspace.name,\n kind: getWorkspaceKind(workspace),\n description: workspace.description,\n projectName: workspace.project_name,\n docCount: (workspace.shared_document_count ?? 0) + (workspace.private_document_count ?? 0),\n memberCount: people.length,\n members: people.map((u) => ({ name: memberName(u.user), picture: u.user?.picture })),\n updatedAt: workspace.updated_at,\n }\n}\n\n/** The moment a workspace was last opened here, else last updated; 0 when neither is known. */\nfunction recency(\n workspace: ShellWorkspaceItem,\n lastOpened: Readonly<Record<string, number>> | undefined\n): number {\n const opened = lastOpened?.[workspace.id]\n if (opened !== undefined) return opened\n const updated = Date.parse(workspace.updatedAt ?? '')\n return Number.isNaN(updated) ? 0 : updated\n}\n\n/**\n * The workspace the app is in
|
|
5
|
-
"mappings": "AAsEO,SAAS,iBACd,WACoB;AACpB,MAAI,UAAU,UAAW,QAAO;AAChC,OAAK,UAAU,OAAO,UAAU,KAAK,EAAG,QAAO;AAC/C,SAAO;AACT;AAEA,SAAS,WAAW,MAA0E;AAC5F,QAAM,OAAO,CAAC,MAAM,YAAY,MAAM,WAAW,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK;AAClF,SAAO,QAAQ,MAAM,SAAS;AAChC;AAGO,SAAS,iBAAiB,WAAqD;AACpF,QAAM,UAAU,UAAU,SAAS,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,YAAY;AACpE,SAAO;AAAA,IACL,IAAI,UAAU;AAAA,IACd,MAAM,UAAU;AAAA,IAChB,MAAM,iBAAiB,SAAS;AAAA,IAChC,aAAa,UAAU;AAAA,IACvB,aAAa,UAAU;AAAA,IACvB,WAAW,UAAU,yBAAyB,MAAM,UAAU,0BAA0B;AAAA,IACxF,aAAa,OAAO;AAAA,IACpB,SAAS,OAAO,IAAI,CAAC,OAAO,EAAE,MAAM,WAAW,EAAE,IAAI,GAAG,SAAS,EAAE,MAAM,QAAQ,EAAE;AAAA,IACnF,WAAW,UAAU;AAAA,EACvB;AACF;AAGA,SAAS,QACP,WACA,YACQ;AACR,QAAM,SAAS,aAAa,UAAU,EAAE;AACxC,MAAI,WAAW,OAAW,QAAO;AACjC,QAAM,UAAU,KAAK,MAAM,UAAU,aAAa,EAAE;AACpD,SAAO,OAAO,MAAM,OAAO,IAAI,IAAI;AACrC;
|
|
4
|
+
"sourcesContent": ["/**\n * Pure workspace adapters: an SDK `WorkspaceResponse` (or the host's own copy of it) to the view\n * models the shell and the workspaces gallery show. No React state, no SDK calls, so a host that\n * has no `arbi` in its host can use them too.\n */\n\nimport type { ReactNode } from 'react'\n\n/** Workspace visibility: public = common, several members = shared, else private. */\nexport type ShellWorkspaceKind = 'private' | 'shared' | 'common'\n\n/** One face on a workspace card. */\nexport interface ShellWorkspaceMember {\n name: string\n picture?: string | null\n}\n\n/**\n * The fields of an SDK workspace the adapters read. Every field but the id and the name is\n * optional, so the SDK's `WorkspaceResponse` and a host's own copy of it are both assignable.\n */\nexport interface ShellWorkspaceSource {\n external_id: string\n name: string\n description?: string | null\n is_public?: boolean\n project_name?: string | null\n updated_at?: string\n shared_document_count?: number\n private_document_count?: number\n users?: ReadonlyArray<{\n user?: {\n given_name?: string | null\n family_name?: string | null\n email?: string | null\n picture?: string | null\n }\n /** Set when the member is an agent: agents are not people and are left off the faces. */\n agent_ext_id?: string | null\n }>\n}\n\n/**\n * A workspace as the shell and the gallery see it. Structurally a superset of blocks'\n * `ShellWorkspace` and `WorkspaceSummary`, so it is passed to both unchanged.\n */\nexport interface ShellWorkspaceItem {\n id: string\n name: string\n kind: ShellWorkspaceKind\n description?: string | null\n projectName?: string | null\n /** A rendered project pill; the host supplies it (see `decorate`). */\n projectLine?: ReactNode\n /** Shared plus private documents. */\n docCount: number\n /** People in the workspace (agents excluded). */\n memberCount: number\n members: ShellWorkspaceMember[]\n /** ISO timestamp. */\n updatedAt?: string\n}\n\n/** A workspace offered in the switcher menu. */\nexport interface ShellRecentWorkspaceItem extends ShellWorkspaceItem {\n /** Pre-formatted \"last seen\" text, when the host supplies `formatLastSeen`. */\n lastSeen?: string\n}\n\n/** Public, several members: shared. Otherwise private. */\nexport function getWorkspaceKind(\n workspace: Pick<ShellWorkspaceSource, 'is_public' | 'users'>\n): ShellWorkspaceKind {\n if (workspace.is_public) return 'common'\n if ((workspace.users?.length ?? 0) > 1) return 'shared'\n return 'private'\n}\n\nfunction memberName(user: NonNullable<ShellWorkspaceSource['users']>[number]['user']): string {\n const full = [user?.given_name, user?.family_name].filter(Boolean).join(' ').trim()\n return full || user?.email || ''\n}\n\n/** Adapt one SDK workspace to the shell and gallery view model. */\nexport function toShellWorkspace(workspace: ShellWorkspaceSource): ShellWorkspaceItem {\n const people = (workspace.users ?? []).filter((u) => !u.agent_ext_id)\n return {\n id: workspace.external_id,\n name: workspace.name,\n kind: getWorkspaceKind(workspace),\n description: workspace.description,\n projectName: workspace.project_name,\n docCount: (workspace.shared_document_count ?? 0) + (workspace.private_document_count ?? 0),\n memberCount: people.length,\n members: people.map((u) => ({ name: memberName(u.user), picture: u.user?.picture })),\n updatedAt: workspace.updated_at,\n }\n}\n\n/** The moment a workspace was last opened here, else last updated; 0 when neither is known. */\nfunction recency(\n workspace: ShellWorkspaceItem,\n lastOpened: Readonly<Record<string, number>> | undefined\n): number {\n const opened = lastOpened?.[workspace.id]\n if (opened !== undefined) return opened\n const updated = Date.parse(workspace.updatedAt ?? '')\n return Number.isNaN(updated) ? 0 : updated\n}\n\n/**\n * The workspace the app is in: the host's selection if it is in the list; else the seed's active one\n * (demo only). Never the first listed: with nothing selected the user is in no workspace yet (a new\n * account lists public workspaces it is not a member of), and the shell says so.\n */\nexport function resolveActiveWorkspace(\n items: readonly ShellWorkspaceItem[],\n selectedId: string | null | undefined,\n options: { isSeed?: boolean; seedActiveId?: string } = {}\n): ShellWorkspaceItem | undefined {\n const selected = selectedId ? items.find((w) => w.id === selectedId) : undefined\n if (selected) return selected\n if (options.isSeed && options.seedActiveId) {\n const seeded = items.find((w) => w.id === options.seedActiveId)\n if (seeded) return seeded\n }\n return undefined\n}\n\n/** The other workspaces for the quick-switch menu, most recently opened first, capped. */\nexport function pickRecentWorkspaces(\n items: readonly ShellWorkspaceItem[],\n activeId: string | undefined,\n options: {\n limit?: number\n lastOpened?: Readonly<Record<string, number>>\n formatLastSeen?: (timestamp: number) => string\n } = {}\n): ShellRecentWorkspaceItem[] {\n const { limit = 4, lastOpened, formatLastSeen } = options\n return items\n .filter((w) => w.id !== activeId)\n .map((w) => ({ w, at: recency(w, lastOpened) }))\n .sort((a, b) => b.at - a.at)\n .slice(0, limit)\n .map(({ w, at }) => (formatLastSeen ? { ...w, lastSeen: formatLastSeen(at) } : w))\n}\n"],
|
|
5
|
+
"mappings": "AAsEO,SAAS,iBACd,WACoB;AACpB,MAAI,UAAU,UAAW,QAAO;AAChC,OAAK,UAAU,OAAO,UAAU,KAAK,EAAG,QAAO;AAC/C,SAAO;AACT;AAEA,SAAS,WAAW,MAA0E;AAC5F,QAAM,OAAO,CAAC,MAAM,YAAY,MAAM,WAAW,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK;AAClF,SAAO,QAAQ,MAAM,SAAS;AAChC;AAGO,SAAS,iBAAiB,WAAqD;AACpF,QAAM,UAAU,UAAU,SAAS,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,YAAY;AACpE,SAAO;AAAA,IACL,IAAI,UAAU;AAAA,IACd,MAAM,UAAU;AAAA,IAChB,MAAM,iBAAiB,SAAS;AAAA,IAChC,aAAa,UAAU;AAAA,IACvB,aAAa,UAAU;AAAA,IACvB,WAAW,UAAU,yBAAyB,MAAM,UAAU,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
|
|
3
|
+
"version": "0.5.197",
|
|
4
4
|
"description": "React hooks and provider for the ARBI SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -122,8 +122,8 @@
|
|
|
122
122
|
"build-storybook": "storybook build"
|
|
123
123
|
},
|
|
124
124
|
"dependencies": {
|
|
125
|
-
"@arbidocs/client": "0.5.
|
|
126
|
-
"@arbidocs/sdk": "0.5.
|
|
125
|
+
"@arbidocs/client": "0.5.197",
|
|
126
|
+
"@arbidocs/sdk": "0.5.197",
|
|
127
127
|
"@didit-protocol/sdk-web": "0.4.0",
|
|
128
128
|
"@livekit/components-react": "2.9.24",
|
|
129
129
|
"@radix-ui/react-avatar": "^1.2.0",
|