@malloy-publisher/sdk 0.0.382-dev → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +115 -95
- package/TREE_SHAKING.md +16 -11
- package/bunfig.toml +7 -0
- package/dist/ServerProvider-Cn_LhKda.cjs.js +1 -0
- package/dist/ServerProvider-sfabtriY.es.js +4076 -0
- package/dist/client/api.d.ts +3773 -1515
- package/dist/client/configuration.d.ts +1 -1
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.es.js +86 -59
- package/dist/components/Connections/EditConnectionDialog.d.ts +2 -1
- package/dist/components/Connections/common.d.ts +8 -2
- package/dist/components/Dashboard/Dashboard.d.ts +62 -0
- package/dist/components/Dashboard/DashboardTile.d.ts +57 -0
- package/dist/components/Dashboard/index.d.ts +2 -0
- package/dist/components/DataAppViewer/DataAppViewer.d.ts +23 -0
- package/dist/components/DataAppViewer/index.d.ts +1 -0
- package/dist/components/Environment/Environment.d.ts +6 -0
- package/dist/components/Environment/index.d.ts +2 -0
- package/dist/components/Home/AddEnvironmentDialog.d.ts +1 -0
- package/dist/components/Home/DeleteEnvironmentDialog.d.ts +5 -0
- package/dist/components/Home/EditEnvironmentDialog.d.ts +7 -0
- package/dist/components/Home/Home.d.ts +2 -2
- package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +14 -0
- package/dist/components/Materializations/CreateMaterializationDialog.d.ts +10 -0
- package/dist/components/Materializations/DeleteMaterializationDialog.d.ts +7 -0
- package/dist/components/Materializations/EnvironmentMaterializations.d.ts +7 -0
- package/dist/components/Materializations/ManifestView.d.ts +13 -0
- package/dist/components/Materializations/MaterializationDetailDialog.d.ts +9 -0
- package/dist/components/Materializations/MaterializationRunsList.d.ts +15 -0
- package/dist/components/Materializations/Materializations.d.ts +7 -0
- package/dist/components/Materializations/ScheduleCard.d.ts +20 -0
- package/dist/components/Materializations/SectionLabel.d.ts +10 -0
- package/dist/components/Materializations/SetScheduleDialog.d.ts +11 -0
- package/dist/components/Materializations/TriggerChip.d.ts +10 -0
- package/dist/components/Materializations/cron.d.ts +23 -0
- package/dist/components/Materializations/index.d.ts +2 -0
- package/dist/components/Materializations/utils.d.ts +46 -0
- package/dist/components/Notebook/Notebook.d.ts +47 -4
- package/dist/components/Notebook/NotebookCell.d.ts +37 -1
- package/dist/components/Notebook/runPlan.d.ts +29 -0
- package/dist/components/Notebook/types.d.ts +10 -0
- package/dist/components/Package/ContentTypeIcon.d.ts +31 -0
- package/dist/components/Package/Package.d.ts +1 -4
- package/dist/components/RenderedResult/RenderedResult.d.ts +7 -1
- package/dist/components/RenderedResult/ResultContainer.d.ts +5 -1
- package/dist/components/RenderedResult/renderLogs.d.ts +6 -0
- package/dist/components/ResultsDialog.d.ts +6 -1
- package/dist/components/ServerProvider.d.ts +28 -4
- package/dist/components/click_helper.d.ts +10 -1
- package/dist/components/drill/index.d.ts +3 -0
- package/dist/components/drill/markDrillableCells.d.ts +55 -0
- package/dist/components/drill/resolveDrill.d.ts +139 -0
- package/dist/components/drill/useDrill.d.ts +63 -0
- package/dist/components/given/GivenInput.d.ts +52 -0
- package/dist/components/given/GivensPanel.d.ts +47 -0
- package/dist/components/given/filterValue.d.ts +97 -0
- package/dist/components/given/index.d.ts +2 -0
- package/dist/components/given/paramCodec.d.ts +60 -0
- package/dist/components/given/utils.d.ts +17 -0
- package/dist/components/highlighter.d.ts +6 -1
- package/dist/components/index.d.ts +7 -2
- package/dist/components/styles.d.ts +47 -0
- package/dist/constants/docLinks.d.ts +12 -0
- package/dist/{core-YNpOLuB1.cjs.js → core-CqRKhtoy.cjs.js} +1 -1
- package/dist/{core-CjeTkq8O.es.js → core-DyU47reh.es.js} +1 -1
- package/dist/github-dark-BKL9xNgN.cjs.js +1 -0
- package/dist/github-dark-DenFmJkN.es.js +4 -0
- package/dist/hooks/givenValue.d.ts +10 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/useDimensionFiltersFromSpec.d.ts +3 -3
- package/dist/hooks/useDimensionFiltersQuery.d.ts +3 -3
- package/dist/hooks/useDimensionalFilterRangeData.d.ts +4 -4
- package/dist/hooks/useGivensState.d.ts +64 -0
- package/dist/hooks/useModelGivens.d.ts +10 -0
- package/dist/hooks/useSuggestOptions.d.ts +78 -0
- package/dist/{index-DRDu9kIV.es.js → index-CAkFE4Ol.es.js} +41278 -28504
- package/dist/index-DD4b_bt0.cjs.js +356 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.es.js +79 -48
- package/dist/malloy-explorer.css +12 -1
- package/dist/sdk.css +1 -1
- package/dist/theme/ThemeContext.d.ts +45 -0
- package/dist/theme/buildMalloyExplicitTheme.d.ts +34 -0
- package/dist/theme/buildTableCssVars.d.ts +41 -0
- package/dist/theme/buildVegaThemeOverride.d.ts +16 -0
- package/dist/theme/defaults.d.ts +7 -0
- package/dist/theme/index.d.ts +8 -0
- package/dist/theme/keys.d.ts +20 -0
- package/dist/theme/readChartAnnotations.d.ts +23 -0
- package/dist/theme/resolveTheme.d.ts +22 -0
- package/dist/theme/types.d.ts +70 -0
- package/dist/utils/dataAppEmbed.d.ts +44 -0
- package/dist/utils/formatting.d.ts +1 -1
- package/dist/utils/malloyString.d.ts +7 -0
- package/dist/utils/parsing.d.ts +2 -2
- package/dist/utils/queryClient.d.ts +5 -0
- package/package.json +19 -8
- package/src/client-entry.ts +3 -0
- package/src/components/AnalyzePackageButton.tsx +9 -3
- package/src/components/ApiErrorDisplay.tsx +3 -0
- package/src/components/Connections/AddConnectionDialog.tsx +132 -25
- package/src/components/Connections/DeleteConnectionDialog.tsx +14 -3
- package/src/components/Connections/EditConnectionDialog.tsx +167 -37
- package/src/components/Connections/common.ts +94 -3
- package/src/components/DOMElement/DOMElement.tsx +3 -0
- package/src/components/DOMElement/index.ts +3 -0
- package/src/components/Dashboard/Dashboard.spec.tsx +216 -0
- package/src/components/Dashboard/Dashboard.tsx +458 -0
- package/src/components/Dashboard/DashboardTile.spec.tsx +81 -0
- package/src/components/Dashboard/DashboardTile.tsx +199 -0
- package/src/components/Dashboard/index.ts +5 -0
- package/src/components/Dashboard/tileGridColumn.spec.ts +35 -0
- package/src/components/DataAppViewer/DataAppViewer.tsx +214 -0
- package/src/components/DataAppViewer/index.ts +4 -0
- package/src/components/{Project → Environment}/About.tsx +11 -4
- package/src/components/Environment/AddPackageDialog.tsx +202 -0
- package/src/components/{Project → Environment}/ConnectionExplorer.tsx +17 -14
- package/src/components/Environment/Connections.tsx +391 -0
- package/src/components/{Project → Environment}/DeletePackageDialog.tsx +8 -4
- package/src/components/{Project → Environment}/EditPackageDialog.tsx +21 -13
- package/src/components/Environment/Environment.tsx +89 -0
- package/src/components/Environment/Packages.tsx +206 -0
- package/src/components/Environment/index.ts +5 -0
- package/src/components/Home/{AddProjectDialog.tsx → AddEnvironmentDialog.tsx} +25 -19
- package/src/components/Home/{DeleteProjectDialog.tsx → DeleteEnvironmentDialog.tsx} +20 -15
- package/src/components/Home/{EditProjectDialog.tsx → EditEnvironmentDialog.tsx} +35 -28
- package/src/components/Home/Home.tsx +386 -408
- package/src/components/Home/index.ts +3 -0
- package/src/components/Loading.tsx +3 -0
- package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +179 -0
- package/src/components/Materializations/CreateMaterializationDialog.tsx +112 -0
- package/src/components/Materializations/DeleteMaterializationDialog.tsx +109 -0
- package/src/components/Materializations/EnvironmentMaterializations.tsx +267 -0
- package/src/components/Materializations/ManifestView.tsx +87 -0
- package/src/components/Materializations/MaterializationDetailDialog.tsx +259 -0
- package/src/components/Materializations/MaterializationRunsList.tsx +256 -0
- package/src/components/Materializations/Materializations.tsx +355 -0
- package/src/components/Materializations/ScheduleCard.tsx +231 -0
- package/src/components/Materializations/SectionLabel.tsx +30 -0
- package/src/components/Materializations/SetScheduleDialog.tsx +162 -0
- package/src/components/Materializations/TriggerChip.tsx +44 -0
- package/src/components/Materializations/cron.ts +124 -0
- package/src/components/Materializations/index.ts +5 -0
- package/src/components/Materializations/utils.ts +145 -0
- package/src/components/Model/Model.tsx +44 -2
- package/src/components/Model/ModelCell.tsx +14 -5
- package/src/components/Model/ModelExplorer.tsx +3 -0
- package/src/components/Model/ModelExplorerDialog.tsx +4 -1
- package/src/components/Model/SourcesExplorer.tsx +9 -6
- package/src/components/Model/index.ts +3 -0
- package/src/components/Model/useModelData.ts +6 -3
- package/src/components/Notebook/Notebook.spec.tsx +88 -0
- package/src/components/Notebook/Notebook.tsx +476 -339
- package/src/components/Notebook/NotebookCell.tsx +264 -25
- package/src/components/Notebook/index.ts +3 -0
- package/src/components/Notebook/runPlan.spec.ts +155 -0
- package/src/components/Notebook/runPlan.ts +67 -0
- package/src/components/Notebook/types.ts +14 -0
- package/src/components/Package/ContentTypeIcon.spec.ts +91 -0
- package/src/components/Package/ContentTypeIcon.tsx +177 -0
- package/src/components/Package/FileTreeView.tsx +3 -0
- package/src/components/Package/Models.tsx +7 -4
- package/src/components/Package/Package.spec.tsx +113 -0
- package/src/components/Package/Package.tsx +692 -59
- package/src/components/Package/index.ts +3 -0
- package/src/components/QueryResult/QueryResult.tsx +17 -8
- package/src/components/QueryResult/index.ts +3 -0
- package/src/components/RenderedResult/RenderedResult.tsx +725 -67
- package/src/components/RenderedResult/ResultContainer.tsx +71 -2
- package/src/components/RenderedResult/index.ts +3 -0
- package/src/components/RenderedResult/renderLogs.spec.ts +58 -0
- package/src/components/RenderedResult/renderLogs.ts +43 -0
- package/src/components/ResultsDialog.tsx +13 -1
- package/src/components/ServerProvider.tsx +175 -51
- package/src/components/Workbook/BrowserWorkbookStorage.ts +3 -0
- package/src/components/Workbook/EditableMalloyCell.tsx +3 -0
- package/src/components/Workbook/ModelPicker.tsx +7 -4
- package/src/components/Workbook/MutableCell.tsx +10 -5
- package/src/components/Workbook/Workbook.tsx +8 -5
- package/src/components/Workbook/WorkbookList.tsx +3 -0
- package/src/components/Workbook/WorkbookManager.ts +3 -0
- package/src/components/Workbook/WorkbookStorage.ts +3 -0
- package/src/components/Workbook/WorkbookStorageProvider.tsx +3 -0
- package/src/components/Workbook/index.ts +3 -0
- package/src/components/click_helper.ts +17 -1
- package/src/components/drill/index.ts +28 -0
- package/src/components/drill/markDrillableCells.dom.spec.ts +313 -0
- package/src/components/drill/markDrillableCells.spec.ts +109 -0
- package/src/components/drill/markDrillableCells.ts +314 -0
- package/src/components/drill/resolveDrill.spec.ts +449 -0
- package/src/components/drill/resolveDrill.ts +375 -0
- package/src/components/drill/useDrill.tsx +203 -0
- package/src/components/filter/DimensionFilter.tsx +3 -0
- package/src/components/filter/index.ts +3 -0
- package/src/components/filter/utils.ts +16 -5
- package/src/components/given/GivenInput.spec.tsx +689 -0
- package/src/components/given/GivenInput.tsx +801 -0
- package/src/components/given/GivensPanel.spec.tsx +175 -0
- package/src/components/given/GivensPanel.tsx +195 -0
- package/src/components/given/filterValue.spec.ts +364 -0
- package/src/components/given/filterValue.ts +207 -0
- package/src/components/given/index.ts +9 -0
- package/src/components/given/paramCodec.spec.ts +857 -0
- package/src/components/given/paramCodec.ts +483 -0
- package/src/components/given/utils.spec.ts +60 -0
- package/src/components/given/utils.ts +79 -0
- package/src/components/highlighter.ts +22 -5
- package/src/components/index.ts +10 -2
- package/src/components/styles.ts +82 -33
- package/src/constants/docLinks.spec.ts +54 -0
- package/src/constants/docLinks.ts +46 -0
- package/src/hooks/givenValue.ts +13 -0
- package/src/hooks/index.ts +13 -0
- package/src/hooks/useDimensionFilters.ts +4 -7
- package/src/hooks/useDimensionFiltersFromSpec.ts +8 -5
- package/src/hooks/useDimensionFiltersQuery.ts +10 -13
- package/src/hooks/useDimensionalFilterRangeData.ts +11 -14
- package/src/hooks/useGivensState.spec.ts +449 -0
- package/src/hooks/useGivensState.ts +340 -0
- package/src/hooks/useModelGivens.ts +29 -0
- package/src/hooks/useQueryWithApiError.ts +3 -0
- package/src/hooks/useRawQueryData.ts +6 -3
- package/src/hooks/useSuggestOptions.dom.spec.ts +91 -0
- package/src/hooks/useSuggestOptions.spec.ts +112 -0
- package/src/hooks/useSuggestOptions.ts +268 -0
- package/src/index.ts +10 -1
- package/src/react-app-env.d.ts +3 -0
- package/src/theme/ThemeContext.tsx +86 -0
- package/src/theme/buildMalloyExplicitTheme.ts +61 -0
- package/src/theme/buildTableCssVars.spec.ts +86 -0
- package/src/theme/buildTableCssVars.ts +98 -0
- package/src/theme/buildVegaThemeOverride.spec.ts +56 -0
- package/src/theme/buildVegaThemeOverride.ts +47 -0
- package/src/theme/defaults.ts +78 -0
- package/src/theme/index.ts +11 -0
- package/src/theme/keys.ts +32 -0
- package/src/theme/readChartAnnotations.spec.ts +58 -0
- package/src/theme/readChartAnnotations.ts +69 -0
- package/src/theme/resolveTheme.spec.ts +160 -0
- package/src/theme/resolveTheme.ts +121 -0
- package/src/theme/types.ts +79 -0
- package/src/utils/dataAppEmbed.spec.ts +63 -0
- package/src/utils/dataAppEmbed.ts +84 -0
- package/src/utils/formatting.spec.ts +25 -21
- package/src/utils/formatting.ts +11 -7
- package/src/utils/malloyString.spec.ts +24 -0
- package/src/utils/malloyString.ts +12 -0
- package/src/utils/parsing.spec.ts +26 -19
- package/src/utils/parsing.ts +11 -6
- package/src/utils/queryClient.ts +17 -0
- package/test/README.md +185 -0
- package/test/serverProvider.tsx +72 -0
- package/test/setup.ts +29 -0
- package/tsconfig.json +12 -1
- package/tsconfig.spec.json +22 -0
- package/vite.config.ts +3 -0
- package/dist/ServerProvider-lOQXDlqB.cjs.js +0 -1
- package/dist/ServerProvider-on-8FH5Z.es.js +0 -3060
- package/dist/components/Home/AddProjectDialog.d.ts +0 -1
- package/dist/components/Home/DeleteProjectDialog.d.ts +0 -5
- package/dist/components/Home/EditProjectDialog.d.ts +0 -7
- package/dist/components/Package/Config.d.ts +0 -5
- package/dist/components/Package/Databases.d.ts +0 -5
- package/dist/components/Package/Notebooks.d.ts +0 -6
- package/dist/components/Project/Project.d.ts +0 -6
- package/dist/components/Project/index.d.ts +0 -2
- package/dist/index-BOLBP6_i.cjs.js +0 -233
- package/src/components/Package/Config.tsx +0 -97
- package/src/components/Package/Connections.tsx +0 -373
- package/src/components/Package/Databases.tsx +0 -228
- package/src/components/Package/Notebooks.tsx +0 -77
- package/src/components/Project/AddPackageDialog.tsx +0 -159
- package/src/components/Project/Packages.tsx +0 -191
- package/src/components/Project/Project.tsx +0 -52
- package/src/components/Project/index.ts +0 -2
- /package/dist/components/{Project → Environment}/About.d.ts +0 -0
- /package/dist/components/{Project → Environment}/AddPackageDialog.d.ts +0 -0
- /package/dist/components/{Project → Environment}/ConnectionExplorer.d.ts +0 -0
- /package/dist/components/{Package → Environment}/Connections.d.ts +0 -0
- /package/dist/components/{Project → Environment}/DeletePackageDialog.d.ts +0 -0
- /package/dist/components/{Project → Environment}/EditPackageDialog.d.ts +0 -0
- /package/dist/components/{Project → Environment}/Packages.d.ts +0 -0
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
1
4
|
// TODO(jjs) - Export to .malloynb
|
|
2
5
|
// TOOD(jjs) - Import via Publisher API that parses whole NB
|
|
3
6
|
|
|
@@ -45,7 +48,7 @@ export default function Workbook({ workbookPath, resourceUri }: WorkbookProps) {
|
|
|
45
48
|
const { server, getAccessToken } = useServer();
|
|
46
49
|
const { apiClients } = useServer();
|
|
47
50
|
const { workbookStorage } = useWorkbookStorage();
|
|
48
|
-
const {
|
|
51
|
+
const { environmentName, packageName } = parseResourceUri(resourceUri);
|
|
49
52
|
const [success, setSuccess] = React.useState<string | undefined>(undefined);
|
|
50
53
|
const [lastError, setLastError] = React.useState<string | undefined>(
|
|
51
54
|
undefined,
|
|
@@ -113,7 +116,7 @@ export default function Workbook({ workbookPath, resourceUri }: WorkbookProps) {
|
|
|
113
116
|
}
|
|
114
117
|
setDeleteDialogOpen(false);
|
|
115
118
|
// TODO(jjs) - on delete event
|
|
116
|
-
navigate(`/${
|
|
119
|
+
navigate(`/${environmentName}/${packageName}`);
|
|
117
120
|
};
|
|
118
121
|
|
|
119
122
|
const handleDeleteCancel = () => {
|
|
@@ -155,7 +158,7 @@ export default function Workbook({ workbookPath, resourceUri }: WorkbookProps) {
|
|
|
155
158
|
console.log("Fetching model from Publisher", model);
|
|
156
159
|
promises.push(
|
|
157
160
|
apiClients.models
|
|
158
|
-
.getModel(
|
|
161
|
+
.getModel(environmentName, packageName, model, undefined)
|
|
159
162
|
.then((data) => ({
|
|
160
163
|
modelPath: model,
|
|
161
164
|
sourceInfos: data.data.sourceInfos.map((source) =>
|
|
@@ -182,7 +185,7 @@ export default function Workbook({ workbookPath, resourceUri }: WorkbookProps) {
|
|
|
182
185
|
fetchModels();
|
|
183
186
|
// This function cannot depend on sourceAndPaths because it would cause an infinite loop.
|
|
184
187
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
185
|
-
}, [getAccessToken, workbookData, packageName,
|
|
188
|
+
}, [getAccessToken, workbookData, packageName, environmentName, server]);
|
|
186
189
|
|
|
187
190
|
React.useEffect(() => {
|
|
188
191
|
if (!workbookPath) {
|
|
@@ -218,7 +221,7 @@ export default function Workbook({ workbookPath, resourceUri }: WorkbookProps) {
|
|
|
218
221
|
onClick={() => handleAddCell(isMarkdown, index)}
|
|
219
222
|
variant="contained"
|
|
220
223
|
sx={{
|
|
221
|
-
backgroundColor:
|
|
224
|
+
backgroundColor: (theme) => theme.palette.background.paper,
|
|
222
225
|
color: (theme) =>
|
|
223
226
|
theme.palette.mode === "dark"
|
|
224
227
|
? theme.palette.grey[100]
|
|
@@ -1,6 +1,22 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
1
4
|
import { useNavigate } from "react-router-dom";
|
|
2
5
|
import { MouseEvent } from "react";
|
|
3
6
|
|
|
7
|
+
/**
|
|
8
|
+
* The modifier state a navigation decision reads, and nothing more.
|
|
9
|
+
*
|
|
10
|
+
* Both React's synthetic mouse event and the DOM's satisfy it, which is the
|
|
11
|
+
* point. A click can reach navigation from a React handler, or from outside
|
|
12
|
+
* React entirely (a `# drill` click arrives from the Malloy renderer as a plain
|
|
13
|
+
* DOM event), and neither should have to be converted to the other first.
|
|
14
|
+
*/
|
|
15
|
+
export type NavigationClick = Pick<
|
|
16
|
+
MouseEvent,
|
|
17
|
+
"metaKey" | "ctrlKey" | "shiftKey" | "button"
|
|
18
|
+
>;
|
|
19
|
+
|
|
4
20
|
/**
|
|
5
21
|
* Custom hook that returns a function for handling clicks with proper modifier key support.
|
|
6
22
|
* The returned function handles CMD/Ctrl clicks to open in new tabs, regular clicks for navigation.
|
|
@@ -10,7 +26,7 @@ import { MouseEvent } from "react";
|
|
|
10
26
|
export function useRouterClickHandler() {
|
|
11
27
|
const navigate = useNavigate();
|
|
12
28
|
|
|
13
|
-
return (to: string, event?:
|
|
29
|
+
return (to: string, event?: NavigationClick) => {
|
|
14
30
|
// If no event or no modifier keys, use normal navigation
|
|
15
31
|
if (
|
|
16
32
|
!event ||
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
export {
|
|
5
|
+
DRILL_CELL_CLASS,
|
|
6
|
+
drillableFieldNames,
|
|
7
|
+
markDrillableCells,
|
|
8
|
+
type DrillMetadataSource,
|
|
9
|
+
} from "./markDrillableCells";
|
|
10
|
+
export {
|
|
11
|
+
DRILL_SELF,
|
|
12
|
+
drillDestinations,
|
|
13
|
+
drillValueToFilter,
|
|
14
|
+
encodeDrillValue,
|
|
15
|
+
humanizeSlug,
|
|
16
|
+
resolveDrill,
|
|
17
|
+
type DrillClickPayload,
|
|
18
|
+
type DrillField,
|
|
19
|
+
type DrillIntent,
|
|
20
|
+
type DrillNavigation,
|
|
21
|
+
type DrillTagReader,
|
|
22
|
+
} from "./resolveDrill";
|
|
23
|
+
export {
|
|
24
|
+
useDrill,
|
|
25
|
+
type DrillBinding,
|
|
26
|
+
type UseDrillOptions,
|
|
27
|
+
type UseDrillResult,
|
|
28
|
+
} from "./useDrill";
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it } from "bun:test";
|
|
5
|
+
import {
|
|
6
|
+
DRILL_CELL_CLASS,
|
|
7
|
+
drillColumnSiblings,
|
|
8
|
+
moveDrillStop,
|
|
9
|
+
markDrillableCells,
|
|
10
|
+
} from "./markDrillableCells";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The DOM half of the marking, which the sibling spec deliberately does not
|
|
14
|
+
* cover. Added because a guard written against rendered TEXT missed the case it
|
|
15
|
+
* existed for: the renderer draws a null cell as the glyph `∅` inside a
|
|
16
|
+
* `.value-null` span, so its `textContent` is not empty and every null cell
|
|
17
|
+
* stayed marked as a link whose click `resolveDrill` then refused.
|
|
18
|
+
*/
|
|
19
|
+
describe("markDrillableCells and cells with no value", () => {
|
|
20
|
+
/** The renderer's own shape: a grid table with an inline grid-column per cell. */
|
|
21
|
+
const table = (cells: string[]) => {
|
|
22
|
+
const root = document.createElement("div");
|
|
23
|
+
root.innerHTML = `
|
|
24
|
+
<div class="malloy-table">
|
|
25
|
+
<div class="column-cell th" style="grid-column: 1 / 2;">region</div>
|
|
26
|
+
${cells.join("")}
|
|
27
|
+
</div>`;
|
|
28
|
+
return root;
|
|
29
|
+
};
|
|
30
|
+
const cell = (inner: string) =>
|
|
31
|
+
`<div class="column-cell td" style="grid-column: 1 / 2;">${inner}</div>`;
|
|
32
|
+
|
|
33
|
+
it("marks a cell with a value and skips a null one", () => {
|
|
34
|
+
const root = table([
|
|
35
|
+
cell("West"),
|
|
36
|
+
cell('<span class="value-null">∅</span>'),
|
|
37
|
+
cell(""),
|
|
38
|
+
cell("0"),
|
|
39
|
+
]);
|
|
40
|
+
markDrillableCells(root, new Set(["region"]));
|
|
41
|
+
|
|
42
|
+
const marked = Array.from(
|
|
43
|
+
root.querySelectorAll<HTMLElement>(".column-cell.td"),
|
|
44
|
+
).map((node) => node.classList.contains(DRILL_CELL_CLASS));
|
|
45
|
+
// West and 0 are values; the null glyph and the empty cell are not.
|
|
46
|
+
expect(marked).toEqual([true, false, false, true]);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe("markDrillableCells and the tab order", () => {
|
|
51
|
+
const table = (rows: number) => {
|
|
52
|
+
const root = document.createElement("div");
|
|
53
|
+
const cells = Array.from(
|
|
54
|
+
{ length: rows },
|
|
55
|
+
(_unused, index) =>
|
|
56
|
+
`<div class="column-cell td" style="grid-column: 1 / 2;">v${index}</div>` +
|
|
57
|
+
`<div class="column-cell td" style="grid-column: 2 / 3;">n${index}</div>`,
|
|
58
|
+
).join("");
|
|
59
|
+
root.innerHTML = `
|
|
60
|
+
<div class="malloy-table">
|
|
61
|
+
<div class="column-cell th" style="grid-column: 1 / 2;">region</div>
|
|
62
|
+
<div class="column-cell th" style="grid-column: 2 / 3;">sales</div>
|
|
63
|
+
${cells}
|
|
64
|
+
</div>`;
|
|
65
|
+
return root;
|
|
66
|
+
};
|
|
67
|
+
const stops = (root: HTMLElement) =>
|
|
68
|
+
Array.from(root.querySelectorAll<HTMLElement>(`.${DRILL_CELL_CLASS}`))
|
|
69
|
+
.filter((node) => node.getAttribute("tabindex") === "0")
|
|
70
|
+
.map((node) => node.textContent);
|
|
71
|
+
|
|
72
|
+
// Marking every cell tabbable put a whole column in the tab order, so a
|
|
73
|
+
// result at the row cap cost a keyboard reader hundreds of presses to get
|
|
74
|
+
// past it. One stop per column, arrow keys within.
|
|
75
|
+
it("gives a drillable column one tab stop, not one per cell", () => {
|
|
76
|
+
const root = table(12);
|
|
77
|
+
markDrillableCells(root, new Set(["region"]));
|
|
78
|
+
|
|
79
|
+
const marked = root.querySelectorAll(`.${DRILL_CELL_CLASS}`);
|
|
80
|
+
expect(marked.length).toBe(12);
|
|
81
|
+
expect(stops(root)).toEqual(["v0"]);
|
|
82
|
+
// The rest are reachable by arrow key, so they are focusable but skipped.
|
|
83
|
+
const rest = Array.from(marked).slice(1);
|
|
84
|
+
expect(rest.every((n) => n.getAttribute("tabindex") === "-1")).toBe(true);
|
|
85
|
+
// The non-drillable column is left alone entirely.
|
|
86
|
+
expect(
|
|
87
|
+
root.querySelectorAll('[style*="grid-column: 2"][tabindex]').length,
|
|
88
|
+
).toBe(0);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// A `# dashboard` settles over several frames, so the caller re-runs the
|
|
92
|
+
// marking. Rebuilding the stop from scratch each pass would snap it back to
|
|
93
|
+
// the first row under a reader who had arrowed down.
|
|
94
|
+
it("keeps the roving position across a re-run", () => {
|
|
95
|
+
const root = table(5);
|
|
96
|
+
markDrillableCells(root, new Set(["region"]));
|
|
97
|
+
|
|
98
|
+
const cells = Array.from(
|
|
99
|
+
root.querySelectorAll<HTMLElement>(`.${DRILL_CELL_CLASS}`),
|
|
100
|
+
);
|
|
101
|
+
// Move the stop the way the arrow handler does.
|
|
102
|
+
cells[0].tabIndex = -1;
|
|
103
|
+
cells[3].tabIndex = 0;
|
|
104
|
+
|
|
105
|
+
markDrillableCells(root, new Set(["region"]));
|
|
106
|
+
expect(stops(root)).toEqual(["v3"]);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("reports a column's marked cells in row order", () => {
|
|
110
|
+
const root = table(4);
|
|
111
|
+
markDrillableCells(root, new Set(["region"]));
|
|
112
|
+
const first = root.querySelector<HTMLElement>(`.${DRILL_CELL_CLASS}`);
|
|
113
|
+
expect(first).not.toBeNull();
|
|
114
|
+
expect(
|
|
115
|
+
drillColumnSiblings(first as HTMLElement).map((n) => n.textContent),
|
|
116
|
+
).toEqual(["v0", "v1", "v2", "v3"]);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("reports nothing for a cell that is not in a table", () => {
|
|
120
|
+
const orphan = document.createElement("div");
|
|
121
|
+
orphan.className = DRILL_CELL_CLASS;
|
|
122
|
+
expect(drillColumnSiblings(orphan)).toEqual([]);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
describe("markDrillableCells across two drillable columns", () => {
|
|
127
|
+
// The stop is per drillable COLUMN, scoped to its table, not per table. The
|
|
128
|
+
// guide said "one stop per TABLE" for two rounds, which is wrong the moment a
|
|
129
|
+
// dashboard groups by two drilled dimensions.
|
|
130
|
+
it("gives each drillable column its own stop", () => {
|
|
131
|
+
const root = document.createElement("div");
|
|
132
|
+
root.innerHTML = `
|
|
133
|
+
<div class="malloy-table">
|
|
134
|
+
<div class="column-cell th" style="grid-column: 1 / 2;">category</div>
|
|
135
|
+
<div class="column-cell th" style="grid-column: 2 / 3;">brand</div>
|
|
136
|
+
<div class="column-cell th" style="grid-column: 3 / 4;">sales</div>
|
|
137
|
+
<div class="column-cell td" style="grid-column: 1 / 2;">c0</div>
|
|
138
|
+
<div class="column-cell td" style="grid-column: 2 / 3;">b0</div>
|
|
139
|
+
<div class="column-cell td" style="grid-column: 3 / 4;">1</div>
|
|
140
|
+
<div class="column-cell td" style="grid-column: 1 / 2;">c1</div>
|
|
141
|
+
<div class="column-cell td" style="grid-column: 2 / 3;">b1</div>
|
|
142
|
+
<div class="column-cell td" style="grid-column: 3 / 4;">2</div>
|
|
143
|
+
</div>`;
|
|
144
|
+
markDrillableCells(root, new Set(["category", "brand"]));
|
|
145
|
+
|
|
146
|
+
const stops = Array.from(
|
|
147
|
+
root.querySelectorAll<HTMLElement>(`.${DRILL_CELL_CLASS}`),
|
|
148
|
+
)
|
|
149
|
+
.filter((n) => n.getAttribute("tabindex") === "0")
|
|
150
|
+
.map((n) => n.textContent);
|
|
151
|
+
// One per column, both on the first row, and the undrilled column
|
|
152
|
+
// contributes none.
|
|
153
|
+
expect(stops).toEqual(["c0", "b0"]);
|
|
154
|
+
expect(root.querySelectorAll(`.${DRILL_CELL_CLASS}`).length).toBe(4);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
describe("moveDrillStop keeps a column to exactly one tab stop", () => {
|
|
159
|
+
const table = (rows: number) => {
|
|
160
|
+
const root = document.createElement("div");
|
|
161
|
+
const cells = Array.from(
|
|
162
|
+
{ length: rows },
|
|
163
|
+
(_unused, index) =>
|
|
164
|
+
`<div class="column-cell td" style="grid-column: 1 / 2;">v${index}</div>`,
|
|
165
|
+
).join("");
|
|
166
|
+
root.innerHTML = `
|
|
167
|
+
<div class="malloy-table">
|
|
168
|
+
<div class="column-cell th" style="grid-column: 1 / 2;">region</div>
|
|
169
|
+
${cells}
|
|
170
|
+
</div>`;
|
|
171
|
+
markDrillableCells(root, new Set(["region"]));
|
|
172
|
+
return root;
|
|
173
|
+
};
|
|
174
|
+
const marked = (root: HTMLElement) =>
|
|
175
|
+
Array.from(root.querySelectorAll<HTMLElement>(`.${DRILL_CELL_CLASS}`));
|
|
176
|
+
const stops = (root: HTMLElement) =>
|
|
177
|
+
marked(root)
|
|
178
|
+
.filter((n) => n.getAttribute("tabindex") === "0")
|
|
179
|
+
.map((n) => n.textContent);
|
|
180
|
+
|
|
181
|
+
// The case both earlier tests missed, because each simulated the move by
|
|
182
|
+
// hand-setting tabIndex on the cell that already held the stop. A cell with
|
|
183
|
+
// `tabindex="-1"` is still CLICK-focusable, so the cell an arrow moves from
|
|
184
|
+
// is frequently not the one holding the stop.
|
|
185
|
+
it("moves from a click-focused cell without leaving a second stop", () => {
|
|
186
|
+
const root = table(6);
|
|
187
|
+
const cells = marked(root);
|
|
188
|
+
expect(stops(root)).toEqual(["v0"]);
|
|
189
|
+
|
|
190
|
+
// The reader clicks row 3. Focus is there; the stop is still on row 0.
|
|
191
|
+
const next = moveDrillStop(cells[3], 1);
|
|
192
|
+
|
|
193
|
+
expect(next?.textContent).toBe("v4");
|
|
194
|
+
expect(stops(root)).toEqual(["v4"]);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it("repeating that gesture cannot accumulate stops", () => {
|
|
198
|
+
const root = table(6);
|
|
199
|
+
const cells = marked(root);
|
|
200
|
+
moveDrillStop(cells[3], 1);
|
|
201
|
+
moveDrillStop(cells[1], 1);
|
|
202
|
+
moveDrillStop(cells[5], -1);
|
|
203
|
+
expect(stops(root)).toEqual(["v4"]);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it("a clamped move at the end repairs a column rather than doing nothing", () => {
|
|
207
|
+
const root = table(4);
|
|
208
|
+
const cells = marked(root);
|
|
209
|
+
// Drift the column into two stops by hand, the state the old move left.
|
|
210
|
+
cells[2].tabIndex = 0;
|
|
211
|
+
expect(stops(root)).toEqual(["v0", "v2"]);
|
|
212
|
+
|
|
213
|
+
moveDrillStop(cells[3], 1); // already last, so it clamps to itself
|
|
214
|
+
expect(stops(root)).toEqual(["v3"]);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it("reports nothing for a cell outside a table", () => {
|
|
218
|
+
const orphan = document.createElement("div");
|
|
219
|
+
orphan.className = DRILL_CELL_CLASS;
|
|
220
|
+
expect(moveDrillStop(orphan, 1)).toBeUndefined();
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
// Home and End. Untested until a mutation sweep showed that making "first"
|
|
224
|
+
// resolve to the LAST cell kept every other test green, so Home would have
|
|
225
|
+
// jumped a reader to the bottom row with nothing to catch it.
|
|
226
|
+
it("Home goes to the first row and End to the last", () => {
|
|
227
|
+
const root = table(5);
|
|
228
|
+
const cells = marked(root);
|
|
229
|
+
|
|
230
|
+
expect(moveDrillStop(cells[2], "first")?.textContent).toBe("v0");
|
|
231
|
+
expect(stops(root)).toEqual(["v0"]);
|
|
232
|
+
|
|
233
|
+
expect(moveDrillStop(cells[2], "last")?.textContent).toBe("v4");
|
|
234
|
+
expect(stops(root)).toEqual(["v4"]);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
// A nested table has its own grid and its own column numbering. Untested
|
|
238
|
+
// until a mutation sweep showed that dropping the own-table filter kept
|
|
239
|
+
// everything green, because no fixture anywhere had a nested table: arrow
|
|
240
|
+
// keys would have walked out of the outer column into the inner one and
|
|
241
|
+
// stripped the outer column's stop on the way.
|
|
242
|
+
it("does not walk into a nested table that shares a column number", () => {
|
|
243
|
+
const root = document.createElement("div");
|
|
244
|
+
root.innerHTML = `
|
|
245
|
+
<div class="malloy-table">
|
|
246
|
+
<div class="column-cell th" style="grid-column: 1 / 2;">region</div>
|
|
247
|
+
<div class="column-cell td" style="grid-column: 1 / 2;">outer0</div>
|
|
248
|
+
<div class="column-cell td" style="grid-column: 1 / 2;">outer1</div>
|
|
249
|
+
<div class="column-cell td" style="grid-column: 1 / 2;">
|
|
250
|
+
<div class="malloy-table">
|
|
251
|
+
<div class="column-cell th" style="grid-column: 1 / 2;">region</div>
|
|
252
|
+
<div class="column-cell td" style="grid-column: 1 / 2;">inner0</div>
|
|
253
|
+
<div class="column-cell td" style="grid-column: 1 / 2;">inner1</div>
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
</div>`;
|
|
257
|
+
markDrillableCells(root, new Set(["region"]));
|
|
258
|
+
|
|
259
|
+
const outer = Array.from(
|
|
260
|
+
root.querySelectorAll<HTMLElement>(`.${DRILL_CELL_CLASS}`),
|
|
261
|
+
).filter((n) => n.textContent === "outer0");
|
|
262
|
+
expect(outer).toHaveLength(1);
|
|
263
|
+
|
|
264
|
+
// The outer column's siblings are its own rows only. The cell wrapping the
|
|
265
|
+
// nested table is not marked at all, so it is not among them either.
|
|
266
|
+
expect(
|
|
267
|
+
drillColumnSiblings(outer[0]).map((n) => n.textContent?.trim()),
|
|
268
|
+
).toEqual(["outer0", "outer1"]);
|
|
269
|
+
|
|
270
|
+
// Each table keeps its own stop, so the nested one does not steal the
|
|
271
|
+
// outer one's.
|
|
272
|
+
const inner = Array.from(
|
|
273
|
+
root.querySelectorAll<HTMLElement>(`.${DRILL_CELL_CLASS}`),
|
|
274
|
+
).filter((n) => n.textContent === "inner0");
|
|
275
|
+
expect(inner).toHaveLength(1);
|
|
276
|
+
expect(outer[0].getAttribute("tabindex")).toBe("0");
|
|
277
|
+
expect(inner[0].getAttribute("tabindex")).toBe("0");
|
|
278
|
+
|
|
279
|
+
// The case that matters is a re-mark with the nested stop MOVED OFF row
|
|
280
|
+
// zero. Asserting only that `inner0` still holds it proves nothing: that
|
|
281
|
+
// is where the fallback promotion lands anyway, so the assertion passes
|
|
282
|
+
// with the guard deleted. This is the shape that fails without it.
|
|
283
|
+
const inner1 = Array.from(
|
|
284
|
+
root.querySelectorAll<HTMLElement>(`.${DRILL_CELL_CLASS}`),
|
|
285
|
+
).find((n) => n.textContent === "inner1");
|
|
286
|
+
expect(inner1).toBeDefined();
|
|
287
|
+
inner[0].tabIndex = -1;
|
|
288
|
+
(inner1 as HTMLElement).tabIndex = 0;
|
|
289
|
+
|
|
290
|
+
markDrillableCells(root, new Set(["region"]));
|
|
291
|
+
|
|
292
|
+
// The outer pass sees the nested stop as a duplicate of its own column and
|
|
293
|
+
// demotes it; the nested pass then re-promotes the FIRST row rather than
|
|
294
|
+
// the roved one, so a reader who had arrowed down inside a nested table
|
|
295
|
+
// would be thrown back to its top on every re-mark, and a settling
|
|
296
|
+
// `# dashboard` re-marks repeatedly.
|
|
297
|
+
expect(outer[0].getAttribute("tabindex")).toBe("0");
|
|
298
|
+
expect(inner[0].getAttribute("tabindex")).toBe("-1");
|
|
299
|
+
expect((inner1 as HTMLElement).getAttribute("tabindex")).toBe("0");
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
// Belt and braces: even if some other path drifts a column, the next mark
|
|
303
|
+
// pass demotes the extra rather than preserving both for good.
|
|
304
|
+
it("a re-mark demotes a duplicate stop instead of keeping it", () => {
|
|
305
|
+
const root = table(4);
|
|
306
|
+
const cells = marked(root);
|
|
307
|
+
cells[2].tabIndex = 0;
|
|
308
|
+
expect(stops(root)).toEqual(["v0", "v2"]);
|
|
309
|
+
|
|
310
|
+
markDrillableCells(root, new Set(["region"]));
|
|
311
|
+
expect(stops(root)).toEqual(["v0"]);
|
|
312
|
+
});
|
|
313
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { parseAnnotation } from "@malloydata/malloy-tag";
|
|
5
|
+
import { describe, expect, it } from "bun:test";
|
|
6
|
+
import { drillableFieldNames } from "./markDrillableCells";
|
|
7
|
+
import { drillDestinations, type DrillField } from "./resolveDrill";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Which columns the affordance marks. The marking itself walks the renderer's
|
|
11
|
+
* own table DOM, and stubbing that markup would only test our idea of it, so
|
|
12
|
+
* this file covers the field-name decision and not the DOM walk.
|
|
13
|
+
*
|
|
14
|
+
* The DOM walk is currently verified BY HAND against the real renderer, not by a
|
|
15
|
+
* committed spec: on a notebook whose model carries two `# drill` dimensions,
|
|
16
|
+
* the reachable one's column marks all 10 of its cells and the unreachable one's
|
|
17
|
+
* marks none. Recorded here rather than left implied, and deliberately NOT as a
|
|
18
|
+
* pointer to `packages/app/tests/playwright/package-dashboards.spec.ts`, which
|
|
19
|
+
* does not exist in this repository: it arrives with the dashboard slice. That
|
|
20
|
+
* spec is
|
|
21
|
+
* the natural home for pinning it, since it will have a drill-carrying fixture
|
|
22
|
+
* to assert against; until then, treat the DOM half as unpinned.
|
|
23
|
+
*/
|
|
24
|
+
describe("drillableFieldNames", () => {
|
|
25
|
+
const field = (name: string, annotations: string[]): DrillField => ({
|
|
26
|
+
name,
|
|
27
|
+
tag: parseAnnotation(annotations).tag,
|
|
28
|
+
});
|
|
29
|
+
const viz = (fields: DrillField[]) => ({
|
|
30
|
+
getMetadata: () => ({ getAllFields: () => fields }),
|
|
31
|
+
});
|
|
32
|
+
/** A surface that can navigate but cannot filter itself. */
|
|
33
|
+
const navigateOnly = (f: DrillField) =>
|
|
34
|
+
drillDestinations(f).some((destination) => destination !== "self");
|
|
35
|
+
|
|
36
|
+
it("collects the one spelling a drillable field renders", () => {
|
|
37
|
+
// The label when the author set one, the name otherwise, which is what
|
|
38
|
+
// the header this is matched against actually shows. Adding the raw name
|
|
39
|
+
// as WELL used to look defensive and was not: a labelled field never puts
|
|
40
|
+
// its name on screen, so that key could only ever match some other
|
|
41
|
+
// column and paint it as a link that does nothing.
|
|
42
|
+
const names = drillableFieldNames(
|
|
43
|
+
viz([
|
|
44
|
+
field("category", ['# drill { to=overview } label="Category"\n']),
|
|
45
|
+
field("total_sales", ["# currency\n"]),
|
|
46
|
+
]),
|
|
47
|
+
navigateOnly,
|
|
48
|
+
);
|
|
49
|
+
expect([...names].sort()).toEqual(["Category"]);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("leaves out a drill this surface cannot honor", () => {
|
|
53
|
+
// Malloyyo's rule, and the reason the predicate belongs to the host: a
|
|
54
|
+
// dead link is worse than none, so a `to=self` on a surface with no
|
|
55
|
+
// controls to write to stays plain text rather than promising a click it
|
|
56
|
+
// would then swallow.
|
|
57
|
+
const names = drillableFieldNames(
|
|
58
|
+
viz([field("region", ["# drill { to=self }\n"])]),
|
|
59
|
+
navigateOnly,
|
|
60
|
+
);
|
|
61
|
+
expect(names.size).toBe(0);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("survives a viz with no metadata", () => {
|
|
65
|
+
// Clicks still resolve in this case; only the affordance is missing, so a
|
|
66
|
+
// renderer that has not published metadata yet must not throw here.
|
|
67
|
+
expect(
|
|
68
|
+
drillableFieldNames({ getMetadata: () => null }, () => true).size,
|
|
69
|
+
).toBe(0);
|
|
70
|
+
expect(
|
|
71
|
+
drillableFieldNames(
|
|
72
|
+
{
|
|
73
|
+
getMetadata: () => {
|
|
74
|
+
throw new Error("not ready");
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
() => true,
|
|
78
|
+
).size,
|
|
79
|
+
).toBe(0);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("drops a spelling a non-drillable field also renders", () => {
|
|
83
|
+
// Matching on header TEXT cannot tell the two columns apart, so marking
|
|
84
|
+
// `Region` would paint the non-drillable column as a link that does
|
|
85
|
+
// nothing. The affordance is given up instead, on both columns.
|
|
86
|
+
const names = drillableFieldNames(
|
|
87
|
+
viz([
|
|
88
|
+
field("region", ['# drill { to=overview } label="Region"\n']),
|
|
89
|
+
field("ship_from", ['# label="Region"\n']),
|
|
90
|
+
]),
|
|
91
|
+
navigateOnly,
|
|
92
|
+
);
|
|
93
|
+
// Nothing marked: the drillable field's only rendered spelling is the
|
|
94
|
+
// one the non-drillable field also renders, so the affordance is given up
|
|
95
|
+
// rather than painted on a column whose click does nothing.
|
|
96
|
+
expect([...names].sort()).toEqual([]);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("still marks a label no other field renders", () => {
|
|
100
|
+
const names = drillableFieldNames(
|
|
101
|
+
viz([
|
|
102
|
+
field("region", ['# drill { to=overview } label="Region"\n']),
|
|
103
|
+
field("ship_from", ['# label="Origin"\n']),
|
|
104
|
+
]),
|
|
105
|
+
navigateOnly,
|
|
106
|
+
);
|
|
107
|
+
expect([...names].sort()).toEqual(["Region"]);
|
|
108
|
+
});
|
|
109
|
+
});
|