@malloy-publisher/sdk 0.9.1 → 0.9.3
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/dist/{RenderedResult-BRgIgxWh.es.js → RenderedResult-DwB0-9Yx.es.js} +219 -210
- package/dist/RenderedResult-hKjFEqaN.cjs.js +141 -0
- package/dist/{ServerProvider-Boxrv6Ym.es.js → ServerProvider-CcSrGaRN.es.js} +1473 -1326
- package/dist/ServerProvider-Gbf1YPOP.cjs.js +1 -0
- package/dist/builder/index.cjs.js +143 -58
- package/dist/builder/index.es.js +12179 -9318
- package/dist/builder-entry.d.ts +5 -1
- package/dist/client/api.d.ts +247 -56
- package/dist/client/configuration.d.ts +1 -1
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.es.js +94 -88
- package/dist/client-entry.d.ts +2 -0
- package/dist/components/ApiErrorDisplay.d.ts +11 -0
- package/dist/components/AppDialog.d.ts +6 -6
- package/dist/components/Dashboard/Dashboard.d.ts +8 -15
- package/dist/components/Dashboard/DashboardGrid.d.ts +38 -6
- package/dist/components/Dashboard/DashboardTile.d.ts +21 -2
- package/dist/components/Dashboard/DashboardView.d.ts +71 -0
- package/dist/components/Dashboard/TileCard.d.ts +30 -5
- package/dist/components/Dashboard/TileFilterTag.d.ts +12 -0
- package/dist/components/Dashboard/dropValueUrlTags.d.ts +6 -0
- package/dist/components/Dashboard/index.d.ts +5 -1
- package/dist/components/Dashboard/telemetry.d.ts +16 -3
- package/dist/components/Dashboard/textSource.d.ts +19 -0
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +15 -9
- package/dist/components/DashboardBuilder/BuilderDialogs.d.ts +25 -0
- package/dist/components/DashboardBuilder/BuilderGrid.d.ts +31 -0
- package/dist/components/DashboardBuilder/BuilderHeader.d.ts +17 -0
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +23 -15
- package/dist/components/DashboardBuilder/ChartPicker.d.ts +31 -0
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +56 -21
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +44 -5
- package/dist/components/DashboardBuilder/EditorSurface.d.ts +33 -0
- package/dist/components/DashboardBuilder/FilterDialog.d.ts +2 -2
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +8 -4
- package/dist/components/DashboardBuilder/InlineMarkdown.d.ts +18 -0
- package/dist/components/DashboardBuilder/InlineText.d.ts +19 -0
- package/dist/components/DashboardBuilder/NotebookEditor.d.ts +15 -0
- package/dist/components/DashboardBuilder/SourceViewPicker.d.ts +9 -0
- package/dist/components/DashboardBuilder/TextTileBody.d.ts +10 -0
- package/dist/components/DashboardBuilder/TileFrame.d.ts +51 -12
- package/dist/components/DashboardBuilder/TileMenu.d.ts +12 -6
- package/dist/components/DashboardBuilder/annotationText.d.ts +4 -0
- package/dist/components/DashboardBuilder/builderReport.d.ts +13 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +4 -18
- package/dist/components/DashboardBuilder/changedTile.d.ts +7 -0
- package/dist/components/DashboardBuilder/chartLine.d.ts +33 -0
- package/dist/components/DashboardBuilder/controls.d.ts +2 -2
- package/dist/components/DashboardBuilder/document.d.ts +42 -26
- package/dist/components/DashboardBuilder/documentSession.d.ts +100 -0
- package/dist/components/DashboardBuilder/imports.d.ts +19 -0
- package/dist/components/DashboardBuilder/inlineEdit.d.ts +18 -0
- package/dist/components/DashboardBuilder/legacyNotebook.d.ts +73 -0
- package/dist/components/DashboardBuilder/loadMalloy.d.ts +15 -0
- package/dist/components/DashboardBuilder/malloyTree.d.ts +119 -0
- package/dist/components/DashboardBuilder/newDashboard.d.ts +3 -1
- package/dist/components/DashboardBuilder/openDraft.d.ts +10 -0
- package/dist/components/DashboardBuilder/preview.d.ts +24 -4
- package/dist/components/DashboardBuilder/readDocument.d.ts +6 -1
- package/dist/components/DashboardBuilder/readForEditor.d.ts +16 -0
- package/dist/components/DashboardBuilder/sortable.d.ts +16 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +15 -13
- package/dist/components/DashboardBuilder/spliceResult.d.ts +11 -0
- package/dist/components/DashboardBuilder/tagParse.d.ts +24 -0
- package/dist/components/DashboardBuilder/telemetry.d.ts +43 -0
- package/dist/components/DashboardBuilder/testing/fixtures.d.ts +3 -1
- package/dist/components/DashboardBuilder/testing/inline.d.ts +4 -0
- package/dist/components/DashboardBuilder/testing/resize.d.ts +7 -0
- package/dist/components/DashboardBuilder/tileDisplayTitle.d.ts +7 -0
- package/dist/components/DashboardBuilder/useBuilderSelection.d.ts +53 -0
- package/dist/components/DashboardBuilder/useBuilderSession.d.ts +86 -0
- package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +9 -6
- package/dist/components/DashboardBuilder/useControlBindings.d.ts +30 -0
- package/dist/components/DashboardBuilder/useConversionConfirm.d.ts +20 -0
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +19 -55
- package/dist/components/DashboardBuilder/useDocumentEditor.d.ts +105 -0
- package/dist/components/DashboardBuilder/useDraft.d.ts +3 -1
- package/dist/components/DashboardBuilder/useExitGuard.d.ts +19 -0
- package/dist/components/DashboardBuilder/useFilterForm.d.ts +3 -3
- package/dist/components/DashboardBuilder/useHostCopy.d.ts +26 -0
- package/dist/components/DashboardBuilder/useOpenDraftCommit.d.ts +17 -0
- package/dist/components/DashboardBuilder/useOpenedDocument.d.ts +71 -0
- package/dist/components/DashboardBuilder/useSaveChannel.d.ts +50 -0
- package/dist/components/DashboardBuilder/useTileEditing.d.ts +33 -0
- package/dist/components/DashboardBuilder/useTileResize.d.ts +6 -3
- package/dist/components/DocumentCreate/canRetry.d.ts +6 -0
- package/dist/components/DocumentCreate/createDocument.d.ts +58 -0
- package/dist/components/DocumentCreate/documentPath.d.ts +10 -0
- package/dist/components/DocumentCreate/events.d.ts +10 -0
- package/dist/components/DocumentCreate/exportedSources.d.ts +7 -0
- package/dist/components/DocumentCreate/guards.d.ts +12 -0
- package/dist/components/DocumentCreate/index.d.ts +6 -0
- package/dist/components/DocumentCreate/newNotebook.d.ts +9 -0
- package/dist/components/DocumentCreate/useDocumentChoices.d.ts +32 -0
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +2 -1
- package/dist/components/Loading.d.ts +13 -0
- package/dist/components/NarrowEditGate.d.ts +8 -0
- package/dist/components/Notebook/Notebook.d.ts +1 -1
- package/dist/components/Notebook/NotebookCell.d.ts +1 -5
- package/dist/components/Package/NewDocumentDialog.d.ts +33 -0
- package/dist/components/Package/Package.d.ts +17 -1
- package/dist/components/Package/documentLocation.d.ts +28 -0
- package/dist/components/Package/index.d.ts +5 -1
- package/dist/components/Package/useDocumentLocation.d.ts +12 -0
- package/dist/components/PackageSection.d.ts +2 -2
- package/dist/components/Prose.d.ts +1 -1
- package/dist/components/RenderedResult/RenderedResult.d.ts +2 -0
- package/dist/components/RenderedResult/ResultContainer.d.ts +8 -1
- package/dist/components/RenderedResult/ResultPanel.d.ts +3 -1
- package/dist/components/RenderedResult/loadRenderer.d.ts +7 -0
- package/dist/components/RenderedResult/resultSizing.d.ts +9 -1
- package/dist/components/ServerProvider.d.ts +2 -1
- package/dist/components/UnsavedChangesDialog.d.ts +9 -0
- package/dist/components/given/GivensPanel.d.ts +2 -2
- package/dist/components/given/paramCodec.d.ts +8 -1
- package/dist/components/index.d.ts +3 -2
- package/dist/components/styles.d.ts +4 -4
- package/dist/hooks/givenValue.d.ts +6 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useCompiledDocument.d.ts +23 -0
- package/dist/hooks/useDocumentControls.d.ts +6 -1
- package/dist/hooks/useNarrowScreen.d.ts +4 -0
- package/dist/hooks/useNearViewport.d.ts +16 -0
- package/dist/hooks/useQueryResult.d.ts +2 -0
- package/dist/hooks/useQueryWithApiError.d.ts +7 -2
- package/dist/hooks/useSettled.d.ts +14 -0
- package/dist/hooks/useSuggestOptions.d.ts +9 -2
- package/dist/index.cjs.js +23 -24
- package/dist/index.es.js +9041 -7002
- package/dist/text/index.cjs.js +1 -0
- package/dist/text/index.d.ts +2 -0
- package/dist/text/index.es.js +6 -0
- package/dist/text-entry-BJwltZiy.cjs.js +7 -0
- package/dist/text-entry-CA0LZ1xL.es.js +196 -0
- package/dist/text-entry.d.ts +2 -0
- package/dist/theme/accent.d.ts +29 -0
- package/dist/theme/buildVegaThemeOverride.d.ts +3 -3
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/keys.d.ts +1 -1
- package/dist/theme/motion.d.ts +31 -0
- package/dist/theme/readChartAnnotations.d.ts +1 -1
- package/dist/theme/resolveTheme.d.ts +4 -4
- package/dist/theme/types.d.ts +33 -5
- package/dist/{Dashboard-H1kJlDFo.es.js → useCompiledDocument-BU6d8FPp.es.js} +17904 -19057
- package/dist/useCompiledDocument-pOg2W-Yt.cjs.js +142 -0
- package/dist/utils/clock.d.ts +2 -0
- package/dist/utils/malloyText.d.ts +104 -0
- package/package.json +20 -11
- package/src/builder-entry.ts +36 -0
- package/src/client-entry.ts +8 -0
- package/src/clientEntry.spec.ts +17 -0
- package/src/components/ApiErrorDisplay.tsx +37 -18
- package/src/components/AppDialog.tsx +8 -7
- package/src/components/Dashboard/Dashboard.spec.tsx +3 -32
- package/src/components/Dashboard/Dashboard.tsx +29 -280
- package/src/components/Dashboard/DashboardGrid.tsx +87 -8
- package/src/components/Dashboard/DashboardTile.spec.tsx +121 -2
- package/src/components/Dashboard/DashboardTile.tsx +121 -30
- package/src/components/Dashboard/DashboardView.spec.tsx +368 -0
- package/src/components/Dashboard/DashboardView.tsx +428 -0
- package/src/components/Dashboard/RowsDialog.tsx +4 -3
- package/src/components/Dashboard/TileCard.tsx +60 -11
- package/src/components/Dashboard/TileFilterTag.spec.tsx +73 -0
- package/src/components/Dashboard/TileFilterTag.tsx +78 -0
- package/src/components/Dashboard/defaultTileSpan.spec.ts +32 -0
- package/src/components/Dashboard/dropValueUrlTags.spec.ts +177 -0
- package/src/components/Dashboard/dropValueUrlTags.ts +108 -0
- package/src/components/Dashboard/index.ts +13 -1
- package/src/components/Dashboard/telemetry.ts +17 -5
- package/src/components/Dashboard/textSource.spec.ts +36 -0
- package/src/components/Dashboard/textSource.ts +39 -0
- package/src/components/DashboardBuilder/AddTileDialog.spec.tsx +88 -0
- package/src/components/DashboardBuilder/AddTileDialog.tsx +124 -138
- package/src/components/DashboardBuilder/BuilderDialogs.tsx +162 -0
- package/src/components/DashboardBuilder/BuilderGrid.tsx +245 -0
- package/src/components/DashboardBuilder/BuilderHeader.tsx +107 -0
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +111 -80
- package/src/components/DashboardBuilder/ChartPicker.render.spec.tsx +25 -0
- package/src/components/DashboardBuilder/ChartPicker.spec.ts +77 -0
- package/src/components/DashboardBuilder/ChartPicker.tsx +156 -0
- package/src/components/DashboardBuilder/DashboardBuilder.charts.spec.tsx +205 -0
- package/src/components/DashboardBuilder/DashboardBuilder.exit.spec.tsx +183 -0
- package/src/components/DashboardBuilder/DashboardBuilder.inline.spec.tsx +373 -0
- package/src/components/DashboardBuilder/DashboardBuilder.notebook.spec.tsx +310 -0
- package/src/components/DashboardBuilder/DashboardBuilder.openDraft.spec.tsx +105 -0
- package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +117 -0
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +146 -108
- package/src/components/DashboardBuilder/DashboardBuilder.textTiles.spec.tsx +179 -0
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +330 -512
- package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +55 -25
- package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +142 -0
- package/src/components/DashboardBuilder/DashboardEditor.filterTag.spec.tsx +162 -0
- package/src/components/DashboardBuilder/DashboardEditor.notebook.spec.tsx +310 -0
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +39 -13
- package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +9 -26
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +102 -25
- package/src/components/DashboardBuilder/DashboardEditor.textSource.spec.tsx +317 -0
- package/src/components/DashboardBuilder/DashboardEditor.tsx +252 -780
- package/src/components/DashboardBuilder/DrillDialog.tsx +2 -2
- package/src/components/DashboardBuilder/EditorSurface.tsx +471 -0
- package/src/components/DashboardBuilder/FilterDialog.tsx +23 -11
- package/src/components/DashboardBuilder/FilterStrip.tsx +130 -70
- package/src/components/DashboardBuilder/InlineMarkdown.tsx +182 -0
- package/src/components/DashboardBuilder/InlineText.tsx +112 -0
- package/src/components/DashboardBuilder/NotebookEditor.tsx +44 -0
- package/src/components/DashboardBuilder/SourceViewPicker.tsx +122 -0
- package/src/components/DashboardBuilder/TextTileBody.tsx +31 -0
- package/src/components/DashboardBuilder/TileFrame.tsx +302 -163
- package/src/components/DashboardBuilder/TileMenu.tsx +125 -97
- package/src/components/DashboardBuilder/annotationText.spec.ts +33 -0
- package/src/components/DashboardBuilder/annotationText.ts +17 -0
- package/src/components/DashboardBuilder/artifactBlock.spec.ts +248 -0
- package/src/components/DashboardBuilder/artifactTagParity.spec.ts +46 -0
- package/src/components/DashboardBuilder/builderReport.ts +74 -0
- package/src/components/DashboardBuilder/catalog.aggregate.spec.ts +49 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +2 -44
- package/src/components/DashboardBuilder/catalog.ts +61 -57
- package/src/components/DashboardBuilder/changedTile.spec.ts +46 -0
- package/src/components/DashboardBuilder/changedTile.ts +28 -0
- package/src/components/DashboardBuilder/chartLine.spec.ts +180 -0
- package/src/components/DashboardBuilder/chartLine.ts +121 -0
- package/src/components/DashboardBuilder/controls.spec.ts +21 -10
- package/src/components/DashboardBuilder/controls.ts +22 -8
- package/src/components/DashboardBuilder/document.ts +53 -5
- package/src/components/DashboardBuilder/documentSession.spec.ts +209 -0
- package/src/components/DashboardBuilder/documentSession.ts +258 -0
- package/src/components/DashboardBuilder/emptyStart.spec.ts +131 -0
- package/src/components/DashboardBuilder/imports.spec.ts +61 -0
- package/src/components/DashboardBuilder/imports.ts +93 -0
- package/src/components/DashboardBuilder/inlineEdit.tsx +78 -0
- package/src/components/DashboardBuilder/invariants.spec.ts +6 -2
- package/src/components/DashboardBuilder/legacyNotebook.chart.spec.ts +77 -0
- package/src/components/DashboardBuilder/legacyNotebook.convert.spec.ts +630 -0
- package/src/components/DashboardBuilder/legacyNotebook.read.spec.ts +338 -0
- package/src/components/DashboardBuilder/legacyNotebook.ts +1117 -0
- package/src/components/DashboardBuilder/loadMalloy.spec.ts +80 -0
- package/src/components/DashboardBuilder/loadMalloy.ts +39 -0
- package/src/components/DashboardBuilder/malloyTree.ts +159 -7
- package/src/components/DashboardBuilder/newDashboard.spec.ts +46 -2
- package/src/components/DashboardBuilder/newDashboard.ts +30 -3
- package/src/components/DashboardBuilder/openDraft.ts +52 -0
- package/src/components/DashboardBuilder/preview.shapes.spec.ts +75 -0
- package/src/components/DashboardBuilder/preview.spec.ts +159 -12
- package/src/components/DashboardBuilder/preview.ts +83 -9
- package/src/components/DashboardBuilder/readDocument.spec.ts +174 -26
- package/src/components/DashboardBuilder/readDocument.ts +137 -45
- package/src/components/DashboardBuilder/readForEditor.spec.ts +80 -0
- package/src/components/DashboardBuilder/readForEditor.ts +52 -0
- package/src/components/DashboardBuilder/scannerShapes.spec.ts +14 -13
- package/src/components/DashboardBuilder/sortable.spec.ts +89 -0
- package/src/components/DashboardBuilder/sortable.tsx +11 -10
- package/src/components/DashboardBuilder/spliceDocument.chart.spec.ts +340 -0
- package/src/components/DashboardBuilder/spliceDocument.imports.spec.ts +167 -0
- package/src/components/DashboardBuilder/spliceDocument.spec.ts +229 -94
- package/src/components/DashboardBuilder/spliceDocument.ts +768 -131
- package/src/components/DashboardBuilder/spliceResult.ts +15 -0
- package/src/components/DashboardBuilder/statementExtent.spec.ts +33 -30
- package/src/components/DashboardBuilder/tagParse.spec.ts +149 -0
- package/src/components/DashboardBuilder/tagParse.ts +103 -0
- package/src/components/DashboardBuilder/telemetry.ts +47 -0
- package/src/components/DashboardBuilder/testing/artifactTagParity.json +253 -0
- package/src/components/DashboardBuilder/testing/documentKindRule.json +40 -0
- package/src/components/DashboardBuilder/testing/fixtures.ts +16 -1
- package/src/components/DashboardBuilder/testing/inline.ts +25 -0
- package/src/components/DashboardBuilder/testing/resize.ts +48 -0
- package/src/components/DashboardBuilder/testing/urlRenderTags.json +62 -0
- package/src/components/DashboardBuilder/textTiles.spec.ts +760 -0
- package/src/components/DashboardBuilder/tileDisplayTitle.ts +13 -0
- package/src/components/DashboardBuilder/useBuilderSelection.ts +121 -0
- package/src/components/DashboardBuilder/useBuilderSession.spec.ts +250 -0
- package/src/components/DashboardBuilder/useBuilderSession.ts +255 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.overlay.spec.tsx +97 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.spec.tsx +60 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +45 -9
- package/src/components/DashboardBuilder/useControlBindings.ts +152 -0
- package/src/components/DashboardBuilder/useConversionConfirm.ts +55 -0
- package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +16 -13
- package/src/components/DashboardBuilder/useDashboardEditor.ts +57 -181
- package/src/components/DashboardBuilder/useDocumentEditor.spec.ts +565 -0
- package/src/components/DashboardBuilder/useDocumentEditor.ts +399 -0
- package/src/components/DashboardBuilder/useDraft.ts +15 -2
- package/src/components/DashboardBuilder/useExitGuard.spec.ts +159 -0
- package/src/components/DashboardBuilder/useExitGuard.ts +89 -0
- package/src/components/DashboardBuilder/useFilterForm.existing.spec.tsx +41 -0
- package/src/components/DashboardBuilder/useFilterForm.spec.tsx +24 -2
- package/src/components/DashboardBuilder/useFilterForm.ts +41 -13
- package/src/components/DashboardBuilder/useHostCopy.ts +104 -0
- package/src/components/DashboardBuilder/useOpenDraftCommit.ts +47 -0
- package/src/components/DashboardBuilder/useOpenedDocument.ts +314 -0
- package/src/components/DashboardBuilder/useSaveChannel.ts +275 -0
- package/src/components/DashboardBuilder/useTileEditing.ts +141 -0
- package/src/components/DashboardBuilder/useTileReorder.spec.tsx +28 -5
- package/src/components/DashboardBuilder/useTileReorder.ts +5 -7
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +30 -5
- package/src/components/DashboardBuilder/useTileResize.ts +31 -8
- package/src/components/DataAppViewer/DataAppViewer.tsx +7 -4
- package/src/components/DocumentCreate/canRetry.spec.ts +32 -0
- package/src/components/DocumentCreate/canRetry.ts +19 -0
- package/src/components/DocumentCreate/createDocument.spec.ts +310 -0
- package/src/components/DocumentCreate/createDocument.ts +159 -0
- package/src/components/DocumentCreate/documentPath.ts +40 -0
- package/src/components/DocumentCreate/events.ts +15 -0
- package/src/components/DocumentCreate/exportedSources.ts +25 -0
- package/src/components/DocumentCreate/guards.ts +45 -0
- package/src/components/DocumentCreate/index.ts +27 -0
- package/src/components/DocumentCreate/newNotebook.spec.ts +156 -0
- package/src/components/DocumentCreate/newNotebook.ts +44 -0
- package/src/components/DocumentCreate/useDocumentChoices.spec.tsx +138 -0
- package/src/components/DocumentCreate/useDocumentChoices.ts +113 -0
- package/src/components/DocumentStorage/DocumentStorage.ts +2 -1
- package/src/components/Environment/Environment.tsx +0 -10
- package/src/components/Loading.tsx +14 -0
- package/src/components/Model/Model.tsx +16 -9
- package/src/components/Model/ModelExplorer.spec.tsx +2 -2
- package/src/components/Model/ModelExplorer.tsx +2 -2
- package/src/components/Model/SourcesExplorer.tsx +2 -4
- package/src/components/NarrowEditGate.spec.tsx +73 -0
- package/src/components/NarrowEditGate.tsx +29 -0
- package/src/components/Notebook/Notebook.layout.spec.tsx +94 -0
- package/src/components/Notebook/Notebook.tsx +72 -29
- package/src/components/Notebook/NotebookCell.tsx +90 -215
- package/src/components/Package/NewDocumentDialog.spec.tsx +749 -0
- package/src/components/Package/NewDocumentDialog.tsx +401 -0
- package/src/components/Package/Package.artifacts.spec.tsx +186 -0
- package/src/components/Package/Package.create.spec.tsx +401 -0
- package/src/components/Package/Package.notebooks.spec.tsx +18 -0
- package/src/components/Package/Package.tsx +396 -177
- package/src/components/Package/documentLocation.spec.ts +81 -0
- package/src/components/Package/documentLocation.ts +55 -0
- package/src/components/Package/index.ts +14 -1
- package/src/components/Package/useDocumentLocation.ts +59 -0
- package/src/components/PackageSection.tsx +2 -2
- package/src/components/Prose.spec.tsx +37 -0
- package/src/components/Prose.tsx +35 -5
- package/src/components/RenderedResult/RenderedResult.tsx +23 -8
- package/src/components/RenderedResult/ResultContainer.tsx +51 -13
- package/src/components/RenderedResult/ResultPanel.tsx +24 -5
- package/src/components/RenderedResult/loadRenderer.ts +42 -0
- package/src/components/RenderedResult/resultSizing.spec.ts +68 -0
- package/src/components/RenderedResult/resultSizing.ts +14 -3
- package/src/components/ServerProvider.tsx +2 -1
- package/src/components/UnsavedChangesDialog.spec.tsx +70 -0
- package/src/components/UnsavedChangesDialog.tsx +49 -0
- package/src/components/given/GivenInput.spec.tsx +5 -5
- package/src/components/given/GivenInput.tsx +46 -38
- package/src/components/given/GivensPanel.spec.tsx +6 -6
- package/src/components/given/GivensPanel.tsx +5 -11
- package/src/components/given/paramCodec.ts +27 -1
- package/src/components/index.ts +3 -2
- package/src/components/styles.ts +4 -5
- package/src/hooks/givenValue.ts +9 -0
- package/src/hooks/index.ts +7 -0
- package/src/hooks/useCompiledDocument.spec.tsx +86 -0
- package/src/hooks/useCompiledDocument.ts +59 -0
- package/src/hooks/useDimensionalFilterRangeData.ts +3 -1
- package/src/hooks/useDocumentControls.ts +13 -1
- package/src/hooks/useNarrowScreen.ts +21 -0
- package/src/hooks/useNearViewport.spec.tsx +150 -0
- package/src/hooks/useNearViewport.ts +102 -0
- package/src/hooks/useQueryResult.ts +23 -1
- package/src/hooks/useQueryWithApiError.ts +10 -3
- package/src/hooks/useRawQueryData.ts +3 -1
- package/src/hooks/useSettled.spec.ts +41 -0
- package/src/hooks/useSettled.ts +27 -0
- package/src/hooks/useSuggestOptions.dom.spec.ts +40 -1
- package/src/hooks/useSuggestOptions.ts +42 -10
- package/src/mainEntry.spec.ts +145 -0
- package/src/text-entry.ts +12 -0
- package/src/textEntry.spec.ts +112 -0
- package/src/theme/accent.spec.ts +116 -0
- package/src/theme/accent.ts +148 -0
- package/src/theme/buildTableCssVars.spec.ts +24 -0
- package/src/theme/buildTableCssVars.ts +1 -2
- package/src/theme/buildVegaThemeOverride.spec.ts +38 -2
- package/src/theme/buildVegaThemeOverride.ts +5 -5
- package/src/theme/defaults.ts +34 -0
- package/src/theme/index.ts +9 -0
- package/src/theme/keys.ts +6 -0
- package/src/theme/motion.ts +44 -0
- package/src/theme/readChartAnnotations.spec.ts +18 -0
- package/src/theme/readChartAnnotations.ts +1 -1
- package/src/theme/resolveTheme.spec.ts +73 -0
- package/src/theme/resolveTheme.ts +61 -20
- package/src/theme/types.ts +30 -5
- package/src/utils/clock.spec.ts +12 -0
- package/src/utils/clock.ts +6 -0
- package/src/{components/DashboardBuilder → utils}/malloyText.spec.ts +48 -0
- package/src/utils/malloyText.ts +368 -0
- package/src/utils/queryClient.ts +8 -0
- package/vite.config.ts +4 -0
- package/dist/Dashboard-ChyylkTD.cjs.js +0 -136
- package/dist/RenderedResult-AJPMUkAD.cjs.js +0 -135
- package/dist/ServerProvider-CXrOKD6g.cjs.js +0 -1
- package/dist/components/Dashboard/DashboardBar.d.ts +0 -21
- package/dist/components/Dashboard/ExploreDialog.d.ts +0 -20
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +0 -15
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +0 -20
- package/dist/components/DashboardBuilder/diff.d.ts +0 -35
- package/dist/components/DashboardBuilder/malloyText.d.ts +0 -64
- package/dist/components/Package/NewDashboardDialog.d.ts +0 -18
- package/src/components/Dashboard/DashboardBar.tsx +0 -88
- package/src/components/Dashboard/ExploreDialog.tsx +0 -89
- package/src/components/DashboardBuilder/DiffDialog.tsx +0 -122
- package/src/components/DashboardBuilder/SettingsPopover.tsx +0 -168
- package/src/components/DashboardBuilder/diff.spec.ts +0 -44
- package/src/components/DashboardBuilder/diff.ts +0 -93
- package/src/components/DashboardBuilder/malloyText.ts +0 -214
- package/src/components/Package/NewDashboardDialog.spec.tsx +0 -129
- package/src/components/Package/NewDashboardDialog.tsx +0 -265
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
cleanup,
|
|
6
|
+
fireEvent,
|
|
7
|
+
render,
|
|
8
|
+
screen,
|
|
9
|
+
waitFor,
|
|
10
|
+
within,
|
|
11
|
+
} from "@testing-library/react";
|
|
12
|
+
import { afterEach, describe, expect, it, mock } from "bun:test";
|
|
13
|
+
import { DashboardBuilder } from "./DashboardBuilder";
|
|
14
|
+
import { openDocument } from "./testing/fixtures";
|
|
15
|
+
import { editInline } from "./testing/inline";
|
|
16
|
+
import { TEXT_TILE_PLACEHOLDER } from "./TextTileBody";
|
|
17
|
+
|
|
18
|
+
const SOURCE = `## artifact { title="Storefront" tiles=[intro { kind=text colspan=12 }, "a -> by_cat", "a -> by_brand"] } dashboard { columns=12 }
|
|
19
|
+
import "../data_app.malloy"
|
|
20
|
+
|
|
21
|
+
##|(markdown) intro
|
|
22
|
+
Read [the docs](https://example.com/docs).
|
|
23
|
+
|##
|
|
24
|
+
|
|
25
|
+
source: a is scoped_orders extend {
|
|
26
|
+
# colspan=6
|
|
27
|
+
# label="By category"
|
|
28
|
+
view: by_cat is by_category
|
|
29
|
+
|
|
30
|
+
# colspan=6
|
|
31
|
+
view: by_brand is by_category
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
const catalog = {
|
|
36
|
+
sources: [
|
|
37
|
+
{
|
|
38
|
+
name: "scoped_orders",
|
|
39
|
+
modelPath: "data_app.malloy",
|
|
40
|
+
views: [{ name: "sales_by_state" }],
|
|
41
|
+
givens: [],
|
|
42
|
+
fields: [],
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const mount = async (
|
|
48
|
+
options: {
|
|
49
|
+
onSave?: (source: string) => void;
|
|
50
|
+
savesTo?: "package" | "browser" | "host";
|
|
51
|
+
saveLabel?: string;
|
|
52
|
+
} = {},
|
|
53
|
+
) => {
|
|
54
|
+
const document = await openDocument(SOURCE);
|
|
55
|
+
return render(
|
|
56
|
+
<DashboardBuilder
|
|
57
|
+
source={SOURCE}
|
|
58
|
+
document={document}
|
|
59
|
+
catalog={catalog}
|
|
60
|
+
{...(options.onSave ? { onSave: options.onSave } : {})}
|
|
61
|
+
{...(options.savesTo ? { savesTo: options.savesTo } : {})}
|
|
62
|
+
{...(options.saveLabel ? { saveLabel: options.saveLabel } : {})}
|
|
63
|
+
/>,
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const tile = (name: string) => screen.getByLabelText(`Tile ${name}`);
|
|
68
|
+
const button = (name: string) =>
|
|
69
|
+
screen.getByRole("button", { name, hidden: true });
|
|
70
|
+
const undo = () => fireEvent.click(button("Undo"));
|
|
71
|
+
|
|
72
|
+
afterEach(cleanup);
|
|
73
|
+
|
|
74
|
+
describe("click-to-edit text", () => {
|
|
75
|
+
it("selects a tile when keyboard focus lands in it, as a press does", async () => {
|
|
76
|
+
await mount();
|
|
77
|
+
fireEvent.focus(screen.getByLabelText("Settings for By category"));
|
|
78
|
+
expect(
|
|
79
|
+
screen.getByLabelText("Tile by_cat").getAttribute("aria-current"),
|
|
80
|
+
).toBe("true");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("keeps the selection when Escape cancels a title being typed", async () => {
|
|
84
|
+
await mount();
|
|
85
|
+
fireEvent.pointerDown(screen.getByLabelText("Tile by_cat"));
|
|
86
|
+
fireEvent.click(screen.getByText("By category"));
|
|
87
|
+
const field = screen.getByLabelText("Tile title");
|
|
88
|
+
fireEvent.keyDown(field, { key: "Escape" });
|
|
89
|
+
expect(
|
|
90
|
+
screen.getByLabelText("Tile by_cat").getAttribute("aria-current"),
|
|
91
|
+
).toBe("true");
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("announces the save state for a screen reader", async () => {
|
|
95
|
+
await mount({ onSave: () => {} });
|
|
96
|
+
expect(screen.getByText("All changes saved")).toBeDefined();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("selects the description or a tile, never both", async () => {
|
|
100
|
+
await mount();
|
|
101
|
+
const description = screen.getByLabelText("Description");
|
|
102
|
+
fireEvent.pointerDown(description);
|
|
103
|
+
expect(description.getAttribute("aria-current")).toBe("true");
|
|
104
|
+
fireEvent.pointerDown(screen.getByLabelText("Tile by_cat"));
|
|
105
|
+
expect(description.getAttribute("aria-current")).toBe("false");
|
|
106
|
+
expect(
|
|
107
|
+
screen.getByLabelText("Tile by_cat").getAttribute("aria-current"),
|
|
108
|
+
).toBe("true");
|
|
109
|
+
fireEvent.pointerDown(description);
|
|
110
|
+
expect(
|
|
111
|
+
screen.getByLabelText("Tile by_cat").getAttribute("aria-current"),
|
|
112
|
+
).toBe("false");
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("opens on a click, commits on Enter, and is one undo step", async () => {
|
|
116
|
+
await mount();
|
|
117
|
+
editInline("By category", "Tile title", "Revenue");
|
|
118
|
+
expect(within(tile("by_cat")).getByText("Revenue")).toBeDefined();
|
|
119
|
+
undo();
|
|
120
|
+
expect(within(tile("by_cat")).getByText("By category")).toBeDefined();
|
|
121
|
+
expect(button("Undo")).toHaveProperty("disabled", true);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("puts the old text back on Escape, with no history entry", async () => {
|
|
125
|
+
await mount();
|
|
126
|
+
editInline("By category", "Tile title", "Discarded", "Escape");
|
|
127
|
+
expect(within(tile("by_cat")).getByText("By category")).toBeDefined();
|
|
128
|
+
expect(screen.queryByLabelText("Tile title")).toBeNull();
|
|
129
|
+
expect(button("Undo")).toHaveProperty("disabled", true);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it("commits when focus leaves the field", async () => {
|
|
133
|
+
await mount();
|
|
134
|
+
fireEvent.click(screen.getByText("By category"));
|
|
135
|
+
const field = screen.getByLabelText("Tile title");
|
|
136
|
+
fireEvent.change(field, { target: { value: "Left behind" } });
|
|
137
|
+
fireEvent.blur(field);
|
|
138
|
+
expect(within(tile("by_cat")).getByText("Left behind")).toBeDefined();
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("adds no history entry for text that did not change", async () => {
|
|
142
|
+
await mount();
|
|
143
|
+
editInline("By category", "Tile title", "By category");
|
|
144
|
+
expect(button("Undo")).toHaveProperty("disabled", true);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("opens from the keyboard: the display is a tab stop that Enter and Space open", async () => {
|
|
148
|
+
await mount();
|
|
149
|
+
const display = screen.getByText("By category");
|
|
150
|
+
expect(display.tagName).toBe("BUTTON");
|
|
151
|
+
expect(display.tabIndex).toBe(0);
|
|
152
|
+
fireEvent.keyDown(display, { key: "Enter" });
|
|
153
|
+
expect(screen.getByLabelText("Tile title")).toBeDefined();
|
|
154
|
+
fireEvent.keyDown(screen.getByLabelText("Tile title"), {
|
|
155
|
+
key: "Escape",
|
|
156
|
+
});
|
|
157
|
+
fireEvent.keyDown(screen.getByText("By category"), { key: " " });
|
|
158
|
+
expect(screen.getByLabelText("Tile title")).toBeDefined();
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it("shows a placeholder for a missing subtitle and an emptied title, and removes the tag when emptied", async () => {
|
|
162
|
+
await mount();
|
|
163
|
+
expect(within(tile("by_cat")).getByText("Add a subtitle")).toBeDefined();
|
|
164
|
+
// An unlabelled tile shows the name it falls back to.
|
|
165
|
+
expect(within(tile("by_brand")).getByText("By brand")).toBeDefined();
|
|
166
|
+
editInline("By category", "Tile title", "");
|
|
167
|
+
expect(within(tile("by_cat")).getByText("By cat")).toBeDefined();
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("edits the page's title and description in place", async () => {
|
|
171
|
+
await mount();
|
|
172
|
+
editInline("Storefront", "Dashboard title", "Storefront, weekly");
|
|
173
|
+
expect(screen.getByText("Storefront, weekly")).toBeDefined();
|
|
174
|
+
fireEvent.click(screen.getByText("Add a description"));
|
|
175
|
+
const field = screen.getByLabelText("Markdown");
|
|
176
|
+
fireEvent.change(field, { target: { value: "What sold." } });
|
|
177
|
+
fireEvent.keyDown(field, { key: "Escape" });
|
|
178
|
+
expect(screen.getByText("What sold.")).toBeDefined();
|
|
179
|
+
undo();
|
|
180
|
+
expect(screen.getByText("Add a description")).toBeDefined();
|
|
181
|
+
undo();
|
|
182
|
+
expect(screen.getByText("Storefront")).toBeDefined();
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it("has no title or subtitle fields in the tile menu, and no page settings window", async () => {
|
|
186
|
+
await mount();
|
|
187
|
+
fireEvent.click(screen.getByLabelText("Settings for By category"));
|
|
188
|
+
expect(screen.queryByLabelText("Tile title")).toBeNull();
|
|
189
|
+
expect(screen.queryByLabelText("Tile subtitle")).toBeNull();
|
|
190
|
+
expect(button("Drill")).toBeDefined();
|
|
191
|
+
fireEvent.keyDown(button("Delete"), { key: "Escape" });
|
|
192
|
+
// There is no page settings window at all: the title and description
|
|
193
|
+
// are edited on the page.
|
|
194
|
+
expect(screen.queryByRole("button", { name: "Settings" })).toBeNull();
|
|
195
|
+
expect(screen.queryByLabelText("Dashboard title")).toBeNull();
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
describe("click-to-edit markdown in a text tile", () => {
|
|
200
|
+
it("opens on a click and commits on Done, as one undo step", async () => {
|
|
201
|
+
await mount();
|
|
202
|
+
fireEvent.click(within(tile("intro")).getByText(/Read/));
|
|
203
|
+
const field = screen.getByLabelText("Markdown") as HTMLTextAreaElement;
|
|
204
|
+
expect(field.selectionStart).toBe(field.value.length);
|
|
205
|
+
fireEvent.change(field, { target: { value: "# New heading" } });
|
|
206
|
+
fireEvent.click(screen.getByRole("button", { name: "Done" }));
|
|
207
|
+
expect(
|
|
208
|
+
within(tile("intro")).getByRole("heading", { name: "New heading" }),
|
|
209
|
+
).toBeDefined();
|
|
210
|
+
undo();
|
|
211
|
+
expect(within(tile("intro")).getByText(/Read/)).toBeDefined();
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it("keeps its editor open on a draft the writer would refuse, and says why", async () => {
|
|
215
|
+
await mount();
|
|
216
|
+
fireEvent.click(within(tile("intro")).getByText(/Read/));
|
|
217
|
+
const field = screen.getByLabelText("Markdown");
|
|
218
|
+
fireEvent.change(field, { target: { value: "a\n|## b" } });
|
|
219
|
+
expect(screen.getByText(/close the text early/)).toBeDefined();
|
|
220
|
+
expect(
|
|
221
|
+
screen.getByRole("button", { name: "Done" }).hasAttribute("disabled"),
|
|
222
|
+
).toBe(true);
|
|
223
|
+
// Escape is Done, which holds.
|
|
224
|
+
fireEvent.keyDown(field, { key: "Escape" });
|
|
225
|
+
expect(screen.getByLabelText("Markdown")).toBeDefined();
|
|
226
|
+
fireEvent.change(field, { target: { value: "fine" } });
|
|
227
|
+
fireEvent.keyDown(field, { key: "Escape" });
|
|
228
|
+
expect(screen.queryByLabelText("Markdown")).toBeNull();
|
|
229
|
+
expect(within(tile("intro")).getByText("fine")).toBeDefined();
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it("Cancel drops the draft", async () => {
|
|
233
|
+
await mount();
|
|
234
|
+
fireEvent.click(within(tile("intro")).getByText(/Read/));
|
|
235
|
+
fireEvent.change(screen.getByLabelText("Markdown"), {
|
|
236
|
+
target: { value: "dropped" },
|
|
237
|
+
});
|
|
238
|
+
fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
|
|
239
|
+
expect(within(tile("intro")).queryByText("dropped")).toBeNull();
|
|
240
|
+
expect(button("Undo")).toHaveProperty("disabled", true);
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
it("opens from the keyboard, and leaves a link inert", async () => {
|
|
244
|
+
await mount();
|
|
245
|
+
const display = within(tile("intro")).getByRole("button", {
|
|
246
|
+
name: /Read/,
|
|
247
|
+
});
|
|
248
|
+
expect(display.tabIndex).toBe(0);
|
|
249
|
+
// A link neither navigates nor opens the editor.
|
|
250
|
+
const link = within(tile("intro")).getByRole("link", {
|
|
251
|
+
name: "the docs",
|
|
252
|
+
});
|
|
253
|
+
expect(fireEvent.click(link)).toBe(false);
|
|
254
|
+
expect(screen.queryByLabelText("Markdown")).toBeNull();
|
|
255
|
+
fireEvent.keyDown(display, { key: "Enter" });
|
|
256
|
+
expect(screen.getByLabelText("Markdown")).toBeDefined();
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it("shows the hint in an empty tile, and the edit survives a save", async () => {
|
|
260
|
+
let written: string | undefined;
|
|
261
|
+
await mount({
|
|
262
|
+
onSave: (source) => {
|
|
263
|
+
written = source;
|
|
264
|
+
},
|
|
265
|
+
});
|
|
266
|
+
fireEvent.click(button("Add tile"));
|
|
267
|
+
fireEvent.click(screen.getByRole("button", { name: "Text" }));
|
|
268
|
+
fireEvent.click(screen.getByRole("button", { name: "Add text" }));
|
|
269
|
+
fireEvent.click(within(tile("text_1")).getByText(TEXT_TILE_PLACEHOLDER));
|
|
270
|
+
const field = screen.getByLabelText("Markdown");
|
|
271
|
+
expect(field.getAttribute("placeholder")).toBe(TEXT_TILE_PLACEHOLDER);
|
|
272
|
+
fireEvent.change(field, { target: { value: "Typed in place" } });
|
|
273
|
+
fireEvent.keyDown(field, { key: "Escape" });
|
|
274
|
+
|
|
275
|
+
fireEvent.click(button("Save"));
|
|
276
|
+
await waitFor(() => expect(written).toBeDefined());
|
|
277
|
+
expect(written).toContain("##|(markdown) text_1\nTyped in place\n|##");
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
describe("the save shortcut inside a markdown field", () => {
|
|
282
|
+
it("saves the open draft, not the text before it", async () => {
|
|
283
|
+
let written: string | undefined;
|
|
284
|
+
await mount({
|
|
285
|
+
onSave: (source) => {
|
|
286
|
+
written = source;
|
|
287
|
+
},
|
|
288
|
+
});
|
|
289
|
+
fireEvent.click(
|
|
290
|
+
within(tile("intro")).getByRole("button", { name: /Read/ }),
|
|
291
|
+
);
|
|
292
|
+
const field = screen.getByLabelText("Markdown");
|
|
293
|
+
field.focus();
|
|
294
|
+
fireEvent.change(field, { target: { value: "Drafted, never closed" } });
|
|
295
|
+
fireEvent.keyDown(field, { key: "s", ctrlKey: true, metaKey: true });
|
|
296
|
+
await waitFor(() => expect(written).toBeDefined());
|
|
297
|
+
expect(written).toContain(
|
|
298
|
+
"##|(markdown) intro\nDrafted, never closed\n|##",
|
|
299
|
+
);
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
describe("undo and redo point at the tile they changed", () => {
|
|
304
|
+
it("scrolls to it and lights it briefly, for the buttons and the keyboard", async () => {
|
|
305
|
+
const scrolled = mock((_options?: unknown) => {});
|
|
306
|
+
const original = HTMLElement.prototype.scrollIntoView;
|
|
307
|
+
HTMLElement.prototype.scrollIntoView = scrolled;
|
|
308
|
+
try {
|
|
309
|
+
await mount();
|
|
310
|
+
editInline("By category", "Tile title", "Revenue");
|
|
311
|
+
expect(tile("by_cat").hasAttribute("data-flash")).toBe(false);
|
|
312
|
+
undo();
|
|
313
|
+
expect(tile("by_cat").getAttribute("data-flash")).toBe("true");
|
|
314
|
+
expect(scrolled).toHaveBeenCalledTimes(1);
|
|
315
|
+
expect(tile("by_brand").hasAttribute("data-flash")).toBe(false);
|
|
316
|
+
|
|
317
|
+
fireEvent.click(button("Redo"));
|
|
318
|
+
expect(scrolled).toHaveBeenCalledTimes(2);
|
|
319
|
+
fireEvent.keyDown(window, {
|
|
320
|
+
key: "z",
|
|
321
|
+
ctrlKey: true,
|
|
322
|
+
metaKey: true,
|
|
323
|
+
});
|
|
324
|
+
expect(scrolled).toHaveBeenCalledTimes(3);
|
|
325
|
+
await waitFor(() =>
|
|
326
|
+
expect(tile("by_cat").hasAttribute("data-flash")).toBe(true),
|
|
327
|
+
);
|
|
328
|
+
} finally {
|
|
329
|
+
HTMLElement.prototype.scrollIntoView = original;
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
it("copes with a browser that cannot scroll", async () => {
|
|
334
|
+
await mount();
|
|
335
|
+
editInline("By category", "Tile title", "Revenue");
|
|
336
|
+
undo();
|
|
337
|
+
expect(tile("by_cat").getAttribute("data-flash")).toBe("true");
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
describe("the save target", () => {
|
|
342
|
+
/** Save's tooltip text, once hovered. */
|
|
343
|
+
const saveTooltip = async () => {
|
|
344
|
+
fireEvent.mouseOver(screen.getByRole("button", { name: /Save/ }));
|
|
345
|
+
return (await screen.findByRole("tooltip")).textContent;
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
it("is Save's tooltip", async () => {
|
|
349
|
+
await mount({ onSave: () => {} });
|
|
350
|
+
expect(await saveTooltip()).toBe("Saves to the package file");
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
it("is the workspace's own words when it supplies them", async () => {
|
|
354
|
+
await mount({
|
|
355
|
+
onSave: () => {},
|
|
356
|
+
savesTo: "host",
|
|
357
|
+
saveLabel: "Saved to this draft",
|
|
358
|
+
});
|
|
359
|
+
expect(await saveTooltip()).toBe("Saved to this draft");
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
it("is a generic line, without the word host, when the workspace says nothing", async () => {
|
|
363
|
+
await mount({ onSave: () => {}, savesTo: "host" });
|
|
364
|
+
const text = await saveTooltip();
|
|
365
|
+
expect(text).toBe("Saves to the app this is embedded in");
|
|
366
|
+
expect(text).not.toMatch(/host/i);
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
it("is absent when there is nowhere to save", async () => {
|
|
370
|
+
await mount();
|
|
371
|
+
expect(screen.queryByRole("button", { name: /^Save/ })).toBeNull();
|
|
372
|
+
});
|
|
373
|
+
});
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
act,
|
|
6
|
+
cleanup,
|
|
7
|
+
fireEvent,
|
|
8
|
+
render,
|
|
9
|
+
screen,
|
|
10
|
+
waitFor,
|
|
11
|
+
} from "@testing-library/react";
|
|
12
|
+
import { afterEach, describe, expect, it, mock } from "bun:test";
|
|
13
|
+
import * as fs from "fs";
|
|
14
|
+
import * as path from "path";
|
|
15
|
+
import { DashboardBuilder } from "./DashboardBuilder";
|
|
16
|
+
import { readForEditor } from "./readForEditor";
|
|
17
|
+
import { openDocument } from "./testing/fixtures";
|
|
18
|
+
import type { BuilderEvent } from "./telemetry";
|
|
19
|
+
import { editInline } from "./testing/inline";
|
|
20
|
+
|
|
21
|
+
const NOTEBOOK = `## artifact { kind=notebook title="Review" tiles=[intro { kind=text }, "a -> by_cat"] }
|
|
22
|
+
import "../data_app.malloy"
|
|
23
|
+
|
|
24
|
+
##|(markdown) intro
|
|
25
|
+
Hello.
|
|
26
|
+
|##
|
|
27
|
+
|
|
28
|
+
source: a is scoped_orders extend {
|
|
29
|
+
view: by_cat is by_category
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
const WIDE = NOTEBOOK.replace(
|
|
34
|
+
" view: by_cat",
|
|
35
|
+
" # colspan=6\n view: by_cat",
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const DASHBOARD = `## artifact { title="Storefront" tiles=["a -> by_cat"] } dashboard { columns=12 }
|
|
39
|
+
import "../data_app.malloy"
|
|
40
|
+
|
|
41
|
+
source: a is scoped_orders extend {
|
|
42
|
+
# colspan=12
|
|
43
|
+
view: by_cat is by_category
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
const catalog = {
|
|
48
|
+
sources: [
|
|
49
|
+
{
|
|
50
|
+
name: "scoped_orders",
|
|
51
|
+
modelPath: "data_app.malloy",
|
|
52
|
+
views: [{ name: "sales_by_state" }],
|
|
53
|
+
givens: [],
|
|
54
|
+
fields: [],
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const REPO = path.resolve(import.meta.dir, "../../../../..");
|
|
60
|
+
const LEGACY = fs
|
|
61
|
+
.readFileSync(
|
|
62
|
+
path.join(REPO, "examples/storefront/notebooks/category-review.malloy"),
|
|
63
|
+
"utf8",
|
|
64
|
+
)
|
|
65
|
+
.replace(/\r\n/g, "\n");
|
|
66
|
+
|
|
67
|
+
const button = (name: string) =>
|
|
68
|
+
screen.getByRole("button", { name, hidden: true });
|
|
69
|
+
|
|
70
|
+
afterEach(cleanup);
|
|
71
|
+
|
|
72
|
+
const mountText = async (
|
|
73
|
+
source: string,
|
|
74
|
+
options: {
|
|
75
|
+
onSave?: (source: string) => void;
|
|
76
|
+
onEvent?: (event: BuilderEvent) => void;
|
|
77
|
+
withCatalog?: boolean;
|
|
78
|
+
} = {},
|
|
79
|
+
) =>
|
|
80
|
+
render(
|
|
81
|
+
<DashboardBuilder
|
|
82
|
+
source={source}
|
|
83
|
+
document={await openDocument(source)}
|
|
84
|
+
{...(options.withCatalog ? { catalog } : {})}
|
|
85
|
+
{...(options.onSave ? { onSave: options.onSave } : {})}
|
|
86
|
+
{...(options.onEvent ? { onEvent: options.onEvent } : {})}
|
|
87
|
+
/>,
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
describe("DashboardBuilder: a notebook is one column", () => {
|
|
91
|
+
it("draws its text and description bare, as the notebook reader does", async () => {
|
|
92
|
+
await mountText(NOTEBOOK);
|
|
93
|
+
for (const card of document.querySelectorAll("[data-chrome]"))
|
|
94
|
+
expect(card.getAttribute("data-chrome")).toBe("none");
|
|
95
|
+
expect(document.querySelectorAll("[data-chrome]").length).toBeGreaterThan(
|
|
96
|
+
0,
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("offers no width: no resize edge, no width presets", async () => {
|
|
101
|
+
await mountText(NOTEBOOK);
|
|
102
|
+
expect(
|
|
103
|
+
screen.queryByRole("separator", { name: /^Width of / }),
|
|
104
|
+
).toBeNull();
|
|
105
|
+
fireEvent.click(screen.getByLabelText("Settings for intro"));
|
|
106
|
+
expect(screen.queryByRole("button", { name: "Width ½" })).toBeNull();
|
|
107
|
+
fireEvent.click(screen.getByLabelText("Settings for by_cat"));
|
|
108
|
+
expect(screen.queryByRole("button", { name: "Width ½" })).toBeNull();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("does not nudge a width with the arrow keys", async () => {
|
|
112
|
+
// A width left in the file by hand is not the builder's to rewrite.
|
|
113
|
+
await mountText(WIDE, { onSave: () => {} });
|
|
114
|
+
fireEvent.click(screen.getByLabelText("Tile by_cat"));
|
|
115
|
+
fireEvent.keyDown(window, { key: "ArrowLeft" });
|
|
116
|
+
fireEvent.keyDown(window, { key: "ArrowRight" });
|
|
117
|
+
expect(button("Saved")).toBeDefined();
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("adds a tile without a width, and never writes columns", async () => {
|
|
121
|
+
let written: string | undefined;
|
|
122
|
+
await mountText(NOTEBOOK, {
|
|
123
|
+
withCatalog: true,
|
|
124
|
+
onSave: (source) => {
|
|
125
|
+
written = source;
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
fireEvent.click(button("Add tile"));
|
|
129
|
+
expect(screen.queryByLabelText("Tile width")).toBeNull();
|
|
130
|
+
fireEvent.click(screen.getByLabelText("View sales_by_state"));
|
|
131
|
+
fireEvent.click(screen.getByRole("button", { name: "Add tile" }));
|
|
132
|
+
fireEvent.click(button("Save"));
|
|
133
|
+
await waitFor(() => expect(written).toBeDefined());
|
|
134
|
+
expect(written).toContain("view: sales_by_state_tile is sales_by_state");
|
|
135
|
+
expect(written).not.toContain("colspan");
|
|
136
|
+
expect(written).not.toContain("columns");
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it("describes the Add tile dialog the same way for either kind", async () => {
|
|
140
|
+
await mountText(NOTEBOOK, { withCatalog: true });
|
|
141
|
+
fireEvent.click(button("Add tile"));
|
|
142
|
+
expect(
|
|
143
|
+
screen.getByText("A tile shows one view of a source in this package."),
|
|
144
|
+
).toBeDefined();
|
|
145
|
+
cleanup();
|
|
146
|
+
|
|
147
|
+
await mountText(DASHBOARD, { withCatalog: true });
|
|
148
|
+
fireEvent.click(button("Add tile"));
|
|
149
|
+
expect(
|
|
150
|
+
screen.getByText("A tile shows one view of a source in this package."),
|
|
151
|
+
).toBeDefined();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it("inserts a tile between two tiles from the + on the edge between them", async () => {
|
|
155
|
+
let written: string | undefined;
|
|
156
|
+
await mountText(NOTEBOOK, {
|
|
157
|
+
withCatalog: true,
|
|
158
|
+
onSave: (source) => {
|
|
159
|
+
written = source;
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
fireEvent.click(screen.getByLabelText("Insert tile after intro"));
|
|
163
|
+
fireEvent.click(screen.getByRole("button", { name: "Text" }));
|
|
164
|
+
fireEvent.click(screen.getByRole("button", { name: "Add text" }));
|
|
165
|
+
fireEvent.click(button("Save"));
|
|
166
|
+
await waitFor(() => expect(written).toBeDefined());
|
|
167
|
+
expect(written).toContain(
|
|
168
|
+
'tiles=[intro { kind=text }, text_1 { kind=text }, "a -> by_cat"]',
|
|
169
|
+
);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("adds a tile at the end from the section-level +", async () => {
|
|
173
|
+
let written: string | undefined;
|
|
174
|
+
await mountText(NOTEBOOK, {
|
|
175
|
+
withCatalog: true,
|
|
176
|
+
onSave: (source) => {
|
|
177
|
+
written = source;
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
fireEvent.click(screen.getByLabelText("Insert tile after intro"));
|
|
181
|
+
fireEvent.keyDown(screen.getByRole("dialog"), { key: "Escape" });
|
|
182
|
+
fireEvent.click(screen.getByLabelText("Add tile at the end"));
|
|
183
|
+
fireEvent.click(screen.getByRole("button", { name: "Text" }));
|
|
184
|
+
fireEvent.click(screen.getByRole("button", { name: "Add text" }));
|
|
185
|
+
fireEvent.click(button("Save"));
|
|
186
|
+
await waitFor(() => expect(written).toBeDefined());
|
|
187
|
+
expect(written).toContain(
|
|
188
|
+
'tiles=[intro { kind=text }, "a -> by_cat", text_1 { kind=text }]',
|
|
189
|
+
);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it("offers no insert + in a dashboard, where position is a grid cell", async () => {
|
|
193
|
+
await mountText(DASHBOARD, { withCatalog: true });
|
|
194
|
+
expect(screen.queryByLabelText(/^Insert tile after/)).toBeNull();
|
|
195
|
+
expect(screen.queryByLabelText("Add tile at the end")).toBeNull();
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it("reports notebook events, with the cell count", async () => {
|
|
199
|
+
const onEvent = mock((_event: BuilderEvent) => {});
|
|
200
|
+
await mountText(NOTEBOOK, { onSave: () => {}, onEvent });
|
|
201
|
+
editInline("By cat", "Tile title", "Categories");
|
|
202
|
+
fireEvent.click(button("Save"));
|
|
203
|
+
await waitFor(() => expect(onEvent).toHaveBeenCalledTimes(1));
|
|
204
|
+
expect(onEvent.mock.calls[0][0]).toMatchObject({
|
|
205
|
+
type: "notebook.saved",
|
|
206
|
+
cells: 2,
|
|
207
|
+
structural: false,
|
|
208
|
+
converted: false,
|
|
209
|
+
where: "package",
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
describe("DashboardBuilder: a document's kind", () => {
|
|
215
|
+
it("is fixed once created: there is no switch between dashboard and notebook", async () => {
|
|
216
|
+
await mountText(DASHBOARD, { onSave: () => {} });
|
|
217
|
+
expect(screen.queryByRole("button", { name: "Settings" })).toBeNull();
|
|
218
|
+
expect(screen.queryByLabelText("Show as")).toBeNull();
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
describe("DashboardBuilder: a notebook in the cell format", () => {
|
|
223
|
+
const open = async (
|
|
224
|
+
options: {
|
|
225
|
+
onSave?: (source: string) => void;
|
|
226
|
+
onEvent?: (event: BuilderEvent) => void;
|
|
227
|
+
onDirtyChange?: (dirty: boolean) => void;
|
|
228
|
+
} = {},
|
|
229
|
+
) => {
|
|
230
|
+
const result = await readForEditor(LEGACY);
|
|
231
|
+
if (result.ok === false) throw new Error(result.reason);
|
|
232
|
+
if (!result.conversion) throw new Error("expected a conversion");
|
|
233
|
+
render(
|
|
234
|
+
<DashboardBuilder
|
|
235
|
+
source={LEGACY}
|
|
236
|
+
document={result.document}
|
|
237
|
+
conversion={result.conversion}
|
|
238
|
+
{...options}
|
|
239
|
+
/>,
|
|
240
|
+
);
|
|
241
|
+
return result.conversion;
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
it("opens unsaved, says what Save does, and is not edited", async () => {
|
|
245
|
+
const onDirtyChange = mock((_dirty: boolean) => {});
|
|
246
|
+
await open({ onSave: () => {}, onDirtyChange });
|
|
247
|
+
expect(
|
|
248
|
+
screen.getByText(
|
|
249
|
+
/This notebook is in the cell format\. Saving rewrites it as a layout notebook, and a named query run once becomes that tile's view\./,
|
|
250
|
+
),
|
|
251
|
+
).toBeDefined();
|
|
252
|
+
expect(button("Save")).toBeDefined();
|
|
253
|
+
// Each tile says why it has no preview yet, beside the view it will run.
|
|
254
|
+
expect(
|
|
255
|
+
screen.getAllByText("Preview appears after you Save"),
|
|
256
|
+
).toHaveLength(3);
|
|
257
|
+
expect(
|
|
258
|
+
screen.getByText("order_items_tiles → revenue_by_month"),
|
|
259
|
+
).toBeDefined();
|
|
260
|
+
// No edit has been made, so a host guarding navigation is told so.
|
|
261
|
+
expect(onDirtyChange).toHaveBeenLastCalledWith(false);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it("asks before Save converts the file, and writes it once confirmed", async () => {
|
|
265
|
+
const writes: string[] = [];
|
|
266
|
+
await open({ onSave: (source) => void writes.push(source) });
|
|
267
|
+
fireEvent.click(button("Save"));
|
|
268
|
+
expect(
|
|
269
|
+
await screen.findByText(
|
|
270
|
+
/Saving rewrites this notebook in the tile layout/,
|
|
271
|
+
),
|
|
272
|
+
).toBeDefined();
|
|
273
|
+
expect(writes).toHaveLength(0);
|
|
274
|
+
fireEvent.click(button("Convert and save"));
|
|
275
|
+
await waitFor(() => expect(writes).toHaveLength(1));
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
it("writes nothing when the conversion is cancelled", async () => {
|
|
279
|
+
const writes: string[] = [];
|
|
280
|
+
await open({ onSave: (source) => void writes.push(source) });
|
|
281
|
+
fireEvent.click(button("Save"));
|
|
282
|
+
fireEvent.click(await screen.findByRole("button", { name: "Cancel" }));
|
|
283
|
+
await act(async () => {});
|
|
284
|
+
expect(writes).toHaveLength(0);
|
|
285
|
+
expect(button("Save")).toBeDefined();
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it("saves the conversion exactly as converted", async () => {
|
|
289
|
+
const writes: string[] = [];
|
|
290
|
+
const onEvent = mock((_event: BuilderEvent) => {});
|
|
291
|
+
const conversion = await open({
|
|
292
|
+
onSave: (source) => void writes.push(source),
|
|
293
|
+
onEvent,
|
|
294
|
+
});
|
|
295
|
+
fireEvent.click(button("Save"));
|
|
296
|
+
fireEvent.click(
|
|
297
|
+
await screen.findByRole("button", { name: "Convert and save" }),
|
|
298
|
+
);
|
|
299
|
+
await waitFor(() => expect(writes).toHaveLength(1));
|
|
300
|
+
// Nothing was edited, so the file written is the conversion itself.
|
|
301
|
+
expect(writes[0]).toBe(conversion.to);
|
|
302
|
+
expect(onEvent.mock.calls[0][0]).toMatchObject({
|
|
303
|
+
type: "notebook.saved",
|
|
304
|
+
converted: true,
|
|
305
|
+
});
|
|
306
|
+
expect(
|
|
307
|
+
screen.queryByText(/This notebook is in the cell format/),
|
|
308
|
+
).toBeNull();
|
|
309
|
+
});
|
|
310
|
+
});
|