@malloy-publisher/sdk 0.9.10 → 0.9.12
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-Dp1Qdajz.es.js → RenderedResult-CDiXJAh9.es.js} +102 -102
- package/dist/RenderedResult-De51QvsZ.cjs.js +153 -0
- package/dist/ServerProvider-DKrBcXL7.cjs.js +1 -0
- package/dist/{ServerProvider-CQy4jVYK.es.js → ServerProvider-RvKSbvnL.es.js} +622 -587
- package/dist/builder/index.cjs.js +78 -130
- package/dist/builder/index.es.js +7493 -6769
- package/dist/builder-entry.d.ts +3 -0
- package/dist/client/api.d.ts +72 -23
- 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/Connections/common.d.ts +11 -3
- 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 -34
- package/dist/components/Dashboard/TileCard.d.ts +10 -3
- package/dist/components/Dashboard/useStuck.d.ts +15 -7
- 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 -8
- 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 +12 -9
- 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 +8418 -7722
- 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-BMPDvdFx.es.js → useCompiledDocument-Bf4RSfB6.es.js} +8669 -7851
- package/dist/useCompiledDocument-XsQz85Ri.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/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/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 +137 -155
- 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 +28 -17
- package/src/components/DocumentCreate/useDocumentChoices.ts +19 -2
- package/src/components/Environment/Connections.tsx +1 -0
- 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 +28 -39
- package/src/components/ReportBuilder/BuilderGrid.tsx +31 -29
- 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 +130 -151
- 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 -15
- 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 +37 -31
- package/src/components/ReportBuilder/ReportBuilder.textTiles.spec.tsx +22 -15
- package/src/components/ReportBuilder/ReportBuilder.tsx +292 -117
- 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 +241 -140
- 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/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-BcgYjkZ0.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-UY28ITET.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
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
+
import { segmentedSx } from "./BuilderToolbar";
|
|
5
|
+
import { reportClasses } from "../../theme/classes";
|
|
6
|
+
import ArrowDropDownCircleOutlinedIcon from "@mui/icons-material/ArrowDropDownCircleOutlined";
|
|
7
|
+
import ChecklistRtlIcon from "@mui/icons-material/ChecklistRtl";
|
|
4
8
|
import DeleteOutlineIcon from "@mui/icons-material/DeleteOutline";
|
|
9
|
+
import EventOutlinedIcon from "@mui/icons-material/EventOutlined";
|
|
10
|
+
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
|
11
|
+
import LinearScaleIcon from "@mui/icons-material/LinearScale";
|
|
12
|
+
import ShortTextIcon from "@mui/icons-material/ShortText";
|
|
13
|
+
import ViewQuiltOutlinedIcon from "@mui/icons-material/ViewQuiltOutlined";
|
|
5
14
|
import {
|
|
6
15
|
Autocomplete,
|
|
7
16
|
Box,
|
|
8
17
|
Button,
|
|
18
|
+
ButtonBase,
|
|
9
19
|
Checkbox,
|
|
20
|
+
Collapse,
|
|
10
21
|
MenuItem,
|
|
11
22
|
Stack,
|
|
12
23
|
TextField,
|
|
@@ -17,14 +28,25 @@ import {
|
|
|
17
28
|
type SxProps,
|
|
18
29
|
type Theme,
|
|
19
30
|
} from "@mui/material";
|
|
20
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
useEffect,
|
|
33
|
+
useMemo,
|
|
34
|
+
useRef,
|
|
35
|
+
useState,
|
|
36
|
+
type ReactNode,
|
|
37
|
+
type Ref,
|
|
38
|
+
} from "react";
|
|
21
39
|
import { titleCase, useFilterForm } from "./useFilterForm";
|
|
22
|
-
import { dangerTextColor } from "../../theme/motion";
|
|
40
|
+
import { dangerTextColor, MOTION_FAST } from "../../theme/motion";
|
|
41
|
+
import { edgeColor, hoverEdgeColor } from "../controlTokens";
|
|
23
42
|
import { usePublisherTheme } from "../../theme/ThemeContext";
|
|
24
43
|
import type { CatalogField } from "./catalog";
|
|
25
44
|
import {
|
|
45
|
+
acceptsField,
|
|
26
46
|
CONTROL_KINDS,
|
|
47
|
+
newLocalGiven,
|
|
27
48
|
OPERATORS,
|
|
49
|
+
typeLabel,
|
|
28
50
|
type BuilderControl,
|
|
29
51
|
type ControlKind,
|
|
30
52
|
type MappingRow,
|
|
@@ -71,6 +93,8 @@ export interface FilterDialogProps {
|
|
|
71
93
|
control?: BuilderControl;
|
|
72
94
|
/** Model givens not yet bound anywhere, offered as "from the model". */
|
|
73
95
|
available: readonly BuilderControl[];
|
|
96
|
+
/** Names a new filter must not take, beyond the page's own and `available`'s. */
|
|
97
|
+
takenNames?: readonly string[];
|
|
74
98
|
/**
|
|
75
99
|
* The fields a binding on THIS tile may name: the dimensions of the source
|
|
76
100
|
* it reads. Per tile, because a composite dashboard exists to span sources,
|
|
@@ -106,6 +130,7 @@ function FieldPicker({
|
|
|
106
130
|
disabled,
|
|
107
131
|
autoFocus,
|
|
108
132
|
placeholder,
|
|
133
|
+
inputRef,
|
|
109
134
|
sx,
|
|
110
135
|
}: {
|
|
111
136
|
value: string;
|
|
@@ -120,6 +145,7 @@ function FieldPicker({
|
|
|
120
145
|
disabled?: boolean;
|
|
121
146
|
autoFocus?: boolean;
|
|
122
147
|
placeholder?: string;
|
|
148
|
+
inputRef?: Ref<HTMLInputElement>;
|
|
123
149
|
sx?: SxProps<Theme>;
|
|
124
150
|
}) {
|
|
125
151
|
const options = useMemo(
|
|
@@ -146,14 +172,10 @@ function FieldPicker({
|
|
|
146
172
|
disableClearable
|
|
147
173
|
renderOption={(props, option) => (
|
|
148
174
|
<li {...props} key={option}>
|
|
149
|
-
<
|
|
175
|
+
<TypeBadge type={types.get(option)} />
|
|
176
|
+
<Typography variant="body2" sx={{ flex: 1, ml: 1 }}>
|
|
150
177
|
{option}
|
|
151
178
|
</Typography>
|
|
152
|
-
{types.get(option) && (
|
|
153
|
-
<Typography variant="caption" sx={{ opacity: 0.6 }}>
|
|
154
|
-
{types.get(option)?.replace(/_type$/, "")}
|
|
155
|
-
</Typography>
|
|
156
|
-
)}
|
|
157
179
|
</li>
|
|
158
180
|
)}
|
|
159
181
|
renderInput={(params) => (
|
|
@@ -162,8 +184,18 @@ function FieldPicker({
|
|
|
162
184
|
label={label}
|
|
163
185
|
placeholder={placeholder}
|
|
164
186
|
autoFocus={autoFocus}
|
|
187
|
+
{...(inputRef ? { inputRef } : {})}
|
|
165
188
|
error={error}
|
|
166
189
|
helperText={helperText}
|
|
190
|
+
InputLabelProps={{ ...params.InputLabelProps, shrink: true }}
|
|
191
|
+
InputProps={{
|
|
192
|
+
...params.InputProps,
|
|
193
|
+
startAdornment: types.get(value.trim()) ? (
|
|
194
|
+
<Box sx={{ display: "flex", ml: 0.5, mr: -0.25 }}>
|
|
195
|
+
<TypeBadge type={types.get(value.trim())} />
|
|
196
|
+
</Box>
|
|
197
|
+
) : undefined,
|
|
198
|
+
}}
|
|
167
199
|
inputProps={{ ...params.inputProps, "aria-label": ariaLabel }}
|
|
168
200
|
/>
|
|
169
201
|
)}
|
|
@@ -193,12 +225,14 @@ export function FilterDialog({
|
|
|
193
225
|
document,
|
|
194
226
|
control,
|
|
195
227
|
available,
|
|
228
|
+
takenNames,
|
|
196
229
|
fieldsFor,
|
|
197
230
|
onClose,
|
|
198
231
|
onApply,
|
|
199
232
|
onRemove,
|
|
200
233
|
}: FilterDialogProps) {
|
|
201
234
|
const { theme } = usePublisherTheme();
|
|
235
|
+
const ui = theme.ui;
|
|
202
236
|
const {
|
|
203
237
|
editing,
|
|
204
238
|
shown,
|
|
@@ -239,10 +273,74 @@ export function FilterDialog({
|
|
|
239
273
|
document,
|
|
240
274
|
control,
|
|
241
275
|
available,
|
|
276
|
+
...(takenNames ? { takenNames } : {}),
|
|
242
277
|
fieldsFor,
|
|
243
278
|
onApply,
|
|
244
279
|
});
|
|
245
280
|
|
|
281
|
+
const fieldRef = useRef<HTMLInputElement>(null);
|
|
282
|
+
const edge = edgeColor(theme.cardBorder);
|
|
283
|
+
const hoverEdge = hoverEdgeColor(theme.cardBorder, theme.tileTitle);
|
|
284
|
+
// The tiles are a summary until asked for: most filters apply to every
|
|
285
|
+
// tile, and a list of checkboxes on every open was most of the window. It
|
|
286
|
+
// opens by itself on a control that does not apply to them all.
|
|
287
|
+
const [tilesOpen, setTilesOpen] = useState(false);
|
|
288
|
+
// Decided once per opening, on the render after the form has read the
|
|
289
|
+
// control's mapping: in the opening render itself the rows are still the
|
|
290
|
+
// last window's, and the list opened (or not) for the wrong control.
|
|
291
|
+
const [deciding, setDeciding] = useState(false);
|
|
292
|
+
useEffect(() => {
|
|
293
|
+
if (open) setDeciding(true);
|
|
294
|
+
else setTilesOpen(false);
|
|
295
|
+
}, [open]);
|
|
296
|
+
useEffect(() => {
|
|
297
|
+
if (!deciding) return;
|
|
298
|
+
setDeciding(false);
|
|
299
|
+
setTilesOpen(editing && included < bindableCount);
|
|
300
|
+
// Only when deciding: ticking a tile must not fold the list away.
|
|
301
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
302
|
+
}, [deciding]);
|
|
303
|
+
useEffect(() => {
|
|
304
|
+
if (perTile) setTilesOpen(true);
|
|
305
|
+
}, [perTile]);
|
|
306
|
+
// Why a kind cannot filter the picked field, when it cannot.
|
|
307
|
+
const fieldType = commonFields?.find((f) => f.name === field.trim())?.type;
|
|
308
|
+
const kindReason = (candidate: ControlKind): string | undefined => {
|
|
309
|
+
if (!fieldType) return undefined;
|
|
310
|
+
const wants = newLocalGiven({
|
|
311
|
+
name: "X",
|
|
312
|
+
label,
|
|
313
|
+
kind: candidate,
|
|
314
|
+
field,
|
|
315
|
+
}).type;
|
|
316
|
+
return acceptsField(wants, fieldType)
|
|
317
|
+
? undefined
|
|
318
|
+
: `${field.trim()} is ${typeLabel(fieldType)}, which this control cannot filter.`;
|
|
319
|
+
};
|
|
320
|
+
const previewLabel =
|
|
321
|
+
label.trim() || (newName ? titleCase(newName) : "Filter");
|
|
322
|
+
const previewValue =
|
|
323
|
+
kind === "number"
|
|
324
|
+
? "Any"
|
|
325
|
+
: kind === "date"
|
|
326
|
+
? dateDefault
|
|
327
|
+
? new Date(`${dateDefault}T00:00:00`).toLocaleDateString([], {
|
|
328
|
+
month: "short",
|
|
329
|
+
day: "numeric",
|
|
330
|
+
year: "numeric",
|
|
331
|
+
})
|
|
332
|
+
: "Any"
|
|
333
|
+
: "All";
|
|
334
|
+
// The builder's own segmented control, as the bar's layout switch is.
|
|
335
|
+
const segmentSx = {
|
|
336
|
+
...segmentedSx(edge, ui),
|
|
337
|
+
alignSelf: "flex-start",
|
|
338
|
+
"& .MuiToggleButton-root": {
|
|
339
|
+
...segmentedSx(edge, ui)["& .MuiToggleButton-root"],
|
|
340
|
+
textTransform: "none",
|
|
341
|
+
},
|
|
342
|
+
};
|
|
343
|
+
|
|
246
344
|
const operatorField = (
|
|
247
345
|
value: string | undefined,
|
|
248
346
|
onChange: (op: string) => void,
|
|
@@ -267,16 +365,15 @@ export function FilterDialog({
|
|
|
267
365
|
|
|
268
366
|
return (
|
|
269
367
|
<AppDialog
|
|
368
|
+
className={`${reportClasses.dialog} ${reportClasses.filterDialog}`}
|
|
270
369
|
open={open}
|
|
271
370
|
onClose={onClose}
|
|
371
|
+
{...(!editing ? { initialFocus: fieldRef } : {})}
|
|
272
372
|
title={editing ? (shown.label ?? shown.name) : "Add a filter"}
|
|
273
373
|
description={
|
|
274
374
|
editing ? (
|
|
275
375
|
<>
|
|
276
|
-
<Box
|
|
277
|
-
component="span"
|
|
278
|
-
sx={{ fontFamily: "ui-monospace, monospace" }}
|
|
279
|
-
>
|
|
376
|
+
<Box component="span" sx={{ fontFamily: ui.font.mono }}>
|
|
280
377
|
${shown.name}
|
|
281
378
|
</Box>
|
|
282
379
|
{fromModel
|
|
@@ -336,6 +433,7 @@ export function FilterDialog({
|
|
|
336
433
|
pickExisting(available[0]);
|
|
337
434
|
}}
|
|
338
435
|
aria-label="Where the filter comes from"
|
|
436
|
+
sx={segmentSx}
|
|
339
437
|
>
|
|
340
438
|
<ToggleButton value="new">New in this report</ToggleButton>
|
|
341
439
|
<ToggleButton value="existing">From the model</ToggleButton>
|
|
@@ -370,20 +468,30 @@ export function FilterDialog({
|
|
|
370
468
|
</TextField>
|
|
371
469
|
) : null}
|
|
372
470
|
|
|
373
|
-
<
|
|
471
|
+
<Box
|
|
472
|
+
sx={{
|
|
473
|
+
display: "grid",
|
|
474
|
+
gridTemplateColumns: {
|
|
475
|
+
xs: "1fr",
|
|
476
|
+
sm: fromModel ? "1fr" : "minmax(0, 1.4fr) minmax(0, 1fr)",
|
|
477
|
+
},
|
|
478
|
+
gap: 1.5,
|
|
479
|
+
alignItems: "start",
|
|
480
|
+
}}
|
|
481
|
+
>
|
|
374
482
|
{/* Hidden while per-tile fields are open: they speak for
|
|
375
|
-
|
|
376
|
-
|
|
483
|
+
themselves then, and a box above them that applied to
|
|
484
|
+
nothing would read as one more thing to fill. */}
|
|
377
485
|
{!perTile && (
|
|
378
486
|
<FieldPicker
|
|
379
487
|
value={field}
|
|
380
488
|
onChange={pickField}
|
|
381
489
|
fields={commonFields}
|
|
382
490
|
accepts={accepts}
|
|
383
|
-
label="Field
|
|
491
|
+
label="Field"
|
|
384
492
|
ariaLabel="Field to filter"
|
|
385
493
|
placeholder="category"
|
|
386
|
-
|
|
494
|
+
inputRef={fieldRef}
|
|
387
495
|
error={commonProblem !== undefined}
|
|
388
496
|
helperText={
|
|
389
497
|
commonProblem ??
|
|
@@ -391,7 +499,6 @@ export function FilterDialog({
|
|
|
391
499
|
? `Declared as $${newName}`
|
|
392
500
|
: undefined)
|
|
393
501
|
}
|
|
394
|
-
sx={{ flex: 1, minWidth: 200 }}
|
|
395
502
|
/>
|
|
396
503
|
)}
|
|
397
504
|
{!fromModel && (
|
|
@@ -401,47 +508,92 @@ export function FilterDialog({
|
|
|
401
508
|
placeholder={newName ? titleCase(newName) : ""}
|
|
402
509
|
value={label}
|
|
403
510
|
onChange={(event) => setLabel(event.target.value)}
|
|
511
|
+
InputLabelProps={{ shrink: true }}
|
|
404
512
|
inputProps={{ "aria-label": "Filter label" }}
|
|
405
|
-
sx={{ flex: 1, minWidth: 160 }}
|
|
406
513
|
/>
|
|
407
514
|
)}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
515
|
+
</Box>
|
|
516
|
+
{valueTyped &&
|
|
517
|
+
!perTile &&
|
|
518
|
+
operatorField(commonOp, setCommonOp, "Comparison")}
|
|
519
|
+
|
|
412
520
|
{!editing && source.kind === "new" && (
|
|
413
|
-
<
|
|
414
|
-
<
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
label="Filter kind"
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
slotProps={{
|
|
424
|
-
select: {
|
|
425
|
-
renderValue: (value) =>
|
|
426
|
-
CONTROL_KINDS.find((k) => k.kind === value)
|
|
427
|
-
?.label ?? String(value),
|
|
521
|
+
<Box>
|
|
522
|
+
<SectionLabel>Control</SectionLabel>
|
|
523
|
+
<Box
|
|
524
|
+
role="radiogroup"
|
|
525
|
+
aria-label="Filter kind"
|
|
526
|
+
sx={{
|
|
527
|
+
display: "grid",
|
|
528
|
+
gridTemplateColumns: {
|
|
529
|
+
xs: "repeat(3, minmax(0, 1fr))",
|
|
530
|
+
sm: "repeat(5, minmax(0, 1fr))",
|
|
428
531
|
},
|
|
532
|
+
gap: 1,
|
|
429
533
|
}}
|
|
430
|
-
sx={{ flex: 1 }}
|
|
431
534
|
>
|
|
432
|
-
{CONTROL_KINDS.map((option) =>
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
535
|
+
{CONTROL_KINDS.map((option) => {
|
|
536
|
+
const checked = option.kind === kind;
|
|
537
|
+
const reason = kindReason(option.kind);
|
|
538
|
+
return (
|
|
539
|
+
<Tooltip
|
|
540
|
+
key={option.kind}
|
|
541
|
+
title={reason ?? option.hint}
|
|
542
|
+
describeChild
|
|
439
543
|
>
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
544
|
+
<ButtonBase
|
|
545
|
+
role="radio"
|
|
546
|
+
aria-checked={checked}
|
|
547
|
+
aria-label={option.label}
|
|
548
|
+
aria-disabled={reason !== undefined}
|
|
549
|
+
onClick={() => {
|
|
550
|
+
if (reason === undefined)
|
|
551
|
+
pickKind(option.kind);
|
|
552
|
+
}}
|
|
553
|
+
sx={(mui) => ({
|
|
554
|
+
flexDirection: "column",
|
|
555
|
+
gap: 0.5,
|
|
556
|
+
px: 1,
|
|
557
|
+
py: 1.25,
|
|
558
|
+
borderRadius: ui.radius.tile,
|
|
559
|
+
border: `1px solid ${checked ? theme.accent : edge}`,
|
|
560
|
+
boxShadow: checked
|
|
561
|
+
? `0 0 0 1px ${theme.accent}`
|
|
562
|
+
: "none",
|
|
563
|
+
bgcolor: checked
|
|
564
|
+
? `color-mix(in srgb, ${theme.accent} 6%, ${mui.palette.background.paper})`
|
|
565
|
+
: mui.palette.background.paper,
|
|
566
|
+
color: checked
|
|
567
|
+
? theme.accent
|
|
568
|
+
: mui.palette.text.secondary,
|
|
569
|
+
opacity: reason ? 0.45 : 1,
|
|
570
|
+
cursor: reason ? "default" : "pointer",
|
|
571
|
+
transition: `border-color ${MOTION_FAST}, background-color ${MOTION_FAST}`,
|
|
572
|
+
"&:hover":
|
|
573
|
+
reason || checked
|
|
574
|
+
? {}
|
|
575
|
+
: { borderColor: hoverEdge },
|
|
576
|
+
})}
|
|
577
|
+
>
|
|
578
|
+
<KindGlyph kind={option.kind} />
|
|
579
|
+
<Box
|
|
580
|
+
component="span"
|
|
581
|
+
sx={{
|
|
582
|
+
...ui.type.caption,
|
|
583
|
+
fontWeight: checked ? 600 : 500,
|
|
584
|
+
color: checked
|
|
585
|
+
? theme.accent
|
|
586
|
+
: "text.primary",
|
|
587
|
+
textAlign: "center",
|
|
588
|
+
}}
|
|
589
|
+
>
|
|
590
|
+
{SHORT_KIND[option.kind]}
|
|
591
|
+
</Box>
|
|
592
|
+
</ButtonBase>
|
|
593
|
+
</Tooltip>
|
|
594
|
+
);
|
|
595
|
+
})}
|
|
596
|
+
</Box>
|
|
445
597
|
{kind === "date" && (
|
|
446
598
|
<TextField
|
|
447
599
|
size="small"
|
|
@@ -450,137 +602,335 @@ export function FilterDialog({
|
|
|
450
602
|
value={dateDefault}
|
|
451
603
|
onChange={(event) => setDateDefault(event.target.value)}
|
|
452
604
|
InputLabelProps={{ shrink: true }}
|
|
453
|
-
sx={{
|
|
605
|
+
sx={{ mt: 1.5, width: 200 }}
|
|
454
606
|
/>
|
|
455
607
|
)}
|
|
456
|
-
</
|
|
608
|
+
</Box>
|
|
457
609
|
)}
|
|
458
610
|
|
|
459
|
-
{/* WHICH tiles. */}
|
|
460
|
-
<Box
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
611
|
+
{/* WHICH tiles: a summary, opened into the list on request. */}
|
|
612
|
+
<Box
|
|
613
|
+
sx={{
|
|
614
|
+
border: `1px solid ${edge}`,
|
|
615
|
+
borderRadius: ui.radius.tile,
|
|
616
|
+
overflow: "hidden",
|
|
617
|
+
}}
|
|
618
|
+
>
|
|
619
|
+
<Stack
|
|
620
|
+
direction="row"
|
|
621
|
+
sx={{ alignItems: "center", gap: 1.25, px: 1.5, py: 1 }}
|
|
622
|
+
>
|
|
623
|
+
<ViewQuiltOutlinedIcon
|
|
624
|
+
aria-hidden
|
|
625
|
+
sx={{ fontSize: 18, color: "text.secondary" }}
|
|
469
626
|
/>
|
|
470
|
-
<Typography variant="
|
|
471
|
-
|
|
627
|
+
<Typography variant="body2" sx={{ flex: 1, minWidth: 0 }}>
|
|
628
|
+
<Box
|
|
629
|
+
component="span"
|
|
630
|
+
sx={{ fontWeight: ui.type.label.fontWeight }}
|
|
631
|
+
>
|
|
632
|
+
{included === bindableCount && bindableCount > 0
|
|
633
|
+
? `Applies to all ${included} tile${included === 1 ? "" : "s"}`
|
|
634
|
+
: `Applies to ${included} of ${bindableCount} tile${bindableCount === 1 ? "" : "s"}`}
|
|
635
|
+
</Box>
|
|
636
|
+
{!perTile && field.trim() !== "" && included > 0 && (
|
|
637
|
+
<Box component="span" sx={{ color: "text.secondary" }}>
|
|
638
|
+
{" · each filters on "}
|
|
639
|
+
<Box
|
|
640
|
+
component="span"
|
|
641
|
+
sx={{
|
|
642
|
+
...ui.type.code,
|
|
643
|
+
}}
|
|
644
|
+
>
|
|
645
|
+
{field.trim()}
|
|
646
|
+
</Box>
|
|
647
|
+
</Box>
|
|
648
|
+
)}
|
|
472
649
|
</Typography>
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
{perTile ? "Same field for all" : "Adjust per tile"}
|
|
486
|
-
</Button>
|
|
650
|
+
{/* Not folded while each tile has a field of its own: a
|
|
651
|
+
problem with one is the only thing holding Apply, and
|
|
652
|
+
folded it would be out of sight. */}
|
|
653
|
+
{!perTile && (
|
|
654
|
+
<Button
|
|
655
|
+
size="small"
|
|
656
|
+
aria-expanded={tilesOpen}
|
|
657
|
+
onClick={() => setTilesOpen((was) => !was)}
|
|
658
|
+
>
|
|
659
|
+
{tilesOpen ? "Done choosing" : "Choose tiles"}
|
|
660
|
+
</Button>
|
|
661
|
+
)}
|
|
487
662
|
</Stack>
|
|
488
|
-
<
|
|
489
|
-
{
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
663
|
+
<Collapse in={tilesOpen} unmountOnExit>
|
|
664
|
+
<Box sx={{ borderTop: `1px solid ${edge}`, px: 0.5, pb: 1 }}>
|
|
665
|
+
<Stack
|
|
666
|
+
direction="row"
|
|
667
|
+
sx={{ alignItems: "center", gap: 0.5, pt: 0.5 }}
|
|
668
|
+
>
|
|
669
|
+
<Checkbox
|
|
670
|
+
size="small"
|
|
671
|
+
checked={
|
|
672
|
+
bindableCount > 0 && included === bindableCount
|
|
673
|
+
}
|
|
674
|
+
indeterminate={
|
|
675
|
+
included > 0 && included < bindableCount
|
|
676
|
+
}
|
|
677
|
+
disabled={bindableCount === 0}
|
|
678
|
+
onChange={(event) => setAll(event.target.checked)}
|
|
679
|
+
inputProps={{ "aria-label": "All tiles" }}
|
|
680
|
+
/>
|
|
681
|
+
<Typography
|
|
682
|
+
variant="body2"
|
|
683
|
+
sx={{ flex: 1, color: "text.secondary" }}
|
|
684
|
+
>
|
|
685
|
+
All tiles
|
|
686
|
+
</Typography>
|
|
687
|
+
<Button
|
|
688
|
+
size="small"
|
|
689
|
+
onClick={() => {
|
|
690
|
+
// Opening per-tile starts every row from the
|
|
691
|
+
// common field; closing it goes back to one box.
|
|
692
|
+
if (!perTile)
|
|
693
|
+
setRows((previous) =>
|
|
694
|
+
previous.map((row) => ({ ...row, field })),
|
|
695
|
+
);
|
|
696
|
+
setPerTile((was) => !was);
|
|
502
697
|
}}
|
|
503
698
|
>
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
noWrap
|
|
527
|
-
>
|
|
528
|
-
{title}
|
|
529
|
-
</Typography>
|
|
530
|
-
{!bindable[index] ? (
|
|
531
|
-
<Tooltip
|
|
532
|
-
title={
|
|
533
|
-
unbindable(document.tiles[index]).reason
|
|
534
|
-
}
|
|
699
|
+
{perTile ? "Same field for all" : "Adjust per tile"}
|
|
700
|
+
</Button>
|
|
701
|
+
</Stack>
|
|
702
|
+
<Stack sx={{ gap: perTile ? 1 : 0 }}>
|
|
703
|
+
{document.tiles.map((tile, index) => {
|
|
704
|
+
if (!isQueryTile(tile)) return null;
|
|
705
|
+
const row = rows[index];
|
|
706
|
+
const title = tile.label ?? tile.name;
|
|
707
|
+
const problem = perTile
|
|
708
|
+
? rowProblems[index]
|
|
709
|
+
: undefined;
|
|
710
|
+
return (
|
|
711
|
+
<Stack
|
|
712
|
+
key={`${tile.source}.${tile.name}`}
|
|
713
|
+
direction="row"
|
|
714
|
+
sx={{
|
|
715
|
+
gap: 1,
|
|
716
|
+
alignItems: perTile
|
|
717
|
+
? "flex-start"
|
|
718
|
+
: "center",
|
|
719
|
+
opacity: bindable[index] ? 1 : 0.6,
|
|
720
|
+
}}
|
|
535
721
|
>
|
|
722
|
+
<Checkbox
|
|
723
|
+
size="small"
|
|
724
|
+
disabled={!bindable[index]}
|
|
725
|
+
checked={
|
|
726
|
+
(row?.include ?? false) &&
|
|
727
|
+
bindable[index]
|
|
728
|
+
}
|
|
729
|
+
inputProps={{
|
|
730
|
+
"aria-label": `Filter ${title}`,
|
|
731
|
+
}}
|
|
732
|
+
onChange={(event) =>
|
|
733
|
+
setRow(index, {
|
|
734
|
+
include: event.target.checked,
|
|
735
|
+
})
|
|
736
|
+
}
|
|
737
|
+
/>
|
|
536
738
|
<Typography
|
|
537
|
-
variant="
|
|
538
|
-
sx={{
|
|
739
|
+
variant="body2"
|
|
740
|
+
sx={{
|
|
741
|
+
flex: 1,
|
|
742
|
+
minWidth: 0,
|
|
743
|
+
pt: perTile ? 1 : 0,
|
|
744
|
+
}}
|
|
745
|
+
noWrap
|
|
539
746
|
>
|
|
540
|
-
{
|
|
747
|
+
{title}
|
|
541
748
|
</Typography>
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
setRow(index, { field: next })
|
|
749
|
+
{!bindable[index] ? (
|
|
750
|
+
<Typography
|
|
751
|
+
variant="caption"
|
|
752
|
+
sx={{
|
|
753
|
+
color: theme.tileTitle,
|
|
754
|
+
pr: 1,
|
|
755
|
+
maxWidth: 260,
|
|
756
|
+
textAlign: "right",
|
|
757
|
+
}}
|
|
758
|
+
>
|
|
759
|
+
{
|
|
760
|
+
unbindable(document.tiles[index])
|
|
761
|
+
.reason
|
|
556
762
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
763
|
+
</Typography>
|
|
764
|
+
) : (
|
|
765
|
+
perTile && (
|
|
766
|
+
<>
|
|
767
|
+
{valueTyped &&
|
|
768
|
+
operatorField(
|
|
769
|
+
row?.op,
|
|
770
|
+
(op) => setRow(index, { op }),
|
|
771
|
+
`Comparison for ${title}`,
|
|
772
|
+
)}
|
|
773
|
+
<FieldPicker
|
|
774
|
+
value={row?.field ?? ""}
|
|
775
|
+
onChange={(next) =>
|
|
776
|
+
setRow(index, { field: next })
|
|
777
|
+
}
|
|
778
|
+
fields={fieldsFor?.(tile)}
|
|
779
|
+
accepts={accepts}
|
|
780
|
+
label="Field"
|
|
781
|
+
ariaLabel={`Field for ${title}`}
|
|
782
|
+
disabled={!row?.include}
|
|
783
|
+
error={problem !== undefined}
|
|
784
|
+
helperText={problem}
|
|
785
|
+
sx={{ width: 220, pr: 1 }}
|
|
786
|
+
/>
|
|
787
|
+
</>
|
|
788
|
+
)
|
|
789
|
+
)}
|
|
790
|
+
</Stack>
|
|
791
|
+
);
|
|
792
|
+
})}
|
|
793
|
+
</Stack>
|
|
794
|
+
</Box>
|
|
795
|
+
</Collapse>
|
|
582
796
|
</Box>
|
|
797
|
+
{included === 0 && (
|
|
798
|
+
<Typography
|
|
799
|
+
variant="caption"
|
|
800
|
+
sx={{ color: "warning.main", display: "block", mt: -1.5 }}
|
|
801
|
+
>
|
|
802
|
+
No tile is ticked, so this control will not appear on the
|
|
803
|
+
report.
|
|
804
|
+
</Typography>
|
|
805
|
+
)}
|
|
806
|
+
|
|
807
|
+
{/* What a reader will see: the filter's button as it will sit on
|
|
808
|
+
the page, before it does. */}
|
|
809
|
+
{!fromModel && (
|
|
810
|
+
<Box>
|
|
811
|
+
<SectionLabel>Preview</SectionLabel>
|
|
812
|
+
<Box
|
|
813
|
+
sx={(mui) => ({
|
|
814
|
+
display: "flex",
|
|
815
|
+
alignItems: "center",
|
|
816
|
+
gap: 1,
|
|
817
|
+
p: 1.5,
|
|
818
|
+
borderRadius: ui.radius.tile,
|
|
819
|
+
bgcolor: mui.palette.action.hover,
|
|
820
|
+
})}
|
|
821
|
+
>
|
|
822
|
+
<Box
|
|
823
|
+
aria-hidden
|
|
824
|
+
sx={(mui) => ({
|
|
825
|
+
display: "inline-flex",
|
|
826
|
+
alignItems: "center",
|
|
827
|
+
gap: 0.75,
|
|
828
|
+
height: 30,
|
|
829
|
+
px: 1.25,
|
|
830
|
+
borderRadius: ui.radius.control,
|
|
831
|
+
border: `1px solid ${edge}`,
|
|
832
|
+
bgcolor: mui.palette.background.paper,
|
|
833
|
+
...ui.type.control,
|
|
834
|
+
})}
|
|
835
|
+
>
|
|
836
|
+
<Box component="span" sx={{ color: "text.secondary" }}>
|
|
837
|
+
{previewLabel}
|
|
838
|
+
</Box>
|
|
839
|
+
<Box
|
|
840
|
+
component="span"
|
|
841
|
+
sx={{ fontWeight: ui.type.label.fontWeight }}
|
|
842
|
+
>
|
|
843
|
+
{previewValue}
|
|
844
|
+
</Box>
|
|
845
|
+
<ExpandMoreIcon
|
|
846
|
+
sx={{ fontSize: 16, color: "text.secondary" }}
|
|
847
|
+
/>
|
|
848
|
+
</Box>
|
|
849
|
+
</Box>
|
|
850
|
+
</Box>
|
|
851
|
+
)}
|
|
583
852
|
</Stack>
|
|
584
853
|
</AppDialog>
|
|
585
854
|
);
|
|
586
855
|
}
|
|
856
|
+
|
|
857
|
+
/** A small heading over a part of the window. */
|
|
858
|
+
function SectionLabel({ children }: { children: ReactNode }) {
|
|
859
|
+
const ui = usePublisherTheme().theme.ui;
|
|
860
|
+
return (
|
|
861
|
+
<Typography
|
|
862
|
+
component="div"
|
|
863
|
+
sx={{
|
|
864
|
+
...ui.type.label,
|
|
865
|
+
color: "text.secondary",
|
|
866
|
+
mb: 0.75,
|
|
867
|
+
}}
|
|
868
|
+
>
|
|
869
|
+
{children}
|
|
870
|
+
</Typography>
|
|
871
|
+
);
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
/** The words on a control kind's card: short, since five sit in a row. */
|
|
875
|
+
const SHORT_KIND: Record<ControlKind, string> = {
|
|
876
|
+
select: "Pick one",
|
|
877
|
+
multiselect: "Pick several",
|
|
878
|
+
text: "Text",
|
|
879
|
+
number: "Range",
|
|
880
|
+
date: "Date",
|
|
881
|
+
};
|
|
882
|
+
|
|
883
|
+
/** A control kind's picture, so the five read at a glance. */
|
|
884
|
+
function KindGlyph({ kind }: { kind: ControlKind }) {
|
|
885
|
+
const sx = { fontSize: 22 };
|
|
886
|
+
switch (kind) {
|
|
887
|
+
case "select":
|
|
888
|
+
return <ArrowDropDownCircleOutlinedIcon sx={sx} />;
|
|
889
|
+
case "multiselect":
|
|
890
|
+
return <ChecklistRtlIcon sx={sx} />;
|
|
891
|
+
case "text":
|
|
892
|
+
return <ShortTextIcon sx={sx} />;
|
|
893
|
+
case "number":
|
|
894
|
+
return <LinearScaleIcon sx={sx} />;
|
|
895
|
+
case "date":
|
|
896
|
+
return <EventOutlinedIcon sx={sx} />;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
/** A field's type, as a small badge: Abc, #, a date. */
|
|
901
|
+
function TypeBadge({ type }: { type: string | undefined }) {
|
|
902
|
+
const scalar = type?.replace(/_type$/, "");
|
|
903
|
+
const text =
|
|
904
|
+
scalar === "string"
|
|
905
|
+
? "Abc"
|
|
906
|
+
: scalar === "number"
|
|
907
|
+
? "#"
|
|
908
|
+
: scalar === "date" || scalar === "timestamp"
|
|
909
|
+
? "Date"
|
|
910
|
+
: scalar === "boolean"
|
|
911
|
+
? "T/F"
|
|
912
|
+
: undefined;
|
|
913
|
+
const ui = usePublisherTheme().theme.ui;
|
|
914
|
+
if (!text) return null;
|
|
915
|
+
return (
|
|
916
|
+
<Box
|
|
917
|
+
component="span"
|
|
918
|
+
aria-hidden
|
|
919
|
+
sx={(mui) => ({
|
|
920
|
+
fontFamily: ui.font.mono,
|
|
921
|
+
fontSize: 10,
|
|
922
|
+
fontWeight: ui.type.label.fontWeight,
|
|
923
|
+
color: mui.palette.text.secondary,
|
|
924
|
+
bgcolor: mui.palette.action.hover,
|
|
925
|
+
borderRadius: "4px",
|
|
926
|
+
px: 0.5,
|
|
927
|
+
py: 0.25,
|
|
928
|
+
minWidth: 22,
|
|
929
|
+
textAlign: "center",
|
|
930
|
+
flex: "none",
|
|
931
|
+
})}
|
|
932
|
+
>
|
|
933
|
+
{text}
|
|
934
|
+
</Box>
|
|
935
|
+
);
|
|
936
|
+
}
|