makersclaw 0.1.0 → 0.3.0
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/LICENSE +21 -0
- package/README.md +41 -1
- package/THIRD-PARTY-NOTICES.md +180 -0
- package/package.json +15 -8
- package/r/annotate.json +62 -0
- package/r/approval-request.json +52 -0
- package/r/audio-player.json +74 -0
- package/r/auth-form.json +55 -0
- package/r/board.json +55 -0
- package/r/calendar-view.json +105 -0
- package/r/cart.json +62 -0
- package/r/chart.json +83 -0
- package/r/chat.json +95 -0
- package/r/code-editor.json +94 -0
- package/r/comment-box.json +64 -0
- package/r/contact-section.json +53 -0
- package/r/core.json +341 -0
- package/r/csv-import.json +63 -0
- package/r/data-table.json +69 -0
- package/r/diagram.json +74 -0
- package/r/doc-editor.json +82 -0
- package/r/doc-page.json +61 -0
- package/r/email-render.json +73 -0
- package/r/faq.json +50 -0
- package/r/file-upload.json +54 -0
- package/r/flow-canvas.json +93 -0
- package/r/footer.json +52 -0
- package/r/gantt.json +70 -0
- package/r/job-panel.json +56 -0
- package/r/json-editor.json +66 -0
- package/r/map.json +89 -0
- package/r/menubar.json +52 -0
- package/r/mind-map.json +67 -0
- package/r/navigation-menu.json +52 -0
- package/r/order-detail.json +54 -0
- package/r/org-chart.json +66 -0
- package/r/page-builder.json +105 -0
- package/r/payment-methods.json +51 -0
- package/r/pdf-document.json +79 -0
- package/r/pdf-viewer.json +88 -0
- package/r/product-detail.json +76 -0
- package/r/product-grid.json +65 -0
- package/r/record-form.json +67 -0
- package/r/record-notes.json +55 -0
- package/r/registry.json +3612 -0
- package/r/search-dialog.json +51 -0
- package/r/settings-list.json +66 -0
- package/r/setup-checklist.json +51 -0
- package/r/share-dialog.json +52 -0
- package/r/sidebar.json +69 -0
- package/r/signature-pad.json +72 -0
- package/r/sketch-canvas.json +99 -0
- package/r/spreadsheet.json +90 -0
- package/r/stat-cards.json +66 -0
- package/r/task-list.json +63 -0
- package/r/task-model.json +98 -0
- package/r/testimonials.json +52 -0
- package/r/transaction-list.json +53 -0
- package/r/whiteboard.json +66 -0
- package/registry/blocks/annotate/README.md +179 -0
- package/registry/blocks/annotate/annotate-data.js +250 -0
- package/registry/blocks/annotate/annotate.jsx +646 -0
- package/registry/blocks/annotate/block.json +10 -0
- package/registry/blocks/annotate/demo.jsx +135 -0
- package/registry/blocks/annotate/index.js +15 -0
- package/registry/blocks/approval-request/README.md +116 -0
- package/registry/blocks/approval-request/approval-request.jsx +386 -0
- package/registry/blocks/approval-request/block.json +10 -0
- package/registry/blocks/approval-request/demo.jsx +127 -0
- package/registry/blocks/approval-request/index.js +4 -0
- package/registry/blocks/audio-player/README.md +167 -0
- package/registry/blocks/audio-player/audio-player.jsx +623 -0
- package/registry/blocks/audio-player/block.json +14 -0
- package/registry/blocks/audio-player/colors.js +109 -0
- package/registry/blocks/audio-player/demo.jsx +209 -0
- package/registry/blocks/audio-player/index.js +6 -0
- package/registry/blocks/audio-player/time.js +67 -0
- package/registry/blocks/audio-player/wavesurfer.js +9 -0
- package/registry/blocks/auth-form/README.md +126 -0
- package/registry/blocks/auth-form/auth-form.jsx +568 -0
- package/registry/blocks/auth-form/block.json +10 -0
- package/registry/blocks/auth-form/demo.jsx +131 -0
- package/registry/blocks/auth-form/index.js +3 -0
- package/registry/blocks/board/README.md +64 -13
- package/registry/blocks/board/block.json +2 -2
- package/registry/blocks/board/board.jsx +237 -94
- package/registry/blocks/board/demo.jsx +103 -24
- package/registry/blocks/calendar-view/README.md +180 -0
- package/registry/blocks/calendar-view/agenda.jsx +147 -0
- package/registry/blocks/calendar-view/block.json +76 -0
- package/registry/blocks/calendar-view/calendar-model.js +442 -0
- package/registry/blocks/calendar-view/calendar.jsx +627 -0
- package/registry/blocks/calendar-view/demo.jsx +195 -0
- package/registry/blocks/calendar-view/draft.jsx +49 -0
- package/registry/blocks/calendar-view/index.js +39 -0
- package/registry/blocks/calendar-view/month.jsx +346 -0
- package/registry/blocks/calendar-view/paint.js +69 -0
- package/registry/blocks/calendar-view/time-grid.jsx +527 -0
- package/registry/blocks/calendar-view/tray.jsx +87 -0
- package/registry/blocks/cart/README.md +146 -0
- package/registry/blocks/cart/block.json +10 -0
- package/registry/blocks/cart/cart.jsx +597 -0
- package/registry/blocks/cart/demo.jsx +98 -0
- package/registry/blocks/cart/index.js +4 -0
- package/registry/blocks/cart/money.js +28 -0
- package/registry/blocks/chart/README.md +316 -0
- package/registry/blocks/chart/block.json +10 -0
- package/registry/blocks/chart/cartesian.jsx +642 -0
- package/registry/blocks/chart/core.jsx +262 -0
- package/registry/blocks/chart/demo.jsx +357 -0
- package/registry/blocks/chart/heatmap.jsx +336 -0
- package/registry/blocks/chart/index.js +8 -0
- package/registry/blocks/chart/pie.jsx +245 -0
- package/registry/blocks/chart/sparkline.jsx +88 -0
- package/registry/blocks/chat/README.md +273 -0
- package/registry/blocks/chat/attachment.jsx +95 -0
- package/registry/blocks/chat/block.json +10 -0
- package/registry/blocks/chat/chat.jsx +132 -0
- package/registry/blocks/chat/composer.jsx +364 -0
- package/registry/blocks/chat/demo.jsx +578 -0
- package/registry/blocks/chat/header.jsx +34 -0
- package/registry/blocks/chat/index.js +9 -0
- package/registry/blocks/chat/message.jsx +450 -0
- package/registry/blocks/chat/scroller.jsx +247 -0
- package/registry/blocks/chat/text.jsx +104 -0
- package/registry/blocks/code-editor/README.md +210 -0
- package/registry/blocks/code-editor/block.json +22 -0
- package/registry/blocks/code-editor/code-editor.jsx +534 -0
- package/registry/blocks/code-editor/codemirror.js +38 -0
- package/registry/blocks/code-editor/demo.jsx +205 -0
- package/registry/blocks/code-editor/index.js +8 -0
- package/registry/blocks/code-editor/json.js +317 -0
- package/registry/blocks/code-editor/sql.js +136 -0
- package/registry/blocks/code-editor/text.js +101 -0
- package/registry/blocks/code-editor/theme.js +186 -0
- package/registry/blocks/comment-box/README.md +123 -0
- package/registry/blocks/comment-box/block.json +10 -0
- package/registry/blocks/comment-box/comment-body.jsx +217 -0
- package/registry/blocks/comment-box/comment-box.jsx +198 -0
- package/registry/blocks/comment-box/comment-time.jsx +77 -0
- package/registry/blocks/comment-box/demo.jsx +141 -0
- package/registry/blocks/comment-box/index.js +8 -0
- package/registry/blocks/contact-section/README.md +152 -0
- package/registry/blocks/contact-section/block.json +11 -0
- package/registry/blocks/contact-section/contact-section.jsx +509 -0
- package/registry/blocks/contact-section/demo.jsx +93 -0
- package/registry/blocks/contact-section/index.js +4 -0
- package/registry/blocks/csv-import/README.md +133 -0
- package/registry/blocks/csv-import/block.json +13 -0
- package/registry/blocks/csv-import/csv-import.jsx +479 -0
- package/registry/blocks/csv-import/demo.jsx +106 -0
- package/registry/blocks/csv-import/import.js +200 -0
- package/registry/blocks/csv-import/index.js +7 -0
- package/registry/blocks/data-table/README.md +386 -0
- package/registry/blocks/data-table/block.json +10 -0
- package/registry/blocks/data-table/data-table.jsx +1164 -0
- package/registry/blocks/data-table/demo.jsx +588 -0
- package/registry/blocks/data-table/index.js +5 -0
- package/registry/blocks/data-table/model.js +169 -0
- package/registry/blocks/diagram/README.md +108 -0
- package/registry/blocks/diagram/block.json +13 -0
- package/registry/blocks/diagram/demo.jsx +113 -0
- package/registry/blocks/diagram/diagram.jsx +481 -0
- package/registry/blocks/diagram/index.js +7 -0
- package/registry/blocks/diagram/mermaid.js +52 -0
- package/registry/blocks/diagram/palette.js +313 -0
- package/registry/blocks/diagram/source.js +98 -0
- package/registry/blocks/doc-editor/README.md +215 -0
- package/registry/blocks/doc-editor/block.json +15 -0
- package/registry/blocks/doc-editor/demo.jsx +225 -0
- package/registry/blocks/doc-editor/doc-editor.jsx +291 -0
- package/registry/blocks/doc-editor/doc.js +309 -0
- package/registry/blocks/doc-editor/index.js +7 -0
- package/registry/blocks/doc-editor/schema.jsx +56 -0
- package/registry/blocks/doc-editor/shadcn-classes.js +110 -0
- package/registry/blocks/doc-editor/theme.js +82 -0
- package/registry/blocks/doc-page/README.md +119 -0
- package/registry/blocks/doc-page/autosave.js +104 -0
- package/registry/blocks/doc-page/block.json +10 -0
- package/registry/blocks/doc-page/demo.jsx +137 -0
- package/registry/blocks/doc-page/doc-page.jsx +276 -0
- package/registry/blocks/doc-page/index.js +4 -0
- package/registry/blocks/email-render/README.md +151 -0
- package/registry/blocks/email-render/block.json +14 -0
- package/registry/blocks/email-render/demo.jsx +153 -0
- package/registry/blocks/email-render/doc-email.jsx +210 -0
- package/registry/blocks/email-render/email.jsx +221 -0
- package/registry/blocks/email-render/index.js +10 -0
- package/registry/blocks/email-render/render.js +50 -0
- package/registry/blocks/email-render/theme.js +215 -0
- package/registry/blocks/faq/README.md +101 -0
- package/registry/blocks/faq/block.json +11 -0
- package/registry/blocks/faq/demo.jsx +89 -0
- package/registry/blocks/faq/faq.jsx +220 -0
- package/registry/blocks/faq/index.js +4 -0
- package/registry/blocks/file-upload/README.md +138 -0
- package/registry/blocks/file-upload/block.json +10 -0
- package/registry/blocks/file-upload/demo.jsx +204 -0
- package/registry/blocks/file-upload/file-upload.jsx +635 -0
- package/registry/blocks/file-upload/index.js +4 -0
- package/registry/blocks/flow-canvas/README.md +420 -0
- package/registry/blocks/flow-canvas/block.json +13 -0
- package/registry/blocks/flow-canvas/board.js +819 -0
- package/registry/blocks/flow-canvas/chrome.jsx +649 -0
- package/registry/blocks/flow-canvas/context.jsx +35 -0
- package/registry/blocks/flow-canvas/demo.jsx +249 -0
- package/registry/blocks/flow-canvas/edges.jsx +107 -0
- package/registry/blocks/flow-canvas/flow-canvas.jsx +1329 -0
- package/registry/blocks/flow-canvas/index.js +41 -0
- package/registry/blocks/flow-canvas/nodes.jsx +392 -0
- package/registry/blocks/flow-canvas/theme.js +174 -0
- package/registry/blocks/footer/README.md +133 -0
- package/registry/blocks/footer/block.json +11 -0
- package/registry/blocks/footer/demo.jsx +119 -0
- package/registry/blocks/footer/footer.jsx +406 -0
- package/registry/blocks/footer/index.js +4 -0
- package/registry/blocks/gantt/README.md +220 -0
- package/registry/blocks/gantt/block.json +10 -0
- package/registry/blocks/gantt/demo.jsx +148 -0
- package/registry/blocks/gantt/gantt.jsx +923 -0
- package/registry/blocks/gantt/index.js +7 -0
- package/registry/blocks/gantt/rows.jsx +468 -0
- package/registry/blocks/gantt/schedule.js +278 -0
- package/registry/blocks/job-panel/README.md +86 -2
- package/registry/blocks/job-panel/block.json +3 -3
- package/registry/blocks/job-panel/demo.jsx +230 -3
- package/registry/blocks/job-panel/job-panel.jsx +169 -3
- package/registry/blocks/json-editor/README.md +133 -0
- package/registry/blocks/json-editor/block.json +10 -0
- package/registry/blocks/json-editor/demo.jsx +92 -0
- package/registry/blocks/json-editor/index.js +7 -0
- package/registry/blocks/json-editor/json-editor.jsx +305 -0
- package/registry/blocks/json-editor/json-tree.jsx +393 -0
- package/registry/blocks/json-editor/tree.js +225 -0
- package/registry/blocks/map/README.md +221 -0
- package/registry/blocks/map/block.json +14 -0
- package/registry/blocks/map/demo.jsx +201 -0
- package/registry/blocks/map/geo.js +198 -0
- package/registry/blocks/map/index.js +8 -0
- package/registry/blocks/map/list.jsx +128 -0
- package/registry/blocks/map/map-view.jsx +715 -0
- package/registry/blocks/map/maplibre.js +30 -0
- package/registry/blocks/map/marks.jsx +146 -0
- package/registry/blocks/map/theme.js +142 -0
- package/registry/blocks/menubar/README.md +109 -0
- package/registry/blocks/menubar/block.json +10 -0
- package/registry/blocks/menubar/demo.jsx +128 -0
- package/registry/blocks/menubar/index.js +4 -0
- package/registry/blocks/menubar/menubar.jsx +199 -0
- package/registry/blocks/mind-map/README.md +206 -0
- package/registry/blocks/mind-map/block.json +10 -0
- package/registry/blocks/mind-map/demo.jsx +103 -0
- package/registry/blocks/mind-map/index.js +31 -0
- package/registry/blocks/mind-map/mind-map.jsx +1125 -0
- package/registry/blocks/mind-map/topic.jsx +143 -0
- package/registry/blocks/mind-map/tree.js +645 -0
- package/registry/blocks/navigation-menu/README.md +124 -0
- package/registry/blocks/navigation-menu/block.json +10 -0
- package/registry/blocks/navigation-menu/demo.jsx +84 -0
- package/registry/blocks/navigation-menu/index.js +4 -0
- package/registry/blocks/navigation-menu/navigation-menu.jsx +448 -0
- package/registry/blocks/order-detail/README.md +109 -0
- package/registry/blocks/order-detail/block.json +10 -0
- package/registry/blocks/order-detail/demo.jsx +88 -0
- package/registry/blocks/order-detail/index.js +4 -0
- package/registry/blocks/order-detail/order-detail.jsx +354 -0
- package/registry/blocks/org-chart/README.md +145 -0
- package/registry/blocks/org-chart/block.json +10 -0
- package/registry/blocks/org-chart/demo.jsx +94 -0
- package/registry/blocks/org-chart/index.js +7 -0
- package/registry/blocks/org-chart/org-chart.jsx +631 -0
- package/registry/blocks/org-chart/org.js +245 -0
- package/registry/blocks/org-chart/person.jsx +96 -0
- package/registry/blocks/page-builder/README.md +257 -0
- package/registry/blocks/page-builder/block.json +14 -0
- package/registry/blocks/page-builder/demo.jsx +145 -0
- package/registry/blocks/page-builder/grapes.js +18 -0
- package/registry/blocks/page-builder/index.js +11 -0
- package/registry/blocks/page-builder/page-builder.jsx +704 -0
- package/registry/blocks/page-builder/page-view.jsx +33 -0
- package/registry/blocks/page-builder/page.js +118 -0
- package/registry/blocks/page-builder/panels.jsx +588 -0
- package/registry/blocks/page-builder/sections.js +209 -0
- package/registry/blocks/page-builder/theme.js +87 -0
- package/registry/blocks/page-builder/thumbs.jsx +189 -0
- package/registry/blocks/page-builder/tokens.js +329 -0
- package/registry/blocks/payment-methods/README.md +104 -0
- package/registry/blocks/payment-methods/block.json +10 -0
- package/registry/blocks/payment-methods/demo.jsx +71 -0
- package/registry/blocks/payment-methods/index.js +4 -0
- package/registry/blocks/payment-methods/payment-methods.jsx +302 -0
- package/registry/blocks/pdf-document/README.md +213 -0
- package/registry/blocks/pdf-document/block.json +13 -0
- package/registry/blocks/pdf-document/demo.jsx +136 -0
- package/registry/blocks/pdf-document/index.js +33 -0
- package/registry/blocks/pdf-document/money.js +83 -0
- package/registry/blocks/pdf-document/pdf-document.jsx +144 -0
- package/registry/blocks/pdf-document/primitives.jsx +271 -0
- package/registry/blocks/pdf-document/quote.jsx +179 -0
- package/registry/blocks/pdf-document/theme.js +193 -0
- package/registry/blocks/pdf-viewer/README.md +191 -0
- package/registry/blocks/pdf-viewer/block.json +14 -0
- package/registry/blocks/pdf-viewer/demo.jsx +252 -0
- package/registry/blocks/pdf-viewer/helpers.js +270 -0
- package/registry/blocks/pdf-viewer/index.js +8 -0
- package/registry/blocks/pdf-viewer/notes.jsx +195 -0
- package/registry/blocks/pdf-viewer/pdf-viewer.jsx +1368 -0
- package/registry/blocks/pdf-viewer/pdfjs.js +37 -0
- package/registry/blocks/pdf-viewer/ssr-shim-end.js +6 -0
- package/registry/blocks/pdf-viewer/ssr-shim.js +44 -0
- package/registry/blocks/product-detail/README.md +217 -0
- package/registry/blocks/product-detail/block.json +10 -0
- package/registry/blocks/product-detail/demo.jsx +233 -0
- package/registry/blocks/product-detail/index.js +7 -0
- package/registry/blocks/product-detail/price.jsx +115 -0
- package/registry/blocks/product-detail/product-detail.jsx +348 -0
- package/registry/blocks/product-detail/product-media.jsx +102 -0
- package/registry/blocks/product-detail/product-options.jsx +144 -0
- package/registry/blocks/product-grid/README.md +162 -0
- package/registry/blocks/product-grid/block.json +10 -0
- package/registry/blocks/product-grid/demo.jsx +255 -0
- package/registry/blocks/product-grid/index.js +5 -0
- package/registry/blocks/product-grid/product-card.jsx +232 -0
- package/registry/blocks/product-grid/product-grid.jsx +235 -0
- package/registry/blocks/record-form/README.md +196 -0
- package/registry/blocks/record-form/block.json +10 -0
- package/registry/blocks/record-form/demo.jsx +525 -0
- package/registry/blocks/record-form/index.js +4 -0
- package/registry/blocks/record-form/record-fields.jsx +457 -0
- package/registry/blocks/record-form/record-form.jsx +415 -0
- package/registry/blocks/record-form/rules.js +81 -0
- package/registry/blocks/record-notes/README.md +139 -0
- package/registry/blocks/record-notes/block.json +10 -0
- package/registry/blocks/record-notes/demo.jsx +179 -0
- package/registry/blocks/record-notes/index.js +4 -0
- package/registry/blocks/record-notes/record-notes.jsx +266 -0
- package/registry/blocks/search-dialog/README.md +108 -0
- package/registry/blocks/search-dialog/block.json +10 -0
- package/registry/blocks/search-dialog/demo.jsx +116 -0
- package/registry/blocks/search-dialog/index.js +3 -0
- package/registry/blocks/search-dialog/search-dialog.jsx +235 -0
- package/registry/blocks/settings-list/README.md +171 -0
- package/registry/blocks/settings-list/block.json +10 -0
- package/registry/blocks/settings-list/demo.jsx +333 -0
- package/registry/blocks/settings-list/index.js +4 -0
- package/registry/blocks/settings-list/row-state.jsx +93 -0
- package/registry/blocks/settings-list/settings-list.jsx +349 -0
- package/registry/blocks/settings-list/settings-matrix.jsx +118 -0
- package/registry/blocks/setup-checklist/README.md +142 -0
- package/registry/blocks/setup-checklist/block.json +10 -0
- package/registry/blocks/setup-checklist/demo.jsx +159 -0
- package/registry/blocks/setup-checklist/index.js +4 -0
- package/registry/blocks/setup-checklist/setup-checklist.jsx +446 -0
- package/registry/blocks/share-dialog/README.md +113 -0
- package/registry/blocks/share-dialog/block.json +10 -0
- package/registry/blocks/share-dialog/demo.jsx +140 -0
- package/registry/blocks/share-dialog/index.js +3 -0
- package/registry/blocks/share-dialog/share-dialog.jsx +384 -0
- package/registry/blocks/sidebar/README.md +190 -0
- package/registry/blocks/sidebar/block.json +43 -0
- package/registry/blocks/sidebar/demo.jsx +577 -0
- package/registry/blocks/sidebar/index.js +4 -0
- package/registry/blocks/sidebar/sidebar-panel.jsx +149 -0
- package/registry/blocks/sidebar/sidebar.jsx +864 -0
- package/registry/blocks/signature-pad/README.md +137 -0
- package/registry/blocks/signature-pad/block.json +13 -0
- package/registry/blocks/signature-pad/colors.js +115 -0
- package/registry/blocks/signature-pad/demo.jsx +94 -0
- package/registry/blocks/signature-pad/index.js +6 -0
- package/registry/blocks/signature-pad/pad.js +7 -0
- package/registry/blocks/signature-pad/signature-pad.jsx +434 -0
- package/registry/blocks/signature-pad/signature.js +68 -0
- package/registry/blocks/sketch-canvas/README.md +280 -0
- package/registry/blocks/sketch-canvas/block.json +13 -0
- package/registry/blocks/sketch-canvas/demo.jsx +159 -0
- package/registry/blocks/sketch-canvas/excalidraw.js +40 -0
- package/registry/blocks/sketch-canvas/index.js +9 -0
- package/registry/blocks/sketch-canvas/palette.js +226 -0
- package/registry/blocks/sketch-canvas/sketch-canvas.jsx +1188 -0
- package/registry/blocks/sketch-canvas/sketch.js +179 -0
- package/registry/blocks/sketch-canvas/ssr-shim-end.js +6 -0
- package/registry/blocks/sketch-canvas/ssr-shim.js +45 -0
- package/registry/blocks/sketch-canvas/stamps.js +104 -0
- package/registry/blocks/sketch-canvas/theme.js +131 -0
- package/registry/blocks/spreadsheet/README.md +307 -0
- package/registry/blocks/spreadsheet/block.json +13 -0
- package/registry/blocks/spreadsheet/cells.jsx +455 -0
- package/registry/blocks/spreadsheet/chrome.jsx +325 -0
- package/registry/blocks/spreadsheet/demo.jsx +177 -0
- package/registry/blocks/spreadsheet/grid.js +387 -0
- package/registry/blocks/spreadsheet/index.js +34 -0
- package/registry/blocks/spreadsheet/spreadsheet.jsx +1732 -0
- package/registry/blocks/spreadsheet/types.js +473 -0
- package/registry/blocks/stat-cards/README.md +173 -0
- package/registry/blocks/stat-cards/block.json +10 -0
- package/registry/blocks/stat-cards/demo.jsx +257 -0
- package/registry/blocks/stat-cards/index.js +4 -0
- package/registry/blocks/stat-cards/stat-cards.jsx +307 -0
- package/registry/blocks/stat-cards/usage.jsx +243 -0
- package/registry/blocks/task-list/README.md +176 -0
- package/registry/blocks/task-list/block.json +10 -0
- package/registry/blocks/task-list/demo.jsx +134 -0
- package/registry/blocks/task-list/index.js +5 -0
- package/registry/blocks/task-list/task-list.jsx +907 -0
- package/registry/blocks/task-model/README.md +455 -0
- package/registry/blocks/task-model/block.json +167 -0
- package/registry/blocks/task-model/changes.js +89 -0
- package/registry/blocks/task-model/dates.js +371 -0
- package/registry/blocks/task-model/demo.jsx +215 -0
- package/registry/blocks/task-model/dnd.jsx +240 -0
- package/registry/blocks/task-model/index.js +97 -0
- package/registry/blocks/task-model/model.js +919 -0
- package/registry/blocks/task-model/parts.jsx +449 -0
- package/registry/blocks/task-model/toolbar.jsx +271 -0
- package/registry/blocks/testimonials/README.md +139 -0
- package/registry/blocks/testimonials/block.json +11 -0
- package/registry/blocks/testimonials/demo.jsx +137 -0
- package/registry/blocks/testimonials/index.js +4 -0
- package/registry/blocks/testimonials/testimonials.jsx +430 -0
- package/registry/blocks/transaction-list/README.md +126 -0
- package/registry/blocks/transaction-list/block.json +10 -0
- package/registry/blocks/transaction-list/demo.jsx +79 -0
- package/registry/blocks/transaction-list/index.js +4 -0
- package/registry/blocks/transaction-list/transaction-list.jsx +383 -0
- package/registry/blocks/whiteboard/README.md +179 -0
- package/registry/blocks/whiteboard/block.json +10 -0
- package/registry/blocks/whiteboard/demo.jsx +169 -0
- package/registry/blocks/whiteboard/index.js +6 -0
- package/registry/blocks/whiteboard/templates.js +150 -0
- package/registry/blocks/whiteboard/whiteboard.jsx +721 -0
- package/src/install.mjs +18 -0
- package/src/shadcn.mjs +171 -0
- package/templates/next/files/README.md +145 -11
- package/templates/next/files/app/globals.css +55 -4
- package/templates/next/files/check/run.mjs +3 -3
- package/templates/next/files/components/parts/fixture.jsx +1 -1
- package/templates/next/files/components/parts/sample.js +15 -0
- package/templates/next/files/components/ui/avatar.jsx +141 -0
- package/templates/next/files/components/ui/breadcrumb.jsx +149 -0
- package/templates/next/files/components/ui/button-group.jsx +70 -0
- package/templates/next/files/components/ui/button.jsx +132 -12
- package/templates/next/files/components/ui/calendar.jsx +609 -0
- package/templates/next/files/components/ui/carousel.jsx +281 -0
- package/templates/next/files/components/ui/collapsible.jsx +208 -0
- package/templates/next/files/components/ui/combobox.jsx +608 -0
- package/templates/next/files/components/ui/command.jsx +577 -0
- package/templates/next/files/components/ui/context-menu.jsx +191 -0
- package/templates/next/files/components/ui/date-picker.jsx +360 -0
- package/templates/next/files/components/ui/distribution.jsx +117 -0
- package/templates/next/files/components/ui/feedback.jsx +143 -0
- package/templates/next/files/components/ui/field.jsx +115 -3
- package/templates/next/files/components/ui/file-input.jsx +234 -0
- package/templates/next/files/components/ui/icon.jsx +130 -8
- package/templates/next/files/components/ui/image.jsx +143 -0
- package/templates/next/files/components/ui/index.js +47 -2
- package/templates/next/files/components/ui/input-group.jsx +213 -0
- package/templates/next/files/components/ui/input-otp.jsx +170 -0
- package/templates/next/files/components/ui/item.jsx +206 -0
- package/templates/next/files/components/ui/menu.jsx +454 -82
- package/templates/next/files/components/ui/notice.jsx +126 -14
- package/templates/next/files/components/ui/pagination.jsx +156 -0
- package/templates/next/files/components/ui/popover.jsx +284 -0
- package/templates/next/files/components/ui/radio.jsx +193 -0
- package/templates/next/files/components/ui/rating.jsx +131 -0
- package/templates/next/files/components/ui/resizable.jsx +338 -0
- package/templates/next/files/components/ui/scroll-area.jsx +123 -0
- package/templates/next/files/components/ui/separator.jsx +119 -0
- package/templates/next/files/components/ui/sheet.jsx +96 -11
- package/templates/next/files/components/ui/slider.jsx +174 -0
- package/templates/next/files/components/ui/stat.jsx +574 -0
- package/templates/next/files/components/ui/steps.jsx +338 -0
- package/templates/next/files/components/ui/swatch.jsx +33 -0
- package/templates/next/files/components/ui/table.jsx +130 -0
- package/templates/next/files/components/ui/toast.jsx +440 -0
- package/templates/next/files/components/ui/toggle.jsx +195 -0
- package/templates/next/files/components/ui/tooltip.jsx +270 -0
- package/templates/next/files/lib/sample.js +4 -12
- package/templates/next/template.json +264 -8
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// SettingsList in each of its shapes — the gallery's and the smoke test's
|
|
4
|
+
// surface. Not installed into apps. Saves are pretend: pick whether they
|
|
5
|
+
// succeed or fail, and watch the row that changed.
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
import { Button, Field, InputGroup, Notice, Select, toast } from "../components/ui";
|
|
8
|
+
import { SettingsList } from "../components/blocks/settings-list";
|
|
9
|
+
|
|
10
|
+
const wait = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
11
|
+
|
|
12
|
+
const PREFERENCES = [
|
|
13
|
+
{ key: "digest", icon: "mail", label: "Weekly digest", description: "A summary of the week's numbers, every Monday at 8:00.", control: { type: "switch", value: true } },
|
|
14
|
+
{ key: "sounds", icon: "bell", label: "Sounds", description: "Play a sound when a message arrives.", control: { type: "switch", value: false } },
|
|
15
|
+
{
|
|
16
|
+
key: "theme",
|
|
17
|
+
icon: "palette",
|
|
18
|
+
label: "Appearance",
|
|
19
|
+
description: "How the app looks on this device.",
|
|
20
|
+
control: {
|
|
21
|
+
type: "select",
|
|
22
|
+
value: "system",
|
|
23
|
+
options: [
|
|
24
|
+
{ value: "system", label: "Match the system" },
|
|
25
|
+
{ value: "light", label: "Light" },
|
|
26
|
+
{ value: "dark", label: "Dark" },
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
key: "week",
|
|
32
|
+
icon: "calendar",
|
|
33
|
+
label: "Week starts on",
|
|
34
|
+
control: {
|
|
35
|
+
type: "select",
|
|
36
|
+
value: "mon",
|
|
37
|
+
options: [
|
|
38
|
+
{ value: "mon", label: "Monday" },
|
|
39
|
+
{ value: "sun", label: "Sunday" },
|
|
40
|
+
{ value: "sat", label: "Saturday" },
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{ key: "export", icon: "download", label: "Export your data", description: "Everything you own, as a zip of CSV files.", control: { type: "button", label: "Export", icon: "download" } },
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
const METHODS = [
|
|
48
|
+
{
|
|
49
|
+
key: "keys",
|
|
50
|
+
icon: "key",
|
|
51
|
+
label: "Security keys",
|
|
52
|
+
badge: { label: "Recommended", tone: "success" },
|
|
53
|
+
description: "A hardware key you touch to sign in. The strongest option.",
|
|
54
|
+
value: "No keys added",
|
|
55
|
+
control: { type: "button", label: "Add", variant: "primary" },
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
key: "app",
|
|
59
|
+
icon: "smartphone",
|
|
60
|
+
label: "Authenticator app",
|
|
61
|
+
badge: { label: "Recommended", tone: "success" },
|
|
62
|
+
description: "Six-digit codes from an app on your phone.",
|
|
63
|
+
value: "Not set up",
|
|
64
|
+
control: { type: "button", label: "Set up", variant: "primary" },
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
key: "sms",
|
|
68
|
+
icon: "message-square",
|
|
69
|
+
label: "Text message",
|
|
70
|
+
description: "Codes sent to your phone by SMS.",
|
|
71
|
+
value: "+44 7700 900 461",
|
|
72
|
+
valueTone: "set",
|
|
73
|
+
control: { type: "button", label: "Edit" },
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
const SESSIONS = [
|
|
78
|
+
{ key: "s1", icon: "laptop", label: "MacBook Pro", badge: { label: "This device", tone: "info" }, meta: [{ icon: "globe", text: "Lisbon, Portugal" }, { icon: "clock", text: "Active now" }, "Safari 18 on macOS 15"] },
|
|
79
|
+
{
|
|
80
|
+
key: "s2",
|
|
81
|
+
icon: "smartphone",
|
|
82
|
+
label: "iPhone 15",
|
|
83
|
+
meta: [{ icon: "globe", text: "Porto, Portugal" }, { icon: "clock", text: "Yesterday, 18:40" }, "Makersclaw for iOS"],
|
|
84
|
+
control: { type: "remove", label: "Sign out iPhone 15", confirm: { title: "Sign out this iPhone?", body: "It will need your password to come back.", confirmLabel: "Sign out" } },
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
key: "s3",
|
|
88
|
+
icon: "monitor",
|
|
89
|
+
label: "Windows desktop",
|
|
90
|
+
meta: [{ icon: "globe", text: "Madrid, Spain" }, { icon: "clock", text: "3 days ago" }, "Firefox 131 on Windows 11"],
|
|
91
|
+
control: { type: "remove", label: "Sign out Windows desktop", confirm: { title: "Sign out this desktop?", body: "It will need your password to come back.", confirmLabel: "Sign out" } },
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
const INTEGRATIONS = [
|
|
96
|
+
{ key: "github", icon: "github", label: "GitHub", badge: { label: "Development", hue: 1 }, description: "Link commits and pull requests to tasks.", control: { type: "switch", value: false } },
|
|
97
|
+
{
|
|
98
|
+
key: "slack",
|
|
99
|
+
icon: "message-square",
|
|
100
|
+
label: "Slack",
|
|
101
|
+
badge: { label: "Messaging", hue: 2 },
|
|
102
|
+
description: "Post a note to a channel when a deal moves.",
|
|
103
|
+
control: { type: "switch", value: true },
|
|
104
|
+
connected: { account: "ops@quillhouse.com", code: "QH-4417-208" },
|
|
105
|
+
},
|
|
106
|
+
{ key: "google", icon: "google", label: "Google Calendar", badge: { label: "Calendar", hue: 3 }, description: "Put booked calls on your calendar.", control: { type: "switch", value: false } },
|
|
107
|
+
];
|
|
108
|
+
|
|
109
|
+
const BILLING = [
|
|
110
|
+
{
|
|
111
|
+
key: "b1",
|
|
112
|
+
icon: "building",
|
|
113
|
+
label: "Harbourline Ltd",
|
|
114
|
+
description: "Main account",
|
|
115
|
+
meta: ["Contact: Tomas Kowalski", "tomas@harbourline.co", "VAT GB 204 1187 63"],
|
|
116
|
+
control: { type: "actions", items: [{ key: "edit", label: "Edit", icon: "pencil" }, { key: "delete", label: "Delete", icon: "trash", tone: "danger", confirm: { title: "Delete this billing profile?", body: "Invoices already sent keep it.", confirmLabel: "Delete" } }] },
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
key: "b2",
|
|
120
|
+
icon: "building",
|
|
121
|
+
label: "Harbourline GmbH",
|
|
122
|
+
description: "Germany",
|
|
123
|
+
meta: ["Contact: Lena Vogt", "lena@harbourline.de", "VAT DE 318 552 904"],
|
|
124
|
+
control: { type: "actions", items: [{ key: "edit", label: "Edit", icon: "pencil" }, { key: "delete", label: "Delete", icon: "trash", tone: "danger", confirm: { title: "Delete this billing profile?", body: "Invoices already sent keep it.", confirmLabel: "Delete" } }] },
|
|
125
|
+
},
|
|
126
|
+
];
|
|
127
|
+
|
|
128
|
+
const CHANNELS = [
|
|
129
|
+
{ key: "email", label: "Email", icon: "mail" },
|
|
130
|
+
{ key: "push", label: "Push", icon: "smartphone" },
|
|
131
|
+
{ key: "sms", label: "SMS", icon: "message-square" },
|
|
132
|
+
];
|
|
133
|
+
|
|
134
|
+
const EVENTS = [
|
|
135
|
+
{ key: "mentions", group: "Conversations", label: "Mentions", description: "Someone mentions you in a comment.", values: { email: true, push: true, sms: false } },
|
|
136
|
+
{ key: "replies", group: "Conversations", label: "Replies", description: "Someone answers a thread you are in.", values: { email: true, push: false, sms: false } },
|
|
137
|
+
{ key: "signin", group: "Security", label: "New sign-in", description: "Your account is used on a new device.", values: { email: true, push: true, sms: true }, locked: ["email"] },
|
|
138
|
+
{ key: "password", group: "Security", label: "Password changed", description: "Sent the moment it happens.", values: { email: true, push: true, sms: false }, locked: ["email"] },
|
|
139
|
+
{ key: "product", group: "Product", label: "What's new", description: "New features, once a month.", values: { email: false, push: false, sms: null } },
|
|
140
|
+
];
|
|
141
|
+
|
|
142
|
+
const VARIANTS = {
|
|
143
|
+
preferences: { label: "Preferences" },
|
|
144
|
+
methods: { label: "Two-step sign-in" },
|
|
145
|
+
sessions: { label: "Signed-in devices" },
|
|
146
|
+
integrations: { label: "Integrations" },
|
|
147
|
+
details: { label: "Billing profiles" },
|
|
148
|
+
matrix: { label: "Notifications" },
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/** Rows in memory with a pretend save that honours the chosen outcome. */
|
|
152
|
+
function useRows(initial, outcome) {
|
|
153
|
+
const [rows, setRows] = useState(initial);
|
|
154
|
+
async function save(fn) {
|
|
155
|
+
await wait(800);
|
|
156
|
+
if (outcome === "fail") return { ok: false, error: "The server did not answer." };
|
|
157
|
+
fn?.();
|
|
158
|
+
return { ok: true };
|
|
159
|
+
}
|
|
160
|
+
return { rows, setRows, save };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function setControl(rows, key, value) {
|
|
164
|
+
return rows.map((r) => (r.key === key ? { ...r, control: { ...r.control, value } } : r));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export default function SettingsListDemo() {
|
|
168
|
+
const [variant, setVariant] = useState("preferences");
|
|
169
|
+
const [outcome, setOutcome] = useState("ok");
|
|
170
|
+
const [state, setState] = useState("ready");
|
|
171
|
+
|
|
172
|
+
const prefs = useRows(PREFERENCES, outcome);
|
|
173
|
+
const methods = useRows(METHODS, outcome);
|
|
174
|
+
const sessions = useRows(SESSIONS, outcome);
|
|
175
|
+
const integrations = useRows(INTEGRATIONS, outcome);
|
|
176
|
+
const billing = useRows(BILLING, outcome);
|
|
177
|
+
const events = useRows(EVENTS, outcome);
|
|
178
|
+
|
|
179
|
+
const common = {
|
|
180
|
+
loading: state === "loading",
|
|
181
|
+
error: state === "error" ? "The settings service is not answering." : undefined,
|
|
182
|
+
onRetry: () => setState("ready"),
|
|
183
|
+
};
|
|
184
|
+
const pick = (rows) => (state === "empty" ? [] : rows);
|
|
185
|
+
|
|
186
|
+
let list;
|
|
187
|
+
if (variant === "preferences") {
|
|
188
|
+
list = (
|
|
189
|
+
<SettingsList
|
|
190
|
+
{...common}
|
|
191
|
+
title="Preferences"
|
|
192
|
+
description="Saved as you change them."
|
|
193
|
+
rows={pick(prefs.rows)}
|
|
194
|
+
onChange={(row, value) => prefs.save(() => prefs.setRows((rs) => setControl(rs, row.key, value)))}
|
|
195
|
+
onAction={() => prefs.save(() => toast("Your export is on its way by email."))}
|
|
196
|
+
/>
|
|
197
|
+
);
|
|
198
|
+
} else if (variant === "methods") {
|
|
199
|
+
list = (
|
|
200
|
+
<SettingsList
|
|
201
|
+
{...common}
|
|
202
|
+
icon="shield"
|
|
203
|
+
title="Two-step sign-in"
|
|
204
|
+
description="A second step after your password, so a leaked password is not enough."
|
|
205
|
+
badge={{ label: "On", tone: "success", icon: "circle-check" }}
|
|
206
|
+
rows={pick(methods.rows)}
|
|
207
|
+
onAction={(row) => methods.save(() => toast(`${row.label}: the setup would open here.`))}
|
|
208
|
+
footer={<Notice tone="info">Keep at least two methods, so losing a phone never locks you out.</Notice>}
|
|
209
|
+
/>
|
|
210
|
+
);
|
|
211
|
+
} else if (variant === "sessions") {
|
|
212
|
+
list = (
|
|
213
|
+
<SettingsList
|
|
214
|
+
{...common}
|
|
215
|
+
icon="shield-check"
|
|
216
|
+
title="Signed-in devices"
|
|
217
|
+
description="Where your account is open now. Sign out anything you do not recognise."
|
|
218
|
+
rows={pick(sessions.rows)}
|
|
219
|
+
onAction={(row) => sessions.save(() => sessions.setRows((rs) => rs.filter((r) => r.key !== row.key)))}
|
|
220
|
+
emptyTitle="No other devices"
|
|
221
|
+
footer={<Notice tone="warning" title="Something you don't recognise?">Sign it out, then change your password.</Notice>}
|
|
222
|
+
/>
|
|
223
|
+
);
|
|
224
|
+
} else if (variant === "integrations") {
|
|
225
|
+
list = (
|
|
226
|
+
<SettingsList
|
|
227
|
+
{...common}
|
|
228
|
+
icon="layers"
|
|
229
|
+
title="Integrations"
|
|
230
|
+
description="Tools this workspace talks to."
|
|
231
|
+
rows={pick(integrations.rows).map((r) => ({
|
|
232
|
+
...r,
|
|
233
|
+
details: r.control.value
|
|
234
|
+
? () => (
|
|
235
|
+
<div className="grid gap-3">
|
|
236
|
+
<p>
|
|
237
|
+
Connected as <span className="font-medium">{r.connected?.account ?? "ops@quillhouse.com"}</span>
|
|
238
|
+
</p>
|
|
239
|
+
<Field id={`code-${r.key}`} label="Verification code" hint="Paste it in the other tool to finish linking.">
|
|
240
|
+
<InputGroup
|
|
241
|
+
id={`code-${r.key}`}
|
|
242
|
+
readOnly
|
|
243
|
+
value={r.connected?.code ?? "QH-0000-000"}
|
|
244
|
+
action={{
|
|
245
|
+
label: "Copy",
|
|
246
|
+
icon: "copy",
|
|
247
|
+
onClick: () => {
|
|
248
|
+
navigator.clipboard?.writeText(r.connected?.code ?? "").catch(() => {});
|
|
249
|
+
toast("Copied");
|
|
250
|
+
},
|
|
251
|
+
}}
|
|
252
|
+
/>
|
|
253
|
+
</Field>
|
|
254
|
+
</div>
|
|
255
|
+
)
|
|
256
|
+
: undefined,
|
|
257
|
+
}))}
|
|
258
|
+
onChange={(row, value) => integrations.save(() => integrations.setRows((rs) => setControl(rs, row.key, value)))}
|
|
259
|
+
/>
|
|
260
|
+
);
|
|
261
|
+
} else if (variant === "details") {
|
|
262
|
+
list = (
|
|
263
|
+
<SettingsList
|
|
264
|
+
{...common}
|
|
265
|
+
title="Billing profiles"
|
|
266
|
+
description="Who invoices are addressed to."
|
|
267
|
+
actions={
|
|
268
|
+
<Button size="sm" icon="plus" onClick={() => toast("A billing form would open here.")}>
|
|
269
|
+
Add profile
|
|
270
|
+
</Button>
|
|
271
|
+
}
|
|
272
|
+
rows={pick(billing.rows)}
|
|
273
|
+
onAction={(row, action) =>
|
|
274
|
+
billing.save(() => {
|
|
275
|
+
if (action === "delete") billing.setRows((rs) => rs.filter((r) => r.key !== row.key));
|
|
276
|
+
else toast(`Editing ${row.label}`);
|
|
277
|
+
})
|
|
278
|
+
}
|
|
279
|
+
emptyTitle="No billing profiles"
|
|
280
|
+
emptyBody="Add one so invoices carry your company's details."
|
|
281
|
+
/>
|
|
282
|
+
);
|
|
283
|
+
} else {
|
|
284
|
+
list = (
|
|
285
|
+
<SettingsList
|
|
286
|
+
{...common}
|
|
287
|
+
variant="matrix"
|
|
288
|
+
title="Notifications"
|
|
289
|
+
description="Choose where each kind of news reaches you. Security emails always go out."
|
|
290
|
+
channels={CHANNELS}
|
|
291
|
+
rows={pick(events.rows)}
|
|
292
|
+
onChange={(row, value, channel) =>
|
|
293
|
+
events.save(() => events.setRows((rs) => rs.map((r) => (r.key === row.key ? { ...r, values: { ...r.values, [channel]: value } } : r))))
|
|
294
|
+
}
|
|
295
|
+
/>
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return (
|
|
300
|
+
<div className="grid max-w-3xl gap-4">
|
|
301
|
+
<div className="grid gap-3 sm:grid-cols-3">
|
|
302
|
+
<Field id="sl-variant" label="Shape">
|
|
303
|
+
<Select id="sl-variant" value={variant} onChange={(e) => setVariant(e.target.value)} options={Object.entries(VARIANTS).map(([value, v]) => ({ value, label: v.label }))} />
|
|
304
|
+
</Field>
|
|
305
|
+
<Field id="sl-outcome" label="Saving">
|
|
306
|
+
<Select
|
|
307
|
+
id="sl-outcome"
|
|
308
|
+
value={outcome}
|
|
309
|
+
onChange={(e) => setOutcome(e.target.value)}
|
|
310
|
+
options={[
|
|
311
|
+
{ value: "ok", label: "Succeeds" },
|
|
312
|
+
{ value: "fail", label: "Fails" },
|
|
313
|
+
]}
|
|
314
|
+
/>
|
|
315
|
+
</Field>
|
|
316
|
+
<Field id="sl-state" label="State">
|
|
317
|
+
<Select
|
|
318
|
+
id="sl-state"
|
|
319
|
+
value={state}
|
|
320
|
+
onChange={(e) => setState(e.target.value)}
|
|
321
|
+
options={[
|
|
322
|
+
{ value: "ready", label: "Loaded" },
|
|
323
|
+
{ value: "loading", label: "Loading" },
|
|
324
|
+
{ value: "error", label: "Load failed" },
|
|
325
|
+
{ value: "empty", label: "Empty" },
|
|
326
|
+
]}
|
|
327
|
+
/>
|
|
328
|
+
</Field>
|
|
329
|
+
</div>
|
|
330
|
+
{list}
|
|
331
|
+
</div>
|
|
332
|
+
);
|
|
333
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { Button, Icon, Spinner } from "../../ui";
|
|
5
|
+
|
|
6
|
+
// Each control in a SettingsList saves on its own. This keeps, per control
|
|
7
|
+
// (a row, or a row × channel in the matrix), what it shows while its save
|
|
8
|
+
// runs (the new value, at once), that it is saving, and why its last save
|
|
9
|
+
// failed — with the attempt kept so "Try again" repeats it.
|
|
10
|
+
|
|
11
|
+
/** Run `save()` → { ok } | { ok: false, error }; a throw counts as failed. */
|
|
12
|
+
async function attempt(save) {
|
|
13
|
+
try {
|
|
14
|
+
const res = await save();
|
|
15
|
+
return res?.ok ? { ok: true } : { ok: false, error: res?.error };
|
|
16
|
+
} catch (e) {
|
|
17
|
+
return { ok: false, error: e?.message };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function sameValue(a, b) {
|
|
22
|
+
return a === b || (a == null && b == null);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function useSaves(failedText = "Not saved.") {
|
|
26
|
+
const [shown, setShown] = useState({}); // key → { value, from }: the new value, over the stored `from`
|
|
27
|
+
const [busy, setBusy] = useState({}); // key → true
|
|
28
|
+
const [failed, setFailed] = useState({}); // key → { error, retry }
|
|
29
|
+
const alive = useRef(true);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
alive.current = true;
|
|
32
|
+
return () => {
|
|
33
|
+
alive.current = false;
|
|
34
|
+
};
|
|
35
|
+
}, []);
|
|
36
|
+
|
|
37
|
+
const drop = (setter, key) =>
|
|
38
|
+
setter((m) => {
|
|
39
|
+
if (!(key in m)) return m;
|
|
40
|
+
const { [key]: _gone, ...rest } = m;
|
|
41
|
+
return rest;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
/** Save `key`: show `value` (optional; `stored` is what the rows hold
|
|
45
|
+
* now) at once, run `save`, put the stored value back on failure.
|
|
46
|
+
* `fallback` words a failure that came back without an error. */
|
|
47
|
+
async function run(key, save, { value, stored, fallback } = {}) {
|
|
48
|
+
const retry = () => run(key, save, { value, stored, fallback });
|
|
49
|
+
if (value !== undefined) setShown((m) => ({ ...m, [key]: { value, from: stored } }));
|
|
50
|
+
setBusy((m) => ({ ...m, [key]: true }));
|
|
51
|
+
drop(setFailed, key);
|
|
52
|
+
const res = await attempt(save);
|
|
53
|
+
if (!alive.current) return res;
|
|
54
|
+
drop(setBusy, key);
|
|
55
|
+
// Good: the new value stays on screen until the rows catch up (see
|
|
56
|
+
// valueOf). Bad: the stored one returns.
|
|
57
|
+
if (!res.ok) {
|
|
58
|
+
drop(setShown, key);
|
|
59
|
+
setFailed((m) => ({ ...m, [key]: { error: res.error || fallback || failedText, retry } }));
|
|
60
|
+
}
|
|
61
|
+
return res;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
run,
|
|
66
|
+
// The new value while the rows still hold what they held before the
|
|
67
|
+
// save; once they change (the save landed, or anything else moved
|
|
68
|
+
// them) the rows are the truth again.
|
|
69
|
+
valueOf: (key, stored) => (key in shown && sameValue(shown[key].from, stored) ? shown[key].value : stored),
|
|
70
|
+
isBusy: (key) => Boolean(busy[key]),
|
|
71
|
+
failure: (key) => failed[key] ?? null,
|
|
72
|
+
dismiss: (key) => drop(setFailed, key),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** The line under a row whose save failed: why, and Try again. */
|
|
77
|
+
export function Failure({ failure, id, className }) {
|
|
78
|
+
if (!failure) return null;
|
|
79
|
+
return (
|
|
80
|
+
<p id={id} role="alert" className={className ?? "flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-destructive"}>
|
|
81
|
+
<Icon name="warning" size={14} className="shrink-0" />
|
|
82
|
+
<span className="min-w-0">{failure.error}</span>
|
|
83
|
+
<Button variant="link" size="sm" onClick={failure.retry}>
|
|
84
|
+
Try again
|
|
85
|
+
</Button>
|
|
86
|
+
</p>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** A small spinner that says what is happening. */
|
|
91
|
+
export function Saving({ label = "Saving" }) {
|
|
92
|
+
return <Spinner size="sm" label={label} className="text-muted-foreground" />;
|
|
93
|
+
}
|