@malloy-publisher/sdk 0.9.9 → 0.9.10
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-Bw7EQc42.cjs.js → RenderedResult-BcgYjkZ0.cjs.js} +1 -1
- package/dist/{RenderedResult-BHuJpdSn.es.js → RenderedResult-Dp1Qdajz.es.js} +1 -1
- package/dist/builder/index.cjs.js +61 -61
- package/dist/builder/index.es.js +782 -793
- package/dist/components/Dashboard/DashboardView.d.ts +11 -0
- package/dist/components/Dashboard/useStuck.d.ts +14 -0
- package/dist/components/DocumentCreate/newNotebook.d.ts +9 -5
- package/dist/components/ReportBuilder/FilterStrip.d.ts +3 -1
- package/dist/components/ReportBuilder/TileMenu.d.ts +7 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +3 -3
- package/dist/{useCompiledDocument-1dgF5CC9.es.js → useCompiledDocument-BMPDvdFx.es.js} +2348 -2310
- package/dist/{useCompiledDocument-BKyRnXmA.cjs.js → useCompiledDocument-UY28ITET.cjs.js} +34 -34
- package/package.json +1 -1
- package/src/components/Dashboard/DashboardView.tsx +62 -13
- package/src/components/Dashboard/useStuck.ts +38 -0
- package/src/components/DocumentCreate/newNotebook.spec.ts +8 -6
- package/src/components/DocumentCreate/newNotebook.ts +26 -12
- package/src/components/ReportBuilder/BuilderDialogs.tsx +5 -3
- package/src/components/ReportBuilder/BuilderGrid.tsx +13 -3
- package/src/components/ReportBuilder/FilterStrip.tsx +118 -118
- package/src/components/ReportBuilder/ReportBuilder.inline.spec.tsx +0 -1
- package/src/components/ReportBuilder/ReportBuilder.spec.tsx +5 -6
- package/src/components/ReportBuilder/ReportBuilder.tsx +1 -0
- package/src/components/ReportBuilder/TileMenu.tsx +8 -3
- package/src/components/ReportBuilder/newDashboard.spec.ts +2 -3
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
import { Alert, Box, Stack, Typography } from "@mui/material";
|
|
5
|
-
import { useCallback, useMemo, useState } from "react";
|
|
5
|
+
import { useCallback, useMemo, useState, type ReactNode } from "react";
|
|
6
6
|
import type { DashboardManifest } from "../../client";
|
|
7
7
|
import type { HostGivenValue } from "../../hooks/givenValue";
|
|
8
8
|
import { useDocumentControls } from "../../hooks/useDocumentControls";
|
|
@@ -16,6 +16,8 @@ import {
|
|
|
16
16
|
import { GivensPanel, type GivensLayout } from "../given";
|
|
17
17
|
import { givensToRequest, withHostGivens } from "../given/paramCodec";
|
|
18
18
|
import { Prose } from "../Prose";
|
|
19
|
+
import { MOTION_FAST, reducedMotionSx } from "../../theme/motion";
|
|
20
|
+
import { usePublisherTheme } from "../../theme/ThemeContext";
|
|
19
21
|
import { TILE_MAX_HEIGHT } from "../RenderedResult/resultSizing";
|
|
20
22
|
import {
|
|
21
23
|
DashboardGrid,
|
|
@@ -29,6 +31,7 @@ import { RowsDialog, stepsOf, type RowsRequest } from "./RowsDialog";
|
|
|
29
31
|
import { useReportEvents } from "../Report/telemetry";
|
|
30
32
|
import { TileCard, type TileChrome } from "./TileCard";
|
|
31
33
|
import { tileIgnoredFilterLabels } from "./TileFilterTag";
|
|
34
|
+
import { useStuck } from "./useStuck";
|
|
32
35
|
|
|
33
36
|
/** Narrowest a tile that sets no `colspan` is allowed to render. */
|
|
34
37
|
const MIN_TILE_PX = 240;
|
|
@@ -231,20 +234,16 @@ export function DashboardView({
|
|
|
231
234
|
<DashboardHeader manifest={manifest} chrome={chrome} />
|
|
232
235
|
)}
|
|
233
236
|
|
|
234
|
-
{/* Sticky so the controls stay in reach while the tiles scroll under
|
|
235
|
-
|
|
236
|
-
|
|
237
|
+
{/* Sticky so the controls stay in reach while the tiles scroll under,
|
|
238
|
+
in a grid only: a linear report's controls are a full panel, and
|
|
239
|
+
pinned they would take a third of a laptop screen from the prose
|
|
240
|
+
they sit above. Only when there are controls: GivensPanel draws
|
|
241
|
+
nothing without them, and an empty box would still cost the Stack
|
|
242
|
+
a gap. */}
|
|
237
243
|
{specs.length > 0 && (
|
|
238
|
-
<
|
|
239
|
-
sx={{
|
|
240
|
-
position: "sticky",
|
|
241
|
-
top: 0,
|
|
242
|
-
zIndex: STICKY_CONTROLS_Z,
|
|
243
|
-
bgcolor: "background.default",
|
|
244
|
-
}}
|
|
245
|
-
>
|
|
244
|
+
<StickyControls sticky={chrome === "card"}>
|
|
246
245
|
<GivensPanel {...controls.panel} layout={controlsLayout} />
|
|
247
|
-
</
|
|
246
|
+
</StickyControls>
|
|
248
247
|
)}
|
|
249
248
|
|
|
250
249
|
{modelPath === undefined ? (
|
|
@@ -410,3 +409,53 @@ export function DashboardProse({
|
|
|
410
409
|
</Stack>
|
|
411
410
|
);
|
|
412
411
|
}
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* A control row that pins to the top of the scroller and, while pinned, draws
|
|
415
|
+
* a hairline under itself, so tiles scrolling beneath read as passing under a
|
|
416
|
+
* bar rather than being cut off by nothing. Shared by the reader and the
|
|
417
|
+
* builder so both pin the same way.
|
|
418
|
+
*/
|
|
419
|
+
export function StickyControls({
|
|
420
|
+
sticky = true,
|
|
421
|
+
children,
|
|
422
|
+
}: {
|
|
423
|
+
sticky?: boolean;
|
|
424
|
+
children: ReactNode;
|
|
425
|
+
}) {
|
|
426
|
+
const { theme } = usePublisherTheme();
|
|
427
|
+
const { sentinelRef, stuck } = useStuck();
|
|
428
|
+
if (!sticky) return <Box>{children}</Box>;
|
|
429
|
+
const edge = theme.cardBorder.replace(/^1px solid /, "");
|
|
430
|
+
return (
|
|
431
|
+
<>
|
|
432
|
+
{/* The sentinel the pin is detected from; it costs the parent Stack
|
|
433
|
+
no gap, since it is a zero-height sibling and Stack gaps are on
|
|
434
|
+
the bar's own margin. */}
|
|
435
|
+
<Box
|
|
436
|
+
ref={sentinelRef}
|
|
437
|
+
aria-hidden
|
|
438
|
+
sx={{ height: 0, m: "0 !important" }}
|
|
439
|
+
/>
|
|
440
|
+
<Box
|
|
441
|
+
data-stuck={stuck || undefined}
|
|
442
|
+
sx={{
|
|
443
|
+
position: "sticky",
|
|
444
|
+
top: 0,
|
|
445
|
+
zIndex: STICKY_CONTROLS_Z,
|
|
446
|
+
bgcolor: "background.default",
|
|
447
|
+
// Room under the bar for the edge, so the line never sits on
|
|
448
|
+
// the controls themselves.
|
|
449
|
+
pb: 1,
|
|
450
|
+
// A shadow rather than a border: drawing the edge must not
|
|
451
|
+
// change the bar's height, or the page jumps as it pins.
|
|
452
|
+
boxShadow: stuck ? `0 1px 0 ${edge}` : "none",
|
|
453
|
+
transition: `box-shadow ${MOTION_FAST}`,
|
|
454
|
+
...reducedMotionSx,
|
|
455
|
+
}}
|
|
456
|
+
>
|
|
457
|
+
{children}
|
|
458
|
+
</Box>
|
|
459
|
+
</>
|
|
460
|
+
);
|
|
461
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { useCallback, useRef, useState } from "react";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Whether a `position: sticky` bar is currently pinned, so it can draw an edge
|
|
8
|
+
* only while content scrolls under it. Unpinned, the bar sits in the flow and
|
|
9
|
+
* an edge would be a stray line between it and the first tile.
|
|
10
|
+
*
|
|
11
|
+
* Watches a zero-height sentinel placed directly before the bar: once the
|
|
12
|
+
* sentinel has scrolled out through the top, the bar is pinned. No explicit
|
|
13
|
+
* root, so it works whichever ancestor scrolls — an observer with the implicit
|
|
14
|
+
* root counts clipping by every scrolling ancestor, not just the viewport.
|
|
15
|
+
*/
|
|
16
|
+
export function useStuck(): {
|
|
17
|
+
sentinelRef: (node: HTMLElement | null) => void;
|
|
18
|
+
stuck: boolean;
|
|
19
|
+
} {
|
|
20
|
+
const [stuck, setStuck] = useState(false);
|
|
21
|
+
const observer = useRef<IntersectionObserver | null>(null);
|
|
22
|
+
const sentinelRef = useCallback((node: HTMLElement | null) => {
|
|
23
|
+
observer.current?.disconnect();
|
|
24
|
+
observer.current = null;
|
|
25
|
+
if (!node || typeof IntersectionObserver === "undefined") return;
|
|
26
|
+
observer.current = new IntersectionObserver(([entry]) => {
|
|
27
|
+
if (!entry) return;
|
|
28
|
+
// Out of view BELOW the fold is not pinned: only out through the top.
|
|
29
|
+
setStuck(
|
|
30
|
+
!entry.isIntersecting &&
|
|
31
|
+
entry.boundingClientRect.top <
|
|
32
|
+
(entry.rootBounds?.height ?? window.innerHeight) / 2,
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
observer.current.observe(node);
|
|
36
|
+
}, []);
|
|
37
|
+
return { sentinelRef, stuck };
|
|
38
|
+
}
|
|
@@ -35,7 +35,7 @@ describe("newNotebookSource", () => {
|
|
|
35
35
|
expect(lintNotebookText("notebooks/q3.malloy", text)).toEqual([]);
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
it("reads back as a layout notebook:
|
|
38
|
+
it("reads back as a layout notebook: one labelled query tile, no text tile, and no run cell", async () => {
|
|
39
39
|
const text = newNotebookSource(INPUT);
|
|
40
40
|
const result = await readDashboardDocument(text);
|
|
41
41
|
if (readFailed(result)) throw new Error(result.reason);
|
|
@@ -43,9 +43,11 @@ describe("newNotebookSource", () => {
|
|
|
43
43
|
expect(document.layout).toBe("linear");
|
|
44
44
|
expect(
|
|
45
45
|
document.tiles.map((t) => (isTextTile(t) ? "text" : "query")),
|
|
46
|
-
).toEqual(["
|
|
46
|
+
).toEqual(["query"]);
|
|
47
47
|
const query = document.tiles.find(isQueryTile);
|
|
48
48
|
expect(query?.name).toBe("by_category_tile");
|
|
49
|
+
// Titled for the view it shows, not the extension's `_tile` name.
|
|
50
|
+
expect(query?.label).toBe("By category");
|
|
49
51
|
expect(text).toContain(
|
|
50
52
|
"source: order_items_tiles is order_items extend {",
|
|
51
53
|
);
|
|
@@ -54,7 +56,7 @@ describe("newNotebookSource", () => {
|
|
|
54
56
|
|
|
55
57
|
it("writes the artifact tag as a block with a tile on each line, named for its view", () => {
|
|
56
58
|
expect(newNotebookSource(INPUT)).toContain(
|
|
57
|
-
'##| artifact { layout=linear title="Sales \\"West\\""\n tiles=[\n
|
|
59
|
+
'##| artifact { layout=linear title="Sales \\"West\\""\n tiles=[\n "order_items_tiles -> by_category_tile"\n ]\n}\n|##\n',
|
|
58
60
|
);
|
|
59
61
|
});
|
|
60
62
|
|
|
@@ -118,7 +120,7 @@ describe("newReportSource", () => {
|
|
|
118
120
|
expect(grid.document.columns).toBe(12);
|
|
119
121
|
expect(
|
|
120
122
|
grid.document.tiles.map((t) => (isTextTile(t) ? "text" : "query")),
|
|
121
|
-
).toEqual(["
|
|
123
|
+
).toEqual(["query"]);
|
|
122
124
|
const linear = await readDashboardDocument(
|
|
123
125
|
newReportSource(INPUT, "linear"),
|
|
124
126
|
);
|
|
@@ -163,10 +165,10 @@ describe("newDocumentProblem", () => {
|
|
|
163
165
|
expect(newDocumentProblem({ ...INPUT, source: "date" })).toBeUndefined();
|
|
164
166
|
});
|
|
165
167
|
|
|
166
|
-
it("trims the title once
|
|
168
|
+
it("trims the title, and writes it once: in the tag, not again as a heading", () => {
|
|
167
169
|
const text = newNotebookSource({ ...INPUT, title: " Q3 " });
|
|
168
170
|
expect(text).toContain('title="Q3"');
|
|
169
|
-
expect(text).toContain("# Q3\n");
|
|
171
|
+
expect(text).not.toContain("# Q3\n");
|
|
170
172
|
});
|
|
171
173
|
|
|
172
174
|
it("refuses names that cannot be written", () => {
|
|
@@ -5,16 +5,34 @@ import { importPathOf } from "../ReportBuilder/imports";
|
|
|
5
5
|
import type { ReportLayout } from "../Package/documentLocation";
|
|
6
6
|
import { malloyName, newDocumentProblem, type NewDocument } from "./guards";
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* `top_products` → `Top products`: the title a tile derives from a view name.
|
|
10
|
+
* Restated rather than imported from `drill/resolveDrill`, which would pull
|
|
11
|
+
* the filter parser into the create entry this module ships in.
|
|
12
|
+
*/
|
|
13
|
+
const titleOf = (name: string) => {
|
|
14
|
+
const words = name.replace(/[-_]+/g, " ").trim();
|
|
15
|
+
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** A Malloy tag string. */
|
|
19
|
+
const quote = (text: string) =>
|
|
20
|
+
`"${text.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
21
|
+
|
|
8
22
|
/** Where a new report goes when nobody says otherwise: the package root. */
|
|
9
23
|
const ROOT_REPORT_PATH = "report.malloy";
|
|
10
24
|
|
|
11
25
|
/**
|
|
12
26
|
* A new report file, in the format the builder writes: the givens flag, the
|
|
13
|
-
* artifact tag (a block, a tile per line) listing
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
27
|
+
* artifact tag (a block, a tile per line) listing one query tile, a named
|
|
28
|
+
* import of the one source it runs (written relative to where the report
|
|
29
|
+
* sits, so a report at the root imports `"<model>"`), and one extension of the
|
|
30
|
+
* source (`<source>_tiles`, the builder's naming) holding the picked view as
|
|
31
|
+
* the query tile, labelled with the view's own title.
|
|
32
|
+
*
|
|
33
|
+
* No intro text tile: the page already shows the title, and offers the
|
|
34
|
+
* description in place, so a generated `# <title>` and a line asking for a
|
|
35
|
+
* description said both twice on the first screen of every new report.
|
|
18
36
|
*
|
|
19
37
|
* The two layouts differ only in `layout=` and the grid tag a grid carries.
|
|
20
38
|
* `layout=` is always written, so the file never depends on the reading rule.
|
|
@@ -29,7 +47,7 @@ export function newReportSource(
|
|
|
29
47
|
if (problem) throw new Error(problem);
|
|
30
48
|
const { modelPath, source, view } = input;
|
|
31
49
|
const title = input.title.trim();
|
|
32
|
-
const quoted =
|
|
50
|
+
const quoted = quote(title);
|
|
33
51
|
const extension = malloyName(`${source}_tiles`);
|
|
34
52
|
const tile = malloyName(`${view}_tile`);
|
|
35
53
|
// The entry is a quoted string, so a back-quoted extension name is written inside it as is.
|
|
@@ -38,19 +56,15 @@ export function newReportSource(
|
|
|
38
56
|
"##! experimental.givens",
|
|
39
57
|
`##| artifact { layout=${layout} title=${quoted}`,
|
|
40
58
|
" tiles=[",
|
|
41
|
-
" intro { kind=text },",
|
|
42
59
|
` ${entry}`,
|
|
43
60
|
" ]",
|
|
44
61
|
layout === "grid" ? "} dashboard { columns=12 }" : "}",
|
|
45
62
|
"|##",
|
|
46
63
|
`import { ${malloyName(source)} } from "${importPathOf(modelPath, reportPath)}"`,
|
|
47
64
|
"",
|
|
48
|
-
"##|(markdown) intro",
|
|
49
|
-
`# ${title}`,
|
|
50
|
-
"Say what this report is for, then let the queries below answer it.",
|
|
51
|
-
"|##",
|
|
52
|
-
"",
|
|
53
65
|
`source: ${extension} is ${malloyName(source)} extend {`,
|
|
66
|
+
// The view's title, not the extension's `<view>_tile` name humanized.
|
|
67
|
+
` # label=${quote(titleOf(view))}`,
|
|
54
68
|
` view: ${tile} is ${malloyName(view)}`,
|
|
55
69
|
"}",
|
|
56
70
|
"",
|
|
@@ -104,9 +104,11 @@ export function BuilderDialogs({
|
|
|
104
104
|
}
|
|
105
105
|
: {})}
|
|
106
106
|
view={menuView}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
{...((editor.document.sources.find(
|
|
108
|
+
(s) => s.name === menuTile?.source,
|
|
109
|
+
)?.dimensions?.length ?? 0) > 0
|
|
110
|
+
? { onDrills: () => setDrillSource(menuTile?.source) }
|
|
111
|
+
: {})}
|
|
110
112
|
/>
|
|
111
113
|
<DrillDialog
|
|
112
114
|
open={drillSource !== undefined}
|
|
@@ -87,9 +87,14 @@ export function BuilderGrid({
|
|
|
87
87
|
)
|
|
88
88
|
: (preview ?? editor.document.tiles);
|
|
89
89
|
// And, while a drag is live, the empty end of every row as a drop target.
|
|
90
|
-
//
|
|
90
|
+
// While an edge is dragged too: narrowing a tile frees columns its row-mate
|
|
91
|
+
// does not take, and an undrawn hole there read as a broken layout rather
|
|
92
|
+
// than room to fill. Not otherwise: a gap is only shown mid-gesture.
|
|
91
93
|
const empty = editor.document.tiles.length === 0;
|
|
92
|
-
const entries =
|
|
94
|
+
const entries =
|
|
95
|
+
dragging || resize !== undefined
|
|
96
|
+
? withGaps(shown, columns)
|
|
97
|
+
: shown.map(tileEntry);
|
|
93
98
|
const heading = (tile: QueryTile) =>
|
|
94
99
|
headingOf(tile, tileDisplayTitle(tile), editTile);
|
|
95
100
|
return (
|
|
@@ -126,7 +131,12 @@ export function BuilderGrid({
|
|
|
126
131
|
flash={tileKey(each) === flash}
|
|
127
132
|
menuOpen={menuIndex === index}
|
|
128
133
|
bare={chrome === "none"}
|
|
129
|
-
|
|
134
|
+
// Not on the last tile: the "Add tile" under the
|
|
135
|
+
// list adds there already, and the two drew on top
|
|
136
|
+
// of each other.
|
|
137
|
+
{...(notebook &&
|
|
138
|
+
canAdd &&
|
|
139
|
+
index < editor.document.tiles.length - 1
|
|
130
140
|
? {
|
|
131
141
|
onInsertAfter: () => openAdd(index + 1),
|
|
132
142
|
}
|
|
@@ -7,7 +7,7 @@ import FilterListIcon from "@mui/icons-material/FilterList";
|
|
|
7
7
|
import { Chip, Stack, Tooltip, Typography } from "@mui/material";
|
|
8
8
|
import type { ReactNode } from "react";
|
|
9
9
|
import { MOTION_FAST, reducedMotionSx } from "../../theme/motion";
|
|
10
|
-
import {
|
|
10
|
+
import { StickyControls } from "../Dashboard/DashboardView";
|
|
11
11
|
import { usePublisherTheme } from "../../theme/ThemeContext";
|
|
12
12
|
import type { BuilderControl } from "./controls";
|
|
13
13
|
|
|
@@ -24,6 +24,7 @@ export function FilterStrip({
|
|
|
24
24
|
onAdd,
|
|
25
25
|
addDisabledReason,
|
|
26
26
|
onRemove,
|
|
27
|
+
sticky = true,
|
|
27
28
|
children,
|
|
28
29
|
}: {
|
|
29
30
|
controls: BuilderControl[];
|
|
@@ -36,6 +37,8 @@ export function FilterStrip({
|
|
|
36
37
|
addDisabledReason?: string;
|
|
37
38
|
/** Take a control off the dashboard, as its window's Remove does. */
|
|
38
39
|
onRemove: (name: string) => void;
|
|
40
|
+
/** Pin the strip to the top of the scroller: a grid's, not a linear report's. */
|
|
41
|
+
sticky?: boolean;
|
|
39
42
|
/** The host's live control row. */
|
|
40
43
|
children?: ReactNode;
|
|
41
44
|
}) {
|
|
@@ -48,139 +51,136 @@ export function FilterStrip({
|
|
|
48
51
|
Remove does. The live control row the caller
|
|
49
52
|
passes in sits directly under, showing the same controls as a
|
|
50
53
|
reader gets them — from the saved file. */}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// Pinned at the top of the scroller, so the controls stay in
|
|
56
|
-
// reach on a long page.
|
|
57
|
-
top: 0,
|
|
58
|
-
// The page's ground, as the reader's sticky control row uses:
|
|
59
|
-
// this bar is page chrome, not the chart canvas.
|
|
60
|
-
zIndex: STICKY_CONTROLS_Z,
|
|
61
|
-
bgcolor: "background.default",
|
|
62
|
-
pb: 1,
|
|
63
|
-
}}
|
|
64
|
-
>
|
|
65
|
-
<Stack
|
|
66
|
-
direction="row"
|
|
67
|
-
sx={{ gap: 2, alignItems: "center", minHeight: 32 }}
|
|
68
|
-
>
|
|
54
|
+
{/* Pinned the way the reader's control row is, and only where the
|
|
55
|
+
reader pins it: in a grid. */}
|
|
56
|
+
<StickyControls sticky={sticky}>
|
|
57
|
+
<Stack sx={{ gap: 1 }}>
|
|
69
58
|
<Stack
|
|
70
59
|
direction="row"
|
|
71
|
-
|
|
72
|
-
role="group"
|
|
73
|
-
aria-label="Filters"
|
|
74
|
-
sx={{
|
|
75
|
-
gap: 1,
|
|
76
|
-
alignItems: "center",
|
|
77
|
-
flexWrap: "wrap",
|
|
78
|
-
flex: 1,
|
|
79
|
-
minWidth: 0,
|
|
80
|
-
}}
|
|
60
|
+
sx={{ gap: 2, alignItems: "center", minHeight: 32 }}
|
|
81
61
|
>
|
|
82
|
-
<
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
sx={{
|
|
62
|
+
<Stack
|
|
63
|
+
direction="row"
|
|
64
|
+
// A named group, so the label is announced.
|
|
65
|
+
role="group"
|
|
66
|
+
aria-label="Filters"
|
|
67
|
+
sx={{
|
|
68
|
+
gap: 1,
|
|
69
|
+
alignItems: "center",
|
|
70
|
+
flexWrap: "wrap",
|
|
71
|
+
flex: 1,
|
|
72
|
+
minWidth: 0,
|
|
73
|
+
}}
|
|
88
74
|
>
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
75
|
+
<FilterListIcon
|
|
76
|
+
sx={{
|
|
77
|
+
fontSize: 18,
|
|
78
|
+
color: theme.tileTitle,
|
|
79
|
+
opacity: 0.7,
|
|
80
|
+
}}
|
|
81
|
+
/>
|
|
92
82
|
<Typography
|
|
93
|
-
variant="
|
|
94
|
-
sx={{ color: theme.tileTitle,
|
|
83
|
+
variant="subtitle2"
|
|
84
|
+
sx={{ color: theme.tileTitle, mr: 0.5 }}
|
|
95
85
|
>
|
|
96
|
-
|
|
86
|
+
Filters
|
|
97
87
|
</Typography>
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
control.type,
|
|
103
|
-
);
|
|
104
|
-
return (
|
|
105
|
-
<Tooltip
|
|
106
|
-
key={control.name}
|
|
107
|
-
title={
|
|
108
|
-
unknown.length > 0
|
|
109
|
-
? `$${control.name} · cannot filter on: ${unknown.join(", ")}`
|
|
110
|
-
: `$${control.name} · ${
|
|
111
|
-
control.origin === "dashboard"
|
|
112
|
-
? "declared here"
|
|
113
|
-
: "from the model"
|
|
114
|
-
} · ${control.boundTiles} of ${tileCount} tiles`
|
|
115
|
-
}
|
|
88
|
+
{controlList.length === 0 && (
|
|
89
|
+
<Typography
|
|
90
|
+
variant="body2"
|
|
91
|
+
sx={{ color: theme.tileTitle, opacity: 0.8 }}
|
|
116
92
|
>
|
|
93
|
+
None yet.
|
|
94
|
+
</Typography>
|
|
95
|
+
)}
|
|
96
|
+
{controlList.map((control) => {
|
|
97
|
+
const unknown = unknownFieldsOf(
|
|
98
|
+
control.name,
|
|
99
|
+
control.type,
|
|
100
|
+
);
|
|
101
|
+
return (
|
|
102
|
+
<Tooltip
|
|
103
|
+
key={control.name}
|
|
104
|
+
title={
|
|
105
|
+
unknown.length > 0
|
|
106
|
+
? `$${control.name} · cannot filter on: ${unknown.join(", ")}`
|
|
107
|
+
: `$${control.name} · ${
|
|
108
|
+
control.origin === "dashboard"
|
|
109
|
+
? "declared here"
|
|
110
|
+
: "from the model"
|
|
111
|
+
} · ${control.boundTiles} of ${tileCount} tiles`
|
|
112
|
+
}
|
|
113
|
+
>
|
|
114
|
+
<Chip
|
|
115
|
+
size="small"
|
|
116
|
+
// Unused says so in words, not only by fading:
|
|
117
|
+
// the state survives colour and touch.
|
|
118
|
+
label={`${control.label ?? control.name}${control.boundTiles === 0 ? " · unused" : ""}`}
|
|
119
|
+
aria-label={`Edit filter ${control.name}`}
|
|
120
|
+
// Warning where a binding names a field the source
|
|
121
|
+
// does not have: the package would refuse the file.
|
|
122
|
+
color={
|
|
123
|
+
unknown.length > 0 ? "warning" : "default"
|
|
124
|
+
}
|
|
125
|
+
variant={
|
|
126
|
+
control.origin === "dashboard"
|
|
127
|
+
? "filled"
|
|
128
|
+
: "outlined"
|
|
129
|
+
}
|
|
130
|
+
onClick={() => onEdit(control)}
|
|
131
|
+
onDelete={() => onRemove(control.name)}
|
|
132
|
+
deleteIcon={
|
|
133
|
+
<CancelIcon
|
|
134
|
+
aria-label={`Remove filter ${control.name}`}
|
|
135
|
+
/>
|
|
136
|
+
}
|
|
137
|
+
sx={{
|
|
138
|
+
// Faint when nothing binds it: declared, but not yet a
|
|
139
|
+
// control a reader would see.
|
|
140
|
+
opacity: control.boundTiles === 0 ? 0.6 : 1,
|
|
141
|
+
cursor: "pointer",
|
|
142
|
+
transition: `opacity ${MOTION_FAST}`,
|
|
143
|
+
...reducedMotionSx,
|
|
144
|
+
}}
|
|
145
|
+
/>
|
|
146
|
+
</Tooltip>
|
|
147
|
+
);
|
|
148
|
+
})}
|
|
149
|
+
{/* Beside the chips and shaped like one, as the next filter
|
|
150
|
+
would be: outlined where they are filled, so it reads as the
|
|
151
|
+
empty slot rather than another filter. */}
|
|
152
|
+
{/* A disabled button takes no pointer events, so the tooltip
|
|
153
|
+
saying why sits on a wrapper. */}
|
|
154
|
+
<Tooltip title={addDisabledReason ?? ""}>
|
|
155
|
+
<span>
|
|
117
156
|
<Chip
|
|
157
|
+
component="button"
|
|
118
158
|
size="small"
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
label=
|
|
122
|
-
aria-label=
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
variant={
|
|
127
|
-
control.origin === "dashboard"
|
|
128
|
-
? "filled"
|
|
129
|
-
: "outlined"
|
|
130
|
-
}
|
|
131
|
-
onClick={() => onEdit(control)}
|
|
132
|
-
onDelete={() => onRemove(control.name)}
|
|
133
|
-
deleteIcon={
|
|
134
|
-
<CancelIcon
|
|
135
|
-
aria-label={`Remove filter ${control.name}`}
|
|
136
|
-
/>
|
|
137
|
-
}
|
|
159
|
+
variant="outlined"
|
|
160
|
+
icon={<AddIcon />}
|
|
161
|
+
label="Filter"
|
|
162
|
+
aria-label="Add filter"
|
|
163
|
+
aria-haspopup="dialog"
|
|
164
|
+
disabled={addDisabledReason !== undefined}
|
|
165
|
+
onClick={() => onAdd()}
|
|
138
166
|
sx={{
|
|
139
|
-
// Faint when nothing binds it: declared, but not yet a
|
|
140
|
-
// control a reader would see.
|
|
141
|
-
opacity: control.boundTiles === 0 ? 0.6 : 1,
|
|
142
167
|
cursor: "pointer",
|
|
143
|
-
|
|
144
|
-
|
|
168
|
+
color: theme.tileTitle,
|
|
169
|
+
borderStyle: "dashed",
|
|
170
|
+
"& .MuiChip-icon": {
|
|
171
|
+
color: "inherit",
|
|
172
|
+
fontSize: 16,
|
|
173
|
+
},
|
|
145
174
|
}}
|
|
146
175
|
/>
|
|
147
|
-
</
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
{/* Beside the chips and shaped like one, as the next filter
|
|
151
|
-
would be: outlined where they are filled, so it reads as the
|
|
152
|
-
empty slot rather than another filter. */}
|
|
153
|
-
{/* A disabled button takes no pointer events, so the tooltip
|
|
154
|
-
saying why sits on a wrapper. */}
|
|
155
|
-
<Tooltip title={addDisabledReason ?? ""}>
|
|
156
|
-
<span>
|
|
157
|
-
<Chip
|
|
158
|
-
component="button"
|
|
159
|
-
size="small"
|
|
160
|
-
variant="outlined"
|
|
161
|
-
icon={<AddIcon />}
|
|
162
|
-
label="Filter"
|
|
163
|
-
aria-label="Add filter"
|
|
164
|
-
aria-haspopup="dialog"
|
|
165
|
-
disabled={addDisabledReason !== undefined}
|
|
166
|
-
onClick={() => onAdd()}
|
|
167
|
-
sx={{
|
|
168
|
-
cursor: "pointer",
|
|
169
|
-
color: theme.tileTitle,
|
|
170
|
-
borderStyle: "dashed",
|
|
171
|
-
"& .MuiChip-icon": {
|
|
172
|
-
color: "inherit",
|
|
173
|
-
fontSize: 16,
|
|
174
|
-
},
|
|
175
|
-
}}
|
|
176
|
-
/>
|
|
177
|
-
</span>
|
|
178
|
-
</Tooltip>
|
|
176
|
+
</span>
|
|
177
|
+
</Tooltip>
|
|
178
|
+
</Stack>
|
|
179
179
|
</Stack>
|
|
180
|
-
</Stack>
|
|
181
180
|
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
{children}
|
|
182
|
+
</Stack>
|
|
183
|
+
</StickyControls>
|
|
184
184
|
</>
|
|
185
185
|
);
|
|
186
186
|
}
|
|
@@ -187,7 +187,6 @@ describe("click-to-edit text", () => {
|
|
|
187
187
|
fireEvent.click(screen.getByLabelText("Settings for By category"));
|
|
188
188
|
expect(screen.queryByLabelText("Tile title")).toBeNull();
|
|
189
189
|
expect(screen.queryByLabelText("Tile subtitle")).toBeNull();
|
|
190
|
-
expect(button("Drill")).toBeDefined();
|
|
191
190
|
fireEvent.keyDown(button("Delete"), { key: "Escape" });
|
|
192
191
|
// There is no page settings window at all: the title and description
|
|
193
192
|
// are edited on the page.
|
|
@@ -734,14 +734,13 @@ source: a is scoped_orders extend {
|
|
|
734
734
|
);
|
|
735
735
|
});
|
|
736
736
|
|
|
737
|
-
it("
|
|
737
|
+
it("offers no Drill when the source declares no dimension here", async () => {
|
|
738
|
+
// A window whose only content is why its Apply is off is a dead end;
|
|
739
|
+
// the menu leaves the entry out instead.
|
|
738
740
|
await mount();
|
|
739
741
|
fireEvent.click(screen.getByLabelText("Settings for By category"));
|
|
740
|
-
|
|
741
|
-
expect(
|
|
742
|
-
screen.getByText(/declares no dimensions of its own/),
|
|
743
|
-
).toBeDefined();
|
|
744
|
-
expect(button("Apply").hasAttribute("disabled")).toBe(true);
|
|
742
|
+
expect(screen.queryByRole("button", { name: "Drill" })).toBeNull();
|
|
743
|
+
expect(button("Delete")).toBeDefined();
|
|
745
744
|
});
|
|
746
745
|
});
|
|
747
746
|
|