@sqlrooms/kepler 0.26.1-rc.7 → 0.27.0-rc.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/LICENSE.md +1 -1
- package/dist/KeplerSlice.d.ts.map +1 -1
- package/dist/KeplerSlice.js +7 -4
- package/dist/KeplerSlice.js.map +1 -1
- package/dist/components/CustomFilterManager.d.ts +1 -1
- package/dist/components/CustomFilterManager.d.ts.map +1 -1
- package/dist/components/CustomFilterManager.js +8 -6
- package/dist/components/CustomFilterManager.js.map +1 -1
- package/dist/components/CustomFilterPanelHeader.d.ts +2 -7
- package/dist/components/CustomFilterPanelHeader.d.ts.map +1 -1
- package/dist/components/CustomFilterPanelHeader.js.map +1 -1
- package/dist/components/CustomInteractionManager.d.ts.map +1 -1
- package/dist/components/CustomInteractionManager.js +7 -7
- package/dist/components/CustomInteractionManager.js.map +1 -1
- package/dist/components/CustomLayerManager.d.ts +1 -1
- package/dist/components/CustomLayerManager.d.ts.map +1 -1
- package/dist/components/CustomLayerManager.js +0 -1
- package/dist/components/CustomLayerManager.js.map +1 -1
- package/dist/components/CustomMapLegend.d.ts +7 -0
- package/dist/components/CustomMapLegend.d.ts.map +1 -0
- package/dist/components/CustomMapLegend.js +70 -0
- package/dist/components/CustomMapLegend.js.map +1 -0
- package/dist/components/CustomMapLegendPanel.d.ts +6 -0
- package/dist/components/CustomMapLegendPanel.d.ts.map +1 -0
- package/dist/components/CustomMapLegendPanel.js +12 -0
- package/dist/components/CustomMapLegendPanel.js.map +1 -0
- package/dist/components/CustomMapManager.d.ts +1 -1
- package/dist/components/CustomMapManager.d.ts.map +1 -1
- package/dist/components/CustomMapManager.js +8 -9
- package/dist/components/CustomMapManager.js.map +1 -1
- package/dist/components/KeplerInjector.d.ts.map +1 -1
- package/dist/components/KeplerInjector.js +5 -1
- package/dist/components/KeplerInjector.js.map +1 -1
- package/dist/components/KeplerMapContainer.d.ts.map +1 -1
- package/dist/components/KeplerMapContainer.js +21 -4
- package/dist/components/KeplerMapContainer.js.map +1 -1
- package/dist/components/KeplerPlotContainer.js +2 -2
- package/dist/components/KeplerPlotContainer.js.map +1 -1
- package/dist/components/KeplerS3Browser.d.ts.map +1 -1
- package/dist/components/KeplerS3Browser.js +4 -1
- package/dist/components/KeplerS3Browser.js.map +1 -1
- package/dist/styles/theme.d.ts +2 -467
- package/dist/styles/theme.d.ts.map +1 -1
- package/dist/styles/theme.js.map +1 -1
- package/package.json +24 -28
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LayerLegendContentFactory, LayerLegendHeaderFactory } from '@kepler.gl/components';
|
|
2
|
+
import { MapLegendProps } from '@kepler.gl/components/dist/map/map-legend';
|
|
3
|
+
export declare function CustomMapLegendFactory(LayerLegendHeader: ReturnType<typeof LayerLegendHeaderFactory>, LayerLegendContent: ReturnType<typeof LayerLegendContentFactory>): import("react").FC<MapLegendProps>;
|
|
4
|
+
export declare namespace CustomMapLegendFactory {
|
|
5
|
+
var deps: (typeof LayerLegendHeaderFactory | typeof LayerLegendContentFactory)[];
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=CustomMapLegend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomMapLegend.d.ts","sourceRoot":"","sources":["../../src/components/CustomMapLegend.tsx"],"names":[],"mappings":"AAIA,OAAO,EAEL,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAC,cAAc,EAAC,MAAM,2CAA2C,CAAC;AAgCzE,wBAAgB,sBAAsB,CACpC,iBAAiB,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,EAC9D,kBAAkB,EAAE,UAAU,CAAC,OAAO,yBAAyB,CAAC,sCAgKjE;yBAlKe,sBAAsB"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright contributors to the kepler.gl project
|
|
4
|
+
import { layerConfigChange, toggleMapControl } from '@kepler.gl/actions';
|
|
5
|
+
import { KeplerGlContext, LayerLegendContentFactory, LayerLegendHeaderFactory, } from '@kepler.gl/components';
|
|
6
|
+
import { DIMENSIONS } from '@kepler.gl/constants';
|
|
7
|
+
import { Button } from '@sqlrooms/ui';
|
|
8
|
+
import { ArrowDown, ArrowRight, ChevronDownIcon, ChevronRightIcon, EyeIcon, EyeOffIcon, XIcon, } from 'lucide-react';
|
|
9
|
+
import { useCallback, useContext, useRef, useState, } from 'react';
|
|
10
|
+
import { useStoreWithKepler } from '../KeplerSlice';
|
|
11
|
+
const defaultActionIcons = {
|
|
12
|
+
expanded: ArrowDown,
|
|
13
|
+
collapsed: ArrowRight,
|
|
14
|
+
};
|
|
15
|
+
CustomMapLegendFactory.deps = [
|
|
16
|
+
LayerLegendHeaderFactory,
|
|
17
|
+
LayerLegendContentFactory,
|
|
18
|
+
];
|
|
19
|
+
export function CustomMapLegendFactory(LayerLegendHeader, LayerLegendContent) {
|
|
20
|
+
const MapLegend = ({ layers = [], width, ...restProps }) => {
|
|
21
|
+
const containerW = width || DIMENSIONS.mapControl.width;
|
|
22
|
+
const mapId = useContext(KeplerGlContext).id;
|
|
23
|
+
const dispatchAction = useStoreWithKepler((state) => state.kepler.dispatchAction);
|
|
24
|
+
const handleClose = (evt) => {
|
|
25
|
+
evt.stopPropagation();
|
|
26
|
+
dispatchAction(mapId, toggleMapControl('mapLegend', 0));
|
|
27
|
+
};
|
|
28
|
+
return (_jsx("div", { className: "map-legend", style: { width: containerW }, children: _jsxs("div", { className: "relative flex flex-col", children: [_jsxs("div", { className: "border-muted bg-background sticky top-0 flex w-full items-center justify-between border-b p-2", children: [_jsx("div", { className: "text-xs font-medium", children: "Map Layers" }), _jsx(Button, { variant: "ghost", size: "xs", className: "h-6 w-6", onClick: handleClose, children: _jsx(XIcon, { className: "h-4 w-4" }) })] }), _jsx("div", { className: "flex w-full flex-1 flex-col items-center", children: layers.map((layer, index) => {
|
|
29
|
+
return (_jsx(LayerLegendItem, { layer: layer, containerW: containerW, ...restProps }, index));
|
|
30
|
+
}) })] }) }));
|
|
31
|
+
};
|
|
32
|
+
const LayerLegendItem = ({ layer, containerW, isExport, mapState, disableEdit, onLayerVisConfigChange, }) => {
|
|
33
|
+
const [isExpanded, setIsExpanded] = useState(layer.config.isVisible);
|
|
34
|
+
const dispatchAction = useStoreWithKepler((state) => state.kepler.dispatchAction);
|
|
35
|
+
const scrollIntoView = useCallback(() => {
|
|
36
|
+
requestAnimationFrame(() => {
|
|
37
|
+
containerRef.current?.scrollIntoView({
|
|
38
|
+
behavior: 'smooth',
|
|
39
|
+
block: 'nearest',
|
|
40
|
+
inline: 'nearest',
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}, []);
|
|
44
|
+
const handleToggleExpanded = (evt) => {
|
|
45
|
+
evt.stopPropagation();
|
|
46
|
+
const nextExpanded = !isExpanded;
|
|
47
|
+
setIsExpanded(nextExpanded);
|
|
48
|
+
if (!isExpanded) {
|
|
49
|
+
scrollIntoView();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const mapId = useContext(KeplerGlContext).id;
|
|
53
|
+
const containerRef = useRef(null);
|
|
54
|
+
const handleToggleVisibility = (evt) => {
|
|
55
|
+
evt.stopPropagation();
|
|
56
|
+
const nextVisible = !layer.config.isVisible;
|
|
57
|
+
dispatchAction(mapId, layerConfigChange(layer, { isVisible: nextVisible }));
|
|
58
|
+
};
|
|
59
|
+
if (!layer.isValidToSave() || layer.config.hidden) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
if (isExport && !layer.config.isVisible) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
return (_jsxs("div", { ref: containerRef, className: "border-muted flex w-full flex-col items-center border-b", children: [_jsx("style", { children: `.legend--layer__item .panel--header__action { display: none !important; }` }), _jsxs("div", { className: "flex w-full flex-row items-center gap-2", onClick: handleToggleExpanded, children: [_jsx("div", { className: "cursor-pointer select-none items-center overflow-hidden text-ellipsis whitespace-nowrap p-2 text-xs", children: layer.config.label }), _jsx("div", { className: "flex-1" }), _jsxs("div", { className: "flex flex-row items-center justify-end gap-1", children: [_jsx(Button, { className: "h-7 w-7", variant: "ghost", size: "icon", onClick: handleToggleVisibility, children: layer.config.isVisible ? (_jsx(EyeIcon, { className: "h-4 w-4" })) : (_jsx(EyeOffIcon, { className: "h-4 w-4" })) }), _jsx(Button, { className: "h-7 w-7", variant: "ghost", size: "icon", onClick: handleToggleExpanded, children: isExpanded ? (_jsx(ChevronDownIcon, { className: "h-4 w-4" })) : (_jsx(ChevronRightIcon, { className: "h-4 w-4" })) })] })] }), isExpanded && (_jsx("div", { className: "w-full px-[8px] py-[5px] text-xs", children: _jsx(LayerLegendContent, { containerW: containerW, layer: layer, mapState: mapState, disableEdit: disableEdit, isExport: isExport, onLayerVisConfigChange: onLayerVisConfigChange, actionIcons: defaultActionIcons }) }))] }));
|
|
66
|
+
};
|
|
67
|
+
MapLegend.displayName = 'MapLegend';
|
|
68
|
+
return MapLegend;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=CustomMapLegend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomMapLegend.js","sourceRoot":"","sources":["../../src/components/CustomMapLegend.tsx"],"names":[],"mappings":";AAAA,+BAA+B;AAC/B,kDAAkD;AAElD,OAAO,EAAC,iBAAiB,EAAE,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACvE,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AACpC,OAAO,EACL,SAAS,EACT,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,OAAO,EACP,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ACL,SAAS,EAAC,SAAS,EACnB,OAAO,EAAC,OAAO,EACf,IAAI,EAAC,MAAM,EACX,OAAO,EAAE,oBAAoB,YAE5B,UAAU,CAAC,CAAC,CAAC,CACZ,KAAC,eAAe,IAAC,SAAS,EAAC,SAAS,GAAG,CACxC,CAAC,CAAC,CAAC,CACF,KAAC,gBAAgB,IAAC,SAAS,EAAC,SAAS,GAAG,CACzC,GACM,IACL,IACF,EAEL,UAAU,IAAI,CACb,cAAK,SAAS,EAAC,kCAAkC,YAC/C,KAAC,kBAAkB,IACjB,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,sBAAsB,EAAE,sBAAsB,EAC9C,WAAW,EAAE,kBAAkB,GAC/B,GACE,CACP,IACG,CACP,CAAC;IACJ,CAAC,CAAC;IAEF,SAAS,CAAC,WAAW,GAAG,WAAW,CAAC;IAEpC,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright contributors to the kepler.gl project\n\nimport {layerConfigChange, toggleMapControl} from '@kepler.gl/actions';\nimport {\n KeplerGlContext,\n LayerLegendContentFactory,\n LayerLegendHeaderFactory,\n} from '@kepler.gl/components';\nimport {MapLegendProps} from '@kepler.gl/components/dist/map/map-legend';\nimport {DIMENSIONS} from '@kepler.gl/constants';\nimport {Layer} from '@kepler.gl/layers';\nimport {Button} from '@sqlrooms/ui';\nimport {\n ArrowDown,\n ArrowRight,\n ChevronDownIcon,\n ChevronRightIcon,\n EyeIcon,\n EyeOffIcon,\n XIcon,\n} from 'lucide-react';\nimport {\n MouseEventHandler,\n useCallback,\n useContext,\n useRef,\n useState,\n} from 'react';\nimport {useStoreWithKepler} from '../KeplerSlice';\n\nconst defaultActionIcons = {\n expanded: ArrowDown,\n collapsed: ArrowRight,\n};\n\nCustomMapLegendFactory.deps = [\n LayerLegendHeaderFactory,\n LayerLegendContentFactory,\n];\n\nexport function CustomMapLegendFactory(\n LayerLegendHeader: ReturnType<typeof LayerLegendHeaderFactory>,\n LayerLegendContent: ReturnType<typeof LayerLegendContentFactory>,\n) {\n const MapLegend: React.FC<MapLegendProps> = ({\n layers = [],\n width,\n ...restProps\n }) => {\n const containerW = width || DIMENSIONS.mapControl.width;\n const mapId = useContext(KeplerGlContext).id;\n const dispatchAction = useStoreWithKepler(\n (state) => state.kepler.dispatchAction,\n );\n const handleClose = (evt: React.MouseEvent<HTMLButtonElement>) => {\n evt.stopPropagation();\n dispatchAction(mapId, toggleMapControl('mapLegend', 0));\n };\n\n return (\n <div className=\"map-legend\" style={{width: containerW}}>\n <div className=\"relative flex flex-col\">\n <div className=\"border-muted bg-background sticky top-0 flex w-full items-center justify-between border-b p-2\">\n <div className=\"text-xs font-medium\">Map Layers</div>\n <Button\n variant=\"ghost\"\n size=\"xs\"\n className=\"h-6 w-6\"\n onClick={handleClose}\n >\n <XIcon className=\"h-4 w-4\" />\n </Button>\n </div>\n <div className=\"flex w-full flex-1 flex-col items-center\">\n {layers.map((layer, index) => {\n return (\n <LayerLegendItem\n key={index}\n layer={layer}\n containerW={containerW}\n {...restProps}\n />\n );\n })}\n </div>\n </div>\n </div>\n );\n };\n\n const LayerLegendItem = ({\n layer,\n containerW,\n isExport,\n mapState,\n disableEdit,\n onLayerVisConfigChange,\n }: {layer: Layer; containerW: number} & MapLegendProps) => {\n const [isExpanded, setIsExpanded] = useState(layer.config.isVisible);\n\n const dispatchAction = useStoreWithKepler(\n (state) => state.kepler.dispatchAction,\n );\n const scrollIntoView = useCallback(() => {\n requestAnimationFrame(() => {\n containerRef.current?.scrollIntoView({\n behavior: 'smooth',\n block: 'nearest',\n inline: 'nearest',\n });\n });\n }, []);\n\n const handleToggleExpanded: MouseEventHandler<HTMLElement> = (evt) => {\n evt.stopPropagation();\n const nextExpanded = !isExpanded;\n setIsExpanded(nextExpanded);\n if (!isExpanded) {\n scrollIntoView();\n }\n };\n\n const mapId = useContext(KeplerGlContext).id;\n const containerRef = useRef<HTMLDivElement>(null);\n const handleToggleVisibility = (\n evt: React.MouseEvent<HTMLButtonElement>,\n ) => {\n evt.stopPropagation();\n const nextVisible = !layer.config.isVisible;\n dispatchAction(mapId, layerConfigChange(layer, {isVisible: nextVisible}));\n };\n\n if (!layer.isValidToSave() || layer.config.hidden) {\n return null;\n }\n\n if (isExport && !layer.config.isVisible) {\n return null;\n }\n\n return (\n <div\n ref={containerRef}\n className=\"border-muted flex w-full flex-col items-center border-b\"\n >\n <style>{`.legend--layer__item .panel--header__action { display: none !important; }`}</style>\n <div\n className=\"flex w-full flex-row items-center gap-2\"\n onClick={handleToggleExpanded}\n >\n <div className=\"cursor-pointer select-none items-center overflow-hidden text-ellipsis whitespace-nowrap p-2 text-xs\">\n {layer.config.label}\n </div>\n <div className=\"flex-1\" />\n <div className=\"flex flex-row items-center justify-end gap-1\">\n <Button\n className=\"h-7 w-7\"\n variant=\"ghost\"\n size=\"icon\"\n onClick={handleToggleVisibility}\n >\n {layer.config.isVisible ? (\n <EyeIcon className=\"h-4 w-4\" />\n ) : (\n <EyeOffIcon className=\"h-4 w-4\" />\n )}\n </Button>\n <Button\n className=\"h-7 w-7\"\n variant=\"ghost\"\n size=\"icon\"\n onClick={handleToggleExpanded}\n >\n {isExpanded ? (\n <ChevronDownIcon className=\"h-4 w-4\" />\n ) : (\n <ChevronRightIcon className=\"h-4 w-4\" />\n )}\n </Button>\n </div>\n </div>\n\n {isExpanded && (\n <div className=\"w-full px-[8px] py-[5px] text-xs\">\n <LayerLegendContent\n containerW={containerW}\n layer={layer}\n mapState={mapState}\n disableEdit={disableEdit}\n isExport={isExport}\n onLayerVisConfigChange={onLayerVisConfigChange}\n actionIcons={defaultActionIcons}\n />\n </div>\n )}\n </div>\n );\n };\n\n MapLegend.displayName = 'MapLegend';\n\n return MapLegend;\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MapLegendPanelFactory } from '@kepler.gl/components';
|
|
2
|
+
export declare function CustomMapLegendPanelFactory(...deps: Parameters<typeof MapLegendPanelFactory>): ReturnType<typeof MapLegendPanelFactory>;
|
|
3
|
+
export declare namespace CustomMapLegendPanelFactory {
|
|
4
|
+
var deps: (typeof import("@kepler.gl/components").MapControlTooltipFactory | typeof import("@kepler.gl/components").MapControlPanelFactory | typeof import("@kepler.gl/components").MapLegendFactory)[];
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=CustomMapLegendPanel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomMapLegendPanel.d.ts","sourceRoot":"","sources":["../../src/components/CustomMapLegendPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EAEtB,MAAM,uBAAuB,CAAC;AAI/B,wBAAgB,2BAA2B,CACzC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,GAChD,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAY1C;yBAde,2BAA2B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { MapLegendPanelFactory, } from '@kepler.gl/components';
|
|
3
|
+
CustomMapLegendPanelFactory.deps = MapLegendPanelFactory.deps;
|
|
4
|
+
export function CustomMapLegendPanelFactory(...deps) {
|
|
5
|
+
const MapLegendPanel = MapLegendPanelFactory(...deps);
|
|
6
|
+
const CustomMapLegendPanel = (props) => {
|
|
7
|
+
return (_jsxs(_Fragment, { children: [_jsx("style", { children: `.draggable-legend .map-control__panel-header { display: none !important; }` }), _jsx(MapLegendPanel, { ...props })] }));
|
|
8
|
+
};
|
|
9
|
+
CustomMapLegendPanel.displayName = 'CustomMapLegendPanel';
|
|
10
|
+
return CustomMapLegendPanel;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=CustomMapLegendPanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomMapLegendPanel.js","sourceRoot":"","sources":["../../src/components/CustomMapLegendPanel.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,qBAAqB,GAEtB,MAAM,uBAAuB,CAAC;AAE/B,2BAA2B,CAAC,IAAI,GAAG,qBAAqB,CAAC,IAAI,CAAC;AAE9D,MAAM,UAAU,2BAA2B,CACzC,GAAG,IAA8C;IAEjD,MAAM,cAAc,GAAG,qBAAqB,CAAC,GAAG,IAAI,CAAC,CAAC;IACtD,MAAM,oBAAoB,GAAG,CAAC,KAA0B,EAAE,EAAE;QAC1D,OAAO,CACL,8BACE,0BAAQ,4EAA4E,GAAS,EAC7F,KAAC,cAAc,OAAK,KAAK,GAAI,IAC5B,CACJ,CAAC;IACJ,CAAC,CAAC;IACF,oBAAoB,CAAC,WAAW,GAAG,sBAAsB,CAAC;IAC1D,OAAO,oBAAoB,CAAC;AAC9B,CAAC","sourcesContent":["import {\n MapLegendPanelFactory,\n MapLegendPanelProps,\n} from '@kepler.gl/components';\n\nCustomMapLegendPanelFactory.deps = MapLegendPanelFactory.deps;\n\nexport function CustomMapLegendPanelFactory(\n ...deps: Parameters<typeof MapLegendPanelFactory>\n): ReturnType<typeof MapLegendPanelFactory> {\n const MapLegendPanel = MapLegendPanelFactory(...deps);\n const CustomMapLegendPanel = (props: MapLegendPanelProps) => {\n return (\n <>\n <style>{`.draggable-legend .map-control__panel-header { display: none !important; }`}</style>\n <MapLegendPanel {...props} />\n </>\n );\n };\n CustomMapLegendPanel.displayName = 'CustomMapLegendPanel';\n return CustomMapLegendPanel;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomMapManager.d.ts","sourceRoot":"","sources":["../../src/components/CustomMapManager.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAkElD,KAAK,qBAAqB,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAqGF,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"CustomMapManager.d.ts","sourceRoot":"","sources":["../../src/components/CustomMapManager.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAkElD,KAAK,qBAAqB,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAqGF,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAiF5D,CAAC"}
|
|
@@ -68,16 +68,10 @@ export const CustomMapManager = ({ mapId }) => {
|
|
|
68
68
|
const { keplerActions, keplerState } = useKeplerStateActions({ mapId });
|
|
69
69
|
const intl = useIntl();
|
|
70
70
|
const { onShowAddMapStyleModal, onMapStyleChange, onRemoveCustomMapStyle } = useCustomMapActions(keplerActions);
|
|
71
|
-
if (!keplerState || !keplerActions) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
const { mapStyle } = keplerState;
|
|
75
|
-
const currentStyle = mapStyle.mapStyles[mapStyle.styleType] || {};
|
|
76
|
-
const editableLayers = currentStyle.layerGroups || [];
|
|
77
71
|
// Custom map styles actions (for delete functionality)
|
|
78
72
|
const customMapStylesActions = useMemo(() => {
|
|
79
73
|
const actionsPerCustomStyle = {};
|
|
80
|
-
Object.values(mapStyle.mapStyles)
|
|
74
|
+
Object.values(keplerState?.mapStyle.mapStyles || {})
|
|
81
75
|
.filter((style) => Boolean(style.custom))
|
|
82
76
|
.forEach((style) => {
|
|
83
77
|
actionsPerCustomStyle[style.id] = [
|
|
@@ -90,10 +84,15 @@ export const CustomMapManager = ({ mapId }) => {
|
|
|
90
84
|
];
|
|
91
85
|
});
|
|
92
86
|
return actionsPerCustomStyle;
|
|
93
|
-
}, [mapStyle.mapStyles, onRemoveCustomMapStyle]);
|
|
87
|
+
}, [keplerState?.mapStyle.mapStyles, onRemoveCustomMapStyle]);
|
|
88
|
+
if (!keplerState || !keplerActions) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const { mapStyle } = keplerState;
|
|
92
|
+
const currentStyle = mapStyle.mapStyles[mapStyle.styleType] || {};
|
|
93
|
+
const editableLayers = currentStyle.layerGroups || [];
|
|
94
94
|
return (_jsx(CustomMapManagerContainer, { children: _jsxs("div", { className: "map-style-panel", children: [_jsx(SidePanelSection, { children: _jsx(PanelTitle, { className: "map-manager-title", title: intl.formatMessage({
|
|
95
95
|
id: mapPanelMetadata?.label || 'Base map',
|
|
96
96
|
}), children: _jsxs(Button, { className: "add-map-style-button", onClick: onShowAddMapStyleModal, children: [_jsx(Add, { height: "12px" }), _jsx("span", { children: intl.formatMessage({ id: 'mapManager.addMapStyle' }) })] }) }) }), _jsxs(SidePanelSection, { children: [_jsx("div", { className: "mb-1", children: _jsx(MapStyleDropdown, { mapStyle: mapStyle, onChange: onMapStyleChange, customMapStylesActions: customMapStylesActions }) }), editableLayers.length ? (_jsx(LayerGroupSelector, { layers: mapStyle.visibleLayerGroups, editableLayers: editableLayers, topLayers: mapStyle.topLayerGroups, onChange: keplerActions.mapStyleActions.mapConfigChange, threeDBuildingColor: mapStyle.threeDBuildingColor, on3dBuildingColorChange: keplerActions.mapStyleActions.set3dBuildingColor, backgroundColor: mapStyle.backgroundColor, onBackgroundColorChange: keplerActions.mapStyleActions.setBackgroundColor })) : null] })] }) }));
|
|
97
97
|
};
|
|
98
|
-
export default CustomMapManager;
|
|
99
98
|
//# sourceMappingURL=CustomMapManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomMapManager.js","sourceRoot":"","sources":["../../src/components/CustomMapManager.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAC,WAAW,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AAClD,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AACnC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EACL,yBAAy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styled-components';\n\nimport {\n LayerGroupSelectorFactory,\n PanelTitleFactory,\n SidePanelSection,\n Button,\n Icons,\n} from '@kepler.gl/components';\nimport {SIDEBAR_PANELS, ADD_MAP_STYLE_ID} from '@kepler.gl/constants';\nimport {MapStyle} from '@kepler.gl/reducers';\n\nimport {KeplerInjector} from './KeplerInjector';\nimport {\n KeplerActions,\n useKeplerStateActions,\n} from '../hooks/useKeplerStateActions';\n\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuCheckboxItem,\n DropdownMenuTrigger,\n} from '@sqlrooms/ui';\nimport {ChevronDown} from 'lucide-react';\n\n// Get the kepler.gl components through the injector\nconst LayerGroupSelector = KeplerInjector.get(LayerGroupSelectorFactory);\nconst PanelTitle = KeplerInjector.get(PanelTitleFactory);\n\n// Import icons from kepler.gl\nconst {Add, Trash} = Icons;\n\nconst mapPanelMetadata = SIDEBAR_PANELS.find((p) => p.id === 'map');\n\n// Custom styled components for the map manager\nconst CustomMapManagerContainer = styled.div<{isOpen?: boolean}>`\n .map-style-panel {\n /* Add your custom styles here */\n }\n\n .map-manager-title {\n /* Custom title styling */\n }\n\n .add-map-style-button {\n background-color: ${(props) =>\n props.theme.sidePanelBg || props.theme.panelBackground || '#fff'};\n color: ${(props) =>\n props.theme.activeColor || props.theme.textColorHl || '#2563EB'};\n border: 0px;\n height: 28px;\n font-weight: 500;\n font-size: 14px;\n display: flex;\n align-items: center;\n gap: 6px;\n }\n\n .layer-group__header {\n display: none;\n }\n`;\n\ntype CustomMapManagerProps = {\n mapId: string;\n};\n\n// Custom hook for map style actions\nfunction useCustomMapActions(keplerActions: KeplerActions) {\n const {toggleModal} = keplerActions.uiStateActions;\n const {mapStyleChange, removeCustomMapStyle} = keplerActions.mapStyleActions;\n\n const onShowAddMapStyleModal = useCallback(\n () => toggleModal(ADD_MAP_STYLE_ID),\n [toggleModal],\n );\n\n const onMapStyleChange = useCallback(\n (styleType: string) => mapStyleChange(styleType),\n [mapStyleChange],\n );\n\n const onRemoveCustomMapStyle = useCallback(\n (styleId: string) => removeCustomMapStyle({id: styleId}),\n [removeCustomMapStyle],\n );\n\n return {\n onShowAddMapStyleModal,\n onMapStyleChange,\n onRemoveCustomMapStyle,\n };\n}\n\n// Custom Map Style Dropdown Component\nconst MapStyleDropdown: React.FC<{\n mapStyle: MapStyle;\n onChange: (styleType: string) => void;\n customMapStylesActions?: any;\n}> = ({mapStyle, onChange, customMapStylesActions}) => {\n const {mapStyles, styleType} = mapStyle;\n const currentStyle = mapStyles[styleType];\n\n const handleStyleSelect = (styleId: string) => onChange(styleId);\n return (\n <div className=\"w-full\">\n <DropdownMenu>\n <DropdownMenuTrigger asChild className=\"w-full\">\n <div className=\"border-primary-foreground bg-muted flex min-h-[40px] w-full cursor-pointer items-center justify-between rounded border px-3 py-2 transition-colors hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-white dark:hover:bg-gray-700\">\n <div className=\"flex items-center gap-2\">\n <img\n className=\"h-6 w-6 rounded-sm object-cover\"\n src={currentStyle?.icon || ''}\n alt={currentStyle?.label || 'Map Style'}\n />\n <span className=\"text-sm font-medium dark:text-white\">\n {currentStyle?.label || 'Select Style'}\n </span>\n </div>\n <ChevronDown className=\"h-4 w-4 text-gray-500 dark:text-gray-400\" />\n </div>\n </DropdownMenuTrigger>\n <DropdownMenuContent className=\"max-h-64 w-[var(--radix-dropdown-menu-trigger-width)] overflow-y-auto bg-white dark:bg-gray-700\">\n {Object.values(mapStyles).map((style: any) => (\n <DropdownMenuCheckboxItem\n key={style.id}\n onClick={() => handleStyleSelect(style.id)}\n className=\"flex cursor-pointer items-center gap-2 bg-white p-2 text-gray-900 dark:bg-gray-700 dark:text-white dark:hover:bg-gray-600\"\n >\n <img\n src={style.icon || ''}\n alt={style.label || 'Untitled'}\n className=\"h-6 w-6 flex-shrink-0 rounded-sm object-cover\"\n />\n <span className=\"flex-1 truncate text-sm\">\n {style.label || 'Untitled'}\n </span>\n {style.custom && customMapStylesActions?.[style.id] && (\n <div\n className=\"flex items-center\"\n onClick={(e) => e.stopPropagation()}\n >\n {customMapStylesActions[style.id].map((action: any) => (\n <button\n key={action.id}\n onClick={(e) => {\n e.stopPropagation();\n action.onClick();\n }}\n className=\"rounded bg-white p-1 transition-colors hover:bg-gray-100 dark:hover:bg-gray-700\"\n title={action.tooltip}\n >\n <action.IconComponent height=\"16px\" />\n </button>\n ))}\n </div>\n )}\n </DropdownMenuCheckboxItem>\n ))}\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n );\n};\n\n// Main Custom Map Manager Component\nexport const CustomMapManager: React.FC<CustomMapManagerProps> = ({mapId}) => {\n const {keplerActions, keplerState} = useKeplerStateActions({mapId});\n const intl = useIntl();\n\n const {onShowAddMapStyleModal, onMapStyleChange, onRemoveCustomMapStyle} =\n useCustomMapActions(keplerActions);\n\n if (!keplerState || !keplerActions) {\n return null;\n }\n\n const {mapStyle} = keplerState;\n const currentStyle = mapStyle.mapStyles[mapStyle.styleType] || {};\n const editableLayers = (currentStyle as any).layerGroups || [];\n\n // Custom map styles actions (for delete functionality)\n const customMapStylesActions = useMemo(() => {\n const actionsPerCustomStyle: any = {};\n Object.values(mapStyle.mapStyles)\n .filter((style: any) => Boolean(style.custom))\n .forEach((style: any) => {\n actionsPerCustomStyle[style.id] = [\n {\n id: `remove-map-style-${style.id}`,\n IconComponent: Trash,\n tooltip: 'tooltip.removeBaseMapStyle',\n onClick: () => onRemoveCustomMapStyle(style.id),\n },\n ];\n });\n return actionsPerCustomStyle;\n }, [mapStyle.mapStyles, onRemoveCustomMapStyle]);\n\n return (\n <CustomMapManagerContainer>\n <div className=\"map-style-panel\">\n <SidePanelSection>\n <PanelTitle\n className=\"map-manager-title\"\n title={intl.formatMessage({\n id: mapPanelMetadata?.label || 'Base map',\n })}\n >\n <Button\n className=\"add-map-style-button\"\n onClick={onShowAddMapStyleModal}\n >\n <Add height=\"12px\" />\n <span>{intl.formatMessage({id: 'mapManager.addMapStyle'})}</span>\n </Button>\n </PanelTitle>\n </SidePanelSection>\n\n <SidePanelSection>\n <div className=\"mb-1\">\n <MapStyleDropdown\n mapStyle={mapStyle}\n onChange={onMapStyleChange}\n customMapStylesActions={customMapStylesActions}\n />\n </div>\n\n {editableLayers.length ? (\n <LayerGroupSelector\n layers={mapStyle.visibleLayerGroups}\n editableLayers={editableLayers}\n topLayers={mapStyle.topLayerGroups}\n onChange={keplerActions.mapStyleActions.mapConfigChange}\n threeDBuildingColor={mapStyle.threeDBuildingColor}\n on3dBuildingColorChange={\n keplerActions.mapStyleActions.set3dBuildingColor\n }\n backgroundColor={mapStyle.backgroundColor}\n onBackgroundColorChange={\n keplerActions.mapStyleActions.setBackgroundColor\n }\n />\n ) : null}\n </SidePanelSection>\n </div>\n </CustomMapManagerContainer>\n );\n};\n\nexport default CustomMapManager;\n"]}
|
|
1
|
+
{"version":3,"file":"CustomMapManager.js","sourceRoot":"","sources":["../../src/components/CustomMapManager.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAC,WAAW,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AAClD,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AACnC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EACjB,gBAAgB,EAChB,MAAM,EACN,KAAK,GACN,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAC,cAAc,EAAE,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AAGtE,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAEL,qBAAqB,GACtB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAEzC,oDAAoD;AACpD,MAAM,kBAAkB,GAAG,cAAc,CAAC,GAAG,CAAC,yBAAyB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AC,EAAC,EAAE,EAAE,wBAAwB,EAAC,CAAC,GAAQ,IAC1D,GACE,GACI,EAEnB,MAAC,gBAAgB,eACf,cAAK,SAAS,EAAC,MAAM,YACnB,KAAC,gBAAgB,IACf,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,gBAAgB,EAC1B,sBAAsB,EAAE,sBAAsB,GAC9C,GACE,EAEL,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CACvB,KAAC,kBAAkB,IACjB,MAAM,EAAE,QAAQ,CAAC,kBAAkB,EACnC,cAAc,EAAE,cAAc,EAC9B,SAAS,EAAE,QAAQ,CAAC,cAAc,EAClC,QAAQ,EAAE,aAAa,CAAC,eAAe,CAAC,eAAe,EACvD,mBAAmB,EAAE,QAAQ,CAAC,mBAAmB,EACjD,uBAAuB,EACrB,aAAa,CAAC,eAAe,CAAC,kBAAkB,EAElD,eAAe,EAAE,QAAQ,CAAC,eAAe,EACzC,uBAAuB,EACrB,aAAa,CAAC,eAAe,CAAC,kBAAkB,GAElD,CACH,CAAC,CAAC,CAAC,IAAI,IACS,IACf,GACoB,CAC7B,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React, {useCallback, useMemo} from 'react';\nimport {useIntl} from 'react-intl';\nimport styled from 'styled-components';\n\nimport {\n LayerGroupSelectorFactory,\n PanelTitleFactory,\n SidePanelSection,\n Button,\n Icons,\n} from '@kepler.gl/components';\nimport {SIDEBAR_PANELS, ADD_MAP_STYLE_ID} from '@kepler.gl/constants';\nimport {MapStyle} from '@kepler.gl/reducers';\n\nimport {KeplerInjector} from './KeplerInjector';\nimport {\n KeplerActions,\n useKeplerStateActions,\n} from '../hooks/useKeplerStateActions';\n\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuCheckboxItem,\n DropdownMenuTrigger,\n} from '@sqlrooms/ui';\nimport {ChevronDown} from 'lucide-react';\n\n// Get the kepler.gl components through the injector\nconst LayerGroupSelector = KeplerInjector.get(LayerGroupSelectorFactory);\nconst PanelTitle = KeplerInjector.get(PanelTitleFactory);\n\n// Import icons from kepler.gl\nconst {Add, Trash} = Icons;\n\nconst mapPanelMetadata = SIDEBAR_PANELS.find((p) => p.id === 'map');\n\n// Custom styled components for the map manager\nconst CustomMapManagerContainer = styled.div<{isOpen?: boolean}>`\n .map-style-panel {\n /* Add your custom styles here */\n }\n\n .map-manager-title {\n /* Custom title styling */\n }\n\n .add-map-style-button {\n background-color: ${(props) =>\n props.theme.sidePanelBg || props.theme.panelBackground || '#fff'};\n color: ${(props) =>\n props.theme.activeColor || props.theme.textColorHl || '#2563EB'};\n border: 0px;\n height: 28px;\n font-weight: 500;\n font-size: 14px;\n display: flex;\n align-items: center;\n gap: 6px;\n }\n\n .layer-group__header {\n display: none;\n }\n`;\n\ntype CustomMapManagerProps = {\n mapId: string;\n};\n\n// Custom hook for map style actions\nfunction useCustomMapActions(keplerActions: KeplerActions) {\n const {toggleModal} = keplerActions.uiStateActions;\n const {mapStyleChange, removeCustomMapStyle} = keplerActions.mapStyleActions;\n\n const onShowAddMapStyleModal = useCallback(\n () => toggleModal(ADD_MAP_STYLE_ID),\n [toggleModal],\n );\n\n const onMapStyleChange = useCallback(\n (styleType: string) => mapStyleChange(styleType),\n [mapStyleChange],\n );\n\n const onRemoveCustomMapStyle = useCallback(\n (styleId: string) => removeCustomMapStyle({id: styleId}),\n [removeCustomMapStyle],\n );\n\n return {\n onShowAddMapStyleModal,\n onMapStyleChange,\n onRemoveCustomMapStyle,\n };\n}\n\n// Custom Map Style Dropdown Component\nconst MapStyleDropdown: React.FC<{\n mapStyle: MapStyle;\n onChange: (styleType: string) => void;\n customMapStylesActions?: any;\n}> = ({mapStyle, onChange, customMapStylesActions}) => {\n const {mapStyles, styleType} = mapStyle;\n const currentStyle = mapStyles[styleType];\n\n const handleStyleSelect = (styleId: string) => onChange(styleId);\n return (\n <div className=\"w-full\">\n <DropdownMenu>\n <DropdownMenuTrigger asChild className=\"w-full\">\n <div className=\"border-primary-foreground bg-muted flex min-h-[40px] w-full cursor-pointer items-center justify-between rounded border px-3 py-2 transition-colors hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-white dark:hover:bg-gray-700\">\n <div className=\"flex items-center gap-2\">\n <img\n className=\"h-6 w-6 rounded-sm object-cover\"\n src={currentStyle?.icon || ''}\n alt={currentStyle?.label || 'Map Style'}\n />\n <span className=\"text-sm font-medium dark:text-white\">\n {currentStyle?.label || 'Select Style'}\n </span>\n </div>\n <ChevronDown className=\"h-4 w-4 text-gray-500 dark:text-gray-400\" />\n </div>\n </DropdownMenuTrigger>\n <DropdownMenuContent className=\"max-h-64 w-[var(--radix-dropdown-menu-trigger-width)] overflow-y-auto bg-white dark:bg-gray-700\">\n {Object.values(mapStyles).map((style: any) => (\n <DropdownMenuCheckboxItem\n key={style.id}\n onClick={() => handleStyleSelect(style.id)}\n className=\"flex cursor-pointer items-center gap-2 bg-white p-2 text-gray-900 dark:bg-gray-700 dark:text-white dark:hover:bg-gray-600\"\n >\n <img\n src={style.icon || ''}\n alt={style.label || 'Untitled'}\n className=\"h-6 w-6 flex-shrink-0 rounded-sm object-cover\"\n />\n <span className=\"flex-1 truncate text-sm\">\n {style.label || 'Untitled'}\n </span>\n {style.custom && customMapStylesActions?.[style.id] && (\n <div\n className=\"flex items-center\"\n onClick={(e) => e.stopPropagation()}\n >\n {customMapStylesActions[style.id].map((action: any) => (\n <button\n key={action.id}\n onClick={(e) => {\n e.stopPropagation();\n action.onClick();\n }}\n className=\"rounded bg-white p-1 transition-colors hover:bg-gray-100 dark:hover:bg-gray-700\"\n title={action.tooltip}\n >\n <action.IconComponent height=\"16px\" />\n </button>\n ))}\n </div>\n )}\n </DropdownMenuCheckboxItem>\n ))}\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n );\n};\n\n// Main Custom Map Manager Component\nexport const CustomMapManager: React.FC<CustomMapManagerProps> = ({mapId}) => {\n const {keplerActions, keplerState} = useKeplerStateActions({mapId});\n const intl = useIntl();\n\n const {onShowAddMapStyleModal, onMapStyleChange, onRemoveCustomMapStyle} =\n useCustomMapActions(keplerActions);\n\n // Custom map styles actions (for delete functionality)\n const customMapStylesActions = useMemo(() => {\n const actionsPerCustomStyle: any = {};\n Object.values(keplerState?.mapStyle.mapStyles || {})\n .filter((style: any) => Boolean(style.custom))\n .forEach((style: any) => {\n actionsPerCustomStyle[style.id] = [\n {\n id: `remove-map-style-${style.id}`,\n IconComponent: Trash,\n tooltip: 'tooltip.removeBaseMapStyle',\n onClick: () => onRemoveCustomMapStyle(style.id),\n },\n ];\n });\n return actionsPerCustomStyle;\n }, [keplerState?.mapStyle.mapStyles, onRemoveCustomMapStyle]);\n if (!keplerState || !keplerActions) {\n return null;\n }\n\n const {mapStyle} = keplerState;\n const currentStyle = mapStyle.mapStyles[mapStyle.styleType] || {};\n const editableLayers = (currentStyle as any).layerGroups || [];\n\n return (\n <CustomMapManagerContainer>\n <div className=\"map-style-panel\">\n <SidePanelSection>\n <PanelTitle\n className=\"map-manager-title\"\n title={intl.formatMessage({\n id: mapPanelMetadata?.label || 'Base map',\n })}\n >\n <Button\n className=\"add-map-style-button\"\n onClick={onShowAddMapStyleModal}\n >\n <Add height=\"12px\" />\n <span>{intl.formatMessage({id: 'mapManager.addMapStyle'})}</span>\n </Button>\n </PanelTitle>\n </SidePanelSection>\n\n <SidePanelSection>\n <div className=\"mb-1\">\n <MapStyleDropdown\n mapStyle={mapStyle}\n onChange={onMapStyleChange}\n customMapStylesActions={customMapStylesActions}\n />\n </div>\n\n {editableLayers.length ? (\n <LayerGroupSelector\n layers={mapStyle.visibleLayerGroups}\n editableLayers={editableLayers}\n topLayers={mapStyle.topLayerGroups}\n onChange={keplerActions.mapStyleActions.mapConfigChange}\n threeDBuildingColor={mapStyle.threeDBuildingColor}\n on3dBuildingColorChange={\n keplerActions.mapStyleActions.set3dBuildingColor\n }\n backgroundColor={mapStyle.backgroundColor}\n onBackgroundColorChange={\n keplerActions.mapStyleActions.setBackgroundColor\n }\n />\n ) : null}\n </SidePanelSection>\n </div>\n </CustomMapManagerContainer>\n );\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeplerInjector.d.ts","sourceRoot":"","sources":["../../src/components/KeplerInjector.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"KeplerInjector.d.ts","sourceRoot":"","sources":["../../src/components/KeplerInjector.tsx"],"names":[],"mappings":"AAqCA,eAAO,MAAM,cAAc,8CAAiD,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { appInjector, provideRecipesToInjector, AddDataButtonFactory, PanelTitleFactory, DndContextFactory, FilterPanelHeaderFactory, } from '@kepler.gl/components';
|
|
2
|
+
import { appInjector, provideRecipesToInjector, AddDataButtonFactory, PanelTitleFactory, DndContextFactory, FilterPanelHeaderFactory, MapLegendFactory, MapLegendPanelFactory, } from '@kepler.gl/components';
|
|
3
3
|
import { CustomDndContextFactory } from './CustomDndContext';
|
|
4
4
|
import { CustomFilterPanelHeaderFactory } from './CustomFilterPanelHeader';
|
|
5
|
+
import { CustomMapLegendFactory } from './CustomMapLegend';
|
|
6
|
+
import { CustomMapLegendPanelFactory } from './CustomMapLegendPanel';
|
|
5
7
|
const CustomAddDataButtonFactory = () => {
|
|
6
8
|
return () => null;
|
|
7
9
|
};
|
|
@@ -14,6 +16,8 @@ const recipes = [
|
|
|
14
16
|
[PanelTitleFactory, CustomPanelTitleFactory],
|
|
15
17
|
[DndContextFactory, CustomDndContextFactory],
|
|
16
18
|
[FilterPanelHeaderFactory, CustomFilterPanelHeaderFactory],
|
|
19
|
+
[MapLegendPanelFactory, CustomMapLegendPanelFactory],
|
|
20
|
+
[MapLegendFactory, CustomMapLegendFactory],
|
|
17
21
|
];
|
|
18
22
|
export const KeplerInjector = provideRecipesToInjector(recipes, appInjector);
|
|
19
23
|
//# sourceMappingURL=KeplerInjector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeplerInjector.js","sourceRoot":"","sources":["../../src/components/KeplerInjector.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,WAAW,EACX,wBAAwB,EACxB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EAEjB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"KeplerInjector.js","sourceRoot":"","sources":["../../src/components/KeplerInjector.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,WAAW,EACX,wBAAwB,EACxB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EAEjB,wBAAwB,EACxB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAC,8BAA8B,EAAC,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAC,sBAAsB,EAAC,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAC,2BAA2B,EAAC,MAAM,wBAAwB,CAAC;AAEnE,MAAM,0BAA0B,GAAG,GAAG,EAAE;IACtC,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,uBAAuB,GAAG,GAAG,EAAE;IACnC,MAAM,UAAU,GAAgC,CAAC,EAAC,QAAQ,EAAC,EAAE,EAAE,CAAC,CAC9D,cAAK,SAAS,EAAC,+BAA+B,YAAE,QAAQ,GAAO,CAChE,CAAC;IAEF,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AACF,MAAM,OAAO,GAAG;IACd,CAAC,oBAAoB,EAAE,0BAA0B,CAAC;IAClD,CAAC,iBAAiB,EAAE,uBAAuB,CAAC;IAC5C,CAAC,iBAAiB,EAAE,uBAAuB,CAAC;IAC5C,CAAC,wBAAwB,EAAE,8BAA8B,CAAC;IAC1D,CAAC,qBAAqB,EAAE,2BAA2B,CAAC;IACpD,CAAC,gBAAgB,EAAE,sBAAsB,CAAC;CACnB,CAAC;AAE1B,MAAM,CAAC,MAAM,cAAc,GAAG,wBAAwB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import {\n appInjector,\n provideRecipesToInjector,\n AddDataButtonFactory,\n PanelTitleFactory,\n DndContextFactory,\n Factory,\n FilterPanelHeaderFactory,\n MapLegendFactory,\n MapLegendPanelFactory,\n} from '@kepler.gl/components';\nimport React, {PropsWithChildren} from 'react';\nimport {CustomDndContextFactory} from './CustomDndContext';\nimport {CustomFilterPanelHeaderFactory} from './CustomFilterPanelHeader';\nimport {CustomMapLegendFactory} from './CustomMapLegend';\nimport {CustomMapLegendPanelFactory} from './CustomMapLegendPanel';\n\nconst CustomAddDataButtonFactory = () => {\n return () => null;\n};\n\nconst CustomPanelTitleFactory = () => {\n const PanelTitle: React.FC<PropsWithChildren> = ({children}) => (\n <div className=\"flex items-center justify-end\">{children}</div>\n );\n\n return PanelTitle;\n};\nconst recipes = [\n [AddDataButtonFactory, CustomAddDataButtonFactory],\n [PanelTitleFactory, CustomPanelTitleFactory],\n [DndContextFactory, CustomDndContextFactory],\n [FilterPanelHeaderFactory, CustomFilterPanelHeaderFactory],\n [MapLegendPanelFactory, CustomMapLegendPanelFactory],\n [MapLegendFactory, CustomMapLegendFactory],\n] as [Factory, Factory][];\n\nexport const KeplerInjector = provideRecipesToInjector(recipes, appInjector);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeplerMapContainer.d.ts","sourceRoot":"","sources":["../../src/components/KeplerMapContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"KeplerMapContainer.d.ts","sourceRoot":"","sources":["../../src/components/KeplerMapContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,EAAE,EAAuC,MAAM,OAAO,CAAC;AAyK/D,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;CACf,CAMA,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo, useRef, useEffect } from 'react';
|
|
2
|
+
import { useMemo, useRef, useEffect, useState } from 'react';
|
|
3
3
|
import { MapContainerFactory, BottomWidgetFactory, GeocoderPanelFactory, mapFieldsSelector, bottomWidgetSelector, geoCoderPanelSelector, modalContainerSelector, MapViewStateContextProvider, RootContext, ModalContainerFactory, } from '@kepler.gl/components';
|
|
4
|
-
import { useDimensions } from '@kepler.gl/utils';
|
|
4
|
+
import { useDimensions, getAnimatableVisibleLayers } from '@kepler.gl/utils';
|
|
5
5
|
import styled, { useTheme } from 'styled-components';
|
|
6
6
|
import { KeplerInjector } from './KeplerInjector';
|
|
7
7
|
import { KeplerProvider } from './KeplerProvider';
|
|
@@ -29,14 +29,25 @@ const CustomWidgetcontainer = styled.div `
|
|
|
29
29
|
.map-popover {
|
|
30
30
|
z-index: 50;
|
|
31
31
|
}
|
|
32
|
+
|
|
33
|
+
/* Remove top margin from Trip layer timeline */
|
|
34
|
+
.kepler-gl .bottom-widget--container .animation-control-container,
|
|
35
|
+
.bottom-widget--container .animation-control-container {
|
|
36
|
+
margin-top: 0 !important;
|
|
37
|
+
}
|
|
32
38
|
`;
|
|
33
39
|
const KeplerGl = ({ mapId }) => {
|
|
34
40
|
const bottomWidgetRef = useRef(null);
|
|
35
41
|
const [containerRef, size] = useDimensions();
|
|
42
|
+
const [containerNode, setContainerNode] = useState(null);
|
|
36
43
|
const theme = useTheme();
|
|
37
44
|
const basicKeplerProps = useStoreWithKepler((state) => state.kepler.basicKeplerProps);
|
|
38
45
|
const { keplerActions, keplerState } = useKeplerStateActions({ mapId });
|
|
39
46
|
const interactionConfig = keplerState?.visState?.interactionConfig;
|
|
47
|
+
// Capture the current container DOM node outside of render logic
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
setContainerNode(containerRef.current);
|
|
50
|
+
}, [containerRef]);
|
|
40
51
|
// Update export image settings when size changes
|
|
41
52
|
useEffect(() => {
|
|
42
53
|
if (size?.width && size?.height) {
|
|
@@ -60,11 +71,17 @@ const KeplerGl = ({ mapId }) => {
|
|
|
60
71
|
size || DEFAULT_DIMENSIONS)
|
|
61
72
|
: null;
|
|
62
73
|
const mapFields = useMemo(() => (keplerState?.visState ? mapFieldsSelector(mergedKeplerProps) : null), [keplerState, mergedKeplerProps]);
|
|
63
|
-
|
|
74
|
+
// Check if there are filters or animatable layers (e.g., Trip layers)
|
|
75
|
+
const hasFilters = Boolean(keplerState?.visState.filters?.length);
|
|
76
|
+
const hasAnimatableLayers = useMemo(() => {
|
|
77
|
+
const layers = keplerState?.visState?.layers || [];
|
|
78
|
+
return getAnimatableVisibleLayers(layers).length > 0;
|
|
79
|
+
}, [keplerState?.visState?.layers]);
|
|
80
|
+
const bottomWidgetFields = hasFilters || hasAnimatableLayers
|
|
64
81
|
? bottomWidgetSelector(mergedKeplerProps, theme)
|
|
65
82
|
: null;
|
|
66
83
|
const modalContainerFields = keplerState?.visState
|
|
67
|
-
? modalContainerSelector(mergedKeplerProps,
|
|
84
|
+
? modalContainerSelector(mergedKeplerProps, containerNode)
|
|
68
85
|
: null;
|
|
69
86
|
const mapboxApiAccessToken = mapFields?.mapStyle?.mapboxApiAccessToken ||
|
|
70
87
|
basicKeplerProps?.mapboxApiAccessToken;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeplerMapContainer.js","sourceRoot":"","sources":["../../src/components/KeplerMapContainer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAK,OAAO,EAAE,MAAM,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"KeplerMapContainer.js","sourceRoot":"","sources":["../../src/components/KeplerMapContainer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAK,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE/D,OAAO,EACL,m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AAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,YACvD,KAAC,YAAY,IACX,OAAO,EAAE,IAAI,EACb,WAAW,EAAE,CAAC,EAEd,KAAK,EAAE,CAAC,KACJ,SAAS,EACb,oBAAoB,EAAE,oBAAoB,IAHrC,CAAC,CAIN,GAC0B,CAC/B,CAAC,CAAC,CAAC,IAAI,EACP,iBAAiB,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CACtC,KAAC,aAAa,OACR,mBAAmB,EACvB,KAAK,EAAE,CAAC,EACR,iBAAiB,EAAE,KAAK,EACxB,oBAAoB,EAAE,oBAAoB,GAC1C,CACH,CAAC,CAAC,CAAC,IAAI,EACP,kBAAkB,CAAC,CAAC,CAAC,CACpB,KAAC,YAAY,IACX,OAAO,EAAE,eAAe,KACpB,kBAAkB,EACtB,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,IAAI,EAAE,KAAK,GACvB,CACH,CAAC,CAAC,CAAC,IAAI,EACP,oBAAoB,CAAC,CAAC,CAAC,CACtB,KAAC,cAAc,OACT,oBAAoB,EACxB,UAAU,EAAE,IAAI,EAAE,KAAK,EACvB,UAAU,EAAE,IAAI,EAAE,MAAM,GACxB,CACH,CAAC,CAAC,CAAC,IAAI,IACc,GACH,CACxB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAE1B,CAAC,EAAC,KAAK,EAAC,EAAE,EAAE;IACf,OAAO,CACL,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,YAC1B,KAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,GAAI,GACX,CAClB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {FC, useMemo, useRef, useEffect, useState} from 'react';\n\nimport {\n MapContainerFactory,\n BottomWidgetFactory,\n GeocoderPanelFactory,\n mapFieldsSelector,\n bottomWidgetSelector,\n geoCoderPanelSelector,\n modalContainerSelector,\n MapViewStateContextProvider,\n RootContext,\n ModalContainerFactory,\n} from '@kepler.gl/components';\nimport {useDimensions, getAnimatableVisibleLayers} from '@kepler.gl/utils';\nimport styled, {useTheme} from 'styled-components';\n\nimport {KeplerInjector} from './KeplerInjector';\nimport {KeplerProvider} from './KeplerProvider';\nimport {useKeplerStateActions} from '../hooks/useKeplerStateActions';\nimport {useStoreWithKepler} from '../KeplerSlice';\n\nconst MapContainer = KeplerInjector.get(MapContainerFactory);\nconst BottomWidget = KeplerInjector.get(BottomWidgetFactory);\nconst GeoCoderPanel = KeplerInjector.get(GeocoderPanelFactory);\nconst ModalContainer = KeplerInjector.get(ModalContainerFactory);\n\nconst DEFAULT_DIMENSIONS = {\n width: 0,\n height: 0,\n};\nconst KEPLER_PROPS = {\n mapboxApiUrl: 'https://api.mapbox.com',\n appName: 'kepler.gl',\n sidePanelWidth: 0,\n};\n// overide kepler default style\nconst CustomWidgetcontainer = styled.div`\n .bottom-widget--inner {\n margin-top: 0;\n }\n\n .map-popover {\n z-index: 50;\n }\n\n /* Remove top margin from Trip layer timeline */\n .kepler-gl .bottom-widget--container .animation-control-container,\n .bottom-widget--container .animation-control-container {\n margin-top: 0 !important;\n }\n`;\n\ntype KeplerGLProps = Parameters<typeof geoCoderPanelSelector>[0];\n\nconst KeplerGl: FC<{\n mapId: string;\n}> = ({mapId}) => {\n const bottomWidgetRef = useRef(null);\n const [containerRef, size] = useDimensions<HTMLDivElement>();\n const [containerNode, setContainerNode] = useState<HTMLElement | null>(null);\n const theme = useTheme();\n const basicKeplerProps = useStoreWithKepler(\n (state) => state.kepler.basicKeplerProps,\n );\n\n const {keplerActions, keplerState} = useKeplerStateActions({mapId});\n const interactionConfig = keplerState?.visState?.interactionConfig;\n\n // Capture the current container DOM node outside of render logic\n useEffect(() => {\n setContainerNode(containerRef.current);\n }, [containerRef]);\n\n // Update export image settings when size changes\n useEffect(() => {\n if (size?.width && size?.height) {\n keplerActions.uiStateActions.setExportImageSetting({\n mapW: size.width,\n mapH: size.height,\n });\n }\n }, [size?.width, size?.height, keplerActions.uiStateActions]);\n\n const mergedKeplerProps = useMemo(() => {\n return {\n ...KEPLER_PROPS,\n ...keplerState,\n ...keplerActions,\n id: mapId,\n } as KeplerGLProps;\n }, [keplerState, keplerActions, mapId]);\n const geoCoderPanelFields = keplerState?.visState\n ? geoCoderPanelSelector(\n mergedKeplerProps,\n // dont need height\n size || DEFAULT_DIMENSIONS,\n )\n : null;\n const mapFields = useMemo(\n () => (keplerState?.visState ? mapFieldsSelector(mergedKeplerProps) : null),\n [keplerState, mergedKeplerProps],\n );\n\n // Check if there are filters or animatable layers (e.g., Trip layers)\n const hasFilters = Boolean(keplerState?.visState.filters?.length);\n const hasAnimatableLayers = useMemo(() => {\n const layers = keplerState?.visState?.layers || [];\n return getAnimatableVisibleLayers(layers).length > 0;\n }, [keplerState?.visState?.layers]);\n\n const bottomWidgetFields =\n hasFilters || hasAnimatableLayers\n ? bottomWidgetSelector(mergedKeplerProps, theme)\n : null;\n\n const modalContainerFields = keplerState?.visState\n ? modalContainerSelector(mergedKeplerProps, containerNode)\n : null;\n\n const mapboxApiAccessToken =\n mapFields?.mapStyle?.mapboxApiAccessToken ||\n basicKeplerProps?.mapboxApiAccessToken;\n return (\n <RootContext.Provider value={containerRef}>\n <CustomWidgetcontainer\n ref={containerRef}\n className=\"kepler-gl relative flex h-full w-full flex-col justify-between\"\n >\n {mapFields?.mapState ? (\n <MapViewStateContextProvider mapState={mapFields.mapState}>\n <MapContainer\n primary={true}\n containerId={0}\n key={0}\n index={0}\n {...mapFields}\n mapboxApiAccessToken={mapboxApiAccessToken}\n />\n </MapViewStateContextProvider>\n ) : null}\n {interactionConfig?.geocoder?.enabled ? (\n <GeoCoderPanel\n {...geoCoderPanelFields}\n index={0}\n unsyncedViewports={false}\n mapboxApiAccessToken={mapboxApiAccessToken}\n />\n ) : null}\n {bottomWidgetFields ? (\n <BottomWidget\n rootRef={bottomWidgetRef}\n {...bottomWidgetFields}\n theme={theme}\n containerW={size?.width}\n />\n ) : null}\n {modalContainerFields ? (\n <ModalContainer\n {...modalContainerFields}\n containerW={size?.width}\n containerH={size?.height}\n />\n ) : null}\n </CustomWidgetcontainer>\n </RootContext.Provider>\n );\n};\n\nexport const KeplerMapContainer: FC<{\n mapId: string;\n}> = ({mapId}) => {\n return (\n <KeplerProvider mapId={mapId}>\n <KeplerGl mapId={mapId} />\n </KeplerProvider>\n );\n};\n"]}
|
|
@@ -26,8 +26,8 @@ export const KeplerPlotContainer = ({ mapId, logoComponent }) => {
|
|
|
26
26
|
}
|
|
27
27
|
: null, [keplerState, keplerActions, mapId]);
|
|
28
28
|
const plotContainerFields = useMemo(() => (mergedKeplerProps ? plotContainerSelector(mergedKeplerProps) : null),
|
|
29
|
-
//
|
|
30
|
-
[mergedKeplerProps
|
|
29
|
+
// mergedKeplerProps already changes when filters change via keplerState
|
|
30
|
+
[mergedKeplerProps]);
|
|
31
31
|
return isExportingImage && plotContainerFields ? (_jsx(KeplerProvider, { mapId: mapId, children: _jsx(PlotContainer, { ...plotContainerFields, logoComponent: logoComponent ?? null }) })) : null;
|
|
32
32
|
};
|
|
33
33
|
//# sourceMappingURL=KeplerPlotContainer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeplerPlotContainer.js","sourceRoot":"","sources":["../../src/components/KeplerPlotContainer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAgB,OAAO,EAAC,MAAM,OAAO,CAAC;AAE7C,OAAO,EACL,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAC,qBAAqB,EAAC,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAEhD,MAAM,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;AAC/D,MAAM,YAAY,GAAG;IACnB,YAAY,EAAE,wBAAwB;IACtC,OAAO,EAAE,WA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ode, useMemo} from 'react';\n\nimport {\n PlotContainerFactory,\n plotContainerSelector,\n} from '@kepler.gl/components';\nimport {useKeplerStateActions} from '../hooks/useKeplerStateActions';\nimport {KeplerInjector} from './KeplerInjector';\nimport {KeplerProvider} from './KeplerProvider';\n\nconst PlotContainer = KeplerInjector.get(PlotContainerFactory);\nconst KEPLER_PROPS = {\n mapboxApiUrl: 'https://api.mapbox.com',\n appName: 'kepler.gl',\n sidePanelWidth: 0,\n mapboxApiAccessToken: '',\n};\n\nexport const KeplerPlotContainer: FC<{\n mapId: string;\n logoComponent?: ReactNode;\n}> = ({mapId, logoComponent}) => {\n const {keplerState, keplerActions} = useKeplerStateActions({mapId});\n\n const isExportingImage = keplerState?.uiState?.exportImage?.exporting;\n const mergedKeplerProps = useMemo(\n () =>\n keplerState !== undefined\n ? {\n ...KEPLER_PROPS,\n mapboxApiAccessToken:\n KEPLER_PROPS.mapboxApiAccessToken ||\n keplerState?.mapStyle?.mapboxApiAccessToken ||\n '',\n ...keplerState,\n ...keplerActions,\n id: mapId,\n }\n : null,\n [keplerState, keplerActions, mapId],\n );\n\n const plotContainerFields = useMemo(\n () => (mergedKeplerProps ? plotContainerSelector(mergedKeplerProps) : null),\n // mergedKeplerProps already changes when filters change via keplerState\n [mergedKeplerProps],\n );\n\n return isExportingImage && plotContainerFields ? (\n <KeplerProvider mapId={mapId}>\n <PlotContainer\n {...plotContainerFields}\n logoComponent={logoComponent ?? null}\n />\n </KeplerProvider>\n ) : null;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeplerS3Browser.d.ts","sourceRoot":"","sources":["../../src/components/KeplerS3Browser.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGL,cAAc,EACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAC,iBAAiB,EAAE,QAAQ,EAAE,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAUhF,MAAM,MAAM,oBAAoB,GAAG;IACjC,WAAW,EAAE,CAAC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AAE,cAAc,CAAC,WAAW,CAAC,CAAC;IACvC,iBAAiB,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,iBAAiB,EAAE,MAAM,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAClD,mBAAmB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD,CAAC;AACF,eAAO,MAAM,eAAe,GAAI,qGAO7B,oBAAoB,4CAqJtB,CAAC"}
|
|
@@ -35,12 +35,15 @@ export const KeplerS3Browser = ({ listS3Files, s3Browser, loadS3Files, saveS3Cre
|
|
|
35
35
|
files: selectedFiles,
|
|
36
36
|
});
|
|
37
37
|
}, [loadS3Files, currentS3Config, selectedFiles, selectedDirectory]);
|
|
38
|
-
//
|
|
38
|
+
// Load files on mount if there's a saved S3 config (restore previous session)
|
|
39
|
+
// Intentional mount-only effect; state updates are async after data fetch
|
|
40
|
+
/* eslint-disable react-hooks/set-state-in-effect, react-hooks/exhaustive-deps */
|
|
39
41
|
useEffect(() => {
|
|
40
42
|
if (currentS3Config) {
|
|
41
43
|
listFiles(currentS3Config, '');
|
|
42
44
|
}
|
|
43
45
|
}, []);
|
|
46
|
+
/* eslint-enable react-hooks/set-state-in-effect, react-hooks/exhaustive-deps */
|
|
44
47
|
const onSelectDirectory = useCallback((directory) => {
|
|
45
48
|
if (!currentS3Config)
|
|
46
49
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeplerS3Browser.js","sourceRoot":"","sources":["../../src/components/KeplerS3Browser.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAC,MAAM,OAAO,CAAC;AAE9D,OAAO,EACL,aAAa,EACb,iBAAiB,GAElB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AACzC,OAAO,EACL,YAAY,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sForm,\n S3BrowserState,\n} from '@sqlrooms/s3-browser';\nimport {S3FileOrDirectory, S3Config, S3Credentials} from '@sqlrooms/s3-browser';\nimport {ChevronLeft} from 'lucide-react';\nimport {\n DialogFooter,\n Button,\n Spinner,\n Alert,\n AlertDescription,\n} from '@sqlrooms/ui';\n\nexport type KeplerS3BrowserProps = {\n listS3Files: (args: {\n s3Config: S3Config;\n prefix: string;\n }) => Promise<S3FileOrDirectory[]>;\n loadS3Files: (args: {\n s3Config: S3Config;\n prefix: string;\n files: string[];\n }) => Promise<void>;\n s3Browser: S3BrowserState['s3Browser'];\n saveS3Credentials: (s3Config: S3Config) => Promise<void>;\n loadS3Credentials: () => Promise<S3Credentials[]>;\n deleteS3Credentials: (id: string) => Promise<void>;\n};\nexport const KeplerS3Browser = ({\n listS3Files,\n s3Browser,\n loadS3Files,\n saveS3Credentials,\n loadS3Credentials,\n deleteS3Credentials,\n}: KeplerS3BrowserProps) => {\n const [isConnecting, setIsConnecting] = useState(false);\n const [error, setError] = useState('');\n const [files, setFiles] = useState<S3FileOrDirectory[] | null>(null);\n const [selectedDirectory, onChangeSelectedDirectory] = useState('');\n const [selectedFiles, setSelectedFiles] = useState<string[]>([]);\n const {setCurrentS3Config, clearCurrentS3Config, currentS3Config} = s3Browser;\n\n const listFiles = useCallback(\n async (s3Config: S3Config, prefix: string) => {\n try {\n const files = await listS3Files({\n s3Config,\n prefix,\n });\n setCurrentS3Config(s3Config);\n setFiles(files);\n setError('');\n onChangeSelectedDirectory(prefix);\n } catch (error) {\n setError((error as Error).message);\n }\n setIsConnecting(false);\n },\n [listS3Files, setCurrentS3Config, setFiles, setIsConnecting, setError],\n );\n const handleLoadFiles = useCallback(async () => {\n if (!currentS3Config) return;\n await loadS3Files({\n s3Config: currentS3Config,\n prefix: selectedDirectory,\n files: selectedFiles,\n });\n }, [loadS3Files, currentS3Config, selectedFiles, selectedDirectory]);\n\n // Load files on mount if there's a saved S3 config (restore previous session)\n // Intentional mount-only effect; state updates are async after data fetch\n /* eslint-disable react-hooks/set-state-in-effect, react-hooks/exhaustive-deps */\n useEffect(() => {\n if (currentS3Config) {\n listFiles(currentS3Config, '');\n }\n }, []);\n /* eslint-enable react-hooks/set-state-in-effect, react-hooks/exhaustive-deps */\n\n const onSelectDirectory = useCallback(\n (directory: string) => {\n if (!currentS3Config) return;\n setIsConnecting(true);\n listFiles(currentS3Config, directory);\n },\n [currentS3Config, setIsConnecting, listFiles],\n );\n\n const onConnect = useCallback(\n (values: S3Config) => {\n setIsConnecting(true);\n listFiles(values, '');\n },\n [listFiles],\n );\n const onBack = useCallback(() => {\n setIsConnecting(false);\n setFiles(null);\n setSelectedFiles([]);\n onChangeSelectedDirectory('');\n clearCurrentS3Config();\n }, [\n setIsConnecting,\n setFiles,\n setSelectedFiles,\n clearCurrentS3Config,\n onChangeSelectedDirectory,\n ]);\n return (\n <div className=\"flex h-full flex-col items-center gap-4\">\n {/* Connection Panel */}\n {!files ? (\n <>\n {error ? (\n <div className=\"flex w-full justify-center px-4\">\n <Alert variant=\"destructive\">\n <AlertDescription>{error}</AlertDescription>\n </Alert>\n </div>\n ) : null}\n <S3CredentialsForm\n onConnect={onConnect}\n isLoading={isConnecting}\n saveS3Credentials={saveS3Credentials}\n loadS3Credentials={loadS3Credentials}\n deleteS3Credentials={deleteS3Credentials}\n onInputChange={() => setError('')}\n />\n </>\n ) : files.length ? (\n <div className=\"flex h-full w-full flex-col items-start justify-start gap-2\">\n <S3FileBrowser\n files={files}\n selectedFiles={selectedFiles}\n selectedDirectory={selectedDirectory}\n onChangeSelectedFiles={setSelectedFiles}\n onChangeSelectedDirectory={onSelectDirectory}\n onCanConfirmChange={() => {}}\n renderFileActions={() => (\n <div className=\"flex w-full items-center justify-between px-2 text-xs\">\n <Button\n variant=\"link\"\n className=\"h-6 px-1 py-0\"\n onClick={onBack}\n >\n <ChevronLeft size={16} />\n Disconnect\n </Button>\n <div className=\"flex items-center gap-1\">\n {isConnecting ? (\n <div className=\"text-muted-foreground\">\n <Spinner className=\"h-6 w-6\" />\n </div>\n ) : (\n <div className=\"text-muted-foreground\">Connected to</div>\n )}\n\n <b>{currentS3Config?.bucket}</b>\n </div>\n </div>\n )}\n />\n </div>\n ) : (\n <div className=\"flex h-full items-center justify-center\">\n <p className=\"text-muted-foreground\">No files found</p>\n </div>\n )}\n\n {/* Footer */}\n <DialogFooter className=\"mt-6 w-full justify-end\">\n {files?.length ? (\n <Button\n disabled={!selectedFiles.length}\n type=\"submit\"\n onClick={handleLoadFiles}\n >\n Add Selected\n </Button>\n ) : null}\n </DialogFooter>\n </div>\n );\n};\n"]}
|