@sqlrooms/kepler 0.29.0-rc.1 → 0.29.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -2
- package/dist/KeplerSlice.d.ts +29 -11
- package/dist/KeplerSlice.d.ts.map +1 -1
- package/dist/KeplerSlice.js +247 -112
- package/dist/KeplerSlice.js.map +1 -1
- package/dist/components/CustomDndContext.d.ts.map +1 -1
- package/dist/components/CustomDndContext.js +5 -2
- package/dist/components/CustomDndContext.js.map +1 -1
- package/dist/components/CustomFilterManager.d.ts.map +1 -1
- package/dist/components/CustomFilterManager.js +4 -1
- package/dist/components/CustomFilterManager.js.map +1 -1
- package/dist/components/CustomFilterPanelHeader.d.ts.map +1 -1
- package/dist/components/CustomFilterPanelHeader.js +5 -5
- package/dist/components/CustomFilterPanelHeader.js.map +1 -1
- package/dist/components/CustomInteractionManager.d.ts.map +1 -1
- package/dist/components/CustomInteractionManager.js +4 -1
- package/dist/components/CustomInteractionManager.js.map +1 -1
- package/dist/components/CustomLayerManager.d.ts.map +1 -1
- package/dist/components/CustomLayerManager.js +138 -17
- package/dist/components/CustomLayerManager.js.map +1 -1
- package/dist/components/CustomMapDrawPanel.d.ts +8 -0
- package/dist/components/CustomMapDrawPanel.d.ts.map +1 -0
- package/dist/components/CustomMapDrawPanel.js +28 -0
- package/dist/components/CustomMapDrawPanel.js.map +1 -0
- package/dist/components/CustomMapLegend.d.ts +4 -1
- package/dist/components/CustomMapLegend.d.ts.map +1 -1
- package/dist/components/CustomMapLegend.js +15 -5
- package/dist/components/CustomMapLegend.js.map +1 -1
- package/dist/components/CustomMapLegendPanel.d.ts +3 -3
- package/dist/components/CustomMapLegendPanel.d.ts.map +1 -1
- package/dist/components/CustomMapLegendPanel.js +19 -4
- package/dist/components/CustomMapLegendPanel.js.map +1 -1
- package/dist/components/KeplerAddDataDialog.d.ts +2 -3
- package/dist/components/KeplerAddDataDialog.d.ts.map +1 -1
- package/dist/components/KeplerAddDataDialog.js +18 -8
- package/dist/components/KeplerAddDataDialog.js.map +1 -1
- package/dist/components/KeplerImageExport.d.ts.map +1 -1
- package/dist/components/KeplerImageExport.js +26 -8
- package/dist/components/KeplerImageExport.js.map +1 -1
- package/dist/components/KeplerInjector.d.ts.map +1 -1
- package/dist/components/KeplerInjector.js +3 -1
- package/dist/components/KeplerInjector.js.map +1 -1
- package/dist/components/KeplerMapContainer.d.ts.map +1 -1
- package/dist/components/KeplerMapContainer.js +36 -4
- package/dist/components/KeplerMapContainer.js.map +1 -1
- package/dist/components/SplitMapIndexContext.d.ts +2 -0
- package/dist/components/SplitMapIndexContext.d.ts.map +1 -0
- package/dist/components/SplitMapIndexContext.js +3 -0
- package/dist/components/SplitMapIndexContext.js.map +1 -0
- package/dist/hooks/useDndEffects.d.ts +1 -1
- package/dist/hooks/useDndEffects.d.ts.map +1 -1
- package/dist/hooks/useDndEffects.js +4 -0
- package/dist/hooks/useDndEffects.js.map +1 -1
- package/dist/hooks/useDndLayers.d.ts +1 -1
- package/dist/hooks/useDndLayers.d.ts.map +1 -1
- package/dist/hooks/useDndLayers.js +4 -0
- package/dist/hooks/useDndLayers.js.map +1 -1
- package/dist/hooks/useKeplerStateActions.d.ts +7 -6
- package/dist/hooks/useKeplerStateActions.d.ts.map +1 -1
- package/dist/hooks/useKeplerStateActions.js +1 -1
- package/dist/hooks/useKeplerStateActions.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/package.json +20 -20
|
@@ -1,31 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useMemo } from 'react';
|
|
2
|
+
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { useIntl } from 'react-intl';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
|
-
import { LayerListFactory, DatasetLayerGroupFactory, PanelTitleFactory,
|
|
5
|
+
import { Accessor, Button, Icons, LayerListFactory, DatasetLayerGroupFactory, PanelTitleFactory, SidePanelSection, Typeahead, } from '@kepler.gl/components';
|
|
6
6
|
import { PANEL_VIEW_TOGGLES, SIDEBAR_PANELS } from '@kepler.gl/constants';
|
|
7
7
|
import { getApplicationConfig } from '@kepler.gl/utils';
|
|
8
8
|
import { getKeplerFactory } from './KeplerInjector';
|
|
9
9
|
import { useKeplerStateActions, } from '../hooks/useKeplerStateActions';
|
|
10
|
-
|
|
10
|
+
import { useStoreWithKepler } from '../KeplerSlice';
|
|
11
11
|
const LayerList = getKeplerFactory(LayerListFactory);
|
|
12
12
|
const DatasetLayerGroup = getKeplerFactory(DatasetLayerGroupFactory);
|
|
13
13
|
const PanelTitle = getKeplerFactory(PanelTitleFactory);
|
|
14
|
-
const AddLayerButton = getKeplerFactory(AddLayerButtonFactory);
|
|
15
14
|
const layerPanelMetadata = SIDEBAR_PANELS.find((p) => p.id === 'layer');
|
|
16
|
-
// Custom styled components for your layer manager
|
|
17
15
|
const CustomLayerManagerContainer = styled.div `
|
|
18
|
-
.layer-manager {
|
|
19
|
-
/* Add your custom styles here */
|
|
20
|
-
}
|
|
21
|
-
|
|
22
16
|
.layer-manager-title {
|
|
23
|
-
/* Custom title styling */
|
|
24
17
|
}
|
|
25
18
|
|
|
26
19
|
.add-layer-button {
|
|
27
20
|
background-color: ${(props) => props.theme.sidePanelBg || props.theme.panelBackground};
|
|
28
|
-
color: #2563EB;
|
|
21
|
+
color: #2563EB;
|
|
29
22
|
border: 0px;
|
|
30
23
|
height: 28px;
|
|
31
24
|
font-weight: 500;
|
|
@@ -58,7 +51,125 @@ const CustomLayerManagerContainer = styled.div `
|
|
|
58
51
|
}
|
|
59
52
|
}
|
|
60
53
|
`;
|
|
61
|
-
|
|
54
|
+
const DropdownWrapper = styled.div `
|
|
55
|
+
position: relative;
|
|
56
|
+
display: inline-block;
|
|
57
|
+
overflow: visible;
|
|
58
|
+
`;
|
|
59
|
+
const DropdownMenu = styled.div `
|
|
60
|
+
display: flex;
|
|
61
|
+
flex-direction: column;
|
|
62
|
+
min-width: 240px;
|
|
63
|
+
max-width: 240px;
|
|
64
|
+
position: fixed;
|
|
65
|
+
z-index: 100;
|
|
66
|
+
|
|
67
|
+
.list-selector {
|
|
68
|
+
border-top: 1px solid ${(props) => props.theme.secondaryInputBorderColor};
|
|
69
|
+
width: 100%;
|
|
70
|
+
max-height: unset;
|
|
71
|
+
}
|
|
72
|
+
.list__item > div {
|
|
73
|
+
display: flex;
|
|
74
|
+
flex-direction: row;
|
|
75
|
+
justify-content: flex-start;
|
|
76
|
+
line-height: 18px;
|
|
77
|
+
padding: 0;
|
|
78
|
+
}
|
|
79
|
+
`;
|
|
80
|
+
const ListItemWrapper = styled.div `
|
|
81
|
+
display: flex;
|
|
82
|
+
color: ${(props) => props.theme.textColor};
|
|
83
|
+
font-size: 11px;
|
|
84
|
+
letter-spacing: 0.2px;
|
|
85
|
+
overflow: auto;
|
|
86
|
+
.table-name {
|
|
87
|
+
white-space: nowrap;
|
|
88
|
+
overflow: hidden;
|
|
89
|
+
text-overflow: ellipsis;
|
|
90
|
+
}
|
|
91
|
+
`;
|
|
92
|
+
const TYPEAHEAD_CLASS = 'typeahead';
|
|
93
|
+
const TYPEAHEAD_INPUT_CLASS = 'typeahead__input';
|
|
94
|
+
const TableListItem = ({ value }) => (_jsx(ListItemWrapper, { children: _jsx("div", { className: "table-name", title: value.label, children: value.label }) }));
|
|
95
|
+
/**
|
|
96
|
+
* Dropdown button that lists available datasets and DuckDB tables.
|
|
97
|
+
* When a table is selected, it is synced to Kepler on demand and a new
|
|
98
|
+
* layer is created for it.
|
|
99
|
+
*/
|
|
100
|
+
const AddTableLayerButton = ({ onAdd, keplerDatasetIds, disabled }) => {
|
|
101
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
102
|
+
const [isAdding, setIsAdding] = useState(false);
|
|
103
|
+
const dropdownRef = useRef(null);
|
|
104
|
+
const buttonRef = useRef(null);
|
|
105
|
+
const [menuPos, setMenuPos] = useState({
|
|
106
|
+
top: 0,
|
|
107
|
+
right: 0,
|
|
108
|
+
});
|
|
109
|
+
const intl = useIntl();
|
|
110
|
+
const dbTables = useStoreWithKepler((state) => state.db.tables);
|
|
111
|
+
const options = useMemo(() => {
|
|
112
|
+
const tableNames = new Set(dbTables
|
|
113
|
+
.filter((t) => t.table.schema === 'main')
|
|
114
|
+
.map((t) => t.table.table));
|
|
115
|
+
for (const id of keplerDatasetIds) {
|
|
116
|
+
tableNames.add(id);
|
|
117
|
+
}
|
|
118
|
+
return Array.from(tableNames)
|
|
119
|
+
.sort()
|
|
120
|
+
.map((name) => ({ label: name, value: name }));
|
|
121
|
+
}, [dbTables, keplerDatasetIds]);
|
|
122
|
+
const handleClick = useCallback(async () => {
|
|
123
|
+
if (options.length === 1 && options[0]) {
|
|
124
|
+
setIsAdding(true);
|
|
125
|
+
try {
|
|
126
|
+
await onAdd(options[0].value);
|
|
127
|
+
}
|
|
128
|
+
catch (e) {
|
|
129
|
+
console.error('Failed to add layer:', e);
|
|
130
|
+
}
|
|
131
|
+
finally {
|
|
132
|
+
setIsAdding(false);
|
|
133
|
+
}
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (buttonRef.current) {
|
|
137
|
+
const rect = buttonRef.current.getBoundingClientRect();
|
|
138
|
+
setMenuPos({
|
|
139
|
+
top: rect.bottom,
|
|
140
|
+
right: window.innerWidth - rect.right,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
setIsOpen((prev) => !prev);
|
|
144
|
+
}, [options, onAdd]);
|
|
145
|
+
const handleSelect = useCallback((option) => {
|
|
146
|
+
if (!option)
|
|
147
|
+
return;
|
|
148
|
+
setIsAdding(true);
|
|
149
|
+
onAdd(option.value)
|
|
150
|
+
.then(() => setIsOpen(false))
|
|
151
|
+
.catch((e) => console.error('Failed to add layer:', e))
|
|
152
|
+
.finally(() => setIsAdding(false));
|
|
153
|
+
}, [onAdd]);
|
|
154
|
+
// Close dropdown on outside click
|
|
155
|
+
React.useEffect(() => {
|
|
156
|
+
if (!isOpen)
|
|
157
|
+
return;
|
|
158
|
+
const handleClickOutside = (e) => {
|
|
159
|
+
if (dropdownRef.current &&
|
|
160
|
+
!dropdownRef.current.contains(e.target)) {
|
|
161
|
+
setIsOpen(false);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
165
|
+
return () => document.removeEventListener('mousedown', handleClickOutside);
|
|
166
|
+
}, [isOpen]);
|
|
167
|
+
return (_jsxs(DropdownWrapper, { ref: dropdownRef, children: [_jsxs(Button, { ref: buttonRef, className: "add-layer-button", onClick: handleClick, disabled: !options.length || disabled || isAdding, children: [_jsx(Icons.Add, { height: "12px" }), intl.formatMessage({ id: 'layerManager.addLayer' })] }), isOpen && options.length > 1 && (_jsx(DropdownMenu, { style: { top: menuPos.top, right: menuPos.right }, children: _jsx(Typeahead, { className: TYPEAHEAD_CLASS, customClasses: {
|
|
168
|
+
results: 'list-selector',
|
|
169
|
+
input: TYPEAHEAD_INPUT_CLASS,
|
|
170
|
+
listItem: 'list__item',
|
|
171
|
+
}, placeholder: intl ? intl.formatMessage({ id: 'placeholder.search' }) : 'Search', selectedItems: null, options: options, displayOption: Accessor.generateOptionToStringFor('label'), filterOption: 'label', searchable: true, onOptionSelected: handleSelect, customListItemComponent: TableListItem }) }))] }));
|
|
172
|
+
};
|
|
62
173
|
function useCustomSidePanelActions(keplerActions) {
|
|
63
174
|
const { openDeleteModal, toggleModal } = keplerActions.uiStateActions;
|
|
64
175
|
const { updateTableColor } = keplerActions.visStateActions;
|
|
@@ -75,13 +186,23 @@ function useCustomSidePanelActions(keplerActions) {
|
|
|
75
186
|
export const CustomLayerManager = ({ mapId, showDeleteDataset = true, }) => {
|
|
76
187
|
const { keplerActions, keplerState } = useKeplerStateActions({ mapId });
|
|
77
188
|
const intl = useIntl();
|
|
189
|
+
const addTableToMap = useStoreWithKepler((state) => state.kepler.addTableToMap);
|
|
78
190
|
const { onRemoveDataset, onUpdateTableColor } = useCustomSidePanelActions(keplerActions);
|
|
79
191
|
const { addLayer } = keplerActions.visStateActions;
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
192
|
+
const keplerDatasetIds = useMemo(() => Object.keys(keplerState?.visState.datasets ?? {}), [keplerState?.visState.datasets]);
|
|
193
|
+
const onAddTableLayer = useCallback(async (tableName) => {
|
|
194
|
+
const keplerDatasets = keplerState?.visState.datasets;
|
|
195
|
+
if (!keplerDatasets?.[tableName]) {
|
|
196
|
+
await addTableToMap(mapId, tableName, {
|
|
197
|
+
autoCreateLayers: true,
|
|
198
|
+
centerMap: true,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
addLayer(undefined, tableName);
|
|
203
|
+
}
|
|
204
|
+
}, [addLayer, addTableToMap, keplerState?.visState.datasets, mapId]);
|
|
83
205
|
const isSortByDatasetMode = keplerState?.uiState.layerPanelListView === PANEL_VIEW_TOGGLES.byDataset;
|
|
84
|
-
// Filter layer classes based on application config
|
|
85
206
|
const enableRasterTileLayer = getApplicationConfig().enableRasterTileLayer;
|
|
86
207
|
const enableWMSLayer = getApplicationConfig().enableWMSLayer;
|
|
87
208
|
const filteredLayerClasses = useMemo(() => {
|
|
@@ -105,6 +226,6 @@ export const CustomLayerManager = ({ mapId, showDeleteDataset = true, }) => {
|
|
|
105
226
|
}
|
|
106
227
|
return (_jsx(CustomLayerManagerContainer, { children: _jsxs("div", { className: "layer-manager", children: [_jsx(SidePanelSection, { children: _jsx(PanelTitle, { className: "layer-manager-title", title: intl.formatMessage({
|
|
107
228
|
id: layerPanelMetadata?.label || 'Layers',
|
|
108
|
-
}), children: _jsx(
|
|
229
|
+
}), children: _jsx(AddTableLayerButton, { onAdd: onAddTableLayer, keplerDatasetIds: keplerDatasetIds }) }) }), _jsx(SidePanelSection, { children: isSortByDatasetMode ? (_jsx(DatasetLayerGroup, { datasets: keplerState.visState.datasets, showDatasetTable: keplerActions.visStateActions.showDatasetTable, layers: keplerState.visState.layers, updateTableColor: onUpdateTableColor, removeDataset: onRemoveDataset, layerOrder: keplerState.visState.layerOrder, layerClasses: filteredLayerClasses, uiStateActions: keplerActions.uiStateActions, visStateActions: keplerActions.visStateActions, mapStateActions: keplerActions.mapStateActions, showDeleteDataset: showDeleteDataset })) : (_jsx(LayerList, { layers: keplerState.visState.layers, datasets: keplerState.visState.datasets, layerOrder: keplerState.visState.layerOrder, uiStateActions: keplerActions.uiStateActions, visStateActions: keplerActions.visStateActions, mapStateActions: keplerActions.mapStateActions, layerClasses: filteredLayerClasses })) })] }) }));
|
|
109
230
|
};
|
|
110
231
|
//# sourceMappingURL=CustomLayerManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomLayerManager.js","sourceRoot":"","sources":["../../src/components/CustomLayerManager.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,gBAAgB,EAChB,wBAAwB,EACxB,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAC,kBAAkB,EAAE,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAAC,oBAAoB,EAAC,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAEL,qBAAqB,GACtB,MAAM,gCAAgC,CAAC;AAGxC,oDAAoD;AACpD,MAAM,SAAS,GAAG,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;AACrD,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,wBAAwB,CAAC,CAAC;AACrE,MAAM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AC5C,eAAe,EAAE,aAAa,CAAC,eAAe,EAC9C,eAAe,EAAE,aAAa,CAAC,eAAe,EAC9C,YAAY,EAAE,oBAAoB,GAClC,CACH,GACgB,IACf,GACsB,CAC/B,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React, {useCallback, useMemo} from 'react';\nimport {useIntl} from 'react-intl';\nimport styled from 'styled-components';\n\nimport {\n LayerListFactory,\n DatasetLayerGroupFactory,\n PanelTitleFactory,\n AddLayerButtonFactory,\n SidePanelSection,\n} from '@kepler.gl/components';\nimport {PANEL_VIEW_TOGGLES, SIDEBAR_PANELS} from '@kepler.gl/constants';\nimport {LayerClassesType} from '@kepler.gl/layers';\nimport {getApplicationConfig} from '@kepler.gl/utils';\n\nimport {getKeplerFactory} from './KeplerInjector';\nimport {\n KeplerActions,\n useKeplerStateActions,\n} from '../hooks/useKeplerStateActions';\nimport {RGBColor} from '@kepler.gl/types';\n\n// Get the kepler.gl components through the injector\nconst LayerList = getKeplerFactory(LayerListFactory);\nconst DatasetLayerGroup = getKeplerFactory(DatasetLayerGroupFactory);\nconst PanelTitle = getKeplerFactory(PanelTitleFactory);\nconst AddLayerButton = getKeplerFactory(AddLayerButtonFactory);\n\nconst layerPanelMetadata = SIDEBAR_PANELS.find((p) => p.id === 'layer');\n\n// Custom styled components for your layer manager\nconst CustomLayerManagerContainer = styled.div`\n .layer-manager {\n /* Add your custom styles here */\n }\n \n .layer-manager-title {\n /* Custom title styling */\n }\n\n .add-layer-button {\n background-color: ${(props) => props.theme.sidePanelBg || props.theme.panelBackground};\n color: #2563EB; \n border: 0px;\n height: 28px;\n font-weight: 500;\n font-size: 14px;\n }\n\n .layer__title__type {\n display: none !important;\n }\n\n .layer-panel__header {\n height: 36px;\n }\n\n .layer__title {\n min-width: 0;\n }\n\n .layer__title > div {\n flex: 1;\n min-width: 0;\n display: flex;\n flex-direction: column;\n }\n\n .layer__title__editor {\n width: 100%;\n min-width: 0;\n flex: 1;\n }\n}\n`;\n\ntype CustomLayerManagerProps = {\n mapId: string;\n showDeleteDataset?: boolean;\n};\n\n// Custom hook for side panel actions\nfunction useCustomSidePanelActions(keplerActions: KeplerActions) {\n const {openDeleteModal, toggleModal} = keplerActions.uiStateActions;\n const {updateTableColor} = keplerActions.visStateActions;\n\n const onRemoveDataset = useCallback(\n (dataId: string) => openDeleteModal(dataId),\n [openDeleteModal],\n );\n\n const onShowAddDataModal = useCallback(\n () => toggleModal('addData'),\n [toggleModal],\n );\n\n const onUpdateTableColor = useCallback(\n (dataId: string, newColor: RGBColor) => updateTableColor(dataId, newColor),\n [updateTableColor],\n );\n\n return {\n onRemoveDataset,\n onShowAddDataModal,\n onUpdateTableColor,\n };\n}\n\n// Main Custom Layer Manager Component\nexport const CustomLayerManager: React.FC<CustomLayerManagerProps> = ({\n mapId,\n showDeleteDataset = true,\n}) => {\n const {keplerActions, keplerState} = useKeplerStateActions({mapId});\n const intl = useIntl();\n\n const {onRemoveDataset, onUpdateTableColor} =\n useCustomSidePanelActions(keplerActions);\n\n const {addLayer} = keplerActions.visStateActions;\n\n const onAddLayer = useCallback(\n (dataset: string) => {\n addLayer(undefined, dataset);\n },\n [addLayer],\n );\n\n const isSortByDatasetMode =\n keplerState?.uiState.layerPanelListView === PANEL_VIEW_TOGGLES.byDataset;\n\n // Filter layer classes based on application config\n const enableRasterTileLayer = getApplicationConfig().enableRasterTileLayer;\n const enableWMSLayer = getApplicationConfig().enableWMSLayer;\n\n const filteredLayerClasses = useMemo(() => {\n let filteredClasses = keplerState?.visState.layerClasses || {};\n if (!enableRasterTileLayer && 'rasterTile' in filteredClasses) {\n const {rasterTile: _rasterTile, ...rest} = filteredClasses;\n filteredClasses = rest as LayerClassesType;\n }\n if (!enableWMSLayer && 'wms' in filteredClasses) {\n const {wms: _wms, ...rest} = filteredClasses;\n filteredClasses = rest as LayerClassesType;\n }\n return filteredClasses as LayerClassesType;\n }, [\n enableRasterTileLayer,\n enableWMSLayer,\n keplerState?.visState.layerClasses,\n ]);\n\n if (!keplerState || !keplerActions) {\n return null;\n }\n\n return (\n <CustomLayerManagerContainer>\n <div className=\"layer-manager\">\n <SidePanelSection>\n <PanelTitle\n className=\"layer-manager-title\"\n title={intl.formatMessage({\n id: layerPanelMetadata?.label || 'Layers',\n })}\n >\n <AddLayerButton\n datasets={keplerState.visState.datasets}\n onAdd={onAddLayer}\n />\n </PanelTitle>\n </SidePanelSection>\n\n <SidePanelSection>\n {isSortByDatasetMode ? (\n <DatasetLayerGroup\n datasets={keplerState.visState.datasets}\n showDatasetTable={keplerActions.visStateActions.showDatasetTable}\n layers={keplerState.visState.layers}\n updateTableColor={onUpdateTableColor}\n removeDataset={onRemoveDataset}\n layerOrder={keplerState.visState.layerOrder}\n layerClasses={filteredLayerClasses}\n uiStateActions={keplerActions.uiStateActions}\n visStateActions={keplerActions.visStateActions}\n mapStateActions={keplerActions.mapStateActions}\n showDeleteDataset={showDeleteDataset}\n />\n ) : (\n <LayerList\n layers={keplerState.visState.layers}\n datasets={keplerState.visState.datasets}\n layerOrder={keplerState.visState.layerOrder}\n uiStateActions={keplerActions.uiStateActions}\n visStateActions={keplerActions.visStateActions}\n mapStateActions={keplerActions.mapStateActions}\n layerClasses={filteredLayerClasses}\n />\n )}\n </SidePanelSection>\n </div>\n </CustomLayerManagerContainer>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"CustomLayerManager.js","sourceRoot":"","sources":["../../src/components/CustomLayerManager.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAC,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACpE,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AACnC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EACL,QAAQ,EACR,MAAM,EACN,KAAK,EACL,gBAAgB,EAChB,wBAAwB,EACxB,iBAAiB,EACjB,gBAAgB,EAChB,SAAS,GACV,MAAM,uBAAuB,CAAC;AAC/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AI,QAAQ;yBAC1C,CAAC,YAEF,KAAC,mBAAmB,IAClB,KAAK,EAAE,eAAe,EACtB,gBAAgB,EAAE,gBAAgB,GAClC,GACS,GACI,EAEnB,KAAC,gBAAgB,cACd,mBAAmB,CAAC,CAAC,CAAC,CACrB,KAAC,iBAAiB,IAChB,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAAC,QAAQ,EACvC,gBAAgB,EAAE,aAAa,CAAC,eAAe,CAAC,gBAAgB,EAChE,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,MAAM,EACnC,gBAAgB,EAAE,kBAAkB,EACpC,aAAa,EAAE,eAAe,EAC9B,UAAU,EAAE,WAAW,CAAC,QAAQ,CAAC,UAAU,EAC3C,YAAY,EAAE,oBAAoB,EAClC,cAAc,EAAE,aAAa,CAAC,cAAc,EAC5C,eAAe,EAAE,aAAa,CAAC,eAAe,EAC9C,eAAe,EAAE,aAAa,CAAC,eAAe,EAC9C,iBAAiB,EAAE,iBAAiB,GACpC,CACH,CAAC,CAAC,CAAC,CACF,KAAC,SAAS,IACR,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,MAAM,EACnC,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAAC,QAAQ,EACvC,UAAU,EAAE,WAAW,CAAC,QAAQ,CAAC,UAAU,EAC3C,cAAc,EAAE,aAAa,CAAC,cAAc,EAC5C,eAAe,EAAE,aAAa,CAAC,eAAe,EAC9C,eAAe,EAAE,aAAa,CAAC,eAAe,EAC9C,YAAY,EAAE,oBAAoB,GAClC,CACH,GACgB,IACf,GACsB,CAC/B,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React, {useCallback, useMemo, useRef, useState} from 'react';\nimport {useIntl} from 'react-intl';\nimport styled from 'styled-components';\n\nimport {\n Accessor,\n Button,\n Icons,\n LayerListFactory,\n DatasetLayerGroupFactory,\n PanelTitleFactory,\n SidePanelSection,\n Typeahead,\n} from '@kepler.gl/components';\nimport {PANEL_VIEW_TOGGLES, SIDEBAR_PANELS} from '@kepler.gl/constants';\nimport {LayerClassesType} from '@kepler.gl/layers';\nimport {getApplicationConfig} from '@kepler.gl/utils';\n\nimport {getKeplerFactory} from './KeplerInjector';\nimport {\n KeplerActions,\n useKeplerStateActions,\n} from '../hooks/useKeplerStateActions';\nimport {useStoreWithKepler} from '../KeplerSlice';\nimport {RGBColor} from '@kepler.gl/types';\n\nconst LayerList = getKeplerFactory(LayerListFactory);\nconst DatasetLayerGroup = getKeplerFactory(DatasetLayerGroupFactory);\nconst PanelTitle = getKeplerFactory(PanelTitleFactory);\n\nconst layerPanelMetadata = SIDEBAR_PANELS.find((p) => p.id === 'layer');\n\nconst CustomLayerManagerContainer = styled.div`\n .layer-manager-title {\n }\n\n .add-layer-button {\n background-color: ${(props) => props.theme.sidePanelBg || props.theme.panelBackground};\n color: #2563EB;\n border: 0px;\n height: 28px;\n font-weight: 500;\n font-size: 14px;\n }\n\n .layer__title__type {\n display: none !important;\n }\n\n .layer-panel__header {\n height: 36px;\n }\n\n .layer__title {\n min-width: 0;\n }\n\n .layer__title > div {\n flex: 1;\n min-width: 0;\n display: flex;\n flex-direction: column;\n }\n\n .layer__title__editor {\n width: 100%;\n min-width: 0;\n flex: 1;\n }\n}\n`;\n\nconst DropdownWrapper = styled.div`\n position: relative;\n display: inline-block;\n overflow: visible;\n`;\n\nconst DropdownMenu = styled.div`\n display: flex;\n flex-direction: column;\n min-width: 240px;\n max-width: 240px;\n position: fixed;\n z-index: 100;\n\n .list-selector {\n border-top: 1px solid ${(props) => props.theme.secondaryInputBorderColor};\n width: 100%;\n max-height: unset;\n }\n .list__item > div {\n display: flex;\n flex-direction: row;\n justify-content: flex-start;\n line-height: 18px;\n padding: 0;\n }\n`;\n\nconst ListItemWrapper = styled.div`\n display: flex;\n color: ${(props) => props.theme.textColor};\n font-size: 11px;\n letter-spacing: 0.2px;\n overflow: auto;\n .table-name {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n`;\n\nconst TYPEAHEAD_CLASS = 'typeahead';\nconst TYPEAHEAD_INPUT_CLASS = 'typeahead__input';\n\ntype TableOption = {label: string; value: string};\n\nconst TableListItem: React.FC<{value: TableOption}> = ({value}) => (\n <ListItemWrapper>\n <div className=\"table-name\" title={value.label}>\n {value.label}\n </div>\n </ListItemWrapper>\n);\n\n/**\n * Dropdown button that lists available datasets and DuckDB tables.\n * When a table is selected, it is synced to Kepler on demand and a new\n * layer is created for it.\n */\nconst AddTableLayerButton: React.FC<{\n onAdd: (tableName: string) => Promise<void>;\n keplerDatasetIds: string[];\n disabled?: boolean;\n}> = ({onAdd, keplerDatasetIds, disabled}) => {\n const [isOpen, setIsOpen] = useState(false);\n const [isAdding, setIsAdding] = useState(false);\n const dropdownRef = useRef<HTMLDivElement>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const [menuPos, setMenuPos] = useState<{top: number; right: number}>({\n top: 0,\n right: 0,\n });\n const intl = useIntl();\n\n const dbTables = useStoreWithKepler((state) => state.db.tables);\n\n const options: TableOption[] = useMemo(() => {\n const tableNames = new Set(\n dbTables\n .filter((t) => t.table.schema === 'main')\n .map((t) => t.table.table),\n );\n for (const id of keplerDatasetIds) {\n tableNames.add(id);\n }\n return Array.from(tableNames)\n .sort()\n .map((name) => ({label: name, value: name}));\n }, [dbTables, keplerDatasetIds]);\n\n const handleClick = useCallback(async () => {\n if (options.length === 1 && options[0]) {\n setIsAdding(true);\n try {\n await onAdd(options[0].value);\n } catch (e) {\n console.error('Failed to add layer:', e);\n } finally {\n setIsAdding(false);\n }\n return;\n }\n if (buttonRef.current) {\n const rect = buttonRef.current.getBoundingClientRect();\n setMenuPos({\n top: rect.bottom,\n right: window.innerWidth - rect.right,\n });\n }\n setIsOpen((prev) => !prev);\n }, [options, onAdd]);\n\n const handleSelect = useCallback(\n (option: TableOption | null) => {\n if (!option) return;\n setIsAdding(true);\n onAdd(option.value)\n .then(() => setIsOpen(false))\n .catch((e) => console.error('Failed to add layer:', e))\n .finally(() => setIsAdding(false));\n },\n [onAdd],\n );\n\n // Close dropdown on outside click\n React.useEffect(() => {\n if (!isOpen) return;\n const handleClickOutside = (e: MouseEvent) => {\n if (\n dropdownRef.current &&\n !dropdownRef.current.contains(e.target as Node)\n ) {\n setIsOpen(false);\n }\n };\n document.addEventListener('mousedown', handleClickOutside);\n return () => document.removeEventListener('mousedown', handleClickOutside);\n }, [isOpen]);\n\n return (\n <DropdownWrapper ref={dropdownRef}>\n <Button\n ref={buttonRef}\n className=\"add-layer-button\"\n onClick={handleClick}\n disabled={!options.length || disabled || isAdding}\n >\n <Icons.Add height=\"12px\" />\n {intl.formatMessage({id: 'layerManager.addLayer'})}\n </Button>\n {isOpen && options.length > 1 && (\n <DropdownMenu style={{top: menuPos.top, right: menuPos.right}}>\n <Typeahead\n className={TYPEAHEAD_CLASS}\n customClasses={{\n results: 'list-selector',\n input: TYPEAHEAD_INPUT_CLASS,\n listItem: 'list__item',\n }}\n placeholder={\n intl ? intl.formatMessage({id: 'placeholder.search'}) : 'Search'\n }\n selectedItems={null}\n options={options}\n displayOption={Accessor.generateOptionToStringFor('label')}\n filterOption={'label'}\n searchable\n onOptionSelected={handleSelect}\n customListItemComponent={TableListItem}\n />\n </DropdownMenu>\n )}\n </DropdownWrapper>\n );\n};\n\ntype CustomLayerManagerProps = {\n mapId: string;\n showDeleteDataset?: boolean;\n};\n\nfunction useCustomSidePanelActions(keplerActions: KeplerActions) {\n const {openDeleteModal, toggleModal} = keplerActions.uiStateActions;\n const {updateTableColor} = keplerActions.visStateActions;\n\n const onRemoveDataset = useCallback(\n (dataId: string) => openDeleteModal(dataId),\n [openDeleteModal],\n );\n\n const onShowAddDataModal = useCallback(\n () => toggleModal('addData'),\n [toggleModal],\n );\n\n const onUpdateTableColor = useCallback(\n (dataId: string, newColor: RGBColor) => updateTableColor(dataId, newColor),\n [updateTableColor],\n );\n\n return {\n onRemoveDataset,\n onShowAddDataModal,\n onUpdateTableColor,\n };\n}\n\n// Main Custom Layer Manager Component\nexport const CustomLayerManager: React.FC<CustomLayerManagerProps> = ({\n mapId,\n showDeleteDataset = true,\n}) => {\n const {keplerActions, keplerState} = useKeplerStateActions({mapId});\n const intl = useIntl();\n const addTableToMap = useStoreWithKepler(\n (state) => state.kepler.addTableToMap,\n );\n\n const {onRemoveDataset, onUpdateTableColor} =\n useCustomSidePanelActions(keplerActions);\n\n const {addLayer} = keplerActions.visStateActions;\n\n const keplerDatasetIds = useMemo(\n () => Object.keys(keplerState?.visState.datasets ?? {}),\n [keplerState?.visState.datasets],\n );\n\n const onAddTableLayer = useCallback(\n async (tableName: string) => {\n const keplerDatasets = keplerState?.visState.datasets;\n if (!keplerDatasets?.[tableName]) {\n await addTableToMap(mapId, tableName, {\n autoCreateLayers: true,\n centerMap: true,\n });\n } else {\n addLayer(undefined, tableName);\n }\n },\n [addLayer, addTableToMap, keplerState?.visState.datasets, mapId],\n );\n\n const isSortByDatasetMode =\n keplerState?.uiState.layerPanelListView === PANEL_VIEW_TOGGLES.byDataset;\n\n const enableRasterTileLayer = getApplicationConfig().enableRasterTileLayer;\n const enableWMSLayer = getApplicationConfig().enableWMSLayer;\n\n const filteredLayerClasses = useMemo(() => {\n let filteredClasses = keplerState?.visState.layerClasses || {};\n if (!enableRasterTileLayer && 'rasterTile' in filteredClasses) {\n const {rasterTile: _rasterTile, ...rest} = filteredClasses;\n filteredClasses = rest as LayerClassesType;\n }\n if (!enableWMSLayer && 'wms' in filteredClasses) {\n const {wms: _wms, ...rest} = filteredClasses;\n filteredClasses = rest as LayerClassesType;\n }\n return filteredClasses as LayerClassesType;\n }, [\n enableRasterTileLayer,\n enableWMSLayer,\n keplerState?.visState.layerClasses,\n ]);\n\n if (!keplerState || !keplerActions) {\n return null;\n }\n\n return (\n <CustomLayerManagerContainer>\n <div className=\"layer-manager\">\n <SidePanelSection>\n <PanelTitle\n className=\"layer-manager-title\"\n title={intl.formatMessage({\n id: layerPanelMetadata?.label || 'Layers',\n })}\n >\n <AddTableLayerButton\n onAdd={onAddTableLayer}\n keplerDatasetIds={keplerDatasetIds}\n />\n </PanelTitle>\n </SidePanelSection>\n\n <SidePanelSection>\n {isSortByDatasetMode ? (\n <DatasetLayerGroup\n datasets={keplerState.visState.datasets}\n showDatasetTable={keplerActions.visStateActions.showDatasetTable}\n layers={keplerState.visState.layers}\n updateTableColor={onUpdateTableColor}\n removeDataset={onRemoveDataset}\n layerOrder={keplerState.visState.layerOrder}\n layerClasses={filteredLayerClasses}\n uiStateActions={keplerActions.uiStateActions}\n visStateActions={keplerActions.visStateActions}\n mapStateActions={keplerActions.mapStateActions}\n showDeleteDataset={showDeleteDataset}\n />\n ) : (\n <LayerList\n layers={keplerState.visState.layers}\n datasets={keplerState.visState.datasets}\n layerOrder={keplerState.visState.layerOrder}\n uiStateActions={keplerActions.uiStateActions}\n visStateActions={keplerActions.visStateActions}\n mapStateActions={keplerActions.mapStateActions}\n layerClasses={filteredLayerClasses}\n />\n )}\n </SidePanelSection>\n </div>\n </CustomLayerManagerContainer>\n );\n};\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MapControlTooltipFactory, MapControlToolbarFactory, MapDrawPanelFactory } from '@kepler.gl/components';
|
|
3
|
+
import type { MapDrawPanelProps } from '@kepler.gl/components';
|
|
4
|
+
export declare function CustomMapDrawPanelFactory(...deps: Parameters<typeof MapDrawPanelFactory>): React.FC<MapDrawPanelProps>;
|
|
5
|
+
export declare namespace CustomMapDrawPanelFactory {
|
|
6
|
+
var deps: (typeof MapControlTooltipFactory | typeof MapControlToolbarFactory)[];
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=CustomMapDrawPanel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomMapDrawPanel.d.ts","sourceRoot":"","sources":["../../src/components/CustomMapDrawPanel.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AAM7D,wBAAgB,yBAAyB,CACvC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,+BA6ChD;yBA9Ce,yBAAyB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
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 React, { useCallback } from 'react';
|
|
5
|
+
import { MapDrawPanelFactory, } from '@kepler.gl/components';
|
|
6
|
+
import { XIcon } from 'lucide-react';
|
|
7
|
+
import { Button } from '@sqlrooms/ui';
|
|
8
|
+
CustomMapDrawPanelFactory.deps = MapDrawPanelFactory.deps;
|
|
9
|
+
export function CustomMapDrawPanelFactory(...deps) {
|
|
10
|
+
// Get the original MapDrawPanel component
|
|
11
|
+
const OriginalMapDrawPanel = MapDrawPanelFactory(...deps);
|
|
12
|
+
const CustomMapDrawPanel = React.memo((props) => {
|
|
13
|
+
const { mapControls, onToggleMapControl } = props;
|
|
14
|
+
const isActive = mapControls?.mapDraw?.active;
|
|
15
|
+
const onToggleMenuPanel = useCallback(() => onToggleMapControl('mapDraw'), [onToggleMapControl]);
|
|
16
|
+
if (!mapControls?.mapDraw?.show) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return (_jsxs("div", { className: "map-draw-controls", style: { position: 'relative' }, children: [_jsx(OriginalMapDrawPanel, { ...props }), isActive && (_jsx(Button, { variant: "ghost", size: "xs", className: "border-border bg-background hover:bg-accent absolute z-50 h-6 w-6 rounded-full border p-0 shadow-sm", style: { left: '-35px', top: '-20px' }, "aria-label": "Close draw panel", onClick: (e) => {
|
|
20
|
+
e.preventDefault();
|
|
21
|
+
e.stopPropagation();
|
|
22
|
+
onToggleMenuPanel();
|
|
23
|
+
}, children: _jsx(XIcon, { className: "h-3 w-3" }) }))] }));
|
|
24
|
+
});
|
|
25
|
+
CustomMapDrawPanel.displayName = 'CustomMapDrawPanel';
|
|
26
|
+
return CustomMapDrawPanel;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=CustomMapDrawPanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomMapDrawPanel.js","sourceRoot":"","sources":["../../src/components/CustomMapDrawPanel.tsx"],"names":[],"mappings":";AAAA,+BAA+B;AAC/B,kDAAkD;AAElD,OAAO,KAAK,EAAE,EAAC,WAAW,EAAC,MAAM,OAAO,CAAC;AACzC,OAAO,EAGL,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAC;AACnC,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAEpC,yBAAyB,CAAC,IAAI,GAAG,mBAAmB,CAAC,IAAI,CAAC;AAE1D,MAAM,UAAU,yBAAyB,CACvC,GAAG,IAA4C;IAE/C,0CAA0C;IAC1C,MAAM,oBAAoB,GAAG,mBAAmB,CAAC,GAAG,IAAI,CAAC,CAAC;IAE1D,MAAM,kBAAkB,GAAgC,KAAK,CAAC,IAAI,CAChE,CAAC,KAAK,EAAE,EAAE;QACR,MAAM,EAAC,WAAW,EAAE,kBAAkB,EAAC,GAAG,KAAK,CAAC;QAChD,MAAM,QAAQ,GAAG,WAAW,EAAE,OAAO,EAAE,MAAM,CAAC;QAE9C,MAAM,iBAAiB,GAAG,WAAW,CACnC,GAAG,EAAE,CAAC,kBAAkB,CAAC,SAAS,CAAC,EACnC,CAAC,kBAAkB,CAAC,CACrB,CAAC;QAEF,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,CACL,eAAK,SAAS,EAAC,mBAAmB,EAAC,KAAK,EAAE,EAAC,QAAQ,EAAE,UAAU,EAAC,aAC9D,KAAC,oBAAoB,OAAK,KAAK,GAAI,EAClC,QAAQ,IAAI,CACX,KAAC,MAAM,IACL,OAAO,EAAC,OAAO,EACf,IAAI,EAAC,IAAI,EACT,SAAS,EAAC,qGAAqG,EAC/G,KAAK,EAAE,EAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAC,gBACzB,kBAAkB,EAC7B,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;wBACb,CAAC,CAAC,cAAc,EAAE,CAAC;wBACnB,CAAC,CAAC,eAAe,EAAE,CAAC;wBACpB,iBAAiB,EAAE,CAAC;oBACtB,CAAC,YAED,KAAC,KAAK,IAAC,SAAS,EAAC,SAAS,GAAG,GACtB,CACV,IACG,CACP,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,kBAAkB,CAAC,WAAW,GAAG,oBAAoB,CAAC;IACtD,OAAO,kBAAkB,CAAC;AAC5B,CAAC","sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright contributors to the kepler.gl project\n\nimport React, {useCallback} from 'react';\nimport {\n MapControlTooltipFactory,\n MapControlToolbarFactory,\n MapDrawPanelFactory,\n} from '@kepler.gl/components';\nimport type {MapDrawPanelProps} from '@kepler.gl/components';\nimport {XIcon} from 'lucide-react';\nimport {Button} from '@sqlrooms/ui';\n\nCustomMapDrawPanelFactory.deps = MapDrawPanelFactory.deps;\n\nexport function CustomMapDrawPanelFactory(\n ...deps: Parameters<typeof MapDrawPanelFactory>\n) {\n // Get the original MapDrawPanel component\n const OriginalMapDrawPanel = MapDrawPanelFactory(...deps);\n\n const CustomMapDrawPanel: React.FC<MapDrawPanelProps> = React.memo(\n (props) => {\n const {mapControls, onToggleMapControl} = props;\n const isActive = mapControls?.mapDraw?.active;\n\n const onToggleMenuPanel = useCallback(\n () => onToggleMapControl('mapDraw'),\n [onToggleMapControl],\n );\n\n if (!mapControls?.mapDraw?.show) {\n return null;\n }\n\n return (\n <div className=\"map-draw-controls\" style={{position: 'relative'}}>\n <OriginalMapDrawPanel {...props} />\n {isActive && (\n <Button\n variant=\"ghost\"\n size=\"xs\"\n className=\"border-border bg-background hover:bg-accent absolute z-50 h-6 w-6 rounded-full border p-0 shadow-sm\"\n style={{left: '-35px', top: '-20px'}}\n aria-label=\"Close draw panel\"\n onClick={(e) => {\n e.preventDefault();\n e.stopPropagation();\n onToggleMenuPanel();\n }}\n >\n <XIcon className=\"h-3 w-3\" />\n </Button>\n )}\n </div>\n );\n },\n );\n\n CustomMapDrawPanel.displayName = 'CustomMapDrawPanel';\n return CustomMapDrawPanel;\n}\n"]}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { LayerLegendContentFactory, LayerLegendHeaderFactory } from '@kepler.gl/components';
|
|
2
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
|
|
3
|
+
export declare function CustomMapLegendFactory(LayerLegendHeader: ReturnType<typeof LayerLegendHeaderFactory>, LayerLegendContent: ReturnType<typeof LayerLegendContentFactory>): import("react").FC<MapLegendProps & {
|
|
4
|
+
mapIndex?: number;
|
|
5
|
+
onClose?: () => void;
|
|
6
|
+
}>;
|
|
4
7
|
export declare namespace CustomMapLegendFactory {
|
|
5
8
|
var deps: (typeof LayerLegendHeaderFactory | typeof LayerLegendContentFactory)[];
|
|
6
9
|
}
|
|
@@ -1 +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;
|
|
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;AAiCzE,wBAAgB,sBAAsB,CACpC,iBAAiB,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,EAC9D,kBAAkB,EAAE,UAAU,CAAC,OAAO,yBAAyB,CAAC;eAGjC,MAAM;cAAY,MAAM,IAAI;GAuK5D;yBA5Ke,sBAAsB"}
|
|
@@ -8,6 +8,7 @@ import { Button } from '@sqlrooms/ui';
|
|
|
8
8
|
import { ArrowDown, ArrowRight, ChevronDownIcon, ChevronRightIcon, XIcon, } from 'lucide-react';
|
|
9
9
|
import { useCallback, useContext, useRef, useState, } from 'react';
|
|
10
10
|
import { useStoreWithKepler } from '../KeplerSlice';
|
|
11
|
+
import { SplitMapIndexContext } from './SplitMapIndexContext';
|
|
11
12
|
const defaultActionIcons = {
|
|
12
13
|
expanded: ArrowDown,
|
|
13
14
|
collapsed: ArrowRight,
|
|
@@ -17,17 +18,26 @@ CustomMapLegendFactory.deps = [
|
|
|
17
18
|
LayerLegendContentFactory,
|
|
18
19
|
];
|
|
19
20
|
export function CustomMapLegendFactory(LayerLegendHeader, LayerLegendContent) {
|
|
20
|
-
const MapLegend = ({ layers = [], width, isExport, ...restProps }) => {
|
|
21
|
+
const MapLegend = ({ layers = [], width, isExport, mapIndex: mapIndexProp, onClose, ...restProps }) => {
|
|
21
22
|
const containerW = width || DIMENSIONS.mapControl.width;
|
|
22
23
|
const mapId = useContext(KeplerGlContext).id;
|
|
24
|
+
const splitMapIndex = useContext(SplitMapIndexContext);
|
|
25
|
+
const mapIndex = mapIndexProp ?? splitMapIndex;
|
|
23
26
|
const dispatchAction = useStoreWithKepler((state) => state.kepler.dispatchAction);
|
|
27
|
+
const splitMaps = useStoreWithKepler((state) => state.kepler.map[mapId]?.visState?.splitMaps);
|
|
24
28
|
const handleClose = (evt) => {
|
|
25
29
|
evt.stopPropagation();
|
|
26
|
-
|
|
30
|
+
if (onClose) {
|
|
31
|
+
onClose();
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
dispatchAction(mapId, toggleMapControl('mapLegend', 0));
|
|
35
|
+
}
|
|
27
36
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
const isSplit = splitMaps && splitMaps.length > 1;
|
|
38
|
+
const panelLayers = isSplit && mapIndex != null ? splitMaps[mapIndex]?.layers : undefined;
|
|
39
|
+
const visibleLayers = layers.filter((layer) => layer.config.isVisible && (!panelLayers || panelLayers[layer.id]));
|
|
40
|
+
return (_jsx("div", { className: "map-legend border-border border", style: { width: containerW }, children: _jsxs("div", { className: "relative flex flex-col", children: [!isExport && (_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: "Legend" }), _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: visibleLayers.map((layer, index) => {
|
|
31
41
|
return (_jsx(LayerLegendItem, { layer: layer, containerW: containerW, isExport: isExport, ...restProps }, index));
|
|
32
42
|
}) })] }) }));
|
|
33
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomMapLegend.js","sourceRoot":"","sources":["../../src/components/CustomMapLegend.tsx"],"names":[],"mappings":";AAAA,+BAA+B;AAC/B,kDAAkD;AAElD,OAAO,EAAoB,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,EA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AkB,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 isExport,\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\n className=\"map-legend border-border border\"\n style={{width: containerW}}\n >\n <div className=\"relative flex flex-col\">\n {!isExport && (\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\">Legend</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 )}\n <div className=\"flex w-full flex-1 flex-col items-center\">\n {layers\n .filter((layer) => layer.config.isVisible)\n .map((layer, index) => {\n return (\n <LayerLegendItem\n key={index}\n layer={layer}\n containerW={containerW}\n isExport={isExport}\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\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 items-center overflow-hidden p-2 text-xs text-ellipsis whitespace-nowrap select-none\">\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={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"]}
|
|
1
|
+
{"version":3,"file":"CustomMapLegend.js","sourceRoot":"","sources":["../../src/components/CustomMapLegend.tsx"],"names":[],"mappings":";AAAA,+BAA+B;AAC/B,kDAAkD;AAElD,OAAO,EAAoB,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,EAGhB,KAAK,GACN,MAAM,cAAc,CAAC;AACtB,OAAO,EAEL,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAA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AAC,MAAM,CAAC,KAAK,GACf,EACN,cAAK,SAAS,EAAC,QAAQ,GAAG,EAC1B,cAAK,SAAS,EAAC,8CAA8C,YAC3D,KAAC,MAAM,IACL,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,GACL,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';\nimport {SplitMapIndexContext} from './SplitMapIndexContext';\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<\n MapLegendProps & {mapIndex?: number; onClose?: () => void}\n > = ({\n layers = [],\n width,\n isExport,\n mapIndex: mapIndexProp,\n onClose,\n ...restProps\n }) => {\n const containerW = width || DIMENSIONS.mapControl.width;\n const mapId = useContext(KeplerGlContext).id;\n const splitMapIndex = useContext(SplitMapIndexContext);\n const mapIndex = mapIndexProp ?? splitMapIndex;\n const dispatchAction = useStoreWithKepler(\n (state) => state.kepler.dispatchAction,\n );\n const splitMaps = useStoreWithKepler(\n (state) => state.kepler.map[mapId]?.visState?.splitMaps,\n );\n const handleClose = (evt: React.MouseEvent<HTMLButtonElement>) => {\n evt.stopPropagation();\n if (onClose) {\n onClose();\n } else {\n dispatchAction(mapId, toggleMapControl('mapLegend', 0));\n }\n };\n\n const isSplit = splitMaps && splitMaps.length > 1;\n const panelLayers =\n isSplit && mapIndex != null ? splitMaps[mapIndex]?.layers : undefined;\n\n const visibleLayers = layers.filter(\n (layer) =>\n layer.config.isVisible && (!panelLayers || panelLayers[layer.id]),\n );\n\n return (\n <div\n className=\"map-legend border-border border\"\n style={{width: containerW}}\n >\n <div className=\"relative flex flex-col\">\n {!isExport && (\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\">Legend</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 )}\n <div className=\"flex w-full flex-1 flex-col items-center\">\n {visibleLayers.map((layer, index) => {\n return (\n <LayerLegendItem\n key={index}\n layer={layer}\n containerW={containerW}\n isExport={isExport}\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\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 items-center overflow-hidden p-2 text-xs text-ellipsis whitespace-nowrap select-none\">\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={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"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MapLegendPanelFactory } from '@kepler.gl/components';
|
|
2
|
-
export declare function CustomMapLegendPanelFactory(
|
|
1
|
+
import { MapControlPanelFactory, MapControlTooltipFactory, MapLegendFactory, MapLegendPanelFactory } from '@kepler.gl/components';
|
|
2
|
+
export declare function CustomMapLegendPanelFactory(MapControlTooltip: ReturnType<typeof MapControlTooltipFactory>, MapControlPanel: ReturnType<typeof MapControlPanelFactory>, MapLegend: ReturnType<typeof MapLegendFactory>): ReturnType<typeof MapLegendPanelFactory>;
|
|
3
3
|
export declare namespace CustomMapLegendPanelFactory {
|
|
4
|
-
var deps: (typeof
|
|
4
|
+
var deps: (typeof MapControlTooltipFactory | typeof MapControlPanelFactory | typeof MapLegendFactory)[];
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=CustomMapLegendPanel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomMapLegendPanel.d.ts","sourceRoot":"","sources":["../../src/components/CustomMapLegendPanel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CustomMapLegendPanel.d.ts","sourceRoot":"","sources":["../../src/components/CustomMapLegendPanel.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,qBAAqB,EAEtB,MAAM,uBAAuB,CAAC;AAI/B,wBAAgB,2BAA2B,CACzC,iBAAiB,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,EAC9D,eAAe,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,EAC1D,SAAS,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GAC7C,UAAU,CAAC,OAAO,qBAAqB,CAAC,CA0E1C;yBA9Ee,2BAA2B"}
|
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useCallback, useState } from 'react';
|
|
3
|
+
import { Icons, MapControlButton, MapLegendPanelFactory, } from '@kepler.gl/components';
|
|
3
4
|
CustomMapLegendPanelFactory.deps = MapLegendPanelFactory.deps;
|
|
4
|
-
export function CustomMapLegendPanelFactory(
|
|
5
|
-
const
|
|
5
|
+
export function CustomMapLegendPanelFactory(MapControlTooltip, MapControlPanel, MapLegend) {
|
|
6
|
+
const OriginalMapLegendPanel = MapLegendPanelFactory(MapControlTooltip, MapControlPanel, MapLegend);
|
|
7
|
+
const SplitPaneLegend = (props) => {
|
|
8
|
+
const [isActive, setIsActive] = useState(false);
|
|
9
|
+
const mapLegend = props.mapControls?.mapLegend;
|
|
10
|
+
const toggleLegend = useCallback((e) => {
|
|
11
|
+
e?.preventDefault();
|
|
12
|
+
setIsActive((prev) => !prev);
|
|
13
|
+
}, []);
|
|
14
|
+
if (!mapLegend?.show)
|
|
15
|
+
return null;
|
|
16
|
+
return isActive ? (_jsxs(_Fragment, { children: [_jsx("style", { children: `.split-legend .map-control__panel-header { display: none !important; }` }), _jsx("div", { className: "split-legend", children: _jsx(MapControlPanel, { scale: props.scale, header: "header.layerLegend", onClick: toggleLegend, pinnable: false, disableClose: false, isExport: props.isExport, logoComponent: props.logoComponent, children: _jsx(MapLegend, { layers: props.layers, mapState: props.mapState, disableEdit: mapLegend.disableEdit, isExport: props.isExport, onLayerVisConfigChange: props.onLayerVisConfigChange, onToggleLayerVisibility: props.onToggleLayerVisibility, ...{ onClose: toggleLegend } }) }) })] })) : (_jsx(MapControlTooltip, { id: "show-legend", message: "tooltip.showLegend", children: _jsx(MapControlButton, { className: "map-control-button show-legend", onClick: toggleLegend, children: _jsx(Icons.Legend, { height: "22px" }) }) }));
|
|
17
|
+
};
|
|
6
18
|
const CustomMapLegendPanel = (props) => {
|
|
7
|
-
|
|
19
|
+
if (props.isSplit) {
|
|
20
|
+
return _jsx(SplitPaneLegend, { ...props });
|
|
21
|
+
}
|
|
22
|
+
return (_jsxs(_Fragment, { children: [_jsx("style", { children: `.draggable-legend .map-control__panel-header { display: none !important; }` }), _jsx(OriginalMapLegendPanel, { ...props })] }));
|
|
8
23
|
};
|
|
9
24
|
CustomMapLegendPanel.displayName = 'CustomMapLegendPanel';
|
|
10
25
|
return CustomMapLegendPanel;
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"CustomMapLegendPanel.js","sourceRoot":"","sources":["../../src/components/CustomMapLegendPanel.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,WAAW,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC5C,OAAO,EACL,KAAK,EACL,gBAAgB,EAIhB,qBAAqB,GAEtB,MAAM,uBAAuB,CAAC;AAE/B,2BAA2B,CAAC,IAAI,GAAG,qBAAqB,CAAC,IAAI,CAAC;AAE9D,MAAM,UAAU,2BAA2B,CACzC,iBAA8D,EAC9D,eAA0D,EAC1D,SAA8C;IAE9C,MAAM,sBAAsB,GAAG,qBAAqB,CAClD,iBAAiB,EACjB,eAAe,EACf,SAAS,CACV,CAAC;IAEF,MAAM,eAAe,GAAG,CACtB,KAAgD,EAChD,EAAE;QACF,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,K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,CAAC,CAAC;IAEF,MAAM,oBAAoB,GAAG,CAC3B,KAAmE,EACnE,EAAE;QACF,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YAClB,OAAO,KAAC,eAAe,OAAK,KAAK,GAAI,CAAC;QACxC,CAAC;QAED,OAAO,CACL,8BACE,0BAAQ,4EAA4E,GAAS,EAC7F,KAAC,sBAAsB,OAAK,KAAK,GAAI,IACpC,CACJ,CAAC;IACJ,CAAC,CAAC;IAEF,oBAAoB,CAAC,WAAW,GAAG,sBAAsB,CAAC;IAC1D,OAAO,oBAAoB,CAAC;AAC9B,CAAC","sourcesContent":["import {useCallback, useState} from 'react';\nimport {\n Icons,\n MapControlButton,\n MapControlPanelFactory,\n MapControlTooltipFactory,\n MapLegendFactory,\n MapLegendPanelFactory,\n MapLegendPanelProps,\n} from '@kepler.gl/components';\n\nCustomMapLegendPanelFactory.deps = MapLegendPanelFactory.deps;\n\nexport function CustomMapLegendPanelFactory(\n MapControlTooltip: ReturnType<typeof MapControlTooltipFactory>,\n MapControlPanel: ReturnType<typeof MapControlPanelFactory>,\n MapLegend: ReturnType<typeof MapLegendFactory>,\n): ReturnType<typeof MapLegendPanelFactory> {\n const OriginalMapLegendPanel = MapLegendPanelFactory(\n MapControlTooltip,\n MapControlPanel,\n MapLegend,\n );\n\n const SplitPaneLegend = (\n props: MapLegendPanelProps & {mapIndex?: number},\n ) => {\n const [isActive, setIsActive] = useState(false);\n const mapLegend = props.mapControls?.mapLegend;\n\n const toggleLegend = useCallback((e?: React.MouseEvent) => {\n e?.preventDefault();\n setIsActive((prev) => !prev);\n }, []);\n\n if (!mapLegend?.show) return null;\n\n return isActive ? (\n <>\n <style>{`.split-legend .map-control__panel-header { display: none !important; }`}</style>\n <div className=\"split-legend\">\n <MapControlPanel\n scale={props.scale}\n header=\"header.layerLegend\"\n onClick={toggleLegend}\n pinnable={false}\n disableClose={false}\n isExport={props.isExport}\n logoComponent={props.logoComponent}\n >\n <MapLegend\n layers={props.layers}\n mapState={props.mapState}\n disableEdit={mapLegend.disableEdit}\n isExport={props.isExport}\n onLayerVisConfigChange={props.onLayerVisConfigChange}\n onToggleLayerVisibility={props.onToggleLayerVisibility}\n {...({onClose: toggleLegend} as any)}\n />\n </MapControlPanel>\n </div>\n </>\n ) : (\n <MapControlTooltip id=\"show-legend\" message=\"tooltip.showLegend\">\n <MapControlButton\n className=\"map-control-button show-legend\"\n onClick={toggleLegend}\n >\n <Icons.Legend height=\"22px\" />\n </MapControlButton>\n </MapControlTooltip>\n );\n };\n\n const CustomMapLegendPanel = (\n props: MapLegendPanelProps & {mapIndex?: number; isSplit?: boolean},\n ) => {\n if (props.isSplit) {\n return <SplitPaneLegend {...props} />;\n }\n\n return (\n <>\n <style>{`.draggable-legend .map-control__panel-header { display: none !important; }`}</style>\n <OriginalMapLegendPanel {...props} />\n </>\n );\n };\n\n CustomMapLegendPanel.displayName = 'CustomMapLegendPanel';\n return CustomMapLegendPanel;\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { UseDisclosureReturnValue } from '@sqlrooms/ui';
|
|
2
|
-
import type { KeplerS3BrowserProps } from './KeplerS3Browser';
|
|
3
2
|
export type LoadTileSet = (args: {
|
|
4
3
|
tileset: {
|
|
5
4
|
name: string;
|
|
@@ -19,6 +18,6 @@ export type KeplerAddDataDialogProps = {
|
|
|
19
18
|
loadFiles: (files: FileList | string[]) => Promise<void>;
|
|
20
19
|
method?: AddDataMethods;
|
|
21
20
|
acceptedFormats?: string[];
|
|
22
|
-
}
|
|
23
|
-
export declare const KeplerAddDataDialog: ({ addDataModal, loadTileSet, loadFiles,
|
|
21
|
+
};
|
|
22
|
+
export declare const KeplerAddDataDialog: ({ addDataModal, loadTileSet, loadFiles, method, acceptedFormats, }: KeplerAddDataDialogProps) => import("react/jsx-runtime").JSX.Element;
|
|
24
23
|
//# sourceMappingURL=KeplerAddDataDialog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeplerAddDataDialog.d.ts","sourceRoot":"","sources":["../../src/components/KeplerAddDataDialog.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"KeplerAddDataDialog.d.ts","sourceRoot":"","sources":["../../src/components/KeplerAddDataDialog.tsx"],"names":[],"mappings":"AAGA,OAAO,EAUL,wBAAwB,EACzB,MAAM,cAAc,CAAC;AAmBtB,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE;IAC/B,OAAO,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAC,CAAC;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC,KAAK,IAAI,CAAC;AA+BX,oBAAY,cAAc;IACxB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,EAAE,OAAO;CACV;AAgBD,MAAM,MAAM,wBAAwB,GAAG;IACrC,YAAY,EAAE,IAAI,CAAC,wBAAwB,EAAE,QAAQ,GAAG,SAAS,CAAC,CAAC;IACnE,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,EAAE,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,oEAYjC,wBAAwB,4CAkG1B,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useMemo, useState } from 'react';
|
|
3
|
+
import { Icons, LoadTileSetFactory } from '@kepler.gl/components';
|
|
3
4
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, Tabs, TabsContent, TabsList, TabsTrigger, } from '@sqlrooms/ui';
|
|
4
|
-
import { LoadTileSetFactory, Icons } from '@kepler.gl/components';
|
|
5
5
|
import { FileDropInput } from './FileDropInput';
|
|
6
6
|
import { getKeplerFactory } from './KeplerInjector';
|
|
7
7
|
import { KeplerProvider } from './KeplerProvider';
|
|
8
|
-
import {
|
|
8
|
+
// import type {KeplerS3BrowserProps} from './KeplerS3Browser';
|
|
9
9
|
import { useIntl } from 'react-intl';
|
|
10
10
|
const DEFAULT_ACCEPTED_FORMATS = [
|
|
11
11
|
'csv',
|
|
@@ -46,16 +46,26 @@ const ADD_DATA_METHODS = [
|
|
|
46
46
|
// value: AddDataMethods.S3,
|
|
47
47
|
// },
|
|
48
48
|
];
|
|
49
|
-
export const KeplerAddDataDialog = ({ addDataModal, loadTileSet, loadFiles,
|
|
49
|
+
export const KeplerAddDataDialog = ({ addDataModal, loadTileSet, loadFiles,
|
|
50
|
+
// listS3Files,
|
|
51
|
+
// loadS3Files,
|
|
52
|
+
// saveS3Credentials,
|
|
53
|
+
// loadS3Credentials,
|
|
54
|
+
// deleteS3Credentials,
|
|
55
|
+
// s3Browser,
|
|
56
|
+
method = AddDataMethods.Upload, acceptedFormats = DEFAULT_ACCEPTED_FORMATS, }) => {
|
|
50
57
|
const [currentMethod, selectCurrentMethod] = useState(method);
|
|
51
58
|
const onFileDrop = useCallback((files) => {
|
|
52
59
|
loadFiles(files);
|
|
53
60
|
addDataModal.onClose();
|
|
54
61
|
}, [loadFiles, addDataModal]);
|
|
55
|
-
const onLoadS3Files = useCallback(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
// const onLoadS3Files = useCallback(
|
|
63
|
+
// async (...args: Parameters<KeplerS3BrowserProps['loadS3Files']>) => {
|
|
64
|
+
// await loadS3Files(...args);
|
|
65
|
+
// addDataModal.onClose();
|
|
66
|
+
// },
|
|
67
|
+
// [loadS3Files, addDataModal],
|
|
68
|
+
// );
|
|
69
|
+
return (_jsx(KeplerProvider, { mapId: '', children: _jsx(Dialog, { open: addDataModal.isOpen, onOpenChange: (isOpen) => !isOpen && addDataModal.onClose(), children: _jsxs(DialogContent, { className: "h-[80vh] max-w-4xl min-w-md grid-rows-[auto_1fr]", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Add Data" }), _jsx(DialogDescription, { children: "Add data to the project." })] }), _jsxs(Tabs, { defaultValue: currentMethod, className: "flex h-full w-full flex-col gap-4 overflow-auto", onValueChange: (value) => selectCurrentMethod(value), children: [_jsx(TabsList, { className: "flex h-10 items-center justify-start gap-1", children: ADD_DATA_METHODS.map(({ value, label }) => (_jsx(TabsTrigger, { value: value, className: "flex items-center gap-2", children: _jsx("span", { className: "text-muted-foreground", children: label }) }, value))) }), _jsx(TabsContent, { value: AddDataMethods.Upload, className: "h-full w-full data-[state=inactive]:hidden", children: _jsx("div", { className: "h-min-[200px] flex h-full w-full items-center justify-center", children: _jsx(FileDropInput, { onFileDrop: onFileDrop, children: acceptedFormats ? (_jsx("div", { className: "text-muted-foreground flex flex-wrap justify-center gap-2 opacity-80", children: acceptedFormats.map((ext) => (_jsx(Icons.FileType, { ext: ext, height: "50px", fontSize: "9px" }, ext))) })) : null }) }) }), _jsx(TabsContent, { value: AddDataMethods.TileSet, className: "h-full w-full overflow-auto data-[state=inactive]:hidden", children: _jsx(LoadTileSetContent, { loadTileSet: loadTileSet, onClose: addDataModal.onClose }) })] })] }) }) }));
|
|
60
70
|
};
|
|
61
71
|
//# sourceMappingURL=KeplerAddDataDialog.js.map
|