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,627 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { Button, IconButton, Notice, Sheet, Skeleton, ToggleGroup, cx } from "../../ui";
|
|
5
|
+
import {
|
|
6
|
+
DEFAULT_VIEW,
|
|
7
|
+
LIFTED,
|
|
8
|
+
TaskChip,
|
|
9
|
+
TaskDragProvider,
|
|
10
|
+
ViewToolbar,
|
|
11
|
+
addDays,
|
|
12
|
+
applyView,
|
|
13
|
+
createTaskContext,
|
|
14
|
+
dayOf,
|
|
15
|
+
deleteChange,
|
|
16
|
+
draftTask,
|
|
17
|
+
formatDay,
|
|
18
|
+
isDone,
|
|
19
|
+
minutesOf,
|
|
20
|
+
startOfMonth,
|
|
21
|
+
useTaskChanges,
|
|
22
|
+
withTime,
|
|
23
|
+
} from "../task-model";
|
|
24
|
+
import {
|
|
25
|
+
CALENDAR_MODES,
|
|
26
|
+
DAY_MINUTES,
|
|
27
|
+
MODE_LABELS,
|
|
28
|
+
UNSCHEDULE,
|
|
29
|
+
allDayPatch,
|
|
30
|
+
closedOn,
|
|
31
|
+
dayPatch,
|
|
32
|
+
durationOf,
|
|
33
|
+
eventsOf,
|
|
34
|
+
extendPatch,
|
|
35
|
+
minutesLabel,
|
|
36
|
+
moveEventPatch,
|
|
37
|
+
normalizeSlots,
|
|
38
|
+
placeEventPatch,
|
|
39
|
+
rangeFor,
|
|
40
|
+
resizeEventPatch,
|
|
41
|
+
snapMinutes,
|
|
42
|
+
stepAnchor,
|
|
43
|
+
timedPatch,
|
|
44
|
+
titleFor,
|
|
45
|
+
unscheduledOf,
|
|
46
|
+
} from "./calendar-model";
|
|
47
|
+
import { AgendaView } from "./agenda";
|
|
48
|
+
import { MonthView } from "./month";
|
|
49
|
+
import { TimeGrid } from "./time-grid";
|
|
50
|
+
import { UnscheduledTray } from "./tray";
|
|
51
|
+
import { isTyping } from "./paint";
|
|
52
|
+
|
|
53
|
+
// CalendarView — tasks on a calendar: month, week, day and agenda. Drag an
|
|
54
|
+
// item to another day or hour, drag its end to change how long it runs,
|
|
55
|
+
// click (or drag across) an empty stretch to add one there, and drag
|
|
56
|
+
// tasks without a date in from the unscheduled tray. A line marks now.
|
|
57
|
+
// Search and filters come from task-model's ViewToolbar, so a task
|
|
58
|
+
// filtered out of the list is filtered out here too.
|
|
59
|
+
//
|
|
60
|
+
// Everything saves through one async `onChange(change)` answering { ok }
|
|
61
|
+
// (task-model's change shapes); the calendar shows each change at once
|
|
62
|
+
// and takes it back, with a notice, when the save fails.
|
|
63
|
+
//
|
|
64
|
+
// The available-time layer (closed hours muted, open slots as boxes you
|
|
65
|
+
// can pick) is what booking-page builds on: `availability`, `slots` or
|
|
66
|
+
// `getSlots`, `renderSlot`, `onSlotClick`. README.md lists every prop.
|
|
67
|
+
|
|
68
|
+
const useIsoLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
69
|
+
const clamp = (n, lo, hi) => Math.max(lo, Math.min(hi, n));
|
|
70
|
+
const UNIT = { month: "month", week: "week", day: "day", agenda: "stretch" };
|
|
71
|
+
const quote = (t) => `“${t?.title || "Untitled"}”`;
|
|
72
|
+
|
|
73
|
+
function useControlled(value, initial, onChange) {
|
|
74
|
+
const [own, setOwn] = useState(initial);
|
|
75
|
+
const controlled = value !== undefined;
|
|
76
|
+
const set = useCallback(
|
|
77
|
+
(next) => {
|
|
78
|
+
if (!controlled) setOwn(next);
|
|
79
|
+
onChange?.(next);
|
|
80
|
+
},
|
|
81
|
+
[controlled, onChange],
|
|
82
|
+
);
|
|
83
|
+
return [controlled ? value : own, set];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// The wall clock, a minute at a time — after mount only, so the server
|
|
87
|
+
// and the first client render agree. A fixed `now` wins (a demo).
|
|
88
|
+
function useNow(fixed) {
|
|
89
|
+
const [clock, setClock] = useState(null);
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (fixed) return undefined;
|
|
92
|
+
const tick = () => {
|
|
93
|
+
const d = new Date();
|
|
94
|
+
setClock(withTime(dayOf(d), d.getHours() * 60 + d.getMinutes()));
|
|
95
|
+
};
|
|
96
|
+
tick();
|
|
97
|
+
const t = setInterval(tick, 60000);
|
|
98
|
+
return () => clearInterval(t);
|
|
99
|
+
}, [fixed]);
|
|
100
|
+
return fixed ?? clock;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function CalendarView({
|
|
104
|
+
tasks,
|
|
105
|
+
statuses,
|
|
106
|
+
people,
|
|
107
|
+
projects,
|
|
108
|
+
fields,
|
|
109
|
+
today,
|
|
110
|
+
weekStartsOn,
|
|
111
|
+
weekend,
|
|
112
|
+
holidays,
|
|
113
|
+
now: nowProp,
|
|
114
|
+
locale,
|
|
115
|
+
onChange,
|
|
116
|
+
onOpen,
|
|
117
|
+
mode: modeProp,
|
|
118
|
+
defaultMode = "month",
|
|
119
|
+
onModeChange,
|
|
120
|
+
modes = CALENDAR_MODES,
|
|
121
|
+
date: dateProp,
|
|
122
|
+
defaultDate,
|
|
123
|
+
onDateChange,
|
|
124
|
+
view: viewProp,
|
|
125
|
+
defaultView,
|
|
126
|
+
onViewChange,
|
|
127
|
+
header = true,
|
|
128
|
+
toolbar = true,
|
|
129
|
+
toolbarExtra,
|
|
130
|
+
tray = true,
|
|
131
|
+
colorBy = "project",
|
|
132
|
+
availability,
|
|
133
|
+
slots,
|
|
134
|
+
getSlots,
|
|
135
|
+
renderSlot,
|
|
136
|
+
onSlotClick,
|
|
137
|
+
selectedSlot,
|
|
138
|
+
slotLabel = "Open",
|
|
139
|
+
hourHeight = 48,
|
|
140
|
+
height = "40rem",
|
|
141
|
+
snap = 15,
|
|
142
|
+
defaultDuration = 60,
|
|
143
|
+
agendaDays = 14,
|
|
144
|
+
addLabel = "Add task",
|
|
145
|
+
loading = false,
|
|
146
|
+
error: readError,
|
|
147
|
+
label = "Calendar",
|
|
148
|
+
className,
|
|
149
|
+
}) {
|
|
150
|
+
const ctx = useMemo(
|
|
151
|
+
() => createTaskContext({ statuses, people, projects, fields, today, weekStartsOn, weekend, holidays }),
|
|
152
|
+
[statuses, people, projects, fields, today, weekStartsOn, weekend, holidays],
|
|
153
|
+
);
|
|
154
|
+
const editable = typeof onChange === "function";
|
|
155
|
+
const { tasks: all, commit, error, clearError } = useTaskChanges(tasks, onChange);
|
|
156
|
+
const now = useNow(nowProp);
|
|
157
|
+
|
|
158
|
+
const [modeRaw, setModeRaw] = useControlled(modeProp, defaultMode, onModeChange);
|
|
159
|
+
const mode = modes.includes(modeRaw) ? modeRaw : modes[0] ?? "month";
|
|
160
|
+
const [anchorRaw, setAnchor] = useControlled(dateProp, dayOf(defaultDate) ?? ctx.today, onDateChange);
|
|
161
|
+
const anchor = dayOf(anchorRaw) ?? ctx.today;
|
|
162
|
+
const [viewRaw, setView] = useControlled(viewProp, { ...DEFAULT_VIEW, groupBy: "none", ...defaultView }, onViewChange);
|
|
163
|
+
const view = useMemo(() => ({ ...DEFAULT_VIEW, groupBy: "none", ...viewRaw }), [viewRaw]);
|
|
164
|
+
|
|
165
|
+
// How wide we are, not the window: a calendar in a side panel is narrow.
|
|
166
|
+
const rootRef = useRef(null);
|
|
167
|
+
const [width, setWidth] = useState(null);
|
|
168
|
+
useIsoLayoutEffect(() => {
|
|
169
|
+
const el = rootRef.current;
|
|
170
|
+
if (!el) return undefined;
|
|
171
|
+
setWidth(el.getBoundingClientRect().width);
|
|
172
|
+
if (typeof ResizeObserver === "undefined") return undefined;
|
|
173
|
+
const ro = new ResizeObserver(([entry]) => setWidth(entry.contentRect.width));
|
|
174
|
+
ro.observe(el);
|
|
175
|
+
return () => ro.disconnect();
|
|
176
|
+
}, []);
|
|
177
|
+
const narrow = width !== null && width < 640;
|
|
178
|
+
const sidePanel = width === null || width >= 960;
|
|
179
|
+
const count = mode === "week" && narrow ? 3 : 7;
|
|
180
|
+
|
|
181
|
+
const range = useMemo(() => rangeFor(mode, anchor, { weekStartsOn: ctx.weekStartsOn, count, agendaDays }), [mode, anchor, ctx.weekStartsOn, count, agendaDays]);
|
|
182
|
+
const shown = useMemo(() => applyView(all, view, ctx).tasks, [all, view, ctx]);
|
|
183
|
+
const events = useMemo(() => eventsOf(shown, { defaultMinutes: defaultDuration }), [shown, defaultDuration]);
|
|
184
|
+
const unscheduled = useMemo(() => unscheduledOf(shown).filter((t) => !isDone(t, ctx)), [shown, ctx]);
|
|
185
|
+
|
|
186
|
+
const [announce, setAnnounce] = useState("");
|
|
187
|
+
const say = (text) => setAnnounce(text);
|
|
188
|
+
const [draft, setDraft] = useState(null); // { day, allDay } | { day, from, to }
|
|
189
|
+
const [selected, setSelected] = useState(null); // a phone's month: the tapped day
|
|
190
|
+
const [trayOpen, setTrayOpen] = useState(true);
|
|
191
|
+
const [traySheet, setTraySheet] = useState(false);
|
|
192
|
+
useEffect(() => setDraft(null), [mode, anchor]);
|
|
193
|
+
|
|
194
|
+
// ---- saving ----------------------------------------------------------
|
|
195
|
+
|
|
196
|
+
function update(task, patch, words) {
|
|
197
|
+
if (!patch) return Promise.resolve({ ok: false });
|
|
198
|
+
return commit({ type: "update", id: task.id, patch }, { label: quote(task) }).then((r) => {
|
|
199
|
+
if (r.ok !== false && words) say(words);
|
|
200
|
+
return r;
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function remove(task) {
|
|
205
|
+
return commit(deleteChange(all, [task.id]), { label: quote(task), undo: `Deleted ${quote(task)}` });
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function saveDraft(title) {
|
|
209
|
+
const d = draft;
|
|
210
|
+
setDraft(null);
|
|
211
|
+
if (!d || !editable) return undefined;
|
|
212
|
+
const patch = d.allDay ? { due: d.day } : { start: withTime(d.day, d.from), due: withTime(d.day, d.to) };
|
|
213
|
+
const task = draftTask(title, ctx, patch);
|
|
214
|
+
return commit({ type: "create", task }, { label: quote(task) }).then((r) => {
|
|
215
|
+
if (r.ok !== false) say(`Added ${quote(task)} on ${formatDay(d.day, ctx.today, { locale })}${d.allDay ? "" : `, ${minutesLabel(d.from, { locale })}`}`);
|
|
216
|
+
return r;
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function extend(event, dir) {
|
|
221
|
+
const end = addDays(event.end, dir);
|
|
222
|
+
if (end < event.start) return;
|
|
223
|
+
update(event.task, extendPatch(event, end), `${quote(event.task)} now ends ${formatDay(end, ctx.today, { locale })}`);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Arrow keys on a timed block: previewed at once, saved when the keys
|
|
227
|
+
// rest, so ten presses are one save.
|
|
228
|
+
const [nudge, setNudge] = useState(null);
|
|
229
|
+
const nudgeRef = useRef(null);
|
|
230
|
+
const nudgeTimer = useRef(null);
|
|
231
|
+
const focusRef = useRef(null);
|
|
232
|
+
useEffect(() => () => clearTimeout(nudgeTimer.current), []);
|
|
233
|
+
|
|
234
|
+
function flushNudge() {
|
|
235
|
+
clearTimeout(nudgeTimer.current);
|
|
236
|
+
const n = nudgeRef.current;
|
|
237
|
+
nudgeRef.current = null;
|
|
238
|
+
setNudge(null);
|
|
239
|
+
if (!n || (!n.dm && !n.dd && !n.dr)) return;
|
|
240
|
+
const e = n.event;
|
|
241
|
+
const len = Math.max(15, e.to - e.from + n.dr);
|
|
242
|
+
const from = clamp(e.from + n.dm, 0, DAY_MINUTES - len);
|
|
243
|
+
const day = addDays(e.start, n.dd);
|
|
244
|
+
update(e.task, placeEventPatch(e, day, from, from + len), `${quote(e.task)} is now ${formatDay(day, ctx.today, { locale })}, ${minutesLabel(from, { locale })} to ${minutesLabel(from + len, { locale })}`);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function nudgeBy(event, { dm = 0, dd = 0, dr = 0 }) {
|
|
248
|
+
if (nudgeRef.current && nudgeRef.current.id !== event.id) flushNudge();
|
|
249
|
+
focusRef.current = event.id;
|
|
250
|
+
const cur = nudgeRef.current ?? { id: event.id, event, dm: 0, dd: 0, dr: 0 };
|
|
251
|
+
const next = { ...cur, dm: cur.dm + dm, dd: cur.dd + dd, dr: cur.dr + dr };
|
|
252
|
+
nudgeRef.current = next;
|
|
253
|
+
setNudge(next);
|
|
254
|
+
clearTimeout(nudgeTimer.current);
|
|
255
|
+
nudgeTimer.current = setTimeout(flushNudge, 700);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const shownEvents = useMemo(() => {
|
|
259
|
+
if (!nudge) return events;
|
|
260
|
+
return events.map((e) => {
|
|
261
|
+
if (e.id !== nudge.id || !e.timed) return e;
|
|
262
|
+
const day = addDays(e.start, nudge.dd);
|
|
263
|
+
const len = Math.max(15, e.to - e.from + nudge.dr);
|
|
264
|
+
const from = clamp(e.from + nudge.dm, 0, DAY_MINUTES - len);
|
|
265
|
+
return { ...e, start: day, end: day, from, to: from + len, preview: true };
|
|
266
|
+
});
|
|
267
|
+
}, [events, nudge]);
|
|
268
|
+
|
|
269
|
+
// A block moved by keys to another column is a new element: keep focus.
|
|
270
|
+
useEffect(() => {
|
|
271
|
+
if (!focusRef.current || !rootRef.current) return;
|
|
272
|
+
const el = rootRef.current.querySelector(`[data-cal-id="${CSS.escape(focusRef.current)}"]`);
|
|
273
|
+
if (!el) return;
|
|
274
|
+
if (document.activeElement !== el) el.focus({ preventScroll: false });
|
|
275
|
+
if (!nudgeRef.current) focusRef.current = null;
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
// ---- navigation --------------------------------------------------------
|
|
279
|
+
|
|
280
|
+
function setMode(next) {
|
|
281
|
+
setModeRaw(next);
|
|
282
|
+
setDraft(null);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function go(dir) {
|
|
286
|
+
const next = stepAnchor(mode, anchor, dir, { count, agendaDays });
|
|
287
|
+
setAnchor(next);
|
|
288
|
+
if (mode === "month") setSelected(next.slice(0, 7) === ctx.today.slice(0, 7) ? ctx.today : startOfMonth(next));
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function goToday() {
|
|
292
|
+
setAnchor(ctx.today);
|
|
293
|
+
setSelected(ctx.today);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function openDay(day) {
|
|
297
|
+
if (modes.includes("day")) {
|
|
298
|
+
setAnchor(day);
|
|
299
|
+
setModeRaw("day");
|
|
300
|
+
} else setAnchor(day);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function addNew() {
|
|
304
|
+
if (!editable) return;
|
|
305
|
+
const inView = mode === "month" ? ctx.today.slice(0, 7) === anchor.slice(0, 7) : range.days.includes(ctx.today);
|
|
306
|
+
const day = inView ? ctx.today : mode === "month" ? startOfMonth(anchor) : range.days[0];
|
|
307
|
+
if (mode === "week" || mode === "day") {
|
|
308
|
+
const nowMin = dayOf(now) === day ? minutesOf(now) : null;
|
|
309
|
+
const from = nowMin !== null ? Math.min(Math.ceil(nowMin / 60) * 60, DAY_MINUTES - defaultDuration) : 9 * 60;
|
|
310
|
+
setDraft({ day, from, to: from + defaultDuration });
|
|
311
|
+
} else {
|
|
312
|
+
setDraft({ day, allDay: true });
|
|
313
|
+
if (narrow) setSelected(day);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function onKeyDown(e) {
|
|
318
|
+
if (e.defaultPrevented || isTyping(e) || e.metaKey || e.ctrlKey || e.altKey) return;
|
|
319
|
+
if (e.target.closest?.("[popover], dialog")) return;
|
|
320
|
+
const k = e.key.toLowerCase();
|
|
321
|
+
const byKey = { m: "month", w: "week", d: "day", a: "agenda" };
|
|
322
|
+
if (k === "t") goToday();
|
|
323
|
+
else if (k === "j" || k === "n") go(1);
|
|
324
|
+
else if (k === "k" || k === "p") go(-1);
|
|
325
|
+
else if (k === "c" && editable) addNew();
|
|
326
|
+
else if (byKey[k] && modes.includes(byKey[k])) setMode(byKey[k]);
|
|
327
|
+
else return;
|
|
328
|
+
e.preventDefault();
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// ---- dragging ------------------------------------------------------------
|
|
332
|
+
|
|
333
|
+
const ppm = hourHeight / 60;
|
|
334
|
+
const pointer = useRef(null); // where the last press started
|
|
335
|
+
const lastMove = useRef(null); // where the pointer is during a drag
|
|
336
|
+
const grab = useRef(null); // the day of a span that was grabbed
|
|
337
|
+
const [dragging, setDragging] = useState(false);
|
|
338
|
+
useEffect(() => {
|
|
339
|
+
if (!dragging) return undefined;
|
|
340
|
+
const move = (e) => {
|
|
341
|
+
lastMove.current = { x: e.clientX, y: e.clientY };
|
|
342
|
+
};
|
|
343
|
+
window.addEventListener("pointermove", move, { passive: true });
|
|
344
|
+
return () => window.removeEventListener("pointermove", move);
|
|
345
|
+
}, [dragging]);
|
|
346
|
+
|
|
347
|
+
function pointerMinute(over, delta) {
|
|
348
|
+
const p = lastMove.current ?? (pointer.current ? { y: pointer.current.y + delta.y } : null);
|
|
349
|
+
if (!p || typeof over.top !== "function") return 9 * 60;
|
|
350
|
+
return clamp(Math.floor((p.y - over.top()) / ppm / 15) * 15, 0, DAY_MINUTES - 15);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function onDragEnd({ active, over, delta }) {
|
|
354
|
+
setDragging(false);
|
|
355
|
+
const a = active?.data ?? {};
|
|
356
|
+
const o = over?.data ?? null;
|
|
357
|
+
const task = a.task;
|
|
358
|
+
const grabbed = grab.current;
|
|
359
|
+
grab.current = null;
|
|
360
|
+
if (!task) return;
|
|
361
|
+
const name = quote(task);
|
|
362
|
+
const on = (day) => formatDay(day, ctx.today, { locale });
|
|
363
|
+
if (a.kind === "resize-y") {
|
|
364
|
+
const dm = snapMinutes(delta.y / ppm, snap);
|
|
365
|
+
if (!dm) return;
|
|
366
|
+
const to = clamp(a.event.to + dm, a.event.from + 15, DAY_MINUTES);
|
|
367
|
+
update(task, resizeEventPatch(a.event, to), `${name} now ends at ${minutesLabel(to, { locale })}`);
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
if (a.kind === "resize-x") {
|
|
371
|
+
const dd = Math.round(delta.x / a.cellWidth());
|
|
372
|
+
if (!dd) return;
|
|
373
|
+
const end = addDays(a.event.end, dd) < a.event.start ? a.event.start : addDays(a.event.end, dd);
|
|
374
|
+
update(task, extendPatch(a.event, end), `${name} now ends ${on(end)}`);
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
if (o?.kind === "tray") {
|
|
378
|
+
if (a.kind !== "tray") update(task, UNSCHEDULE, `${name} has no date now`);
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
if (a.kind === "timed") {
|
|
382
|
+
if (o?.kind === "cell") {
|
|
383
|
+
update(task, allDayPatch(o.day), `${name} is all day on ${on(o.day)}`);
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
const days = range.days;
|
|
387
|
+
const k = clamp(Math.round(delta.x / a.colWidth()), -a.colIndex, days.length - 1 - a.colIndex);
|
|
388
|
+
const dm = snapMinutes(delta.y / ppm, snap);
|
|
389
|
+
if (!k && !dm) return;
|
|
390
|
+
const day = days[a.colIndex + k];
|
|
391
|
+
const from = clamp(a.event.from + dm, 0, DAY_MINUTES - (a.event.to - a.event.from));
|
|
392
|
+
update(task, moveEventPatch(a.event, day, from), `${name} is now ${on(day)}, ${minutesLabel(from, { locale })}`);
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
if (!o) return;
|
|
396
|
+
if (o.kind === "column") {
|
|
397
|
+
const from = pointerMinute(o, delta);
|
|
398
|
+
const len = a.kind === "tray" ? durationOf(task, defaultDuration) : defaultDuration;
|
|
399
|
+
update(task, timedPatch(o.day, from, len), `${name} is now ${on(o.day)}, ${minutesLabel(from, { locale })}`);
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
if (o.kind === "cell") {
|
|
403
|
+
const patch = a.kind === "tray" ? { due: o.day } : dayPatch(task, o.day, { grabbed });
|
|
404
|
+
if (patch) update(task, patch, `${name} is now on ${on(o.day)}`);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// ---- the available-time layer -------------------------------------------
|
|
409
|
+
|
|
410
|
+
const slotKey = `${range.from}:${range.to}`;
|
|
411
|
+
const [fetched, setFetched] = useState({ key: null, slots: [] });
|
|
412
|
+
const timeMode = mode === "week" || mode === "day";
|
|
413
|
+
useEffect(() => {
|
|
414
|
+
if (!getSlots || !timeMode) return undefined;
|
|
415
|
+
let alive = true;
|
|
416
|
+
Promise.resolve()
|
|
417
|
+
.then(() => getSlots({ from: range.from, to: range.to }))
|
|
418
|
+
.then(
|
|
419
|
+
(r) => alive && setFetched({ key: slotKey, slots: normalizeSlots(r) }),
|
|
420
|
+
() => alive && setFetched({ key: slotKey, slots: [] }),
|
|
421
|
+
);
|
|
422
|
+
return () => {
|
|
423
|
+
alive = false;
|
|
424
|
+
};
|
|
425
|
+
// range.from / range.to are in slotKey
|
|
426
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
427
|
+
}, [getSlots, slotKey, timeMode]);
|
|
428
|
+
const gridSlots = useMemo(() => [...normalizeSlots(slots), ...(fetched.key === slotKey ? fetched.slots : [])], [slots, fetched, slotKey]);
|
|
429
|
+
const closed = useMemo(() => (availability ? (day) => closedOn(day, availability) : null), [availability]);
|
|
430
|
+
|
|
431
|
+
const api = {
|
|
432
|
+
ctx,
|
|
433
|
+
editable,
|
|
434
|
+
locale,
|
|
435
|
+
colorBy,
|
|
436
|
+
addLabel,
|
|
437
|
+
snap,
|
|
438
|
+
defaultDuration,
|
|
439
|
+
open: onOpen ?? null,
|
|
440
|
+
openDay,
|
|
441
|
+
draft,
|
|
442
|
+
startDraft: (d) => editable && setDraft(d),
|
|
443
|
+
cancelDraft: () => setDraft(null),
|
|
444
|
+
saveDraft,
|
|
445
|
+
commit,
|
|
446
|
+
update,
|
|
447
|
+
remove,
|
|
448
|
+
extend,
|
|
449
|
+
nudge: nudgeBy,
|
|
450
|
+
setGrab: (day) => {
|
|
451
|
+
grab.current = day;
|
|
452
|
+
},
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
// ---- drawing -----------------------------------------------------------------
|
|
456
|
+
|
|
457
|
+
const title = titleFor(mode, range, anchor, { today: ctx.today, locale });
|
|
458
|
+
const trayShown = tray && (sidePanel ? trayOpen : traySheet);
|
|
459
|
+
const empty = editable && !loading && all.length === 0;
|
|
460
|
+
|
|
461
|
+
let body;
|
|
462
|
+
if (loading) body = <CalendarSkeleton />;
|
|
463
|
+
else if (mode === "month")
|
|
464
|
+
body = <MonthView weeks={range.weeks} month={anchor.slice(0, 7)} events={shownEvents} api={api} narrow={narrow} selected={selected} onSelect={setSelected} />;
|
|
465
|
+
else if (mode === "agenda") body = <AgendaView days={range.days} events={shownEvents} api={api} />;
|
|
466
|
+
else
|
|
467
|
+
body = (
|
|
468
|
+
<TimeGrid
|
|
469
|
+
days={range.days}
|
|
470
|
+
events={shownEvents}
|
|
471
|
+
api={api}
|
|
472
|
+
hourHeight={hourHeight}
|
|
473
|
+
height={height}
|
|
474
|
+
closed={closed}
|
|
475
|
+
slots={gridSlots}
|
|
476
|
+
renderSlot={renderSlot}
|
|
477
|
+
onSlotClick={onSlotClick}
|
|
478
|
+
selectedSlot={selectedSlot}
|
|
479
|
+
slotLabel={slotLabel}
|
|
480
|
+
now={now}
|
|
481
|
+
/>
|
|
482
|
+
);
|
|
483
|
+
|
|
484
|
+
return (
|
|
485
|
+
<section
|
|
486
|
+
ref={rootRef}
|
|
487
|
+
aria-label={label}
|
|
488
|
+
className={cx("grid min-w-0 gap-3", className)}
|
|
489
|
+
onKeyDown={onKeyDown}
|
|
490
|
+
onPointerDownCapture={(e) => {
|
|
491
|
+
pointer.current = { x: e.clientX, y: e.clientY };
|
|
492
|
+
focusRef.current = null;
|
|
493
|
+
}}
|
|
494
|
+
onKeyDownCapture={(e) => {
|
|
495
|
+
if (e.key === " " || e.key === "Enter") {
|
|
496
|
+
pointer.current = null;
|
|
497
|
+
grab.current = null;
|
|
498
|
+
}
|
|
499
|
+
}}
|
|
500
|
+
>
|
|
501
|
+
{header ? (
|
|
502
|
+
<div className="flex flex-wrap items-center gap-x-3 gap-y-2">
|
|
503
|
+
<h2 className="min-w-0 flex-1 truncate text-lg font-semibold tracking-tight" aria-live="polite">
|
|
504
|
+
{title}
|
|
505
|
+
</h2>
|
|
506
|
+
<div className="flex items-center gap-1">
|
|
507
|
+
<Button size="sm" variant="secondary" onClick={goToday} title="Today (T)">
|
|
508
|
+
Today
|
|
509
|
+
</Button>
|
|
510
|
+
<IconButton size="sm" icon="chevron-left" label={`Previous ${UNIT[mode]}`} onClick={() => go(-1)} />
|
|
511
|
+
<IconButton size="sm" icon="chevron-right" label={`Next ${UNIT[mode]}`} onClick={() => go(1)} />
|
|
512
|
+
</div>
|
|
513
|
+
{modes.length > 1 ? (
|
|
514
|
+
<ToggleGroup
|
|
515
|
+
size="sm"
|
|
516
|
+
aria-label="Calendar view"
|
|
517
|
+
value={mode}
|
|
518
|
+
onChange={setMode}
|
|
519
|
+
items={modes.map((m) => ({ value: m, label: MODE_LABELS[m] ?? m }))}
|
|
520
|
+
className={narrow ? "w-full" : undefined}
|
|
521
|
+
/>
|
|
522
|
+
) : null}
|
|
523
|
+
</div>
|
|
524
|
+
) : null}
|
|
525
|
+
{toolbar ? (
|
|
526
|
+
<ViewToolbar
|
|
527
|
+
view={view}
|
|
528
|
+
onViewChange={setView}
|
|
529
|
+
ctx={ctx}
|
|
530
|
+
tasks={all}
|
|
531
|
+
controls={["search", "filter"]}
|
|
532
|
+
count={shown.length}
|
|
533
|
+
extra={
|
|
534
|
+
<>
|
|
535
|
+
{tray ? (
|
|
536
|
+
<Button
|
|
537
|
+
size="sm"
|
|
538
|
+
variant={trayShown ? "secondary" : "quiet"}
|
|
539
|
+
icon="inbox"
|
|
540
|
+
aria-pressed={sidePanel ? trayOpen : undefined}
|
|
541
|
+
onClick={() => (sidePanel ? setTrayOpen((v) => !v) : setTraySheet(true))}
|
|
542
|
+
>
|
|
543
|
+
{unscheduled.length ? `Unscheduled · ${unscheduled.length}` : "Unscheduled"}
|
|
544
|
+
</Button>
|
|
545
|
+
) : null}
|
|
546
|
+
{editable ? (
|
|
547
|
+
<Button size="sm" variant="primary" icon="plus" onClick={addNew} title={`${addLabel} (C)`}>
|
|
548
|
+
{addLabel}
|
|
549
|
+
</Button>
|
|
550
|
+
) : null}
|
|
551
|
+
{toolbarExtra}
|
|
552
|
+
</>
|
|
553
|
+
}
|
|
554
|
+
/>
|
|
555
|
+
) : null}
|
|
556
|
+
{readError ? <Notice tone="danger">{readError}</Notice> : null}
|
|
557
|
+
{error ? (
|
|
558
|
+
<Notice tone="danger" onDismiss={clearError}>
|
|
559
|
+
{error}
|
|
560
|
+
</Notice>
|
|
561
|
+
) : null}
|
|
562
|
+
{empty ? (
|
|
563
|
+
<p className="text-sm text-muted-foreground">
|
|
564
|
+
{timeMode ? "Nothing on the calendar yet. Click an hour, or drag across a few, to add a task." : "Nothing on the calendar yet. Click any day to add a task there."}
|
|
565
|
+
</p>
|
|
566
|
+
) : null}
|
|
567
|
+
<TaskDragProvider
|
|
568
|
+
disabled={!editable}
|
|
569
|
+
onDragStart={() => {
|
|
570
|
+
lastMove.current = null;
|
|
571
|
+
setDragging(true);
|
|
572
|
+
}}
|
|
573
|
+
onDragOver={({ over }) => {
|
|
574
|
+
if (grab.current == null && over?.data?.kind === "cell") grab.current = over.data.day;
|
|
575
|
+
}}
|
|
576
|
+
onDragEnd={onDragEnd}
|
|
577
|
+
onDragCancel={() => {
|
|
578
|
+
setDragging(false);
|
|
579
|
+
grab.current = null;
|
|
580
|
+
}}
|
|
581
|
+
overlay={(a) =>
|
|
582
|
+
a.data.kind === "span" || a.data.kind === "tray" ? (
|
|
583
|
+
<div className={cx(LIFTED, "w-52 max-w-[70vw]")}>
|
|
584
|
+
<TaskChip task={a.data.task} ctx={ctx} />
|
|
585
|
+
</div>
|
|
586
|
+
) : null
|
|
587
|
+
}
|
|
588
|
+
>
|
|
589
|
+
<div className="flex min-w-0 items-start gap-4">
|
|
590
|
+
<div className="min-w-0 flex-1">{body}</div>
|
|
591
|
+
{tray && sidePanel && trayOpen ? <UnscheduledTray tasks={unscheduled} api={api} className="sticky top-4 max-h-[40rem] w-60 shrink-0 overflow-y-auto" /> : null}
|
|
592
|
+
</div>
|
|
593
|
+
</TaskDragProvider>
|
|
594
|
+
{tray && !sidePanel ? (
|
|
595
|
+
<Sheet open={traySheet} onClose={() => setTraySheet(false)} title="Unscheduled" description="Tasks without a date yet. Give each one a day.">
|
|
596
|
+
<UnscheduledTray tasks={unscheduled} api={api} mode="sheet" />
|
|
597
|
+
</Sheet>
|
|
598
|
+
) : null}
|
|
599
|
+
<p aria-live="polite" className="sr-only">
|
|
600
|
+
{announce}
|
|
601
|
+
</p>
|
|
602
|
+
</section>
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
function CalendarSkeleton() {
|
|
607
|
+
return (
|
|
608
|
+
<div className="overflow-hidden rounded-lg border border-border bg-card" aria-busy="true" aria-label="Loading the calendar">
|
|
609
|
+
<div className="grid grid-cols-7 gap-px border-b border-border p-2">
|
|
610
|
+
{Array.from({ length: 7 }, (_, i) => (
|
|
611
|
+
<Skeleton key={i} className="h-3 w-10" />
|
|
612
|
+
))}
|
|
613
|
+
</div>
|
|
614
|
+
{Array.from({ length: 5 }, (_, w) => (
|
|
615
|
+
<div key={w} className="grid grid-cols-7 border-b border-border last:border-b-0">
|
|
616
|
+
{Array.from({ length: 7 }, (_, d) => (
|
|
617
|
+
<div key={d} className="grid min-h-28 content-start gap-1.5 border-e border-border p-2 last:border-e-0">
|
|
618
|
+
<Skeleton className="h-3 w-4" />
|
|
619
|
+
{(w + d) % 3 === 0 ? <Skeleton className="h-4 w-full" /> : null}
|
|
620
|
+
{(w * d) % 4 === 1 ? <Skeleton className="h-4 w-2/3" /> : null}
|
|
621
|
+
</div>
|
|
622
|
+
))}
|
|
623
|
+
</div>
|
|
624
|
+
))}
|
|
625
|
+
</div>
|
|
626
|
+
);
|
|
627
|
+
}
|