@malloy-publisher/sdk 0.12.1 → 0.12.3
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 +79 -6
- package/dist/{RenderedResult-DrNhQ2_9.cjs.js → RenderedResult-C2arX5Zz.cjs.js} +1 -1
- package/dist/{RenderedResult-AyM-RQaA.es.js → RenderedResult-DqPvGZgL.es.js} +2 -2
- package/dist/ServerProvider-CqL6xzta.cjs.js +1 -0
- package/dist/{ServerProvider-a9Ki0QXO.es.js → ServerProvider-DRbZ6tLP.es.js} +1213 -1187
- package/dist/builder/index.cjs.js +1 -1
- package/dist/builder/index.es.js +3 -3
- package/dist/client/api.d.ts +43 -13
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +28 -27
- package/dist/components/Model/ExplorerPage.d.ts +9 -0
- package/dist/components/Model/Model.d.ts +27 -11
- package/dist/components/ModelViewer/AccessChips.d.ts +34 -0
- package/dist/components/ModelViewer/EmptyRow.d.ts +23 -0
- package/dist/components/ModelViewer/Facts.d.ts +15 -0
- package/dist/components/ModelViewer/FieldGroup.d.ts +31 -0
- package/dist/components/ModelViewer/FieldRow.d.ts +69 -0
- package/dist/components/ModelViewer/GivenFacts.d.ts +21 -0
- package/dist/components/ModelViewer/HeaderBar.d.ts +75 -0
- package/dist/components/ModelViewer/InlineDoc.d.ts +13 -0
- package/dist/components/ModelViewer/ModelGivensSection.d.ts +32 -0
- package/dist/components/ModelViewer/ModelSection.d.ts +21 -0
- package/dist/components/ModelViewer/ModelViewer.d.ts +91 -0
- package/dist/components/ModelViewer/QueriesGroup.d.ts +15 -0
- package/dist/components/ModelViewer/RowGlyph.d.ts +27 -0
- package/dist/components/ModelViewer/RunResult.d.ts +46 -0
- package/dist/components/ModelViewer/SampleValues.d.ts +20 -0
- package/dist/components/ModelViewer/SchemaJoin.d.ts +51 -0
- package/dist/components/ModelViewer/SchemaView.d.ts +52 -0
- package/dist/components/ModelViewer/SegmentIcons.d.ts +70 -0
- package/dist/components/ModelViewer/SourcesDropdown.d.ts +53 -0
- package/dist/components/ModelViewer/SourcesNav.d.ts +25 -0
- package/dist/components/ModelViewer/StatusPill.d.ts +56 -0
- package/dist/components/ModelViewer/ValueChip.d.ts +17 -0
- package/dist/components/ModelViewer/ViewRow.d.ts +36 -0
- package/dist/components/ModelViewer/clickableBox.d.ts +29 -0
- package/dist/components/ModelViewer/codeDisplay.d.ts +44 -0
- package/dist/components/ModelViewer/docAnnotations.d.ts +90 -0
- package/dist/components/ModelViewer/explorerModel.d.ts +12 -0
- package/dist/components/ModelViewer/extensions.d.ts +94 -0
- package/dist/components/ModelViewer/fieldCode.d.ts +74 -0
- package/dist/components/ModelViewer/fieldEntities.d.ts +45 -0
- package/dist/components/ModelViewer/fieldExpansion.d.ts +41 -0
- package/dist/components/ModelViewer/givenUsage.d.ts +71 -0
- package/dist/components/ModelViewer/headerCard.d.ts +31 -0
- package/dist/components/ModelViewer/httpStatus.d.ts +4 -0
- package/dist/components/ModelViewer/icons.d.ts +31 -0
- package/dist/components/ModelViewer/index.d.ts +9 -0
- package/dist/components/ModelViewer/joinAccess.d.ts +52 -0
- package/dist/components/ModelViewer/malloyRunText.d.ts +22 -0
- package/dist/components/ModelViewer/malloyText.d.ts +21 -0
- package/dist/components/ModelViewer/modelGivens.d.ts +61 -0
- package/dist/components/ModelViewer/modelGivensContext.d.ts +9 -0
- package/dist/components/ModelViewer/modelHeaderPresentation.d.ts +28 -0
- package/dist/components/ModelViewer/modelTextDeclarations.d.ts +32 -0
- package/dist/components/ModelViewer/modelTextParse.d.ts +27 -0
- package/dist/components/ModelViewer/namedQueryCode.d.ts +12 -0
- package/dist/components/ModelViewer/offSurface.d.ts +54 -0
- package/dist/components/ModelViewer/rowLayers.d.ts +30 -0
- package/dist/components/ModelViewer/runGate.d.ts +49 -0
- package/dist/components/ModelViewer/schemaModel.d.ts +109 -0
- package/dist/components/ModelViewer/sectionOpenCommand.d.ts +45 -0
- package/dist/components/ModelViewer/sourceAccess.d.ts +67 -0
- package/dist/components/ModelViewer/sourceLineage.d.ts +14 -0
- package/dist/components/ModelViewer/sourcePicker.d.ts +66 -0
- package/dist/components/ModelViewer/surface.d.ts +47 -0
- package/dist/components/ModelViewer/text.d.ts +6 -0
- package/dist/components/ModelViewer/theme.d.ts +63 -0
- package/dist/components/ModelViewer/tokens.d.ts +52 -0
- package/dist/components/ModelViewer/ui.d.ts +48 -0
- package/dist/components/ModelViewer/useDimensionSamples.d.ts +76 -0
- package/dist/components/ModelViewer/useModelSources.d.ts +92 -0
- package/dist/components/ModelViewer/useRunQuery.d.ts +115 -0
- package/dist/components/ReportBuilder/loadMalloy.d.ts +4 -0
- package/dist/components/ServerProvider.d.ts +15 -1
- package/dist/components/filter/utils.d.ts +1 -1
- package/dist/components/given/GivenInput.d.ts +7 -1
- package/dist/components/given/GivensPanel.d.ts +3 -1
- package/dist/components/given/filterSummary.d.ts +6 -0
- package/dist/components/given/useGivenUrlParams.d.ts +11 -0
- package/dist/components/index.d.ts +2 -1
- package/dist/components/modelPage.d.ts +36 -0
- package/dist/hooks/useDimensionalFilterRangeData.d.ts +9 -0
- package/dist/hooks/useSuggestOptions.d.ts +26 -2
- package/dist/index.cjs.js +47 -19
- package/dist/index.es.js +14281 -9879
- package/dist/useCompiledDocument--Z7vKZL5.cjs.js +143 -0
- package/dist/{useCompiledDocument-Utj2u8CG.es.js → useCompiledDocument-BnT2QpG0.es.js} +6975 -6893
- package/dist/utils/filterCondition.d.ts +14 -0
- package/dist/utils/malloyLiteral.d.ts +20 -1
- package/package.json +2 -2
- package/src/components/Model/ExplorerPage.tsx +269 -0
- package/src/components/Model/Model.tsx +66 -250
- package/src/components/Model/ModelExplorer.spec.tsx +64 -1
- package/src/components/ModelViewer/AccessChips.tsx +149 -0
- package/src/components/ModelViewer/EmptyRow.tsx +71 -0
- package/src/components/ModelViewer/Facts.tsx +46 -0
- package/src/components/ModelViewer/FieldGroup.tsx +137 -0
- package/src/components/ModelViewer/FieldRow.tsx +566 -0
- package/src/components/ModelViewer/GivenFacts.tsx +89 -0
- package/src/components/ModelViewer/HeaderBar.tsx +362 -0
- package/src/components/ModelViewer/InlineDoc.tsx +50 -0
- package/src/components/ModelViewer/ModelGivensSection.tsx +142 -0
- package/src/components/ModelViewer/ModelSection.tsx +98 -0
- package/src/components/ModelViewer/ModelViewer.spec.tsx +937 -0
- package/src/components/ModelViewer/ModelViewer.tsx +777 -0
- package/src/components/ModelViewer/QueriesGroup.tsx +107 -0
- package/src/components/ModelViewer/RowGlyph.tsx +138 -0
- package/src/components/ModelViewer/RunResult.tsx +298 -0
- package/src/components/ModelViewer/SampleValues.tsx +97 -0
- package/src/components/ModelViewer/SchemaJoin.tsx +258 -0
- package/src/components/ModelViewer/SchemaView.tsx +222 -0
- package/src/components/ModelViewer/SegmentIcons.tsx +129 -0
- package/src/components/ModelViewer/SourcesDropdown.tsx +265 -0
- package/src/components/ModelViewer/SourcesNav.tsx +75 -0
- package/src/components/ModelViewer/StatusPill.tsx +145 -0
- package/src/components/ModelViewer/ValueChip.tsx +39 -0
- package/src/components/ModelViewer/ViewRow.tsx +274 -0
- package/src/components/ModelViewer/clickableBox.ts +59 -0
- package/src/components/ModelViewer/codeDisplay.spec.ts +176 -0
- package/src/components/ModelViewer/codeDisplay.ts +118 -0
- package/src/components/ModelViewer/docAnnotations.spec.ts +181 -0
- package/src/components/ModelViewer/docAnnotations.ts +244 -0
- package/src/components/ModelViewer/docAnnotations.typeDetail.spec.ts +114 -0
- package/src/components/ModelViewer/explorerModel.spec.ts +43 -0
- package/src/components/ModelViewer/explorerModel.ts +31 -0
- package/src/components/ModelViewer/extensions.tsx +112 -0
- package/src/components/ModelViewer/fieldCode.spec.ts +168 -0
- package/src/components/ModelViewer/fieldCode.ts +118 -0
- package/src/components/ModelViewer/fieldEntities.ts +63 -0
- package/src/components/ModelViewer/fieldExpansion.spec.ts +116 -0
- package/src/components/ModelViewer/fieldExpansion.ts +95 -0
- package/src/components/ModelViewer/givenUsage.spec.ts +304 -0
- package/src/components/ModelViewer/givenUsage.ts +325 -0
- package/src/components/ModelViewer/headerCard.tsx +102 -0
- package/src/components/ModelViewer/httpStatus.ts +15 -0
- package/src/components/ModelViewer/icons.tsx +67 -0
- package/src/components/ModelViewer/index.ts +26 -0
- package/src/components/ModelViewer/joinAccess.spec.ts +95 -0
- package/src/components/ModelViewer/joinAccess.ts +54 -0
- package/src/components/ModelViewer/malloyRunText.spec.ts +48 -0
- package/src/components/ModelViewer/malloyRunText.ts +51 -0
- package/src/components/ModelViewer/malloyText.spec.ts +47 -0
- package/src/components/ModelViewer/malloyText.ts +77 -0
- package/src/components/ModelViewer/modelGivens.ts +228 -0
- package/src/components/ModelViewer/modelGivensContext.ts +13 -0
- package/src/components/ModelViewer/modelHeaderPresentation.spec.ts +31 -0
- package/src/components/ModelViewer/modelHeaderPresentation.ts +41 -0
- package/src/components/ModelViewer/modelTextDeclarations.spec.ts +336 -0
- package/src/components/ModelViewer/modelTextDeclarations.ts +228 -0
- package/src/components/ModelViewer/modelTextParse.ts +112 -0
- package/src/components/ModelViewer/namedQueryCode.spec.ts +58 -0
- package/src/components/ModelViewer/namedQueryCode.ts +26 -0
- package/src/components/ModelViewer/offSurface.tsx +124 -0
- package/src/components/ModelViewer/rowLayers.tsx +104 -0
- package/src/components/ModelViewer/runGate.spec.ts +219 -0
- package/src/components/ModelViewer/runGate.ts +145 -0
- package/src/components/ModelViewer/schemaModel.defaultSource.spec.ts +126 -0
- package/src/components/ModelViewer/schemaModel.queries.spec.ts +37 -0
- package/src/components/ModelViewer/schemaModel.ts +300 -0
- package/src/components/ModelViewer/sectionOpenCommand.tsx +125 -0
- package/src/components/ModelViewer/sourceAccess.spec.ts +130 -0
- package/src/components/ModelViewer/sourceAccess.ts +194 -0
- package/src/components/ModelViewer/sourceLineage.spec.ts +73 -0
- package/src/components/ModelViewer/sourceLineage.ts +38 -0
- package/src/components/ModelViewer/sourcePicker.spec.ts +294 -0
- package/src/components/ModelViewer/sourcePicker.ts +162 -0
- package/src/components/ModelViewer/surface.ts +51 -0
- package/src/components/ModelViewer/text.tsx +33 -0
- package/src/components/ModelViewer/theme.spec.ts +38 -0
- package/src/components/ModelViewer/theme.ts +58 -0
- package/src/components/ModelViewer/tokens.ts +87 -0
- package/src/components/ModelViewer/ui.tsx +201 -0
- package/src/components/ModelViewer/useDimensionSamples.spec.tsx +139 -0
- package/src/components/ModelViewer/useDimensionSamples.ts +220 -0
- package/src/components/ModelViewer/useModelSources.spec.ts +110 -0
- package/src/components/ModelViewer/useModelSources.ts +238 -0
- package/src/components/ModelViewer/useRunQuery.spec.ts +50 -0
- package/src/components/ModelViewer/useRunQuery.ts +223 -0
- package/src/components/ReportBuilder/emptyStart.spec.ts +8 -0
- package/src/components/ReportBuilder/loadMalloy.ts +8 -1
- package/src/components/ServerProvider.tsx +27 -3
- package/src/components/filter/utils.ts +4 -60
- package/src/components/given/FilterButton.tsx +4 -1
- package/src/components/given/GivenInput.tsx +8 -0
- package/src/components/given/GivensPanel.tsx +6 -1
- package/src/components/given/filterSummary.spec.ts +31 -1
- package/src/components/given/filterSummary.ts +41 -19
- package/src/components/given/useGivenUrlParams.spec.tsx +32 -0
- package/src/components/given/useGivenUrlParams.ts +49 -14
- package/src/components/index.ts +6 -1
- package/src/components/legacy/malloynb/Notebook.spec.tsx +38 -4
- package/src/components/legacy/malloynb/NotebookCell.tsx +8 -2
- package/src/components/modelPage.spec.ts +79 -0
- package/src/components/modelPage.ts +48 -0
- package/src/hooks/useDimensionFilters.ts +3 -58
- package/src/hooks/useDimensionFiltersQuery.ts +3 -58
- package/src/hooks/useDimensionalFilterRangeData.spec.ts +57 -0
- package/src/hooks/useDimensionalFilterRangeData.ts +8 -63
- package/src/hooks/useSuggestOptions.dom.spec.ts +54 -1
- package/src/hooks/useSuggestOptions.spec.ts +71 -0
- package/src/hooks/useSuggestOptions.ts +102 -12
- package/src/utils/filterCondition.spec.ts +87 -0
- package/src/utils/filterCondition.ts +66 -0
- package/src/utils/malloyLiteral.spec.ts +53 -1
- package/src/utils/malloyLiteral.ts +47 -12
- package/dist/ServerProvider-BvD7PYZ7.cjs.js +0 -1
- package/dist/useCompiledDocument-CRhFBKv_.cjs.js +0 -142
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { Box, ButtonBase, Popover, Typography } from "@mui/material";
|
|
5
|
+
import type { ReactNode } from "react";
|
|
6
|
+
import { AccessPills, accessRowLabel } from "./AccessChips";
|
|
7
|
+
import { focusRingSx } from "./clickableBox";
|
|
8
|
+
import { withInlineCode } from "./HeaderBar";
|
|
9
|
+
import { IconColumn } from "./icons";
|
|
10
|
+
import { MODEL_SOURCES_HELP } from "./modelHeaderPresentation";
|
|
11
|
+
import { hasAccessRules, type SourceAccess } from "./sourceAccess";
|
|
12
|
+
import type { PickerDescription } from "./sourcePicker";
|
|
13
|
+
import { StatusPill } from "./StatusPill";
|
|
14
|
+
import { CaptionText } from "./text";
|
|
15
|
+
import { fontSizes, MONO_FONT_FAMILY, roles } from "./theme";
|
|
16
|
+
import { ACCENT } from "./tokens";
|
|
17
|
+
|
|
18
|
+
/** A source as this dropdown needs it: what to show. */
|
|
19
|
+
export interface SourceNavItem {
|
|
20
|
+
name: string;
|
|
21
|
+
/** The row's description, two lines at most: the source's `#(doc)`, else a
|
|
22
|
+
* host's summary, marked as generated (`pickerDescription`). */
|
|
23
|
+
description?: PickerDescription;
|
|
24
|
+
/** Hold the description's line: the source has no doc, and a host's
|
|
25
|
+
* summaries are still being read, so one may arrive. */
|
|
26
|
+
descriptionPending?: boolean;
|
|
27
|
+
/** "16 views · 37 fields · 4 joins" (`sourceMetaLine`), from the compiled model. */
|
|
28
|
+
meta: string;
|
|
29
|
+
/** The source the model opens on, when it has the most views: a quiet token. */
|
|
30
|
+
mostViews?: boolean;
|
|
31
|
+
/** The source's access declarations. A restricted source stays listed (a
|
|
32
|
+
* reader learns it exists, and that it is restricted), marked beside its
|
|
33
|
+
* name. */
|
|
34
|
+
access?: SourceAccess;
|
|
35
|
+
/** A host's chips after the source's name (`describePickerSource`). */
|
|
36
|
+
status?: ReactNode;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The header's line on the package's root `index.malloy`, whose sources are the curated set,
|
|
40
|
+
* when they are listed in its export order. */
|
|
41
|
+
export const CURATED_SOURCES_HELP =
|
|
42
|
+
"This package's curated sources, in the order its index.malloy exports them.";
|
|
43
|
+
|
|
44
|
+
/** The same, when the file's export order is unknown (its text withheld): it claims no order. */
|
|
45
|
+
export const PUBLIC_SOURCES_HELP = "This package's public sources.";
|
|
46
|
+
|
|
47
|
+
/** The words a row's accessible name adds for its tokens. */
|
|
48
|
+
function tokenRowLabel(source: SourceNavItem): string {
|
|
49
|
+
return source.mostViews ? ", most views" : "";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The sources of a model, as a dropdown hanging off the source picker pill
|
|
54
|
+
* beside the title ({@link import("./SourcesNav").SourcesNav}). A dropdown
|
|
55
|
+
* rather than a resident switcher: a model has a handful of sources and a
|
|
56
|
+
* reader settles into one, so the page stays in view and it closes on a click
|
|
57
|
+
* away.
|
|
58
|
+
*
|
|
59
|
+
* <p>Each row is what a reader needs to choose the source an analysis starts
|
|
60
|
+
* from: its name, its pills (the default's quiet **Most views**, access), two
|
|
61
|
+
* lines of description, and one line of counts, in `orderPickerSources`' order.
|
|
62
|
+
*/
|
|
63
|
+
export function SourcesDropdown({
|
|
64
|
+
anchorEl,
|
|
65
|
+
onClose,
|
|
66
|
+
sources,
|
|
67
|
+
currentName,
|
|
68
|
+
onPickSource,
|
|
69
|
+
curated = false,
|
|
70
|
+
exportOrdered = false,
|
|
71
|
+
}: {
|
|
72
|
+
/** The button this dropdown hangs from; null while closed. */
|
|
73
|
+
anchorEl: HTMLElement | null;
|
|
74
|
+
onClose: () => void;
|
|
75
|
+
sources: ReadonlyArray<SourceNavItem>;
|
|
76
|
+
currentName: string;
|
|
77
|
+
onPickSource: (name: string) => void;
|
|
78
|
+
/** The model is the package's root `index.malloy`: its header says these are the curated set. */
|
|
79
|
+
curated?: boolean;
|
|
80
|
+
/** The curated set is listed in the order its index.malloy exports it, so the header says so. */
|
|
81
|
+
exportOrdered?: boolean;
|
|
82
|
+
}) {
|
|
83
|
+
const open = Boolean(anchorEl);
|
|
84
|
+
return (
|
|
85
|
+
<Popover
|
|
86
|
+
open={open}
|
|
87
|
+
anchorEl={anchorEl}
|
|
88
|
+
onClose={onClose}
|
|
89
|
+
// Growing rightward from the pill beside the title.
|
|
90
|
+
anchorOrigin={{ vertical: "bottom", horizontal: "left" }}
|
|
91
|
+
transformOrigin={{ vertical: "top", horizontal: "left" }}
|
|
92
|
+
slotProps={{
|
|
93
|
+
paper: {
|
|
94
|
+
sx: {
|
|
95
|
+
width: 460,
|
|
96
|
+
maxWidth: "calc(100vw - 32px)",
|
|
97
|
+
maxHeight: "min(70vh, 560px)",
|
|
98
|
+
display: "flex",
|
|
99
|
+
flexDirection: "column",
|
|
100
|
+
borderRadius: "10px",
|
|
101
|
+
},
|
|
102
|
+
"data-testid": "model-sources-dropdown",
|
|
103
|
+
} as object,
|
|
104
|
+
}}
|
|
105
|
+
>
|
|
106
|
+
<Box
|
|
107
|
+
sx={{
|
|
108
|
+
px: 2,
|
|
109
|
+
pt: 1.5,
|
|
110
|
+
pb: 1,
|
|
111
|
+
borderBottom: 1,
|
|
112
|
+
borderColor: "divider",
|
|
113
|
+
}}
|
|
114
|
+
>
|
|
115
|
+
<Typography variant="subtitle2" component="h2" sx={{ m: 0 }}>
|
|
116
|
+
Sources
|
|
117
|
+
</Typography>
|
|
118
|
+
<CaptionText component="p" sx={{ m: 0 }}>
|
|
119
|
+
{curated
|
|
120
|
+
? exportOrdered
|
|
121
|
+
? CURATED_SOURCES_HELP
|
|
122
|
+
: PUBLIC_SOURCES_HELP
|
|
123
|
+
: MODEL_SOURCES_HELP}
|
|
124
|
+
</CaptionText>
|
|
125
|
+
</Box>
|
|
126
|
+
<Box sx={{ overflowY: "auto", py: 0.5 }}>
|
|
127
|
+
{sources.length === 0 ? (
|
|
128
|
+
<Typography
|
|
129
|
+
variant="body2"
|
|
130
|
+
color="text.secondary"
|
|
131
|
+
sx={{ py: 4, textAlign: "center" }}
|
|
132
|
+
>
|
|
133
|
+
This model defines no sources.
|
|
134
|
+
</Typography>
|
|
135
|
+
) : (
|
|
136
|
+
sources.map((source) => {
|
|
137
|
+
const current = source.name === currentName;
|
|
138
|
+
return (
|
|
139
|
+
<ButtonBase
|
|
140
|
+
key={`source:${source.name}`}
|
|
141
|
+
data-item-name={source.name}
|
|
142
|
+
aria-label={`Open source ${source.name}${tokenRowLabel(source)}${accessRowLabel(source.access)}`}
|
|
143
|
+
aria-current={current || undefined}
|
|
144
|
+
onClick={() => {
|
|
145
|
+
// Selecting with the dropdown still mounted would leave
|
|
146
|
+
// it covering the source it just opened.
|
|
147
|
+
onClose();
|
|
148
|
+
onPickSource(source.name);
|
|
149
|
+
}}
|
|
150
|
+
sx={{
|
|
151
|
+
display: "flex",
|
|
152
|
+
width: "100%",
|
|
153
|
+
alignItems: "flex-start",
|
|
154
|
+
justifyContent: "flex-start",
|
|
155
|
+
textAlign: "left",
|
|
156
|
+
gap: 1.25,
|
|
157
|
+
px: 2,
|
|
158
|
+
py: 1,
|
|
159
|
+
bgcolor: current
|
|
160
|
+
? roles.background.muted
|
|
161
|
+
: undefined,
|
|
162
|
+
"&:hover": {
|
|
163
|
+
bgcolor: current
|
|
164
|
+
? roles.background.strong
|
|
165
|
+
: roles.background.muted,
|
|
166
|
+
},
|
|
167
|
+
...focusRingSx,
|
|
168
|
+
}}
|
|
169
|
+
>
|
|
170
|
+
<Box
|
|
171
|
+
component="span"
|
|
172
|
+
aria-hidden
|
|
173
|
+
sx={{
|
|
174
|
+
color: ACCENT.steel.main,
|
|
175
|
+
display: "inline-flex",
|
|
176
|
+
pt: "2px",
|
|
177
|
+
}}
|
|
178
|
+
>
|
|
179
|
+
<IconColumn size={16} />
|
|
180
|
+
</Box>
|
|
181
|
+
<Box component="span" sx={{ minWidth: 0, flex: 1 }}>
|
|
182
|
+
<Box
|
|
183
|
+
component="span"
|
|
184
|
+
sx={{
|
|
185
|
+
display: "flex",
|
|
186
|
+
alignItems: "center",
|
|
187
|
+
flexWrap: "wrap",
|
|
188
|
+
gap: 1,
|
|
189
|
+
}}
|
|
190
|
+
>
|
|
191
|
+
<Box
|
|
192
|
+
component="span"
|
|
193
|
+
sx={{
|
|
194
|
+
fontFamily: MONO_FONT_FAMILY,
|
|
195
|
+
fontSize: fontSizes.body,
|
|
196
|
+
fontWeight: 500,
|
|
197
|
+
color: "text.primary",
|
|
198
|
+
}}
|
|
199
|
+
>
|
|
200
|
+
{source.name}
|
|
201
|
+
</Box>
|
|
202
|
+
{source.mostViews && (
|
|
203
|
+
<StatusPill
|
|
204
|
+
tone="quiet"
|
|
205
|
+
sx={{ alignSelf: "center" }}
|
|
206
|
+
>
|
|
207
|
+
{MOST_VIEWS_LABEL}
|
|
208
|
+
</StatusPill>
|
|
209
|
+
)}
|
|
210
|
+
{hasAccessRules(source.access) && (
|
|
211
|
+
<AccessPills access={source.access} />
|
|
212
|
+
)}
|
|
213
|
+
{source.status}
|
|
214
|
+
</Box>
|
|
215
|
+
{(source.description ||
|
|
216
|
+
source.descriptionPending) && (
|
|
217
|
+
<Box
|
|
218
|
+
component="span"
|
|
219
|
+
sx={{
|
|
220
|
+
display: "-webkit-box",
|
|
221
|
+
WebkitBoxOrient: "vertical",
|
|
222
|
+
WebkitLineClamp: 2,
|
|
223
|
+
overflow: "hidden",
|
|
224
|
+
mt: 0.25,
|
|
225
|
+
fontSize: fontSizes.small,
|
|
226
|
+
color: "text.secondary",
|
|
227
|
+
minHeight: !source.description
|
|
228
|
+
? "1.4em"
|
|
229
|
+
: undefined,
|
|
230
|
+
}}
|
|
231
|
+
>
|
|
232
|
+
{source.description?.generated && (
|
|
233
|
+
<StatusPill
|
|
234
|
+
tone="quiet"
|
|
235
|
+
data-testid="model-sources-summary-generated"
|
|
236
|
+
sx={{
|
|
237
|
+
mr: 0.75,
|
|
238
|
+
verticalAlign: "baseline",
|
|
239
|
+
}}
|
|
240
|
+
>
|
|
241
|
+
Generated
|
|
242
|
+
</StatusPill>
|
|
243
|
+
)}
|
|
244
|
+
{source.description &&
|
|
245
|
+
withInlineCode(source.description.text)}
|
|
246
|
+
</Box>
|
|
247
|
+
)}
|
|
248
|
+
<CaptionText
|
|
249
|
+
data-testid="model-sources-row-meta"
|
|
250
|
+
sx={{ display: "block", mt: 0.25 }}
|
|
251
|
+
>
|
|
252
|
+
{source.meta}
|
|
253
|
+
</CaptionText>
|
|
254
|
+
</Box>
|
|
255
|
+
</ButtonBase>
|
|
256
|
+
);
|
|
257
|
+
})
|
|
258
|
+
)}
|
|
259
|
+
</Box>
|
|
260
|
+
</Popover>
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** The quiet token on the source a model opens on, when it has the most views. */
|
|
265
|
+
export const MOST_VIEWS_LABEL = "Most views";
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { IconDropdown } from "./icons";
|
|
6
|
+
import { PillButton } from "./ui";
|
|
7
|
+
import { SourcesDropdown, type SourceNavItem } from "./SourcesDropdown";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The model's source picker, beside the source's h1 ({@link import("./HeaderBar").HeaderBar})
|
|
11
|
+
* as the package page's version pill sits beside the package's ("v1.0.1 ▾"): the same
|
|
12
|
+
* `PillButton`, with the same props, so the two read as one family. Its face is the count —
|
|
13
|
+
* "2 sources ▾", or "4 public sources ▾" on the package's root `index.malloy`, whose sources
|
|
14
|
+
* are what the package publishes — and it opens the {@link SourcesDropdown} . The caller draws it only when there is something to switch to:
|
|
15
|
+
* more than one source. A model's named queries are rows on the page (QueriesGroup).
|
|
16
|
+
*
|
|
17
|
+
* <p>Reaching for it (pointer over, focus, a click) calls `onWarm`, which is when the
|
|
18
|
+
* picker's summaries are asked for (§7a).
|
|
19
|
+
*/
|
|
20
|
+
export function SourcesNav({
|
|
21
|
+
sources,
|
|
22
|
+
currentName,
|
|
23
|
+
countLabel,
|
|
24
|
+
onPickSource,
|
|
25
|
+
curated = false,
|
|
26
|
+
exportOrdered = false,
|
|
27
|
+
onWarm,
|
|
28
|
+
}: {
|
|
29
|
+
sources: ReadonlyArray<SourceNavItem>;
|
|
30
|
+
currentName: string;
|
|
31
|
+
/** The pill's face: "2 sources", "4 public sources" (`sourceCountLabel`). */
|
|
32
|
+
countLabel: string;
|
|
33
|
+
onPickSource: (name: string) => void;
|
|
34
|
+
/** The model is the package's root `index.malloy` (see SourcesDropdown). */
|
|
35
|
+
curated?: boolean;
|
|
36
|
+
/** Its sources are listed in the order its index.malloy exports them (see SourcesDropdown). */
|
|
37
|
+
exportOrdered?: boolean;
|
|
38
|
+
/** The reader is reaching for the picker: start what its rows will need. */
|
|
39
|
+
onWarm?: () => void;
|
|
40
|
+
}) {
|
|
41
|
+
const [anchor, setAnchor] = useState<HTMLElement | null>(null);
|
|
42
|
+
return (
|
|
43
|
+
<>
|
|
44
|
+
{/* The package page's version pill, prop for prop (PackagePage's title). */}
|
|
45
|
+
<PillButton
|
|
46
|
+
size="small"
|
|
47
|
+
variant="outlined"
|
|
48
|
+
onClick={(e) => {
|
|
49
|
+
onWarm?.();
|
|
50
|
+
setAnchor(e.currentTarget);
|
|
51
|
+
}}
|
|
52
|
+
endIcon={<IconDropdown size={20} />}
|
|
53
|
+
// The visible text first (§7 "A visible label is contained in the accessible
|
|
54
|
+
// name"), then what it means.
|
|
55
|
+
aria-label={`${countLabel}. Showing ${currentName}, one of the ${countLabel} in this model`}
|
|
56
|
+
aria-haspopup="dialog"
|
|
57
|
+
aria-expanded={Boolean(anchor)}
|
|
58
|
+
onPointerEnter={onWarm}
|
|
59
|
+
onFocus={onWarm}
|
|
60
|
+
sx={{ ml: 1, transition: "none" }}
|
|
61
|
+
>
|
|
62
|
+
{countLabel}
|
|
63
|
+
</PillButton>
|
|
64
|
+
<SourcesDropdown
|
|
65
|
+
anchorEl={anchor}
|
|
66
|
+
onClose={() => setAnchor(null)}
|
|
67
|
+
sources={sources}
|
|
68
|
+
currentName={currentName}
|
|
69
|
+
onPickSource={onPickSource}
|
|
70
|
+
curated={curated}
|
|
71
|
+
exportOrdered={exportOrdered}
|
|
72
|
+
/>
|
|
73
|
+
</>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import Box from "@mui/material/Box";
|
|
5
|
+
import CircularProgress from "@mui/material/CircularProgress";
|
|
6
|
+
import type { SxProps, Theme } from "@mui/material/styles";
|
|
7
|
+
import { forwardRef, type ReactNode } from "react";
|
|
8
|
+
import { roles, fontSizes, fontWeights } from "./theme";
|
|
9
|
+
import { MONO_FONT_FAMILY, SANS_FONT_FAMILY } from "./theme";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The one status/tag pill: fully rounded, tinted, borderless (the design
|
|
13
|
+
* system has no outlines). Two voices, chosen by what the text IS:
|
|
14
|
+
*
|
|
15
|
+
* - `state` — a human state word ("Indexed", "In scope", "Materialized",
|
|
16
|
+
* "Published"): sans, sentence case supplied by the caller.
|
|
17
|
+
* - `token` — a machine token that exists verbatim in code or config
|
|
18
|
+
* (`join_one`, `line_chart`): mono, rendered exactly as written.
|
|
19
|
+
*
|
|
20
|
+
* Every status the app shows is drawn by this component — a list row's
|
|
21
|
+
* annotation and a page header's state alike — so a "Ready" reads the same
|
|
22
|
+
* wherever it sits, at ONE size: a header's state is the same pill as a row's,
|
|
23
|
+
* centered in the header's 28px row, so two states side by side never differ
|
|
24
|
+
* in scale. A host's own states (`renderSourceStatus`, `renderFieldStatus`)
|
|
25
|
+
* read best drawn with it too.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* A pill reports a state, and there are four a reader acts on differently. The
|
|
29
|
+
* first two are the labels: `neutral` names a thing, `positive` says it is good.
|
|
30
|
+
*
|
|
31
|
+
* `warning` and `negative` are for a state that is degraded — data that is out
|
|
32
|
+
* of date, or something that failed outright — which the reader needs to see
|
|
33
|
+
* WITHOUT opening the row. Reach for them only where the state is genuinely degraded — a join
|
|
34
|
+
* relationship (`join_one`) is not a warning, so it takes no warm tone.
|
|
35
|
+
*/
|
|
36
|
+
/** `info`: work under way, with its spinner (`busy`). */
|
|
37
|
+
export type StatusPillTone =
|
|
38
|
+
| "positive"
|
|
39
|
+
| "neutral"
|
|
40
|
+
| "warning"
|
|
41
|
+
| "negative"
|
|
42
|
+
| "quiet"
|
|
43
|
+
| "info";
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Where the pill sits: a row's annotation (`inline`) or a page or panel header's state
|
|
47
|
+
* (`header`). The same pill either way; the size names the place, not a scale.
|
|
48
|
+
*/
|
|
49
|
+
export type StatusPillSize = "inline" | "header";
|
|
50
|
+
|
|
51
|
+
const TONES: Record<StatusPillTone, { bg?: string; fg?: string }> = {
|
|
52
|
+
positive: { bg: roles.accent.sage.tint, fg: roles.accent.sage.onTint },
|
|
53
|
+
neutral: { bg: roles.background.strong, fg: roles.text.secondary },
|
|
54
|
+
warning: { bg: roles.warning.tint, fg: roles.warning.onTint },
|
|
55
|
+
negative: { bg: roles.error.tint, fg: roles.error.onTint },
|
|
56
|
+
info: { bg: roles.info.tint, fg: roles.info.onTint },
|
|
57
|
+
// A descriptor, not a state: a field's type, its "inherited", its display
|
|
58
|
+
// tags. A step lighter than `neutral` so the states beside it (Indexed,
|
|
59
|
+
// Given, Restricted) read first. Secondary text, not tertiary: tertiary on
|
|
60
|
+
// this fill is 4.34:1 in light, under AA for micro text.
|
|
61
|
+
quiet: { bg: roles.background.muted, fg: roles.text.secondary },
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
interface StatusPillProps {
|
|
65
|
+
tone?: StatusPillTone;
|
|
66
|
+
voice?: "state" | "token";
|
|
67
|
+
size?: StatusPillSize;
|
|
68
|
+
children: ReactNode;
|
|
69
|
+
sx?: SxProps<Theme>;
|
|
70
|
+
/**
|
|
71
|
+
* Accessibility passthrough to the rendered span. Declared rather than left
|
|
72
|
+
* to `...rest` because only one of the two was actually being type-checked:
|
|
73
|
+
* TypeScript skips JSX attributes containing a hyphen, so `aria-label` was
|
|
74
|
+
* always accepted while `role` was rejected — and an `aria-label` without a
|
|
75
|
+
* role is exactly the combination screen readers ignore.
|
|
76
|
+
*/
|
|
77
|
+
role?: string;
|
|
78
|
+
"aria-label"?: string;
|
|
79
|
+
/** A tab stop, for a pill whose tooltip must reach a keyboard (guide §7). */
|
|
80
|
+
tabIndex?: number;
|
|
81
|
+
/** Work in flight: a spinner before the label. */
|
|
82
|
+
busy?: boolean;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export const StatusPill = forwardRef<HTMLSpanElement, StatusPillProps>(
|
|
86
|
+
function StatusPill(
|
|
87
|
+
{
|
|
88
|
+
tone = "neutral",
|
|
89
|
+
voice = "state",
|
|
90
|
+
size = "inline",
|
|
91
|
+
busy = false,
|
|
92
|
+
children,
|
|
93
|
+
sx,
|
|
94
|
+
...rest
|
|
95
|
+
},
|
|
96
|
+
ref,
|
|
97
|
+
) {
|
|
98
|
+
const { bg, fg } = TONES[tone];
|
|
99
|
+
const fontSize = fontSizes.micro;
|
|
100
|
+
return (
|
|
101
|
+
<Box
|
|
102
|
+
ref={ref}
|
|
103
|
+
component="span"
|
|
104
|
+
// A hook for a container that tints on hover (a model row) to lift a
|
|
105
|
+
// quiet pill a step, so it never sinks into the same grey.
|
|
106
|
+
data-pill-tone={tone}
|
|
107
|
+
// Where it sits (a row or a header), for a container or a test to select on;
|
|
108
|
+
// it does not change the pill.
|
|
109
|
+
data-pill-placement={size}
|
|
110
|
+
{...rest}
|
|
111
|
+
sx={[
|
|
112
|
+
{
|
|
113
|
+
display: "inline-flex",
|
|
114
|
+
alignItems: "center",
|
|
115
|
+
gap: busy ? "4px" : 0,
|
|
116
|
+
padding: "2px 8px",
|
|
117
|
+
borderRadius: "999px",
|
|
118
|
+
bgcolor: bg,
|
|
119
|
+
color: fg,
|
|
120
|
+
flexShrink: 0,
|
|
121
|
+
whiteSpace: "nowrap",
|
|
122
|
+
...(voice === "token"
|
|
123
|
+
? { fontFamily: MONO_FONT_FAMILY, fontSize }
|
|
124
|
+
: {
|
|
125
|
+
fontFamily: SANS_FONT_FAMILY,
|
|
126
|
+
fontSize,
|
|
127
|
+
fontWeight: fontWeights.strong,
|
|
128
|
+
}),
|
|
129
|
+
},
|
|
130
|
+
...(Array.isArray(sx) ? sx : [sx]),
|
|
131
|
+
]}
|
|
132
|
+
>
|
|
133
|
+
{busy && (
|
|
134
|
+
<CircularProgress
|
|
135
|
+
size={9}
|
|
136
|
+
thickness={5}
|
|
137
|
+
sx={{ color: "info.main", flexShrink: 0 }}
|
|
138
|
+
aria-hidden
|
|
139
|
+
/>
|
|
140
|
+
)}
|
|
141
|
+
{children}
|
|
142
|
+
</Box>
|
|
143
|
+
);
|
|
144
|
+
},
|
|
145
|
+
);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { Box } from "@mui/material";
|
|
5
|
+
import type { ReactNode } from "react";
|
|
6
|
+
import { MONO_FONT_FAMILY, fontSizes, roles } from "./theme";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A single data VALUE — a sample from a dimension's index — as a **grey,
|
|
10
|
+
* outlined, gently-rounded rectangle**, deliberately unlike every other chip on
|
|
11
|
+
* these surfaces (the borderless, fully-rounded, semantically- or
|
|
12
|
+
* neutrally-toned pills the Base/Declarations/Platform layers use). A sample
|
|
13
|
+
* value is neither a layer status nor an annotation; it is raw data pulled from
|
|
14
|
+
* the warehouse, so it gets its own bordered-box vocabulary rather than reading
|
|
15
|
+
* as one more layer pill.
|
|
16
|
+
*
|
|
17
|
+
* <p>Mono, because a value is a literal that exists verbatim in the data (like
|
|
18
|
+
* the identifiers elsewhere here). On theme tokens (`action.hover` / `divider` /
|
|
19
|
+
* `text.primary`), no raw hex.
|
|
20
|
+
*/
|
|
21
|
+
export function ValueChip({ children }: { children: ReactNode }) {
|
|
22
|
+
return (
|
|
23
|
+
<Box
|
|
24
|
+
component="span"
|
|
25
|
+
sx={{
|
|
26
|
+
fontFamily: MONO_FONT_FAMILY,
|
|
27
|
+
fontSize: fontSizes.caption,
|
|
28
|
+
color: "text.primary",
|
|
29
|
+
bgcolor: roles.background.muted,
|
|
30
|
+
border: "1px solid",
|
|
31
|
+
borderColor: "divider",
|
|
32
|
+
borderRadius: 1,
|
|
33
|
+
padding: "2px 8px",
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
36
|
+
{children}
|
|
37
|
+
</Box>
|
|
38
|
+
);
|
|
39
|
+
}
|