@marimo-team/islands 0.24.1-dev2 → 0.24.1-dev21
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/{ConnectedDataExplorerComponent-BUC1MrsF.js → ConnectedDataExplorerComponent-yEsovh7C.js} +4 -4
- package/dist/{chat-ui-o-tATfmW.js → chat-ui-dZ0mdOG3.js} +3 -3
- package/dist/{common-DjnMIXVY.js → common-DhYGWkNU.js} +14 -8
- package/dist/{formats-HSfYlcA8.js → formats-BZtMpeQe.js} +2 -2
- package/dist/{glide-data-editor-BI2i_IEE.js → glide-data-editor-BcvvJTCH.js} +2 -0
- package/dist/{html-to-image-BOiFHx3u.js → html-to-image-p-mxZ3_V.js} +2333 -2311
- package/dist/{loader-DTnbNSVZ.js → loader-Chm6nOqy.js} +1 -1
- package/dist/main.js +1106 -1011
- package/dist/{process-output-HrsM52f8.js → process-output-Bh4xztNq.js} +1 -1
- package/dist/{react-vega-zyfTF9SY.js → react-vega-BE2Uv1cq.js} +1 -1
- package/dist/{reveal-component-BufNyZPY.js → reveal-component-BzecpV7i.js} +5 -5
- package/dist/{spec-BL1GSUUF.js → spec-DR1CyTOo.js} +2 -0
- package/dist/style.css +1 -1
- package/dist/{toDate-BGM7kFtQ.js → toDate-CjUYDkFI.js} +2 -2
- package/dist/{vega-component-CJug-VdR.js → vega-component-CTiCS_5w.js} +5 -5
- package/dist/{vega-embed-container-BRjjqRGz.js → vega-embed-container-B1tc-DoN.js} +2 -2
- package/dist/{vega-loader.browser-CGb-2Kwi.js → vega-loader.browser-VFQfHaoV.js} +1 -1
- package/package.json +1 -1
- package/src/__mocks__/requests.ts +4 -0
- package/src/components/app-config/optional-features.test.ts +78 -0
- package/src/components/app-config/optional-features.tsx +33 -6
- package/src/components/data-table/__tests__/column_formatting.test.ts +7 -0
- package/src/components/data-table/charts/__tests__/schemas.test.ts +17 -2
- package/src/components/data-table/charts/chart-spec/types.ts +2 -0
- package/src/components/data-table/column-formatting/feature.ts +1 -0
- package/src/components/data-table/column-formatting/types.ts +1 -0
- package/src/components/data-table/column-summary/chart-spec-model.tsx +1 -0
- package/src/components/data-table/column-summary/column-summary.tsx +1 -0
- package/src/components/data-table/columns.tsx +4 -3
- package/src/components/datasets/__tests__/icons.test.ts +10 -2
- package/src/components/datasets/icons.tsx +4 -0
- package/src/components/datasources/__tests__/components.test.tsx +14 -1
- package/src/components/editor/actions/export-dialog/__tests__/export-dialog.test.tsx +206 -34
- package/src/components/editor/actions/export-dialog/export-dialog.tsx +9 -3
- package/src/components/editor/actions/export-dialog/format-notice.tsx +69 -24
- package/src/components/editor/actions/export-dialog/use-export-dialog.ts +27 -2
- package/src/components/ui/toaster.tsx +14 -1
- package/src/core/codemirror/code-lens/__tests__/popover.test.ts +13 -0
- package/src/core/codemirror/code-lens/popover.tsx +11 -5
- package/src/core/codemirror/language/languages/sql/__tests__/renderers.test.tsx +15 -4
- package/src/core/codemirror/language/languages/sql/renderers.tsx +1 -0
- package/src/core/islands/bridge.ts +1 -0
- package/src/core/kernel/messages.ts +1 -0
- package/src/core/mode.ts +6 -1
- package/src/core/network/__tests__/requests-lazy.test.ts +40 -0
- package/src/core/network/__tests__/requests-network.test.ts +13 -0
- package/src/core/network/requests-lazy.ts +11 -4
- package/src/core/network/requests-network.ts +8 -0
- package/src/core/network/requests-static.ts +1 -0
- package/src/core/network/requests-toasting.tsx +1 -0
- package/src/core/network/types.ts +5 -0
- package/src/core/wasm/bridge.ts +1 -0
- package/src/plugins/impl/MatrixPlugin.tsx +256 -35
- package/src/plugins/impl/__tests__/DataEditorPlugin.test.ts +13 -1
- package/src/plugins/impl/__tests__/MatrixPlugin.test.tsx +540 -3
- package/src/plugins/impl/data-editor/glide-data-editor.tsx +1 -0
- package/src/plugins/impl/data-editor/glide-utils.ts +1 -0
- package/src/plugins/impl/data-frames/__tests__/schema.test.ts +9 -1
- package/src/plugins/impl/data-frames/utils/__tests__/operators.test.ts +8 -0
- package/src/plugins/impl/data-frames/utils/operators.ts +1 -1
- package/src/plugins/impl/vega/__tests__/vega.test.ts +22 -4
- package/src/plugins/impl/vega/utils.ts +3 -0
|
@@ -54,8 +54,8 @@ const viewStateAtom = atom({
|
|
|
54
54
|
cellAnchor: null
|
|
55
55
|
}), initialModeAtom = atom(void 0), kioskModeAtom = atom(false);
|
|
56
56
|
function useInstallAllowed() {
|
|
57
|
-
let { mode: e } = useAtomValue(viewStateAtom);
|
|
58
|
-
return e !== "read";
|
|
57
|
+
let { mode: e } = useAtomValue(viewStateAtom), S = useAtomValue(kioskModeAtom), C = new URLSearchParams(window.location.search).get(KnownQueryParams.kiosk) === "true";
|
|
58
|
+
return e !== "read" && !S && !C;
|
|
59
59
|
}
|
|
60
60
|
const WebSocketState = {
|
|
61
61
|
NOT_STARTED: "NOT_STARTED",
|
|
@@ -2,7 +2,7 @@ import { o as __toESM } from "./chunk-Bfp04NdC.js";
|
|
|
2
2
|
import { g as Logger, h as cn, m as Events } from "./button-Dr2uAwhT.js";
|
|
3
3
|
import { t as require_react } from "./react-DhGsCS90.js";
|
|
4
4
|
import { t as require_compiler_runtime } from "./compiler-runtime-DsR6imPN.js";
|
|
5
|
-
import { c as asRemoteURL, w as CircleQuestionMark } from "./toDate-
|
|
5
|
+
import { c as asRemoteURL, w as CircleQuestionMark } from "./toDate-CjUYDkFI.js";
|
|
6
6
|
import "./react-dom-CmENFV8Q.js";
|
|
7
7
|
import { t as require_jsx_runtime } from "./jsx-runtime-Dp_oQwaf.js";
|
|
8
8
|
import "./zod-BFY2SnzC.js";
|
|
@@ -12,10 +12,10 @@ import { t as debounce_default } from "./debounce-D784bpms.js";
|
|
|
12
12
|
import { A as useEvent_default, n as useTheme } from "./useTheme-BzEXeAR5.js";
|
|
13
13
|
import { s as uniq } from "./arrays-C56grfjL.js";
|
|
14
14
|
import { t as Objects } from "./objects-UzwQd5gx.js";
|
|
15
|
-
import { a as isValid, i as AlertTitle, n as Alert, t as arrow } from "./formats-
|
|
16
|
-
import { A as getContainerWidth, n as formats } from "./vega-loader.browser-
|
|
17
|
-
import { a as tooltipHandler, n as vegaLoadData } from "./loader-
|
|
18
|
-
import { t as j } from "./react-vega-
|
|
15
|
+
import { a as isValid, i as AlertTitle, n as Alert, t as arrow } from "./formats-BZtMpeQe.js";
|
|
16
|
+
import { A as getContainerWidth, n as formats } from "./vega-loader.browser-VFQfHaoV.js";
|
|
17
|
+
import { a as tooltipHandler, n as vegaLoadData } from "./loader-Chm6nOqy.js";
|
|
18
|
+
import { t as j } from "./react-vega-BE2Uv1cq.js";
|
|
19
19
|
import "./defaultLocale-CMezyvMc.js";
|
|
20
20
|
import "./defaultLocale-DMZFeDB8.js";
|
|
21
21
|
import { t as useAsyncData } from "./useAsyncData-CDcbh-Qv.js";
|
|
@@ -2,8 +2,8 @@ import { o as __toESM } from "./chunk-Bfp04NdC.js";
|
|
|
2
2
|
import { t as require_react } from "./react-DhGsCS90.js";
|
|
3
3
|
import { t as require_compiler_runtime } from "./compiler-runtime-DsR6imPN.js";
|
|
4
4
|
import { t as require_jsx_runtime } from "./jsx-runtime-Dp_oQwaf.js";
|
|
5
|
-
import { A as getContainerWidth } from "./vega-loader.browser-
|
|
6
|
-
import { n as q } from "./react-vega-
|
|
5
|
+
import { A as getContainerWidth } from "./vega-loader.browser-VFQfHaoV.js";
|
|
6
|
+
import { n as q } from "./react-vega-BE2Uv1cq.js";
|
|
7
7
|
import "./defaultLocale-CMezyvMc.js";
|
|
8
8
|
import "./defaultLocale-DMZFeDB8.js";
|
|
9
9
|
import { t as useVegaContainerRemeasure } from "./use-vega-container-remeasure-B7OD7yUY.js";
|
|
@@ -410,7 +410,7 @@ function getContainerWidth(o) {
|
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
412
|
function getVegaFieldTypes(F) {
|
|
413
|
-
return !F || Object.keys(F).length === 0 ? "auto" : Objects.mapValues(F, (o) => o === "date" || o === "time" ? "string" : o === "datetime" ? "date" : o);
|
|
413
|
+
return !F || Object.keys(F).length === 0 ? "auto" : Objects.mapValues(F, (o) => o === "geometry" || o === "date" || o === "time" ? "string" : o === "datetime" ? "date" : o);
|
|
414
414
|
}
|
|
415
415
|
var EOL = {}, EOF = {}, QUOTE = 34, NEWLINE = 10, RETURN = 13;
|
|
416
416
|
function objectConverter(o) {
|
package/package.json
CHANGED
|
@@ -100,6 +100,10 @@ export const MockRequestClient = {
|
|
|
100
100
|
},
|
|
101
101
|
],
|
|
102
102
|
}),
|
|
103
|
+
installExportRequirements: vi.fn().mockResolvedValue({
|
|
104
|
+
source: "server",
|
|
105
|
+
formats: [],
|
|
106
|
+
}),
|
|
103
107
|
exportAsHTML: vi.fn().mockResolvedValue({
|
|
104
108
|
contents: "",
|
|
105
109
|
filename: "notebook.html",
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
import { isPackageRequirementInstalled } from "./optional-features";
|
|
5
|
+
|
|
6
|
+
describe("isPackageRequirementInstalled", () => {
|
|
7
|
+
const installedPackages = [
|
|
8
|
+
{ name: "mcp", version: "2.0.0" },
|
|
9
|
+
{ name: "polars", version: "1.8.2" },
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
it("requires the package to be installed", () => {
|
|
13
|
+
expect(
|
|
14
|
+
isPackageRequirementInstalled({ name: "missing" }, installedPackages),
|
|
15
|
+
).toBe(false);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("accepts an installed package without a minimum version", () => {
|
|
19
|
+
expect(
|
|
20
|
+
isPackageRequirementInstalled({ name: "polars" }, installedPackages),
|
|
21
|
+
).toBe(true);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("rejects an installed package below the minimum version", () => {
|
|
25
|
+
expect(
|
|
26
|
+
isPackageRequirementInstalled(
|
|
27
|
+
{ name: "mcp", minVersion: "2.1.0" },
|
|
28
|
+
installedPackages,
|
|
29
|
+
),
|
|
30
|
+
).toBe(false);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it.each(["2.0.0rc1", "2.0.0.dev1", "2.0.0-beta1"])(
|
|
34
|
+
"rejects the prerelease version %s",
|
|
35
|
+
(version) => {
|
|
36
|
+
expect(
|
|
37
|
+
isPackageRequirementInstalled({ name: "mcp", minVersion: "2.0.0" }, [
|
|
38
|
+
{ name: "mcp", version },
|
|
39
|
+
]),
|
|
40
|
+
).toBe(false);
|
|
41
|
+
},
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
it.each(["2.1.0rc1", "3.0.0rc1"])(
|
|
45
|
+
"accepts the later prerelease version %s",
|
|
46
|
+
(version) => {
|
|
47
|
+
expect(
|
|
48
|
+
isPackageRequirementInstalled({ name: "mcp", minVersion: "2.0.0" }, [
|
|
49
|
+
{ name: "mcp", version },
|
|
50
|
+
]),
|
|
51
|
+
).toBe(true);
|
|
52
|
+
},
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
it("accepts an installed package at or above the minimum version", () => {
|
|
56
|
+
expect(
|
|
57
|
+
isPackageRequirementInstalled(
|
|
58
|
+
{ name: "mcp", minVersion: "2.0.0" },
|
|
59
|
+
installedPackages,
|
|
60
|
+
),
|
|
61
|
+
).toBe(true);
|
|
62
|
+
expect(
|
|
63
|
+
isPackageRequirementInstalled(
|
|
64
|
+
{ name: "mcp", minVersion: "1.9.0" },
|
|
65
|
+
installedPackages,
|
|
66
|
+
),
|
|
67
|
+
).toBe(true);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("normalizes extras in the requirement name", () => {
|
|
71
|
+
expect(
|
|
72
|
+
isPackageRequirementInstalled(
|
|
73
|
+
{ name: "polars[pyarrow]" },
|
|
74
|
+
installedPackages,
|
|
75
|
+
),
|
|
76
|
+
).toBe(true);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -20,6 +20,7 @@ import { isWasm } from "@/core/wasm/utils";
|
|
|
20
20
|
import { useAsyncData } from "@/hooks/useAsyncData";
|
|
21
21
|
import { ErrorBanner } from "@/plugins/impl/common/error-banner";
|
|
22
22
|
import { cn } from "@/utils/cn";
|
|
23
|
+
import { semverSort } from "@/utils/versions";
|
|
23
24
|
import { SettingSubtitle } from "./common";
|
|
24
25
|
|
|
25
26
|
interface Package {
|
|
@@ -27,6 +28,35 @@ interface Package {
|
|
|
27
28
|
minVersion?: string;
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
interface InstalledPackage {
|
|
32
|
+
name: string;
|
|
33
|
+
version: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const PEP_440_PRERELEASE =
|
|
37
|
+
/^((?:\d+!)?\d+(?:\.\d+)*)(?:[-_.]?(?:a|b|c|rc|alpha|beta|pre|preview|dev)\d*)/i;
|
|
38
|
+
|
|
39
|
+
export function isPackageRequirementInstalled(
|
|
40
|
+
requirement: Package,
|
|
41
|
+
installedPackages: InstalledPackage[],
|
|
42
|
+
): boolean {
|
|
43
|
+
const packageName = requirement.name.split("[")[0];
|
|
44
|
+
const installedPackage = installedPackages.find(
|
|
45
|
+
(pkg) => pkg.name === packageName,
|
|
46
|
+
);
|
|
47
|
+
if (!installedPackage) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
if (!requirement.minVersion) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
const prerelease = installedPackage.version.match(PEP_440_PRERELEASE);
|
|
54
|
+
if (prerelease) {
|
|
55
|
+
return semverSort(prerelease[1], requirement.minVersion) > 0;
|
|
56
|
+
}
|
|
57
|
+
return semverSort(installedPackage.version, requirement.minVersion) >= 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
30
60
|
interface OptionalFeature {
|
|
31
61
|
id: string;
|
|
32
62
|
/**
|
|
@@ -77,8 +107,8 @@ const OPTIONAL_DEPENDENCIES: OptionalFeature[] = [
|
|
|
77
107
|
},
|
|
78
108
|
{
|
|
79
109
|
id: "mcp",
|
|
80
|
-
packagesRequired: [{ name: "mcp", minVersion: "
|
|
81
|
-
additionalPackageInstalls: [
|
|
110
|
+
packagesRequired: [{ name: "mcp", minVersion: "2.0.0" }],
|
|
111
|
+
additionalPackageInstalls: [],
|
|
82
112
|
description: "Connect to MCP servers",
|
|
83
113
|
},
|
|
84
114
|
{
|
|
@@ -123,9 +153,6 @@ export const OptionalFeatures: React.FC = () => {
|
|
|
123
153
|
}
|
|
124
154
|
|
|
125
155
|
const installedPackages = data?.packages || [];
|
|
126
|
-
const installedPackageNames = new Set(
|
|
127
|
-
installedPackages.map((pkg) => pkg.name),
|
|
128
|
-
);
|
|
129
156
|
|
|
130
157
|
return (
|
|
131
158
|
<div className="flex-1 flex flex-col overflow-hidden gap-2">
|
|
@@ -149,7 +176,7 @@ export const OptionalFeatures: React.FC = () => {
|
|
|
149
176
|
<TableBody>
|
|
150
177
|
{OPTIONAL_DEPENDENCIES.map((dep) => {
|
|
151
178
|
const isInstalled = dep.packagesRequired.every((pkg) =>
|
|
152
|
-
|
|
179
|
+
isPackageRequirementInstalled(pkg, installedPackages),
|
|
153
180
|
);
|
|
154
181
|
const packageSpec = dep.packagesRequired
|
|
155
182
|
.map((pkg) => pkg.name)
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
prettyScientificNumber,
|
|
6
6
|
} from "@/utils/numbers";
|
|
7
7
|
import { applyFormat } from "../column-formatting/feature";
|
|
8
|
+
import { formatOptions } from "../column-formatting/types";
|
|
8
9
|
|
|
9
10
|
const locale = "en-US";
|
|
10
11
|
|
|
@@ -128,3 +129,9 @@ describe("applyFormat", () => {
|
|
|
128
129
|
).toBe(123);
|
|
129
130
|
});
|
|
130
131
|
});
|
|
132
|
+
|
|
133
|
+
describe("formatOptions", () => {
|
|
134
|
+
it("has no geometry format options", () => {
|
|
135
|
+
expect(formatOptions.geometry).toEqual([]);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
@@ -14,7 +14,7 @@ describe("ChartSchema", () => {
|
|
|
14
14
|
|
|
15
15
|
it("normalizes an unrecognized axis column type", () => {
|
|
16
16
|
const result = ChartSchema.parse({
|
|
17
|
-
general: { xColumn: { field: "geom", type: "
|
|
17
|
+
general: { xColumn: { field: "geom", type: "bogus_type" } },
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
expect(result.general?.xColumn?.type).toBe("unknown");
|
|
@@ -24,7 +24,7 @@ describe("ChartSchema", () => {
|
|
|
24
24
|
const result = ChartSchema.parse({
|
|
25
25
|
tooltips: {
|
|
26
26
|
auto: false,
|
|
27
|
-
fields: [{ field: "geom", type: "
|
|
27
|
+
fields: [{ field: "geom", type: "bogus_type" }],
|
|
28
28
|
},
|
|
29
29
|
});
|
|
30
30
|
|
|
@@ -32,4 +32,19 @@ describe("ChartSchema", () => {
|
|
|
32
32
|
{ field: "geom", type: "unknown" },
|
|
33
33
|
]);
|
|
34
34
|
});
|
|
35
|
+
|
|
36
|
+
it("keeps geometry axis and tooltip field types", () => {
|
|
37
|
+
const result = ChartSchema.parse({
|
|
38
|
+
general: { xColumn: { field: "geom", type: "geometry" } },
|
|
39
|
+
tooltips: {
|
|
40
|
+
auto: false,
|
|
41
|
+
fields: [{ field: "geom", type: "geometry" }],
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
expect(result.general?.xColumn?.type).toBe("geometry");
|
|
46
|
+
expect(result.tooltips?.fields).toEqual([
|
|
47
|
+
{ field: "geom", type: "geometry" },
|
|
48
|
+
]);
|
|
49
|
+
});
|
|
35
50
|
});
|
|
@@ -29,6 +29,7 @@ export function convertDataTypeToVega(
|
|
|
29
29
|
return "quantitative";
|
|
30
30
|
case "string":
|
|
31
31
|
case "boolean":
|
|
32
|
+
case "geometry":
|
|
32
33
|
case "unknown":
|
|
33
34
|
return "nominal";
|
|
34
35
|
case "date":
|
|
@@ -51,6 +52,7 @@ export function convertDataTypeToSelectable(
|
|
|
51
52
|
return "number";
|
|
52
53
|
case "string":
|
|
53
54
|
case "boolean":
|
|
55
|
+
case "geometry":
|
|
54
56
|
case "unknown":
|
|
55
57
|
return "string";
|
|
56
58
|
case "date":
|
|
@@ -13,6 +13,7 @@ export const formatOptions = {
|
|
|
13
13
|
number: ["Auto", "Percent", "Scientific", "Engineering", "Integer"],
|
|
14
14
|
string: ["Uppercase", "Lowercase", "Capitalize", "Title"],
|
|
15
15
|
boolean: ["Yes/No", "On/Off"],
|
|
16
|
+
geometry: [],
|
|
16
17
|
unknown: [],
|
|
17
18
|
} as const satisfies Record<DataType, string[]>;
|
|
18
19
|
|
|
@@ -320,9 +320,8 @@ export function generateColumns<T>({
|
|
|
320
320
|
},
|
|
321
321
|
// Remove any default filtering
|
|
322
322
|
filterFn: undefined,
|
|
323
|
-
//
|
|
324
|
-
|
|
325
|
-
enableSorting: !!key,
|
|
323
|
+
// Unnamed index columns and geometry columns are not sortable
|
|
324
|
+
enableSorting: !!key && getMeta(key).dataType !== "geometry",
|
|
326
325
|
meta: {
|
|
327
326
|
...getMeta(key),
|
|
328
327
|
width: columnWidths?.[key],
|
|
@@ -485,6 +484,8 @@ function getFilterTypeForFieldType(
|
|
|
485
484
|
return "time";
|
|
486
485
|
case "boolean":
|
|
487
486
|
return "boolean";
|
|
487
|
+
case "geometry":
|
|
488
|
+
return undefined;
|
|
488
489
|
default:
|
|
489
490
|
return undefined;
|
|
490
491
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { describe, expect, it } from "vitest";
|
|
4
4
|
import type { DataType } from "@/core/kernel/messages";
|
|
5
|
-
import { DATA_TYPE_ICON, resolveDataType } from "../icons";
|
|
5
|
+
import { DATA_TYPE_ICON, getDataTypeColor, resolveDataType } from "../icons";
|
|
6
6
|
|
|
7
7
|
describe("resolveDataType", () => {
|
|
8
8
|
it("passes through every mapped data type", () => {
|
|
@@ -12,7 +12,15 @@ describe("resolveDataType", () => {
|
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
it("resolves unmapped data types to unknown", () => {
|
|
15
|
-
expect(resolveDataType("
|
|
15
|
+
expect(resolveDataType("bogus_type" as DataType)).toBe("unknown");
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("resolves geometry with its icon and color", () => {
|
|
19
|
+
expect(resolveDataType("geometry")).toBe("geometry");
|
|
20
|
+
expect(DATA_TYPE_ICON.geometry).toBeDefined();
|
|
21
|
+
expect(getDataTypeColor("geometry")).toBe(
|
|
22
|
+
"bg-(--cyan-4) dark:bg-(--cyan-5)",
|
|
23
|
+
);
|
|
16
24
|
});
|
|
17
25
|
|
|
18
26
|
it("resolves data types shadowing Object.prototype keys to unknown", () => {
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
CurlyBracesIcon,
|
|
8
8
|
HashIcon,
|
|
9
9
|
type LucideIcon,
|
|
10
|
+
MapPinIcon,
|
|
10
11
|
ToggleLeftIcon,
|
|
11
12
|
TypeIcon,
|
|
12
13
|
} from "lucide-react";
|
|
@@ -27,6 +28,7 @@ export const DATA_TYPE_ICON: Record<DataType | SelectableDataType, LucideIcon> =
|
|
|
27
28
|
number: HashIcon,
|
|
28
29
|
string: TypeIcon,
|
|
29
30
|
integer: HashIcon,
|
|
31
|
+
geometry: MapPinIcon,
|
|
30
32
|
unknown: CurlyBracesIcon,
|
|
31
33
|
};
|
|
32
34
|
|
|
@@ -56,6 +58,8 @@ export function getDataTypeColor(
|
|
|
56
58
|
return "bg-(--purple-4)";
|
|
57
59
|
case "string":
|
|
58
60
|
return "bg-(--blue-4)";
|
|
61
|
+
case "geometry":
|
|
62
|
+
return "bg-(--cyan-4) dark:bg-(--cyan-5)";
|
|
59
63
|
case "unknown":
|
|
60
64
|
return "bg-(--slate-4) dark:bg-(--slate-6)";
|
|
61
65
|
default:
|
|
@@ -12,7 +12,7 @@ describe("ColumnName", () => {
|
|
|
12
12
|
|
|
13
13
|
try {
|
|
14
14
|
const unrecognized = render(
|
|
15
|
-
<ColumnName columnName="geom" dataType={"
|
|
15
|
+
<ColumnName columnName="geom" dataType={"bogus_type" as DataType} />,
|
|
16
16
|
);
|
|
17
17
|
const unknown = render(
|
|
18
18
|
<ColumnName columnName="geom" dataType="unknown" />,
|
|
@@ -26,4 +26,17 @@ describe("ColumnName", () => {
|
|
|
26
26
|
warn.mockRestore();
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
|
+
|
|
30
|
+
it("renders geometry with a distinct icon", () => {
|
|
31
|
+
const geometry = render(
|
|
32
|
+
<ColumnName columnName="geom" dataType="geometry" />,
|
|
33
|
+
);
|
|
34
|
+
const unknown = render(<ColumnName columnName="geom" dataType="unknown" />);
|
|
35
|
+
|
|
36
|
+
expect(geometry.container.querySelector(".lucide-map-pin")).not.toBeNull();
|
|
37
|
+
expect(unknown.container.querySelector(".lucide-braces")).not.toBeNull();
|
|
38
|
+
expect(geometry.container.innerHTML).not.toEqual(
|
|
39
|
+
unknown.container.innerHTML,
|
|
40
|
+
);
|
|
41
|
+
});
|
|
29
42
|
});
|