@malloy-publisher/sdk 0.9.11 → 0.9.13
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 +5 -7
- package/dist/{RenderedResult-Cmx8sX8d.es.js → RenderedResult-DnBtf-cI.es.js} +2 -2
- package/dist/{RenderedResult-BlNoIiSi.cjs.js → RenderedResult-DtQtNV0d.cjs.js} +1 -1
- package/dist/ServerProvider-BIFPCzTD.cjs.js +1 -0
- package/dist/{ServerProvider-azXLkk1q.es.js → ServerProvider-BV7IoDMR.es.js} +808 -607
- package/dist/builder/index.cjs.js +72 -72
- package/dist/builder/index.es.js +4156 -4219
- package/dist/builder-entry.d.ts +1 -0
- package/dist/client/api.d.ts +224 -1
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +41 -37
- package/dist/components/Connections/common.d.ts +11 -3
- package/dist/components/Report/telemetry.d.ts +0 -5
- package/dist/components/ReportBuilder/BuilderBar.d.ts +1 -1
- package/dist/components/ReportBuilder/BuilderToolbar.d.ts +14 -10
- package/dist/components/ReportBuilder/EditorSurface.d.ts +1 -2
- package/dist/components/ReportBuilder/ReportBuilder.d.ts +3 -10
- package/dist/components/ReportBuilder/ReportEditor.d.ts +2 -9
- package/dist/components/ReportBuilder/SaveStatus.d.ts +16 -0
- package/dist/components/ReportBuilder/TileFrame.d.ts +9 -2
- package/dist/components/ReportBuilder/builderControls.d.ts +14 -6
- package/dist/components/ReportBuilder/useBuilderSession.d.ts +1 -1
- package/dist/components/ReportBuilder/useReportDraft.d.ts +6 -2
- package/dist/components/given/GivenInput.d.ts +18 -1
- package/dist/components/given/GivensPanel.d.ts +12 -1
- package/dist/components/given/useOptionSearch.d.ts +30 -0
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/useDocumentControls.d.ts +5 -0
- package/dist/hooks/useGivensState.d.ts +7 -0
- package/dist/hooks/useSuggestOptions.d.ts +60 -4
- package/dist/index.cjs.js +9 -9
- package/dist/index.es.js +2541 -2400
- package/dist/{useCompiledDocument-7j5cBjQd.es.js → useCompiledDocument-B4QF1mIl.es.js} +6912 -6759
- package/dist/useCompiledDocument-D0OAMejE.cjs.js +142 -0
- package/package.json +1 -1
- package/src/builder-entry.ts +1 -0
- package/src/components/Connections/AddConnectionDialog.tsx +34 -2
- package/src/components/Connections/EditConnectionDialog.tsx +45 -3
- package/src/components/Connections/common.spec.ts +69 -0
- package/src/components/Connections/common.ts +132 -0
- package/src/components/Environment/Connections.tsx +1 -0
- package/src/components/Report/ReportPage.tsx +5 -1
- package/src/components/Report/telemetry.ts +0 -6
- package/src/components/ReportBuilder/AddTileDialog.tsx +2 -2
- package/src/components/ReportBuilder/BuilderBar.tsx +5 -256
- package/src/components/ReportBuilder/BuilderHeader.tsx +9 -3
- package/src/components/ReportBuilder/BuilderToolbar.tsx +15 -38
- package/src/components/ReportBuilder/EditorSurface.tsx +0 -3
- package/src/components/ReportBuilder/FilterDialog.tsx +1 -1
- package/src/components/ReportBuilder/ReportBuilder.controls.spec.tsx +210 -24
- package/src/components/ReportBuilder/ReportBuilder.tsx +43 -85
- package/src/components/ReportBuilder/ReportEditor.package.spec.tsx +0 -36
- package/src/components/ReportBuilder/ReportEditor.tsx +2 -13
- package/src/components/ReportBuilder/SaveStatus.tsx +271 -0
- package/src/components/ReportBuilder/TileFrame.spec.ts +34 -0
- package/src/components/ReportBuilder/TileFrame.tsx +10 -3
- package/src/components/ReportBuilder/builderControls.ts +39 -13
- package/src/components/ReportBuilder/emptyStart.spec.ts +1 -1
- package/src/components/ReportBuilder/useReportDraft.ts +38 -4
- package/src/components/given/GivenInput.tsx +219 -104
- package/src/components/given/GivensPanel.spec.tsx +19 -0
- package/src/components/given/GivensPanel.tsx +31 -1
- package/src/components/given/useOptionSearch.spec.tsx +218 -0
- package/src/components/given/useOptionSearch.ts +100 -0
- package/src/hooks/index.ts +5 -1
- package/src/hooks/useDocumentControls.ts +12 -1
- package/src/hooks/useGivensState.spec.ts +54 -0
- package/src/hooks/useGivensState.ts +21 -1
- package/src/hooks/useSuggestOptions.dom.spec.ts +125 -4
- package/src/hooks/useSuggestOptions.spec.ts +73 -2
- package/src/hooks/useSuggestOptions.ts +234 -62
- package/dist/ServerProvider-BOgiW8MX.cjs.js +0 -1
- package/dist/useCompiledDocument-B21sVbb4.cjs.js +0 -141
- package/src/components/ReportBuilder/ReportBuilder.layoutSwitch.spec.tsx +0 -145
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Credible Data Inc.
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
|
|
4
|
-
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
|
5
|
-
import { describe, expect, it, mock } from "bun:test";
|
|
6
|
-
import type { ReportEvent } from "../Report/telemetry";
|
|
7
|
-
import { ReportBuilder } from "./ReportBuilder";
|
|
8
|
-
import { openDocument } from "./testing/fixtures";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* The layout switch: one editor for both layouts, and switching rewrites the
|
|
12
|
-
* tag's `layout=` and nothing else (docs/reports-design.md §2, §10).
|
|
13
|
-
*/
|
|
14
|
-
const LINEAR = `## artifact { layout=linear title="Storefront" tiles=["a -> by_cat", "a -> by_brand"] }
|
|
15
|
-
import "../data_app.malloy"
|
|
16
|
-
|
|
17
|
-
source: a is scoped_orders extend {
|
|
18
|
-
# label="By category"
|
|
19
|
-
view: by_cat is by_category
|
|
20
|
-
|
|
21
|
-
view: by_brand is by_brand_view
|
|
22
|
-
}`;
|
|
23
|
-
|
|
24
|
-
const GRID = `## artifact { layout=grid title="Storefront" tiles=["a -> by_cat", "a -> by_brand"] } dashboard { columns=12 }
|
|
25
|
-
import "../data_app.malloy"
|
|
26
|
-
|
|
27
|
-
source: a is scoped_orders extend {
|
|
28
|
-
# colspan=6
|
|
29
|
-
# label="By category"
|
|
30
|
-
view: by_cat is by_category
|
|
31
|
-
|
|
32
|
-
# colspan=6
|
|
33
|
-
view: by_brand is by_brand_view
|
|
34
|
-
}`;
|
|
35
|
-
|
|
36
|
-
const button = (name: string | RegExp) =>
|
|
37
|
-
screen.getByRole("button", { name, hidden: true });
|
|
38
|
-
|
|
39
|
-
const mount = async (
|
|
40
|
-
source: string,
|
|
41
|
-
onSave: (source: string) => Promise<void> | void,
|
|
42
|
-
textHeld = false,
|
|
43
|
-
) =>
|
|
44
|
-
render(
|
|
45
|
-
<ReportBuilder
|
|
46
|
-
source={source}
|
|
47
|
-
document={await openDocument(source)}
|
|
48
|
-
onSave={onSave}
|
|
49
|
-
{...(textHeld ? { visibleSources: ["scoped_orders"] } : {})}
|
|
50
|
-
/>,
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
describe("the layout switch", () => {
|
|
54
|
-
it("shows Linear and Grid for a file, the file's own layout pressed", async () => {
|
|
55
|
-
await mount(LINEAR, () => {});
|
|
56
|
-
expect(button("Linear layout").getAttribute("aria-pressed")).toBe("true");
|
|
57
|
-
expect(button("Grid layout").getAttribute("aria-pressed")).toBe("false");
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("is not offered when the host turns it off with allowLayoutChange={false}", async () => {
|
|
61
|
-
render(
|
|
62
|
-
<ReportBuilder
|
|
63
|
-
source={GRID}
|
|
64
|
-
document={await openDocument(GRID)}
|
|
65
|
-
onSave={() => {}}
|
|
66
|
-
allowLayoutChange={false}
|
|
67
|
-
/>,
|
|
68
|
-
);
|
|
69
|
-
expect(
|
|
70
|
-
screen.queryByRole("button", { name: "Grid layout", hidden: true }),
|
|
71
|
-
).toBeNull();
|
|
72
|
-
expect(
|
|
73
|
-
screen.queryByRole("button", { name: "Linear layout", hidden: true }),
|
|
74
|
-
).toBeNull();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it("is not offered for a document held as text, whose layout is the host's record", async () => {
|
|
78
|
-
await mount(LINEAR, () => {}, true);
|
|
79
|
-
expect(
|
|
80
|
-
screen.queryByRole("button", { name: "Grid layout", hidden: true }),
|
|
81
|
-
).toBeNull();
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("switches linear to grid by rewriting layout= and nothing else", async () => {
|
|
85
|
-
const onSave = mock((_source: string) => Promise.resolve());
|
|
86
|
-
await mount(LINEAR, onSave);
|
|
87
|
-
fireEvent.click(button("Grid layout"));
|
|
88
|
-
await waitFor(() =>
|
|
89
|
-
expect(button("Grid layout").getAttribute("aria-pressed")).toBe(
|
|
90
|
-
"true",
|
|
91
|
-
),
|
|
92
|
-
);
|
|
93
|
-
fireEvent.click(button("Save"));
|
|
94
|
-
await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
|
|
95
|
-
expect(onSave.mock.calls[0][0]).toBe(
|
|
96
|
-
LINEAR.replace("layout=linear", "layout=grid"),
|
|
97
|
-
);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// KNOWN BUG, not yet fixed in source: the switch sets only the document's
|
|
101
|
-
// kind, and the splice refuses a linear document whose `columns` is still
|
|
102
|
-
// set ("one column"), so a grid report with `dashboard { columns=N }`
|
|
103
|
-
// cannot be switched to linear. The design keeps the file's own
|
|
104
|
-
// `dashboard { columns=N }` and changes only `layout=`.
|
|
105
|
-
it("switches grid to linear by rewriting layout= and nothing else, keeping the file's width", async () => {
|
|
106
|
-
const onSave = mock((_source: string) => Promise.resolve());
|
|
107
|
-
await mount(GRID, onSave);
|
|
108
|
-
fireEvent.click(button("Linear layout"));
|
|
109
|
-
fireEvent.click(button("Save"));
|
|
110
|
-
await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
|
|
111
|
-
expect(onSave.mock.calls[0][0]).toBe(
|
|
112
|
-
GRID.replace("layout=grid", "layout=linear"),
|
|
113
|
-
);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it("reports a switch once, and the save after it under the new layout", async () => {
|
|
117
|
-
const onEvent = mock((_event: ReportEvent) => {});
|
|
118
|
-
render(
|
|
119
|
-
<ReportBuilder
|
|
120
|
-
source={LINEAR}
|
|
121
|
-
document={await openDocument(LINEAR)}
|
|
122
|
-
onSave={() => Promise.resolve()}
|
|
123
|
-
modelPath="store/front.malloy"
|
|
124
|
-
onEvent={onEvent}
|
|
125
|
-
/>,
|
|
126
|
-
);
|
|
127
|
-
fireEvent.click(button("Grid layout"));
|
|
128
|
-
// The layout already pressed is not a switch.
|
|
129
|
-
fireEvent.click(button("Grid layout"));
|
|
130
|
-
fireEvent.click(button("Save"));
|
|
131
|
-
await waitFor(() => expect(onEvent).toHaveBeenCalledTimes(2));
|
|
132
|
-
expect(onEvent.mock.calls[0][0]).toEqual({
|
|
133
|
-
type: "report.layout_changed",
|
|
134
|
-
path: "store/front.malloy",
|
|
135
|
-
layout: "grid",
|
|
136
|
-
from: "linear",
|
|
137
|
-
to: "grid",
|
|
138
|
-
});
|
|
139
|
-
expect(onEvent.mock.calls[1][0]).toMatchObject({
|
|
140
|
-
type: "report.saved",
|
|
141
|
-
path: "store/front.malloy",
|
|
142
|
-
layout: "grid",
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
});
|