@malloy-publisher/sdk 0.9.2 → 0.9.4
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-CBLHr32C.es.js → RenderedResult-DwB0-9Yx.es.js} +118 -119
- package/dist/{RenderedResult-B48wAjM8.cjs.js → RenderedResult-hKjFEqaN.cjs.js} +2 -2
- package/dist/{ServerProvider-DCV8BUWD.es.js → ServerProvider-CcSrGaRN.es.js} +1281 -1142
- package/dist/ServerProvider-Gbf1YPOP.cjs.js +1 -0
- package/dist/builder/index.cjs.js +112 -115
- package/dist/builder/index.es.js +11766 -11502
- package/dist/builder-entry.d.ts +1 -1
- package/dist/client/api.d.ts +170 -9
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +93 -89
- 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/DashboardGrid.d.ts +18 -3
- package/dist/components/Dashboard/DashboardTile.d.ts +12 -2
- package/dist/components/Dashboard/DashboardView.d.ts +38 -3
- package/dist/components/Dashboard/TileCard.d.ts +16 -2
- package/dist/components/Dashboard/dropValueUrlTags.d.ts +6 -0
- package/dist/components/Dashboard/index.d.ts +3 -2
- package/dist/components/Dashboard/telemetry.d.ts +2 -1
- package/dist/components/Dashboard/textSource.d.ts +19 -0
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +7 -8
- 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 +14 -17
- package/dist/components/DashboardBuilder/ChartPicker.d.ts +3 -1
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +15 -7
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +28 -2
- package/dist/components/DashboardBuilder/EditorSurface.d.ts +33 -0
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +6 -4
- package/dist/components/DashboardBuilder/InlineText.d.ts +1 -1
- package/dist/components/DashboardBuilder/NotebookEditor.d.ts +1 -1
- package/dist/components/DashboardBuilder/TextTileBody.d.ts +4 -1
- package/dist/components/DashboardBuilder/TileFrame.d.ts +43 -6
- package/dist/components/DashboardBuilder/TileMenu.d.ts +6 -8
- package/dist/components/DashboardBuilder/builderReport.d.ts +13 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +0 -18
- package/dist/components/DashboardBuilder/documentSession.d.ts +2 -2
- package/dist/components/DashboardBuilder/imports.d.ts +19 -0
- package/dist/components/DashboardBuilder/inlineEdit.d.ts +18 -0
- package/dist/components/DashboardBuilder/readDocument.d.ts +3 -1
- package/dist/components/DashboardBuilder/readForEditor.d.ts +1 -1
- package/dist/components/DashboardBuilder/sortable.d.ts +2 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +2 -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 +4 -7
- 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 +2 -0
- package/dist/components/DashboardBuilder/useDraft.d.ts +3 -1
- 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 +32 -0
- package/dist/components/Loading.d.ts +13 -0
- package/dist/components/Notebook/NotebookCell.d.ts +1 -5
- package/dist/components/Package/Package.d.ts +16 -1
- package/dist/components/Package/index.d.ts +1 -1
- package/dist/components/Prose.d.ts +1 -1
- package/dist/components/RenderedResult/loadRenderer.d.ts +7 -0
- package/dist/components/given/paramCodec.d.ts +8 -1
- package/dist/components/index.d.ts +1 -2
- package/dist/components/styles.d.ts +4 -4
- package/dist/hooks/givenValue.d.ts +6 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useCompiledDocument.d.ts +23 -0
- package/dist/hooks/useDocumentControls.d.ts +6 -1
- package/dist/hooks/useNearViewport.d.ts +16 -0
- package/dist/hooks/useQueryWithApiError.d.ts +7 -2
- package/dist/hooks/useSuggestOptions.d.ts +9 -2
- package/dist/index.cjs.js +14 -14
- package/dist/index.es.js +9760 -10363
- package/dist/text/index.es.js +1 -1
- package/dist/{text-entry-CbbBcZl8.es.js → text-entry-CA0LZ1xL.es.js} +8 -8
- package/dist/text-entry.d.ts +1 -1
- 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/{DashboardTile-BFcxdv7R.es.js → useCompiledDocument-BU6d8FPp.es.js} +6978 -6289
- package/dist/useCompiledDocument-pOg2W-Yt.cjs.js +142 -0
- package/package.json +11 -11
- package/src/builder-entry.ts +1 -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 +2 -2
- package/src/components/Dashboard/DashboardGrid.tsx +23 -5
- package/src/components/Dashboard/DashboardTile.spec.tsx +97 -2
- package/src/components/Dashboard/DashboardTile.tsx +95 -31
- package/src/components/Dashboard/DashboardView.spec.tsx +156 -0
- package/src/components/Dashboard/DashboardView.tsx +165 -89
- package/src/components/Dashboard/RowsDialog.tsx +3 -2
- package/src/components/Dashboard/TileCard.tsx +17 -2
- package/src/components/Dashboard/dropValueUrlTags.spec.ts +177 -0
- package/src/components/Dashboard/dropValueUrlTags.ts +108 -0
- package/src/components/Dashboard/index.ts +11 -2
- package/src/components/Dashboard/telemetry.ts +2 -1
- package/src/components/Dashboard/textSource.spec.ts +36 -0
- package/src/components/Dashboard/textSource.ts +39 -0
- package/src/components/DashboardBuilder/AddTileDialog.tsx +16 -56
- 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 +86 -113
- package/src/components/DashboardBuilder/ChartPicker.tsx +4 -1
- package/src/components/DashboardBuilder/DashboardBuilder.charts.spec.tsx +5 -5
- package/src/components/DashboardBuilder/DashboardBuilder.exit.spec.tsx +74 -83
- package/src/components/DashboardBuilder/DashboardBuilder.inline.spec.tsx +62 -18
- package/src/components/DashboardBuilder/DashboardBuilder.notebook.spec.tsx +55 -108
- package/src/components/DashboardBuilder/DashboardBuilder.openDraft.spec.tsx +10 -62
- package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +50 -57
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +53 -40
- package/src/components/DashboardBuilder/DashboardBuilder.textTiles.spec.tsx +10 -8
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +227 -704
- package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +32 -52
- package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +1 -50
- package/src/components/DashboardBuilder/DashboardEditor.notebook.spec.tsx +12 -18
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +4 -24
- package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +4 -4
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +8 -13
- package/src/components/DashboardBuilder/DashboardEditor.textSource.spec.tsx +317 -0
- package/src/components/DashboardBuilder/DashboardEditor.tsx +142 -820
- package/src/components/DashboardBuilder/DrillDialog.tsx +2 -2
- package/src/components/DashboardBuilder/EditorSurface.tsx +471 -0
- package/src/components/DashboardBuilder/FilterDialog.tsx +13 -8
- package/src/components/DashboardBuilder/FilterStrip.tsx +117 -79
- package/src/components/DashboardBuilder/InlineMarkdown.tsx +7 -9
- package/src/components/DashboardBuilder/InlineText.tsx +23 -17
- package/src/components/DashboardBuilder/NotebookEditor.tsx +3 -3
- package/src/components/DashboardBuilder/TextTileBody.tsx +5 -2
- package/src/components/DashboardBuilder/TileFrame.tsx +255 -90
- package/src/components/DashboardBuilder/TileMenu.tsx +41 -91
- package/src/components/DashboardBuilder/artifactBlock.spec.ts +1 -1
- package/src/components/DashboardBuilder/artifactTagParity.spec.ts +9 -4
- package/src/components/DashboardBuilder/builderReport.ts +74 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +0 -44
- package/src/components/DashboardBuilder/catalog.ts +0 -36
- package/src/components/DashboardBuilder/controls.spec.ts +1 -1
- package/src/components/DashboardBuilder/controls.ts +1 -1
- package/src/components/DashboardBuilder/documentSession.ts +3 -2
- 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/legacyNotebook.ts +1 -1
- package/src/components/DashboardBuilder/malloyTree.ts +5 -1
- package/src/components/DashboardBuilder/newDashboard.ts +1 -1
- package/src/components/DashboardBuilder/preview.ts +1 -1
- package/src/components/DashboardBuilder/readDocument.spec.ts +36 -0
- package/src/components/DashboardBuilder/readDocument.ts +10 -4
- package/src/components/DashboardBuilder/readForEditor.ts +7 -2
- package/src/components/DashboardBuilder/sortable.spec.ts +25 -1
- package/src/components/DashboardBuilder/sortable.tsx +11 -0
- package/src/components/DashboardBuilder/spliceDocument.ts +8 -3
- package/src/components/DashboardBuilder/testing/artifactTagParity.json +62 -6
- package/src/components/DashboardBuilder/testing/documentKindRule.json +40 -0
- package/src/components/DashboardBuilder/testing/inline.ts +1 -1
- 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 +43 -1
- package/src/components/DashboardBuilder/tileDisplayTitle.ts +13 -0
- package/src/components/DashboardBuilder/useBuilderSelection.ts +121 -0
- package/src/components/DashboardBuilder/useBuilderSession.spec.ts +0 -85
- package/src/components/DashboardBuilder/useBuilderSession.ts +6 -43
- package/src/components/DashboardBuilder/useBuilderShortcuts.overlay.spec.tsx +32 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +11 -1
- package/src/components/DashboardBuilder/useControlBindings.ts +152 -0
- package/src/components/DashboardBuilder/useConversionConfirm.ts +55 -0
- package/src/components/DashboardBuilder/useDashboardEditor.ts +5 -2
- package/src/components/DashboardBuilder/useDraft.ts +15 -2
- 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/useTileResize.spec.tsx +146 -0
- package/src/components/DashboardBuilder/useTileResize.ts +133 -0
- package/src/components/DataAppViewer/DataAppViewer.tsx +7 -4
- package/src/components/DocumentCreate/guards.ts +1 -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.tsx +2 -2
- package/src/components/Notebook/Notebook.tsx +6 -2
- package/src/components/Notebook/NotebookCell.tsx +90 -215
- package/src/components/Package/Package.artifacts.spec.tsx +8 -12
- package/src/components/Package/Package.create.spec.tsx +22 -1
- package/src/components/Package/Package.tsx +51 -27
- package/src/components/Package/index.ts +1 -1
- package/src/components/Prose.spec.tsx +37 -0
- package/src/components/Prose.tsx +35 -5
- package/src/components/RenderedResult/RenderedResult.tsx +5 -7
- package/src/components/RenderedResult/ResultContainer.tsx +7 -2
- package/src/components/RenderedResult/ResultPanel.tsx +20 -5
- package/src/components/RenderedResult/loadRenderer.ts +42 -0
- package/src/components/given/GivenInput.spec.tsx +5 -5
- package/src/components/given/GivenInput.tsx +46 -38
- package/src/components/given/GivensPanel.tsx +2 -8
- package/src/components/given/paramCodec.ts +27 -1
- package/src/components/index.ts +1 -2
- package/src/components/styles.ts +4 -5
- package/src/hooks/givenValue.ts +9 -0
- package/src/hooks/index.ts +4 -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/useNearViewport.spec.tsx +150 -0
- package/src/hooks/useNearViewport.ts +102 -0
- package/src/hooks/useQueryResult.ts +7 -1
- package/src/hooks/useQueryWithApiError.ts +10 -3
- package/src/hooks/useRawQueryData.ts +3 -1
- package/src/hooks/useSuggestOptions.dom.spec.ts +40 -1
- package/src/hooks/useSuggestOptions.ts +42 -10
- package/src/text-entry.ts +1 -1
- package/src/textEntry.spec.ts +2 -8
- 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/queryClient.ts +8 -0
- package/dist/DashboardTile-sg8LjUk8.cjs.js +0 -137
- package/dist/ServerProvider-HRqT3w1C.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 -7
- package/dist/components/DashboardBuilder/SaveNotice.d.ts +0 -27
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +0 -32
- package/dist/components/DashboardBuilder/diff.d.ts +0 -35
- package/src/components/Dashboard/DashboardBar.tsx +0 -88
- package/src/components/Dashboard/ExploreDialog.tsx +0 -89
- package/src/components/DashboardBuilder/DashboardBuilder.notice.spec.tsx +0 -194
- package/src/components/DashboardBuilder/DiffDialog.spec.tsx +0 -25
- package/src/components/DashboardBuilder/DiffDialog.tsx +0 -103
- package/src/components/DashboardBuilder/SaveNotice.tsx +0 -113
- package/src/components/DashboardBuilder/SettingsPopover.spec.tsx +0 -87
- package/src/components/DashboardBuilder/SettingsPopover.tsx +0 -326
- package/src/components/DashboardBuilder/diff.spec.ts +0 -44
- package/src/components/DashboardBuilder/diff.ts +0 -93
- /package/dist/{components/DashboardBuilder → utils}/malloyText.d.ts +0 -0
- /package/src/{components/DashboardBuilder → utils}/malloyText.spec.ts +0 -0
- /package/src/{components/DashboardBuilder → utils}/malloyText.ts +0 -0
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { PointerEvent, ReactNode } from 'react';
|
|
2
|
+
import { Theme } from '@mui/material';
|
|
3
|
+
import { SystemStyleObject } from '@mui/system';
|
|
4
|
+
import { ResolvedTheme } from '../../theme/types';
|
|
5
|
+
import { TileChrome, TileHeadingSlots } from '../Dashboard/TileCard';
|
|
3
6
|
import { DashboardTile, QueryTile } from './document';
|
|
4
7
|
/**
|
|
5
|
-
* Everything the builder draws AROUND a tile: the selection outline, the
|
|
6
|
-
* the
|
|
8
|
+
* Everything the builder draws AROUND a tile: the selection outline, the menu
|
|
9
|
+
* button, the handle at the right edge and, in a notebook, the insert button. The tile
|
|
7
10
|
* itself is `children` — the host's real `DashboardTile`, or a placeholder
|
|
8
11
|
* saying what the tile will run.
|
|
9
12
|
*/
|
|
10
|
-
export declare function TileFrame({ tile, index, selected, flash, menuOpen, onInsertAfter, onSelect, onOpenMenu, children, }: {
|
|
13
|
+
export declare function TileFrame({ tile, index, selected, flash, menuOpen, bare, onInsertAfter, onSelect, onOpenMenu, resizing, width, onResizeStart, onResizeMove, onResizeEnd, children, }: {
|
|
11
14
|
tile: DashboardTile;
|
|
12
15
|
index: number;
|
|
13
16
|
selected: boolean;
|
|
@@ -15,21 +18,55 @@ export declare function TileFrame({ tile, index, selected, flash, menuOpen, onIn
|
|
|
15
18
|
flash?: boolean;
|
|
16
19
|
/** Whether this tile's menu is open, which keeps its button showing. */
|
|
17
20
|
menuOpen: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The tile has no card (a notebook's): its ring is drawn clear of the
|
|
23
|
+
* content and its menu sits on the ring's top edge, so neither touches the
|
|
24
|
+
* text, and the tile reads where the reader draws it.
|
|
25
|
+
*/
|
|
26
|
+
bare?: boolean;
|
|
18
27
|
/** Offers a "+" on the bottom edge that adds a tile after this one; set where tiles stack in one column. */
|
|
19
28
|
onInsertAfter?: () => void;
|
|
20
29
|
onSelect: () => void;
|
|
21
30
|
onOpenMenu: (anchor: HTMLElement) => void;
|
|
31
|
+
/** This tile's edge is being dragged. */
|
|
32
|
+
resizing?: boolean;
|
|
33
|
+
/** Dragging the right edge sets the width; absent, the tile has no edge handle (one column, or tags the file does not own). */
|
|
34
|
+
onResizeStart?: (event: PointerEvent<HTMLDivElement>) => void;
|
|
35
|
+
onResizeMove?: (event: PointerEvent<HTMLDivElement>) => void;
|
|
36
|
+
onResizeEnd?: (event: PointerEvent<HTMLDivElement>) => void;
|
|
37
|
+
/** The tile's width and the grid's, and a step of one column: the edge's keyboard route. */
|
|
38
|
+
width?: {
|
|
39
|
+
span: number;
|
|
40
|
+
columns: number;
|
|
41
|
+
onStep: (to: number) => void;
|
|
42
|
+
};
|
|
22
43
|
children: ReactNode;
|
|
23
44
|
}): import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
/** How far the selection ring stands outside what it selects: its 2px offset plus its 2px width. */
|
|
46
|
+
export declare const SELECTION_RING_PX = 4;
|
|
47
|
+
/**
|
|
48
|
+
* The builder's selection look, for anything a person can select — a tile,
|
|
49
|
+
* the description: an outline outside the element (so selecting moves no
|
|
50
|
+
* layout), solid in the accent when selected, lifting on hover the way a card
|
|
51
|
+
* does in any builder's edit mode, and a brief halo when an undo or redo just
|
|
52
|
+
* changed it. One definition, so the description selects exactly as a tile.
|
|
53
|
+
*/
|
|
54
|
+
export declare const selectionSx: (theme: ResolvedTheme, { selected, flash, bare, }: {
|
|
55
|
+
selected: boolean;
|
|
56
|
+
flash?: boolean;
|
|
57
|
+
bare?: boolean;
|
|
58
|
+
}) => SystemStyleObject<Theme>;
|
|
24
59
|
/**
|
|
25
60
|
* No host-supplied tile: say what this one will run, so the surface is still
|
|
26
61
|
* legible without a server.
|
|
27
62
|
*/
|
|
28
|
-
export declare function TilePlaceholder({ tile, heading, note, }: {
|
|
63
|
+
export declare function TilePlaceholder({ tile, heading, note, chrome, }: {
|
|
29
64
|
tile: QueryTile;
|
|
30
65
|
heading?: TileHeadingSlots;
|
|
31
66
|
/** Why there is no preview, in place of an empty body. */
|
|
32
67
|
note?: string;
|
|
68
|
+
/** The document's tile chrome, as the reader draws it. */
|
|
69
|
+
chrome?: TileChrome;
|
|
33
70
|
}): import("react/jsx-runtime").JSX.Element;
|
|
34
71
|
/** The empty end of a row, made a drop target while a drag is live. */
|
|
35
72
|
export declare function GapTarget({ after }: {
|
|
@@ -2,15 +2,15 @@ import { CatalogView } from './catalog';
|
|
|
2
2
|
import { DashboardTile } from './document';
|
|
3
3
|
/**
|
|
4
4
|
* A tile's own settings, on the tile: a popover off its menu button, so
|
|
5
|
-
* editing it never means scrolling away from it. Its chart,
|
|
6
|
-
*
|
|
5
|
+
* editing it never means scrolling away from it. Its chart, clickable cells
|
|
6
|
+
* and removal; its width is set by dragging its right edge; its title and subtitle are edited on the tile. Its row is set by dragging it — a drop
|
|
7
7
|
* into the empty end of a row is what "start a new row" means — and its card
|
|
8
8
|
* is the reader's to decide, so neither is a toggle here. Which controls it
|
|
9
9
|
* answers to is not here either: filters are configured in one place, the
|
|
10
|
-
* strip under the header.
|
|
10
|
+
* strip under the header. A chart pick commits at once, so the tile redraws
|
|
11
|
+
* under the open menu (`useDraft`'s `apply`).
|
|
11
12
|
*
|
|
12
|
-
* A text tile has only
|
|
13
|
-
* Remove: its words are written on the tile itself.
|
|
13
|
+
* A text tile has only Remove: its words are written on the tile itself.
|
|
14
14
|
*/
|
|
15
15
|
export interface TileMenuProps {
|
|
16
16
|
anchor: HTMLElement | null;
|
|
@@ -22,11 +22,9 @@ export interface TileMenuProps {
|
|
|
22
22
|
onRemove: () => void;
|
|
23
23
|
/** Why removing is refused, shown beside a Remove that stays focusable; absent when it is allowed. */
|
|
24
24
|
removeBlocked?: string;
|
|
25
|
-
/** The grid's width, which the width presets are fractions of. */
|
|
26
|
-
columns: number;
|
|
27
25
|
/** Open the clickable-cells window for this tile's source. */
|
|
28
26
|
onDrills: () => void;
|
|
29
27
|
/** The catalog's view the tile shows, when the catalog knows it: what decides which charts are offered. */
|
|
30
28
|
view?: Pick<CatalogView, "chart" | "aggregateOnly">;
|
|
31
29
|
}
|
|
32
|
-
export declare function TileMenu({ anchor, tile, onClose, onCommit, onRemove, removeBlocked,
|
|
30
|
+
export declare function TileMenu({ anchor, tile, onClose, onCommit, onRemove, removeBlocked, onDrills, view, }: TileMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SavesTo } from './documentSession';
|
|
2
|
+
import { BuilderEvent } from './telemetry';
|
|
3
|
+
import { SessionReport } from './useBuilderSession';
|
|
4
|
+
/**
|
|
5
|
+
* What the builder's session says about a save, in the event names the
|
|
6
|
+
* document's kind reports under.
|
|
7
|
+
*/
|
|
8
|
+
export declare const builderReport: ({ size, notebook, savesTo, onEvent, }: {
|
|
9
|
+
size: number;
|
|
10
|
+
notebook: boolean;
|
|
11
|
+
savesTo: SavesTo;
|
|
12
|
+
onEvent: ((event: BuilderEvent) => void) | undefined;
|
|
13
|
+
}) => SessionReport;
|
|
@@ -64,21 +64,3 @@ export declare function filterableFields(catalog: PackageCatalog | undefined, so
|
|
|
64
64
|
*/
|
|
65
65
|
export declare const isDashboardModel: (path: string | undefined) => boolean;
|
|
66
66
|
export declare function buildCatalog(models: CompiledModel[]): PackageCatalog;
|
|
67
|
-
/**
|
|
68
|
-
* The part of the package catalog a dashboard file can actually use.
|
|
69
|
-
*
|
|
70
|
-
* The builder never writes an import, so a source the file cannot see would
|
|
71
|
-
* produce a tile that does not compile. A named import says exactly which
|
|
72
|
-
* names it brings. A whole-file import of a published model brings that
|
|
73
|
-
* model's sources. A whole-file import of a file off the surface cannot be
|
|
74
|
-
* read, so then every published source is offered and a wrong pick is caught
|
|
75
|
-
* by the compile check the editor already runs.
|
|
76
|
-
*/
|
|
77
|
-
export declare function visibleToDashboard(catalog: PackageCatalog, imports: ReadonlyArray<{
|
|
78
|
-
kind: "all";
|
|
79
|
-
path: string;
|
|
80
|
-
} | {
|
|
81
|
-
kind: "names";
|
|
82
|
-
names: string[];
|
|
83
|
-
path: string;
|
|
84
|
-
}>, published: CompiledModel[]): PackageCatalog;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { QueryClient, QueryKey } from '@tanstack/react-query';
|
|
2
2
|
import { Workspace } from '../DocumentStorage';
|
|
3
3
|
import { ApiClients } from '../ServerProvider';
|
|
4
|
-
|
|
5
|
-
export type SavesTo
|
|
4
|
+
import { SavesTo } from '../Dashboard/telemetry';
|
|
5
|
+
export type { SavesTo };
|
|
6
6
|
/**
|
|
7
7
|
* The record when one declares itself, and otherwise the first writeable
|
|
8
8
|
* workspace. Pass every workspace, not only the writeable ones: a reader who
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DashboardDocument, DashboardImport } from './document';
|
|
2
|
+
/** How the document at `documentPath` names the model at `modelPath`. */
|
|
3
|
+
export declare function importPathOf(modelPath: string, documentPath: string): string;
|
|
4
|
+
/**
|
|
5
|
+
* Whether the file can already see `name` from `modelPath`: it extends it,
|
|
6
|
+
* imports it by name, or imports that model whole. A whole-file import brings
|
|
7
|
+
* every source the model exports, and naming one of them again would declare
|
|
8
|
+
* it twice. A source the file sees only through another model that re-exports
|
|
9
|
+
* it is not followed: that needs the catalog to say which model declares each
|
|
10
|
+
* source, and the compile check on save catches the duplicate.
|
|
11
|
+
*/
|
|
12
|
+
export declare function reaches(document: Pick<DashboardDocument, "imports" | "sources">, name: string, modelPath: string, documentPath?: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* `imports` with `name` from `modelPath` brought in, by name — into that
|
|
15
|
+
* model's existing `{ … }` import when there is one, else as a new statement
|
|
16
|
+
* written relative to where the document sits. Unchanged when the file can
|
|
17
|
+
* already see it.
|
|
18
|
+
*/
|
|
19
|
+
export declare function withSource(document: Pick<DashboardDocument, "imports" | "sources">, name: string, modelPath: string, documentPath?: string): DashboardImport[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Theme } from '@mui/material';
|
|
2
|
+
import { SystemStyleObject } from '@mui/system';
|
|
3
|
+
import { ResolvedTheme } from '../../theme/types';
|
|
4
|
+
/** Where the pencil goes: after a line of text, or after the first block of prose. */
|
|
5
|
+
export type PencilAt = "line" | "prose";
|
|
6
|
+
/**
|
|
7
|
+
* How text that is edited where it is read says so: a thin pencil straight
|
|
8
|
+
* after the text, in the text's own colour and in proportion to its size,
|
|
9
|
+
* faint at rest and clearer under the pointer. The same mark in the same place
|
|
10
|
+
* for every field — a title, a subtitle, a description — and nothing else: no
|
|
11
|
+
* wash, no outline, no gutter. The keyboard gets a focus ring, since a pencil
|
|
12
|
+
* does not say where focus is.
|
|
13
|
+
*
|
|
14
|
+
* Drawn as a pseudo-element, so it adds no node and moves no layout; for prose
|
|
15
|
+
* it follows the first paragraph or heading, which is the line the reader is
|
|
16
|
+
* looking at when they reach for it.
|
|
17
|
+
*/
|
|
18
|
+
export declare const editableSx: (theme: ResolvedTheme, at?: PencilAt) => SystemStyleObject<Theme>;
|
|
@@ -102,5 +102,7 @@ type ParseTags = (lines: string[]) => {
|
|
|
102
102
|
*/
|
|
103
103
|
export declare function localGivens(parsed: ParsedMalloy, lines: string[], parse: ParseTags): LocalGiven[] | undefined;
|
|
104
104
|
/** Refuses rather than throws: `Tag.text()` throws on a malformed date literal such as `@2024-13-01`, and dropping the value would lose it on the next save. */
|
|
105
|
-
export declare function readDashboardDocument(sourceText: string, modelPath?: string
|
|
105
|
+
export declare function readDashboardDocument(sourceText: string, modelPath?: string,
|
|
106
|
+
/** A document the host keeps as text has no folder to take a kind from, so the layout decides. */
|
|
107
|
+
textHeld?: boolean): Promise<ReadResult>;
|
|
106
108
|
export {};
|
|
@@ -13,4 +13,4 @@ export type EditorOpen = {
|
|
|
13
13
|
reason: string;
|
|
14
14
|
};
|
|
15
15
|
/** Read `text` for the builder, converting a cell-format notebook rather than refusing it. */
|
|
16
|
-
export declare function readForEditor(text: string, modelPath?: string): Promise<EditorOpen>;
|
|
16
|
+
export declare function readForEditor(text: string, modelPath?: string, textHeld?: boolean): Promise<EditorOpen>;
|
|
@@ -18,6 +18,8 @@ export declare const GAP_TYPE = "gap";
|
|
|
18
18
|
* versions this replaced were most of why the gesture felt unfamiliar.
|
|
19
19
|
*/
|
|
20
20
|
export declare const builderSensors: ( PluginDescriptor<any, Plugin<any, PointerSensorOptions>, typeof PointerSensor> | typeof KeyboardSensor)[];
|
|
21
|
+
/** Marks an element inside a tile whose presses must never start a move. */
|
|
22
|
+
export declare const NO_DRAG = "data-no-drag";
|
|
21
23
|
interface TileSortableHandles {
|
|
22
24
|
/** The tile's element: what is dragged, and what a drop lands on. */
|
|
23
25
|
ref: (element: Element | null) => void;
|
|
@@ -61,5 +61,7 @@ export interface SpliceOptions {
|
|
|
61
61
|
changeKind?: boolean;
|
|
62
62
|
/** The file's path within the package; a dashboard under `notebooks/` is tagged `kind=dashboard` rather than left untagged. */
|
|
63
63
|
modelPath?: string;
|
|
64
|
+
/** Write `kind=dashboard` too, whatever the folder: for a document held as text, which the server reads by its tags and not by a folder. */
|
|
65
|
+
explicitKind?: boolean;
|
|
64
66
|
}
|
|
65
67
|
export declare function spliceDashboardDocument(sourceText: string, requested: DashboardDocument, options?: SpliceOptions): Promise<SpliceResult>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drag a tile's right edge until it spans `columns` of a 12-column grid whose
|
|
3
|
+
* tracks are 100px wide and which starts, like every tile, at x = 0. The test
|
|
4
|
+
* DOM lays nothing out, so the measurements the resize reads are stubbed for
|
|
5
|
+
* the length of the gesture.
|
|
6
|
+
*/
|
|
7
|
+
export declare function dragEdge(label: string, columns: number): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { QueryTile } from './document';
|
|
2
|
+
/**
|
|
3
|
+
* The title a query tile is drawn under when it has no label of its own: the
|
|
4
|
+
* one the reader's view derives from the view's name. One definition, so a
|
|
5
|
+
* live tile, a placeholder and the menu agree.
|
|
6
|
+
*/
|
|
7
|
+
export declare const tileDisplayTitle: (tile: QueryTile) => string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { DashboardDocument } from './document';
|
|
3
|
+
import { DashboardEditor } from './useDashboardEditor';
|
|
4
|
+
import { SaveOutcome, LastSave } from './useDocumentEditor';
|
|
5
|
+
/**
|
|
6
|
+
* The builder's selection, and the flash that points at what undo and redo
|
|
7
|
+
* changed.
|
|
8
|
+
*
|
|
9
|
+
* `stepEditor` is the editor with its undo and redo marked as STEPS, so the
|
|
10
|
+
* document they produce is diffed against the one before it and the tile that
|
|
11
|
+
* changed is lit briefly and scrolled to. An ordinary edit is not a step: the
|
|
12
|
+
* author is already looking at what they changed.
|
|
13
|
+
*/
|
|
14
|
+
export declare function useBuilderSelection({ editor, gridBox, }: {
|
|
15
|
+
editor: DashboardEditor;
|
|
16
|
+
/** The grid's box, searched for the changed tile to scroll to. */
|
|
17
|
+
gridBox: RefObject<HTMLDivElement | null>;
|
|
18
|
+
}): {
|
|
19
|
+
selected: number;
|
|
20
|
+
descriptionSelected: boolean;
|
|
21
|
+
selectTile: (index: number) => void;
|
|
22
|
+
deselectTile: () => void;
|
|
23
|
+
selectDescription: () => void;
|
|
24
|
+
clearSelection: () => void;
|
|
25
|
+
flash: string;
|
|
26
|
+
stepEditor: {
|
|
27
|
+
undo: () => void;
|
|
28
|
+
redo: () => void;
|
|
29
|
+
document: DashboardDocument;
|
|
30
|
+
saved: DashboardDocument;
|
|
31
|
+
source: string;
|
|
32
|
+
canUndo: boolean;
|
|
33
|
+
canRedo: boolean;
|
|
34
|
+
dirty: boolean;
|
|
35
|
+
edited: boolean;
|
|
36
|
+
pendingOpen: boolean;
|
|
37
|
+
error?: string;
|
|
38
|
+
update: (change: (draft: DashboardDocument) => void) => void;
|
|
39
|
+
save: () => Promise< SaveOutcome>;
|
|
40
|
+
preview: () => Promise<{
|
|
41
|
+
ok: true;
|
|
42
|
+
source: string;
|
|
43
|
+
} | {
|
|
44
|
+
ok: false;
|
|
45
|
+
reason: string;
|
|
46
|
+
}>;
|
|
47
|
+
structural: boolean;
|
|
48
|
+
clearsHistory: boolean;
|
|
49
|
+
canUndoSave: boolean;
|
|
50
|
+
lastSave?: LastSave;
|
|
51
|
+
undoSave: () => Promise< SaveOutcome>;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { BuilderToolbarProps } from './BuilderToolbar';
|
|
2
2
|
import { BuilderShortcutHandlers } from './useBuilderShortcuts';
|
|
3
3
|
import { LastSave, SaveHandler, SaveOutcome } from './useDocumentEditor';
|
|
4
|
-
import { SaveNoticeProps } from './SaveNotice';
|
|
5
4
|
/** What a builder's session reads of its document editor. */
|
|
6
5
|
export interface SessionEditor<D, L extends LastSave = LastSave> {
|
|
7
6
|
document: D;
|
|
@@ -42,10 +41,9 @@ export interface SessionSaveInfo {
|
|
|
42
41
|
export interface BuilderSessionOptions<D, L extends LastSave = LastSave> {
|
|
43
42
|
editor: SessionEditor<D, L>;
|
|
44
43
|
onSave?: SaveHandler<D>;
|
|
45
|
-
onExit?: () => void;
|
|
46
44
|
onDirtyChange?: (dirty: boolean) => void;
|
|
47
|
-
/**
|
|
48
|
-
|
|
45
|
+
/** The host's way out, opted into: draws Close, which asks first when edits are unsaved. */
|
|
46
|
+
onExit?: () => void;
|
|
49
47
|
onChange?: (document: D) => void;
|
|
50
48
|
/** Unsaved state the editor does not hold, such as an open text draft. */
|
|
51
49
|
extraDirty?: boolean;
|
|
@@ -67,7 +65,7 @@ export interface BuilderSessionOptions<D, L extends LastSave = LastSave> {
|
|
|
67
65
|
*/
|
|
68
66
|
export declare function useBuilderSession<D, L extends LastSave & {
|
|
69
67
|
removedComments?: string[];
|
|
70
|
-
} = LastSave>({ editor, onSave,
|
|
68
|
+
} = LastSave>({ editor, onSave, onDirtyChange, onExit, onChange, extraDirty, report, unit, prepare, shortcuts, }: BuilderSessionOptions<D, L>): {
|
|
71
69
|
saving: boolean;
|
|
72
70
|
save: () => Promise<void> | void;
|
|
73
71
|
exitGuard: {
|
|
@@ -84,6 +82,5 @@ export declare function useBuilderSession<D, L extends LastSave & {
|
|
|
84
82
|
undoSave: () => Promise<void> | void;
|
|
85
83
|
canUndoSave: boolean;
|
|
86
84
|
lastSave: L;
|
|
87
|
-
|
|
88
|
-
toolbarProps: Pick<BuilderToolbarProps, "canUndo" | "canRedo" | "onUndo" | "onRedo" | "dirty" | "saving" | "onSave" | "saveButton" | "onExit">;
|
|
85
|
+
toolbarProps: Pick<BuilderToolbarProps, "onSave" | "canUndo" | "canRedo" | "onUndo" | "onRedo" | "dirty" | "saving" | "saveButton" | "onExit">;
|
|
89
86
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PackageCatalog, CatalogField } from './catalog';
|
|
2
|
+
import { BuilderControl, BuilderGiven, MappingRow } from './controls';
|
|
3
|
+
import { DashboardDocument, LocalGiven, QueryTile } from './document';
|
|
4
|
+
import { DashboardEditor } from './useDashboardEditor';
|
|
5
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
6
|
+
/**
|
|
7
|
+
* The document's controls, the fields each tile may bind one to, and the
|
|
8
|
+
* filter window that edits them — the one place a filter is configured.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useControlBindings({ editor, opened, givens, catalog, }: {
|
|
11
|
+
editor: DashboardEditor;
|
|
12
|
+
/** The document as the host opened it, before any edit here. */
|
|
13
|
+
opened: DashboardDocument;
|
|
14
|
+
/** The givens the host resolved across the model and its imports. */
|
|
15
|
+
givens: BuilderGiven[] | undefined;
|
|
16
|
+
catalog: PackageCatalog | undefined;
|
|
17
|
+
}): {
|
|
18
|
+
filterDialog: {
|
|
19
|
+
control?: BuilderControl;
|
|
20
|
+
};
|
|
21
|
+
setFilterDialog: Dispatch<SetStateAction<{
|
|
22
|
+
control?: BuilderControl;
|
|
23
|
+
}>>;
|
|
24
|
+
controlList: BuilderControl[];
|
|
25
|
+
fieldsFor: (tile: QueryTile) => CatalogField[];
|
|
26
|
+
unknownFieldsOf: (name: string, type: string | undefined) => string[];
|
|
27
|
+
available: BuilderControl[];
|
|
28
|
+
applyFilter: (given: string, rows: MappingRow[], declare?: LocalGiven) => void;
|
|
29
|
+
dropControl: (given: string) => void;
|
|
30
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** A save waiting on the reader's answer: go ahead, or stop without writing. */
|
|
2
|
+
export interface ConversionConfirm {
|
|
3
|
+
go: () => void;
|
|
4
|
+
stop: () => void;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Asking before the save that converts a cell-format notebook.
|
|
8
|
+
*
|
|
9
|
+
* `prepareSave` is `prepare` behind that question. While `confirmConversion`
|
|
10
|
+
* is set the question is open; answering it runs the save, or drops it.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useConversionConfirm({ pendingOpen, prepare, }: {
|
|
13
|
+
/** Whether the document opened unsaved, as a conversion does. */
|
|
14
|
+
pendingOpen: boolean | undefined;
|
|
15
|
+
/** What runs before every save once the reader has said yes. */
|
|
16
|
+
prepare: (run: () => Promise<void> | void) => Promise<void> | void;
|
|
17
|
+
}): {
|
|
18
|
+
confirmConversion: ConversionConfirm;
|
|
19
|
+
prepareSave: (run: () => Promise<void> | void) => Promise<void> | void;
|
|
20
|
+
};
|
|
@@ -22,4 +22,6 @@ export declare function useDashboardEditor(options: {
|
|
|
22
22
|
replaces?: string;
|
|
23
23
|
/** The file's path within the package. */
|
|
24
24
|
modelPath?: string;
|
|
25
|
+
/** The document is held as text: a kind switch always writes `kind=`. */
|
|
26
|
+
explicitKind?: boolean;
|
|
25
27
|
}): DashboardEditor;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A copy of `value` to edit while a window is open, committed ONCE when it
|
|
3
|
-
* closes, and only if something changed
|
|
3
|
+
* closes, and only if something changed — or at once, through `apply`, for a
|
|
4
|
+
* change that should show while the window is open.
|
|
4
5
|
*
|
|
5
6
|
* Per-keystroke commits would put a document in the undo stack for every
|
|
6
7
|
* letter typed into a title, and undo would then walk back through the word.
|
|
@@ -8,6 +9,7 @@
|
|
|
8
9
|
export declare function useDraft<T>(value: T | undefined, open: boolean, onCommit: (next: T) => void, onClose: () => void): {
|
|
9
10
|
draft: T;
|
|
10
11
|
patch: (change: (draft: T) => void) => void;
|
|
12
|
+
apply: (change: (draft: T) => void) => void;
|
|
11
13
|
close: () => void;
|
|
12
14
|
discard: () => void;
|
|
13
15
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DocumentStorage, Workspace } from '../DocumentStorage';
|
|
2
|
+
import { DocumentKind } from './document';
|
|
3
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
4
|
+
/**
|
|
5
|
+
* The host's copy of the document, if one was saved earlier: which workspace
|
|
6
|
+
* holds it, its text, and whether the read has answered yet.
|
|
7
|
+
*
|
|
8
|
+
* Read once per document, from the host's {@link DocumentStorage}. A host
|
|
9
|
+
* without one has nothing to read, so the answer is in at once.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useHostCopy({ storage, kind, notebook, environmentName, packageName, modelPath, }: {
|
|
12
|
+
storage: DocumentStorage | undefined;
|
|
13
|
+
kind: DocumentKind;
|
|
14
|
+
notebook: boolean;
|
|
15
|
+
environmentName: string;
|
|
16
|
+
packageName: string;
|
|
17
|
+
modelPath: string;
|
|
18
|
+
}): {
|
|
19
|
+
workspace: Workspace;
|
|
20
|
+
draft: string;
|
|
21
|
+
setDraft: Dispatch<SetStateAction<string>>;
|
|
22
|
+
draftChecked: boolean;
|
|
23
|
+
offered: boolean;
|
|
24
|
+
setOffered: Dispatch<SetStateAction<boolean>>;
|
|
25
|
+
readFailure: string;
|
|
26
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { OpenDraftSink } from './openDraft';
|
|
2
|
+
/**
|
|
3
|
+
* The text field open somewhere on the page, as the builder's save sees it.
|
|
4
|
+
*
|
|
5
|
+
* An inline field reports itself through `openDraft` (provided as
|
|
6
|
+
* `OpenDraftContext`): whether it holds typing not yet in the document, and
|
|
7
|
+
* how to commit it. `draftDirty` counts that typing as unsaved work, and
|
|
8
|
+
* `prepare` commits it before a save reads the document.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useOpenDraftCommit({ editorDirty, }: {
|
|
11
|
+
/** The editor's own dirty flag: a commit landing changes it, which is when the waiting save runs. */
|
|
12
|
+
editorDirty: boolean;
|
|
13
|
+
}): {
|
|
14
|
+
draftDirty: boolean;
|
|
15
|
+
openDraft: OpenDraftSink;
|
|
16
|
+
prepare: (run: () => Promise<void> | void) => Promise<void> | void;
|
|
17
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { MutableRefObject, Dispatch, SetStateAction, RefObject } from 'react';
|
|
2
|
+
import { Workspace } from '../DocumentStorage';
|
|
3
|
+
import { DashboardDocument } from './document';
|
|
4
|
+
import { BuilderEvent } from './telemetry';
|
|
5
|
+
export declare const LEGACY_REFUSAL = "a .malloynb notebook is read, not edited. Fix: rewrite it as a `.malloy` notebook under notebooks/ to edit it here.";
|
|
6
|
+
/** The document the builder is on, and what it was opened from. */
|
|
7
|
+
export interface OpenedDocument {
|
|
8
|
+
source: string;
|
|
9
|
+
document: DashboardDocument;
|
|
10
|
+
conversion?: {
|
|
11
|
+
from: string;
|
|
12
|
+
to: string;
|
|
13
|
+
};
|
|
14
|
+
/** The package file when this opened, which a draft's save overwrites. */
|
|
15
|
+
packageText?: string;
|
|
16
|
+
generation: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Which text the editor opens, and when a newer one is held back.
|
|
20
|
+
*
|
|
21
|
+
* Three channels can hold the document — the host's record, a copy the reader
|
|
22
|
+
* resumes, the package file — and each can move under an open editor. This
|
|
23
|
+
* decides which one the builder is on, opens it (reporting the open or the
|
|
24
|
+
* refusal), and keeps a newer version behind a banner rather than loading it
|
|
25
|
+
* over work the reader has not saved.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useOpenedDocument({ workspace, draft, draftChecked, readFailure, packageText, fetchedAt, packageSettled, modelPath, notebook, noun, refusedEvent, legacyFormat, textHeld, startedAt, onEventRef, }: {
|
|
28
|
+
workspace: Workspace | undefined;
|
|
29
|
+
/** The host's copy, if one was read. */
|
|
30
|
+
draft: string | undefined;
|
|
31
|
+
/** Whether the host's store has answered. */
|
|
32
|
+
draftChecked: boolean;
|
|
33
|
+
readFailure: string | undefined;
|
|
34
|
+
/** The file as the package's last fetch has it. */
|
|
35
|
+
packageText: string | undefined;
|
|
36
|
+
/** When that fetch landed. */
|
|
37
|
+
fetchedAt: number;
|
|
38
|
+
/** Whether the package's fetch has succeeded and is not refetching. */
|
|
39
|
+
packageSettled: boolean;
|
|
40
|
+
modelPath: string;
|
|
41
|
+
notebook: boolean;
|
|
42
|
+
noun: string;
|
|
43
|
+
refusedEvent: "notebook.open_refused" | "dashboard.open_refused";
|
|
44
|
+
legacyFormat: boolean;
|
|
45
|
+
/** The document is held as text by the host: there is no package file to fall back on. */
|
|
46
|
+
textHeld: boolean;
|
|
47
|
+
/** When the open was asked for, so "opened" can say how long it took. */
|
|
48
|
+
startedAt: MutableRefObject<number>;
|
|
49
|
+
onEventRef: MutableRefObject<((event: BuilderEvent) => void) | undefined>;
|
|
50
|
+
}): {
|
|
51
|
+
authoritative: boolean;
|
|
52
|
+
blockedOnRecord: boolean;
|
|
53
|
+
resume: boolean;
|
|
54
|
+
setResume: Dispatch<SetStateAction<boolean>>;
|
|
55
|
+
fromDraft: boolean;
|
|
56
|
+
opened: OpenedDocument;
|
|
57
|
+
setOpened: Dispatch<SetStateAction<OpenedDocument>>;
|
|
58
|
+
openError: string;
|
|
59
|
+
savedHashRef: RefObject<string>;
|
|
60
|
+
packageBaseRef: RefObject<string>;
|
|
61
|
+
setWrote: Dispatch<SetStateAction<{
|
|
62
|
+
text: string;
|
|
63
|
+
onFetch: number;
|
|
64
|
+
}>>;
|
|
65
|
+
fetchedAtRef: RefObject<number>;
|
|
66
|
+
setDirty: Dispatch<SetStateAction<boolean>>;
|
|
67
|
+
setSeen: Dispatch<SetStateAction<string>>;
|
|
68
|
+
held: string;
|
|
69
|
+
choose: (resumeDraft: boolean) => void;
|
|
70
|
+
acceptHeld: () => void;
|
|
71
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { Dispatch, MutableRefObject, SetStateAction } from 'react';
|
|
3
|
+
import { DocumentStorage, Workspace } from '../DocumentStorage';
|
|
4
|
+
import { useServer } from '../ServerProvider';
|
|
5
|
+
import { DocumentKind } from './document';
|
|
6
|
+
import { OpenedDocument } from './useOpenedDocument';
|
|
7
|
+
import { SavesTo } from './documentSession';
|
|
8
|
+
/**
|
|
9
|
+
* Where Save writes, and the write itself: into the host's store, or into the
|
|
10
|
+
* package, and what each write does to the editor's idea of which text is
|
|
11
|
+
* open, which was seen, and what the next save is spliced against.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useSaveChannel({ storage, workspace, kind, notebook, environmentName, packageName, modelPath, versionId, apiClients, queryClient, mutable, textHeld, readFailure, authoritative, resume, setResume, setOpened, setDraft, setOffered, setSeen, setWrote, savedHashRef, packageBaseRef, fetchedAtRef, }: {
|
|
14
|
+
storage: DocumentStorage | undefined;
|
|
15
|
+
workspace: Workspace | undefined;
|
|
16
|
+
kind: DocumentKind;
|
|
17
|
+
notebook: boolean;
|
|
18
|
+
environmentName: string;
|
|
19
|
+
packageName: string;
|
|
20
|
+
modelPath: string;
|
|
21
|
+
versionId: string | undefined;
|
|
22
|
+
apiClients: ReturnType<typeof useServer>["apiClients"];
|
|
23
|
+
queryClient: QueryClient;
|
|
24
|
+
/** Whether the server takes writes; unknown while `/status` loads. */
|
|
25
|
+
mutable: boolean | undefined;
|
|
26
|
+
/** A document held as text is saved only to the host's record, never into the package. */
|
|
27
|
+
textHeld: boolean;
|
|
28
|
+
readFailure: string | undefined;
|
|
29
|
+
authoritative: boolean;
|
|
30
|
+
resume: boolean | undefined;
|
|
31
|
+
setResume: Dispatch<SetStateAction<boolean | undefined>>;
|
|
32
|
+
setOpened: Dispatch<SetStateAction<OpenedDocument | undefined>>;
|
|
33
|
+
setDraft: Dispatch<SetStateAction<string | undefined>>;
|
|
34
|
+
setOffered: Dispatch<SetStateAction<boolean>>;
|
|
35
|
+
setSeen: Dispatch<SetStateAction<string | undefined>>;
|
|
36
|
+
setWrote: Dispatch<SetStateAction<{
|
|
37
|
+
text: string;
|
|
38
|
+
onFetch: number;
|
|
39
|
+
} | undefined>>;
|
|
40
|
+
savedHashRef: MutableRefObject<string | undefined>;
|
|
41
|
+
packageBaseRef: MutableRefObject<string | undefined>;
|
|
42
|
+
fetchedAtRef: MutableRefObject<number>;
|
|
43
|
+
}): {
|
|
44
|
+
save: (source: string) => Promise<void>;
|
|
45
|
+
savesTo: SavesTo;
|
|
46
|
+
writer: "package" | "storage";
|
|
47
|
+
pinnedPackageSave: boolean;
|
|
48
|
+
takesWrites: boolean;
|
|
49
|
+
supersedeFailure: string;
|
|
50
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { NewTile } from './AddTileDialog';
|
|
2
|
+
import { DashboardTile } from './document';
|
|
3
|
+
import { DashboardEditor } from './useDashboardEditor';
|
|
4
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
5
|
+
/**
|
|
6
|
+
* Adding, changing and removing tiles, with the add-tile picker and a tile's
|
|
7
|
+
* menu that they are reached from.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useTileEditing({ editor, notebook, columns, modelPath, selectTile, deselectTile, }: {
|
|
10
|
+
editor: DashboardEditor;
|
|
11
|
+
notebook: boolean;
|
|
12
|
+
columns: number;
|
|
13
|
+
/** The document's file within the package, which a tile's import is relative to. */
|
|
14
|
+
modelPath: string | undefined;
|
|
15
|
+
selectTile: (index: number) => void;
|
|
16
|
+
deselectTile: () => void;
|
|
17
|
+
}): {
|
|
18
|
+
menu: {
|
|
19
|
+
anchor: HTMLElement;
|
|
20
|
+
index: number;
|
|
21
|
+
};
|
|
22
|
+
setMenu: Dispatch<SetStateAction<{
|
|
23
|
+
anchor: HTMLElement;
|
|
24
|
+
index: number;
|
|
25
|
+
}>>;
|
|
26
|
+
addingTile: boolean;
|
|
27
|
+
openAdd: (at?: number) => void;
|
|
28
|
+
closeAdd: () => void;
|
|
29
|
+
addTile: (tile: NewTile) => void;
|
|
30
|
+
addText: () => void;
|
|
31
|
+
editTile: (key: string, change: (tile: DashboardTile) => void) => void;
|
|
32
|
+
removeTile: (index: number) => void;
|
|
33
|
+
};
|