@malloy-publisher/sdk 0.9.14 → 0.9.16
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-5hOs5XnV.cjs.js +171 -0
- package/dist/RenderedResult-DxmHGZNQ.es.js +671 -0
- package/dist/{ServerProvider-BV7IoDMR.es.js → ServerProvider-D7neZcTk.es.js} +283 -265
- package/dist/ServerProvider-e2369oom.cjs.js +1 -0
- package/dist/builder/index.cjs.js +80 -79
- package/dist/builder/index.es.js +7732 -6717
- package/dist/builder-entry.d.ts +1 -1
- package/dist/client/api.d.ts +31 -7
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/Dashboard/DashboardGrid.d.ts +51 -1
- package/dist/components/Dashboard/DashboardTile.d.ts +7 -2
- package/dist/components/Dashboard/DashboardView.d.ts +9 -2
- package/dist/components/Dashboard/index.d.ts +1 -1
- package/dist/components/Dashboard/promoteMeasureRow.d.ts +5 -7
- package/dist/components/Dashboard/useStuck.d.ts +18 -12
- package/dist/components/RenderedResult/RenderedResult.d.ts +3 -2
- package/dist/components/RenderedResult/ResultContainer.d.ts +18 -1
- package/dist/components/RenderedResult/ResultPanel.d.ts +7 -1
- package/dist/components/RenderedResult/chartPresentation.d.ts +15 -0
- package/dist/components/RenderedResult/chartShapeProblem.d.ts +55 -0
- package/dist/components/RenderedResult/resultSizing.d.ts +47 -6
- package/dist/components/Report/Report.d.ts +7 -1
- package/dist/components/Report/ReportPage.d.ts +7 -0
- package/dist/components/Report/layoutRules.d.ts +45 -0
- package/dist/components/ReportBuilder/AddTileDialog.d.ts +2 -1
- package/dist/components/ReportBuilder/ArrangeMenu.d.ts +9 -0
- package/dist/components/ReportBuilder/BuilderGrid.d.ts +15 -4
- package/dist/components/ReportBuilder/BuilderToolbar.d.ts +3 -1
- package/dist/components/ReportBuilder/ChartPicker.d.ts +4 -2
- package/dist/components/ReportBuilder/EditorSurface.d.ts +10 -1
- package/dist/components/ReportBuilder/ReportBuilder.d.ts +1 -1
- package/dist/components/ReportBuilder/TileFrame.d.ts +54 -10
- package/dist/components/ReportBuilder/TileMenu.d.ts +5 -2
- package/dist/components/ReportBuilder/builderControls.d.ts +19 -0
- package/dist/components/ReportBuilder/catalog.d.ts +23 -0
- package/dist/components/ReportBuilder/chartLine.d.ts +38 -5
- package/dist/components/ReportBuilder/controls.d.ts +2 -2
- package/dist/components/ReportBuilder/document.d.ts +53 -5
- package/dist/components/ReportBuilder/imports.d.ts +7 -0
- package/dist/components/ReportBuilder/placement.d.ts +121 -0
- package/dist/components/ReportBuilder/preview.d.ts +59 -10
- package/dist/components/ReportBuilder/sortable.d.ts +12 -1
- package/dist/components/ReportBuilder/useBuilderSession.d.ts +1 -1
- package/dist/components/ReportBuilder/useBuilderShortcuts.d.ts +9 -1
- package/dist/components/ReportBuilder/useEdgeResize.d.ts +84 -0
- package/dist/components/ReportBuilder/useTileReorder.d.ts +30 -3
- package/dist/index.cjs.js +7 -7
- package/dist/index.es.js +3349 -3307
- package/dist/text/index.es.js +1 -1
- package/dist/{text-entry-72YFLeNk.es.js → text-entry-YKJZbRPo.es.js} +2 -2
- package/dist/theme/classes.d.ts +1 -1
- package/dist/theme/resolveTheme.d.ts +15 -0
- package/dist/{useCompiledDocument-B4QF1mIl.es.js → useCompiledDocument-CaYP_OYG.es.js} +6353 -6047
- package/dist/useCompiledDocument-zYEfLogf.cjs.js +142 -0
- package/dist/utils/blankQuoted.d.ts +15 -0
- package/package.json +1 -1
- package/src/builder-entry.ts +1 -0
- package/src/components/Dashboard/DashboardGrid.tsx +129 -10
- package/src/components/Dashboard/DashboardTile.tsx +15 -1
- package/src/components/Dashboard/DashboardView.tsx +64 -10
- package/src/components/Dashboard/TileCard.tsx +6 -0
- package/src/components/Dashboard/index.ts +1 -0
- package/src/components/Dashboard/promoteMeasureRow.spec.ts +19 -0
- package/src/components/Dashboard/promoteMeasureRow.ts +15 -36
- package/src/components/Dashboard/tileHeight.spec.ts +72 -0
- package/src/components/Dashboard/useStuck.ts +76 -28
- package/src/components/Package/NewDocumentDialog.spec.tsx +20 -16
- package/src/components/Package/NewDocumentDialog.tsx +10 -11
- package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +167 -2
- package/src/components/RenderedResult/RenderedResult.tsx +39 -6
- package/src/components/RenderedResult/ResultContainer.tsx +99 -10
- package/src/components/RenderedResult/ResultPanel.tsx +25 -1
- package/src/components/RenderedResult/chartPresentation.spec.ts +153 -0
- package/src/components/RenderedResult/chartPresentation.ts +166 -0
- package/src/components/RenderedResult/chartShapeProblem.spec.tsx +245 -0
- package/src/components/RenderedResult/chartShapeProblem.ts +219 -0
- package/src/components/RenderedResult/resultSizing.spec.ts +75 -3
- package/src/components/RenderedResult/resultSizing.ts +71 -11
- package/src/components/Report/Report.spec.tsx +19 -0
- package/src/components/Report/Report.tsx +8 -1
- package/src/components/Report/ReportPage.tsx +13 -1
- package/src/components/Report/layoutRules.spec.ts +43 -3
- package/src/components/Report/layoutRules.ts +70 -0
- package/src/components/Report/tileOverflow.spec.tsx +162 -0
- package/src/components/ReportBuilder/AddTileDialog.spec.tsx +2 -2
- package/src/components/ReportBuilder/AddTileDialog.tsx +11 -6
- package/src/components/ReportBuilder/ArrangeMenu.tsx +80 -0
- package/src/components/ReportBuilder/BuilderBar.tsx +5 -1
- package/src/components/ReportBuilder/BuilderDialogs.tsx +28 -1
- package/src/components/ReportBuilder/BuilderGrid.tsx +142 -35
- package/src/components/ReportBuilder/BuilderToolbar.tsx +4 -0
- package/src/components/ReportBuilder/ChartPicker.spec.ts +91 -4
- package/src/components/ReportBuilder/ChartPicker.tsx +45 -10
- package/src/components/ReportBuilder/DrillDialog.tsx +8 -2
- package/src/components/ReportBuilder/EditorSurface.tsx +101 -20
- package/src/components/ReportBuilder/FilterDialog.tsx +17 -8
- package/src/components/ReportBuilder/FilterStrip.tsx +2 -1
- package/src/components/ReportBuilder/ReportBuilder.charts.spec.tsx +193 -2
- package/src/components/ReportBuilder/ReportBuilder.controls.spec.tsx +4 -2
- package/src/components/ReportBuilder/ReportBuilder.notebook.spec.tsx +2 -2
- package/src/components/ReportBuilder/ReportBuilder.spec.tsx +242 -2
- package/src/components/ReportBuilder/ReportBuilder.tsx +161 -27
- package/src/components/ReportBuilder/ReportEditor.fileModel.spec.tsx +178 -0
- package/src/components/ReportBuilder/ReportEditor.modelFilters.spec.tsx +3 -5
- package/src/components/ReportBuilder/ReportEditor.readOnlyTitle.spec.tsx +92 -0
- package/src/components/ReportBuilder/ReportEditor.tsx +13 -0
- package/src/components/ReportBuilder/TileFrame.tsx +366 -170
- package/src/components/ReportBuilder/TileMenu.tsx +259 -20
- package/src/components/ReportBuilder/ViewPicker.tsx +4 -3
- package/src/components/ReportBuilder/addTileToDocument.spec.ts +34 -0
- package/src/components/ReportBuilder/addTileToDocument.ts +26 -1
- package/src/components/ReportBuilder/builderControls.ts +34 -0
- package/src/components/ReportBuilder/catalog.aggregate.spec.ts +137 -1
- package/src/components/ReportBuilder/catalog.ts +90 -37
- package/src/components/ReportBuilder/chartLine.spec.ts +42 -5
- package/src/components/ReportBuilder/chartLine.ts +80 -2
- package/src/components/ReportBuilder/controls.ts +4 -3
- package/src/components/ReportBuilder/document.ts +65 -7
- package/src/components/ReportBuilder/emptyStart.spec.ts +1 -1
- package/src/components/ReportBuilder/entryLayout.spec.ts +151 -0
- package/src/components/ReportBuilder/imports.ts +1 -1
- package/src/components/ReportBuilder/invariants.spec.ts +18 -10
- package/src/components/ReportBuilder/layout.ts +3 -0
- package/src/components/ReportBuilder/placement.spec.ts +401 -0
- package/src/components/ReportBuilder/placement.ts +416 -0
- package/src/components/ReportBuilder/preview.shapes.spec.ts +46 -6
- package/src/components/ReportBuilder/preview.spec.ts +151 -11
- package/src/components/ReportBuilder/preview.ts +203 -40
- package/src/components/ReportBuilder/preview.unsaved.compile.spec.ts +190 -0
- package/src/components/ReportBuilder/readDocument.spec.ts +53 -19
- package/src/components/ReportBuilder/readDocument.ts +197 -29
- package/src/components/ReportBuilder/scannerShapes.spec.ts +10 -10
- package/src/components/ReportBuilder/sortable.tsx +30 -2
- package/src/components/ReportBuilder/spliceDocument.chart.spec.ts +1 -1
- package/src/components/ReportBuilder/spliceDocument.color.spec.ts +80 -0
- package/src/components/ReportBuilder/spliceDocument.colspan.spec.ts +78 -0
- package/src/components/ReportBuilder/spliceDocument.spec.ts +110 -58
- package/src/components/ReportBuilder/spliceDocument.ts +139 -91
- package/src/components/ReportBuilder/statementExtent.spec.ts +3 -3
- package/src/components/ReportBuilder/testing/reportGivenOrder.json +42 -0
- package/src/components/ReportBuilder/textTiles.spec.ts +2 -2
- package/src/components/ReportBuilder/tileDisplayTitle.ts +2 -2
- package/src/components/ReportBuilder/useBuilderSession.ts +7 -2
- package/src/components/ReportBuilder/useBuilderShortcuts.ts +25 -1
- package/src/components/ReportBuilder/useEdgeResize.spec.tsx +324 -0
- package/src/components/ReportBuilder/useEdgeResize.ts +397 -0
- package/src/components/ReportBuilder/useTileEditing.ts +16 -3
- package/src/components/ReportBuilder/useTileReorder.ts +143 -6
- package/src/components/given/FilterButton.spec.tsx +27 -11
- package/src/components/given/FilterButton.tsx +19 -6
- package/src/theme/classes.ts +1 -1
- package/src/theme/resolveTheme.spec.ts +72 -1
- package/src/theme/resolveTheme.ts +43 -0
- package/src/utils/blankQuoted.spec.ts +50 -0
- package/src/utils/blankQuoted.ts +32 -0
- package/src/utils/malloyText.ts +2 -1
- package/dist/RenderedResult-DnBtf-cI.es.js +0 -593
- package/dist/RenderedResult-DtQtNV0d.cjs.js +0 -153
- package/dist/ServerProvider-BIFPCzTD.cjs.js +0 -1
- package/dist/components/ReportBuilder/useTileResize.d.ts +0 -32
- package/dist/useCompiledDocument-D0OAMejE.cjs.js +0 -142
- package/src/components/ReportBuilder/useTileResize.spec.tsx +0 -146
- package/src/components/ReportBuilder/useTileResize.ts +0 -133
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { DashboardTile } from './document';
|
|
2
|
+
/**
|
|
3
|
+
* Free placement on a grid report: each tile at its own `row` and `col`, so
|
|
4
|
+
* empty space anywhere on the grid is somewhere a tile can go.
|
|
5
|
+
*
|
|
6
|
+
* Pure: what a move or a resize does to the tiles, never how the gesture
|
|
7
|
+
* feels. A move or resize keeps the tile it changed where it was put and
|
|
8
|
+
* pushes whatever it now covers straight down, the way the grid dashboards
|
|
9
|
+
* people already know behave. Nothing is pulled up to close a gap, since an
|
|
10
|
+
* empty cell is a choice the author made.
|
|
11
|
+
*/
|
|
12
|
+
/** A tile's rectangle on the grid, in rows and columns counted from 1. */
|
|
13
|
+
export interface Cell {
|
|
14
|
+
row: number;
|
|
15
|
+
col: number;
|
|
16
|
+
colspan: number;
|
|
17
|
+
rowspan: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The fewest rows the builder offers a tile: a chart needs three to draw its
|
|
21
|
+
* plot at all (at two a line chart had no plot area and the renderer failed
|
|
22
|
+
* on it); value cards and a table fit in two, the cards drawing compact;
|
|
23
|
+
* prose fits in one. Which a query tile is comes from what it draws, so
|
|
24
|
+
* `frame` is the tile's element when the caller has it; without it, a query
|
|
25
|
+
* tile is taken for a chart.
|
|
26
|
+
*/
|
|
27
|
+
export declare const minRowsOf: (tile: DashboardTile, frame?: Element | null) => 2 | 1 | 3;
|
|
28
|
+
/** Rows a tile takes on a placed report: its own, or its kind's default. */
|
|
29
|
+
export declare const rowsOf: (tile: DashboardTile) => number;
|
|
30
|
+
/** A placed tile's rectangle, held to the grid; undefined for one not placed yet. */
|
|
31
|
+
export declare function cellOf(tile: DashboardTile, columns: number): Cell | undefined;
|
|
32
|
+
/** Top to bottom, then left to right: the order a placed report is read in, and written. */
|
|
33
|
+
export declare function inReadingOrder(tiles: readonly DashboardTile[]): DashboardTile[];
|
|
34
|
+
/**
|
|
35
|
+
* The tiles with nothing covering anything: `fixed` (the tile just moved or
|
|
36
|
+
* resized) stays exactly where it is, and every placed tile it, or a tile it
|
|
37
|
+
* pushed, now covers moves straight down to just below what it hit. Tiles
|
|
38
|
+
* settle top to bottom, so a pushed tile pushes the ones under it in turn.
|
|
39
|
+
* Without `fixed`, the first tile in reading order holds its place.
|
|
40
|
+
*/
|
|
41
|
+
export declare function settle(tiles: readonly DashboardTile[], columns: number, fixed?: number): DashboardTile[];
|
|
42
|
+
/**
|
|
43
|
+
* The tiles with the one at `index` dropped at `at`. A drop onto the lower
|
|
44
|
+
* part of a tile that starts higher up lands just under that tile, rather
|
|
45
|
+
* than shoving it beneath the dropped one; a drop at or above a tile's top
|
|
46
|
+
* pushes that tile down. Then everything settles around where it landed.
|
|
47
|
+
*/
|
|
48
|
+
export declare function dropAt(tiles: readonly DashboardTile[], index: number, at: {
|
|
49
|
+
row: number;
|
|
50
|
+
col: number;
|
|
51
|
+
}, columns: number): DashboardTile[];
|
|
52
|
+
/** A tile's box against the grid's top left corner, in px. */
|
|
53
|
+
export interface Box {
|
|
54
|
+
top: number;
|
|
55
|
+
left: number;
|
|
56
|
+
width: number;
|
|
57
|
+
height: number;
|
|
58
|
+
}
|
|
59
|
+
/** One column track's width in a grid `gridWidth` px wide. */
|
|
60
|
+
export declare const trackWidth: (gridWidth: number, columns: number) => number;
|
|
61
|
+
/**
|
|
62
|
+
* The cell a tile of `colspan` columns lands in when its top left corner is
|
|
63
|
+
* at (`left`, `top`) px from the grid's: the nearest row and column, held on
|
|
64
|
+
* the grid.
|
|
65
|
+
*/
|
|
66
|
+
export declare function cellAt(left: number, top: number, colspan: number, columns: number, track: number): {
|
|
67
|
+
row: number;
|
|
68
|
+
col: number;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* The tiles placed where they are drawn now, the first time a report is
|
|
72
|
+
* placed: each tile's row, column, width and height read off its box, so
|
|
73
|
+
* turning a flowing report into a placed one moves nothing. A tile with no
|
|
74
|
+
* box (not drawn) is left for the grid to place.
|
|
75
|
+
*/
|
|
76
|
+
export declare function placeWhereDrawn(tiles: readonly DashboardTile[], boxes: ReadonlyArray<Box | undefined>, columns: number, track: number): DashboardTile[];
|
|
77
|
+
/**
|
|
78
|
+
* The tiles with the one at `index` placed under everything else, at the
|
|
79
|
+
* left, when the report is placed: where a new tile goes, so it never drops
|
|
80
|
+
* into a gap an author left on purpose. A report that flows is left as it is.
|
|
81
|
+
*/
|
|
82
|
+
export declare function placeAtEnd(tiles: readonly DashboardTile[], index: number, columns: number): DashboardTile[];
|
|
83
|
+
/**
|
|
84
|
+
* The tiles slid up as far as each will go, top to bottom and then left to
|
|
85
|
+
* right, so every gap above a tile closes; nothing moves sideways. A tile
|
|
86
|
+
* with no place is left for the grid to place.
|
|
87
|
+
*/
|
|
88
|
+
export declare function pack(tiles: readonly DashboardTile[], columns: number): DashboardTile[];
|
|
89
|
+
/** Whether packing would move anything: the action is offered only then. */
|
|
90
|
+
export declare const hasGaps: (tiles: readonly DashboardTile[], columns: number) => boolean;
|
|
91
|
+
/**
|
|
92
|
+
* The tiles with their places taken off, so the report flows again in the
|
|
93
|
+
* order it is read. Widths and heights stay; a row break means nothing to a
|
|
94
|
+
* placed report, so none is set.
|
|
95
|
+
*/
|
|
96
|
+
export declare function flowTiles(tiles: readonly DashboardTile[]): DashboardTile[];
|
|
97
|
+
/** The tiles with the one at `index` set to `at`, nothing else changed: a keyboard step, before it settles. */
|
|
98
|
+
export declare const stepTo: (tiles: readonly DashboardTile[], index: number, at: {
|
|
99
|
+
row: number;
|
|
100
|
+
col: number;
|
|
101
|
+
}) => DashboardTile[];
|
|
102
|
+
/**
|
|
103
|
+
* A placed tile moved one cell by the keyboard, settled. A step into the one
|
|
104
|
+
* tile beside it in that direction swaps the two, so Down past a tile is the
|
|
105
|
+
* mirror of Up past it; otherwise the tile steps and whatever it lands on is
|
|
106
|
+
* pushed down. Returns the tiles unchanged when the tile is at the grid's edge.
|
|
107
|
+
*/
|
|
108
|
+
export declare function stepPlaced(tiles: readonly DashboardTile[], index: number, rows: -1 | 0 | 1, cols: -1 | 0 | 1, columns: number): DashboardTile[];
|
|
109
|
+
/**
|
|
110
|
+
* The widest a tile may be dragged: the whole grid, or, for a placed tile, up
|
|
111
|
+
* to the grid's right edge from its column. A right edge dragged past the grid
|
|
112
|
+
* stops there; it never moves the tile's left edge.
|
|
113
|
+
*/
|
|
114
|
+
export declare const widestFrom: (tile: DashboardTile | undefined, columns: number) => number;
|
|
115
|
+
/**
|
|
116
|
+
* A tile given a chart that plots (anything but value cards or a table) at
|
|
117
|
+
* fewer rows than a chart draws in, raised to that floor. A tile set to two
|
|
118
|
+
* rows as a table and then switched to a line chart in its menu would
|
|
119
|
+
* otherwise keep two rows, where the plot has no room and the renderer fails.
|
|
120
|
+
*/
|
|
121
|
+
export declare function holdChartRows(tile: DashboardTile): DashboardTile;
|
|
@@ -16,18 +16,27 @@ import { DashboardDocument, QueryTile } from './document';
|
|
|
16
16
|
* moment it is added rather than after a save.
|
|
17
17
|
*/
|
|
18
18
|
/**
|
|
19
|
-
* The controls this document shows
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* the model (`modelReads`, from {@link givensReadThroughModel}).
|
|
19
|
+
* The controls this document shows, in the order the reader shows them: every
|
|
20
|
+
* given some tile binds in this file or reads through the model (`modelReads`,
|
|
21
|
+
* from {@link givensReadThroughModel}).
|
|
23
22
|
*
|
|
24
23
|
* That is the reader's rule — only a given some tile reads becomes a control
|
|
25
|
-
* — applied to the document instead of the manifest
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
24
|
+
* — applied to the document instead of the manifest, and so is the order. The
|
|
25
|
+
* server builds the row tile by tile, in tile order, each tile's givens as its
|
|
26
|
+
* compiled query reads them: what the tile's source reads first, then the
|
|
27
|
+
* tile's own `where:` bindings. So here too: per tile, the givens its served
|
|
28
|
+
* self read (`servedReads`), less the bindings since removed, then the tile's
|
|
29
|
+
* current bindings not already listed — a new filter lands after the tile's
|
|
30
|
+
* existing ones, where the save will put it. A model read no tile position
|
|
31
|
+
* accounts for (no `servedReads` given) goes first, in the manifest's order,
|
|
32
|
+
* since a model read is a source's and the reader lists a source's first.
|
|
33
|
+
*
|
|
34
|
+
* A local declaration is built into a `Given` from its control contract, and
|
|
35
|
+
* wins over a model given of the same name; a model given is the manifest's
|
|
36
|
+
* own spec, which carries what the file cannot say (`givenNames` a suggest is
|
|
37
|
+
* gated by, for one).
|
|
29
38
|
*/
|
|
30
|
-
export declare function previewGivens(document: DashboardDocument, modelSpecs: readonly Given[], modelReads?: ReadonlySet<string>): Given[];
|
|
39
|
+
export declare function previewGivens(document: DashboardDocument, modelSpecs: readonly Given[], modelReads?: ReadonlySet<string>, servedReads?: ReadonlyMap<string, readonly string[]>): Given[];
|
|
31
40
|
/**
|
|
32
41
|
* The givens the document's tiles read through the model rather than through
|
|
33
42
|
* a binding in this file: a source whose own `where:` reads a given, say.
|
|
@@ -69,7 +78,45 @@ export interface PreviewTileQuery {
|
|
|
69
78
|
* side reads no given either.
|
|
70
79
|
*/
|
|
71
80
|
reads: string[] | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* The package model to run on instead of the report's own. Set only where
|
|
83
|
+
* the tile's source comes in through an import the served report does not
|
|
84
|
+
* have yet; see {@link UnsavedSources}.
|
|
85
|
+
*/
|
|
86
|
+
modelPath?: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* What the builder added that the served model does not have yet, so a tile on
|
|
90
|
+
* it can be previewed before the save.
|
|
91
|
+
*
|
|
92
|
+
* Add tile puts a tile on the file's extension of its source, and where the
|
|
93
|
+
* file has none it declares a new one: `source: flights_tiles is flights extend
|
|
94
|
+
* { view: kpis_tile is kpis }`. Until the file is saved and served, the model
|
|
95
|
+
* the tiles run on has no `flights_tiles`, and `flights_tiles -> kpis` fails as
|
|
96
|
+
* a reference to an undefined object. A new extension declares no `where:` and
|
|
97
|
+
* no field, so its views are its base's, and `flights -> kpis` returns what the
|
|
98
|
+
* saved page will.
|
|
99
|
+
*/
|
|
100
|
+
export interface UnsavedSources {
|
|
101
|
+
/** The document's extensions that the served model does not declare. */
|
|
102
|
+
sources: ReadonlySet<string>;
|
|
103
|
+
/**
|
|
104
|
+
* The package path of the model to run `base` on, when the served report
|
|
105
|
+
* cannot see `base` because its import is unsaved too. Undefined: the
|
|
106
|
+
* report's own model sees it.
|
|
107
|
+
*/
|
|
108
|
+
modelOf?: (base: string) => string | undefined;
|
|
72
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* The {@link UnsavedSources} of `document` against the document as it was
|
|
112
|
+
* opened, which is what the served model was built from. Undefined when the
|
|
113
|
+
* document declares no extension the opened one did not.
|
|
114
|
+
*
|
|
115
|
+
* A base the opened file could not see came in with an import this session
|
|
116
|
+
* added, and runs on the model that import names. A report held as text has no
|
|
117
|
+
* imports: its sources are all the run model's.
|
|
118
|
+
*/
|
|
119
|
+
export declare function unsavedSources(document: DashboardDocument, opened: DashboardDocument, documentPath: string, textHeld: boolean): UnsavedSources | undefined;
|
|
73
120
|
/**
|
|
74
121
|
* A tile's query with the DOCUMENT's bindings, run on the dashboard's own
|
|
75
122
|
* extension.
|
|
@@ -109,4 +156,6 @@ export interface PreviewTileQuery {
|
|
|
109
156
|
*/
|
|
110
157
|
export declare function previewTileQuery(document: DashboardDocument, tile: QueryTile, runnable: ReadonlySet<string>, values?: ReadonlyMap<string, GivenValue>,
|
|
111
158
|
/** What the served file's compiled tile reads (`DashboardTile.givenNames`), when it has this tile. */
|
|
112
|
-
served?: readonly string[]
|
|
159
|
+
served?: readonly string[],
|
|
160
|
+
/** What the served model does not have yet; see {@link UnsavedSources}. */
|
|
161
|
+
unsaved?: UnsavedSources): PreviewTileQuery;
|
|
@@ -37,9 +37,11 @@ interface TileSortableHandles {
|
|
|
37
37
|
* `index` is the tile's place in the PREVIEWED order, which is what lets the
|
|
38
38
|
* library animate a tile to its new slot when that order changes under it.
|
|
39
39
|
*/
|
|
40
|
-
export declare function TileSortable({ id, index, children, }: {
|
|
40
|
+
export declare function TileSortable({ id, index, disabled, children, }: {
|
|
41
41
|
id: string;
|
|
42
42
|
index: number;
|
|
43
|
+
/** Not movable now: the grid is drawn as one column, where a move means nothing. */
|
|
44
|
+
disabled?: boolean;
|
|
43
45
|
children: (handles: TileSortableHandles) => ReactNode;
|
|
44
46
|
}): import("react/jsx-runtime").JSX.Element;
|
|
45
47
|
/** What a gap drop target carries: the key of the tile the gap follows. */
|
|
@@ -65,4 +67,13 @@ export declare function GapDroppable({ id, after, children, }: {
|
|
|
65
67
|
isDropTarget: boolean;
|
|
66
68
|
}) => ReactNode;
|
|
67
69
|
}): import("react/jsx-runtime").JSX.Element;
|
|
70
|
+
/**
|
|
71
|
+
* Escape cancels a drag wherever focus is. The library's pointer drag listens
|
|
72
|
+
* for Escape only on the element under the pointer, and a press on a tile's
|
|
73
|
+
* padding focuses nothing, so the key reached the page instead and the drop
|
|
74
|
+
* landed on release. Mounted inside the drag provider while a drag is live.
|
|
75
|
+
*/
|
|
76
|
+
export declare function EscapeCancelsDrag({ active }: {
|
|
77
|
+
active: boolean;
|
|
78
|
+
}): any;
|
|
68
79
|
export {};
|
|
@@ -62,7 +62,7 @@ export interface BuilderSessionOptions<D, L extends LastSave = LastSave> {
|
|
|
62
62
|
/** Runs before every save entry point, handing it the save to run once the document is ready. */
|
|
63
63
|
prepare?: (run: () => Promise<void> | void) => Promise<void> | void;
|
|
64
64
|
/** The builder's own keys, less undo, redo and save, which the session owns. Memoized by the caller. */
|
|
65
|
-
shortcuts: Pick<BuilderShortcutHandlers, "escape" | "nudge">;
|
|
65
|
+
shortcuts: Pick<BuilderShortcutHandlers, "escape" | "nudge" | "move" | "paused">;
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
68
|
* What the dashboard and notebook builders share around their document editor:
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Undo and redo on the platform's usual keys, save on ⌘S / Ctrl+S (which the
|
|
5
5
|
* browser would otherwise take), Escape to drop the selection, and the arrow
|
|
6
|
-
* keys to nudge the selected tile's width a column at a time
|
|
6
|
+
* keys to nudge the selected tile's width a column at a time; with Option/Alt
|
|
7
|
+
* held, they move a placed tile one cell.
|
|
7
8
|
*
|
|
8
9
|
* Nothing but Escape and save fires while a text field has focus, so typing
|
|
9
10
|
* into a title never undoes a layout. Save leaves the field first, so its
|
|
@@ -16,6 +17,13 @@ export interface BuilderShortcutHandlers {
|
|
|
16
17
|
escape: () => void;
|
|
17
18
|
/** Nudge the selected tile's width by ±1 column. Absent, the arrow keys are left alone. */
|
|
18
19
|
nudge?: (delta: 1 | -1) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Move the selected tile one cell with Option/Alt and an arrow key, on a
|
|
22
|
+
* report whose tiles are placed. Answers whether it moved one: when it did
|
|
23
|
+
* not (nothing placed is selected), the key is left to the browser, which
|
|
24
|
+
* uses Alt with an arrow for Back and Forward.
|
|
25
|
+
*/
|
|
26
|
+
move?: (rows: -1 | 0 | 1, cols: -1 | 0 | 1) => boolean;
|
|
19
27
|
/** A modal owns the keyboard: no shortcut fires, so none can open a second dialog over it. */
|
|
20
28
|
paused?: boolean;
|
|
21
29
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { DashboardTile } from './document';
|
|
3
|
+
/** The edges a resize moves: one for an edge, two for a corner. */
|
|
4
|
+
export interface Edges {
|
|
5
|
+
n?: boolean;
|
|
6
|
+
s?: boolean;
|
|
7
|
+
e?: boolean;
|
|
8
|
+
w?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** A tile's place and size, as a resize changes them. `rowspan` absent is auto height. */
|
|
11
|
+
export interface TileShape {
|
|
12
|
+
row?: number;
|
|
13
|
+
col?: number;
|
|
14
|
+
colspan: number;
|
|
15
|
+
rowspan: number | undefined;
|
|
16
|
+
}
|
|
17
|
+
/** A resize in flight. */
|
|
18
|
+
export interface EdgeDrag {
|
|
19
|
+
index: number;
|
|
20
|
+
edges: Edges;
|
|
21
|
+
/** The tiles it started from: placed where they were drawn, when a left or top edge needs places. */
|
|
22
|
+
base: DashboardTile[];
|
|
23
|
+
/** Whether this gesture placed them, which the write then has to keep. */
|
|
24
|
+
placedHere: boolean;
|
|
25
|
+
/** Whether the report is placed for this gesture: the edges then move on the grid's own rows. */
|
|
26
|
+
placed: boolean;
|
|
27
|
+
from: TileShape;
|
|
28
|
+
/** The shape the drag began at, as it is drawn: a release here writes nothing. */
|
|
29
|
+
begun: TileShape;
|
|
30
|
+
/** What the tile would be if the pointer let go now. */
|
|
31
|
+
shape: TileShape;
|
|
32
|
+
/** The tile's top against the grid's, where the row guides of a flowing report are drawn from. */
|
|
33
|
+
guideTop: number;
|
|
34
|
+
/** The fewest rows offered, read off what the tile draws when the drag began. */
|
|
35
|
+
min: number;
|
|
36
|
+
/** The tile's top and left on the page when it began, for a flowing report's edges. */
|
|
37
|
+
top: number;
|
|
38
|
+
left: number;
|
|
39
|
+
}
|
|
40
|
+
/** The cursor an edge, or a corner, takes. */
|
|
41
|
+
export declare const edgeCursor: (edges: Edges) => string;
|
|
42
|
+
/**
|
|
43
|
+
* `tile` with what a resize of `edges` changed on it, and nothing else: a
|
|
44
|
+
* right or left edge its width (and, placed, its column), a bottom or top
|
|
45
|
+
* edge its height (and, placed, its row). So a height drag never writes the
|
|
46
|
+
* width a tile happens to be drawn at.
|
|
47
|
+
*/
|
|
48
|
+
export declare function withShape(tile: DashboardTile, shape: TileShape, edges: Edges, placed: boolean): DashboardTile;
|
|
49
|
+
/** What a resize asks the caller to write. */
|
|
50
|
+
export interface EdgeResult {
|
|
51
|
+
index: number;
|
|
52
|
+
edges: Edges;
|
|
53
|
+
shape: TileShape;
|
|
54
|
+
placed: boolean;
|
|
55
|
+
/** Every tile placed where it was drawn, when this gesture is what placed the report. */
|
|
56
|
+
placedAll?: DashboardTile[];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Dragging any edge or corner of a tile. The right edge sets its width and
|
|
60
|
+
* the bottom edge its height, as they always have; the left and top edges
|
|
61
|
+
* move that edge and keep the opposite one where it is, which needs the
|
|
62
|
+
* tile's row and column, so on a report that flows they place every tile
|
|
63
|
+
* where it is drawn first, as a move does. A corner moves its two edges at
|
|
64
|
+
* once. Previewed from `drag.shape` and written ONCE, on release, so one
|
|
65
|
+
* gesture is one undo step.
|
|
66
|
+
*/
|
|
67
|
+
export declare function useEdgeResize({ tiles, columns, gridBox, onStart, commit, }: {
|
|
68
|
+
/** The tiles as drawn: one with no `colspan` carries the span it is drawn at. */
|
|
69
|
+
tiles: readonly DashboardTile[];
|
|
70
|
+
columns: number;
|
|
71
|
+
/** Wraps the grid, so its box is the grid's. */
|
|
72
|
+
gridBox: RefObject<HTMLDivElement | null>;
|
|
73
|
+
/** The tile a drag begins on, which the caller selects. */
|
|
74
|
+
onStart: (index: number) => void;
|
|
75
|
+
/** What to write when the drag ends. */
|
|
76
|
+
commit: (result: EdgeResult) => void;
|
|
77
|
+
}): {
|
|
78
|
+
drag: EdgeDrag;
|
|
79
|
+
start: (event: React.PointerEvent<HTMLElement>, index: number, edges: Edges) => void;
|
|
80
|
+
move: (event: React.PointerEvent<HTMLElement>) => void;
|
|
81
|
+
end: (event: React.PointerEvent<HTMLElement>) => void;
|
|
82
|
+
};
|
|
83
|
+
/** What a resize would make a tile, in words, for the label beside the pointer. */
|
|
84
|
+
export declare function shapeLabel(drag: EdgeDrag, columns: number): string;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { DragEndEvent, DragOverEvent } from '@dnd-kit/react';
|
|
1
|
+
import { DragEndEvent, DragMoveEvent, DragOverEvent } from '@dnd-kit/react';
|
|
2
|
+
import { RefObject } from 'react';
|
|
2
3
|
import { DashboardTile } from './document';
|
|
4
|
+
import { Box } from './placement';
|
|
5
|
+
/** The boxes of the tiles as drawn, against the grid's top left corner, by tile key. */
|
|
6
|
+
export declare function drawnBoxes(grid: HTMLElement): Map<string, Box>;
|
|
3
7
|
/**
|
|
4
8
|
* Dragging a tile to reorder it. The gesture is `@dnd-kit/react`'s (see
|
|
5
9
|
* `sortable.tsx`); what is decided here is what a drop means for the file,
|
|
@@ -7,8 +11,18 @@ import { DashboardTile } from './document';
|
|
|
7
11
|
* drop into the empty end of a row. The preview is rebuilt on each report and
|
|
8
12
|
* written ONCE, on release: one history entry for the whole drag.
|
|
9
13
|
*/
|
|
10
|
-
export declare function useTileReorder({ tiles, commit, onLanded, }: {
|
|
14
|
+
export declare function useTileReorder({ tiles, commit, onLanded, placement, }: {
|
|
11
15
|
tiles: DashboardTile[];
|
|
16
|
+
/**
|
|
17
|
+
* Set on a grid report, where a move is free placement: the tile lands in
|
|
18
|
+
* the cell under it and anything it covers is pushed down. Absent, a move
|
|
19
|
+
* reorders the tiles, as a linear report's does.
|
|
20
|
+
*/
|
|
21
|
+
placement?: {
|
|
22
|
+
columns: number;
|
|
23
|
+
/** Wraps the grid, so its box is the grid's. */
|
|
24
|
+
gridBox: RefObject<HTMLDivElement | null>;
|
|
25
|
+
};
|
|
12
26
|
/** The order to write when the drag ends somewhere new. */
|
|
13
27
|
commit: (next: DashboardTile[]) => void;
|
|
14
28
|
/** Where the dragged tile came to rest, which the caller selects. */
|
|
@@ -16,7 +30,20 @@ export declare function useTileReorder({ tiles, commit, onLanded, }: {
|
|
|
16
30
|
}): {
|
|
17
31
|
dragging: boolean;
|
|
18
32
|
preview: DashboardTile[];
|
|
19
|
-
onDragStart: (
|
|
33
|
+
onDragStart: (event?: {
|
|
34
|
+
operation: {
|
|
35
|
+
source: {
|
|
36
|
+
id: unknown;
|
|
37
|
+
} | null;
|
|
38
|
+
position?: {
|
|
39
|
+
current: {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
}) => void;
|
|
46
|
+
onDragMove: (event: DragMoveEvent) => void;
|
|
20
47
|
onDragOver: (event: DragOverEvent) => void;
|
|
21
48
|
onDragEnd: (event: DragEndEvent) => void;
|
|
22
49
|
};
|