makersclaw 0.2.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/THIRD-PARTY-NOTICES.md +180 -0
- package/package.json +3 -2
- 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 +10 -6
- 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 +205 -8
- 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 +12 -7
- 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 +3411 -29
- 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 +55 -5
- package/registry/blocks/board/block.json +2 -2
- package/registry/blocks/board/board.jsx +230 -86
- 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 +80 -0
- 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 +8 -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/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/template.json +264 -8
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// CodeEditor three ways — the gallery's and the smoke test's surface. Not
|
|
4
|
+
// installed into apps.
|
|
5
|
+
// SQL a query box over a small CRM schema: autocomplete knows the
|
|
6
|
+
// tables, Cmd/Ctrl+Enter (or Run) runs the statement under the
|
|
7
|
+
// cursor against rows in memory; a misspelt table comes back as
|
|
8
|
+
// an error drawn on the text, as a database would report it.
|
|
9
|
+
// JSON a webhook payload, checked as you type, with a Format button
|
|
10
|
+
// through the handle.
|
|
11
|
+
// Empty the first-run state with its placeholder, and read-only.
|
|
12
|
+
import { useState } from "react";
|
|
13
|
+
import { Badge, Button, Notice, Switch, TabPanel, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Tabs } from "../components/ui";
|
|
14
|
+
import { CodeEditor, useCodeEditor } from "../components/blocks/code-editor";
|
|
15
|
+
|
|
16
|
+
const CRM_TABLES = [
|
|
17
|
+
{
|
|
18
|
+
name: "deals",
|
|
19
|
+
description: "Every open and closed deal",
|
|
20
|
+
columns: [
|
|
21
|
+
{ name: "id", type: "uuid", primaryKey: true },
|
|
22
|
+
{ name: "account_id", type: "uuid", description: "The account this deal is with" },
|
|
23
|
+
{ name: "owner", type: "text" },
|
|
24
|
+
{ name: "amount", type: "numeric" },
|
|
25
|
+
{ name: "stage", type: "text", description: "lead · qualified · proposal · won · lost" },
|
|
26
|
+
{ name: "closed_at", type: "timestamptz" },
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "accounts",
|
|
31
|
+
description: "Companies you sell to",
|
|
32
|
+
columns: [
|
|
33
|
+
{ name: "id", type: "uuid", primaryKey: true },
|
|
34
|
+
{ name: "name", type: "text" },
|
|
35
|
+
{ name: "industry", type: "text" },
|
|
36
|
+
{ name: "employees", type: "int4" },
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
{ name: "contacts", columns: [{ name: "id", type: "uuid", primaryKey: true }, { name: "account_id", type: "uuid" }, { name: "email", type: "text" }, { name: "title", type: "text" }] },
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
const STARTING_QUERY = `-- Pipeline by stage this quarter
|
|
43
|
+
SELECT stage, count(*) AS deals, sum(amount) AS total
|
|
44
|
+
FROM deals
|
|
45
|
+
WHERE closed_at >= date_trunc('quarter', now())
|
|
46
|
+
GROUP BY stage
|
|
47
|
+
ORDER BY total DESC;
|
|
48
|
+
|
|
49
|
+
-- Try a mistake: run this one (put the cursor on it)
|
|
50
|
+
SELECT name FROM acounts LIMIT 5;`;
|
|
51
|
+
|
|
52
|
+
const BY_STAGE = [
|
|
53
|
+
{ stage: "won", deals: 14, total: 412800 },
|
|
54
|
+
{ stage: "proposal", deals: 9, total: 268500 },
|
|
55
|
+
{ stage: "qualified", deals: 21, total: 190250 },
|
|
56
|
+
{ stage: "lead", deals: 37, total: 88400 },
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
const money = (n) => n.toLocaleString("en-US", { style: "currency", currency: "USD", maximumFractionDigits: 0 });
|
|
60
|
+
const KNOWN = new Set(CRM_TABLES.map((t) => t.name));
|
|
61
|
+
|
|
62
|
+
function SqlDemo() {
|
|
63
|
+
const [sql, setSql] = useState(STARTING_QUERY);
|
|
64
|
+
const [problems, setProblems] = useState([]);
|
|
65
|
+
const [result, setResult] = useState(null);
|
|
66
|
+
const [running, setRunning] = useState(false);
|
|
67
|
+
|
|
68
|
+
async function run({ statement, from }) {
|
|
69
|
+
setRunning(true);
|
|
70
|
+
await new Promise((r) => setTimeout(r, 380));
|
|
71
|
+
setRunning(false);
|
|
72
|
+
// What a database would say about a table it does not have.
|
|
73
|
+
const m = /\bfrom\s+([a-z_]+)/i.exec(statement);
|
|
74
|
+
if (m && !KNOWN.has(m[1].toLowerCase())) {
|
|
75
|
+
const position = m.index + m[0].length - m[1].length + 1;
|
|
76
|
+
const error = `relation "${m[1]}" does not exist`;
|
|
77
|
+
setProblems([{ position: from + position, message: `${error}. Did you mean "accounts"?` }]);
|
|
78
|
+
setResult({ ok: false, error });
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
setProblems([]);
|
|
82
|
+
setResult({ ok: true, rows: BY_STAGE, ms: 38 });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<div className="grid gap-3">
|
|
87
|
+
<CodeEditor
|
|
88
|
+
language="sql"
|
|
89
|
+
schema={CRM_TABLES}
|
|
90
|
+
value={sql}
|
|
91
|
+
onChange={setSql}
|
|
92
|
+
onRun={run}
|
|
93
|
+
runLabel={running ? "Running…" : "Run"}
|
|
94
|
+
diagnostics={problems}
|
|
95
|
+
placeholder="Write a query — try SELECT * FROM deals"
|
|
96
|
+
label="Query"
|
|
97
|
+
/>
|
|
98
|
+
{result?.ok === false ? (
|
|
99
|
+
<Notice tone="danger" title="The query did not run">
|
|
100
|
+
{result.error}. The line is marked in the editor.
|
|
101
|
+
</Notice>
|
|
102
|
+
) : result?.ok ? (
|
|
103
|
+
<div className="overflow-x-auto rounded-lg border border-border">
|
|
104
|
+
<Table>
|
|
105
|
+
<TableHeader>
|
|
106
|
+
<TableRow>
|
|
107
|
+
<TableHead>stage</TableHead>
|
|
108
|
+
<TableHead className="text-right">deals</TableHead>
|
|
109
|
+
<TableHead className="text-right">total</TableHead>
|
|
110
|
+
</TableRow>
|
|
111
|
+
</TableHeader>
|
|
112
|
+
<TableBody>
|
|
113
|
+
{result.rows.map((r) => (
|
|
114
|
+
<TableRow key={r.stage}>
|
|
115
|
+
<TableCell>{r.stage}</TableCell>
|
|
116
|
+
<TableCell className="text-right tabular-nums">{r.deals}</TableCell>
|
|
117
|
+
<TableCell className="text-right tabular-nums">{money(r.total)}</TableCell>
|
|
118
|
+
</TableRow>
|
|
119
|
+
))}
|
|
120
|
+
</TableBody>
|
|
121
|
+
</Table>
|
|
122
|
+
<p className="border-t border-border px-3 py-2 text-xs text-muted-foreground">
|
|
123
|
+
{result.rows.length} rows in {result.ms} ms
|
|
124
|
+
</p>
|
|
125
|
+
</div>
|
|
126
|
+
) : (
|
|
127
|
+
<p className="text-sm text-muted-foreground">Put the cursor in a statement and press Run. Type <code className="font-mono">deals.</code> to see its columns.</p>
|
|
128
|
+
)}
|
|
129
|
+
</div>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const WEBHOOK_BODY = `{
|
|
134
|
+
"event": "deal.won",
|
|
135
|
+
"occurred_at": "2026-09-18T14:02:11Z",
|
|
136
|
+
"deal": {
|
|
137
|
+
"id": "d_8f21c0",
|
|
138
|
+
"name": "Northwind — annual plan",
|
|
139
|
+
"amount": 48000,
|
|
140
|
+
"currency": "USD",
|
|
141
|
+
"owner": { "name": "Priya Raman", "email": "priya@acme-sales.co" },
|
|
142
|
+
"tags": ["expansion", "q3"]
|
|
143
|
+
},
|
|
144
|
+
"retry": false
|
|
145
|
+
}`;
|
|
146
|
+
|
|
147
|
+
function JsonDemo() {
|
|
148
|
+
const [text, setText] = useState(WEBHOOK_BODY);
|
|
149
|
+
const ed = useCodeEditor();
|
|
150
|
+
return (
|
|
151
|
+
<div className="grid gap-3">
|
|
152
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
153
|
+
<p className="me-auto text-sm text-muted-foreground">Delete a comma to see the check. Format lays it out again.</p>
|
|
154
|
+
<Button size="sm" icon="wand" onClick={() => ed.current?.format()}>
|
|
155
|
+
Format
|
|
156
|
+
</Button>
|
|
157
|
+
<Button size="sm" variant="quiet" icon="refresh" onClick={() => setText(WEBHOOK_BODY)}>
|
|
158
|
+
Reset
|
|
159
|
+
</Button>
|
|
160
|
+
</div>
|
|
161
|
+
<CodeEditor language="json" value={text} onChange={setText} editorRef={ed} label="Webhook body" />
|
|
162
|
+
</div>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function EmptyDemo() {
|
|
167
|
+
const [text, setText] = useState("");
|
|
168
|
+
const [readOnly, setReadOnly] = useState(false);
|
|
169
|
+
return (
|
|
170
|
+
<div className="grid gap-3">
|
|
171
|
+
<div className="flex flex-wrap items-center gap-x-4">
|
|
172
|
+
<Switch id="ce-readonly" label="Read-only" checked={readOnly} onChange={(e) => setReadOnly(e.target.checked)} />
|
|
173
|
+
{text ? <Badge variant="soft">{text.split("\n").length} lines</Badge> : null}
|
|
174
|
+
</div>
|
|
175
|
+
<CodeEditor value={text} onChange={setText} readOnly={readOnly} placeholder="Paste a script or write a note in plain text…" minHeight={160} label="Notes" />
|
|
176
|
+
</div>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export default function CodeEditorDemo() {
|
|
181
|
+
const [tab, setTab] = useState("sql");
|
|
182
|
+
return (
|
|
183
|
+
<div className="mx-auto w-full max-w-3xl">
|
|
184
|
+
<Tabs
|
|
185
|
+
aria-label="Examples"
|
|
186
|
+
tabs={[
|
|
187
|
+
{ key: "sql", label: "SQL" },
|
|
188
|
+
{ key: "json", label: "JSON" },
|
|
189
|
+
{ key: "empty", label: "Empty" },
|
|
190
|
+
]}
|
|
191
|
+
value={tab}
|
|
192
|
+
onChange={setTab}
|
|
193
|
+
/>
|
|
194
|
+
<TabPanel tab="sql" value={tab}>
|
|
195
|
+
<SqlDemo />
|
|
196
|
+
</TabPanel>
|
|
197
|
+
<TabPanel tab="json" value={tab}>
|
|
198
|
+
<JsonDemo />
|
|
199
|
+
</TabPanel>
|
|
200
|
+
<TabPanel tab="empty" value={tab}>
|
|
201
|
+
<EmptyDemo />
|
|
202
|
+
</TabPanel>
|
|
203
|
+
</div>
|
|
204
|
+
);
|
|
205
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// The CodeEditor block — `makersclaw add code-editor`. Fixed: compose it
|
|
2
|
+
// through its props (README.md beside this file). The helpers read SQL and
|
|
3
|
+
// JSON anywhere, the server included; the blocks built on this one
|
|
4
|
+
// (json-editor, sql-console…) import it, never @codemirror/* directly.
|
|
5
|
+
export { CodeEditor, useCodeEditor, LANGUAGES, SQL_DIALECTS } from "./code-editor";
|
|
6
|
+
export { splitStatements, statementAt, sqlNamespace } from "./sql";
|
|
7
|
+
export { checkJson, formatJson, stringifyJson } from "./json";
|
|
8
|
+
export { lineCol, offsetOf, normalizeDiagnostics } from "./text";
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
// JSON helpers: a checker that says what is wrong in words people use, and
|
|
2
|
+
// a formatter that keeps the text's own keys, order and numbers.
|
|
3
|
+
//
|
|
4
|
+
// Why our own parser: JSON.parse's messages differ by browser ("Unexpected
|
|
5
|
+
// token } in JSON at position 41" in one, no position at all in another)
|
|
6
|
+
// and never say how to fix the mistake. This one walks the text the same
|
|
7
|
+
// everywhere and names the usual slips — a missing or trailing comma, a
|
|
8
|
+
// key without quotes, single quotes, a comment. Plain functions: node and
|
|
9
|
+
// the server run them too.
|
|
10
|
+
import { lineCol } from "./text";
|
|
11
|
+
|
|
12
|
+
class JsonSlip extends Error {
|
|
13
|
+
constructor(message, from, to) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.from = from;
|
|
16
|
+
this.to = to;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const WS = new Set([" ", "\t", "\n", "\r"]);
|
|
21
|
+
const WORD = /[A-Za-z_$][\w$]*/y;
|
|
22
|
+
const NUMBER = /-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/y;
|
|
23
|
+
const LOOSE_NUMBER = /[-+]?(?:\d[\d_]*)?\.?\d*(?:[eE][+-]?\d+)?/y;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Check a JSON text. { ok: true, value } or { ok: false, error: { message,
|
|
27
|
+
* from, to, line, col } } — offsets into the text, line and col 1-based.
|
|
28
|
+
* An empty text is an error ("Nothing here yet…") unless `allowEmpty`.
|
|
29
|
+
*/
|
|
30
|
+
export function checkJson(text, { allowEmpty = false } = {}) {
|
|
31
|
+
const s = String(text ?? "");
|
|
32
|
+
let i = 0;
|
|
33
|
+
const opens = [];
|
|
34
|
+
|
|
35
|
+
const slip = (message, from = i, to = from + 1) => {
|
|
36
|
+
throw new JsonSlip(message, Math.min(from, s.length), Math.min(Math.max(to, from), s.length));
|
|
37
|
+
};
|
|
38
|
+
const skip = () => {
|
|
39
|
+
for (;;) {
|
|
40
|
+
while (i < s.length && WS.has(s[i])) i++;
|
|
41
|
+
if (s[i] === "/" && (s[i + 1] === "/" || s[i + 1] === "*")) {
|
|
42
|
+
const end = s[i + 1] === "/" ? s.indexOf("\n", i) : s.indexOf("*/", i + 2) + 2;
|
|
43
|
+
slip("JSON has no comments — remove this one", i, end > i ? end : s.length);
|
|
44
|
+
}
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const openedAt = (o) => `the ${o.ch === "{" ? "object" : "list"} opened on line ${lineCol(s, o.at).line}`;
|
|
49
|
+
|
|
50
|
+
function string() {
|
|
51
|
+
const start = i;
|
|
52
|
+
i++;
|
|
53
|
+
let out = "";
|
|
54
|
+
while (i < s.length) {
|
|
55
|
+
const c = s[i];
|
|
56
|
+
if (c === '"') {
|
|
57
|
+
i++;
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
if (c === "\n") slip("This text is missing its closing quote", start, i);
|
|
61
|
+
if (c < " ") slip("Tabs and line breaks inside text must be written \\t and \\n", i, i + 1);
|
|
62
|
+
if (c === "\\") {
|
|
63
|
+
const e = s[i + 1];
|
|
64
|
+
const map = { '"': '"', "\\": "\\", "/": "/", b: "\b", f: "\f", n: "\n", r: "\r", t: "\t" };
|
|
65
|
+
if (e in map) {
|
|
66
|
+
out += map[e];
|
|
67
|
+
i += 2;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (e === "u" && /^[0-9a-fA-F]{4}$/.test(s.slice(i + 2, i + 6))) {
|
|
71
|
+
out += String.fromCharCode(parseInt(s.slice(i + 2, i + 6), 16));
|
|
72
|
+
i += 6;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
slip(`"\\${e ?? ""}" is not an escape JSON knows — write \\\\ for a backslash`, i, i + 2);
|
|
76
|
+
}
|
|
77
|
+
out += c;
|
|
78
|
+
i++;
|
|
79
|
+
}
|
|
80
|
+
slip("This text is missing its closing quote", start, s.length);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function value() {
|
|
84
|
+
skip();
|
|
85
|
+
if (i >= s.length) {
|
|
86
|
+
const o = opens[opens.length - 1];
|
|
87
|
+
slip(o ? `The JSON ends too soon — close ${openedAt(o)}` : "Nothing here yet — start with { } or [ ]", s.length, s.length);
|
|
88
|
+
}
|
|
89
|
+
const c = s[i];
|
|
90
|
+
if (c === "{") return object();
|
|
91
|
+
if (c === "[") return array();
|
|
92
|
+
if (c === '"') return string();
|
|
93
|
+
if (c === "'") slip("Use double quotes (\") for text, not single quotes", i, closingSingle(i));
|
|
94
|
+
NUMBER.lastIndex = i;
|
|
95
|
+
const num = NUMBER.exec(s);
|
|
96
|
+
if (num && num[0] && num[0] !== "-") {
|
|
97
|
+
const after = s[i + num[0].length];
|
|
98
|
+
if (!after || !/[\w.]/.test(after)) {
|
|
99
|
+
i += num[0].length;
|
|
100
|
+
return Number(num[0]);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (/[-+.\d]/.test(c)) {
|
|
104
|
+
LOOSE_NUMBER.lastIndex = i;
|
|
105
|
+
const loose = LOOSE_NUMBER.exec(s)?.[0] || c;
|
|
106
|
+
slip(`"${loose}" is not a number JSON can read — no leading zeros, + signs or trailing dots`, i, i + loose.length);
|
|
107
|
+
}
|
|
108
|
+
WORD.lastIndex = i;
|
|
109
|
+
const w = WORD.exec(s)?.[0];
|
|
110
|
+
if (w === "true" || w === "false" || w === "null") {
|
|
111
|
+
i += w.length;
|
|
112
|
+
return w === "true" ? true : w === "false" ? false : null;
|
|
113
|
+
}
|
|
114
|
+
if (w) {
|
|
115
|
+
const lower = w.toLowerCase();
|
|
116
|
+
if (lower === "true" || lower === "false" || lower === "null") slip(`Write ${lower} in lower case`, i, i + w.length);
|
|
117
|
+
if (w === "undefined" || w === "NaN" || w === "Infinity") slip(`${w} is not JSON — use null`, i, i + w.length);
|
|
118
|
+
slip(`Text must be in double quotes: "${w}"`, i, i + w.length);
|
|
119
|
+
}
|
|
120
|
+
if (c === "}" || c === "]") slip(`A value is missing before this ${c}`, i);
|
|
121
|
+
if (c === ",") slip("A value is missing before this comma", i);
|
|
122
|
+
slip(`"${c}" cannot start a value`, i);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function closingSingle(from) {
|
|
126
|
+
const end = s.indexOf("'", from + 1);
|
|
127
|
+
const nl = s.indexOf("\n", from + 1);
|
|
128
|
+
return end > 0 && (nl < 0 || end < nl) ? end + 1 : from + 1;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function object() {
|
|
132
|
+
opens.push({ ch: "{", at: i });
|
|
133
|
+
i++;
|
|
134
|
+
const out = {};
|
|
135
|
+
skip();
|
|
136
|
+
if (s[i] === "}") {
|
|
137
|
+
i++;
|
|
138
|
+
opens.pop();
|
|
139
|
+
return out;
|
|
140
|
+
}
|
|
141
|
+
for (;;) {
|
|
142
|
+
skip();
|
|
143
|
+
if (i >= s.length) slip(`The JSON ends too soon — close ${openedAt(opens[opens.length - 1])} with }`, s.length, s.length);
|
|
144
|
+
const c = s[i];
|
|
145
|
+
if (c === "}") slip("Remove this trailing comma", lastComma(i), lastComma(i) + 1);
|
|
146
|
+
if (c === "'") slip("Keys need double quotes, not single quotes", i, closingSingle(i));
|
|
147
|
+
if (c !== '"') {
|
|
148
|
+
WORD.lastIndex = i;
|
|
149
|
+
const w = WORD.exec(s)?.[0];
|
|
150
|
+
if (w) slip(`Keys need double quotes: "${w}"`, i, i + w.length);
|
|
151
|
+
slip("A key in double quotes goes here", i);
|
|
152
|
+
}
|
|
153
|
+
const key = string();
|
|
154
|
+
skip();
|
|
155
|
+
if (s[i] !== ":") slip(i >= s.length ? "The JSON ends too soon — a : and a value go here" : `A colon (:) goes between "${key}" and its value`, i, i + 1);
|
|
156
|
+
i++;
|
|
157
|
+
out[key] = value(); // a duplicate key: the last one wins, as in JSON.parse
|
|
158
|
+
skip();
|
|
159
|
+
if (s[i] === ",") {
|
|
160
|
+
i++;
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
if (s[i] === "}") {
|
|
164
|
+
i++;
|
|
165
|
+
opens.pop();
|
|
166
|
+
return out;
|
|
167
|
+
}
|
|
168
|
+
if (i >= s.length) slip(`The JSON ends too soon — close ${openedAt(opens[opens.length - 1])} with }`, s.length, s.length);
|
|
169
|
+
if (s[i] === "]") slip(`This ] closes a list, but ${openedAt(opens[opens.length - 1])} needs a }`, i);
|
|
170
|
+
slip("A comma is missing before this", i, tokenEnd(i));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function array() {
|
|
175
|
+
opens.push({ ch: "[", at: i });
|
|
176
|
+
i++;
|
|
177
|
+
const out = [];
|
|
178
|
+
skip();
|
|
179
|
+
if (s[i] === "]") {
|
|
180
|
+
i++;
|
|
181
|
+
opens.pop();
|
|
182
|
+
return out;
|
|
183
|
+
}
|
|
184
|
+
for (;;) {
|
|
185
|
+
skip();
|
|
186
|
+
if (s[i] === "]" && out.length) slip("Remove this trailing comma", lastComma(i), lastComma(i) + 1);
|
|
187
|
+
out.push(value());
|
|
188
|
+
skip();
|
|
189
|
+
if (s[i] === ",") {
|
|
190
|
+
i++;
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
if (s[i] === "]") {
|
|
194
|
+
i++;
|
|
195
|
+
opens.pop();
|
|
196
|
+
return out;
|
|
197
|
+
}
|
|
198
|
+
if (i >= s.length) slip(`The JSON ends too soon — close ${openedAt(opens[opens.length - 1])} with ]`, s.length, s.length);
|
|
199
|
+
if (s[i] === "}") slip(`This } closes an object, but ${openedAt(opens[opens.length - 1])} needs a ]`, i);
|
|
200
|
+
slip("A comma is missing before this", i, tokenEnd(i));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const lastComma = (before) => {
|
|
205
|
+
let k = before - 1;
|
|
206
|
+
while (k > 0 && s[k] !== ",") k--;
|
|
207
|
+
return k;
|
|
208
|
+
};
|
|
209
|
+
const tokenEnd = (from) => {
|
|
210
|
+
if (s[from] === '"') {
|
|
211
|
+
const e = s.indexOf('"', from + 1);
|
|
212
|
+
return e > 0 ? e + 1 : from + 1;
|
|
213
|
+
}
|
|
214
|
+
let k = from;
|
|
215
|
+
while (k < s.length && !WS.has(s[k]) && !",:{}[]".includes(s[k])) k++;
|
|
216
|
+
return Math.max(k, from + 1);
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
try {
|
|
220
|
+
skip();
|
|
221
|
+
if (i >= s.length) {
|
|
222
|
+
if (allowEmpty) return { ok: true, value: undefined, empty: true };
|
|
223
|
+
slip("Nothing here yet — start with { } or [ ]", 0, 0);
|
|
224
|
+
}
|
|
225
|
+
const v = value();
|
|
226
|
+
skip();
|
|
227
|
+
if (i < s.length) slip(opens.length ? "Unexpected text" : "There is more after the end of the JSON — remove it, or wrap both in [ ]", i, s.length);
|
|
228
|
+
return { ok: true, value: v };
|
|
229
|
+
} catch (e) {
|
|
230
|
+
if (!(e instanceof JsonSlip)) throw e;
|
|
231
|
+
const { line, col } = lineCol(s, e.from);
|
|
232
|
+
return { ok: false, error: { message: e.message, from: e.from, to: e.to, line, col } };
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Lay a JSON text out again, keeping its keys, their order and its numbers
|
|
238
|
+
* exactly as written (JSON.stringify would reorder number-like keys and
|
|
239
|
+
* round big numbers). `indent` 2 (default), a number of spaces or "\t";
|
|
240
|
+
* `indent: 0` minifies. Short arrays of plain values stay on one line when
|
|
241
|
+
* they fit in `width` (80). Returns null when the text is not valid JSON.
|
|
242
|
+
*/
|
|
243
|
+
export function formatJson(text, { indent = 2, width = 80 } = {}) {
|
|
244
|
+
const s = String(text ?? "");
|
|
245
|
+
if (!checkJson(s).ok) return null;
|
|
246
|
+
const tokens = tokenize(s);
|
|
247
|
+
const pad = typeof indent === "string" ? indent : " ".repeat(Math.max(0, indent | 0));
|
|
248
|
+
if (!pad) return tokens.map((t) => t.v).join("");
|
|
249
|
+
let k = 0;
|
|
250
|
+
function node(depth) {
|
|
251
|
+
const t = tokens[k++];
|
|
252
|
+
if (t.v !== "{" && t.v !== "[") return t.v;
|
|
253
|
+
const close = t.v === "{" ? "}" : "]";
|
|
254
|
+
if (tokens[k].v === close) {
|
|
255
|
+
k++;
|
|
256
|
+
return t.v + close;
|
|
257
|
+
}
|
|
258
|
+
const items = [];
|
|
259
|
+
const plain = [];
|
|
260
|
+
for (;;) {
|
|
261
|
+
let key = "";
|
|
262
|
+
if (t.v === "{") {
|
|
263
|
+
key = tokens[k].v + ": ";
|
|
264
|
+
k += 2;
|
|
265
|
+
}
|
|
266
|
+
const start = k;
|
|
267
|
+
const v = node(depth + 1);
|
|
268
|
+
plain.push(tokens[start].v !== "{" && tokens[start].v !== "[");
|
|
269
|
+
items.push(key + v);
|
|
270
|
+
const sep = tokens[k++].v;
|
|
271
|
+
if (sep === close) break;
|
|
272
|
+
}
|
|
273
|
+
const inner = pad.repeat(depth + 1);
|
|
274
|
+
if (t.v === "[" && plain.every(Boolean)) {
|
|
275
|
+
const one = "[" + items.join(", ") + "]";
|
|
276
|
+
if (one.length + inner.length <= width) return one;
|
|
277
|
+
}
|
|
278
|
+
return t.v + "\n" + items.map((x) => inner + x).join(",\n") + "\n" + pad.repeat(depth) + close;
|
|
279
|
+
}
|
|
280
|
+
return node(0);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** A valid JSON text → its tokens: punctuation, strings, numbers, words. */
|
|
284
|
+
function tokenize(s) {
|
|
285
|
+
const out = [];
|
|
286
|
+
let i = 0;
|
|
287
|
+
while (i < s.length) {
|
|
288
|
+
const c = s[i];
|
|
289
|
+
if (WS.has(c)) {
|
|
290
|
+
i++;
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
if ("{}[],:".includes(c)) {
|
|
294
|
+
out.push({ v: c });
|
|
295
|
+
i++;
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
if (c === '"') {
|
|
299
|
+
let j = i + 1;
|
|
300
|
+
while (s[j] !== '"') j += s[j] === "\\" ? 2 : 1;
|
|
301
|
+
out.push({ v: s.slice(i, j + 1) });
|
|
302
|
+
i = j + 1;
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
let j = i;
|
|
306
|
+
while (j < s.length && !WS.has(s[j]) && !"{}[],:".includes(s[j])) j++;
|
|
307
|
+
out.push({ v: s.slice(i, j) });
|
|
308
|
+
i = j;
|
|
309
|
+
}
|
|
310
|
+
return out;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** A JS value → a JSON text, 2-space indented (the tree view's output). */
|
|
314
|
+
export function stringifyJson(value, indent = 2) {
|
|
315
|
+
if (value === undefined) return "";
|
|
316
|
+
return formatJson(JSON.stringify(value), { indent }) ?? JSON.stringify(value, null, indent);
|
|
317
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// SQL helpers: statements, and the schema autocomplete reads.
|
|
2
|
+
//
|
|
3
|
+
// Plain functions of strings and objects, so they run in node and on the
|
|
4
|
+
// server (sql-console runs `splitStatements` before it calls the database).
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The statements in a script, in order: [{ from, to, text }]. `from`/`to`
|
|
8
|
+
* are offsets into `sql` (the statement's own text, trimmed, without its
|
|
9
|
+
* `;`). A `;` inside a string ('it''s'), a quoted name ("a;b", `a;b`), a
|
|
10
|
+
* comment (-- …, /* … *\/) or a Postgres dollar-quoted body ($$ … $$,
|
|
11
|
+
* $fn$ … $fn$) does not end a statement. A stretch holding only comments
|
|
12
|
+
* or whitespace is not a statement. `opts.backslash: true` also reads \'
|
|
13
|
+
* as an escaped quote inside '…' (MySQL); Postgres and SQLite do not.
|
|
14
|
+
*/
|
|
15
|
+
export function splitStatements(sql, opts = {}) {
|
|
16
|
+
const s = String(sql ?? "");
|
|
17
|
+
const out = [];
|
|
18
|
+
let start = 0;
|
|
19
|
+
let i = 0;
|
|
20
|
+
let meaningful = false;
|
|
21
|
+
const push = (end) => {
|
|
22
|
+
if (meaningful) {
|
|
23
|
+
let a = start;
|
|
24
|
+
let b = end;
|
|
25
|
+
while (a < b && /\s/.test(s[a])) a++;
|
|
26
|
+
while (b > a && /\s/.test(s[b - 1])) b--;
|
|
27
|
+
out.push({ from: a, to: b, text: s.slice(a, b) });
|
|
28
|
+
}
|
|
29
|
+
meaningful = false;
|
|
30
|
+
};
|
|
31
|
+
while (i < s.length) {
|
|
32
|
+
const c = s[i];
|
|
33
|
+
const n = s[i + 1];
|
|
34
|
+
if (c === "-" && n === "-") {
|
|
35
|
+
const e = s.indexOf("\n", i);
|
|
36
|
+
i = e < 0 ? s.length : e + 1;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (c === "/" && n === "*") {
|
|
40
|
+
const e = s.indexOf("*/", i + 2);
|
|
41
|
+
i = e < 0 ? s.length : e + 2;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (c === "'" || c === '"' || c === "`") {
|
|
45
|
+
meaningful = true;
|
|
46
|
+
i++;
|
|
47
|
+
while (i < s.length) {
|
|
48
|
+
if (s[i] === c) {
|
|
49
|
+
if (s[i + 1] === c) i += 2; // '' or "" is an escaped quote
|
|
50
|
+
else break;
|
|
51
|
+
} else if (s[i] === "\\" && c === "'" && opts.backslash) i += 2;
|
|
52
|
+
else i++;
|
|
53
|
+
}
|
|
54
|
+
i++;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (c === "$") {
|
|
58
|
+
const m = /^\$([A-Za-z_][A-Za-z0-9_]*)?\$/.exec(s.slice(i, i + 64));
|
|
59
|
+
if (m) {
|
|
60
|
+
meaningful = true;
|
|
61
|
+
const tag = m[0];
|
|
62
|
+
const e = s.indexOf(tag, i + tag.length);
|
|
63
|
+
i = e < 0 ? s.length : e + tag.length;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (c === ";") {
|
|
68
|
+
push(i);
|
|
69
|
+
i++;
|
|
70
|
+
start = i;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (!/\s/.test(c)) meaningful = true;
|
|
74
|
+
i++;
|
|
75
|
+
}
|
|
76
|
+
push(s.length);
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The statement to run for a cursor at `pos`: the one the cursor is in,
|
|
82
|
+
* or — when it sits between statements — the one it follows on the same
|
|
83
|
+
* line (just after a `;`), else the next one, else the last. Null when the
|
|
84
|
+
* script has no statement. `opts.backslash`: as splitStatements.
|
|
85
|
+
*/
|
|
86
|
+
export function statementAt(sql, pos, opts = {}) {
|
|
87
|
+
const s = String(sql ?? "");
|
|
88
|
+
const all = splitStatements(s, opts);
|
|
89
|
+
if (!all.length) return null;
|
|
90
|
+
const at = Math.max(0, Math.min(s.length, pos | 0));
|
|
91
|
+
for (const st of all) if (at >= st.from && at <= st.to) return st;
|
|
92
|
+
// Between statements: the previous one if nothing but `;`/spaces/comment
|
|
93
|
+
// on the same line separates them.
|
|
94
|
+
let prev = null;
|
|
95
|
+
for (const st of all) if (st.to <= at) prev = st;
|
|
96
|
+
if (prev && !s.slice(prev.to, at).includes("\n")) return prev;
|
|
97
|
+
return all.find((st) => st.from >= at) ?? prev ?? all[all.length - 1];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The tables autocomplete offers, as the editor's SQL mode wants them.
|
|
102
|
+
*
|
|
103
|
+
* tables [{ name, schema?, description?, columns: [
|
|
104
|
+
* { name, type?, description?, primaryKey? } | "name" ] }]
|
|
105
|
+
*
|
|
106
|
+
* Returns { namespace, tables } for @codemirror/lang-sql's `schema`: a
|
|
107
|
+
* table completes as a table (its description beside it), its columns
|
|
108
|
+
* complete after `table.` and anywhere in a query that names it, each
|
|
109
|
+
* with its type. Tables in a `schema` nest under it (`public.deals`).
|
|
110
|
+
*/
|
|
111
|
+
export function sqlNamespace(tables) {
|
|
112
|
+
const namespace = {};
|
|
113
|
+
const list = [];
|
|
114
|
+
for (const t of tables ?? []) {
|
|
115
|
+
if (!t || !t.name) continue;
|
|
116
|
+
const columns = (t.columns ?? [])
|
|
117
|
+
.map((c) => (typeof c === "string" ? { name: c } : c))
|
|
118
|
+
.filter((c) => c && c.name)
|
|
119
|
+
.map((c) => ({
|
|
120
|
+
label: String(c.name),
|
|
121
|
+
type: "property",
|
|
122
|
+
detail: [c.type, c.primaryKey ? "key" : null].filter(Boolean).join(" · ") || undefined,
|
|
123
|
+
info: c.description || undefined,
|
|
124
|
+
boost: c.primaryKey ? 1 : 0,
|
|
125
|
+
}));
|
|
126
|
+
const node = { self: { label: String(t.name), type: "type", detail: `${columns.length} column${columns.length === 1 ? "" : "s"}`, info: t.description || undefined }, children: columns };
|
|
127
|
+
if (t.schema) {
|
|
128
|
+
const holder = (namespace[t.schema] ??= { self: { label: String(t.schema), type: "namespace" }, children: {} });
|
|
129
|
+
holder.children[t.name] = node;
|
|
130
|
+
} else {
|
|
131
|
+
namespace[t.name] = node;
|
|
132
|
+
}
|
|
133
|
+
list.push({ name: String(t.name), schema: t.schema ?? null, columns: columns.map((c) => c.label) });
|
|
134
|
+
}
|
|
135
|
+
return { namespace, tables: list };
|
|
136
|
+
}
|