@malloy-publisher/sdk 0.2.7 → 0.3.1
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/README.md +180 -204
- package/dist/DocumentStorageProvider-BeBD0uWc.cjs.js +134 -0
- package/dist/DocumentStorageProvider-tGvodI8f.es.js +24268 -0
- package/dist/RenderedResult-CPi6uQWq.cjs.js +115 -0
- package/dist/RenderedResult-mDE-4u8S.es.js +542 -0
- package/dist/{ServerProvider-xXW1HJOJ.cjs.js → ServerProvider-CH71GsoL.cjs.js} +1 -1
- package/dist/{ServerProvider-ksC5Su_x.es.js → ServerProvider-X2Ma0HRs.es.js} +324 -359
- package/dist/builder/index.cjs.js +105 -0
- package/dist/builder/index.d.ts +2 -0
- package/dist/builder/index.es.js +9561 -0
- package/dist/builder-entry.d.ts +8 -0
- package/dist/client/api.d.ts +13 -1
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/ApiErrorDisplay.d.ts +1 -2
- package/dist/components/Dashboard/Dashboard.d.ts +23 -16
- package/dist/components/Dashboard/DashboardGrid.d.ts +67 -0
- package/dist/components/Dashboard/DashboardTile.d.ts +6 -1
- package/dist/components/Dashboard/ExploreDialog.d.ts +18 -0
- package/dist/components/Dashboard/RowsDialog.d.ts +47 -0
- package/dist/components/Dashboard/TileCard.d.ts +44 -0
- package/dist/components/Dashboard/index.d.ts +2 -0
- package/dist/components/Dashboard/promoteMeasureRow.d.ts +40 -0
- package/dist/components/Dashboard/telemetry.d.ts +43 -0
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +35 -0
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +29 -0
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +112 -0
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +32 -0
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +15 -0
- package/dist/components/DashboardBuilder/DrillDialog.d.ts +15 -0
- package/dist/components/DashboardBuilder/FilterDialog.d.ts +54 -0
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +17 -0
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +20 -0
- package/dist/components/DashboardBuilder/TileFrame.d.ts +42 -0
- package/dist/components/DashboardBuilder/TileMenu.d.ts +24 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +62 -0
- package/dist/components/DashboardBuilder/controls.d.ts +157 -0
- package/dist/components/DashboardBuilder/diff.d.ts +35 -0
- package/dist/components/DashboardBuilder/document.d.ts +218 -0
- package/dist/components/DashboardBuilder/layout.d.ts +71 -0
- package/dist/components/DashboardBuilder/malloyText.d.ts +45 -0
- package/dist/components/DashboardBuilder/preview.d.ts +60 -0
- package/dist/components/DashboardBuilder/readDocument.d.ts +106 -0
- package/dist/components/DashboardBuilder/sortable.d.ts +51 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +44 -0
- package/dist/components/DashboardBuilder/testing/fixtures.d.ts +10 -0
- package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +22 -0
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +63 -0
- package/dist/components/DashboardBuilder/useDraft.d.ts +13 -0
- package/dist/components/DashboardBuilder/useFilterForm.d.ts +65 -0
- package/dist/components/DashboardBuilder/useTileReorder.d.ts +22 -0
- package/dist/components/DashboardBuilder/useTileResize.d.ts +29 -0
- package/dist/components/DocumentStorage/BrowserDocumentStorage.d.ts +14 -0
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +58 -0
- package/dist/components/DocumentStorage/DocumentStorageProvider.d.ts +25 -0
- package/dist/components/DocumentStorage/index.d.ts +3 -0
- package/dist/components/FloatingIconButton.d.ts +16 -0
- package/dist/components/Model/index.d.ts +0 -1
- package/dist/components/Prose.d.ts +46 -0
- package/dist/components/RenderedResult/RenderedResult.d.ts +12 -0
- package/dist/components/RenderedResult/ResultContainer.d.ts +7 -1
- package/dist/components/RenderedResult/ResultPanel.d.ts +30 -0
- package/dist/components/RenderedResult/index.d.ts +2 -0
- package/dist/components/RenderedResult/resultSizing.d.ts +183 -0
- package/dist/components/drill/index.d.ts +2 -1
- package/dist/components/drill/resolveDrill.d.ts +22 -0
- package/dist/components/drill/useDrill.d.ts +11 -2
- package/dist/components/drill/useDrillSelf.d.ts +46 -0
- package/dist/components/given/filterValue.d.ts +63 -0
- package/dist/components/given/index.d.ts +1 -0
- package/dist/components/given/useGivenUrlParams.d.ts +39 -0
- package/dist/components/index.d.ts +3 -3
- package/dist/components/styles.d.ts +3 -7
- package/dist/core-8NVBCLZh.cjs.js +148 -0
- package/dist/{core-BY7vB5gN.es.js → core-B8oMW4sm.es.js} +3540 -2335
- package/dist/hooks/index.d.ts +3 -1
- package/dist/hooks/useDocumentControls.d.ts +70 -0
- package/dist/hooks/useQueryResult.d.ts +40 -0
- package/dist/hooks/useSuggestOptions.d.ts +28 -12
- package/dist/index.cjs.js +34 -1
- package/dist/index.es.js +21487 -79
- package/dist/sdk.css +1 -1
- package/dist/styles.css +0 -1
- package/dist/utils/malloyLiteral.d.ts +11 -0
- package/package.json +25 -14
- package/src/builder-entry.ts +55 -0
- package/src/components/ApiErrorDisplay.tsx +1 -1
- package/src/components/Connections/EditConnectionDialog.tsx +96 -86
- package/src/components/Dashboard/Dashboard.spec.tsx +7 -10
- package/src/components/Dashboard/Dashboard.tsx +184 -229
- package/src/components/Dashboard/DashboardGrid.tsx +124 -0
- package/src/components/Dashboard/DashboardTile.spec.tsx +30 -6
- package/src/components/Dashboard/DashboardTile.tsx +67 -101
- package/src/components/Dashboard/ExploreDialog.tsx +84 -0
- package/src/components/Dashboard/RowsDialog.spec.ts +42 -0
- package/src/components/Dashboard/RowsDialog.tsx +234 -0
- package/src/components/Dashboard/TileCard.tsx +120 -0
- package/src/components/Dashboard/index.ts +2 -0
- package/src/components/Dashboard/promoteMeasureRow.spec.ts +207 -0
- package/src/components/Dashboard/promoteMeasureRow.ts +160 -0
- package/src/components/Dashboard/telemetry.ts +44 -0
- package/src/components/Dashboard/tileGridColumn.spec.ts +1 -1
- package/src/components/DashboardBuilder/AddTileDialog.tsx +249 -0
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +270 -0
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +858 -0
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +653 -0
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +211 -0
- package/src/components/DashboardBuilder/DashboardEditor.tsx +493 -0
- package/src/components/DashboardBuilder/DiffDialog.tsx +129 -0
- package/src/components/DashboardBuilder/DrillDialog.tsx +281 -0
- package/src/components/DashboardBuilder/FilterDialog.tsx +581 -0
- package/src/components/DashboardBuilder/FilterStrip.tsx +125 -0
- package/src/components/DashboardBuilder/SettingsPopover.tsx +168 -0
- package/src/components/DashboardBuilder/TileFrame.tsx +380 -0
- package/src/components/DashboardBuilder/TileMenu.tsx +188 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +215 -0
- package/src/components/DashboardBuilder/catalog.ts +225 -0
- package/src/components/DashboardBuilder/controls.spec.ts +243 -0
- package/src/components/DashboardBuilder/controls.ts +398 -0
- package/src/components/DashboardBuilder/diff.spec.ts +44 -0
- package/src/components/DashboardBuilder/diff.ts +93 -0
- package/src/components/DashboardBuilder/document.ts +209 -0
- package/src/components/DashboardBuilder/keepRowStructure.spec.ts +84 -0
- package/src/components/DashboardBuilder/layout.ts +143 -0
- package/src/components/DashboardBuilder/malloyText.spec.ts +84 -0
- package/src/components/DashboardBuilder/malloyText.ts +151 -0
- package/src/components/DashboardBuilder/moveIntoGap.spec.ts +90 -0
- package/src/components/DashboardBuilder/preview.spec.ts +149 -0
- package/src/components/DashboardBuilder/preview.ts +172 -0
- package/src/components/DashboardBuilder/readDocument.spec.ts +375 -0
- package/src/components/DashboardBuilder/readDocument.ts +467 -0
- package/src/components/DashboardBuilder/sortable.tsx +151 -0
- package/src/components/DashboardBuilder/spliceDocument.spec.ts +1108 -0
- package/src/components/DashboardBuilder/spliceDocument.ts +1098 -0
- package/src/components/DashboardBuilder/testing/fixtures.ts +48 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +88 -0
- package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +255 -0
- package/src/components/DashboardBuilder/useDashboardEditor.ts +193 -0
- package/src/components/DashboardBuilder/useDraft.ts +43 -0
- package/src/components/DashboardBuilder/useFilterForm.spec.tsx +144 -0
- package/src/components/DashboardBuilder/useFilterForm.ts +352 -0
- package/src/components/DashboardBuilder/useTileReorder.spec.tsx +97 -0
- package/src/components/DashboardBuilder/useTileReorder.ts +115 -0
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +121 -0
- package/src/components/DashboardBuilder/useTileResize.ts +110 -0
- package/src/components/DashboardBuilder/withGaps.spec.ts +96 -0
- package/src/components/DocumentStorage/BrowserDocumentStorage.spec.ts +81 -0
- package/src/components/DocumentStorage/BrowserDocumentStorage.ts +105 -0
- package/src/components/DocumentStorage/DocumentStorage.ts +73 -0
- package/src/components/DocumentStorage/DocumentStorageProvider.tsx +58 -0
- package/src/components/DocumentStorage/index.ts +16 -0
- package/src/components/Environment/About.tsx +4 -36
- package/src/components/FloatingIconButton.tsx +41 -0
- package/src/components/Model/Model.tsx +6 -23
- package/src/components/Model/ModelCell.tsx +34 -72
- package/src/components/Model/index.ts +0 -1
- package/src/components/Notebook/Notebook.tsx +27 -156
- package/src/components/Notebook/NotebookCell.tsx +37 -191
- package/src/components/Prose.spec.tsx +85 -0
- package/src/components/Prose.tsx +179 -0
- package/src/components/QueryResult/QueryResult.tsx +15 -43
- package/src/components/RenderedResult/RenderedResult.tsx +86 -76
- package/src/components/RenderedResult/ResultContainer.tsx +25 -36
- package/src/components/RenderedResult/ResultPanel.spec.tsx +49 -0
- package/src/components/RenderedResult/ResultPanel.tsx +73 -0
- package/src/components/RenderedResult/index.ts +16 -0
- package/src/components/RenderedResult/resultSizing.spec.ts +249 -0
- package/src/components/RenderedResult/resultSizing.ts +308 -0
- package/src/components/ResultsDialog.tsx +2 -1
- package/src/components/drill/index.ts +6 -0
- package/src/components/drill/resolveDrill.ts +22 -1
- package/src/components/drill/useDrill.spec.tsx +94 -0
- package/src/components/drill/useDrill.tsx +52 -12
- package/src/components/drill/useDrillSelf.spec.tsx +64 -0
- package/src/components/drill/useDrillSelf.ts +110 -0
- package/src/components/given/GivenInput.spec.tsx +196 -2
- package/src/components/given/GivenInput.tsx +300 -25
- package/src/components/given/GivensPanel.tsx +1 -1
- package/src/components/given/filterValue.spec.ts +112 -0
- package/src/components/given/filterValue.ts +188 -0
- package/src/components/given/index.ts +4 -0
- package/src/components/given/useGivenUrlParams.spec.tsx +74 -0
- package/src/components/given/useGivenUrlParams.ts +87 -0
- package/src/components/index.ts +11 -3
- package/src/components/styles.ts +0 -37
- package/src/hooks/index.ts +13 -1
- package/src/hooks/useDocumentControls.ts +170 -0
- package/src/hooks/useGivensState.spec.ts +158 -0
- package/src/hooks/useGivensState.ts +114 -23
- package/src/hooks/useQueryResult.ts +82 -0
- package/src/hooks/useSuggestOptions.dom.spec.ts +60 -1
- package/src/hooks/useSuggestOptions.ts +94 -51
- package/src/utils/malloyLiteral.spec.ts +43 -0
- package/src/utils/malloyLiteral.ts +76 -0
- package/vite.config.ts +5 -1
- package/dist/components/AnalyzePackageButton.d.ts +0 -6
- package/dist/components/Workbook/BrowserWorkbookStorage.d.ts +0 -9
- package/dist/components/Workbook/EditableMalloyCell.d.ts +0 -11
- package/dist/components/Workbook/ModelPicker.d.ts +0 -11
- package/dist/components/Workbook/MutableCell.d.ts +0 -17
- package/dist/components/Workbook/Workbook.d.ts +0 -7
- package/dist/components/Workbook/WorkbookList.d.ts +0 -7
- package/dist/components/Workbook/WorkbookManager.d.ts +0 -84
- package/dist/components/Workbook/WorkbookStorage.d.ts +0 -17
- package/dist/components/Workbook/WorkbookStorageProvider.d.ts +0 -12
- package/dist/components/Workbook/index.d.ts +0 -7
- package/dist/core-CWKmWEg2.cjs.js +0 -148
- package/dist/index-B0WyZAUA.es.js +0 -66412
- package/dist/index-kxVD1RjY.cjs.js +0 -356
- package/dist/markdown-editor.css +0 -341
- package/src/components/AnalyzePackageButton.tsx +0 -319
- package/src/components/Workbook/BrowserWorkbookStorage.ts +0 -64
- package/src/components/Workbook/EditableMalloyCell.tsx +0 -49
- package/src/components/Workbook/ModelPicker.tsx +0 -134
- package/src/components/Workbook/MutableCell.tsx +0 -458
- package/src/components/Workbook/Workbook.tsx +0 -501
- package/src/components/Workbook/WorkbookList.tsx +0 -110
- package/src/components/Workbook/WorkbookManager.ts +0 -214
- package/src/components/Workbook/WorkbookStorage.ts +0 -35
- package/src/components/Workbook/WorkbookStorageProvider.tsx +0 -40
- package/src/components/Workbook/index.ts +0 -10
|
@@ -3,18 +3,17 @@
|
|
|
3
3
|
|
|
4
4
|
import "@malloydata/malloy-explorer/styles.css";
|
|
5
5
|
import { Stack, Typography } from "@mui/material";
|
|
6
|
-
import { useCallback, useEffect,
|
|
6
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
7
7
|
import { planRun } from "./runPlan";
|
|
8
8
|
import { RawNotebook } from "../../client";
|
|
9
9
|
import { GivenValue } from "../../hooks/givenValue";
|
|
10
|
-
import {
|
|
10
|
+
import { useDocumentControls } from "../../hooks/useDocumentControls";
|
|
11
11
|
import { useModelGivens } from "../../hooks/useModelGivens";
|
|
12
12
|
import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
13
|
-
import { useSuggestOptions } from "../../hooks/useSuggestOptions";
|
|
14
13
|
import { parseResourceUri } from "../../utils/formatting";
|
|
15
14
|
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
16
15
|
import type { NavigationClick } from "../click_helper";
|
|
17
|
-
import {
|
|
16
|
+
import type { DrillNavigation } from "../drill";
|
|
18
17
|
import { GivensPanel } from "../given";
|
|
19
18
|
import { givensToRequest } from "../given/paramCodec";
|
|
20
19
|
import { Loading } from "../Loading";
|
|
@@ -157,157 +156,38 @@ export default function Notebook({
|
|
|
157
156
|
const lastDocumentRef = useRef<string | undefined>(undefined);
|
|
158
157
|
const [executionError, setExecutionError] = useState<Error | null>(null);
|
|
159
158
|
|
|
160
|
-
// Model-level `given:` declarations, and the state behind their controls
|
|
161
|
-
//
|
|
162
|
-
//
|
|
163
|
-
// implementation rather than two that drift.
|
|
159
|
+
// Model-level `given:` declarations, and the state behind their controls:
|
|
160
|
+
// the same hook the dashboard uses, so both surfaces get URL-addressable
|
|
161
|
+
// parameters, Apply batching and `to=self` drill from one implementation.
|
|
164
162
|
const declaredGivens = useModelGivens(notebook);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
.filter((given) => given.name !== undefined)
|
|
170
|
-
.map((given) => [given.name as string, given.type]),
|
|
171
|
-
),
|
|
172
|
-
[declaredGivens],
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
// Silent until the notebook has actually loaded. Which givens exist is not
|
|
176
|
-
// known before then: `useModelGivens(undefined)` is empty, so a report in
|
|
177
|
-
// that window says "no values, and I manage nothing", which a host reasonably
|
|
178
|
-
// reads as "clear what you wrote". During an in-app navigation from one
|
|
179
|
-
// notebook to another that window sits between the two, and the parameters it
|
|
180
|
-
// would clear can belong to the notebook now ARRIVING. A notebook that
|
|
181
|
-
// genuinely declares no givens still reports, because by then the empty set
|
|
182
|
-
// is the answer rather than the absence of one.
|
|
183
|
-
const reportGivens = useCallback(
|
|
184
|
-
(next: Record<string, string>) => {
|
|
185
|
-
if (!isSuccess) return;
|
|
186
|
-
onGivensChange?.(next, Array.from(declaredTypes.keys()));
|
|
187
|
-
},
|
|
188
|
-
[isSuccess, onGivensChange, declaredTypes],
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
// Read off the notebook now that the server derives it: a file-level
|
|
192
|
-
// `## autorun=false` arrives as `RawNotebook.autorun`, the same field with
|
|
193
|
-
// the same default that a dashboard's `# artifact { autorun=false }`
|
|
194
|
-
// produces. This was hardcoded true while nothing populated the field, on
|
|
195
|
-
// the grounds that a spec declaring one nothing produces is a spec that
|
|
196
|
-
// lies; the reader has landed, so this is the follow-up that comment named.
|
|
197
|
-
//
|
|
198
|
-
// Absent means autorun, so only an explicit `false` batches. Batching
|
|
199
|
-
// matters more here than on a dashboard: one control change re-runs every
|
|
200
|
-
// cell in the document.
|
|
163
|
+
// A file-level `## autorun=false` arrives as `RawNotebook.autorun`, the same
|
|
164
|
+
// field with the same default a dashboard's `# artifact { autorun=false }`
|
|
165
|
+
// produces. Batching matters more here than on a dashboard: one control
|
|
166
|
+
// change re-runs every cell in the document.
|
|
201
167
|
const autorun = notebook?.autorun !== false;
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
//
|
|
168
|
+
const controls = useDocumentControls({
|
|
169
|
+
specs: declaredGivens,
|
|
170
|
+
loaded: isSuccess,
|
|
171
|
+
// Where the controls start, from a file-level `## givens { … }`.
|
|
206
172
|
startingValues: notebook?.startingGivens,
|
|
207
173
|
params: givens,
|
|
208
|
-
|
|
209
|
-
// dropped. `useGivensState` records what it last reported BEFORE calling
|
|
210
|
-
// out, so a report the callback throws away is remembered as delivered
|
|
211
|
-
// and never retried, leaving a parameter stranded in the host's URL.
|
|
212
|
-
// Passing undefined makes the hook skip the report entirely, which leaves
|
|
213
|
-
// its record untouched and the next real change still reportable.
|
|
214
|
-
onParamsChange: isSuccess ? reportGivens : undefined,
|
|
215
|
-
// Which notebook these edits belong to. Navigating between notebooks
|
|
216
|
-
// reuses this component, so without it one notebook's applied values
|
|
217
|
-
// carried into the next whenever both started from the same values.
|
|
174
|
+
onGivensChange,
|
|
218
175
|
documentKey: resourceUri,
|
|
219
176
|
autorun,
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
// A notebook's model path is the notebook itself: `suggest` queries run
|
|
223
|
-
// against the same model the cells do.
|
|
224
|
-
const {
|
|
225
|
-
options: givenOptions,
|
|
226
|
-
isLoading: givenOptionsLoading,
|
|
227
|
-
failed: givenOptionsFailed,
|
|
228
|
-
} = useSuggestOptions(
|
|
229
177
|
environmentName,
|
|
230
178
|
packageName,
|
|
231
|
-
|
|
232
|
-
|
|
179
|
+
// A notebook's model path is the notebook itself: `suggest` queries run
|
|
180
|
+
// against the same model the cells do.
|
|
181
|
+
modelPath: notebookPath,
|
|
233
182
|
versionId,
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
// `MIN_AMOUNT`). An exact match therefore failed for the common case, and
|
|
243
|
-
// upper-casing the dimension name, which is what this did first, only moved
|
|
244
|
-
// the failure onto models that spell their givens in lower case. Folding
|
|
245
|
-
// case resolves both instead of picking a side.
|
|
246
|
-
const givenNamesByFold = useMemo(() => {
|
|
247
|
-
const byFold = new Map<string, string>();
|
|
248
|
-
for (const name of declaredTypes.keys()) {
|
|
249
|
-
// First declaration wins, so a model with `REGION` and `region` keeps
|
|
250
|
-
// the one it declared first rather than silently flipping.
|
|
251
|
-
if (!byFold.has(name.toLowerCase()))
|
|
252
|
-
byFold.set(name.toLowerCase(), name);
|
|
253
|
-
}
|
|
254
|
-
return byFold;
|
|
255
|
-
}, [declaredTypes]);
|
|
256
|
-
|
|
257
|
-
/** The declared given a drill tag's name refers to, or undefined. */
|
|
258
|
-
const resolveGiven = useCallback(
|
|
259
|
-
(given: string) =>
|
|
260
|
-
declaredTypes.has(given)
|
|
261
|
-
? given
|
|
262
|
-
: givenNamesByFold.get(given.toLowerCase()),
|
|
263
|
-
[declaredTypes, givenNamesByFold],
|
|
264
|
-
);
|
|
265
|
-
|
|
266
|
-
// `to=self` filters in place, which only works for a given this notebook
|
|
267
|
-
// actually declares: sending one it cannot bind would fail every cell. The
|
|
268
|
-
// mismatch is reported to the author rather than issued: same rule, same
|
|
269
|
-
// wording, as the dashboard viewer.
|
|
270
|
-
// Asked before a cell is painted as drillable, so the affordance matches what
|
|
271
|
-
// a click can actually do. The refusal below still stands as a backstop for a
|
|
272
|
-
// caller that does not ask.
|
|
273
|
-
const canDrillSelf = useCallback(
|
|
274
|
-
(given: string) => resolveGiven(given) !== undefined,
|
|
275
|
-
[resolveGiven],
|
|
276
|
-
);
|
|
277
|
-
|
|
278
|
-
const onDrillSelf = useCallback(
|
|
279
|
-
(given: string, rawValue: unknown) => {
|
|
280
|
-
const declared = resolveGiven(given);
|
|
281
|
-
if (declared === undefined) {
|
|
282
|
-
console.warn(
|
|
283
|
-
`# drill { to=self } tried to set '${given}', which ` +
|
|
284
|
-
`'${notebookPath}' does not declare as a given. Name the ` +
|
|
285
|
-
`given with 'given=' on the drill tag.`,
|
|
286
|
-
);
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
// Encoded against the declared type of the given being set, which is
|
|
290
|
-
// knowable here and is not knowable at the click. Set under the name
|
|
291
|
-
// the MODEL declares, not the one the tag spelled, so the value goes
|
|
292
|
-
// into the URL and the request under the one name the server knows.
|
|
293
|
-
const declaredType = declaredTypes.get(declared);
|
|
294
|
-
const value = encodeDrillValue(rawValue, declaredType);
|
|
295
|
-
if (value === undefined) {
|
|
296
|
-
// Say so. Returning in silence left a whole column painted as
|
|
297
|
-
// clickable while every click did nothing, and a `given=` pointing
|
|
298
|
-
// at a type the clicked value cannot become is an authoring
|
|
299
|
-
// mistake the author has no other way to see. The sibling refusal
|
|
300
|
-
// in `resolveDrill` warns for the same reason.
|
|
301
|
-
console.warn(
|
|
302
|
-
`Drill declined: ${JSON.stringify(rawValue)} cannot be a value for given "${declared}"` +
|
|
303
|
-
(declaredType ? ` of type ${declaredType}` : ""),
|
|
304
|
-
);
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
setGiven(declared, value);
|
|
308
|
-
},
|
|
309
|
-
[declaredTypes, notebookPath, resolveGiven, setGiven],
|
|
310
|
-
);
|
|
183
|
+
documentName: notebookPath,
|
|
184
|
+
});
|
|
185
|
+
const {
|
|
186
|
+
applied,
|
|
187
|
+
declaredTypes,
|
|
188
|
+
canSelf: canDrillSelf,
|
|
189
|
+
onSelf: onDrillSelf,
|
|
190
|
+
} = controls;
|
|
311
191
|
|
|
312
192
|
/**
|
|
313
193
|
* The `givens` query param for the notebook-cell GET: the same map the
|
|
@@ -624,16 +504,7 @@ export default function Notebook({
|
|
|
624
504
|
<CleanNotebookSection>
|
|
625
505
|
<Stack spacing={3} component="section">
|
|
626
506
|
{/* Parameters panel: the controls for `given:` declarations */}
|
|
627
|
-
<GivensPanel
|
|
628
|
-
givens={declaredGivens}
|
|
629
|
-
values={draft}
|
|
630
|
-
onChange={setGiven}
|
|
631
|
-
onReset={reset}
|
|
632
|
-
options={givenOptions}
|
|
633
|
-
optionsLoading={givenOptionsLoading}
|
|
634
|
-
optionsFailed={givenOptionsFailed}
|
|
635
|
-
apply={autorun ? undefined : { onApply: apply, pending }}
|
|
636
|
-
/>
|
|
507
|
+
<GivensPanel {...controls.panel} />
|
|
637
508
|
|
|
638
509
|
{/* Loading State */}
|
|
639
510
|
{!isSuccess && !isError && (
|
|
@@ -19,27 +19,22 @@ import {
|
|
|
19
19
|
Tooltip,
|
|
20
20
|
Typography,
|
|
21
21
|
} from "@mui/material";
|
|
22
|
-
import Markdown from "markdown-to-jsx";
|
|
23
22
|
import React, { useEffect, useState } from "react";
|
|
24
23
|
import { usePublisherTheme } from "../../theme/ThemeContext";
|
|
25
24
|
import { parseResourceUri } from "../../utils/formatting";
|
|
26
25
|
import { highlight } from "../highlighter";
|
|
27
26
|
import { ModelExplorerDialog } from "../Model/ModelExplorerDialog";
|
|
27
|
+
import { FloatingIconButton } from "../FloatingIconButton";
|
|
28
|
+
import { Prose } from "../Prose";
|
|
28
29
|
import type { NavigationClick } from "../click_helper";
|
|
29
30
|
import { useDrill, type DrillNavigation } from "../drill";
|
|
30
31
|
import { createEmbeddedQueryResult } from "../QueryResult/QueryResult";
|
|
31
32
|
import ResultContainer from "../RenderedResult/ResultContainer";
|
|
33
|
+
import { NOTEBOOK_CELL_MAX_HEIGHT } from "../RenderedResult/resultSizing";
|
|
32
34
|
import ResultsDialog from "../ResultsDialog";
|
|
33
|
-
import { CleanMetricCard
|
|
35
|
+
import { CleanMetricCard } from "../styles";
|
|
34
36
|
import { EnhancedNotebookCell } from "./types";
|
|
35
37
|
|
|
36
|
-
/**
|
|
37
|
-
* Cap for a cell result that lays itself out: a table, mostly. Tall enough for
|
|
38
|
-
* a screenful of rows, after which the cell scrolls rather than the page
|
|
39
|
-
* turning into one long table.
|
|
40
|
-
*/
|
|
41
|
-
const CELL_MAX_HEIGHT = 700;
|
|
42
|
-
|
|
43
38
|
interface NotebookCellProps {
|
|
44
39
|
cell: EnhancedNotebookCell;
|
|
45
40
|
expandCodeCell?: boolean;
|
|
@@ -89,82 +84,6 @@ interface NotebookCellProps {
|
|
|
89
84
|
onDrillNavigate?: (target: DrillNavigation, event?: MouseEvent) => void;
|
|
90
85
|
}
|
|
91
86
|
|
|
92
|
-
interface NotebookMarkdownLinkProps {
|
|
93
|
-
href?: string;
|
|
94
|
-
title?: string;
|
|
95
|
-
children?: React.ReactNode;
|
|
96
|
-
envName: string;
|
|
97
|
-
pkgName: string;
|
|
98
|
-
sourceDir: string;
|
|
99
|
-
onNavigate?: (to: string, event?: NavigationClick) => void;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Links inside a rendered notebook/README are authored relative to the source
|
|
103
|
-
// file (e.g. `spielberg.malloynb`). A plain browser anchor resolves them
|
|
104
|
-
// against the current page URL, which drops the package segment for a README
|
|
105
|
-
// shown at the package route. Resolve relative links against the source file's
|
|
106
|
-
// own directory instead and route them through the SPA. External, hash, and
|
|
107
|
-
// absolute links stay as normal anchors.
|
|
108
|
-
function NotebookMarkdownLink({
|
|
109
|
-
href,
|
|
110
|
-
title,
|
|
111
|
-
children,
|
|
112
|
-
envName,
|
|
113
|
-
pkgName,
|
|
114
|
-
sourceDir,
|
|
115
|
-
onNavigate,
|
|
116
|
-
}: NotebookMarkdownLinkProps) {
|
|
117
|
-
const hasScheme = !!href && /^[a-z][a-z0-9+.-]*:/i.test(href);
|
|
118
|
-
const isInternalRelative =
|
|
119
|
-
!!href && !hasScheme && !href.startsWith("/") && !href.startsWith("#");
|
|
120
|
-
|
|
121
|
-
if (!isInternalRelative || !href) {
|
|
122
|
-
// External, absolute, or hash link: render a normal anchor. Only allow
|
|
123
|
-
// safe schemes so a crafted `javascript:`/`data:` href in a package
|
|
124
|
-
// README (packages can come from untrusted git/S3 sources) cannot run.
|
|
125
|
-
const isUnsafeScheme =
|
|
126
|
-
hasScheme && !/^(https?|mailto|tel):/i.test(href ?? "");
|
|
127
|
-
return (
|
|
128
|
-
<a
|
|
129
|
-
href={isUnsafeScheme ? undefined : href}
|
|
130
|
-
title={title}
|
|
131
|
-
{...(hasScheme
|
|
132
|
-
? { target: "_blank", rel: "noopener noreferrer" }
|
|
133
|
-
: {})}
|
|
134
|
-
>
|
|
135
|
-
{children}
|
|
136
|
-
</a>
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// Resolve the relative href against the source file's directory (empty for a
|
|
141
|
-
// package-root README) via a dummy origin, which normalizes any `./`/`../`
|
|
142
|
-
// and clamps escapes at the package root, then prefix the package path.
|
|
143
|
-
const resolved = new URL(href, `https://malloy.invalid/${sourceDir}`);
|
|
144
|
-
const packageRelative =
|
|
145
|
-
resolved.pathname.slice(1) + resolved.search + resolved.hash;
|
|
146
|
-
const to = `/${envName}/${pkgName}/${packageRelative}`;
|
|
147
|
-
// With a host router (onNavigate) intercept and route through the SPA.
|
|
148
|
-
// Without one (router-free SDK embedding) the absolute href navigates on
|
|
149
|
-
// its own, so rendering a notebook needs no react-router context.
|
|
150
|
-
return (
|
|
151
|
-
<a
|
|
152
|
-
href={to}
|
|
153
|
-
title={title}
|
|
154
|
-
onClick={
|
|
155
|
-
onNavigate
|
|
156
|
-
? (event) => {
|
|
157
|
-
event.preventDefault();
|
|
158
|
-
onNavigate(to, event);
|
|
159
|
-
}
|
|
160
|
-
: undefined
|
|
161
|
-
}
|
|
162
|
-
>
|
|
163
|
-
{children}
|
|
164
|
-
</a>
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
87
|
export function NotebookCell({
|
|
169
88
|
cell,
|
|
170
89
|
hideCodeCellIcon,
|
|
@@ -195,6 +114,14 @@ export function NotebookCell({
|
|
|
195
114
|
|
|
196
115
|
const { environmentName, packageName, modelPath } =
|
|
197
116
|
parseResourceUri(resourceUri);
|
|
117
|
+
// Links in a markdown cell are authored relative to the notebook file, and
|
|
118
|
+
// route through the host when it gave us a way to.
|
|
119
|
+
const links = {
|
|
120
|
+
environmentName,
|
|
121
|
+
packageName,
|
|
122
|
+
sourcePath: modelPath,
|
|
123
|
+
onNavigate,
|
|
124
|
+
};
|
|
198
125
|
|
|
199
126
|
// `# drill` is declared on a model dimension, so a notebook cell that groups
|
|
200
127
|
// by that dimension is clickable for free: the same resolution, and the
|
|
@@ -225,26 +152,6 @@ export function NotebookCell({
|
|
|
225
152
|
// a shared model dimension and cannot know which document it fired in.
|
|
226
153
|
selfLabel: "Filter this notebook",
|
|
227
154
|
});
|
|
228
|
-
// Directory of the source file within the package (empty for a package-root
|
|
229
|
-
// README), used to resolve relative links the author wrote against it.
|
|
230
|
-
const sourceDir =
|
|
231
|
-
modelPath && modelPath.includes("/")
|
|
232
|
-
? modelPath.slice(0, modelPath.lastIndexOf("/") + 1)
|
|
233
|
-
: "";
|
|
234
|
-
const markdownOptions = {
|
|
235
|
-
overrides: {
|
|
236
|
-
a: {
|
|
237
|
-
component: NotebookMarkdownLink,
|
|
238
|
-
props: {
|
|
239
|
-
envName: environmentName,
|
|
240
|
-
pkgName: packageName,
|
|
241
|
-
sourceDir,
|
|
242
|
-
onNavigate,
|
|
243
|
-
},
|
|
244
|
-
},
|
|
245
|
-
},
|
|
246
|
-
};
|
|
247
|
-
|
|
248
155
|
// Regex to extract imported names from import statements
|
|
249
156
|
const IMPORT_NAMES_REGEX = /import\s*\{([^}]+)\}\s*from\s*['"`][^'"`]+['"`]/;
|
|
250
157
|
|
|
@@ -339,42 +246,17 @@ export function NotebookCell({
|
|
|
339
246
|
|
|
340
247
|
return (
|
|
341
248
|
(cell.type === "markdown" && (
|
|
342
|
-
<
|
|
343
|
-
<Box
|
|
344
|
-
sx={(theme) => ({
|
|
345
|
-
"& h1, & h2, & h3, & h4, & h5, & h6": {
|
|
346
|
-
fontWeight: "600",
|
|
347
|
-
color: theme.palette.text.primary,
|
|
348
|
-
marginBottom: "8px",
|
|
349
|
-
marginTop: "16px",
|
|
350
|
-
},
|
|
351
|
-
"& h1": { fontSize: "28px" },
|
|
352
|
-
"& h2": { fontSize: "24px" },
|
|
353
|
-
"& h3": { fontSize: "20px" },
|
|
354
|
-
"& p": {
|
|
355
|
-
color: theme.palette.text.primary,
|
|
356
|
-
lineHeight: "1.7",
|
|
357
|
-
marginBottom: "8px",
|
|
358
|
-
fontSize: "16px",
|
|
359
|
-
},
|
|
360
|
-
"& ul, & ol": {
|
|
361
|
-
color: theme.palette.text.primary,
|
|
362
|
-
lineHeight: "1.7",
|
|
363
|
-
marginBottom: "8px",
|
|
364
|
-
fontSize: "16px",
|
|
365
|
-
},
|
|
366
|
-
"& li": {
|
|
367
|
-
marginBottom: "4px",
|
|
368
|
-
},
|
|
369
|
-
})}
|
|
370
|
-
>
|
|
249
|
+
<Box>
|
|
250
|
+
<Box>
|
|
371
251
|
{index === 0 ? (
|
|
372
252
|
<Stack
|
|
373
253
|
direction="row"
|
|
374
254
|
alignItems="flex-start"
|
|
375
255
|
justifyContent="space-between"
|
|
376
256
|
>
|
|
377
|
-
<
|
|
257
|
+
<Prose variant="document" links={links}>
|
|
258
|
+
{cell.text}
|
|
259
|
+
</Prose>
|
|
378
260
|
<Tooltip title="Click to copy link">
|
|
379
261
|
<LinkOutlinedIcon
|
|
380
262
|
sx={{
|
|
@@ -388,7 +270,9 @@ export function NotebookCell({
|
|
|
388
270
|
</Tooltip>
|
|
389
271
|
</Stack>
|
|
390
272
|
) : (
|
|
391
|
-
<
|
|
273
|
+
<Prose variant="document" links={links}>
|
|
274
|
+
{cell.text}
|
|
275
|
+
</Prose>
|
|
392
276
|
)}
|
|
393
277
|
<Snackbar
|
|
394
278
|
open={copyMessage !== ""}
|
|
@@ -397,10 +281,10 @@ export function NotebookCell({
|
|
|
397
281
|
message={copyMessage}
|
|
398
282
|
/>
|
|
399
283
|
</Box>
|
|
400
|
-
</
|
|
284
|
+
</Box>
|
|
401
285
|
)) ||
|
|
402
286
|
(cell.type === "code" && (
|
|
403
|
-
<
|
|
287
|
+
<Box>
|
|
404
288
|
{(!hideCodeCellIcon ||
|
|
405
289
|
(!hideEmbeddingIcon && cell.result) ||
|
|
406
290
|
(cell.newSources && cell.newSources.length > 0)) && (
|
|
@@ -442,33 +326,13 @@ export function NotebookCell({
|
|
|
442
326
|
/>
|
|
443
327
|
)}
|
|
444
328
|
{hasValidImport && (
|
|
445
|
-
<
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
"&:hover": {
|
|
449
|
-
backgroundColor:
|
|
450
|
-
"rgba(255, 255, 255, 1)",
|
|
451
|
-
},
|
|
452
|
-
width: "32px",
|
|
453
|
-
height: "32px",
|
|
454
|
-
flexShrink: 0,
|
|
455
|
-
}}
|
|
329
|
+
<FloatingIconButton
|
|
330
|
+
aria-label="Data sources"
|
|
331
|
+
sx={{ flexShrink: 0 }}
|
|
456
332
|
onClick={() => setSourcesDialogOpen(true)}
|
|
457
333
|
>
|
|
458
|
-
<SearchIcon
|
|
459
|
-
|
|
460
|
-
fontSize: "18px",
|
|
461
|
-
// grey.700 is a dark warm grey
|
|
462
|
-
// that stays legible on the
|
|
463
|
-
// white-ish IconButton in both
|
|
464
|
-
// light and dark mode. The
|
|
465
|
-
// button background is
|
|
466
|
-
// hardcoded white, so the icon
|
|
467
|
-
// must be hardcoded dark.
|
|
468
|
-
color: "grey.700",
|
|
469
|
-
}}
|
|
470
|
-
/>
|
|
471
|
-
</IconButton>
|
|
334
|
+
<SearchIcon />
|
|
335
|
+
</FloatingIconButton>
|
|
472
336
|
)}
|
|
473
337
|
</Box>
|
|
474
338
|
</CleanMetricCard>
|
|
@@ -670,7 +534,7 @@ export function NotebookCell({
|
|
|
670
534
|
>
|
|
671
535
|
<ResultContainer
|
|
672
536
|
result={cell.result}
|
|
673
|
-
maxHeight={
|
|
537
|
+
maxHeight={NOTEBOOK_CELL_MAX_HEIGHT}
|
|
674
538
|
maxResultSize={maxResultSize}
|
|
675
539
|
drill={drill}
|
|
676
540
|
/>
|
|
@@ -698,44 +562,26 @@ export function NotebookCell({
|
|
|
698
562
|
}}
|
|
699
563
|
>
|
|
700
564
|
{!hideCodeCellIcon && (
|
|
701
|
-
<
|
|
702
|
-
|
|
703
|
-
backgroundColor: "rgba(255, 255, 255, 0.9)",
|
|
704
|
-
"&:hover": {
|
|
705
|
-
backgroundColor: "rgba(255, 255, 255, 1)",
|
|
706
|
-
},
|
|
707
|
-
width: "32px",
|
|
708
|
-
height: "32px",
|
|
709
|
-
}}
|
|
565
|
+
<FloatingIconButton
|
|
566
|
+
aria-label="Malloy code"
|
|
710
567
|
onClick={(e) => {
|
|
711
568
|
e.stopPropagation();
|
|
712
569
|
setCodeDialogOpen(true);
|
|
713
570
|
}}
|
|
714
571
|
>
|
|
715
|
-
<CodeIcon
|
|
716
|
-
|
|
717
|
-
/>
|
|
718
|
-
</IconButton>
|
|
572
|
+
<CodeIcon />
|
|
573
|
+
</FloatingIconButton>
|
|
719
574
|
)}
|
|
720
|
-
<
|
|
721
|
-
|
|
722
|
-
backgroundColor: "rgba(255, 255, 255, 0.9)",
|
|
723
|
-
"&:hover": {
|
|
724
|
-
backgroundColor: "rgba(255, 255, 255, 1)",
|
|
725
|
-
},
|
|
726
|
-
width: "32px",
|
|
727
|
-
height: "32px",
|
|
728
|
-
}}
|
|
575
|
+
<FloatingIconButton
|
|
576
|
+
aria-label="Expand results"
|
|
729
577
|
onClick={() => setResultsDialogOpen(true)}
|
|
730
578
|
>
|
|
731
|
-
<SearchIcon
|
|
732
|
-
|
|
733
|
-
/>
|
|
734
|
-
</IconButton>
|
|
579
|
+
<SearchIcon />
|
|
580
|
+
</FloatingIconButton>
|
|
735
581
|
</Stack>
|
|
736
582
|
</CleanMetricCard>
|
|
737
583
|
)}
|
|
738
|
-
</
|
|
584
|
+
</Box>
|
|
739
585
|
))
|
|
740
586
|
);
|
|
741
587
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
5
|
+
import { describe, expect, it, mock } from "bun:test";
|
|
6
|
+
import { Prose } from "./Prose";
|
|
7
|
+
|
|
8
|
+
// Package content comes from untrusted git and S3 sources, so the one thing
|
|
9
|
+
// every surface that renders it has to agree on is what a link may do. These
|
|
10
|
+
// are that agreement, tested once against the one component that now renders
|
|
11
|
+
// prose everywhere; the notebook cell used to be the only surface that held
|
|
12
|
+
// to it.
|
|
13
|
+
|
|
14
|
+
describe("Prose: links", () => {
|
|
15
|
+
it("refuses a script-bearing href, keeping the text", () => {
|
|
16
|
+
render(
|
|
17
|
+
<Prose>
|
|
18
|
+
{"[run](javascript:alert(1)) and [d](data:text/html,x)"}
|
|
19
|
+
</Prose>,
|
|
20
|
+
);
|
|
21
|
+
expect(screen.getByText("run").getAttribute("href")).toBeNull();
|
|
22
|
+
expect(screen.getByText("d").getAttribute("href")).toBeNull();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("opens an external link in a new tab, disowning the opener", () => {
|
|
26
|
+
render(<Prose>{"[docs](https://example.com/docs)"}</Prose>);
|
|
27
|
+
const a = screen.getByText("docs");
|
|
28
|
+
expect(a.getAttribute("href")).toBe("https://example.com/docs");
|
|
29
|
+
expect(a.getAttribute("target")).toBe("_blank");
|
|
30
|
+
expect(a.getAttribute("rel")).toBe("noopener noreferrer");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("resolves a relative link against the source file, within the package", () => {
|
|
34
|
+
render(
|
|
35
|
+
<Prose
|
|
36
|
+
links={{
|
|
37
|
+
environmentName: "env",
|
|
38
|
+
packageName: "pkg",
|
|
39
|
+
sourcePath: "guides/intro.malloynb",
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
{"[next](../sales.malloynb) [up](../../../etc/passwd)"}
|
|
43
|
+
</Prose>,
|
|
44
|
+
);
|
|
45
|
+
expect(screen.getByText("next").getAttribute("href")).toBe(
|
|
46
|
+
"/env/pkg/sales.malloynb",
|
|
47
|
+
);
|
|
48
|
+
// An escape past the package root is clamped at it, never above.
|
|
49
|
+
expect(screen.getByText("up").getAttribute("href")).toBe(
|
|
50
|
+
"/env/pkg/etc/passwd",
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("routes a resolved link through the host when it can", () => {
|
|
55
|
+
const onNavigate = mock((_to: string) => undefined);
|
|
56
|
+
render(
|
|
57
|
+
<Prose
|
|
58
|
+
links={{ environmentName: "env", packageName: "pkg", onNavigate }}
|
|
59
|
+
>
|
|
60
|
+
{"[readme](README.md)"}
|
|
61
|
+
</Prose>,
|
|
62
|
+
);
|
|
63
|
+
fireEvent.click(screen.getByText("readme"));
|
|
64
|
+
expect(onNavigate).toHaveBeenCalledTimes(1);
|
|
65
|
+
expect(onNavigate.mock.calls[0][0]).toBe("/env/pkg/README.md");
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("leaves a relative link alone when it has no package to resolve against", () => {
|
|
69
|
+
render(<Prose>{"[here](./notes.md)"}</Prose>);
|
|
70
|
+
expect(screen.getByText("here").getAttribute("href")).toBe("./notes.md");
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe("Prose: variants", () => {
|
|
75
|
+
it("renders headings as headings in both, so structure survives", () => {
|
|
76
|
+
render(<Prose variant="document">{"# Title\n\nBody"}</Prose>);
|
|
77
|
+
expect(screen.getByRole("heading", { level: 1 }).textContent).toBe(
|
|
78
|
+
"Title",
|
|
79
|
+
);
|
|
80
|
+
render(<Prose variant="caption">{"## Section\n\nBody"}</Prose>);
|
|
81
|
+
expect(screen.getByRole("heading", { level: 2 }).textContent).toBe(
|
|
82
|
+
"Section",
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
});
|