@macrostrat/column-views 3.9.0 → 3.11.0
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/CHANGELOG.md +44 -0
- package/dist/column-views.css +10 -0
- package/dist/correlation-chart/main.cjs +11 -3
- package/dist/correlation-chart/main.cjs.map +1 -1
- package/dist/correlation-chart/main.d.ts +1 -1
- package/dist/correlation-chart/main.js +11 -3
- package/dist/correlation-chart/main.js.map +1 -1
- package/dist/index.cjs +18 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -34
- package/dist/index.js.map +1 -1
- package/dist/unit-details/age-window-tag.cjs +68 -0
- package/dist/unit-details/age-window-tag.cjs.map +1 -0
- package/dist/unit-details/age-window-tag.d.ts +26 -0
- package/dist/unit-details/age-window-tag.js +66 -0
- package/dist/unit-details/age-window-tag.js.map +1 -0
- package/dist/unit-details/age-window-tag.module.sass.cjs +12 -0
- package/dist/unit-details/age-window-tag.module.sass.cjs.map +1 -0
- package/dist/unit-details/age-window-tag.module.sass.js +11 -0
- package/dist/unit-details/age-window-tag.module.sass.js.map +1 -0
- package/dist/unit-details/index.d.ts +1 -0
- package/dist/units/boxes.cjs +3 -3
- package/dist/units/boxes.cjs.map +1 -1
- package/dist/units/boxes.js +3 -3
- package/dist/units/boxes.js.map +1 -1
- package/dist/units/index.cjs +7 -11
- package/dist/units/index.cjs.map +1 -1
- package/dist/units/index.d.ts +0 -1
- package/dist/units/index.js +4 -9
- package/dist/units/index.js.map +1 -1
- package/package.json +6 -27
- package/src/correlation-chart/main.ts +14 -2
- package/src/index.ts +3 -1
- package/src/unit-details/age-window-tag.module.sass +10 -0
- package/src/unit-details/age-window-tag.ts +102 -0
- package/src/unit-details/index.ts +1 -0
- package/src/units/boxes.ts +7 -4
- package/src/units/index.ts +9 -26
- package/dist/maps/column-correlation/core.cjs +0 -288
- package/dist/maps/column-correlation/core.cjs.map +0 -1
- package/dist/maps/column-correlation/core.d.ts +0 -9
- package/dist/maps/column-correlation/core.js +0 -286
- package/dist/maps/column-correlation/core.js.map +0 -1
- package/dist/maps/column-correlation/index.d.ts +0 -2
- package/dist/maps/column-correlation/state.cjs +0 -193
- package/dist/maps/column-correlation/state.cjs.map +0 -1
- package/dist/maps/column-correlation/state.d.ts +0 -62
- package/dist/maps/column-correlation/state.js +0 -190
- package/dist/maps/column-correlation/state.js.map +0 -1
- package/dist/maps/column-navigation/index.d.ts +0 -2
- package/dist/maps/column-navigation/mapbox/index.cjs +0 -215
- package/dist/maps/column-navigation/mapbox/index.cjs.map +0 -1
- package/dist/maps/column-navigation/mapbox/index.d.ts +0 -38
- package/dist/maps/column-navigation/mapbox/index.js +0 -213
- package/dist/maps/column-navigation/mapbox/index.js.map +0 -1
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.cjs +0 -105
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.cjs.map +0 -1
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.d.ts +0 -8
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.js +0 -105
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.js.map +0 -1
- package/dist/maps/column-navigation/mapbox/state.cjs +0 -73
- package/dist/maps/column-navigation/mapbox/state.cjs.map +0 -1
- package/dist/maps/column-navigation/mapbox/state.d.ts +0 -23
- package/dist/maps/column-navigation/mapbox/state.js +0 -71
- package/dist/maps/column-navigation/mapbox/state.js.map +0 -1
- package/dist/maps/column-navigation/svg/animated.d.ts +0 -1
- package/dist/maps/column-navigation/svg/data-fetcher.cjs +0 -25
- package/dist/maps/column-navigation/svg/data-fetcher.cjs.map +0 -1
- package/dist/maps/column-navigation/svg/data-fetcher.d.ts +0 -6
- package/dist/maps/column-navigation/svg/data-fetcher.js +0 -25
- package/dist/maps/column-navigation/svg/data-fetcher.js.map +0 -1
- package/dist/maps/column-navigation/svg/index.cjs +0 -94
- package/dist/maps/column-navigation/svg/index.cjs.map +0 -1
- package/dist/maps/column-navigation/svg/index.d.ts +0 -9
- package/dist/maps/column-navigation/svg/index.js +0 -93
- package/dist/maps/column-navigation/svg/index.js.map +0 -1
- package/dist/maps/column-navigation/svg/layers.cjs +0 -177
- package/dist/maps/column-navigation/svg/layers.cjs.map +0 -1
- package/dist/maps/column-navigation/svg/layers.d.ts +0 -54
- package/dist/maps/column-navigation/svg/layers.js +0 -174
- package/dist/maps/column-navigation/svg/layers.js.map +0 -1
- package/dist/maps/column-navigation/utils/keyboard-navigation.cjs +0 -50
- package/dist/maps/column-navigation/utils/keyboard-navigation.cjs.map +0 -1
- package/dist/maps/column-navigation/utils/keyboard-navigation.d.ts +0 -10
- package/dist/maps/column-navigation/utils/keyboard-navigation.js +0 -50
- package/dist/maps/column-navigation/utils/keyboard-navigation.js.map +0 -1
- package/dist/maps/index.d.ts +0 -4
- package/dist/maps/inset-map/index.cjs +0 -71
- package/dist/maps/inset-map/index.cjs.map +0 -1
- package/dist/maps/inset-map/index.d.ts +0 -16
- package/dist/maps/inset-map/index.js +0 -69
- package/dist/maps/inset-map/index.js.map +0 -1
- package/dist/maps/layers/columns.cjs +0 -165
- package/dist/maps/layers/columns.cjs.map +0 -1
- package/dist/maps/layers/columns.d.ts +0 -28
- package/dist/maps/layers/columns.js +0 -165
- package/dist/maps/layers/columns.js.map +0 -1
- package/dist/maps/layers/index.d.ts +0 -2
- package/dist/maps/layers/units.cjs +0 -207
- package/dist/maps/layers/units.cjs.map +0 -1
- package/dist/maps/layers/units.d.ts +0 -14
- package/dist/maps/layers/units.js +0 -204
- package/dist/maps/layers/units.js.map +0 -1
- package/dist/units/colors.cjs +0 -115
- package/dist/units/colors.cjs.map +0 -1
- package/dist/units/colors.d.ts +0 -20
- package/dist/units/colors.js +0 -113
- package/dist/units/colors.js.map +0 -1
- package/dist/units/resolvers.cjs +0 -125
- package/dist/units/resolvers.cjs.map +0 -1
- package/dist/units/resolvers.d.ts +0 -8
- package/dist/units/resolvers.js +0 -125
- package/dist/units/resolvers.js.map +0 -1
- package/src/maps/column-correlation/column-correlation-map.stories.ts +0 -108
- package/src/maps/column-correlation/core.ts +0 -342
- package/src/maps/column-correlation/index.ts +0 -2
- package/src/maps/column-correlation/state.ts +0 -315
- package/src/maps/column-navigation/index.ts +0 -2
- package/src/maps/column-navigation/mapbox/column-navigation-map.stories.ts +0 -278
- package/src/maps/column-navigation/mapbox/index.ts +0 -276
- package/src/maps/column-navigation/mapbox/keyboard-navigation.ts +0 -133
- package/src/maps/column-navigation/mapbox/state.ts +0 -119
- package/src/maps/column-navigation/svg/animated.ts +0 -78
- package/src/maps/column-navigation/svg/column-navigation-svg-map.stories.ts +0 -46
- package/src/maps/column-navigation/svg/data-fetcher.ts +0 -34
- package/src/maps/column-navigation/svg/index.ts +0 -96
- package/src/maps/column-navigation/svg/layers.ts +0 -233
- package/src/maps/column-navigation/utils/keyboard-navigation.ts +0 -58
- package/src/maps/index.ts +0 -4
- package/src/maps/inset-map/index.ts +0 -87
- package/src/maps/inset-map/inset-map.stories.ts +0 -20
- package/src/maps/layers/columns.ts +0 -216
- package/src/maps/layers/index.ts +0 -2
- package/src/maps/layers/units.ts +0 -286
- package/src/maps/unit-map.stories.ts +0 -79
- package/src/units/colors.ts +0 -183
- package/src/units/resolvers.ts +0 -141
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { MapViewProps } from '@macrostrat/map-interface';
|
|
2
|
-
import { ReactNode, CSSProperties } from 'react';
|
|
3
|
-
export interface InsetMapProps extends Omit<MapViewProps, "style"> {
|
|
4
|
-
controls?: ReactNode;
|
|
5
|
-
className?: string;
|
|
6
|
-
children?: ReactNode;
|
|
7
|
-
style?: CSSProperties;
|
|
8
|
-
mapStyle?: mapboxgl.Style | string;
|
|
9
|
-
showLabels?: boolean;
|
|
10
|
-
showAdmin?: boolean;
|
|
11
|
-
showRoads?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare function InsetMap({ controls, className, children, style, mapStyle, accessToken, showLabels, showAdmin, showRoads, ...rest }: InsetMapProps): import('react').ReactElement<{
|
|
14
|
-
className: string | undefined;
|
|
15
|
-
style: CSSProperties | undefined;
|
|
16
|
-
}, string | import('react').JSXElementConstructor<any>>;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { useMemo, useCallback } from "react";
|
|
2
|
-
import { getBasicMapStyle, MapView } from "@macrostrat/map-interface";
|
|
3
|
-
import h from "@macrostrat/hyper";
|
|
4
|
-
import { MapboxMapProvider } from "@macrostrat/mapbox-react";
|
|
5
|
-
import { useInDarkMode } from "@macrostrat/ui-components";
|
|
6
|
-
import { removeMapLabels, removeSourceFromStyle } from "@macrostrat/mapbox-utils";
|
|
7
|
-
function InsetMap({
|
|
8
|
-
controls,
|
|
9
|
-
className,
|
|
10
|
-
children,
|
|
11
|
-
style,
|
|
12
|
-
mapStyle,
|
|
13
|
-
accessToken,
|
|
14
|
-
showLabels = false,
|
|
15
|
-
showAdmin = false,
|
|
16
|
-
showRoads = false,
|
|
17
|
-
...rest
|
|
18
|
-
}) {
|
|
19
|
-
const inDarkMode = useInDarkMode();
|
|
20
|
-
const _style = useMemo(() => {
|
|
21
|
-
return mapStyle ?? getBasicMapStyle({ inDarkMode });
|
|
22
|
-
}, [mapStyle, inDarkMode]);
|
|
23
|
-
const transformStyle = useCallback(
|
|
24
|
-
(style2) => {
|
|
25
|
-
let newStyle = style2;
|
|
26
|
-
if (!showLabels) {
|
|
27
|
-
newStyle = removeMapLabels(newStyle);
|
|
28
|
-
}
|
|
29
|
-
if (!showAdmin) {
|
|
30
|
-
newStyle = removeSourceFromStyle(newStyle, null, "admin");
|
|
31
|
-
}
|
|
32
|
-
if (!showRoads) {
|
|
33
|
-
newStyle = removeSourceFromStyle(newStyle, null, "road");
|
|
34
|
-
newStyle = removeSourceFromStyle(newStyle, null, "aeroway");
|
|
35
|
-
}
|
|
36
|
-
return newStyle;
|
|
37
|
-
},
|
|
38
|
-
[mapStyle, showLabels, showRoads, showAdmin]
|
|
39
|
-
);
|
|
40
|
-
return h("div.inset-map", { className, style }, [
|
|
41
|
-
h(MapboxMapProvider, [
|
|
42
|
-
controls,
|
|
43
|
-
h(
|
|
44
|
-
MapView,
|
|
45
|
-
{
|
|
46
|
-
style: _style,
|
|
47
|
-
accessToken,
|
|
48
|
-
standalone: true,
|
|
49
|
-
/* Default map position that centers on the bulk of Macrostrat columns
|
|
50
|
-
*/
|
|
51
|
-
mapPosition: {
|
|
52
|
-
camera: {
|
|
53
|
-
lng: -100,
|
|
54
|
-
lat: 38,
|
|
55
|
-
altitude: 5e6
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
transformStyle,
|
|
59
|
-
...rest
|
|
60
|
-
},
|
|
61
|
-
children
|
|
62
|
-
)
|
|
63
|
-
])
|
|
64
|
-
]);
|
|
65
|
-
}
|
|
66
|
-
export {
|
|
67
|
-
InsetMap
|
|
68
|
-
};
|
|
69
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/maps/inset-map/index.ts"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\nimport {\n MapView,\n getBasicMapStyle,\n MapViewProps,\n} from \"@macrostrat/map-interface\";\nimport h from \"@macrostrat/hyper\";\nimport { MapboxMapProvider } from \"@macrostrat/mapbox-react\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport {\n removeMapLabels,\n removeSourceFromStyle,\n} from \"@macrostrat/mapbox-utils\";\nimport type { ReactNode, CSSProperties } from \"react\";\n\nexport interface InsetMapProps extends Omit<MapViewProps, \"style\"> {\n controls?: ReactNode;\n className?: string;\n children?: ReactNode;\n style?: CSSProperties;\n mapStyle?: mapboxgl.Style | string;\n showLabels?: boolean;\n showAdmin?: boolean;\n showRoads?: boolean;\n}\n\nexport function InsetMap({\n controls,\n className,\n children,\n style,\n mapStyle,\n accessToken,\n showLabels = false,\n showAdmin = false,\n showRoads = false,\n ...rest\n}: InsetMapProps) {\n const inDarkMode = useInDarkMode();\n const _style = useMemo((): mapboxgl.Style | string => {\n return mapStyle ?? getBasicMapStyle({ inDarkMode });\n }, [mapStyle, inDarkMode]);\n\n const transformStyle = useCallback(\n (style) => {\n let newStyle = style;\n if (!showLabels) {\n newStyle = removeMapLabels(newStyle);\n }\n if (!showAdmin) {\n newStyle = removeSourceFromStyle(newStyle, null, \"admin\");\n }\n if (!showRoads) {\n newStyle = removeSourceFromStyle(newStyle, null, \"road\");\n newStyle = removeSourceFromStyle(newStyle, null, \"aeroway\");\n }\n return newStyle;\n },\n [mapStyle, showLabels, showRoads, showAdmin],\n );\n\n return h(\"div.inset-map\", { className, style }, [\n h(MapboxMapProvider, [\n controls,\n h(\n MapView,\n {\n style: _style,\n accessToken,\n standalone: true,\n /* Default map position that centers on the bulk of Macrostrat columns\n */\n mapPosition: {\n camera: {\n lng: -100,\n lat: 38,\n altitude: 5000000,\n },\n },\n transformStyle,\n ...rest,\n },\n children,\n ),\n ]),\n ]);\n}\n"],"names":["style"],"mappings":";;;;;;AA0BO,SAAS,SAAS;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,GAAG;AACL,GAAkB;AAChB,QAAM,aAAa,cAAA;AACnB,QAAM,SAAS,QAAQ,MAA+B;AACpD,WAAO,YAAY,iBAAiB,EAAE,YAAY;AAAA,EACpD,GAAG,CAAC,UAAU,UAAU,CAAC;AAEzB,QAAM,iBAAiB;AAAA,IACrB,CAACA,WAAU;AACT,UAAI,WAAWA;AACf,UAAI,CAAC,YAAY;AACf,mBAAW,gBAAgB,QAAQ;AAAA,MACrC;AACA,UAAI,CAAC,WAAW;AACd,mBAAW,sBAAsB,UAAU,MAAM,OAAO;AAAA,MAC1D;AACA,UAAI,CAAC,WAAW;AACd,mBAAW,sBAAsB,UAAU,MAAM,MAAM;AACvD,mBAAW,sBAAsB,UAAU,MAAM,SAAS;AAAA,MAC5D;AACA,aAAO;AAAA,IACT;AAAA,IACA,CAAC,UAAU,YAAY,WAAW,SAAS;AAAA,EAAA;AAG7C,SAAO,EAAE,iBAAiB,EAAE,WAAW,SAAS;AAAA,IAC9C,EAAE,mBAAmB;AAAA,MACnB;AAAA,MACA;AAAA,QACE;AAAA,QACA;AAAA,UACE,OAAO;AAAA,UACP;AAAA,UACA,YAAY;AAAA;AAAA;AAAA,UAGZ,aAAa;AAAA,YACX,QAAQ;AAAA,cACN,KAAK;AAAA,cACL,KAAK;AAAA,cACL,UAAU;AAAA,YAAA;AAAA,UACZ;AAAA,UAEF;AAAA,UACA,GAAG;AAAA,QAAA;AAAA,QAEL;AAAA,MAAA;AAAA,IACF,CACD;AAAA,EAAA,CACF;AACH;"}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const mapboxReact = require("@macrostrat/mapbox-react");
|
|
4
|
-
const mapboxUtils = require("@macrostrat/mapbox-utils");
|
|
5
|
-
const colorUtils = require("@macrostrat/color-utils");
|
|
6
|
-
function BaseColumnsLayer({
|
|
7
|
-
enabled = true,
|
|
8
|
-
columns,
|
|
9
|
-
...rest
|
|
10
|
-
}) {
|
|
11
|
-
mapboxReact.useOverlayStyle(() => enabled ? buildColumnsStyle(rest) : null, [enabled]);
|
|
12
|
-
mapboxReact.useMapStyleOperator(
|
|
13
|
-
(map) => {
|
|
14
|
-
if (columns == null) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
mapboxUtils.setGeoJSON(map, "columns", promoteToFeatureCollection(columns));
|
|
18
|
-
},
|
|
19
|
-
[columns, enabled]
|
|
20
|
-
);
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
function promoteToFeatureCollection(data) {
|
|
24
|
-
if (data == null) return null;
|
|
25
|
-
if ("type" in data && data.type == "Feature") {
|
|
26
|
-
return {
|
|
27
|
-
type: "FeatureCollection",
|
|
28
|
-
features: [data]
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
if ("type" in data && data.type == "FeatureCollection" && "features" in data) {
|
|
32
|
-
return data;
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
type: "FeatureCollection",
|
|
36
|
-
features: data
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function buildColumnsStyle(opts = {}) {
|
|
40
|
-
const { color } = opts;
|
|
41
|
-
const columnBaseColor = color ?? colorUtils.getCSSVariable("--text-subtle-color", "black");
|
|
42
|
-
let columnColor = columnBaseColor;
|
|
43
|
-
const columnSelectedColor = opts.selectedColor ?? colorUtils.getCSSVariable("--selection-color", "purple");
|
|
44
|
-
const lineColor = opts.lineColor ?? columnBaseColor;
|
|
45
|
-
const isHovered = [
|
|
46
|
-
"any",
|
|
47
|
-
["boolean", ["feature-state", "hover"], false],
|
|
48
|
-
["boolean", ["feature-state", "highlighted"], false]
|
|
49
|
-
];
|
|
50
|
-
if (typeof columnColor === "string") {
|
|
51
|
-
columnColor = [
|
|
52
|
-
"coalesce",
|
|
53
|
-
["feature-state", "color"],
|
|
54
|
-
["get", "color"],
|
|
55
|
-
columnColor
|
|
56
|
-
];
|
|
57
|
-
}
|
|
58
|
-
const fillOpacity = opts.opacity ?? 0.1;
|
|
59
|
-
const lineOpacity = opts.lineOpacity ?? 0.5;
|
|
60
|
-
const lineWidth = opts.lineWidth ?? 2;
|
|
61
|
-
const circleRadius = opts.circleRadius ?? 4;
|
|
62
|
-
return {
|
|
63
|
-
sources: {
|
|
64
|
-
columns: mapboxUtils.buildGeoJSONSource()
|
|
65
|
-
},
|
|
66
|
-
version: 8,
|
|
67
|
-
layers: [
|
|
68
|
-
{
|
|
69
|
-
id: "columns-fill",
|
|
70
|
-
type: "fill",
|
|
71
|
-
source: "columns",
|
|
72
|
-
paint: {
|
|
73
|
-
"fill-color": columnColor,
|
|
74
|
-
"fill-opacity": fillOpacity
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
id: "columns-points",
|
|
79
|
-
type: "circle",
|
|
80
|
-
source: "columns",
|
|
81
|
-
paint: {
|
|
82
|
-
"circle-radius": circleRadius,
|
|
83
|
-
"circle-color": columnColor,
|
|
84
|
-
"circle-opacity": fillOpacity
|
|
85
|
-
},
|
|
86
|
-
filter: ["==", "$type", "Point"]
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
id: "columns-line",
|
|
90
|
-
type: "line",
|
|
91
|
-
source: "columns",
|
|
92
|
-
paint: {
|
|
93
|
-
"line-color": ["case", isHovered, columnSelectedColor, lineColor],
|
|
94
|
-
"line-width": lineWidth,
|
|
95
|
-
"line-opacity": ["case", isHovered, 1, lineOpacity]
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
]
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
const selectedColumnSourceID = "selectedColumn";
|
|
102
|
-
function SelectedColumnOverlay({
|
|
103
|
-
selectedColumn,
|
|
104
|
-
...styleOpts
|
|
105
|
-
}) {
|
|
106
|
-
mapboxReact.useOverlayStyle(() => buildSelectedColumnStyle(styleOpts), []);
|
|
107
|
-
mapboxReact.useMapStyleOperator(
|
|
108
|
-
(map) => {
|
|
109
|
-
mapboxUtils.setGeoJSON(
|
|
110
|
-
map,
|
|
111
|
-
selectedColumnSourceID,
|
|
112
|
-
promoteToFeatureCollection(selectedColumn)
|
|
113
|
-
);
|
|
114
|
-
},
|
|
115
|
-
[selectedColumn]
|
|
116
|
-
);
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
function buildSelectedColumnStyle(opts = {}) {
|
|
120
|
-
const columnSelectedColor = opts.color ?? colorUtils.getCSSVariable("--selection-color", "purple");
|
|
121
|
-
return {
|
|
122
|
-
sources: {
|
|
123
|
-
selectedColumn: mapboxUtils.buildGeoJSONSource()
|
|
124
|
-
},
|
|
125
|
-
version: 8,
|
|
126
|
-
layers: [
|
|
127
|
-
{
|
|
128
|
-
id: "selected-column-highlight",
|
|
129
|
-
type: "fill",
|
|
130
|
-
source: selectedColumnSourceID,
|
|
131
|
-
paint: {
|
|
132
|
-
"fill-color": columnSelectedColor,
|
|
133
|
-
"fill-opacity": 0.5
|
|
134
|
-
},
|
|
135
|
-
filter: ["==", "$type", "Polygon"]
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
id: "selected-column-edge",
|
|
139
|
-
type: "line",
|
|
140
|
-
source: selectedColumnSourceID,
|
|
141
|
-
paint: {
|
|
142
|
-
"line-color": columnSelectedColor,
|
|
143
|
-
"line-width": 2,
|
|
144
|
-
"line-opacity": 1
|
|
145
|
-
},
|
|
146
|
-
filter: ["==", "$type", "Polygon"]
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
id: "selected-column-point",
|
|
150
|
-
type: "circle",
|
|
151
|
-
source: selectedColumnSourceID,
|
|
152
|
-
paint: {
|
|
153
|
-
"circle-radius": 6,
|
|
154
|
-
"circle-color": columnSelectedColor,
|
|
155
|
-
"circle-opacity": 1
|
|
156
|
-
},
|
|
157
|
-
filter: ["==", "$type", "Point"]
|
|
158
|
-
}
|
|
159
|
-
]
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
exports.BaseColumnsLayer = BaseColumnsLayer;
|
|
163
|
-
exports.SelectedColumnOverlay = SelectedColumnOverlay;
|
|
164
|
-
exports.buildColumnsStyle = buildColumnsStyle;
|
|
165
|
-
//# sourceMappingURL=columns.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"columns.cjs","sources":["../../../src/maps/layers/columns.ts"],"sourcesContent":["import { useMapStyleOperator, useOverlayStyle } from \"@macrostrat/mapbox-react\";\nimport { setGeoJSON } from \"@macrostrat/mapbox-utils\";\nimport GeoJSON, { FeatureCollection } from \"geojson\";\nimport { GeoJSONFeature } from \"mapbox-gl\";\nimport { getCSSVariable } from \"@macrostrat/color-utils\";\nimport { buildGeoJSONSource } from \"@macrostrat/mapbox-utils\";\nimport { StyleFragment } from \"@macrostrat/mapbox-react\";\n\nexport interface ColumnsStyleOptions {\n color?: string | any[];\n selectedColor?: string | any[];\n opacity?: number | any[];\n circleRadius?: number | any[];\n lineOpacity?: number | any[];\n lineWidth?: number | any[];\n lineColor?: string | any[];\n}\n\ninterface ColumnLayerOptions extends ColumnsStyleOptions {\n enabled: boolean;\n columns: FeatureCollection | GeoJSONFeature[];\n}\n\nexport function BaseColumnsLayer({\n enabled = true,\n columns,\n ...rest\n}: ColumnLayerOptions) {\n useOverlayStyle(() => (enabled ? buildColumnsStyle(rest) : null), [enabled]);\n\n useMapStyleOperator(\n (map) => {\n if (columns == null) {\n return;\n }\n\n setGeoJSON(map, \"columns\", promoteToFeatureCollection(columns));\n },\n [columns, enabled],\n );\n return null;\n}\n\nfunction promoteToFeatureCollection(\n data: FeatureCollection | GeoJSONFeature | GeoJSONFeature[] | null,\n): FeatureCollection | null {\n if (data == null) return null;\n if (\"type\" in data && data.type == \"Feature\") {\n return {\n type: \"FeatureCollection\",\n features: [data],\n };\n }\n if (\n \"type\" in data &&\n data.type == \"FeatureCollection\" &&\n \"features\" in data\n ) {\n return data;\n }\n return {\n type: \"FeatureCollection\",\n features: data,\n };\n}\n\nexport function buildColumnsStyle(\n opts: ColumnsStyleOptions = {},\n): StyleFragment {\n const { color } = opts;\n const columnBaseColor =\n color ?? getCSSVariable(\"--text-subtle-color\", \"black\");\n let columnColor: any = columnBaseColor;\n const columnSelectedColor =\n opts.selectedColor ?? getCSSVariable(\"--selection-color\", \"purple\");\n\n const lineColor = opts.lineColor ?? columnBaseColor;\n // Highlight on either direct map hover or an externally-driven highlight\n // (e.g. hovering the corresponding column header elsewhere in the UI).\n const isHovered = [\n \"any\",\n [\"boolean\", [\"feature-state\", \"hover\"], false],\n [\"boolean\", [\"feature-state\", \"highlighted\"], false],\n ];\n // If color is in the feature state or geojson properties, use that as second choice\n if (typeof columnColor === \"string\") {\n columnColor = [\n \"coalesce\",\n [\"feature-state\", \"color\"],\n [\"get\", \"color\"],\n columnColor,\n ];\n }\n\n const fillOpacity = opts.opacity ?? 0.1;\n\n const lineOpacity = opts.lineOpacity ?? 0.5;\n const lineWidth = opts.lineWidth ?? 2;\n\n const circleRadius = opts.circleRadius ?? 4;\n\n return {\n sources: {\n columns: buildGeoJSONSource(),\n },\n version: 8,\n layers: [\n {\n id: \"columns-fill\",\n type: \"fill\",\n source: \"columns\",\n paint: {\n \"fill-color\": columnColor,\n \"fill-opacity\": fillOpacity,\n },\n },\n {\n id: \"columns-points\",\n type: \"circle\",\n source: \"columns\",\n paint: {\n \"circle-radius\": circleRadius,\n \"circle-color\": columnColor,\n \"circle-opacity\": fillOpacity,\n },\n filter: [\"==\", \"$type\", \"Point\"],\n },\n {\n id: \"columns-line\",\n type: \"line\",\n source: \"columns\",\n paint: {\n \"line-color\": [\"case\", isHovered, columnSelectedColor, lineColor],\n \"line-width\": lineWidth,\n \"line-opacity\": [\"case\", isHovered, 1.0, lineOpacity],\n },\n },\n ],\n };\n}\n\nexport type ColumnFeature = GeoJSON.Feature & { id: number };\n\nconst selectedColumnSourceID = \"selectedColumn\";\n\nexport function SelectedColumnOverlay({\n selectedColumn,\n ...styleOpts\n}: { selectedColumn: ColumnFeature | null } & SelectedColumnStyleOpts) {\n useOverlayStyle(() => buildSelectedColumnStyle(styleOpts), []);\n\n useMapStyleOperator(\n (map) => {\n setGeoJSON(\n map,\n selectedColumnSourceID,\n promoteToFeatureCollection(selectedColumn as GeoJSONFeature | null),\n );\n },\n [selectedColumn],\n );\n\n return null;\n}\n\ninterface SelectedColumnStyleOpts {\n color?: string | any[];\n}\n\nfunction buildSelectedColumnStyle(\n opts: SelectedColumnStyleOpts = {},\n): StyleFragment {\n const columnSelectedColor: any =\n opts.color ?? getCSSVariable(\"--selection-color\", \"purple\");\n\n return {\n sources: {\n selectedColumn: buildGeoJSONSource(),\n },\n version: 8,\n layers: [\n {\n id: \"selected-column-highlight\",\n type: \"fill\",\n source: selectedColumnSourceID,\n paint: {\n \"fill-color\": columnSelectedColor,\n \"fill-opacity\": 0.5,\n },\n filter: [\"==\", \"$type\", \"Polygon\"],\n },\n {\n id: \"selected-column-edge\",\n type: \"line\",\n source: selectedColumnSourceID,\n paint: {\n \"line-color\": columnSelectedColor,\n \"line-width\": 2,\n \"line-opacity\": 1.0,\n },\n filter: [\"==\", \"$type\", \"Polygon\"],\n },\n {\n id: \"selected-column-point\",\n type: \"circle\",\n source: selectedColumnSourceID,\n paint: {\n \"circle-radius\": 6,\n \"circle-color\": columnSelectedColor,\n \"circle-opacity\": 1.0,\n },\n filter: [\"==\", \"$type\", \"Point\"],\n },\n ],\n };\n}\n"],"names":["useOverlayStyle","useMapStyleOperator","setGeoJSON","getCSSVariable","buildGeoJSONSource"],"mappings":";;;;;AAuBO,SAAS,iBAAiB;AAAA,EAC/B,UAAU;AAAA,EACV;AAAA,EACA,GAAG;AACL,GAAuB;AACrBA,cAAAA,gBAAgB,MAAO,UAAU,kBAAkB,IAAI,IAAI,MAAO,CAAC,OAAO,CAAC;AAE3EC,cAAAA;AAAAA,IACE,CAAC,QAAQ;AACP,UAAI,WAAW,MAAM;AACnB;AAAA,MACF;AAEAC,kBAAAA,WAAW,KAAK,WAAW,2BAA2B,OAAO,CAAC;AAAA,IAChE;AAAA,IACA,CAAC,SAAS,OAAO;AAAA,EAAA;AAEnB,SAAO;AACT;AAEA,SAAS,2BACP,MAC0B;AAC1B,MAAI,QAAQ,KAAM,QAAO;AACzB,MAAI,UAAU,QAAQ,KAAK,QAAQ,WAAW;AAC5C,WAAO;AAAA,MACL,MAAM;AAAA,MACN,UAAU,CAAC,IAAI;AAAA,IAAA;AAAA,EAEnB;AACA,MACE,UAAU,QACV,KAAK,QAAQ,uBACb,cAAc,MACd;AACA,WAAO;AAAA,EACT;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,EAAA;AAEd;AAEO,SAAS,kBACd,OAA4B,IACb;AACf,QAAM,EAAE,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C;AAAA,EACF;AAEJ;;;;"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { default as GeoJSON, FeatureCollection } from 'geojson';
|
|
2
|
-
import { GeoJSONFeature } from 'mapbox-gl';
|
|
3
|
-
import { StyleFragment } from '@macrostrat/mapbox-react';
|
|
4
|
-
export interface ColumnsStyleOptions {
|
|
5
|
-
color?: string | any[];
|
|
6
|
-
selectedColor?: string | any[];
|
|
7
|
-
opacity?: number | any[];
|
|
8
|
-
circleRadius?: number | any[];
|
|
9
|
-
lineOpacity?: number | any[];
|
|
10
|
-
lineWidth?: number | any[];
|
|
11
|
-
lineColor?: string | any[];
|
|
12
|
-
}
|
|
13
|
-
interface ColumnLayerOptions extends ColumnsStyleOptions {
|
|
14
|
-
enabled: boolean;
|
|
15
|
-
columns: FeatureCollection | GeoJSONFeature[];
|
|
16
|
-
}
|
|
17
|
-
export declare function BaseColumnsLayer({ enabled, columns, ...rest }: ColumnLayerOptions): null;
|
|
18
|
-
export declare function buildColumnsStyle(opts?: ColumnsStyleOptions): StyleFragment;
|
|
19
|
-
export type ColumnFeature = GeoJSON.Feature & {
|
|
20
|
-
id: number;
|
|
21
|
-
};
|
|
22
|
-
export declare function SelectedColumnOverlay({ selectedColumn, ...styleOpts }: {
|
|
23
|
-
selectedColumn: ColumnFeature | null;
|
|
24
|
-
} & SelectedColumnStyleOpts): null;
|
|
25
|
-
interface SelectedColumnStyleOpts {
|
|
26
|
-
color?: string | any[];
|
|
27
|
-
}
|
|
28
|
-
export {};
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { useOverlayStyle, useMapStyleOperator } from "@macrostrat/mapbox-react";
|
|
2
|
-
import { setGeoJSON, buildGeoJSONSource } from "@macrostrat/mapbox-utils";
|
|
3
|
-
import { getCSSVariable } from "@macrostrat/color-utils";
|
|
4
|
-
function BaseColumnsLayer({
|
|
5
|
-
enabled = true,
|
|
6
|
-
columns,
|
|
7
|
-
...rest
|
|
8
|
-
}) {
|
|
9
|
-
useOverlayStyle(() => enabled ? buildColumnsStyle(rest) : null, [enabled]);
|
|
10
|
-
useMapStyleOperator(
|
|
11
|
-
(map) => {
|
|
12
|
-
if (columns == null) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
setGeoJSON(map, "columns", promoteToFeatureCollection(columns));
|
|
16
|
-
},
|
|
17
|
-
[columns, enabled]
|
|
18
|
-
);
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
function promoteToFeatureCollection(data) {
|
|
22
|
-
if (data == null) return null;
|
|
23
|
-
if ("type" in data && data.type == "Feature") {
|
|
24
|
-
return {
|
|
25
|
-
type: "FeatureCollection",
|
|
26
|
-
features: [data]
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
if ("type" in data && data.type == "FeatureCollection" && "features" in data) {
|
|
30
|
-
return data;
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
type: "FeatureCollection",
|
|
34
|
-
features: data
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
function buildColumnsStyle(opts = {}) {
|
|
38
|
-
const { color } = opts;
|
|
39
|
-
const columnBaseColor = color ?? getCSSVariable("--text-subtle-color", "black");
|
|
40
|
-
let columnColor = columnBaseColor;
|
|
41
|
-
const columnSelectedColor = opts.selectedColor ?? getCSSVariable("--selection-color", "purple");
|
|
42
|
-
const lineColor = opts.lineColor ?? columnBaseColor;
|
|
43
|
-
const isHovered = [
|
|
44
|
-
"any",
|
|
45
|
-
["boolean", ["feature-state", "hover"], false],
|
|
46
|
-
["boolean", ["feature-state", "highlighted"], false]
|
|
47
|
-
];
|
|
48
|
-
if (typeof columnColor === "string") {
|
|
49
|
-
columnColor = [
|
|
50
|
-
"coalesce",
|
|
51
|
-
["feature-state", "color"],
|
|
52
|
-
["get", "color"],
|
|
53
|
-
columnColor
|
|
54
|
-
];
|
|
55
|
-
}
|
|
56
|
-
const fillOpacity = opts.opacity ?? 0.1;
|
|
57
|
-
const lineOpacity = opts.lineOpacity ?? 0.5;
|
|
58
|
-
const lineWidth = opts.lineWidth ?? 2;
|
|
59
|
-
const circleRadius = opts.circleRadius ?? 4;
|
|
60
|
-
return {
|
|
61
|
-
sources: {
|
|
62
|
-
columns: buildGeoJSONSource()
|
|
63
|
-
},
|
|
64
|
-
version: 8,
|
|
65
|
-
layers: [
|
|
66
|
-
{
|
|
67
|
-
id: "columns-fill",
|
|
68
|
-
type: "fill",
|
|
69
|
-
source: "columns",
|
|
70
|
-
paint: {
|
|
71
|
-
"fill-color": columnColor,
|
|
72
|
-
"fill-opacity": fillOpacity
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
id: "columns-points",
|
|
77
|
-
type: "circle",
|
|
78
|
-
source: "columns",
|
|
79
|
-
paint: {
|
|
80
|
-
"circle-radius": circleRadius,
|
|
81
|
-
"circle-color": columnColor,
|
|
82
|
-
"circle-opacity": fillOpacity
|
|
83
|
-
},
|
|
84
|
-
filter: ["==", "$type", "Point"]
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
id: "columns-line",
|
|
88
|
-
type: "line",
|
|
89
|
-
source: "columns",
|
|
90
|
-
paint: {
|
|
91
|
-
"line-color": ["case", isHovered, columnSelectedColor, lineColor],
|
|
92
|
-
"line-width": lineWidth,
|
|
93
|
-
"line-opacity": ["case", isHovered, 1, lineOpacity]
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
]
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
const selectedColumnSourceID = "selectedColumn";
|
|
100
|
-
function SelectedColumnOverlay({
|
|
101
|
-
selectedColumn,
|
|
102
|
-
...styleOpts
|
|
103
|
-
}) {
|
|
104
|
-
useOverlayStyle(() => buildSelectedColumnStyle(styleOpts), []);
|
|
105
|
-
useMapStyleOperator(
|
|
106
|
-
(map) => {
|
|
107
|
-
setGeoJSON(
|
|
108
|
-
map,
|
|
109
|
-
selectedColumnSourceID,
|
|
110
|
-
promoteToFeatureCollection(selectedColumn)
|
|
111
|
-
);
|
|
112
|
-
},
|
|
113
|
-
[selectedColumn]
|
|
114
|
-
);
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
function buildSelectedColumnStyle(opts = {}) {
|
|
118
|
-
const columnSelectedColor = opts.color ?? getCSSVariable("--selection-color", "purple");
|
|
119
|
-
return {
|
|
120
|
-
sources: {
|
|
121
|
-
selectedColumn: buildGeoJSONSource()
|
|
122
|
-
},
|
|
123
|
-
version: 8,
|
|
124
|
-
layers: [
|
|
125
|
-
{
|
|
126
|
-
id: "selected-column-highlight",
|
|
127
|
-
type: "fill",
|
|
128
|
-
source: selectedColumnSourceID,
|
|
129
|
-
paint: {
|
|
130
|
-
"fill-color": columnSelectedColor,
|
|
131
|
-
"fill-opacity": 0.5
|
|
132
|
-
},
|
|
133
|
-
filter: ["==", "$type", "Polygon"]
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
id: "selected-column-edge",
|
|
137
|
-
type: "line",
|
|
138
|
-
source: selectedColumnSourceID,
|
|
139
|
-
paint: {
|
|
140
|
-
"line-color": columnSelectedColor,
|
|
141
|
-
"line-width": 2,
|
|
142
|
-
"line-opacity": 1
|
|
143
|
-
},
|
|
144
|
-
filter: ["==", "$type", "Polygon"]
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
id: "selected-column-point",
|
|
148
|
-
type: "circle",
|
|
149
|
-
source: selectedColumnSourceID,
|
|
150
|
-
paint: {
|
|
151
|
-
"circle-radius": 6,
|
|
152
|
-
"circle-color": columnSelectedColor,
|
|
153
|
-
"circle-opacity": 1
|
|
154
|
-
},
|
|
155
|
-
filter: ["==", "$type", "Point"]
|
|
156
|
-
}
|
|
157
|
-
]
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
export {
|
|
161
|
-
BaseColumnsLayer,
|
|
162
|
-
SelectedColumnOverlay,
|
|
163
|
-
buildColumnsStyle
|
|
164
|
-
};
|
|
165
|
-
//# sourceMappingURL=columns.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"columns.js","sources":["../../../src/maps/layers/columns.ts"],"sourcesContent":["import { useMapStyleOperator, useOverlayStyle } from \"@macrostrat/mapbox-react\";\nimport { setGeoJSON } from \"@macrostrat/mapbox-utils\";\nimport GeoJSON, { FeatureCollection } from \"geojson\";\nimport { GeoJSONFeature } from \"mapbox-gl\";\nimport { getCSSVariable } from \"@macrostrat/color-utils\";\nimport { buildGeoJSONSource } from \"@macrostrat/mapbox-utils\";\nimport { StyleFragment } from \"@macrostrat/mapbox-react\";\n\nexport interface ColumnsStyleOptions {\n color?: string | any[];\n selectedColor?: string | any[];\n opacity?: number | any[];\n circleRadius?: number | any[];\n lineOpacity?: number | any[];\n lineWidth?: number | any[];\n lineColor?: string | any[];\n}\n\ninterface ColumnLayerOptions extends ColumnsStyleOptions {\n enabled: boolean;\n columns: FeatureCollection | GeoJSONFeature[];\n}\n\nexport function BaseColumnsLayer({\n enabled = true,\n columns,\n ...rest\n}: ColumnLayerOptions) {\n useOverlayStyle(() => (enabled ? buildColumnsStyle(rest) : null), [enabled]);\n\n useMapStyleOperator(\n (map) => {\n if (columns == null) {\n return;\n }\n\n setGeoJSON(map, \"columns\", promoteToFeatureCollection(columns));\n },\n [columns, enabled],\n );\n return null;\n}\n\nfunction promoteToFeatureCollection(\n data: FeatureCollection | GeoJSONFeature | GeoJSONFeature[] | null,\n): FeatureCollection | null {\n if (data == null) return null;\n if (\"type\" in data && data.type == \"Feature\") {\n return {\n type: \"FeatureCollection\",\n features: [data],\n };\n }\n if (\n \"type\" in data &&\n data.type == \"FeatureCollection\" &&\n \"features\" in data\n ) {\n return data;\n }\n return {\n type: \"FeatureCollection\",\n features: data,\n };\n}\n\nexport function buildColumnsStyle(\n opts: ColumnsStyleOptions = {},\n): StyleFragment {\n const { color } = opts;\n const columnBaseColor =\n color ?? getCSSVariable(\"--text-subtle-color\", \"black\");\n let columnColor: any = columnBaseColor;\n const columnSelectedColor =\n opts.selectedColor ?? getCSSVariable(\"--selection-color\", \"purple\");\n\n const lineColor = opts.lineColor ?? columnBaseColor;\n // Highlight on either direct map hover or an externally-driven highlight\n // (e.g. hovering the corresponding column header elsewhere in the UI).\n const isHovered = [\n \"any\",\n [\"boolean\", [\"feature-state\", \"hover\"], false],\n [\"boolean\", [\"feature-state\", \"highlighted\"], false],\n ];\n // If color is in the feature state or geojson properties, use that as second choice\n if (typeof columnColor === \"string\") {\n columnColor = [\n \"coalesce\",\n [\"feature-state\", \"color\"],\n [\"get\", \"color\"],\n columnColor,\n ];\n }\n\n const fillOpacity = opts.opacity ?? 0.1;\n\n const lineOpacity = opts.lineOpacity ?? 0.5;\n const lineWidth = opts.lineWidth ?? 2;\n\n const circleRadius = opts.circleRadius ?? 4;\n\n return {\n sources: {\n columns: buildGeoJSONSource(),\n },\n version: 8,\n layers: [\n {\n id: \"columns-fill\",\n type: \"fill\",\n source: \"columns\",\n paint: {\n \"fill-color\": columnColor,\n \"fill-opacity\": fillOpacity,\n },\n },\n {\n id: \"columns-points\",\n type: \"circle\",\n source: \"columns\",\n paint: {\n \"circle-radius\": circleRadius,\n \"circle-color\": columnColor,\n \"circle-opacity\": fillOpacity,\n },\n filter: [\"==\", \"$type\", \"Point\"],\n },\n {\n id: \"columns-line\",\n type: \"line\",\n source: \"columns\",\n paint: {\n \"line-color\": [\"case\", isHovered, columnSelectedColor, lineColor],\n \"line-width\": lineWidth,\n \"line-opacity\": [\"case\", isHovered, 1.0, lineOpacity],\n },\n },\n ],\n };\n}\n\nexport type ColumnFeature = GeoJSON.Feature & { id: number };\n\nconst selectedColumnSourceID = \"selectedColumn\";\n\nexport function SelectedColumnOverlay({\n selectedColumn,\n ...styleOpts\n}: { selectedColumn: ColumnFeature | null } & SelectedColumnStyleOpts) {\n useOverlayStyle(() => buildSelectedColumnStyle(styleOpts), []);\n\n useMapStyleOperator(\n (map) => {\n setGeoJSON(\n map,\n selectedColumnSourceID,\n promoteToFeatureCollection(selectedColumn as GeoJSONFeature | null),\n );\n },\n [selectedColumn],\n );\n\n return null;\n}\n\ninterface SelectedColumnStyleOpts {\n color?: string | any[];\n}\n\nfunction buildSelectedColumnStyle(\n opts: SelectedColumnStyleOpts = {},\n): StyleFragment {\n const columnSelectedColor: any =\n opts.color ?? getCSSVariable(\"--selection-color\", \"purple\");\n\n return {\n sources: {\n selectedColumn: buildGeoJSONSource(),\n },\n version: 8,\n layers: [\n {\n id: \"selected-column-highlight\",\n type: \"fill\",\n source: selectedColumnSourceID,\n paint: {\n \"fill-color\": columnSelectedColor,\n \"fill-opacity\": 0.5,\n },\n filter: [\"==\", \"$type\", \"Polygon\"],\n },\n {\n id: \"selected-column-edge\",\n type: \"line\",\n source: selectedColumnSourceID,\n paint: {\n \"line-color\": columnSelectedColor,\n \"line-width\": 2,\n \"line-opacity\": 1.0,\n },\n filter: [\"==\", \"$type\", \"Polygon\"],\n },\n {\n id: \"selected-column-point\",\n type: \"circle\",\n source: selectedColumnSourceID,\n paint: {\n \"circle-radius\": 6,\n \"circle-color\": columnSelectedColor,\n \"circle-opacity\": 1.0,\n },\n filter: [\"==\", \"$type\", \"Point\"],\n },\n ],\n };\n}\n"],"names":[],"mappings":";;;AAuBO,SAAS,iBAAiB;AAAA,EAC/B,UAAU;AAAA,EACV;AAAA,EACA,GAAG;AACL,GAAuB;AACrB,kBAAgB,MAAO,UAAU,kBAAkB,IAAI,IAAI,MAAO,CAAC,OAAO,CAAC;AAE3E;AAAA,IACE,CAAC,QAAQ;AACP,UAAI,WAAW,MAAM;AACnB;AAAA,MACF;AAEA,iBAAW,KAAK,WAAW,2BAA2B,OAAO,CAAC;AAAA,IAChE;AAAA,IACA,CAAC,SAAS,OAAO;AAAA,EAAA;AAEnB,SAAO;AACT;AAEA,SAAS,2BACP,MAC0B;AAC1B,MAAI,QAAQ,KAAM,QAAO;AACzB,MAAI,UAAU,QAAQ,KAAK,QAAQ,WAAW;AAC5C,WAAO;AAAA,MACL,MAAM;AAAA,MACN,UA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