@malloy-publisher/sdk 0.9.15 → 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-BClN_PG6.cjs.js → RenderedResult-5hOs5XnV.cjs.js} +21 -4
- package/dist/{RenderedResult-YBzVMVH2.es.js → RenderedResult-DxmHGZNQ.es.js} +204 -187
- package/dist/builder/index.cjs.js +75 -75
- package/dist/builder/index.es.js +5329 -5193
- package/dist/builder-entry.d.ts +1 -1
- package/dist/client/api.d.ts +1 -1
- package/dist/components/Dashboard/DashboardGrid.d.ts +2 -0
- package/dist/components/Dashboard/DashboardTile.d.ts +3 -1
- package/dist/components/RenderedResult/ResultContainer.d.ts +8 -1
- package/dist/components/RenderedResult/ResultPanel.d.ts +3 -1
- package/dist/components/RenderedResult/resultSizing.d.ts +5 -0
- package/dist/components/ReportBuilder/ArrangeMenu.d.ts +9 -0
- package/dist/components/ReportBuilder/BuilderGrid.d.ts +5 -7
- package/dist/components/ReportBuilder/BuilderToolbar.d.ts +3 -1
- package/dist/components/ReportBuilder/ReportBuilder.d.ts +1 -1
- package/dist/components/ReportBuilder/TileFrame.d.ts +34 -22
- package/dist/components/ReportBuilder/builderControls.d.ts +19 -0
- package/dist/components/ReportBuilder/placement.d.ts +48 -2
- package/dist/components/ReportBuilder/sortable.d.ts +9 -0
- 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 +3 -0
- package/dist/index.cjs.js +5 -5
- package/dist/index.es.js +489 -488
- package/dist/theme/classes.d.ts +1 -1
- package/dist/{useCompiledDocument-BGk38oaW.es.js → useCompiledDocument-CaYP_OYG.es.js} +4021 -4007
- package/dist/{useCompiledDocument-D9t5ry_t.cjs.js → useCompiledDocument-zYEfLogf.cjs.js} +32 -32
- package/package.json +1 -1
- package/src/builder-entry.ts +1 -0
- package/src/components/Dashboard/DashboardGrid.tsx +2 -0
- package/src/components/Dashboard/DashboardTile.tsx +4 -0
- package/src/components/Dashboard/DashboardView.tsx +1 -0
- package/src/components/RenderedResult/RenderedResult.tsx +18 -0
- package/src/components/RenderedResult/ResultContainer.tsx +39 -3
- package/src/components/RenderedResult/ResultPanel.tsx +4 -0
- package/src/components/RenderedResult/resultSizing.ts +6 -0
- package/src/components/ReportBuilder/ArrangeMenu.tsx +80 -0
- package/src/components/ReportBuilder/BuilderBar.tsx +4 -0
- package/src/components/ReportBuilder/BuilderDialogs.tsx +8 -1
- package/src/components/ReportBuilder/BuilderGrid.tsx +61 -60
- package/src/components/ReportBuilder/BuilderToolbar.tsx +4 -0
- package/src/components/ReportBuilder/EditorSurface.tsx +9 -2
- package/src/components/ReportBuilder/ReportBuilder.spec.tsx +99 -0
- package/src/components/ReportBuilder/ReportBuilder.tsx +110 -30
- package/src/components/ReportBuilder/TileFrame.tsx +261 -310
- package/src/components/ReportBuilder/builderControls.ts +34 -0
- package/src/components/ReportBuilder/placement.spec.ts +208 -0
- package/src/components/ReportBuilder/placement.ts +175 -9
- package/src/components/ReportBuilder/readDocument.spec.ts +7 -17
- package/src/components/ReportBuilder/readDocument.ts +3 -6
- package/src/components/ReportBuilder/sortable.tsx +26 -2
- package/src/components/ReportBuilder/spliceDocument.spec.ts +0 -40
- package/src/components/ReportBuilder/spliceDocument.ts +0 -39
- 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/useTileReorder.ts +1 -1
- package/src/theme/classes.ts +1 -1
- package/dist/components/ReportBuilder/useTileHeight.d.ts +0 -39
- package/dist/components/ReportBuilder/useTileResize.d.ts +0 -40
- package/src/components/ReportBuilder/useTileHeight.ts +0 -149
- package/src/components/ReportBuilder/useTileResize.spec.tsx +0 -146
- package/src/components/ReportBuilder/useTileResize.ts +0 -148
package/dist/builder-entry.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { ReportBuilder } from './components/ReportBuilder/ReportBuilder';
|
|
2
2
|
export type { FixedFilter } from './components/ReportBuilder/FilterStrip';
|
|
3
3
|
export { BuilderBar, type BuilderBarProps, } from './components/ReportBuilder/BuilderBar';
|
|
4
|
-
export type { BuilderControls, BuilderControlsHandler, } from './components/ReportBuilder/builderControls';
|
|
4
|
+
export type { ArrangeActions, BuilderControls, BuilderControlsHandler, } from './components/ReportBuilder/builderControls';
|
|
5
5
|
export type { RestoredDraft } from './components/ReportBuilder/useReportDraft';
|
|
6
6
|
export type { BuilderGiven, ReportBuilderProps, } from './components/ReportBuilder/ReportBuilder';
|
|
7
7
|
export { ReportEditor, type ReportEditorProps, type TextSourceOptions, } from './components/ReportBuilder/ReportEditor';
|
package/dist/client/api.d.ts
CHANGED
|
@@ -1675,7 +1675,7 @@ export interface Package {
|
|
|
1675
1675
|
*/
|
|
1676
1676
|
'exploresWarnings'?: Array<string>;
|
|
1677
1677
|
/**
|
|
1678
|
-
* Non-fatal findings collected when the package loaded, none of which stop the model compiling or the package loading. Render-tag findings: a render annotation (e.g. `# big_value`, `# currency` or `# colspan`) the renderer cannot apply as written, either malformed for the field it sits on, so it renders as \"[object Object]\" or an inline error at query time, or inert where it sits and silently ignored. Materialization findings: a `storage=` source not served from storage, a `#@ persist` source that was not recognized as materializable, a `#@ persist` REFUSED by the compile-time eligibility gate (one entry per `BuildPlan.refusedSources` member, carrying that gate\'s own message), a persist-target collision, and materialization-config problems that degrade attribution. A refusal is the one materialization finding the build plan cannot also be read for: a refused `storage`/`colocated` source is ABSENT from `BuildPlan.sources`, so nothing there records that the annotation was written at all. Discovery findings: a model on the package\'s surface whose export closure surfaces no sources or named queries, so it lists as empty and renders a blank page; a surface whose every model failed to compile, so every model in the package answers 404 by name; and, on the reload that caused it, a package that had a surface and now has none, so every source that surface hid is listed and queryable by name again. Manifest findings: each deprecated use of `explores` or of `queryableSources: \"declared\"`, and a root file such as `Index.malloy` that differs from `index.malloy` only in case and so is ignored. A root `index.malloy` with no manifest keys gets no warning. Report findings (one lint pass per report, of either layout, wherever it lives): a file whose artifact tag does not parse or does not describe a report, a tile or suggest query that does not resolve, a `# drill` naming a destination that is not a report, and a tile, single query or filter suggest that reads a source the surface does not export, so it won\'t load. A `# drill` destination is a path from the package root (a bare name is a file at the root); one that names no report is unresolved (`error`). Curation findings: a root `index.malloy` carrying an artifact tag, which is ignored (`index-is-not-a-report`, `error`); and a report that `index.malloy` imports or `explores` lists (`report-on-surface`, `warn`). Two report findings are about Publisher rather than about the package: one when a file carrying an artifact tag could not be read and so is not served at all, and one when the lint stops early, in which case the list must be read as incomplete rather than as a clean package. A linear report whose cells could not be read gets a finding that names the line and the fix and is reported with severity `error`, because it is served with that error instead of opening. The per-file report findings each name their line and the fix and carry a `code`; they are computed at discovery and are also returned by `/compile` at file and package scope. These codes are `error` and fail `/compile`: `notebook-
|
|
1678
|
+
* Non-fatal findings collected when the package loaded, none of which stop the model compiling or the package loading. Render-tag findings: a render annotation (e.g. `# big_value`, `# currency` or `# colspan`) the renderer cannot apply as written, either malformed for the field it sits on, so it renders as \"[object Object]\" or an inline error at query time, or inert where it sits and silently ignored. Materialization findings: a `storage=` source not served from storage, a `#@ persist` source that was not recognized as materializable, a `#@ persist` REFUSED by the compile-time eligibility gate (one entry per `BuildPlan.refusedSources` member, carrying that gate\'s own message), a persist-target collision, and materialization-config problems that degrade attribution. A refusal is the one materialization finding the build plan cannot also be read for: a refused `storage`/`colocated` source is ABSENT from `BuildPlan.sources`, so nothing there records that the annotation was written at all. Discovery findings: a model on the package\'s surface whose export closure surfaces no sources or named queries, so it lists as empty and renders a blank page; a surface whose every model failed to compile, so every model in the package answers 404 by name; and, on the reload that caused it, a package that had a surface and now has none, so every source that surface hid is listed and queryable by name again. Manifest findings: each deprecated use of `explores` or of `queryableSources: \"declared\"`, and a root file such as `Index.malloy` that differs from `index.malloy` only in case and so is ignored. A root `index.malloy` with no manifest keys gets no warning. Report findings (one lint pass per report, of either layout, wherever it lives): a file whose artifact tag does not parse or does not describe a report, a tile or suggest query that does not resolve, a `# drill` naming a destination that is not a report, and a tile, single query or filter suggest that reads a source the surface does not export, so it won\'t load. A `# drill` destination is a path from the package root (a bare name is a file at the root); one that names no report is unresolved (`error`). Curation findings: a root `index.malloy` carrying an artifact tag, which is ignored (`index-is-not-a-report`, `error`); and a report that `index.malloy` imports or `explores` lists (`report-on-surface`, `warn`). Two report findings are about Publisher rather than about the package: one when a file carrying an artifact tag could not be read and so is not served at all, and one when the lint stops early, in which case the list must be read as incomplete rather than as a clean package. A linear report whose cells could not be read gets a finding that names the line and the fix and is reported with severity `error`, because it is served with that error instead of opening. The per-file report findings each name their line and the fix and carry a `code`; they are computed at discovery and are also returned by `/compile` at file and package scope. These codes are `error` and fail `/compile`: `notebook-markdown-opener-text` (more than a name after `(markdown)` on a block\'s opener), `notebook-markdown-attached-nowhere` (a `#(markdown)` annotation with no statement to take it), `notebook-artifact-unparsed` (an `## artifact` tag does not parse), and `notebook-cells-unreadable` (the reader could not read a linear report\'s cells), plus `report-kind-removed` (a tag that sets `kind=`, which is no longer read, so the file is not a report; the finding names the `layout=` to write), `report-cells-removed` (a linear tag that lists no `tiles`, the retired `run:` cell format, so the file is not a report; the fix is to list its tiles in `tiles=[…]`) and `report-layout-unknown` (a `layout=` other than `grid` or `linear`). The rest are `warn` (a mistyped `(markdown)` opener, a block that never closes, and similar). Skill and agent findings, all `warn`: a package skill under `skills/` that is not served (unreadable or linked-out `SKILL.md`, a frontmatter `name` that is not its directory name, a `skills/` directory that links out of the package) or served with a gap (no `description`, a `reference/` that cannot be listed or read); and each agent the manifest declares that is not served, or is served with a finding (an agent skill with no `description`, a skills directory with no skills, an unreadable reference). Deprecated-format findings, all `warn`: each `.malloynb` notebook (`model` is its path), and each source a file declares deprecated `#(filter)` annotations on (`model` is that file, `subject` the source; a source that only inherits or imports a filter is not reported). Both still load and run. Server-computed and read-only: ignored on create/update requests and only returned in responses. Present only when there are such findings. **Almost every `#@ preaggregate` that cannot be honored REJECTS A PUBLISH — a 400 at publish or PATCH — and fails a load thereafter.** The two access-modifier violations are the exception: they warn at BOTH gates and appear in this array. See the split below. Rejected are a `#@ preaggregate` anywhere but on a measure; a `#@ preaggregate` with no `grain=`; a grain naming anything but a dimension the base source itself declares, which rules out an inline time truncation such as `order_time.day`; a measure that cannot be correctly re-aggregated to a coarser grain, whether because its aggregate has no exact merge function (`count(distinct)`, `median`, percentiles, `mode`, and `avg` until it is decomposed) or because it carries its own filter, an ungrouping (`all`, `exclude`), or a required group-by; a measure whose expression cannot be POSITIVELY classified as re-aggregatable, which fails closed rather than being guessed at; a base source with a FAN-OUT join (`join_many` or `join_cross`), which can multiply rows, while a `join_one` is permitted and a measure aggregating through one is served normally; a base source that already fails persist eligibility (unbound parameters, `given` references, authorize gates); `sharing=` or `schedule=` at the resource level; and a synthesized rollup name that collides with an existing model object. WARNED rather than rejected, at publish and at load alike, is a `#@ preaggregate` on a measure the source does not publicly expose, or a grain naming a hidden dimension — a rollup STORES its grain and each measure\'s partial, and the stored table is served under the base\'s name without the source\'s field visibility applying to it. Each names the measure and the fix. Refusing rather than silently dropping the measure is the deliberate choice. A dropped measure is not served from the rollup at ANY grain, so the declaration would have no effect whatsoever while still reading as applied — and the build cost of the rollup would still be paid. An author who writes `#@ preaggregate` on a measure that cannot be rolled up has made a modeling mistake, and an error is where a mistake belongs. The same verdict is enforced at LOAD for every violation EXCEPT the two access-modifier ones, so a package whose declarations stopped being honorable does not load at all: it is absent from its environment and reported in `ServerStatus.loadErrors`. Worth knowing because whether a measure can be re-aggregated is derived from the compiled model, so a Malloy version change can in principle reclassify a measure that published cleanly long before. That surfaces as a package that stops loading rather than as a package quietly serving without its rollups — louder, and deliberately so, since the alternative is paying for rollups that answer nothing. The two access-modifier violations are the deliberate exception, and for two reasons rather than a lesser severity. They WARN at publish and at load alike and appear in this array. First, a package annotating a hidden field published and loaded before this rule existed — refusing it would stop an already-published package from doing either because a new validation was added, which is not a thing a server upgrade may do. Second, the refusal was unfollowable: an annotation INHERITED onto a source that then hides the measure raises it, while that source produces no plan at all and nothing is exposed, so the advice to make the field public or drop the annotation asks an author to give up either the hiding or the rollup over a model that was already safe. Warning is safe here and would not be for the others: what keeps a hidden field out of a rollup is that the planner refuses to plan one at all, so no table is built and nothing can be served whether or not anyone reads the message. For the other violations the refusal IS the enforcement, which is why they stay fatal.
|
|
1679
1679
|
*/
|
|
1680
1680
|
'warnings'?: Array<PackageWarningsInner>;
|
|
1681
1681
|
/**
|
|
@@ -40,6 +40,8 @@ export declare const TILE_ROW_PX = 80;
|
|
|
40
40
|
* heading and axes, and the renderer failed on it. Prose fits in one.
|
|
41
41
|
*/
|
|
42
42
|
export declare const MIN_TILE_ROWS = 3;
|
|
43
|
+
/** A query tile that draws no chart (value cards, a table) goes down to two rows. */
|
|
44
|
+
export declare const MIN_VALUE_TILE_ROWS = 2;
|
|
43
45
|
export declare const MIN_TEXT_TILE_ROWS = 1;
|
|
44
46
|
export declare const MAX_TILE_ROWS = 16;
|
|
45
47
|
/**
|
|
@@ -42,6 +42,8 @@ export interface DashboardTileProps {
|
|
|
42
42
|
height: number | undefined;
|
|
43
43
|
/** A further cap when the result is a table, past which it scrolls under its pinned header. */
|
|
44
44
|
tableMaxHeight?: number;
|
|
45
|
+
/** The tile has a set height (rows of its own): a result taller than it is drawn compact. */
|
|
46
|
+
fixedHeight?: boolean;
|
|
45
47
|
maxResultSize?: number;
|
|
46
48
|
/** Cell clicks and their affordance, for the dashboard's `# drill`. */
|
|
47
49
|
drill?: DrillBinding;
|
|
@@ -90,4 +92,4 @@ export declare function tileTitle(tile: string): string;
|
|
|
90
92
|
* tile: the broken one shows its error in place and the rest of the grid still
|
|
91
93
|
* renders, rather than one failure blanking the page.
|
|
92
94
|
*/
|
|
93
|
-
export declare function DashboardTile({ environmentName, packageName, versionId, modelPath, queryName, tile, annotation, label, subtitle, heading, borderless, givens, hostGivens, declaredTypes, givenNames, height, tableMaxHeight, maxResultSize, drill, onExplore, chrome, ignoredFilters, preamble, restricted, waitingFor, index, }: DashboardTileProps): import("react/jsx-runtime").JSX.Element;
|
|
95
|
+
export declare function DashboardTile({ environmentName, packageName, versionId, modelPath, queryName, tile, annotation, label, subtitle, heading, borderless, givens, hostGivens, declaredTypes, givenNames, height, tableMaxHeight, fixedHeight, maxResultSize, drill, onExplore, chrome, ignoredFilters, preamble, restricted, waitingFor, index, }: DashboardTileProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -29,6 +29,13 @@ interface ResultContainerProps {
|
|
|
29
29
|
* tile's card is. Leave it off wherever the result sets the surface's height.
|
|
30
30
|
*/
|
|
31
31
|
fill?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The cell's height is set (a tile given rows), not its content's: only
|
|
34
|
+
* then is a result taller than it drawn compact to fit. A cell that grows
|
|
35
|
+
* with its content is briefly shorter than a result that just grew, and
|
|
36
|
+
* compact there would be a mistake that never undoes itself.
|
|
37
|
+
*/
|
|
38
|
+
compactToFit?: boolean;
|
|
32
39
|
}
|
|
33
|
-
export default function ResultContainer({ result, maxHeight, tableMaxHeight, firstPaintHeight, maxResultSize, renderLogs, drill, fill, }: ResultContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
40
|
+
export default function ResultContainer({ result, maxHeight, tableMaxHeight, firstPaintHeight, maxResultSize, renderLogs, drill, fill, compactToFit, }: ResultContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
34
41
|
export {};
|
|
@@ -15,6 +15,8 @@ export interface ResultPanelProps {
|
|
|
15
15
|
drill?: DrillBinding;
|
|
16
16
|
/** See `ResultContainer`: stretch the result to its cell. */
|
|
17
17
|
fill?: boolean;
|
|
18
|
+
/** The cell has a set height: a result taller than it is drawn compact (see `ResultContainer`). */
|
|
19
|
+
compactToFit?: boolean;
|
|
18
20
|
/**
|
|
19
21
|
* Rewrites the result before it is rendered — a dashboard tile promotes a
|
|
20
22
|
* one-row measure result to KPI cards this way. Memoized on the result
|
|
@@ -33,4 +35,4 @@ export interface ResultPanelProps {
|
|
|
33
35
|
* survive a bad tile: the broken one shows its error in place and the rest of
|
|
34
36
|
* the grid still renders.
|
|
35
37
|
*/
|
|
36
|
-
export declare function ResultPanel({ state, context, loadingText, maxHeight, tableMaxHeight, firstPaintHeight, maxResultSize, drill, fill, transform, }: ResultPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
export declare function ResultPanel({ state, context, loadingText, maxHeight, tableMaxHeight, firstPaintHeight, maxResultSize, drill, fill, compactToFit, transform, }: ResultPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -225,3 +225,8 @@ export declare function resolveResultHeight({ sizing, contentHeight, maxHeight,
|
|
|
225
225
|
/** See {@link initialResultHeight}. */
|
|
226
226
|
firstPaintHeight?: number | undefined;
|
|
227
227
|
}): number;
|
|
228
|
+
/**
|
|
229
|
+
* On a result's box while it is drawn compact to fit a cell shorter than it
|
|
230
|
+
* (`ResultContainer` sets it); the renderer overrides in `RenderedResult` read it.
|
|
231
|
+
*/
|
|
232
|
+
export declare const TIGHT_ATTR = "data-publisher-tight";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ArrangeActions } from './builderControls';
|
|
2
|
+
/**
|
|
3
|
+
* The layout of a placed grid report as a whole: closing its gaps, or letting
|
|
4
|
+
* its tiles flow again. One menu shared by the builder's own toolbar and the
|
|
5
|
+
* bar a host draws, so the two cannot offer different things.
|
|
6
|
+
*/
|
|
7
|
+
export declare function ArrangeMenu({ arrange }: {
|
|
8
|
+
arrange: ArrangeActions;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,19 +4,17 @@ import { LayoutRules } from '../Report/layoutRules';
|
|
|
4
4
|
import { DashboardTile, QueryTile } from './document';
|
|
5
5
|
import { ReportEditorHandle } from './useReportEditor';
|
|
6
6
|
import { useTileReorder } from './useTileReorder';
|
|
7
|
-
import {
|
|
8
|
-
import { useTileResize } from './useTileResize';
|
|
7
|
+
import { useEdgeResize } from './useEdgeResize';
|
|
9
8
|
/**
|
|
10
9
|
* The builder's tiles, on the SAME grid the dashboard renders on, each drawn
|
|
11
10
|
* by the caller's `renderTile` inside a `TileFrame` that carries the
|
|
12
|
-
* affordances: selection, the
|
|
11
|
+
* affordances: selection, the menu, and its edges and corners.
|
|
13
12
|
*/
|
|
14
|
-
export declare function BuilderGrid({ editor, reorder,
|
|
13
|
+
export declare function BuilderGrid({ editor, reorder, edging, place, arrange, gridBox, defaultSpan, rules, canAdd, selected, flash, menuIndex, onSelect, onOpenMenu, onRemove, removeBlocked, openAdd, editTile, renderTile, }: {
|
|
15
14
|
editor: ReportEditorHandle;
|
|
16
15
|
reorder: ReturnType<typeof useTileReorder>;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
sizing?: ReturnType<typeof useTileHeight>;
|
|
16
|
+
/** Every edge and corner of a tile, dragged to resize it. */
|
|
17
|
+
edging: ReturnType<typeof useEdgeResize>;
|
|
20
18
|
/**
|
|
21
19
|
* The tiles after the one at `index` changed size: on a placed report,
|
|
22
20
|
* whatever it now covers pushed down. Identity elsewhere.
|
|
@@ -120,6 +120,8 @@ export interface BuilderToolbarProps {
|
|
|
120
120
|
actions?: ReactNode;
|
|
121
121
|
/** Open the add-tile picker. Absent when the host passed no catalog to pick from. */
|
|
122
122
|
onAddTile?: () => void;
|
|
123
|
+
/** The arrange menu, on a report whose tiles are placed; drawn before Tile. */
|
|
124
|
+
arrange?: ReactNode;
|
|
123
125
|
/**
|
|
124
126
|
* Leave the builder: draws Close after Save, for a host that opts in. The
|
|
125
127
|
* Console leaves from its own header and passes nothing.
|
|
@@ -132,4 +134,4 @@ export interface BuilderToolbarProps {
|
|
|
132
134
|
*/
|
|
133
135
|
saveStatus?: SaveStatusProps;
|
|
134
136
|
}
|
|
135
|
-
export declare function BuilderToolbar({ canUndo, canRedo, onUndo, onRedo, dirty, saving, onSave, savesTo, saveLabel, saveButton, actions, onAddTile, onExit, saveStatus, }: BuilderToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
137
|
+
export declare function BuilderToolbar({ canUndo, canRedo, onUndo, onRedo, dirty, saving, onSave, savesTo, saveLabel, saveButton, actions, onAddTile, arrange, onExit, saveStatus, }: BuilderToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -26,7 +26,7 @@ export type { BuilderGiven } from './controls';
|
|
|
26
26
|
* draws its own card AND its own heading. Nesting one inside a card of ours
|
|
27
27
|
* would show a card in a card under two titles — which is precisely not what a
|
|
28
28
|
* reader sees. So every affordance is drawn AROUND whatever the caller renders:
|
|
29
|
-
* an outline for selection, a
|
|
29
|
+
* an outline for selection, a menu in the corner, and edges that resize.
|
|
30
30
|
*
|
|
31
31
|
* **Everything here is on the thing it changes.** Set a tile's width from its menu, and drag
|
|
32
32
|
* the tile itself to reorder — into the empty end of a row
|
|
@@ -4,13 +4,14 @@ import { SystemStyleObject } from '@mui/system';
|
|
|
4
4
|
import { ResolvedTheme } from '../../theme/types';
|
|
5
5
|
import { TileChrome, TileHeadingSlots } from '../Dashboard/TileCard';
|
|
6
6
|
import { DashboardTile, QueryTile } from './document';
|
|
7
|
+
import { Edges } from './useEdgeResize';
|
|
7
8
|
/**
|
|
8
9
|
* Everything the builder draws AROUND a tile: the selection outline, the menu
|
|
9
|
-
* button, the
|
|
10
|
+
* button, the resize edges and corners and, in a notebook, the insert button. The tile
|
|
10
11
|
* itself is `children` — the host's real `DashboardTile`, or a placeholder
|
|
11
12
|
* saying what the tile will run.
|
|
12
13
|
*/
|
|
13
|
-
export declare function TileFrame({ tile, index, selected, flash, menuOpen, bare, onInsertAfter, onSelect, onOpenMenu, onRemove, removeBlocked,
|
|
14
|
+
export declare function TileFrame({ tile, index, selected, flash, menuOpen, bare, onInsertAfter, onSelect, onOpenMenu, onRemove, removeBlocked, width, edges, heightEdge, fixed, children, }: {
|
|
14
15
|
tile: DashboardTile;
|
|
15
16
|
index: number;
|
|
16
17
|
selected: boolean;
|
|
@@ -32,13 +33,23 @@ export declare function TileFrame({ tile, index, selected, flash, menuOpen, bare
|
|
|
32
33
|
onRemove: () => void;
|
|
33
34
|
/** Why it cannot be removed (a saved report keeps one tile); the × says so instead. */
|
|
34
35
|
removeBlocked?: string;
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
/**
|
|
37
|
+
* The tile's edges and corners, dragged to resize it. Nothing is drawn on
|
|
38
|
+
* them: the cursor turns to a two-headed arrow over an edge and a diagonal
|
|
39
|
+
* one over a corner. Absent, the tile cannot be resized by pointer.
|
|
40
|
+
*/
|
|
41
|
+
edges?: {
|
|
42
|
+
/** The right edge (and its corners): off while the grid is one column. */
|
|
43
|
+
right: boolean;
|
|
44
|
+
/** The left and top edges too, which move a place: a grid drawn as a grid. */
|
|
45
|
+
all: boolean;
|
|
46
|
+
start: (event: PointerEvent<HTMLElement>, edges: Edges) => void;
|
|
47
|
+
move: (event: PointerEvent<HTMLElement>) => void;
|
|
48
|
+
end: (event: PointerEvent<HTMLElement>) => void;
|
|
49
|
+
/** What the drag would make the tile, in words, while this tile is resized. */
|
|
50
|
+
label?: string;
|
|
51
|
+
};
|
|
52
|
+
/** The tile's width and the grid's, and a step of one column: the right edge's keyboard route. */
|
|
42
53
|
width?: {
|
|
43
54
|
span: number;
|
|
44
55
|
columns: number;
|
|
@@ -46,23 +57,20 @@ export declare function TileFrame({ tile, index, selected, flash, menuOpen, bare
|
|
|
46
57
|
max?: number;
|
|
47
58
|
onStep: (to: number) => void;
|
|
48
59
|
};
|
|
49
|
-
/**
|
|
50
|
-
* The bottom edge, which sets the height in grid rows: dragged, or focused
|
|
51
|
-
* and stepped with the arrow keys. Delete or a double-click puts the tile
|
|
52
|
-
* back to fitting its content. Absent, the tile has no bottom handle.
|
|
53
|
-
*/
|
|
54
60
|
/** The tile cannot be moved now (the grid is drawn as one column). */
|
|
55
61
|
fixed?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* The bottom edge's keyboard route: focused, the arrow keys step the height
|
|
64
|
+
* a row at a time, and Delete puts the tile back to auto height, as a
|
|
65
|
+
* double-click on the edge does.
|
|
66
|
+
*/
|
|
56
67
|
heightEdge?: {
|
|
57
68
|
/** Its rows: the set height, or the drag's preview; absent on auto, as tall as its row. */
|
|
58
69
|
rows: number | undefined;
|
|
59
|
-
/**
|
|
60
|
-
dragging: boolean;
|
|
61
|
-
/** The fewest rows offered: a chart's floor, or prose's. */
|
|
70
|
+
/** The fewest rows offered before anything is known of what the tile draws. */
|
|
62
71
|
min: number;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
onEnd: (event: PointerEvent<HTMLDivElement>) => void;
|
|
72
|
+
/** The fewest rows offered for what the tile draws now: two for cards or a table, three for a chart. */
|
|
73
|
+
minFor?: (frame: Element | null) => number;
|
|
66
74
|
/** A keyboard step, or `undefined` to fit the content again. */
|
|
67
75
|
onStep: (to: number | undefined) => void;
|
|
68
76
|
};
|
|
@@ -111,8 +119,10 @@ export declare function GapTarget({ after }: {
|
|
|
111
119
|
* Column guides, drawn only during a gesture: a flow grid is invisible until
|
|
112
120
|
* you are trying to land on it.
|
|
113
121
|
*/
|
|
114
|
-
export declare function GridGuides({ columns }: {
|
|
122
|
+
export declare function GridGuides({ columns, faint, }: {
|
|
115
123
|
columns: number;
|
|
124
|
+
/** Drawn fainter, as a hint while nothing is dragged. */
|
|
125
|
+
faint?: boolean;
|
|
116
126
|
}): import("react/jsx-runtime").JSX.Element;
|
|
117
127
|
/**
|
|
118
128
|
* The rows a height snaps to, drawn while a tile's bottom edge is dragged: a
|
|
@@ -121,6 +131,8 @@ export declare function GridGuides({ columns }: {
|
|
|
121
131
|
* tile's top, since tiles flow and the grid has no row lines of its own.
|
|
122
132
|
* Behind the tiles and held inside the grid.
|
|
123
133
|
*/
|
|
124
|
-
export declare function RowGuides({ top }: {
|
|
134
|
+
export declare function RowGuides({ top, faint, }: {
|
|
125
135
|
top: number;
|
|
136
|
+
/** Drawn fainter, as a hint while nothing is dragged. */
|
|
137
|
+
faint?: boolean;
|
|
126
138
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -31,6 +31,11 @@ export interface BuilderControls {
|
|
|
31
31
|
/** Why a filter cannot be added here, when it cannot; `filter` is then absent. */
|
|
32
32
|
filterUnavailable?: string;
|
|
33
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* The layout as a whole, on a grid report whose tiles are placed: close
|
|
36
|
+
* its gaps, or let its tiles flow again. Absent on a report that flows.
|
|
37
|
+
*/
|
|
38
|
+
arrange?: ArrangeActions;
|
|
34
39
|
/** Leave the builder: asks first when edits are unsaved. Absent unless the host passed `onExit`. */
|
|
35
40
|
exit?: () => void;
|
|
36
41
|
/**
|
|
@@ -57,6 +62,20 @@ export interface BuilderControls {
|
|
|
57
62
|
/** The author has seen the restored edits: `restored` goes. Present while `restored` is, and not pending. */
|
|
58
63
|
dismissRestored?: () => void;
|
|
59
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* What can be done to a placed report's layout as a whole, as
|
|
67
|
+
* {@link BuilderControls.arrange} offers it.
|
|
68
|
+
*/
|
|
69
|
+
export interface ArrangeActions {
|
|
70
|
+
/**
|
|
71
|
+
* Slide every tile up into the empty space above it. Present only when
|
|
72
|
+
* there is such a gap: absent means there is nothing to close, and a host
|
|
73
|
+
* draws the action disabled (or not at all).
|
|
74
|
+
*/
|
|
75
|
+
pack?: () => void;
|
|
76
|
+
/** Take every tile's place off, so the report flows again; sizes are kept. */
|
|
77
|
+
flow: () => void;
|
|
78
|
+
}
|
|
60
79
|
/** What a host passes to take over the builder's page-level controls. */
|
|
61
80
|
export type BuilderControlsHandler = (controls: BuilderControls | undefined) => void;
|
|
62
81
|
/**
|
|
@@ -16,8 +16,15 @@ export interface Cell {
|
|
|
16
16
|
colspan: number;
|
|
17
17
|
rowspan: number;
|
|
18
18
|
}
|
|
19
|
-
/**
|
|
20
|
-
|
|
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;
|
|
21
28
|
/** Rows a tile takes on a placed report: its own, or its kind's default. */
|
|
22
29
|
export declare const rowsOf: (tile: DashboardTile) => number;
|
|
23
30
|
/** A placed tile's rectangle, held to the grid; undefined for one not placed yet. */
|
|
@@ -73,3 +80,42 @@ export declare function placeWhereDrawn(tiles: readonly DashboardTile[], boxes:
|
|
|
73
80
|
* into a gap an author left on purpose. A report that flows is left as it is.
|
|
74
81
|
*/
|
|
75
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;
|
|
@@ -67,4 +67,13 @@ export declare function GapDroppable({ id, after, children, }: {
|
|
|
67
67
|
isDropTarget: boolean;
|
|
68
68
|
}) => ReactNode;
|
|
69
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;
|
|
70
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,6 +1,9 @@
|
|
|
1
1
|
import { DragEndEvent, DragMoveEvent, DragOverEvent } from '@dnd-kit/react';
|
|
2
2
|
import { RefObject } from 'react';
|
|
3
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>;
|
|
4
7
|
/**
|
|
5
8
|
* Dragging a tile to reorder it. The gesture is `@dnd-kit/react`'s (see
|
|
6
9
|
* `sortable.tsx`); what is decided here is what a drop means for the file,
|