@malloy-publisher/sdk 0.9.9 → 0.9.11
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-BlNoIiSi.cjs.js +153 -0
- package/dist/{RenderedResult-BHuJpdSn.es.js → RenderedResult-Cmx8sX8d.es.js} +102 -102
- package/dist/ServerProvider-BOgiW8MX.cjs.js +1 -0
- package/dist/{ServerProvider-CQy4jVYK.es.js → ServerProvider-azXLkk1q.es.js} +619 -586
- package/dist/builder/index.cjs.js +78 -130
- package/dist/builder/index.es.js +7440 -6727
- package/dist/builder-entry.d.ts +3 -0
- package/dist/client/api.d.ts +26 -22
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/AppDialog.d.ts +9 -1
- package/dist/components/Dashboard/DashboardGrid.d.ts +14 -15
- package/dist/components/Dashboard/DashboardTile.d.ts +8 -1
- package/dist/components/Dashboard/DashboardView.d.ts +22 -23
- package/dist/components/Dashboard/TileCard.d.ts +10 -3
- package/dist/components/Dashboard/useStuck.d.ts +22 -0
- package/dist/components/DocumentCreate/newNotebook.d.ts +9 -5
- package/dist/components/DocumentCreate/useDocumentChoices.d.ts +6 -0
- package/dist/components/Package/PackageProblems.d.ts +14 -0
- package/dist/components/RemoveBadge.d.ts +40 -0
- package/dist/components/Report/Report.d.ts +13 -4
- package/dist/components/Report/ReportPage.d.ts +60 -0
- package/dist/components/Report/layoutRules.d.ts +32 -0
- package/dist/components/Report/reportQuery.d.ts +30 -0
- package/dist/components/Report/telemetry.d.ts +0 -2
- package/dist/components/ReportBuilder/AddTileDialog.d.ts +22 -3
- package/dist/components/ReportBuilder/BuilderBar.d.ts +17 -0
- package/dist/components/ReportBuilder/BuilderDialogs.d.ts +7 -6
- package/dist/components/ReportBuilder/BuilderGrid.d.ts +10 -4
- package/dist/components/ReportBuilder/BuilderHeader.d.ts +4 -7
- package/dist/components/ReportBuilder/BuilderToolbar.d.ts +88 -0
- package/dist/components/ReportBuilder/DrillDialog.d.ts +3 -1
- package/dist/components/ReportBuilder/EditorSurface.d.ts +7 -9
- package/dist/components/ReportBuilder/FilterDialog.d.ts +3 -1
- package/dist/components/ReportBuilder/FilterStrip.d.ts +30 -6
- package/dist/components/ReportBuilder/InlineMarkdown.d.ts +4 -4
- package/dist/components/ReportBuilder/ReportBuilder.d.ts +49 -12
- package/dist/components/ReportBuilder/ReportEditor.d.ts +53 -3
- package/dist/components/ReportBuilder/TextTileBody.d.ts +2 -5
- package/dist/components/ReportBuilder/TileFrame.d.ts +10 -4
- package/dist/components/ReportBuilder/TileMenu.d.ts +19 -11
- package/dist/components/ReportBuilder/ViewPicker.d.ts +53 -0
- package/dist/components/ReportBuilder/addTileToDocument.d.ts +24 -3
- package/dist/components/ReportBuilder/builderControls.d.ts +60 -0
- package/dist/components/ReportBuilder/catalog.d.ts +2 -4
- package/dist/components/ReportBuilder/inlineEdit.d.ts +9 -10
- package/dist/components/ReportBuilder/localGiven.d.ts +12 -0
- package/dist/components/ReportBuilder/preview.d.ts +17 -2
- package/dist/components/ReportBuilder/readDocument.d.ts +0 -2
- package/dist/components/ReportBuilder/readForEditor.d.ts +2 -7
- package/dist/components/ReportBuilder/reportTag.d.ts +11 -1
- package/dist/components/ReportBuilder/sortable.d.ts +4 -3
- package/dist/components/ReportBuilder/testing/inline.d.ts +5 -1
- package/dist/components/ReportBuilder/useBuilderSelection.d.ts +0 -1
- package/dist/components/ReportBuilder/useBuilderSession.d.ts +21 -12
- package/dist/components/ReportBuilder/useDocumentEditor.d.ts +2 -6
- package/dist/components/ReportBuilder/useExitGuard.d.ts +3 -0
- package/dist/components/ReportBuilder/useFilterForm.d.ts +3 -1
- package/dist/components/ReportBuilder/useOpenedDocument.d.ts +0 -4
- package/dist/components/ReportBuilder/useReportDraft.d.ts +66 -0
- package/dist/components/ReportBuilder/useReportEditor.d.ts +0 -9
- package/dist/components/ReportBuilder/useTileEditing.d.ts +6 -3
- package/dist/components/ReportBuilder/viewAnnotations.d.ts +9 -0
- package/dist/components/ReportBuilder/widthLabel.d.ts +6 -0
- package/dist/components/ServerProvider.d.ts +9 -0
- package/dist/components/controlTokens.d.ts +45 -0
- package/dist/components/drill/markDrillableCells.d.ts +1 -1
- package/dist/components/given/FilterButton.d.ts +35 -0
- package/dist/components/given/GivensPanel.d.ts +2 -1
- package/dist/components/given/filterEditing.d.ts +54 -0
- package/dist/components/given/filterSummary.d.ts +9 -0
- package/dist/components/given/paramCodec.d.ts +11 -0
- package/dist/components/given/required.d.ts +25 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/legacy/index.d.ts +1 -1
- package/dist/components/{Report/CellReport.d.ts → legacy/malloynb/CellRunnerView.d.ts} +9 -17
- package/dist/components/legacy/{MalloynbCells.d.ts → malloynb/MalloynbCells.d.ts} +3 -3
- package/dist/components/legacy/{Notebook.d.ts → malloynb/Notebook.d.ts} +1 -1
- package/dist/components/{Notebook → legacy/malloynb}/NotebookCell.d.ts +3 -3
- package/dist/components/legacy/malloynb/cellKind.d.ts +5 -0
- package/dist/components/{Notebook → legacy/malloynb}/types.d.ts +1 -1
- package/dist/components/styles.d.ts +0 -2
- package/dist/hooks/useQueryResult.d.ts +7 -0
- package/dist/index.cjs.js +16 -19
- package/dist/index.es.js +8324 -7769
- package/dist/theme/ThemeContext.d.ts +8 -1
- package/dist/theme/classes.d.ts +49 -0
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/types.d.ts +7 -0
- package/dist/theme/ui.d.ts +75 -0
- package/dist/{useCompiledDocument-1dgF5CC9.es.js → useCompiledDocument-7j5cBjQd.es.js} +8768 -7912
- package/dist/useCompiledDocument-B21sVbb4.cjs.js +141 -0
- package/package.json +2 -2
- package/src/builder-entry.ts +9 -0
- package/src/components/AppDialog.tsx +23 -0
- package/src/components/Dashboard/DashboardGrid.tsx +39 -17
- package/src/components/Dashboard/DashboardTile.tsx +19 -2
- package/src/components/Dashboard/DashboardView.spec.tsx +216 -15
- package/src/components/Dashboard/DashboardView.tsx +136 -105
- package/src/components/Dashboard/RowsDialog.tsx +1 -2
- package/src/components/Dashboard/TileCard.tsx +28 -10
- package/src/components/Dashboard/defaultTileSpan.spec.ts +24 -0
- package/src/components/Dashboard/useStuck.ts +49 -0
- package/src/components/DocumentCreate/newNotebook.spec.ts +8 -6
- package/src/components/DocumentCreate/newNotebook.ts +26 -12
- package/src/components/DocumentCreate/useDocumentChoices.ts +19 -2
- package/src/components/Package/NewDocumentDialog.spec.tsx +76 -59
- package/src/components/Package/NewDocumentDialog.tsx +383 -119
- package/src/components/Package/Package.artifacts.spec.tsx +1 -1
- package/src/components/Package/Package.create.spec.tsx +7 -6
- package/src/components/Package/Package.tsx +10 -7
- package/src/components/Package/PackageProblems.spec.tsx +41 -0
- package/src/components/Package/PackageProblems.tsx +95 -0
- package/src/components/Prose.tsx +12 -7
- package/src/components/RemoveBadge.tsx +94 -0
- package/src/components/RenderedResult/RenderedResult.tsx +5 -9
- package/src/components/RenderedResult/ResultPanel.tsx +59 -3
- package/src/components/Report/Report.spec.tsx +50 -32
- package/src/components/Report/Report.telemetry.spec.tsx +0 -45
- package/src/components/Report/Report.tsx +45 -77
- package/src/components/Report/ReportPage.tsx +168 -0
- package/src/components/Report/layoutRules.spec.ts +35 -0
- package/src/components/Report/layoutRules.ts +55 -0
- package/src/components/Report/reportQuery.ts +53 -0
- package/src/components/Report/telemetry.ts +0 -2
- package/src/components/ReportBuilder/AddTileDialog.spec.tsx +76 -41
- package/src/components/ReportBuilder/AddTileDialog.tsx +368 -133
- package/src/components/ReportBuilder/BuilderBar.tsx +599 -0
- package/src/components/ReportBuilder/BuilderDialogs.tsx +30 -39
- package/src/components/ReportBuilder/BuilderGrid.tsx +43 -31
- package/src/components/ReportBuilder/BuilderHeader.tsx +63 -75
- package/src/components/ReportBuilder/BuilderToolbar.tsx +95 -9
- package/src/components/ReportBuilder/DrillDialog.tsx +240 -128
- package/src/components/ReportBuilder/EditorSurface.tsx +345 -69
- package/src/components/ReportBuilder/FilterDialog.tsx +516 -166
- package/src/components/ReportBuilder/FilterStrip.tsx +129 -150
- package/src/components/ReportBuilder/InlineMarkdown.tsx +71 -45
- package/src/components/ReportBuilder/ReportBuilder.charts.spec.tsx +35 -40
- package/src/components/ReportBuilder/ReportBuilder.controls.spec.tsx +491 -0
- package/src/components/ReportBuilder/ReportBuilder.exit.spec.tsx +2 -4
- package/src/components/ReportBuilder/ReportBuilder.inline.spec.tsx +13 -16
- package/src/components/ReportBuilder/ReportBuilder.notebook.spec.tsx +27 -118
- package/src/components/ReportBuilder/ReportBuilder.openDraft.spec.tsx +12 -5
- package/src/components/ReportBuilder/ReportBuilder.sources.spec.tsx +2 -10
- package/src/components/ReportBuilder/ReportBuilder.spec.tsx +41 -36
- package/src/components/ReportBuilder/ReportBuilder.textTiles.spec.tsx +22 -15
- package/src/components/ReportBuilder/ReportBuilder.tsx +292 -116
- package/src/components/ReportBuilder/ReportEditor.emptyStart.spec.tsx +2 -1
- package/src/components/ReportBuilder/ReportEditor.modelFilters.spec.tsx +312 -0
- package/src/components/ReportBuilder/ReportEditor.notebook.spec.tsx +26 -75
- package/src/components/ReportBuilder/ReportEditor.package.spec.tsx +6 -2
- package/src/components/ReportBuilder/ReportEditor.resourceUri.spec.tsx +3 -2
- package/src/components/ReportBuilder/ReportEditor.spec.tsx +2 -4
- package/src/components/ReportBuilder/ReportEditor.textSource.spec.tsx +93 -13
- package/src/components/ReportBuilder/ReportEditor.tsx +104 -14
- package/src/components/ReportBuilder/TextTileBody.tsx +6 -7
- package/src/components/ReportBuilder/TileFrame.tsx +212 -75
- package/src/components/ReportBuilder/TileMenu.tsx +248 -142
- package/src/components/ReportBuilder/ViewPicker.tsx +349 -0
- package/src/components/ReportBuilder/addTile.compile.spec.ts +1 -1
- package/src/components/ReportBuilder/addTileToDocument.spec.ts +102 -3
- package/src/components/ReportBuilder/addTileToDocument.ts +122 -25
- package/src/components/ReportBuilder/builderControls.ts +164 -0
- package/src/components/ReportBuilder/builderReport.ts +1 -2
- package/src/components/ReportBuilder/catalog.ts +10 -26
- package/src/components/ReportBuilder/inlineEdit.tsx +22 -54
- package/src/components/ReportBuilder/localGiven.ts +56 -0
- package/src/components/ReportBuilder/newDashboard.spec.ts +2 -3
- package/src/components/ReportBuilder/preview.spec.ts +125 -5
- package/src/components/ReportBuilder/preview.ts +60 -44
- package/src/components/ReportBuilder/readDocument.spec.ts +16 -22
- package/src/components/ReportBuilder/readDocument.ts +14 -11
- package/src/components/ReportBuilder/readForEditor.spec.ts +12 -41
- package/src/components/ReportBuilder/readForEditor.ts +4 -26
- package/src/components/ReportBuilder/reportTag.ts +28 -7
- package/src/components/ReportBuilder/sortable.tsx +15 -7
- package/src/components/ReportBuilder/spliceDocument.imports.spec.ts +1 -1
- package/src/components/ReportBuilder/tagParse.spec.ts +0 -40
- package/src/components/ReportBuilder/testing/inline.ts +25 -5
- package/src/components/ReportBuilder/testing/reportLayoutParity.json +13 -8
- package/src/components/ReportBuilder/textTiles.spec.ts +7 -6
- package/src/components/ReportBuilder/useBuilderSelection.ts +35 -0
- package/src/components/ReportBuilder/useBuilderSession.spec.ts +2 -2
- package/src/components/ReportBuilder/useBuilderSession.ts +21 -13
- package/src/components/ReportBuilder/useDocumentEditor.spec.ts +0 -58
- package/src/components/ReportBuilder/useDocumentEditor.ts +3 -16
- package/src/components/ReportBuilder/useEditorCatalog.spec.tsx +26 -0
- package/src/components/ReportBuilder/useEditorCatalog.ts +7 -2
- package/src/components/ReportBuilder/useExitGuard.ts +16 -0
- package/src/components/ReportBuilder/useFilterForm.spec.tsx +17 -0
- package/src/components/ReportBuilder/useFilterForm.ts +5 -1
- package/src/components/ReportBuilder/useOpenedDocument.ts +0 -2
- package/src/components/ReportBuilder/useReportDraft.spec.ts +149 -0
- package/src/components/ReportBuilder/useReportDraft.ts +292 -0
- package/src/components/ReportBuilder/useReportEditor.ts +3 -12
- package/src/components/ReportBuilder/useSaveChannel.ts +0 -1
- package/src/components/ReportBuilder/useTileEditing.ts +43 -12
- package/src/components/ReportBuilder/viewAnnotations.ts +29 -0
- package/src/components/ReportBuilder/widthLabel.spec.ts +25 -0
- package/src/components/ReportBuilder/widthLabel.ts +26 -0
- package/src/components/ServerProvider.tsx +11 -0
- package/src/components/controlTokens.ts +47 -0
- package/src/components/drill/markDrillableCells.ts +2 -1
- package/src/components/given/FilterButton.spec.tsx +143 -0
- package/src/components/given/FilterButton.tsx +478 -0
- package/src/components/given/GivenInput.spec.tsx +47 -0
- package/src/components/given/GivenInput.tsx +20 -2
- package/src/components/given/GivensPanel.spec.tsx +11 -3
- package/src/components/given/GivensPanel.tsx +45 -44
- package/src/components/given/filterEditing.ts +60 -0
- package/src/components/given/filterSummary.spec.ts +108 -0
- package/src/components/given/filterSummary.ts +109 -0
- package/src/components/given/paramCodec.ts +1 -1
- package/src/components/given/required.spec.ts +60 -0
- package/src/components/given/required.ts +78 -0
- package/src/components/index.ts +9 -0
- package/src/components/legacy/Dashboard.spec.tsx +3 -1
- package/src/components/legacy/index.ts +1 -1
- package/src/components/{Report/CellReport.spec.tsx → legacy/malloynb/CellRunnerView.spec.tsx} +53 -57
- package/src/components/{Report/CellReport.tsx → legacy/malloynb/CellRunnerView.tsx} +122 -136
- package/src/components/legacy/{MalloynbCells.tsx → malloynb/MalloynbCells.tsx} +6 -6
- package/src/components/legacy/{Notebook.layout.spec.tsx → malloynb/Notebook.layout.spec.tsx} +16 -7
- package/src/components/legacy/malloynb/Notebook.served.spec.tsx +84 -0
- package/src/components/legacy/{Notebook.spec.tsx → malloynb/Notebook.spec.tsx} +5 -3
- package/src/components/legacy/{Notebook.tsx → malloynb/Notebook.tsx} +9 -7
- package/src/components/{Notebook → legacy/malloynb}/NotebookCell.tsx +70 -150
- package/src/components/legacy/malloynb/cellKind.spec.ts +33 -0
- package/src/components/legacy/malloynb/cellKind.ts +24 -0
- package/src/components/{Notebook → legacy/malloynb}/types.ts +1 -1
- package/src/components/styles.ts +0 -18
- package/src/hooks/useGivensState.ts +7 -3
- package/src/hooks/useQueryResult.placeholder.spec.ts +44 -0
- package/src/hooks/useQueryResult.ts +26 -1
- package/src/theme/ThemeContext.tsx +21 -1
- package/src/theme/classes.ts +52 -0
- package/src/theme/index.ts +8 -0
- package/src/theme/resolveTheme.ts +3 -0
- package/src/theme/types.ts +7 -0
- package/src/theme/ui.spec.tsx +91 -0
- package/src/theme/ui.ts +115 -0
- package/dist/RenderedResult-Bw7EQc42.cjs.js +0 -153
- package/dist/ServerProvider-B0dUY8be.cjs.js +0 -1
- package/dist/components/Notebook/cellKind.d.ts +0 -20
- package/dist/components/Report/LinearReport.d.ts +0 -18
- package/dist/components/ReportBuilder/SourceViewPicker.d.ts +0 -9
- package/dist/components/ReportBuilder/legacyNotebook.d.ts +0 -73
- package/dist/components/ReportBuilder/useConversionConfirm.d.ts +0 -20
- package/dist/useCompiledDocument-BKyRnXmA.cjs.js +0 -141
- package/src/components/Notebook/cellKind.spec.ts +0 -199
- package/src/components/Notebook/cellKind.ts +0 -74
- package/src/components/Report/LinearReport.tsx +0 -71
- package/src/components/ReportBuilder/SourceViewPicker.tsx +0 -122
- package/src/components/ReportBuilder/legacyNotebook.chart.spec.ts +0 -77
- package/src/components/ReportBuilder/legacyNotebook.convert.spec.ts +0 -626
- package/src/components/ReportBuilder/legacyNotebook.read.spec.ts +0 -338
- package/src/components/ReportBuilder/legacyNotebook.ts +0 -1122
- package/src/components/ReportBuilder/useConversionConfirm.ts +0 -55
- package/src/components/legacy/Notebook.served.spec.tsx +0 -183
- /package/dist/components/{Notebook → legacy/malloynb}/runPlan.d.ts +0 -0
- /package/src/components/{Notebook → legacy/malloynb}/runPlan.spec.ts +0 -0
- /package/src/components/{Notebook → legacy/malloynb}/runPlan.ts +0 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
5
|
+
import type { ReportLayout } from "../Package/documentLocation";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The builder's page-level controls, as state and actions rather than as a
|
|
9
|
+
* toolbar, so a host can put each one where its own chrome has room: in its
|
|
10
|
+
* header, in its "⋯" menu, or in the SDK's own {@link BuilderBar}. Everything
|
|
11
|
+
* that acts on a tile, a filter or the text stays on the page itself.
|
|
12
|
+
*
|
|
13
|
+
* The actions are stable across renders: a host may keep the object in state
|
|
14
|
+
* and call them later. A new object is handed over only when something a host
|
|
15
|
+
* would draw has changed.
|
|
16
|
+
*/
|
|
17
|
+
export interface BuilderControls {
|
|
18
|
+
/** Whether the file holds every edit: for a status line. */
|
|
19
|
+
status: "saved" | "unsaved" | "saving";
|
|
20
|
+
/** Where Save writes, in words: "Saves to the package file". */
|
|
21
|
+
saveTarget: string;
|
|
22
|
+
/** Save the edits. Absent when the builder has nowhere to save. */
|
|
23
|
+
save?: () => void;
|
|
24
|
+
canUndo: boolean;
|
|
25
|
+
undo: () => void;
|
|
26
|
+
canRedo: boolean;
|
|
27
|
+
redo: () => void;
|
|
28
|
+
/** The layout and its switch. Absent when the layout cannot be changed here. */
|
|
29
|
+
layout?: {
|
|
30
|
+
value: ReportLayout;
|
|
31
|
+
set: (layout: ReportLayout) => void;
|
|
32
|
+
};
|
|
33
|
+
/** What can be added to the page. A missing entry is not offered. */
|
|
34
|
+
add: {
|
|
35
|
+
/** Open the picker of views for a query tile. */
|
|
36
|
+
tile?: () => void;
|
|
37
|
+
/** Append an empty text tile and select it. */
|
|
38
|
+
text?: () => void;
|
|
39
|
+
/** Open the window that declares a filter. */
|
|
40
|
+
filter?: () => void;
|
|
41
|
+
/** Why a filter cannot be added here, when it cannot; `filter` is then absent. */
|
|
42
|
+
filterUnavailable?: string;
|
|
43
|
+
};
|
|
44
|
+
/** Leave the builder: asks first when edits are unsaved. Absent unless the host passed `onExit`. */
|
|
45
|
+
exit?: () => void;
|
|
46
|
+
/**
|
|
47
|
+
* Write the edits, then leave — once the write has landed; a refused write
|
|
48
|
+
* keeps the builder open with its reason. The one way out a host needs when
|
|
49
|
+
* the builder keeps a draft. Absent unless the host passed `onExit`.
|
|
50
|
+
*/
|
|
51
|
+
done?: () => void;
|
|
52
|
+
/** When unsaved edits were last kept in this browser (`draftKey`); absent when there are none to keep. */
|
|
53
|
+
draftKeptAt?: number;
|
|
54
|
+
/** Put the report back to the file's, as one undoable edit, and drop the draft. Absent with nothing to discard. */
|
|
55
|
+
discard?: () => void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** What a host passes to take over the builder's page-level controls. */
|
|
59
|
+
export type BuilderControlsHandler = (
|
|
60
|
+
controls: BuilderControls | undefined,
|
|
61
|
+
) => void;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Hand the host the builder's controls whenever what they show changes, and
|
|
65
|
+
* `undefined` when the builder goes away. The actions forward to the latest
|
|
66
|
+
* render's, so their identity never changes and a host keeping the object in
|
|
67
|
+
* state cannot loop on it.
|
|
68
|
+
*/
|
|
69
|
+
export function useReportControls(
|
|
70
|
+
onControls: BuilderControlsHandler | undefined,
|
|
71
|
+
controls: BuilderControls,
|
|
72
|
+
): void {
|
|
73
|
+
const latest = useRef(controls);
|
|
74
|
+
latest.current = controls;
|
|
75
|
+
const handlerRef = useRef(onControls);
|
|
76
|
+
handlerRef.current = onControls;
|
|
77
|
+
|
|
78
|
+
// Stable forwarders, made once.
|
|
79
|
+
const actions = useMemo(
|
|
80
|
+
() => ({
|
|
81
|
+
save: () => latest.current.save?.(),
|
|
82
|
+
undo: () => latest.current.undo(),
|
|
83
|
+
redo: () => latest.current.redo(),
|
|
84
|
+
setLayout: (layout: ReportLayout) =>
|
|
85
|
+
latest.current.layout?.set(layout),
|
|
86
|
+
addTile: () => latest.current.add.tile?.(),
|
|
87
|
+
addText: () => latest.current.add.text?.(),
|
|
88
|
+
addFilter: () => latest.current.add.filter?.(),
|
|
89
|
+
exit: () => latest.current.exit?.(),
|
|
90
|
+
done: () => latest.current.done?.(),
|
|
91
|
+
discard: () => latest.current.discard?.(),
|
|
92
|
+
}),
|
|
93
|
+
[],
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const {
|
|
97
|
+
status,
|
|
98
|
+
saveTarget,
|
|
99
|
+
canUndo,
|
|
100
|
+
canRedo,
|
|
101
|
+
add: { filterUnavailable },
|
|
102
|
+
} = controls;
|
|
103
|
+
const hasSave = controls.save !== undefined;
|
|
104
|
+
const layout = controls.layout?.value;
|
|
105
|
+
const hasTile = controls.add.tile !== undefined;
|
|
106
|
+
const hasText = controls.add.text !== undefined;
|
|
107
|
+
const hasFilter = controls.add.filter !== undefined;
|
|
108
|
+
const hasExit = controls.exit !== undefined;
|
|
109
|
+
const hasDone = controls.done !== undefined;
|
|
110
|
+
const hasDiscard = controls.discard !== undefined;
|
|
111
|
+
const { draftKeptAt } = controls;
|
|
112
|
+
|
|
113
|
+
const shown = useMemo<BuilderControls>(
|
|
114
|
+
() => ({
|
|
115
|
+
status,
|
|
116
|
+
saveTarget,
|
|
117
|
+
...(hasSave ? { save: actions.save } : {}),
|
|
118
|
+
canUndo,
|
|
119
|
+
undo: actions.undo,
|
|
120
|
+
canRedo,
|
|
121
|
+
redo: actions.redo,
|
|
122
|
+
...(layout !== undefined
|
|
123
|
+
? { layout: { value: layout, set: actions.setLayout } }
|
|
124
|
+
: {}),
|
|
125
|
+
add: {
|
|
126
|
+
...(hasTile ? { tile: actions.addTile } : {}),
|
|
127
|
+
...(hasText ? { text: actions.addText } : {}),
|
|
128
|
+
...(hasFilter ? { filter: actions.addFilter } : {}),
|
|
129
|
+
...(filterUnavailable !== undefined ? { filterUnavailable } : {}),
|
|
130
|
+
},
|
|
131
|
+
...(hasExit ? { exit: actions.exit } : {}),
|
|
132
|
+
...(hasDone ? { done: actions.done } : {}),
|
|
133
|
+
...(draftKeptAt !== undefined ? { draftKeptAt } : {}),
|
|
134
|
+
...(hasDiscard ? { discard: actions.discard } : {}),
|
|
135
|
+
}),
|
|
136
|
+
[
|
|
137
|
+
actions,
|
|
138
|
+
status,
|
|
139
|
+
saveTarget,
|
|
140
|
+
hasSave,
|
|
141
|
+
canUndo,
|
|
142
|
+
canRedo,
|
|
143
|
+
layout,
|
|
144
|
+
hasTile,
|
|
145
|
+
hasText,
|
|
146
|
+
hasFilter,
|
|
147
|
+
filterUnavailable,
|
|
148
|
+
hasExit,
|
|
149
|
+
hasDone,
|
|
150
|
+
draftKeptAt,
|
|
151
|
+
hasDiscard,
|
|
152
|
+
],
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
// Also when a handler arrives after the builder has mounted: it takes the
|
|
156
|
+
// inline toolbar away at once, so it has to be handed the controls at once
|
|
157
|
+
// too, not on the next change.
|
|
158
|
+
const hasHandler = onControls !== undefined;
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
handlerRef.current?.(shown);
|
|
161
|
+
}, [shown, hasHandler]);
|
|
162
|
+
// Gone with the builder, so a host does not draw controls for nothing.
|
|
163
|
+
useEffect(() => () => handlerRef.current?.(undefined), []);
|
|
164
|
+
}
|
|
@@ -29,12 +29,11 @@ export const builderReport = ({
|
|
|
29
29
|
const { emit } = reportEmitter({ path, layout }, onEvent);
|
|
30
30
|
return {
|
|
31
31
|
size,
|
|
32
|
-
saved: ({ size, structural, durationMs
|
|
32
|
+
saved: ({ size, structural, durationMs }) =>
|
|
33
33
|
emit({
|
|
34
34
|
type: "report.saved",
|
|
35
35
|
tiles: size,
|
|
36
36
|
structural,
|
|
37
|
-
...(fromOpen ? { converted: true } : {}),
|
|
38
37
|
where: savesTo,
|
|
39
38
|
durationMs,
|
|
40
39
|
}),
|
|
@@ -5,6 +5,9 @@ import { parseTag } from "@malloydata/malloy-tag";
|
|
|
5
5
|
import type { CompiledModel } from "../../client";
|
|
6
6
|
import { exportedSources } from "../DocumentCreate/exportedSources";
|
|
7
7
|
import { CHART_TAGS } from "./chartLine";
|
|
8
|
+
import { chartOf, docOf } from "./viewAnnotations";
|
|
9
|
+
|
|
10
|
+
export { chartOf, docOf };
|
|
8
11
|
|
|
9
12
|
export { CHART_TAGS };
|
|
10
13
|
|
|
@@ -63,25 +66,6 @@ export interface PackageCatalog {
|
|
|
63
66
|
sources: CatalogSource[];
|
|
64
67
|
}
|
|
65
68
|
|
|
66
|
-
/** `#(doc) Revenue by product category\n` -> `Revenue by product category`. */
|
|
67
|
-
export function docOf(annotations: string[] | undefined): string | undefined {
|
|
68
|
-
for (const raw of annotations ?? []) {
|
|
69
|
-
const m = /^#\(doc\)\s*(.*)$/s.exec(raw.trim());
|
|
70
|
-
if (m) return m[1].trim();
|
|
71
|
-
}
|
|
72
|
-
return undefined;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/** `# bar_chart\n` -> `bar_chart`. Only the renderer's own chart tags count. */
|
|
76
|
-
export function chartOf(annotations: string[] | undefined): string | undefined {
|
|
77
|
-
for (const raw of annotations ?? []) {
|
|
78
|
-
// A `-name` removes a tag, so it is never the chart the view declares.
|
|
79
|
-
const name = /^#\s*(?:-[A-Za-z_]+\s+)*([a-z_]+)/.exec(raw.trim())?.[1];
|
|
80
|
-
if (name && CHART_TAGS.includes(name)) return name;
|
|
81
|
-
}
|
|
82
|
-
return undefined;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
69
|
/**
|
|
86
70
|
* How far into a source's joins the field list reaches. One level:
|
|
87
71
|
* `products.category` is a field people filter on; `products.supplier.region`
|
|
@@ -207,16 +191,16 @@ export const isReportModel = (
|
|
|
207
191
|
) => path !== undefined && reportPaths.has(path);
|
|
208
192
|
|
|
209
193
|
/**
|
|
210
|
-
* The model's own path.
|
|
194
|
+
* The model's own path: `path`, the field the API declares.
|
|
211
195
|
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
196
|
+
* A server before this release names a single model's path only as
|
|
197
|
+
* `modelPath`, which the spec never declared, so it is still read when `path`
|
|
198
|
+
* is missing. An empty path silently disables the report exclusion below and
|
|
199
|
+
* leaves a preview with nothing to run against, so `useEditorCatalog` sets
|
|
200
|
+
* `path` itself, from the path it asked for.
|
|
217
201
|
*/
|
|
218
202
|
const pathOf = (model: CompiledModel): string =>
|
|
219
|
-
(model as { modelPath?: string }).modelPath
|
|
203
|
+
model.path || (model as { modelPath?: string }).modelPath || "";
|
|
220
204
|
|
|
221
205
|
export function buildCatalog(
|
|
222
206
|
models: CompiledModel[],
|
|
@@ -6,73 +6,41 @@ import type { SystemStyleObject } from "@mui/system";
|
|
|
6
6
|
import { MOTION_FAST, reducedMotionSx } from "../../theme/motion";
|
|
7
7
|
import type { ResolvedTheme } from "../../theme/types";
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
const PENCIL = `url("data:image/svg+xml;utf8,${encodeURIComponent(
|
|
11
|
-
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"/></svg>',
|
|
12
|
-
)}")`;
|
|
13
|
-
|
|
14
|
-
/** Where the pencil goes: after a line of text, or after the first block of prose. */
|
|
9
|
+
/** What kind of text is edited: a line (a title, a subtitle) or a block of prose. */
|
|
15
10
|
export type PencilAt = "line" | "prose";
|
|
16
11
|
|
|
17
12
|
/**
|
|
18
|
-
* How text that is edited where it is read says so: a
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* does not say where focus is.
|
|
13
|
+
* How text that is edited where it is read says so: a faint wash behind it
|
|
14
|
+
* under the pointer, in the page's hover colour, and nothing at rest, so the
|
|
15
|
+
* page reads as the report until the pointer reaches something editable. The
|
|
16
|
+
* wash is padded out into the text's own margin (an equal negative margin
|
|
17
|
+
* takes the padding back), so it never moves the text or its neighbours. The
|
|
18
|
+
* keyboard gets a focus ring, since a wash does not say where focus is.
|
|
24
19
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* looking at when they reach for it.
|
|
20
|
+
* A line gets a tight wash; a block of prose a roomier one, the size of the
|
|
21
|
+
* paragraph it covers.
|
|
28
22
|
*/
|
|
29
23
|
export const editableSx = (
|
|
30
24
|
theme: ResolvedTheme,
|
|
31
25
|
at: PencilAt = "line",
|
|
32
26
|
): SystemStyleObject<Theme> => {
|
|
33
|
-
|
|
34
|
-
// or focused: on the field itself for a line; for prose, on its first
|
|
35
|
-
// paragraph or heading, or on the lone span markdown renders a single line
|
|
36
|
-
// of prose as, with no paragraph around it.
|
|
37
|
-
const blocks = [
|
|
38
|
-
":is(p, h1, h2, h3, h4, h5, h6):first-child::after",
|
|
39
|
-
"> * > span:only-child::after",
|
|
40
|
-
];
|
|
41
|
-
const within = (prefix: string) =>
|
|
42
|
-
blocks.map((block) => `${prefix} ${block}`).join(", ");
|
|
43
|
-
const host = at === "line" ? "&::after" : within("&");
|
|
44
|
-
const lit =
|
|
45
|
-
at === "line"
|
|
46
|
-
? "&:hover::after, &:focus-visible::after"
|
|
47
|
-
: `${within("&:hover")}, ${within("&:focus-visible")}`;
|
|
27
|
+
const [x, y] = at === "line" ? ["6px", "2px"] : ["10px", "6px"];
|
|
48
28
|
return {
|
|
49
29
|
cursor: "text",
|
|
50
|
-
borderRadius: "
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
backgroundColor: "currentColor",
|
|
59
|
-
maskImage: PENCIL,
|
|
60
|
-
WebkitMaskImage: PENCIL,
|
|
61
|
-
maskSize: "contain",
|
|
62
|
-
WebkitMaskSize: "contain",
|
|
63
|
-
maskRepeat: "no-repeat",
|
|
64
|
-
WebkitMaskRepeat: "no-repeat",
|
|
65
|
-
opacity: 0.35,
|
|
66
|
-
transition: `opacity ${MOTION_FAST}`,
|
|
67
|
-
...reducedMotionSx,
|
|
68
|
-
pointerEvents: "none",
|
|
69
|
-
},
|
|
70
|
-
[lit]: {
|
|
71
|
-
opacity: 0.8,
|
|
72
|
-
},
|
|
30
|
+
borderRadius: at === "line" ? "4px" : "6px",
|
|
31
|
+
mx: `-${x}`,
|
|
32
|
+
px: x,
|
|
33
|
+
my: `-${y}`,
|
|
34
|
+
py: y,
|
|
35
|
+
transition: `background-color ${MOTION_FAST}`,
|
|
36
|
+
...reducedMotionSx,
|
|
37
|
+
"&:hover": { bgcolor: "action.hover" },
|
|
73
38
|
"&:focus-visible": {
|
|
74
39
|
outline: `2px solid ${theme.accent}`,
|
|
75
|
-
|
|
40
|
+
// Inside the element: the wash already reaches past the text by
|
|
41
|
+
// negative margins, and a ring outside that was cut off by a card
|
|
42
|
+
// or frame that clips (a borderless tile's title, the description).
|
|
43
|
+
outlineOffset: -2,
|
|
76
44
|
},
|
|
77
45
|
};
|
|
78
46
|
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import type { Given } from "../../client";
|
|
5
|
+
import type { LocalGiven } from "./document";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A `given:` a report declares itself, as the `Given` spec its filter control
|
|
9
|
+
* is drawn from: the spec the server would publish for the same declaration
|
|
10
|
+
* once the report is served.
|
|
11
|
+
*
|
|
12
|
+
* Exported for a host that holds a report as text and draws its controls
|
|
13
|
+
* itself, so a filter it declares looks and behaves as it will once the
|
|
14
|
+
* report is published.
|
|
15
|
+
*/
|
|
16
|
+
export function localGivenSpec(local: LocalGiven): Given {
|
|
17
|
+
const shown = displayDefault(local);
|
|
18
|
+
return {
|
|
19
|
+
name: local.name,
|
|
20
|
+
type: local.type,
|
|
21
|
+
...(shown === undefined ? {} : { default: shown }),
|
|
22
|
+
...(local.label === undefined ? {} : { label: local.label }),
|
|
23
|
+
...(local.description === undefined
|
|
24
|
+
? {}
|
|
25
|
+
: { description: local.description }),
|
|
26
|
+
...(local.control === undefined
|
|
27
|
+
? {}
|
|
28
|
+
: { control: local.control as Given["control"] }),
|
|
29
|
+
...(local.suggest
|
|
30
|
+
? {
|
|
31
|
+
suggest: {
|
|
32
|
+
...(local.suggest.source === undefined
|
|
33
|
+
? {}
|
|
34
|
+
: { source: local.suggest.source }),
|
|
35
|
+
...(local.suggest.query === undefined
|
|
36
|
+
? {}
|
|
37
|
+
: { query: local.suggest.query }),
|
|
38
|
+
dimension: local.suggest.dimension,
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
: {}),
|
|
42
|
+
...(local.rangeMin === undefined ? {} : { rangeMin: local.rangeMin }),
|
|
43
|
+
...(local.rangeMax === undefined ? {} : { rangeMax: local.rangeMax }),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The default the server would publish: it unwraps a filter's `f'…'`, so an
|
|
49
|
+
* empty one is `""` (filters nothing, shows no caption). Never undefined for a
|
|
50
|
+
* declaration with a default: an absent `default` means the given is required.
|
|
51
|
+
*/
|
|
52
|
+
function displayDefault(local: LocalGiven): string | undefined {
|
|
53
|
+
if (!local.type?.startsWith("filter<")) return local.default;
|
|
54
|
+
const body = local.default?.match(/^f(['"])([\s\S]*)\1$/)?.[2];
|
|
55
|
+
return body ?? local.default;
|
|
56
|
+
}
|
|
@@ -17,7 +17,7 @@ describe("a new dashboard", () => {
|
|
|
17
17
|
expect(slugFor("***")).toBe("");
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
it("is a grid report the builder opens:
|
|
20
|
+
it("is a grid report the builder opens: the picked view as its one tile", async () => {
|
|
21
21
|
const text = newDashboardSource({
|
|
22
22
|
title: 'Sales "West"',
|
|
23
23
|
modelPath: "models/storefront.malloy",
|
|
@@ -39,10 +39,9 @@ describe("a new dashboard", () => {
|
|
|
39
39
|
expect(document.layout).toBe("grid");
|
|
40
40
|
expect(document.columns).toBe(12);
|
|
41
41
|
expect(document.tiles.map((tile) => tile.name)).toEqual([
|
|
42
|
-
"intro",
|
|
43
42
|
"by_category_tile",
|
|
44
43
|
]);
|
|
45
|
-
expect(queryTile(document,
|
|
44
|
+
expect(queryTile(document, 0).declaration).toEqual({
|
|
46
45
|
kind: "reference",
|
|
47
46
|
from: "by_category",
|
|
48
47
|
});
|
|
@@ -5,7 +5,12 @@ import { describe, expect, it } from "bun:test";
|
|
|
5
5
|
import type { GivenValue } from "../../hooks/givenValue";
|
|
6
6
|
import type { DashboardDocument, QueryTile } from "./document";
|
|
7
7
|
import { queryTile } from "./testing/fixtures";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
givensReadThroughModel,
|
|
10
|
+
previewGivens,
|
|
11
|
+
previewTileQuery,
|
|
12
|
+
tileExpressionKey,
|
|
13
|
+
} from "./preview";
|
|
9
14
|
|
|
10
15
|
const tile = (
|
|
11
16
|
name: string,
|
|
@@ -65,7 +70,7 @@ describe("previewGivens", () => {
|
|
|
65
70
|
});
|
|
66
71
|
});
|
|
67
72
|
|
|
68
|
-
it("shows a filter default as the server publishes it: unwrapped, and
|
|
73
|
+
it("shows a filter default as the server publishes it: unwrapped, and empty when empty", () => {
|
|
69
74
|
const filtered: DashboardDocument = {
|
|
70
75
|
...document,
|
|
71
76
|
localGivens: [
|
|
@@ -80,7 +85,9 @@ describe("previewGivens", () => {
|
|
|
80
85
|
],
|
|
81
86
|
};
|
|
82
87
|
const [empty, state] = previewGivens(filtered, []);
|
|
83
|
-
|
|
88
|
+
// As the server publishes it: "", which filters nothing (absent would
|
|
89
|
+
// read as no default declared).
|
|
90
|
+
expect(empty.default).toBe("");
|
|
84
91
|
expect(state.default).toBe("WN");
|
|
85
92
|
// The document keeps the literal the file is written from.
|
|
86
93
|
expect(filtered.localGivens?.[1].default).toBe("f'WN'");
|
|
@@ -105,6 +112,114 @@ describe("previewGivens", () => {
|
|
|
105
112
|
});
|
|
106
113
|
});
|
|
107
114
|
|
|
115
|
+
describe("givens read through the model", () => {
|
|
116
|
+
// The auto_recalls shape: the report binds nothing; the model's source
|
|
117
|
+
// filters itself by four givens in its own `where:`.
|
|
118
|
+
const recalls: DashboardDocument = {
|
|
119
|
+
layout: "grid",
|
|
120
|
+
title: "Recalls",
|
|
121
|
+
imports: [{ kind: "all", from: "auto_recalls.malloy" }],
|
|
122
|
+
sources: [{ name: "recalls_tiles", base: "recalls" }],
|
|
123
|
+
tiles: [
|
|
124
|
+
{ ...tile("by_year", "by_year"), source: "recalls_tiles" },
|
|
125
|
+
{ ...tile("by_maker", "by_maker"), source: "recalls_tiles" },
|
|
126
|
+
],
|
|
127
|
+
};
|
|
128
|
+
const MODEL = [
|
|
129
|
+
{ name: "manufacturer_filter", type: "filter<string>" },
|
|
130
|
+
{ name: "subject_filter", type: "filter<string>" },
|
|
131
|
+
{ name: "major_recall_filter", type: "boolean" },
|
|
132
|
+
{ name: "recall_date_filter", type: "filter<date>" },
|
|
133
|
+
];
|
|
134
|
+
const served = new Map([
|
|
135
|
+
[
|
|
136
|
+
"recalls_tiles -> by_year",
|
|
137
|
+
["manufacturer_filter", "recall_date_filter", "major_recall_filter"],
|
|
138
|
+
],
|
|
139
|
+
["recalls_tiles -> by_maker", ["manufacturer_filter", "subject_filter"]],
|
|
140
|
+
]);
|
|
141
|
+
|
|
142
|
+
it("shows a given only the model reads, in the manifest's order", () => {
|
|
143
|
+
const reads = givensReadThroughModel(recalls, recalls, served);
|
|
144
|
+
expect(
|
|
145
|
+
previewGivens(recalls, MODEL, reads).map((spec) => spec.name),
|
|
146
|
+
).toEqual(MODEL.map((spec) => spec.name));
|
|
147
|
+
// Without the reads, the row the builder drew before: empty.
|
|
148
|
+
expect(previewGivens(recalls, MODEL)).toEqual([]);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("leaves out what this file bound, so a removed binding takes its control", () => {
|
|
152
|
+
const bound: DashboardDocument = {
|
|
153
|
+
...recalls,
|
|
154
|
+
tiles: [
|
|
155
|
+
{
|
|
156
|
+
...tile("by_year", "by_year", [
|
|
157
|
+
{ field: "category", given: "CATEGORY" },
|
|
158
|
+
]),
|
|
159
|
+
source: "recalls_tiles",
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
};
|
|
163
|
+
const reads = givensReadThroughModel(
|
|
164
|
+
bound,
|
|
165
|
+
bound,
|
|
166
|
+
new Map([
|
|
167
|
+
["recalls_tiles -> by_year", ["CATEGORY", "manufacturer_filter"]],
|
|
168
|
+
]),
|
|
169
|
+
);
|
|
170
|
+
expect([...reads]).toEqual(["manufacturer_filter"]);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it("puts this file's bound declarations first, then the model's", () => {
|
|
174
|
+
const mixed: DashboardDocument = {
|
|
175
|
+
...recalls,
|
|
176
|
+
localGivens: [{ name: "SINCE", type: "date", default: "@2020-01-01" }],
|
|
177
|
+
tiles: [
|
|
178
|
+
{
|
|
179
|
+
...tile("by_year", "by_year", [
|
|
180
|
+
{ field: "recall_date", given: "SINCE", op: ">=" },
|
|
181
|
+
]),
|
|
182
|
+
source: "recalls_tiles",
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
};
|
|
186
|
+
const reads = givensReadThroughModel(mixed, mixed, served);
|
|
187
|
+
expect(
|
|
188
|
+
previewGivens(mixed, MODEL, reads).map((spec) => spec.name),
|
|
189
|
+
).toEqual([
|
|
190
|
+
"SINCE",
|
|
191
|
+
"manufacturer_filter",
|
|
192
|
+
"major_recall_filter",
|
|
193
|
+
"recall_date_filter",
|
|
194
|
+
]);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it("reads a new tile by a served tile of the same expression, and nothing otherwise", () => {
|
|
198
|
+
const added: DashboardDocument = {
|
|
199
|
+
...recalls,
|
|
200
|
+
tiles: [
|
|
201
|
+
...recalls.tiles,
|
|
202
|
+
{ ...tile("by_maker", "by_maker"), source: "recalls_tiles" },
|
|
203
|
+
{ ...tile("fresh", "fresh"), source: "recalls_tiles" },
|
|
204
|
+
],
|
|
205
|
+
};
|
|
206
|
+
expect(
|
|
207
|
+
[
|
|
208
|
+
...givensReadThroughModel(added, { ...recalls, tiles: [] }, served),
|
|
209
|
+
].sort(),
|
|
210
|
+
).toEqual(
|
|
211
|
+
[
|
|
212
|
+
"major_recall_filter",
|
|
213
|
+
"manufacturer_filter",
|
|
214
|
+
"recall_date_filter",
|
|
215
|
+
"subject_filter",
|
|
216
|
+
].sort(),
|
|
217
|
+
);
|
|
218
|
+
const onlyNew = { ...recalls, tiles: [added.tiles[3]!] };
|
|
219
|
+
expect(givensReadThroughModel(onlyNew, recalls, served).size).toBe(0);
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
|
|
108
223
|
describe("previewTileQuery", () => {
|
|
109
224
|
const runnable = new Set(["CATEGORY", "SINCE"]);
|
|
110
225
|
|
|
@@ -201,9 +316,14 @@ describe("previewTileQuery", () => {
|
|
|
201
316
|
expect(q.givenNames).toEqual(["CATEGORY"]);
|
|
202
317
|
});
|
|
203
318
|
|
|
204
|
-
it("
|
|
319
|
+
it("applies an unsent given's declared default until a value is set, and skips one nobody declares", () => {
|
|
320
|
+
// No value set: SINCE's default applies, as the server applies a
|
|
321
|
+
// given's default once the report is saved; CATEGORY's default is an
|
|
322
|
+
// empty filter, which filters nothing, so it adds no clause.
|
|
205
323
|
const q = previewTileQuery(document, queryTile(document, 0), new Set());
|
|
206
|
-
expect(q.expression).toBe(
|
|
324
|
+
expect(q.expression).toBe(
|
|
325
|
+
"overview -> key_figures + { where: created_at >= @2023-01-01 }",
|
|
326
|
+
);
|
|
207
327
|
expect(q.givenNames).toEqual([]);
|
|
208
328
|
const stray: QueryTile = tile("t", "v", [
|
|
209
329
|
{ field: "x", given: "NOBODY" },
|