@arbidocs/blocks 0.4.69 → 0.4.70

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.
Files changed (48) hide show
  1. package/README.md +85 -1
  2. package/dist/agents/index.cjs +220 -220
  3. package/dist/agents/index.js +4 -4
  4. package/dist/chat/index.cjs +66 -66
  5. package/dist/chat/index.js +2 -2
  6. package/dist/chunk-4DVEGXZQ.cjs +72 -0
  7. package/dist/chunk-4DVEGXZQ.cjs.map +1 -0
  8. package/dist/{chunk-ZYZMCNIS.cjs → chunk-7M22KND4.cjs} +5 -5
  9. package/dist/{chunk-ZYZMCNIS.cjs.map → chunk-7M22KND4.cjs.map} +1 -1
  10. package/dist/{chunk-ZQB7HNE6.js → chunk-BMWZTNZB.js} +3 -3
  11. package/dist/{chunk-ZQB7HNE6.js.map → chunk-BMWZTNZB.js.map} +1 -1
  12. package/dist/{chunk-4HZ46XP2.js → chunk-HLMFU7L2.js} +5 -5
  13. package/dist/{chunk-4HZ46XP2.js.map → chunk-HLMFU7L2.js.map} +1 -1
  14. package/dist/chunk-ODWCTAH7.js +66 -0
  15. package/dist/chunk-ODWCTAH7.js.map +1 -0
  16. package/dist/{chunk-WKNAFILY.cjs → chunk-XNRGCQPZ.cjs} +3 -3
  17. package/dist/{chunk-WKNAFILY.cjs.map → chunk-XNRGCQPZ.cjs.map} +1 -1
  18. package/dist/connect/index.cjs +1 -1
  19. package/dist/connect/index.js +1 -1
  20. package/dist/document-tools/DocumentToolButtons.d.ts +29 -0
  21. package/dist/document-tools/MarkupNotices.d.ts +12 -0
  22. package/dist/document-tools/MarkupViewNote.d.ts +11 -0
  23. package/dist/document-tools/SignDocumentDialog.d.ts +20 -0
  24. package/dist/document-tools/SignatureCertificate.d.ts +26 -0
  25. package/dist/document-tools/SignatureStatus.d.ts +22 -0
  26. package/dist/document-tools/VersionSnapshotBar.d.ts +27 -0
  27. package/dist/document-tools/index.cjs +633 -0
  28. package/dist/document-tools/index.cjs.map +1 -0
  29. package/dist/document-tools/index.d.ts +7 -0
  30. package/dist/document-tools/index.js +619 -0
  31. package/dist/document-tools/index.js.map +1 -0
  32. package/dist/document-tools/viewer/AnnotatedPdfViewer.d.ts +54 -0
  33. package/dist/document-tools/viewer/SignaturePlacementViewer.d.ts +20 -0
  34. package/dist/document-tools/viewer/index.cjs +273 -0
  35. package/dist/document-tools/viewer/index.cjs.map +1 -0
  36. package/dist/document-tools/viewer/index.d.ts +2 -0
  37. package/dist/document-tools/viewer/index.js +268 -0
  38. package/dist/document-tools/viewer/index.js.map +1 -0
  39. package/dist/files/cells/DocumentNameCell.d.ts +3 -1
  40. package/dist/files/index.cjs +38 -67
  41. package/dist/files/index.cjs.map +1 -1
  42. package/dist/files/index.js +19 -63
  43. package/dist/files/index.js.map +1 -1
  44. package/dist/index.cjs +480 -480
  45. package/dist/index.js +7 -7
  46. package/dist/settings/index.cjs +1 -1
  47. package/dist/settings/index.js +1 -1
  48. package/package.json +20 -4
package/README.md CHANGED
@@ -19,7 +19,7 @@ Optional peers, only needed for the entry that uses them:
19
19
 
20
20
  | Peer | Needed by |
21
21
  | --- | --- |
22
- | `@tanstack/react-query` | `@arbidocs/blocks/connect`, `@arbidocs/blocks/studio` |
22
+ | `@tanstack/react-query` | `@arbidocs/blocks/connect`, `@arbidocs/blocks/studio`, `@arbidocs/blocks/document-tools` |
23
23
  | `react-router-dom` | `@arbidocs/blocks/studio` |
24
24
  | `@measured/puck` | `@arbidocs/blocks/studio` |
25
25
  | `@playwright/test` | types of `@arbidocs/blocks/record` (no runtime import) |
@@ -67,6 +67,8 @@ Every capability is its own entry, so a bundler only loads what you use:
67
67
  | `/files`, `/facts` | document grid, facts table | `ag-grid-*` |
68
68
  | `/artifacts` | artifact editor, version bar, track changes | none |
69
69
  | `/artifacts/editor` | rich-text (markdown) editing surface | `@mdxeditor/editor` (optional peer) |
70
+ | `/document-tools` | PDF markup, signing and version parts (see below) | `@tanstack/react-query` |
71
+ | `/document-tools/viewer` | annotated PDF viewer, signature placement | `pdf-lib`, `react-pdf` (optional peers of `@arbidocs/react`) |
70
72
  | `/home`, `/workspaces` | dashboard, workspace cards and forms | `@dnd-kit/*` |
71
73
  | `/settings` | settings, billing, modals | `cmdk` |
72
74
  | `/connect` | demo/live connection layer | `@tanstack/react-query` |
@@ -157,6 +159,88 @@ draft is stored and parsed, then the editor on the stored version (the presentat
157
159
  <StreamedArtifact artifacts={task.artifacts} workspaceId={workspaceId} busy={task.status === 'running'} error={task.error} />
158
160
  ```
159
161
 
162
+ ## Using the document tools in another frontend
163
+
164
+ The PDF document tools are what ARBI's document page uses: annotate (highlight, comment, stamp,
165
+ redact) with the marks saved as the version's markup on the server (autosave, colleagues' edits
166
+ merged in), "Show original", "Download with markup", the notes about markup on an older version
167
+ ("Copy open comments here") and about marks left in this browser, Freeze (a separate annotated or
168
+ redacted copy, with a redaction log), e-signing (choose where the signature goes, sign with the
169
+ password; only the signature and optionally the date are drawn), the signature details with "View
170
+ certificate", the public certificate page, and the read-only version bar.
171
+
172
+ | Import | What |
173
+ | --- | --- |
174
+ | `@arbidocs/react/document-tools` | `DocumentToolsProvider`, `useDocumentMarkup`, `createMarkupStore`, `fetchMarkupPdf`, `canAnnotate`, `useDocumentSignatures`, `useSignDocument`, `useSignatureVerification` |
175
+ | `@arbidocs/blocks/document-tools` | `AnnotateButton`, `ShowOriginalButton`, `DownloadMarkupButton`, `SignButton`, `MarkupNotices`, `MarkupViewNote`, `SignDocumentDialog`, `SignatureStatus`, `SignatureCertificate`, `VersionSnapshotBar` |
176
+ | `@arbidocs/blocks/document-tools/viewer` | `AnnotatedPdfViewer`, `SignaturePlacementViewer` (load lazily: pdf-lib) |
177
+
178
+ What the host provides, once, around the viewer (the tools import no store, router or toast
179
+ library of their own):
180
+
181
+ - an ARBI API client signed in as the user: `arbi.getClient().fetch` from an `@arbidocs/sdk`
182
+ `Arbi`, or `createArbiClient(...).fetch` from `@arbidocs/client`;
183
+ - `deploymentDomain` (the one the user's keys are derived for) and `user: { name, email }`, for
184
+ signing; without a user marks are authored as "You";
185
+ - callbacks, all optional: `notify(message, kind, { description, action })`, `openDocument(ref)`
186
+ (the copy just frozen, the signed copy), `onDocumentsChanged(ids, 'markup' | 'copy' | 'signed')`
187
+ to refresh your lists, `emailDocument(ref)` (adds "Email it" after signing), `uploadDocument`,
188
+ `saveFile` and `certificateUrl` (defaults: the API client, a download link, `/verify/{ref}`);
189
+ - a React Query `QueryClientProvider`, the blocks styles (see Styles), and the pdf.js assets the
190
+ kit `PdfViewer` loads (`/pdf.worker.min.mjs`, `/cmaps/`, `/standard_fonts/` by default) plus the
191
+ optional peers `react-pdf`, `pdfjs-dist` and `pdf-lib`.
192
+
193
+ ```tsx
194
+ import { lazy, Suspense, useState } from 'react'
195
+ import { DocumentToolsProvider, useDocumentMarkup, useDocumentSignatures } from '@arbidocs/react/document-tools'
196
+ import { AnnotateButton, MarkupNotices, SignatureStatus } from '@arbidocs/blocks/document-tools'
197
+ const AnnotatedPdfViewer = lazy(() =>
198
+ import('@arbidocs/blocks/document-tools/viewer').then((m) => ({ default: m.AnnotatedPdfViewer })))
199
+
200
+ <DocumentToolsProvider
201
+ client={arbi.getClient().fetch}
202
+ deploymentDomain={deploymentDomain}
203
+ user={{ name: 'Ana Lopez', email: 'ana@firm.example' }}
204
+ notify={(message, kind) => toast[kind](message)}
205
+ openDocument={(ref) => navigate(`/documents/${ref}`)}
206
+ onDocumentsChanged={() => queryClient.invalidateQueries({ queryKey: ['documents'] })}
207
+ >
208
+ <DocumentPage doc={doc} pdf={pdfBlob} />
209
+ </DocumentToolsProvider>
210
+
211
+ function DocumentPage({ doc, pdf }) {
212
+ // `doc` is the document record (DocResponse): external_id, shared, folder, current_version, versions.
213
+ const [editing, setEditing] = useState(false)
214
+ const markup = useDocumentMarkup(doc, undefined)
215
+ const { data: signatures } = useDocumentSignatures(doc.external_id)
216
+ return (
217
+ <>
218
+ <AnnotateButton active={editing} onClick={() => setEditing((on) => !on)} />
219
+ {signatures?.signed && <SignatureStatus status={signatures} />}
220
+ <MarkupNotices legacyPrompt={markup.legacyPrompt} olderNote={markup.olderNote}
221
+ onOpenVersion={(n) => navigate(`/documents/${doc.external_id}@v${n}`)} />
222
+ <Suspense fallback={null}>
223
+ <AnnotatedPdfViewer file={pdf} documentId={doc.external_id} fileName={doc.file_name}
224
+ shared={!!doc.shared} folder={doc.folder} editing={editing}
225
+ onMarkupChange={markup.onMarkupChange} />
226
+ </Suspense>
227
+ </>
228
+ )
229
+ }
230
+ ```
231
+
232
+ A signed version is locked: only a further signature changes it. Pass `signed` to
233
+ `AnnotatedPdfViewer` and a `disabledReason` (`SIGNED_LOCKED_REASON`, from `isSignedVersion(doc)` or
234
+ the signature status) to `DownloadMarkupButton`: marks stay in the markup layer and are never
235
+ written into its PDF, and the plain download is the signed file. Show `SignedEditNote` above any
236
+ editor of a signed version ("Editing creates a new unsigned version").
237
+
238
+ `AnnotatedPdfViewer` and `SignaturePlacementViewer` take your own binding of the kit viewer as
239
+ `viewer` (for example one that reports the visible page); `SignaturePlacementViewer`'s
240
+ `onContinue(appearance)` hands the box to `SignDocumentDialog`. Serve `SignatureCertificate` on a
241
+ route that needs no sign-in (ARBI uses `/verify/:reference`), inside a `DocumentToolsProvider` with
242
+ an unauthenticated client: it is the page the signature on a signed PDF links to.
243
+
160
244
  ## Editorial site parts
161
245
 
162
246
  `@arbidocs/blocks/site` (and the root) carry the layout parts for static marketing pages: