makersclaw 0.7.0 → 0.8.1
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 +17 -4
- package/package.json +1 -1
- package/r/activity-log.json +52 -0
- package/r/agent-changes.json +51 -0
- package/r/agent-chat.json +53 -0
- package/r/agent-column.json +85 -0
- package/r/agent-dock.json +57 -0
- package/r/agent-kit.json +49 -0
- package/r/agent-marks.json +49 -0
- package/r/agent-pane.json +93 -0
- package/r/ai-action.json +56 -0
- package/r/annotate.json +4 -4
- package/r/approval-request.json +2 -2
- package/r/approval.json +54 -0
- package/r/ask-bar.json +50 -0
- package/r/audio-player.json +2 -2
- package/r/auth-form.json +2 -2
- package/r/automation-editor.json +66 -0
- package/r/automation-list.json +57 -0
- package/r/automation-model.json +118 -0
- package/r/automations-screen.json +71 -0
- package/r/board.json +2 -2
- package/r/calendar-view.json +3 -3
- package/r/cart.json +2 -2
- package/r/chart.json +5 -5
- package/r/chat-pane.json +84 -0
- package/r/chat.json +3 -3
- package/r/code-editor.json +2 -2
- package/r/comment-box.json +3 -3
- package/r/connect-card.json +51 -0
- package/r/contact-section.json +2 -2
- package/r/core.json +18 -6
- package/r/cost.json +51 -0
- package/r/csv-import.json +3 -3
- package/r/data-picker.json +60 -0
- package/r/data-table.json +2 -2
- package/r/diagram.json +2 -2
- package/r/doc-editor.json +2 -2
- package/r/doc-page.json +3 -3
- package/r/email-render.json +2 -2
- package/r/faq.json +2 -2
- package/r/file-upload.json +2 -2
- package/r/first-run.json +63 -0
- package/r/fix-note.json +57 -0
- package/r/flow-canvas.json +3 -3
- package/r/flow-editor.json +79 -0
- package/r/footer.json +3 -3
- package/r/gantt.json +3 -3
- package/r/job-panel.json +2 -2
- package/r/json-editor.json +3 -3
- package/r/library-shelf.json +56 -0
- package/r/map.json +2 -2
- package/r/margin-notes.json +67 -0
- package/r/menubar.json +2 -2
- package/r/mind-map.json +4 -4
- package/r/navigation-menu.json +2 -2
- package/r/needs-you.json +55 -0
- package/r/order-detail.json +2 -2
- package/r/org-chart.json +4 -4
- package/r/pace-bar.json +69 -0
- package/r/page-builder.json +3 -3
- package/r/payment-methods.json +2 -2
- package/r/pdf-document.json +2 -2
- package/r/pdf-viewer.json +3 -3
- package/r/product-detail.json +2 -2
- package/r/product-grid.json +3 -3
- package/r/record-form.json +2 -2
- package/r/record-grid.json +52 -0
- package/r/record-notes.json +4 -4
- package/r/registry.json +4089 -1510
- package/r/run-history.json +52 -0
- package/r/run-view.json +80 -0
- package/r/schedule-card.json +54 -0
- package/r/schedule-engine.json +79 -0
- package/r/schedule-gantt.json +83 -0
- package/r/schedule-ruler.json +64 -0
- package/r/search-dialog.json +2 -2
- package/r/settings-list.json +2 -2
- package/r/setup-checklist.json +2 -2
- package/r/share-dialog.json +2 -2
- package/r/sidebar.json +3 -3
- package/r/signature-pad.json +2 -2
- package/r/sketch-canvas.json +3 -3
- package/r/source-receipt.json +52 -0
- package/r/spreadsheet.json +3 -3
- package/r/stat-cards.json +3 -3
- package/r/step-picker.json +53 -0
- package/r/step-settings.json +72 -0
- package/r/suggestion.json +58 -0
- package/r/sum-bar.json +64 -0
- package/r/task-list.json +3 -3
- package/r/task-model.json +2 -2
- package/r/testimonials.json +2 -2
- package/r/tier-map.json +67 -0
- package/r/time-grid.json +73 -0
- package/r/time-strip.json +64 -0
- package/r/top-bar.json +66 -0
- package/r/transaction-list.json +2 -2
- package/r/trigger-picker.json +61 -0
- package/r/whiteboard.json +4 -4
- package/r/workflow-view.json +55 -0
- package/registry/blocks/activity-log/README.md +112 -0
- package/registry/blocks/activity-log/activity-log.jsx +351 -0
- package/registry/blocks/activity-log/block.json +33 -0
- package/registry/blocks/activity-log/demo.jsx +48 -0
- package/registry/blocks/activity-log/index.js +4 -0
- package/registry/blocks/agent-changes/README.md +94 -0
- package/registry/blocks/agent-changes/agent-changes.jsx +118 -0
- package/registry/blocks/agent-changes/block.json +28 -0
- package/registry/blocks/agent-changes/demo.jsx +39 -0
- package/registry/blocks/agent-changes/index.js +3 -0
- package/registry/blocks/agent-chat/README.md +145 -0
- package/registry/blocks/agent-chat/agent-chat.jsx +415 -0
- package/registry/blocks/agent-chat/block.json +30 -0
- package/registry/blocks/agent-chat/demo.jsx +165 -0
- package/registry/blocks/agent-chat/index.js +3 -0
- package/registry/blocks/agent-column/README.md +197 -0
- package/registry/blocks/agent-column/agent-column.jsx +492 -0
- package/registry/blocks/agent-column/block.json +67 -0
- package/registry/blocks/agent-column/column-picker.jsx +163 -0
- package/registry/blocks/agent-column/demo.jsx +50 -0
- package/registry/blocks/agent-column/index.js +7 -0
- package/registry/blocks/agent-column/model.js +164 -0
- package/registry/blocks/agent-column/receipt.jsx +483 -0
- package/registry/blocks/agent-column/spreadsheet-type.jsx +24 -0
- package/registry/blocks/agent-dock/README.md +210 -0
- package/registry/blocks/agent-dock/agent-dock.jsx +356 -0
- package/registry/blocks/agent-dock/block.json +47 -0
- package/registry/blocks/agent-dock/demo.jsx +153 -0
- package/registry/blocks/agent-dock/dock-model.js +118 -0
- package/registry/blocks/agent-dock/index.js +5 -0
- package/registry/blocks/agent-kit/README.md +73 -0
- package/registry/blocks/agent-kit/agent-kit.jsx +86 -0
- package/registry/blocks/agent-kit/block.json +10 -0
- package/registry/blocks/agent-kit/demo.jsx +35 -0
- package/registry/blocks/agent-kit/index.js +3 -0
- package/registry/blocks/agent-marks/README.md +80 -0
- package/registry/blocks/agent-marks/agent-marks.jsx +133 -0
- package/registry/blocks/agent-marks/block.json +27 -0
- package/registry/blocks/agent-marks/demo.jsx +49 -0
- package/registry/blocks/agent-marks/index.js +3 -0
- package/registry/blocks/agent-pane/README.md +225 -0
- package/registry/blocks/agent-pane/agent-pane.jsx +244 -0
- package/registry/blocks/agent-pane/block.json +41 -0
- package/registry/blocks/agent-pane/composer.jsx +6 -0
- package/registry/blocks/agent-pane/demo.jsx +233 -0
- package/registry/blocks/agent-pane/dock-context.js +10 -0
- package/registry/blocks/agent-pane/index.js +4 -0
- package/registry/blocks/agent-pane/prose.jsx +84 -0
- package/registry/blocks/agent-pane/questions.jsx +134 -0
- package/registry/blocks/agent-pane/transcript.jsx +268 -0
- package/registry/blocks/agent-pane/work.jsx +368 -0
- package/registry/blocks/ai-action/README.md +94 -0
- package/registry/blocks/ai-action/ai-action.jsx +188 -0
- package/registry/blocks/ai-action/block.json +34 -0
- package/registry/blocks/ai-action/demo.jsx +93 -0
- package/registry/blocks/ai-action/index.js +3 -0
- package/registry/blocks/annotate/README.md +14 -11
- package/registry/blocks/approval/README.md +145 -0
- package/registry/blocks/approval/approval.jsx +163 -0
- package/registry/blocks/approval/block.json +31 -0
- package/registry/blocks/approval/demo.jsx +121 -0
- package/registry/blocks/approval/index.js +3 -0
- package/registry/blocks/ask-bar/README.md +105 -0
- package/registry/blocks/ask-bar/ask-bar.jsx +166 -0
- package/registry/blocks/ask-bar/block.json +26 -0
- package/registry/blocks/ask-bar/demo.jsx +78 -0
- package/registry/blocks/ask-bar/index.js +3 -0
- package/registry/blocks/automation-editor/README.md +291 -0
- package/registry/blocks/automation-editor/automation-editor.jsx +656 -0
- package/registry/blocks/automation-editor/block.json +39 -0
- package/registry/blocks/automation-editor/demo.jsx +284 -0
- package/registry/blocks/automation-editor/index.js +4 -0
- package/registry/blocks/automation-editor/run-inputs.jsx +82 -0
- package/registry/blocks/automation-list/README.md +129 -0
- package/registry/blocks/automation-list/automation-list.jsx +476 -0
- package/registry/blocks/automation-list/block.json +35 -0
- package/registry/blocks/automation-list/demo.jsx +67 -0
- package/registry/blocks/automation-list/index.js +3 -0
- package/registry/blocks/automation-model/README.md +109 -0
- package/registry/blocks/automation-model/block.json +135 -0
- package/registry/blocks/automation-model/catalog.js +256 -0
- package/registry/blocks/automation-model/check.js +161 -0
- package/registry/blocks/automation-model/demo.jsx +42 -0
- package/registry/blocks/automation-model/edit.js +262 -0
- package/registry/blocks/automation-model/fixes.js +287 -0
- package/registry/blocks/automation-model/glyph.jsx +13 -0
- package/registry/blocks/automation-model/graph.js +410 -0
- package/registry/blocks/automation-model/index.js +33 -0
- package/registry/blocks/automation-model/overlay.js +175 -0
- package/registry/blocks/automation-model/parts.jsx +94 -0
- package/registry/blocks/automation-model/schedule.js +53 -0
- package/registry/blocks/automation-model/templates.js +128 -0
- package/registry/blocks/automation-model/values.js +29 -0
- package/registry/blocks/automation-model/words.js +439 -0
- package/registry/blocks/automations-screen/README.md +207 -0
- package/registry/blocks/automations-screen/automations-screen.jsx +452 -0
- package/registry/blocks/automations-screen/block.json +47 -0
- package/registry/blocks/automations-screen/demo.jsx +364 -0
- package/registry/blocks/automations-screen/index.js +4 -0
- package/registry/blocks/automations-screen/screen-model.js +129 -0
- package/registry/blocks/chart/cartesian.jsx +1 -1
- package/registry/blocks/chart/core.jsx +33 -23
- package/registry/blocks/chart/pie.jsx +1 -1
- package/registry/blocks/chat/README.md +4 -1
- package/registry/blocks/chat/demo.jsx +2 -2
- package/registry/blocks/chat-pane/README.md +143 -0
- package/registry/blocks/chat-pane/block.json +48 -0
- package/registry/blocks/chat-pane/chat-attach.js +166 -0
- package/registry/blocks/chat-pane/chat-composer.jsx +195 -0
- package/registry/blocks/chat-pane/chat-context.js +17 -0
- package/registry/blocks/chat-pane/chat-model.js +43 -0
- package/registry/blocks/chat-pane/chat-pane.jsx +398 -0
- package/registry/blocks/chat-pane/chats-list.jsx +52 -0
- package/registry/blocks/chat-pane/demo.jsx +103 -0
- package/registry/blocks/chat-pane/index.js +9 -0
- package/registry/blocks/connect-card/README.md +99 -0
- package/registry/blocks/connect-card/block.json +10 -0
- package/registry/blocks/connect-card/connect-card.jsx +103 -0
- package/registry/blocks/connect-card/demo.jsx +49 -0
- package/registry/blocks/connect-card/index.js +3 -0
- package/registry/blocks/cost/README.md +115 -0
- package/registry/blocks/cost/block.json +10 -0
- package/registry/blocks/cost/cost.jsx +176 -0
- package/registry/blocks/cost/demo.jsx +66 -0
- package/registry/blocks/cost/index.js +3 -0
- package/registry/blocks/data-picker/README.md +81 -0
- package/registry/blocks/data-picker/block.json +38 -0
- package/registry/blocks/data-picker/data-picker.jsx +210 -0
- package/registry/blocks/data-picker/demo.jsx +34 -0
- package/registry/blocks/data-picker/fields.js +89 -0
- package/registry/blocks/data-picker/index.js +4 -0
- package/registry/blocks/data-table/demo.jsx +1 -1
- package/registry/blocks/first-run/README.md +118 -0
- package/registry/blocks/first-run/block.json +11 -0
- package/registry/blocks/first-run/demo.jsx +88 -0
- package/registry/blocks/first-run/first-run-model.js +51 -0
- package/registry/blocks/first-run/first-run.jsx +156 -0
- package/registry/blocks/first-run/index.js +5 -0
- package/registry/blocks/first-run/probe-rules.js +26 -0
- package/registry/blocks/fix-note/README.md +79 -0
- package/registry/blocks/fix-note/block.json +35 -0
- package/registry/blocks/fix-note/demo.jsx +30 -0
- package/registry/blocks/fix-note/fix-note.jsx +235 -0
- package/registry/blocks/fix-note/index.js +3 -0
- package/registry/blocks/flow-canvas/README.md +15 -8
- package/registry/blocks/flow-editor/README.md +108 -0
- package/registry/blocks/flow-editor/block.json +44 -0
- package/registry/blocks/flow-editor/demo.jsx +115 -0
- package/registry/blocks/flow-editor/flow-canvas.jsx +568 -0
- package/registry/blocks/flow-editor/flow-editor.jsx +154 -0
- package/registry/blocks/flow-editor/index.js +6 -0
- package/registry/blocks/flow-editor/minimap.jsx +78 -0
- package/registry/blocks/flow-editor/outline.jsx +134 -0
- package/registry/blocks/footer/README.md +3 -2
- package/registry/blocks/library-shelf/README.md +117 -0
- package/registry/blocks/library-shelf/block.json +28 -0
- package/registry/blocks/library-shelf/demo.jsx +68 -0
- package/registry/blocks/library-shelf/index.js +3 -0
- package/registry/blocks/library-shelf/library-shelf.jsx +211 -0
- package/registry/blocks/library-shelf/probe-rules.js +15 -0
- package/registry/blocks/margin-notes/README.md +222 -0
- package/registry/blocks/margin-notes/block.json +10 -0
- package/registry/blocks/margin-notes/demo.jsx +144 -0
- package/registry/blocks/margin-notes/index.js +20 -0
- package/registry/blocks/margin-notes/margin-model.js +224 -0
- package/registry/blocks/margin-notes/margin-notes.jsx +465 -0
- package/registry/blocks/mind-map/README.md +4 -2
- package/registry/blocks/needs-you/README.md +177 -0
- package/registry/blocks/needs-you/block.json +34 -0
- package/registry/blocks/needs-you/demo.jsx +143 -0
- package/registry/blocks/needs-you/index.js +3 -0
- package/registry/blocks/needs-you/needs-you.jsx +441 -0
- package/registry/blocks/org-chart/README.md +4 -2
- package/registry/blocks/pace-bar/README.md +230 -0
- package/registry/blocks/pace-bar/block.json +10 -0
- package/registry/blocks/pace-bar/demo.jsx +255 -0
- package/registry/blocks/pace-bar/index.js +22 -0
- package/registry/blocks/pace-bar/pace-bar.jsx +461 -0
- package/registry/blocks/pace-bar/pace-model.js +288 -0
- package/registry/blocks/page-builder/README.md +1 -1
- package/registry/blocks/page-builder/demo.jsx +3 -3
- package/registry/blocks/pdf-viewer/README.md +4 -1
- package/registry/blocks/record-grid/README.md +100 -0
- package/registry/blocks/record-grid/block.json +28 -0
- package/registry/blocks/record-grid/demo.jsx +43 -0
- package/registry/blocks/record-grid/index.js +3 -0
- package/registry/blocks/record-grid/record-grid.jsx +251 -0
- package/registry/blocks/run-history/README.md +138 -0
- package/registry/blocks/run-history/block.json +10 -0
- package/registry/blocks/run-history/demo.jsx +74 -0
- package/registry/blocks/run-history/index.js +3 -0
- package/registry/blocks/run-history/run-history.jsx +218 -0
- package/registry/blocks/run-view/README.md +174 -0
- package/registry/blocks/run-view/block.json +50 -0
- package/registry/blocks/run-view/demo.jsx +286 -0
- package/registry/blocks/run-view/index.js +5 -0
- package/registry/blocks/run-view/run-controls.jsx +266 -0
- package/registry/blocks/run-view/run-view.jsx +236 -0
- package/registry/blocks/run-view/runs-list.jsx +99 -0
- package/registry/blocks/schedule-card/README.md +121 -0
- package/registry/blocks/schedule-card/block.json +10 -0
- package/registry/blocks/schedule-card/demo.jsx +82 -0
- package/registry/blocks/schedule-card/index.js +3 -0
- package/registry/blocks/schedule-card/schedule-card.jsx +136 -0
- package/registry/blocks/schedule-engine/README.md +137 -0
- package/registry/blocks/schedule-engine/block.json +10 -0
- package/registry/blocks/schedule-engine/demo.jsx +82 -0
- package/registry/blocks/schedule-engine/engine.js +769 -0
- package/registry/blocks/schedule-engine/index.js +9 -0
- package/registry/blocks/schedule-engine/ops.js +71 -0
- package/registry/blocks/schedule-engine/place.js +294 -0
- package/registry/blocks/schedule-engine/tree.js +79 -0
- package/registry/blocks/schedule-engine/waits.js +80 -0
- package/registry/blocks/schedule-gantt/README.md +159 -0
- package/registry/blocks/schedule-gantt/block.json +10 -0
- package/registry/blocks/schedule-gantt/demo.jsx +223 -0
- package/registry/blocks/schedule-gantt/gantt-model.js +219 -0
- package/registry/blocks/schedule-gantt/geometry.js +176 -0
- package/registry/blocks/schedule-gantt/index.js +26 -0
- package/registry/blocks/schedule-gantt/schedule-gantt.jsx +882 -0
- package/registry/blocks/schedule-gantt/sheet.jsx +372 -0
- package/registry/blocks/schedule-gantt/track.jsx +190 -0
- package/registry/blocks/schedule-ruler/README.md +148 -0
- package/registry/blocks/schedule-ruler/block.json +10 -0
- package/registry/blocks/schedule-ruler/demo.jsx +181 -0
- package/registry/blocks/schedule-ruler/index.js +21 -0
- package/registry/blocks/schedule-ruler/ruler-model.js +239 -0
- package/registry/blocks/schedule-ruler/schedule-ruler.jsx +548 -0
- package/registry/blocks/sidebar/README.md +23 -13
- package/registry/blocks/sketch-canvas/README.md +15 -9
- package/registry/blocks/source-receipt/README.md +97 -0
- package/registry/blocks/source-receipt/block.json +30 -0
- package/registry/blocks/source-receipt/demo.jsx +71 -0
- package/registry/blocks/source-receipt/index.js +3 -0
- package/registry/blocks/source-receipt/source-receipt.jsx +107 -0
- package/registry/blocks/spreadsheet/spreadsheet.jsx +15 -1
- package/registry/blocks/step-picker/README.md +78 -0
- package/registry/blocks/step-picker/block.json +31 -0
- package/registry/blocks/step-picker/demo.jsx +23 -0
- package/registry/blocks/step-picker/index.js +3 -0
- package/registry/blocks/step-picker/step-picker.jsx +144 -0
- package/registry/blocks/step-settings/README.md +100 -0
- package/registry/blocks/step-settings/block.json +44 -0
- package/registry/blocks/step-settings/demo.jsx +93 -0
- package/registry/blocks/step-settings/fields.jsx +58 -0
- package/registry/blocks/step-settings/flow-settings.jsx +115 -0
- package/registry/blocks/step-settings/index.js +5 -0
- package/registry/blocks/step-settings/step-settings.jsx +290 -0
- package/registry/blocks/suggestion/README.md +171 -0
- package/registry/blocks/suggestion/block.json +40 -0
- package/registry/blocks/suggestion/demo.jsx +91 -0
- package/registry/blocks/suggestion/index.js +3 -0
- package/registry/blocks/suggestion/suggestion.jsx +436 -0
- package/registry/blocks/sum-bar/README.md +122 -0
- package/registry/blocks/sum-bar/block.json +10 -0
- package/registry/blocks/sum-bar/demo.jsx +110 -0
- package/registry/blocks/sum-bar/index.js +5 -0
- package/registry/blocks/sum-bar/sum-bar.jsx +209 -0
- package/registry/blocks/sum-bar/sum-model.js +126 -0
- package/registry/blocks/tier-map/README.md +217 -0
- package/registry/blocks/tier-map/block.json +10 -0
- package/registry/blocks/tier-map/demo.jsx +222 -0
- package/registry/blocks/tier-map/index.js +24 -0
- package/registry/blocks/tier-map/tier-map.jsx +574 -0
- package/registry/blocks/tier-map/tier-model.js +318 -0
- package/registry/blocks/time-grid/README.md +305 -0
- package/registry/blocks/time-grid/block.json +10 -0
- package/registry/blocks/time-grid/demo.jsx +279 -0
- package/registry/blocks/time-grid/grid-model.js +322 -0
- package/registry/blocks/time-grid/index.js +25 -0
- package/registry/blocks/time-grid/time-grid.jsx +1325 -0
- package/registry/blocks/time-strip/README.md +141 -0
- package/registry/blocks/time-strip/block.json +10 -0
- package/registry/blocks/time-strip/demo.jsx +129 -0
- package/registry/blocks/time-strip/index.js +19 -0
- package/registry/blocks/time-strip/strip-model.js +178 -0
- package/registry/blocks/time-strip/time-strip.jsx +260 -0
- package/registry/blocks/top-bar/README.md +149 -0
- package/registry/blocks/top-bar/block.json +35 -0
- package/registry/blocks/top-bar/demo.jsx +78 -0
- package/registry/blocks/top-bar/index.js +5 -0
- package/registry/blocks/top-bar/probe-rules.js +74 -0
- package/registry/blocks/top-bar/top-bar-model.js +152 -0
- package/registry/blocks/top-bar/top-bar.jsx +244 -0
- package/registry/blocks/trigger-picker/README.md +98 -0
- package/registry/blocks/trigger-picker/block.json +38 -0
- package/registry/blocks/trigger-picker/demo.jsx +59 -0
- package/registry/blocks/trigger-picker/index.js +3 -0
- package/registry/blocks/trigger-picker/trigger-picker.jsx +374 -0
- package/registry/blocks/whiteboard/README.md +20 -14
- package/registry/blocks/workflow-view/README.md +123 -0
- package/registry/blocks/workflow-view/block.json +10 -0
- package/registry/blocks/workflow-view/demo.jsx +90 -0
- package/registry/blocks/workflow-view/index.js +3 -0
- package/registry/blocks/workflow-view/workflow-view.jsx +203 -0
- package/src/cli.mjs +2 -2
- package/src/install.mjs +100 -22
- package/src/registry.mjs +37 -3
- package/templates/next/browser/lib/data.js +6 -1
- package/templates/next/files/README.md +909 -26
- package/templates/next/files/app/shell.jsx +54 -37
- package/templates/next/files/check/automation-format.ts +2103 -0
- package/templates/next/files/check/automation-package.ts +142 -0
- package/templates/next/files/check/run.mjs +1043 -12
- package/templates/next/files/components/ui/field.jsx +17 -4
- package/templates/next/files/components/ui/icon.jsx +13 -0
- package/templates/next/files/components/ui/index.js +3 -1
- package/templates/next/files/components/ui/layout.jsx +382 -0
- package/templates/next/files/components/ui/notice.jsx +70 -0
- package/templates/next/files/components/ui/page.jsx +124 -0
- package/templates/next/files/components/ui/stat.jsx +22 -7
- package/templates/next/files/components/ui/toast.jsx +6 -3
- package/templates/next/files/lib/automations.js +660 -0
- package/templates/next/files/lib/claw.js +244 -5
- package/templates/next/files/lib/door.js +92 -0
- package/templates/next/files/lib/hooks.js +1694 -6
- package/templates/next/files/lib/platform.js +611 -14
- package/templates/next/template.json +22 -3
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
// The margin-notes block's pure model — no React, no DOM.
|
|
2
|
+
//
|
|
3
|
+
// A passage is a stretch of words with an id. A note belongs to one passage
|
|
4
|
+
// (note.passage) and says something about it: where it came from, that it
|
|
5
|
+
// needs checking, that it was cut, a comment. This file holds the rules the
|
|
6
|
+
// component and its tests share: which kinds exist and how each looks and
|
|
7
|
+
// acts, which notes sit by which passage, which words of a passage a note
|
|
8
|
+
// marks, what J and K walk to, and the counts.
|
|
9
|
+
//
|
|
10
|
+
// README.md beside this file is the contract; this file is the proof.
|
|
11
|
+
|
|
12
|
+
/** The tones a kind or a note may use (the kit's status tones). */
|
|
13
|
+
export const TONES = ["neutral", "primary", "info", "success", "warning", "danger"];
|
|
14
|
+
|
|
15
|
+
/** How the words a note is about are drawn in the passage. */
|
|
16
|
+
export const MARKS = ["underline", "wavy", "strike", "highlight", "none"];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The four kinds a margin knows. An app may change any field of one, or add
|
|
20
|
+
* its own kind, through the block's `kinds` prop.
|
|
21
|
+
*
|
|
22
|
+
* label the chip's words
|
|
23
|
+
* icon a kit icon name
|
|
24
|
+
* tone neutral · primary · info · success · warning · danger
|
|
25
|
+
* mark underline · wavy · strike · highlight · none: the words in the
|
|
26
|
+
* passage that the note is about
|
|
27
|
+
* actions [{ id, label, variant?, icon? }]: the buttons on an open note
|
|
28
|
+
* reopen the button on a settled note (false: none)
|
|
29
|
+
*/
|
|
30
|
+
export const MARGIN_KINDS = {
|
|
31
|
+
source: { label: "Source", icon: "link", tone: "neutral", mark: "underline", actions: [], reopen: false },
|
|
32
|
+
flag: {
|
|
33
|
+
label: "Check this line",
|
|
34
|
+
icon: "flag",
|
|
35
|
+
tone: "warning",
|
|
36
|
+
mark: "wavy",
|
|
37
|
+
actions: [
|
|
38
|
+
{ id: "confirm", label: "It’s true", icon: "check", variant: "secondary" },
|
|
39
|
+
{ id: "cut", label: "Cut it", icon: "x", variant: "secondary" },
|
|
40
|
+
{ id: "ask", label: "Ask where it came from", variant: "quiet" },
|
|
41
|
+
],
|
|
42
|
+
reopen: { label: "Reopen" },
|
|
43
|
+
},
|
|
44
|
+
cut: {
|
|
45
|
+
label: "Cut",
|
|
46
|
+
icon: "eraser",
|
|
47
|
+
tone: "danger",
|
|
48
|
+
mark: "strike",
|
|
49
|
+
actions: [{ id: "putback", label: "Put back", icon: "undo", variant: "secondary" }],
|
|
50
|
+
reopen: false,
|
|
51
|
+
},
|
|
52
|
+
comment: { label: "Comment", icon: "message-square", tone: "info", mark: "highlight", actions: [], reopen: false },
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const FALLBACK = { label: "Note", icon: "message-circle", tone: "neutral", mark: "highlight", actions: [], reopen: false };
|
|
56
|
+
|
|
57
|
+
/** "needs_review" -> "Needs review". */
|
|
58
|
+
export function humanize(id) {
|
|
59
|
+
const words = String(id ?? "").replace(/[_-]+/g, " ").trim();
|
|
60
|
+
return words ? words[0].toUpperCase() + words.slice(1) : "";
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The built-in kinds with an app's changes laid over them, field by field. */
|
|
64
|
+
export function resolveKinds(overrides) {
|
|
65
|
+
const out = {};
|
|
66
|
+
for (const [id, def] of Object.entries(MARGIN_KINDS)) out[id] = { ...def };
|
|
67
|
+
for (const [id, def] of Object.entries(overrides ?? {})) {
|
|
68
|
+
if (!def || typeof def !== "object") continue;
|
|
69
|
+
out[id] = { ...(out[id] ?? { ...FALLBACK, label: humanize(id) }), ...def };
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** What a note looks like and offers: its kind's definition with the note's own words over it. */
|
|
75
|
+
export function noteLook(note, kinds) {
|
|
76
|
+
const kind = kinds?.[note?.kind] ?? { ...FALLBACK, label: humanize(note?.kind) || FALLBACK.label };
|
|
77
|
+
const tone = TONES.includes(note?.tone) ? note.tone : TONES.includes(kind.tone) ? kind.tone : "neutral";
|
|
78
|
+
const hue = Number.isInteger(note?.hue) && note.hue >= 1 && note.hue <= 5 ? note.hue : null;
|
|
79
|
+
const mark = MARKS.includes(note?.mark) ? note.mark : MARKS.includes(kind.mark) ? kind.mark : "highlight";
|
|
80
|
+
return {
|
|
81
|
+
label: note?.label || kind.label,
|
|
82
|
+
icon: kind.icon || FALLBACK.icon,
|
|
83
|
+
tone,
|
|
84
|
+
hue,
|
|
85
|
+
mark,
|
|
86
|
+
actions: Array.isArray(note?.actions) ? note.actions : kind.actions ?? [],
|
|
87
|
+
reopen: kind.reopen,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** A note nobody needs to act on any more. */
|
|
92
|
+
export const isSettled = (note) => note?.state === "settled";
|
|
93
|
+
|
|
94
|
+
/** The buttons an open note shows; none when it is locked, settled or read-only. */
|
|
95
|
+
export function actionsOf(note, kinds, { readOnly = false } = {}) {
|
|
96
|
+
if (readOnly || isSettled(note) || note?.locked) return [];
|
|
97
|
+
return noteLook(note, kinds).actions.filter((a) => a && a.id && a.label);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Which notes sit by which passage.
|
|
102
|
+
* byPassage Map: passage id -> its notes, in the order given
|
|
103
|
+
* ordered every note, in the passages' order (a passage's notes keep their order)
|
|
104
|
+
* orphans notes whose passage is not in the list
|
|
105
|
+
*/
|
|
106
|
+
export function arrangeNotes(passages, notes) {
|
|
107
|
+
const byPassage = new Map();
|
|
108
|
+
for (const p of passages ?? []) {
|
|
109
|
+
if (!p || p.id == null || byPassage.has(p.id)) continue;
|
|
110
|
+
byPassage.set(p.id, []);
|
|
111
|
+
}
|
|
112
|
+
const orphans = [];
|
|
113
|
+
const seen = new Set();
|
|
114
|
+
for (const n of notes ?? []) {
|
|
115
|
+
if (!n || n.id == null || seen.has(n.id)) continue;
|
|
116
|
+
seen.add(n.id);
|
|
117
|
+
if (byPassage.has(n.passage)) byPassage.get(n.passage).push(n);
|
|
118
|
+
else orphans.push(n);
|
|
119
|
+
}
|
|
120
|
+
const ordered = [];
|
|
121
|
+
for (const list of byPassage.values()) ordered.push(...list);
|
|
122
|
+
ordered.push(...orphans);
|
|
123
|
+
return { byPassage, ordered, orphans };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* What J (dir 1) and K (dir -1) walk to: the next note that still needs a
|
|
128
|
+
* person, after the selected one. With nothing selected, the first (or the
|
|
129
|
+
* last, going back). At the end it stays where it is. Null when no note is
|
|
130
|
+
* left to walk.
|
|
131
|
+
*/
|
|
132
|
+
export function walkNext(ordered, currentId, dir = 1) {
|
|
133
|
+
const list = ordered ?? [];
|
|
134
|
+
const step = dir < 0 ? -1 : 1;
|
|
135
|
+
const open = (n) => !isSettled(n);
|
|
136
|
+
if (!list.some(open)) return null;
|
|
137
|
+
const at = list.findIndex((n) => n.id === currentId);
|
|
138
|
+
if (at < 0) {
|
|
139
|
+
const pick = step > 0 ? list.find(open) : [...list].reverse().find(open);
|
|
140
|
+
return pick.id;
|
|
141
|
+
}
|
|
142
|
+
for (let i = at + step; i >= 0 && i < list.length; i += step) if (open(list[i])) return list[i].id;
|
|
143
|
+
return currentId;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** A press on a passage: its first note; pressed again, its next; after the last, none. */
|
|
147
|
+
export function cycleNote(passageNotes, currentId) {
|
|
148
|
+
const list = passageNotes ?? [];
|
|
149
|
+
if (!list.length) return null;
|
|
150
|
+
const at = list.findIndex((n) => n.id === currentId);
|
|
151
|
+
if (at < 0) return list[0].id;
|
|
152
|
+
return list[at + 1]?.id ?? null;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
156
|
+
|
|
157
|
+
/** Where a quote sits in a text, ignoring case: [start, end] or null. */
|
|
158
|
+
export function findQuote(text, quote) {
|
|
159
|
+
const q = typeof quote === "string" ? quote.trim() : "";
|
|
160
|
+
if (!q || typeof text !== "string") return null;
|
|
161
|
+
const m = new RegExp(escapeRe(q).replace(/\s+/g, "\\s+"), "iu").exec(text);
|
|
162
|
+
return m ? [m.index, m.index + m[0].length] : null;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* The words of a passage, cut into pieces by the notes that mark them.
|
|
167
|
+
*
|
|
168
|
+
* segments [{ text, ids }]: in order, joined they are the text; ids are
|
|
169
|
+
* the notes whose quote covers the piece (empty: plain words)
|
|
170
|
+
* whole the first open note whose mark is "strike" and whose quote
|
|
171
|
+
* is empty or not in the text: it strikes the whole passage
|
|
172
|
+
* (then `segments` is that one piece)
|
|
173
|
+
*
|
|
174
|
+
* `markOf(note)` names how a note marks its words; a settled note marks
|
|
175
|
+
* nothing (a cut that was put back reads as plain words again).
|
|
176
|
+
*/
|
|
177
|
+
export function inlineMarks(text, notes, markOf = () => "highlight") {
|
|
178
|
+
const body = typeof text === "string" ? text : "";
|
|
179
|
+
const ranges = [];
|
|
180
|
+
let whole = null;
|
|
181
|
+
for (const n of notes ?? []) {
|
|
182
|
+
if (isSettled(n)) continue;
|
|
183
|
+
const mark = markOf(n);
|
|
184
|
+
if (mark === "none") continue;
|
|
185
|
+
const at = findQuote(body, n.quote);
|
|
186
|
+
if (at) ranges.push({ id: n.id, from: at[0], to: at[1] });
|
|
187
|
+
else if (mark === "strike" && !whole) whole = n;
|
|
188
|
+
}
|
|
189
|
+
if (whole) return { segments: [{ text: body, ids: [whole.id] }], whole };
|
|
190
|
+
if (!ranges.length) return { segments: [{ text: body, ids: [] }], whole: null };
|
|
191
|
+
const cuts = [...new Set([0, body.length, ...ranges.flatMap((r) => [r.from, r.to])])].sort((a, b) => a - b);
|
|
192
|
+
const segments = [];
|
|
193
|
+
for (let i = 0; i < cuts.length - 1; i++) {
|
|
194
|
+
const [a, b] = [cuts[i], cuts[i + 1]];
|
|
195
|
+
if (a === b) continue;
|
|
196
|
+
segments.push({ text: body.slice(a, b), ids: ranges.filter((r) => r.from <= a && r.to >= b).map((r) => r.id) });
|
|
197
|
+
}
|
|
198
|
+
return { segments, whole: null };
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** How many notes there are, how many still need a person, and by kind. */
|
|
202
|
+
export function countNotes(notes) {
|
|
203
|
+
const out = { total: 0, open: 0, settled: 0, byKind: {} };
|
|
204
|
+
for (const n of notes ?? []) {
|
|
205
|
+
if (!n) continue;
|
|
206
|
+
out.total += 1;
|
|
207
|
+
if (isSettled(n)) out.settled += 1;
|
|
208
|
+
else out.open += 1;
|
|
209
|
+
const k = (out.byKind[n.kind] ??= { total: 0, open: 0 });
|
|
210
|
+
k.total += 1;
|
|
211
|
+
if (!isSettled(n)) k.open += 1;
|
|
212
|
+
}
|
|
213
|
+
return out;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** "3 open · 1 settled" — the margin's count line. */
|
|
217
|
+
export function countWords(counts, words = {}) {
|
|
218
|
+
const open = words.open ?? "open";
|
|
219
|
+
const settled = words.settled ?? "settled";
|
|
220
|
+
const parts = [];
|
|
221
|
+
if (counts.open) parts.push(`${counts.open} ${open}`);
|
|
222
|
+
if (counts.settled) parts.push(`${counts.settled} ${settled}`);
|
|
223
|
+
return parts.join(" · ");
|
|
224
|
+
}
|