@sqlrooms/kepler 0.29.0-rc.1 → 0.29.0-rc.11

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.
Files changed (90) hide show
  1. package/LICENSE.md +2 -1
  2. package/README.md +133 -6
  3. package/dist/KeplerSlice.d.ts +85 -11
  4. package/dist/KeplerSlice.d.ts.map +1 -1
  5. package/dist/KeplerSlice.js +391 -123
  6. package/dist/KeplerSlice.js.map +1 -1
  7. package/dist/components/CustomDndContext.d.ts.map +1 -1
  8. package/dist/components/CustomDndContext.js +5 -2
  9. package/dist/components/CustomDndContext.js.map +1 -1
  10. package/dist/components/CustomFilterManager.d.ts.map +1 -1
  11. package/dist/components/CustomFilterManager.js +20 -5
  12. package/dist/components/CustomFilterManager.js.map +1 -1
  13. package/dist/components/CustomFilterPanelHeader.d.ts.map +1 -1
  14. package/dist/components/CustomFilterPanelHeader.js +5 -5
  15. package/dist/components/CustomFilterPanelHeader.js.map +1 -1
  16. package/dist/components/CustomInteractionManager.d.ts.map +1 -1
  17. package/dist/components/CustomInteractionManager.js +4 -1
  18. package/dist/components/CustomInteractionManager.js.map +1 -1
  19. package/dist/components/CustomLayerManager.d.ts.map +1 -1
  20. package/dist/components/CustomLayerManager.js +51 -17
  21. package/dist/components/CustomLayerManager.js.map +1 -1
  22. package/dist/components/CustomMapDrawPanel.d.ts +8 -0
  23. package/dist/components/CustomMapDrawPanel.d.ts.map +1 -0
  24. package/dist/components/CustomMapDrawPanel.js +28 -0
  25. package/dist/components/CustomMapDrawPanel.js.map +1 -0
  26. package/dist/components/CustomMapLegend.d.ts +4 -1
  27. package/dist/components/CustomMapLegend.d.ts.map +1 -1
  28. package/dist/components/CustomMapLegend.js +39 -12
  29. package/dist/components/CustomMapLegend.js.map +1 -1
  30. package/dist/components/CustomMapLegendPanel.d.ts +3 -3
  31. package/dist/components/CustomMapLegendPanel.d.ts.map +1 -1
  32. package/dist/components/CustomMapLegendPanel.js +27 -4
  33. package/dist/components/CustomMapLegendPanel.js.map +1 -1
  34. package/dist/components/CustomSourceDataSelector.d.ts +18 -0
  35. package/dist/components/CustomSourceDataSelector.d.ts.map +1 -0
  36. package/dist/components/CustomSourceDataSelector.js +130 -0
  37. package/dist/components/CustomSourceDataSelector.js.map +1 -0
  38. package/dist/components/KeplerAddDataDialog.d.ts +2 -3
  39. package/dist/components/KeplerAddDataDialog.d.ts.map +1 -1
  40. package/dist/components/KeplerAddDataDialog.js +19 -8
  41. package/dist/components/KeplerAddDataDialog.js.map +1 -1
  42. package/dist/components/KeplerImageExport.d.ts.map +1 -1
  43. package/dist/components/KeplerImageExport.js +26 -8
  44. package/dist/components/KeplerImageExport.js.map +1 -1
  45. package/dist/components/KeplerInjector.d.ts.map +1 -1
  46. package/dist/components/KeplerInjector.js +5 -1
  47. package/dist/components/KeplerInjector.js.map +1 -1
  48. package/dist/components/KeplerMapContainer.d.ts.map +1 -1
  49. package/dist/components/KeplerMapContainer.js +45 -6
  50. package/dist/components/KeplerMapContainer.js.map +1 -1
  51. package/dist/components/KeplerPlotContainer.d.ts +1 -1
  52. package/dist/components/KeplerPlotContainer.d.ts.map +1 -1
  53. package/dist/components/KeplerPlotContainer.js +3 -1
  54. package/dist/components/KeplerPlotContainer.js.map +1 -1
  55. package/dist/components/KeplerProvider.d.ts.map +1 -1
  56. package/dist/components/KeplerProvider.js +3 -1
  57. package/dist/components/KeplerProvider.js.map +1 -1
  58. package/dist/components/KeplerTableSourceSelector.d.ts +20 -0
  59. package/dist/components/KeplerTableSourceSelector.d.ts.map +1 -0
  60. package/dist/components/KeplerTableSourceSelector.js +21 -0
  61. package/dist/components/KeplerTableSourceSelector.js.map +1 -0
  62. package/dist/components/SplitMapIndexContext.d.ts +2 -0
  63. package/dist/components/SplitMapIndexContext.d.ts.map +1 -0
  64. package/dist/components/SplitMapIndexContext.js +3 -0
  65. package/dist/components/SplitMapIndexContext.js.map +1 -0
  66. package/dist/hooks/useDndEffects.d.ts +1 -1
  67. package/dist/hooks/useDndEffects.d.ts.map +1 -1
  68. package/dist/hooks/useDndEffects.js +4 -0
  69. package/dist/hooks/useDndEffects.js.map +1 -1
  70. package/dist/hooks/useDndLayers.d.ts +1 -1
  71. package/dist/hooks/useDndLayers.d.ts.map +1 -1
  72. package/dist/hooks/useDndLayers.js +4 -0
  73. package/dist/hooks/useDndLayers.js.map +1 -1
  74. package/dist/hooks/useKeplerStateActions.d.ts +7 -6
  75. package/dist/hooks/useKeplerStateActions.d.ts.map +1 -1
  76. package/dist/hooks/useKeplerStateActions.js +1 -1
  77. package/dist/hooks/useKeplerStateActions.js.map +1 -1
  78. package/dist/index.d.ts +10 -3
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +5 -2
  81. package/dist/index.js.map +1 -1
  82. package/dist/keplerTableSelection.d.ts +142 -0
  83. package/dist/keplerTableSelection.d.ts.map +1 -0
  84. package/dist/keplerTableSelection.js +232 -0
  85. package/dist/keplerTableSelection.js.map +1 -0
  86. package/dist/styles/theme.d.ts +12 -0
  87. package/dist/styles/theme.d.ts.map +1 -1
  88. package/dist/styles/theme.js +12 -0
  89. package/dist/styles/theme.js.map +1 -1
  90. package/package.json +43 -37
@@ -0,0 +1,130 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { PanelLabel, SidePanelSection, SourceDataSelectorFactory, } from '@kepler.gl/components';
3
+ import { FormattedMessage } from '@kepler.gl/localization';
4
+ import { Button, cn } from '@sqlrooms/ui';
5
+ import { useCallback, useMemo, useState } from 'react';
6
+ import { useStoreWithKepler } from '../KeplerSlice';
7
+ import { buildKeplerTableSourceOptions, } from '../keplerTableSelection';
8
+ import { KeplerTableSourceSelector } from './KeplerTableSourceSelector';
9
+ function getSelectedDatasetId(value) {
10
+ if (value === null) {
11
+ return undefined;
12
+ }
13
+ if (Array.isArray(value)) {
14
+ if (value.length === 0) {
15
+ return undefined;
16
+ }
17
+ return getSelectedDatasetId(value[0]);
18
+ }
19
+ if (typeof value === 'string') {
20
+ return value;
21
+ }
22
+ if (typeof value === 'number') {
23
+ return String(value);
24
+ }
25
+ if (typeof value === 'boolean') {
26
+ return String(value);
27
+ }
28
+ if (typeof value === 'object') {
29
+ const option = value;
30
+ if (typeof option.value === 'string') {
31
+ return option.value;
32
+ }
33
+ if (typeof option.id === 'string') {
34
+ return option.id;
35
+ }
36
+ }
37
+ return undefined;
38
+ }
39
+ /**
40
+ * Kepler uses the same SourceDataSelector in layer config and filter config.
41
+ * Layer config passes a layer id, so only that version includes unloaded
42
+ * SQLRooms table options. Filter selectors use the same UI with loaded Kepler
43
+ * datasets only because a filter needs a loaded dataset to expose fields.
44
+ */
45
+ export function CustomSourceDataSelectorFactory(_DataSourceSelectorContent) {
46
+ const SourceDataSelector = ({ dataId, datasets, disabled, onSelect, defaultValue = 'Select A Dataset', className, id: layerId, }) => {
47
+ const [isLoadingTable, setIsLoadingTable] = useState(false);
48
+ const dbTables = useStoreWithKepler((state) => state.db.tables);
49
+ const tableSelection = useStoreWithKepler((state) => state.kepler.tableSelection);
50
+ const addTableToMap = useStoreWithKepler((state) => state.kepler.addTableToMap);
51
+ const keplerMap = useStoreWithKepler((state) => state.kepler.map);
52
+ const mapId = useMemo(() => {
53
+ if (!layerId) {
54
+ return undefined;
55
+ }
56
+ for (const [candidateMapId, mapState] of Object.entries(keplerMap)) {
57
+ const hasLayer = mapState?.visState?.layers?.some((layer) => layer.id === layerId);
58
+ if (hasLayer) {
59
+ return candidateMapId;
60
+ }
61
+ }
62
+ return undefined;
63
+ }, [keplerMap, layerId]);
64
+ const mapDatasets = useMemo(() => {
65
+ if (!mapId) {
66
+ return undefined;
67
+ }
68
+ return keplerMap[mapId]?.visState.datasets;
69
+ }, [keplerMap, mapId]);
70
+ const loadedDatasetIds = useMemo(() => Object.keys(mapDatasets ?? datasets), [datasets, mapDatasets]);
71
+ const options = useMemo(() => {
72
+ return buildKeplerTableSourceOptions({
73
+ dbTables,
74
+ datasets,
75
+ includeUnloadedTables: Boolean(layerId && mapId),
76
+ loadedDatasetIds,
77
+ tableSelection,
78
+ });
79
+ }, [datasets, dbTables, layerId, loadedDatasetIds, mapId, tableSelection]);
80
+ const handleSelect = useCallback((option) => {
81
+ if (!layerId || !mapId) {
82
+ onSelect(option.value);
83
+ return;
84
+ }
85
+ if (option.isLoaded) {
86
+ onSelect(option.value);
87
+ return;
88
+ }
89
+ setIsLoadingTable(true);
90
+ void addTableToMap({
91
+ mapId,
92
+ tableName: option.value,
93
+ options: {
94
+ autoCreateLayers: false,
95
+ centerMap: false,
96
+ },
97
+ })
98
+ .then(() => {
99
+ onSelect(option.value);
100
+ })
101
+ .catch((e) => {
102
+ console.error('Failed to load layer data source:', e);
103
+ })
104
+ .finally(() => {
105
+ setIsLoadingTable(false);
106
+ });
107
+ }, [addTableToMap, layerId, mapId, onSelect]);
108
+ const selectedValue = getSelectedDatasetId(dataId);
109
+ const selectedDataset = selectedValue ? datasets[selectedValue] : undefined;
110
+ const selectedOption = options.find((option) => option.value === selectedValue);
111
+ const selectedLabel = selectedOption?.label ??
112
+ selectedDataset?.label ??
113
+ selectedValue ??
114
+ defaultValue;
115
+ const selectedColor = selectedOption?.color ??
116
+ selectedDataset?.color ?? [143, 149, 161];
117
+ const isDisabled = Boolean(disabled || isLoadingTable || !options.length);
118
+ return (_jsxs(SidePanelSection, { className: "data-source-selector", children: [_jsx(PanelLabel, { children: _jsx(FormattedMessage, { id: "misc.dataSource" }) }), _jsx(KeplerTableSourceSelector, { disabled: isDisabled, options: options, popoverClassName: "w-[360px]", searchPlaceholder: "Search", selectedValue: selectedValue, onSelect: handleSelect, renderTrigger: ({ disabled: triggerDisabled, selectedOption }) => {
119
+ const triggerColor = selectedOption?.color ?? selectedColor;
120
+ const triggerLabel = selectedOption?.label ?? selectedLabel;
121
+ return (_jsxs(Button, { type: "button", variant: "secondary", className: cn(className, 'h-9 w-full justify-start gap-2.5 rounded-sm px-3 text-left text-xs font-semibold'), disabled: triggerDisabled, children: [_jsx("span", { className: "h-2.5 w-2.5 shrink-0", style: {
122
+ backgroundColor: `rgb(${triggerColor.join(',')})`,
123
+ } }), _jsx("span", { className: "min-w-0 truncate", children: triggerLabel })] }));
124
+ } })] }));
125
+ };
126
+ SourceDataSelector.displayName = 'CustomSourceDataSelector';
127
+ return SourceDataSelector;
128
+ }
129
+ CustomSourceDataSelectorFactory.deps = SourceDataSelectorFactory.deps;
130
+ //# sourceMappingURL=CustomSourceDataSelector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomSourceDataSelector.js","sourceRoot":"","sources":["../../src/components/CustomSourceDataSelector.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,yBAAyB,GAE1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAC,gBAAgB,EAAC,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAC,MAAM,EAAE,EAAE,EAAC,MAAM,cAAc,CAAC;AACxC,OAAc,EAAC,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAClD,OAAO,EACL,6BAA6B,GAE9B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAC,yBAAyB,EAAC,MAAM,6BAA6B,CAAC;AAUtE,SAAS,oBAAoB,CAC3B,KAA8B;IAE9B,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAA4B,CAAC,CAAC;IACnE,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CA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IACjD,CACV,CAAC;oBACJ,CAAC,GACD,IACe,CACpB,CAAC;IACJ,CAAC,CAAC;IAEF,kBAAkB,CAAC,WAAW,GAAG,0BAA0B,CAAC;IAC5D,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAED,+BAA+B,CAAC,IAAI,GAAG,yBAAyB,CAAC,IAAI,CAAC","sourcesContent":["import {\n PanelLabel,\n SidePanelSection,\n SourceDataSelectorFactory,\n SourceDataSelectorProps,\n} from '@kepler.gl/components';\nimport {FormattedMessage} from '@kepler.gl/localization';\nimport {Button, cn} from '@sqlrooms/ui';\nimport React, {useCallback, useMemo, useState} from 'react';\nimport {useStoreWithKepler} from '../KeplerSlice';\nimport {\n buildKeplerTableSourceOptions,\n type KeplerTableSourceOption,\n} from '../keplerTableSelection';\nimport {KeplerTableSourceSelector} from './KeplerTableSourceSelector';\n\ntype SourceDataSelectorValue = Parameters<\n SourceDataSelectorProps['onSelect']\n>[0];\ntype SourceDataSelectorContent = React.ComponentType<SourceDataSelectorProps>;\ntype CustomSourceDataSelectorProps = SourceDataSelectorProps & {\n id?: string;\n};\n\nfunction getSelectedDatasetId(\n value: SourceDataSelectorValue,\n): string | undefined {\n if (value === null) {\n return undefined;\n }\n\n if (Array.isArray(value)) {\n if (value.length === 0) {\n return undefined;\n }\n return getSelectedDatasetId(value[0] as SourceDataSelectorValue);\n }\n\n if (typeof value === 'string') {\n return value;\n }\n\n if (typeof value === 'number') {\n return String(value);\n }\n\n if (typeof value === 'boolean') {\n return String(value);\n }\n\n if (typeof value === 'object') {\n const option = value as {id?: unknown; value?: unknown};\n if (typeof option.value === 'string') {\n return option.value;\n }\n if (typeof option.id === 'string') {\n return option.id;\n }\n }\n\n return undefined;\n}\n\n/**\n * Kepler uses the same SourceDataSelector in layer config and filter config.\n * Layer config passes a layer id, so only that version includes unloaded\n * SQLRooms table options. Filter selectors use the same UI with loaded Kepler\n * datasets only because a filter needs a loaded dataset to expose fields.\n */\nexport function CustomSourceDataSelectorFactory(\n _DataSourceSelectorContent: SourceDataSelectorContent,\n): React.FC<CustomSourceDataSelectorProps> {\n const SourceDataSelector: React.FC<CustomSourceDataSelectorProps> = ({\n dataId,\n datasets,\n disabled,\n onSelect,\n defaultValue = 'Select A Dataset',\n className,\n id: layerId,\n }) => {\n const [isLoadingTable, setIsLoadingTable] = useState(false);\n const dbTables = useStoreWithKepler((state) => state.db.tables);\n const tableSelection = useStoreWithKepler(\n (state) => state.kepler.tableSelection,\n );\n const addTableToMap = useStoreWithKepler(\n (state) => state.kepler.addTableToMap,\n );\n const keplerMap = useStoreWithKepler((state) => state.kepler.map);\n const mapId = useMemo(() => {\n if (!layerId) {\n return undefined;\n }\n\n for (const [candidateMapId, mapState] of Object.entries(keplerMap)) {\n const hasLayer = mapState?.visState?.layers?.some(\n (layer: {id?: string}) => layer.id === layerId,\n );\n if (hasLayer) {\n return candidateMapId;\n }\n }\n\n return undefined;\n }, [keplerMap, layerId]);\n const mapDatasets = useMemo(() => {\n if (!mapId) {\n return undefined;\n }\n\n return keplerMap[mapId]?.visState.datasets;\n }, [keplerMap, mapId]);\n const loadedDatasetIds = useMemo(\n () => Object.keys(mapDatasets ?? datasets),\n [datasets, mapDatasets],\n );\n\n const options = useMemo(() => {\n return buildKeplerTableSourceOptions({\n dbTables,\n datasets,\n includeUnloadedTables: Boolean(layerId && mapId),\n loadedDatasetIds,\n tableSelection,\n });\n }, [datasets, dbTables, layerId, loadedDatasetIds, mapId, tableSelection]);\n\n const handleSelect = useCallback(\n (option: KeplerTableSourceOption) => {\n if (!layerId || !mapId) {\n onSelect(option.value);\n return;\n }\n\n if (option.isLoaded) {\n onSelect(option.value);\n return;\n }\n\n setIsLoadingTable(true);\n void addTableToMap({\n mapId,\n tableName: option.value,\n options: {\n autoCreateLayers: false,\n centerMap: false,\n },\n })\n .then(() => {\n onSelect(option.value);\n })\n .catch((e) => {\n console.error('Failed to load layer data source:', e);\n })\n .finally(() => {\n setIsLoadingTable(false);\n });\n },\n [addTableToMap, layerId, mapId, onSelect],\n );\n\n const selectedValue = getSelectedDatasetId(dataId);\n const selectedDataset = selectedValue ? datasets[selectedValue] : undefined;\n const selectedOption = options.find(\n (option) => option.value === selectedValue,\n );\n const selectedLabel =\n selectedOption?.label ??\n selectedDataset?.label ??\n selectedValue ??\n defaultValue;\n const selectedColor = selectedOption?.color ??\n selectedDataset?.color ?? [143, 149, 161];\n const isDisabled = Boolean(disabled || isLoadingTable || !options.length);\n\n return (\n <SidePanelSection className=\"data-source-selector\">\n <PanelLabel>\n <FormattedMessage id=\"misc.dataSource\" />\n </PanelLabel>\n <KeplerTableSourceSelector\n disabled={isDisabled}\n options={options}\n popoverClassName=\"w-[360px]\"\n searchPlaceholder=\"Search\"\n selectedValue={selectedValue}\n onSelect={handleSelect}\n renderTrigger={({disabled: triggerDisabled, selectedOption}) => {\n const triggerColor = selectedOption?.color ?? selectedColor;\n const triggerLabel = selectedOption?.label ?? selectedLabel;\n\n return (\n <Button\n type=\"button\"\n variant=\"secondary\"\n className={cn(\n className,\n 'h-9 w-full justify-start gap-2.5 rounded-sm px-3 text-left text-xs font-semibold',\n )}\n disabled={triggerDisabled}\n >\n <span\n className=\"h-2.5 w-2.5 shrink-0\"\n style={{\n backgroundColor: `rgb(${triggerColor.join(',')})`,\n }}\n />\n <span className=\"min-w-0 truncate\">{triggerLabel}</span>\n </Button>\n );\n }}\n />\n </SidePanelSection>\n );\n };\n\n SourceDataSelector.displayName = 'CustomSourceDataSelector';\n return SourceDataSelector;\n}\n\nCustomSourceDataSelectorFactory.deps = SourceDataSelectorFactory.deps;\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
- } & KeplerS3BrowserProps;
23
- export declare const KeplerAddDataDialog: ({ addDataModal, loadTileSet, loadFiles, listS3Files, loadS3Files, saveS3Credentials, loadS3Credentials, deleteS3Credentials, s3Browser, method, acceptedFormats, }: KeplerAddDataDialogProps) => import("react/jsx-runtime").JSX.Element;
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":"AAEA,OAAO,EAML,wBAAwB,EAKzB,MAAM,cAAc,CAAC;AAMtB,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,mBAAmB,CAAC;AAe5D,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,GAAG,oBAAoB,CAAC;AAEzB,eAAO,MAAM,mBAAmB,GAAI,oKAYjC,wBAAwB,4CAkG1B,CAAC"}
1
+ {"version":3,"file":"KeplerAddDataDialog.d.ts","sourceRoot":"","sources":["../../src/components/KeplerAddDataDialog.tsx"],"names":[],"mappings":"AAGA,OAAO,EAUL,wBAAwB,EACzB,MAAM,cAAc,CAAC;AAoBtB,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,17 +1,18 @@
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 { KeplerS3Browser } from './KeplerS3Browser';
8
+ // import type {KeplerS3BrowserProps} from './KeplerS3Browser';
9
9
  import { useIntl } from 'react-intl';
10
10
  const DEFAULT_ACCEPTED_FORMATS = [
11
11
  'csv',
12
12
  'tsv',
13
13
  'parquet',
14
14
  'json',
15
+ 'geojson',
15
16
  'arrow',
16
17
  'shp',
17
18
  'kml',
@@ -46,16 +47,26 @@ const ADD_DATA_METHODS = [
46
47
  // value: AddDataMethods.S3,
47
48
  // },
48
49
  ];
49
- export const KeplerAddDataDialog = ({ addDataModal, loadTileSet, loadFiles, listS3Files, loadS3Files, saveS3Credentials, loadS3Credentials, deleteS3Credentials, s3Browser, method = AddDataMethods.Upload, acceptedFormats = DEFAULT_ACCEPTED_FORMATS, }) => {
50
+ export const KeplerAddDataDialog = ({ addDataModal, loadTileSet, loadFiles,
51
+ // listS3Files,
52
+ // loadS3Files,
53
+ // saveS3Credentials,
54
+ // loadS3Credentials,
55
+ // deleteS3Credentials,
56
+ // s3Browser,
57
+ method = AddDataMethods.Upload, acceptedFormats = DEFAULT_ACCEPTED_FORMATS, }) => {
50
58
  const [currentMethod, selectCurrentMethod] = useState(method);
51
59
  const onFileDrop = useCallback((files) => {
52
60
  loadFiles(files);
53
61
  addDataModal.onClose();
54
62
  }, [loadFiles, addDataModal]);
55
- const onLoadS3Files = useCallback(async (...args) => {
56
- await loadS3Files(...args);
57
- addDataModal.onClose();
58
- }, [loadS3Files, addDataModal]);
59
- 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 }) }), _jsx(TabsContent, { value: AddDataMethods.S3, className: "h-full w-full data-[state=inactive]:hidden", children: _jsx(KeplerS3Browser, { listS3Files: listS3Files, s3Browser: s3Browser, loadS3Files: onLoadS3Files, saveS3Credentials: saveS3Credentials, loadS3Credentials: loadS3Credentials, deleteS3Credentials: deleteS3Credentials }) })] })] }) }) }));
63
+ // const onLoadS3Files = useCallback(
64
+ // async (...args: Parameters<KeplerS3BrowserProps['loadS3Files']>) => {
65
+ // await loadS3Files(...args);
66
+ // addDataModal.onClose();
67
+ // },
68
+ // [loadS3Files, addDataModal],
69
+ // );
70
+ 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
71
  };
61
72
  //# sourceMappingURL=KeplerAddDataDialog.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KeplerAddDataDialog.js","sourceRoot":"","sources":["../../src/components/KeplerAddDataDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAErD,OAAO,EACL,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,WAAW,EAEX,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,kBAAkB,EAAE,KAAK,EAAC,MAAM,uBAAuB,CAAC;AAChE,OAAO,EA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iBAAiB,EACpC,iBAAiB,EAAE,iBAAiB,EACpC,mBAAmB,EAAE,mBAAmB,GACxC,GACU,IACT,IACO,GACT,GACM,CAClB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {useCallback, useMemo, useState} from 'react';\n\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogHeader,\n DialogTitle,\n UseDisclosureReturnValue,\n Tabs,\n TabsContent,\n TabsList,\n TabsTrigger,\n} from '@sqlrooms/ui';\nimport {LoadTileSetFactory, Icons} from '@kepler.gl/components';\nimport {FileDropInput} from './FileDropInput';\nimport {getKeplerFactory} from './KeplerInjector';\nimport {KeplerProvider} from './KeplerProvider';\nimport {KeplerS3Browser} from './KeplerS3Browser';\nimport type {KeplerS3BrowserProps} from './KeplerS3Browser';\nimport {useIntl} from 'react-intl';\n\nconst DEFAULT_ACCEPTED_FORMATS = [\n 'csv',\n 'tsv',\n 'parquet',\n 'json',\n 'arrow',\n 'shp',\n 'kml',\n];\n\nconst LoadTileSet = getKeplerFactory(LoadTileSetFactory);\n\nexport type LoadTileSet = (args: {\n tileset: {name: string; type: string; metadata: Record<string, any>};\n metadata?: Record<string, any>;\n}) => void;\n\nfunction LoadTileSetContent({\n loadTileSet,\n onClose,\n}: {\n loadTileSet: LoadTileSet;\n onClose?: () => void;\n}) {\n const intl = useIntl();\n const onTilesetAdded = useCallback(\n (\n tileset: {name: string; type: string; metadata: Record<string, any>},\n metadata?: Record<string, any>,\n ) => {\n loadTileSet({tileset, metadata});\n onClose?.();\n },\n [loadTileSet, onClose],\n );\n const meta = useMemo(() => ({}), []); // TODO: add metadata\n return (\n <LoadTileSet\n meta={meta}\n isAddingDatasets={false}\n intl={intl}\n onTilesetAdded={onTilesetAdded}\n />\n );\n}\n\nexport enum AddDataMethods {\n Upload = 'upload',\n TileSet = 'tileset',\n S3 = 's3',\n}\nconst ADD_DATA_METHODS = [\n {\n label: 'Local File',\n value: AddDataMethods.Upload,\n },\n {\n label: 'Tiles',\n value: AddDataMethods.TileSet,\n },\n // {\n // label: 'S3',\n // value: AddDataMethods.S3,\n // },\n];\n\nexport type KeplerAddDataDialogProps = {\n addDataModal: Pick<UseDisclosureReturnValue, 'isOpen' | 'onClose'>;\n loadTileSet: LoadTileSet;\n loadFiles: (files: FileList | string[]) => Promise<void>;\n method?: AddDataMethods;\n acceptedFormats?: string[];\n} & KeplerS3BrowserProps;\n\nexport const KeplerAddDataDialog = ({\n addDataModal,\n loadTileSet,\n loadFiles,\n listS3Files,\n loadS3Files,\n saveS3Credentials,\n loadS3Credentials,\n deleteS3Credentials,\n s3Browser,\n method = AddDataMethods.Upload,\n acceptedFormats = DEFAULT_ACCEPTED_FORMATS,\n}: KeplerAddDataDialogProps) => {\n const [currentMethod, selectCurrentMethod] = useState<AddDataMethods>(method);\n const onFileDrop = useCallback(\n (files: FileList) => {\n loadFiles(files);\n addDataModal.onClose();\n },\n [loadFiles, addDataModal],\n );\n const onLoadS3Files = useCallback(\n async (...args: Parameters<KeplerS3BrowserProps['loadS3Files']>) => {\n await loadS3Files(...args);\n addDataModal.onClose();\n },\n [loadS3Files, addDataModal],\n );\n return (\n <KeplerProvider mapId={''}>\n <Dialog\n open={addDataModal.isOpen}\n onOpenChange={(isOpen: boolean) => !isOpen && addDataModal.onClose()}\n >\n <DialogContent className=\"h-[80vh] max-w-4xl min-w-md grid-rows-[auto_1fr]\">\n <DialogHeader>\n <DialogTitle>Add Data</DialogTitle>\n <DialogDescription>Add data to the project.</DialogDescription>\n </DialogHeader>\n <Tabs\n defaultValue={currentMethod}\n className=\"flex h-full w-full flex-col gap-4 overflow-auto\"\n onValueChange={(value) =>\n selectCurrentMethod(value as AddDataMethods)\n }\n >\n <TabsList className=\"flex h-10 items-center justify-start gap-1\">\n {ADD_DATA_METHODS.map(({value, label}) => (\n <TabsTrigger\n value={value}\n className=\"flex items-center gap-2\"\n key={value}\n >\n <span className=\"text-muted-foreground\">{label}</span>\n </TabsTrigger>\n ))}\n </TabsList>\n\n {/** File Upload */}\n <TabsContent\n value={AddDataMethods.Upload}\n className=\"h-full w-full data-[state=inactive]:hidden\"\n >\n <div className=\"h-min-[200px] flex h-full w-full items-center justify-center\">\n <FileDropInput onFileDrop={onFileDrop}>\n {acceptedFormats ? (\n <div className=\"text-muted-foreground flex flex-wrap justify-center gap-2 opacity-80\">\n {acceptedFormats.map((ext) => (\n <Icons.FileType\n key={ext}\n ext={ext}\n height=\"50px\"\n fontSize=\"9px\"\n />\n ))}\n </div>\n ) : null}\n </FileDropInput>\n </div>\n </TabsContent>\n\n {/** TileSet*/}\n <TabsContent\n value={AddDataMethods.TileSet}\n className=\"h-full w-full overflow-auto data-[state=inactive]:hidden\"\n >\n <LoadTileSetContent\n loadTileSet={loadTileSet}\n onClose={addDataModal.onClose}\n />\n </TabsContent>\n {/** S3 */}\n <TabsContent\n value={AddDataMethods.S3}\n className=\"h-full w-full data-[state=inactive]:hidden\"\n >\n <KeplerS3Browser\n listS3Files={listS3Files}\n s3Browser={s3Browser}\n loadS3Files={onLoadS3Files}\n saveS3Credentials={saveS3Credentials}\n loadS3Credentials={loadS3Credentials}\n deleteS3Credentials={deleteS3Credentials}\n />\n </TabsContent>\n </Tabs>\n </DialogContent>\n </Dialog>\n </KeplerProvider>\n );\n};\n"]}
1
+ {"version":3,"file":"KeplerAddDataDialog.js","sourceRoot":"","sources":["../../src/components/KeplerAddDataDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAErD,OAAO,EAAC,KAAK,EAAE,kBAAkB,EAAC,MAAM,uBAAuB,CAAC;AAChE,OAAO,EACL,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,WAAW,GAEZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,gBAAgB,EA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EAAE,KAAK,EAAC,EAAE,EAAE,CAAC,CACxC,KAAC,WAAW,IACV,KAAK,EAAE,KAAK,EACZ,SAAS,EAAC,yBAAyB,YAGnC,eAAM,SAAS,EAAC,uBAAuB,YAAE,KAAK,GAAQ,IAFjD,KAAK,CAGE,CACf,CAAC,GACO,EAGX,KAAC,WAAW,IACV,KAAK,EAAE,cAAc,CAAC,MAAM,EAC5B,SAAS,EAAC,4CAA4C,YAEtD,cAAK,SAAS,EAAC,8DAA8D,YAC3E,KAAC,aAAa,IAAC,UAAU,EAAE,UAAU,YAClC,eAAe,CAAC,CAAC,CAAC,CACjB,cAAK,SAAS,EAAC,sEAAsE,YAClF,eAAe,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAC5B,KAAC,KAAK,CAAC,QAAQ,IAEb,GAAG,EAAE,GAAG,EACR,MAAM,EAAC,MAAM,EACb,QAAQ,EAAC,KAAK,IAHT,GAAG,CAIR,CACH,CAAC,GACE,CACP,CAAC,CAAC,CAAC,IAAI,GACM,GACZ,GACM,EAGd,KAAC,WAAW,IACV,KAAK,EAAE,cAAc,CAAC,OAAO,EAC7B,SAAS,EAAC,0DAA0D,YAEpE,KAAC,kBAAkB,IACjB,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,YAAY,CAAC,OAAO,GAC7B,GACU,IAeT,IACO,GACT,GACM,CAClB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {useCallback, useMemo, useState} from 'react';\n\nimport {Icons, LoadTileSetFactory} from '@kepler.gl/components';\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogHeader,\n DialogTitle,\n Tabs,\n TabsContent,\n TabsList,\n TabsTrigger,\n UseDisclosureReturnValue,\n} from '@sqlrooms/ui';\nimport {FileDropInput} from './FileDropInput';\nimport {getKeplerFactory} from './KeplerInjector';\nimport {KeplerProvider} from './KeplerProvider';\n// import type {KeplerS3BrowserProps} from './KeplerS3Browser';\nimport {useIntl} from 'react-intl';\n\nconst DEFAULT_ACCEPTED_FORMATS = [\n 'csv',\n 'tsv',\n 'parquet',\n 'json',\n 'geojson',\n 'arrow',\n 'shp',\n 'kml',\n];\n\nconst LoadTileSet = getKeplerFactory(LoadTileSetFactory);\n\nexport type LoadTileSet = (args: {\n tileset: {name: string; type: string; metadata: Record<string, any>};\n metadata?: Record<string, any>;\n}) => void;\n\nfunction LoadTileSetContent({\n loadTileSet,\n onClose,\n}: {\n loadTileSet: LoadTileSet;\n onClose?: () => void;\n}) {\n const intl = useIntl();\n const onTilesetAdded = useCallback(\n (\n tileset: {name: string; type: string; metadata: Record<string, any>},\n metadata?: Record<string, any>,\n ) => {\n loadTileSet({tileset, metadata});\n onClose?.();\n },\n [loadTileSet, onClose],\n );\n const meta = useMemo(() => ({}), []); // TODO: add metadata\n return (\n <LoadTileSet\n meta={meta}\n isAddingDatasets={false}\n intl={intl}\n onTilesetAdded={onTilesetAdded}\n />\n );\n}\n\nexport enum AddDataMethods {\n Upload = 'upload',\n TileSet = 'tileset',\n S3 = 's3',\n}\nconst ADD_DATA_METHODS = [\n {\n label: 'Local File',\n value: AddDataMethods.Upload,\n },\n {\n label: 'Tiles',\n value: AddDataMethods.TileSet,\n },\n // {\n // label: 'S3',\n // value: AddDataMethods.S3,\n // },\n];\n\nexport type KeplerAddDataDialogProps = {\n addDataModal: Pick<UseDisclosureReturnValue, 'isOpen' | 'onClose'>;\n loadTileSet: LoadTileSet;\n loadFiles: (files: FileList | string[]) => Promise<void>;\n method?: AddDataMethods;\n acceptedFormats?: string[];\n}; //& KeplerS3BrowserProps;\n\nexport const KeplerAddDataDialog = ({\n addDataModal,\n loadTileSet,\n loadFiles,\n // listS3Files,\n // loadS3Files,\n // saveS3Credentials,\n // loadS3Credentials,\n // deleteS3Credentials,\n // s3Browser,\n method = AddDataMethods.Upload,\n acceptedFormats = DEFAULT_ACCEPTED_FORMATS,\n}: KeplerAddDataDialogProps) => {\n const [currentMethod, selectCurrentMethod] = useState<AddDataMethods>(method);\n const onFileDrop = useCallback(\n (files: FileList) => {\n loadFiles(files);\n addDataModal.onClose();\n },\n [loadFiles, addDataModal],\n );\n // const onLoadS3Files = useCallback(\n // async (...args: Parameters<KeplerS3BrowserProps['loadS3Files']>) => {\n // await loadS3Files(...args);\n // addDataModal.onClose();\n // },\n // [loadS3Files, addDataModal],\n // );\n return (\n <KeplerProvider mapId={''}>\n <Dialog\n open={addDataModal.isOpen}\n onOpenChange={(isOpen: boolean) => !isOpen && addDataModal.onClose()}\n >\n <DialogContent className=\"h-[80vh] max-w-4xl min-w-md grid-rows-[auto_1fr]\">\n <DialogHeader>\n <DialogTitle>Add Data</DialogTitle>\n <DialogDescription>Add data to the project.</DialogDescription>\n </DialogHeader>\n <Tabs\n defaultValue={currentMethod}\n className=\"flex h-full w-full flex-col gap-4 overflow-auto\"\n onValueChange={(value) =>\n selectCurrentMethod(value as AddDataMethods)\n }\n >\n <TabsList className=\"flex h-10 items-center justify-start gap-1\">\n {ADD_DATA_METHODS.map(({value, label}) => (\n <TabsTrigger\n value={value}\n className=\"flex items-center gap-2\"\n key={value}\n >\n <span className=\"text-muted-foreground\">{label}</span>\n </TabsTrigger>\n ))}\n </TabsList>\n\n {/** File Upload */}\n <TabsContent\n value={AddDataMethods.Upload}\n className=\"h-full w-full data-[state=inactive]:hidden\"\n >\n <div className=\"h-min-[200px] flex h-full w-full items-center justify-center\">\n <FileDropInput onFileDrop={onFileDrop}>\n {acceptedFormats ? (\n <div className=\"text-muted-foreground flex flex-wrap justify-center gap-2 opacity-80\">\n {acceptedFormats.map((ext) => (\n <Icons.FileType\n key={ext}\n ext={ext}\n height=\"50px\"\n fontSize=\"9px\"\n />\n ))}\n </div>\n ) : null}\n </FileDropInput>\n </div>\n </TabsContent>\n\n {/** TileSet*/}\n <TabsContent\n value={AddDataMethods.TileSet}\n className=\"h-full w-full overflow-auto data-[state=inactive]:hidden\"\n >\n <LoadTileSetContent\n loadTileSet={loadTileSet}\n onClose={addDataModal.onClose}\n />\n </TabsContent>\n {/** S3 */}\n {/* <TabsContent\n value={AddDataMethods.S3}\n className=\"h-full w-full data-[state=inactive]:hidden\"\n >\n <KeplerS3Browser\n listS3Files={listS3Files}\n s3Browser={s3Browser}\n loadS3Files={onLoadS3Files}\n saveS3Credentials={saveS3Credentials}\n loadS3Credentials={loadS3Credentials}\n deleteS3Credentials={deleteS3Credentials}\n />\n </TabsContent> */}\n </Tabs>\n </DialogContent>\n </Dialog>\n </KeplerProvider>\n );\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"KeplerImageExport.d.ts","sourceRoot":"","sources":["../../src/components/KeplerImageExport.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+B,MAAM,OAAO,CAAC;AAwBpD,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAE7C,MAAM,WAAW,sBAAsB;IACrC,qBAAqB,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IAChE,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B,mBAAmB,EAAE,WAAW,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAqG9D,CAAC"}
1
+ {"version":3,"file":"KeplerImageExport.d.ts","sourceRoot":"","sources":["../../src/components/KeplerImageExport.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+B,MAAM,OAAO,CAAC;AAuBpD,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAK7C,MAAM,WAAW,sBAAsB;IACrC,qBAAqB,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IAChE,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B,mBAAmB,EAAE,WAAW,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAaD,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAoG9D,CAAC"}
@@ -1,12 +1,31 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect } from 'react';
3
3
  import { Button, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Label, Switch, } from '@sqlrooms/ui';
4
- import { EXPORT_IMG_RATIO_OPTIONS, EXPORT_IMG_RESOLUTION_OPTIONS, } from '@kepler.gl/constants';
5
- import { FormattedMessage } from '@kepler.gl/localization';
4
+ import { Resolution1024x768Option, Resolution1280x720Option, Resolution1280x960Option, Resolution1600x1200Option, Resolution1600x900Option, Resolution1920x1080Option, Resolution1920x1440Option, Resolution2560x1440Option, } from '@kepler.gl/constants';
6
5
  import { ImagePreview } from '@kepler.gl/components';
7
6
  import { dataURItoBlob, downloadFile } from '@kepler.gl/utils';
7
+ import { Loader2 } from 'lucide-react';
8
+ const CUSTOM_RESOLUTION_OPTIONS = [
9
+ Resolution1280x720Option,
10
+ Resolution1920x1080Option,
11
+ Resolution2560x1440Option,
12
+ Resolution1600x900Option,
13
+ Resolution1024x768Option,
14
+ Resolution1280x960Option,
15
+ Resolution1600x1200Option,
16
+ Resolution1920x1440Option,
17
+ ];
8
18
  export const KeplerImageExport = ({ setExportImageSetting, cleanupExportImage, exportImageSettings, fileName, onExportStart, }) => {
9
- const { legend, ratio, resolution, processing, imageDataUri } = exportImageSettings;
19
+ const { legend, resolution, processing, imageDataUri } = exportImageSettings;
20
+ useEffect(() => {
21
+ // hardcode default resolution only when incoming resolution is not a supported custom option
22
+ const isSupportedResolution = CUSTOM_RESOLUTION_OPTIONS.some((option) => option.id === resolution);
23
+ if (!isSupportedResolution) {
24
+ setExportImageSetting({
25
+ resolution: Resolution1280x720Option.id,
26
+ });
27
+ }
28
+ }, [resolution, setExportImageSetting]);
10
29
  useEffect(() => {
11
30
  setExportImageSetting({
12
31
  exporting: true,
@@ -20,12 +39,11 @@ export const KeplerImageExport = ({ setExportImageSetting, cleanupExportImage, e
20
39
  downloadFile(file, `${fileName || 'Untitled'}.png`);
21
40
  }
22
41
  }, [processing, imageDataUri, fileName, onExportStart]);
23
- return (_jsxs("div", { className: "flex flex-col gap-6 px-[5px] pb-5 pt-1", children: [_jsx(ImagePreview, { exportImage: exportImageSettings }), _jsxs("div", { className: "grid grid-cols-[100px_auto] items-center gap-4", children: [_jsx(Label, { children: "Resolution" }), _jsxs(Select, { value: resolution, onValueChange: (value) => setExportImageSetting({
42
+ const isPreviewReady = !processing && Boolean(imageDataUri);
43
+ return (_jsxs("div", { className: "flex flex-col gap-6 px-[5px] pt-1 pb-5", children: [_jsx(ImagePreview, { exportImage: exportImageSettings }), _jsxs("div", { className: "grid grid-cols-[100px_auto] items-center gap-4", children: [_jsx(Label, { children: "Resolution" }), _jsxs(Select, { value: resolution, onValueChange: (value) => setExportImageSetting({
24
44
  resolution: value,
25
- }), children: [_jsx(SelectTrigger, { children: _jsx(SelectValue, { placeholder: "Select resolution" }) }), _jsx(SelectContent, { children: EXPORT_IMG_RESOLUTION_OPTIONS.map((option) => (_jsx(SelectItem, { value: option.id, disabled: !option.available, children: option.label }, option.id))) })] }), _jsx(Label, { children: "Ratio" }), _jsxs(Select, { value: ratio, onValueChange: (value) => setExportImageSetting({
26
- ratio: value,
27
- }), children: [_jsx(SelectTrigger, { children: _jsx(SelectValue, { placeholder: "Select ratio" }) }), _jsx(SelectContent, { children: EXPORT_IMG_RATIO_OPTIONS.filter((op) => !op.hidden).map((option) => (_jsx(SelectItem, { value: option.id, children: _jsx(FormattedMessage, { id: option.label }) }, option.id))) })] }), _jsx(Label, { className: "font-normal", children: "Show legend" }), _jsx(Switch, { checked: legend, onCheckedChange: (checked) => setExportImageSetting({
45
+ }), disabled: processing, children: [_jsx(SelectTrigger, { children: _jsx(SelectValue, { placeholder: "Select resolution" }) }), _jsx(SelectContent, { children: CUSTOM_RESOLUTION_OPTIONS.map((option) => (_jsx(SelectItem, { value: option.id, disabled: !option.available, children: option.label }, option.id))) })] }), _jsx(Label, { className: "font-normal", children: "Show legend" }), _jsx(Switch, { checked: legend, onCheckedChange: (checked) => setExportImageSetting({
28
46
  legend: checked === true,
29
- }) })] }), _jsx("div", { className: "flex flex-col gap-2", children: _jsx(Button, { variant: "default", className: "w-full", onClick: handleExportImage, children: "Export Image" }) })] }));
47
+ }), disabled: processing })] }), _jsx("div", { className: "flex flex-col gap-2", children: _jsx(Button, { variant: "default", className: "w-full", onClick: handleExportImage, disabled: processing || !isPreviewReady, children: processing ? (_jsxs("span", { className: "flex items-center gap-2", children: [_jsx(Loader2, { className: "h-4 w-4 animate-spin" }), "Processing..."] })) : ('Export Image') }) })] }));
30
48
  };
31
49
  //# sourceMappingURL=KeplerImageExport.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KeplerImageExport.js","sourceRoot":"","sources":["../../src/components/KeplerImageExport.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAC,WAAW,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AACpD,OAAO,EACL,MAAM,EACN,MAAM,EACN,aAAa,EACb,UAAU,EACV,aAAa,EACb,WAAW,EACX,KAAK,EACL,MAAM,GACP,MAAM,cAAc,CAAC;AAKtB,OAAO,EAGL,wBAAwB,EACxB,6BAA6B,GAC9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAC,gBAAgB,EAAC,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAC,aAAa,EAAE,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAW7D,MAAM,CAAC,MAAM,iBAAiB,GAAqC,CAAC,EAClE,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,QAAQ,EACR,aAAa,GACd,EAAE,EAAE;IACH,MAAM,EAAC,MAAM,EAAE,KAAK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KAAC,KAAK,wBAAc,EACpB,MAAC,MAAM,IACL,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CACvB,qBAAqB,CAAC;4BACpB,KAAK,EAAE,KAAuC;yBAC/C,CAAC,aAGJ,KAAC,aAAa,cACZ,KAAC,WAAW,IAAC,WAAW,EAAC,cAAc,GAAG,GAC5B,EAChB,KAAC,aAAa,cACX,wBAAwB,CAAC,MAAM,CAC9B,CAAC,EAAoB,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,MAAM,CACrC,CAAC,GAAG,CAAC,CAAC,MAAwB,EAAE,EAAE,CAAC,CAClC,KAAC,UAAU,IAAiB,KAAK,EAAE,MAAM,CAAC,EAAE,YAC1C,KAAC,gBAAgB,IAAC,EAAE,EAAE,MAAM,CAAC,KAAK,GAAI,IADvB,MAAM,CAAC,EAAE,CAEb,CACd,CAAC,GACY,IACT,EAET,KAAC,KAAK,IAAC,SAAS,EAAC,aAAa,4BAAoB,EAClD,KAAC,MAAM,IACL,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,CAAC,OAAO,EAAE,EAAE,CAC3B,qBAAqB,CAAC;4BACpB,MAAM,EAAE,OAAO,KAAK,IAAI;yBACzB,CAAC,GAEJ,IACE,EAEN,cAAK,SAAS,EAAC,qBAAqB,YAClC,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,SAAS,EAAC,QAAQ,EAClB,OAAO,EAAE,iBAAiB,6BAGnB,GACL,IACF,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React, {useCallback, useEffect} from 'react';\nimport {\n Button,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n Label,\n Switch,\n} from '@sqlrooms/ui';\nimport type {\n ImageRatioOption,\n ImageResolutionOption,\n} from '@kepler.gl/constants';\nimport {\n EXPORT_IMG_RATIOS,\n RESOLUTIONS,\n EXPORT_IMG_RATIO_OPTIONS,\n EXPORT_IMG_RESOLUTION_OPTIONS,\n} from '@kepler.gl/constants';\nimport {FormattedMessage} from '@kepler.gl/localization';\nimport {ImagePreview} from '@kepler.gl/components';\nimport {dataURItoBlob, downloadFile} from '@kepler.gl/utils';\nimport {ExportImage} from '@kepler.gl/types';\n\nexport interface KeplerImageExportProps {\n setExportImageSetting: (settings: Partial<ExportImage>) => void;\n cleanupExportImage: () => void;\n exportImageSettings: ExportImage;\n fileName?: string;\n onExportStart?: () => void;\n}\n\nexport const KeplerImageExport: React.FC<KeplerImageExportProps> = ({\n setExportImageSetting,\n cleanupExportImage,\n exportImageSettings,\n fileName,\n onExportStart,\n}) => {\n const {legend, ratio, resolution, processing, imageDataUri} =\n exportImageSettings;\n\n useEffect(() => {\n setExportImageSetting({\n exporting: true,\n });\n return cleanupExportImage;\n }, [setExportImageSetting, cleanupExportImage]);\n\n const handleExportImage = useCallback(() => {\n if (!processing && imageDataUri) {\n onExportStart?.();\n const file = dataURItoBlob(imageDataUri);\n downloadFile(file, `${fileName || 'Untitled'}.png`);\n }\n }, [processing, imageDataUri, fileName, onExportStart]);\n\n return (\n <div className=\"flex flex-col gap-6 px-[5px] pb-5 pt-1\">\n <ImagePreview exportImage={exportImageSettings} />\n <div className=\"grid grid-cols-[100px_auto] items-center gap-4\">\n <Label>Resolution</Label>\n <Select\n value={resolution}\n onValueChange={(value) =>\n setExportImageSetting({\n resolution: value as keyof typeof RESOLUTIONS,\n })\n }\n >\n <SelectTrigger>\n <SelectValue placeholder=\"Select resolution\" />\n </SelectTrigger>\n <SelectContent>\n {EXPORT_IMG_RESOLUTION_OPTIONS.map(\n (option: ImageResolutionOption) => (\n <SelectItem\n key={option.id}\n value={option.id}\n disabled={!option.available}\n >\n {option.label}\n </SelectItem>\n ),\n )}\n </SelectContent>\n </Select>\n\n <Label>Ratio</Label>\n <Select\n value={ratio}\n onValueChange={(value) =>\n setExportImageSetting({\n ratio: value as keyof typeof EXPORT_IMG_RATIOS,\n })\n }\n >\n <SelectTrigger>\n <SelectValue placeholder=\"Select ratio\" />\n </SelectTrigger>\n <SelectContent>\n {EXPORT_IMG_RATIO_OPTIONS.filter(\n (op: ImageRatioOption) => !op.hidden,\n ).map((option: ImageRatioOption) => (\n <SelectItem key={option.id} value={option.id}>\n <FormattedMessage id={option.label} />\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n\n <Label className=\"font-normal\">Show legend</Label>\n <Switch\n checked={legend}\n onCheckedChange={(checked) =>\n setExportImageSetting({\n legend: checked === true,\n })\n }\n />\n </div>\n\n <div className=\"flex flex-col gap-2\">\n <Button\n variant=\"default\"\n className=\"w-full\"\n onClick={handleExportImage}\n >\n Export Image\n </Button>\n </div>\n </div>\n );\n};\n"]}
1
+ {"version":3,"file":"KeplerImageExport.js","sourceRoot":"","sources":["../../src/components/KeplerImageExport.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAC,WAAW,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AACpD,OAAO,EACL,MAAM,EACN,MAAM,EACN,aAAa,EACb,UAAU,EACV,aAAa,EACb,WAAW,EACX,KAAK,EACL,MAAM,GACP,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAC,aAAa,EAAE,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAYrC,MAAM,yBAAyB,GAAG;IAChC,wBAAwB;IACxB,yBAAyB;IACzB,yBAAyB;IACzB,wBAAwB;IACxB,wBAAwB;IACxB,wBAAwB;IACxB,yBAAyB;IACzB,yBAAyB;CAC1B,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAqC,CAAC,EAClE,qBAAqB,EACrB,kB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AC,gDAAgD,aAC7D,KAAC,KAAK,6BAAmB,EACzB,MAAC,MAAM,IACL,KAAK,EAAE,UAAU,EACjB,aAAa,EAAE,CAAC,KAA6B,EAAE,EAAE,CAC/C,qBAAqB,CAAC;4BACpB,UAAU,EAAE,KAAK;yBAClB,CAAC,EAEJ,QAAQ,EAAE,UAAU,aAEpB,KAAC,aAAa,cACZ,KAAC,WAAW,IAAC,WAAW,EAAC,mBAAmB,GAAG,GACjC,EAChB,KAAC,aAAa,cACX,yBAAyB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACzC,KAAC,UAAU,IAET,KAAK,EAAE,MAAM,CAAC,EAA4B,EAC1C,QAAQ,EAAE,CAAC,MAAM,CAAC,SAAS,YAE1B,MAAM,CAAC,KAAK,IAJR,MAAM,CAAC,EAAE,CAKH,CACd,CAAC,GACY,IACT,EAET,KAAC,KAAK,IAAC,SAAS,EAAC,aAAa,4BAAoB,EAClD,KAAC,MAAM,IACL,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,CAAC,OAAO,EAAE,EAAE,CAC3B,qBAAqB,CAAC;4BACpB,MAAM,EAAE,OAAO,KAAK,IAAI;yBACzB,CAAC,EAEJ,QAAQ,EAAE,UAAU,GACpB,IACE,EAEN,cAAK,SAAS,EAAC,qBAAqB,YAClC,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,SAAS,EAAC,QAAQ,EAClB,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,UAAU,IAAI,CAAC,cAAc,YAEtC,UAAU,CAAC,CAAC,CAAC,CACZ,gBAAM,SAAS,EAAC,yBAAyB,aACvC,KAAC,OAAO,IAAC,SAAS,EAAC,sBAAsB,GAAG,qBAEvC,CACR,CAAC,CAAC,CAAC,CACF,cAAc,CACf,GACM,GACL,IACF,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React, {useCallback, useEffect} from 'react';\nimport {\n Button,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n Label,\n Switch,\n} from '@sqlrooms/ui';\nimport {\n Resolution1024x768Option,\n Resolution1280x720Option,\n Resolution1280x960Option,\n Resolution1600x1200Option,\n Resolution1600x900Option,\n Resolution1920x1080Option,\n Resolution1920x1440Option,\n Resolution2560x1440Option,\n} from '@kepler.gl/constants';\nimport {ImagePreview} from '@kepler.gl/components';\nimport {dataURItoBlob, downloadFile} from '@kepler.gl/utils';\nimport {ExportImage} from '@kepler.gl/types';\nimport {Loader2} from 'lucide-react';\n\ntype ExportResolutionOption = ExportImage['resolution'];\n\nexport interface KeplerImageExportProps {\n setExportImageSetting: (settings: Partial<ExportImage>) => void;\n cleanupExportImage: () => void;\n exportImageSettings: ExportImage;\n fileName?: string;\n onExportStart?: () => void;\n}\n\nconst CUSTOM_RESOLUTION_OPTIONS = [\n Resolution1280x720Option,\n Resolution1920x1080Option,\n Resolution2560x1440Option,\n Resolution1600x900Option,\n Resolution1024x768Option,\n Resolution1280x960Option,\n Resolution1600x1200Option,\n Resolution1920x1440Option,\n];\n\nexport const KeplerImageExport: React.FC<KeplerImageExportProps> = ({\n setExportImageSetting,\n cleanupExportImage,\n exportImageSettings,\n fileName,\n onExportStart,\n}) => {\n const {legend, resolution, processing, imageDataUri} = exportImageSettings;\n\n useEffect(() => {\n // hardcode default resolution only when incoming resolution is not a supported custom option\n const isSupportedResolution = CUSTOM_RESOLUTION_OPTIONS.some(\n (option) => option.id === resolution,\n );\n if (!isSupportedResolution) {\n setExportImageSetting({\n resolution: Resolution1280x720Option.id,\n });\n }\n }, [resolution, setExportImageSetting]);\n\n useEffect(() => {\n setExportImageSetting({\n exporting: true,\n });\n return cleanupExportImage;\n }, [setExportImageSetting, cleanupExportImage]);\n\n const handleExportImage = useCallback(() => {\n if (!processing && imageDataUri) {\n onExportStart?.();\n const file = dataURItoBlob(imageDataUri);\n downloadFile(file, `${fileName || 'Untitled'}.png`);\n }\n }, [processing, imageDataUri, fileName, onExportStart]);\n\n const isPreviewReady = !processing && Boolean(imageDataUri);\n\n return (\n <div className=\"flex flex-col gap-6 px-[5px] pt-1 pb-5\">\n <ImagePreview exportImage={exportImageSettings} />\n\n <div className=\"grid grid-cols-[100px_auto] items-center gap-4\">\n <Label>Resolution</Label>\n <Select\n value={resolution}\n onValueChange={(value: ExportResolutionOption) =>\n setExportImageSetting({\n resolution: value,\n })\n }\n disabled={processing}\n >\n <SelectTrigger>\n <SelectValue placeholder=\"Select resolution\" />\n </SelectTrigger>\n <SelectContent>\n {CUSTOM_RESOLUTION_OPTIONS.map((option) => (\n <SelectItem\n key={option.id}\n value={option.id as ExportResolutionOption}\n disabled={!option.available}\n >\n {option.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n\n <Label className=\"font-normal\">Show legend</Label>\n <Switch\n checked={legend}\n onCheckedChange={(checked) =>\n setExportImageSetting({\n legend: checked === true,\n })\n }\n disabled={processing}\n />\n </div>\n\n <div className=\"flex flex-col gap-2\">\n <Button\n variant=\"default\"\n className=\"w-full\"\n onClick={handleExportImage}\n disabled={processing || !isPreviewReady}\n >\n {processing ? (\n <span className=\"flex items-center gap-2\">\n <Loader2 className=\"h-4 w-4 animate-spin\" />\n Processing...\n </span>\n ) : (\n 'Export Image'\n )}\n </Button>\n </div>\n </div>\n );\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"KeplerInjector.d.ts","sourceRoot":"","sources":["../../src/components/KeplerInjector.tsx"],"names":[],"mappings":"AAAA,OAAO,EAaL,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAA0B,MAAM,OAAO,CAAC;AAO/C,eAAO,MAAM,0BAA0B,kBAEtC,CAAC;AAEF,eAAO,MAAM,uBAAuB;;EAMnC,CAAC;AAEF,MAAM,MAAM,aAAa,CAAC,OAAO,GAAG,OAAO,IAAI,CAAC,GAAG,KAAK,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC;AAC5E,MAAM,MAAM,mBAAmB,GAAG,CAAC,aAAa,E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,GAChB,UAAU,CAAC,QAAQ,CAAC,CA+BtB;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc;QACrB,QAAQ,SAAS,aAAa,WAAW,QAAQ;CAGtD,CAAC"}
@@ -1,10 +1,12 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { AddDataButtonFactory, ContainerFactory, injector as createInjector, DndContextFactory, FilterPanelHeaderFactory, flattenDeps, MapControlTooltipFactory, MapLegendFactory, MapLegendPanelFactory, PanelTitleFactory, typeCheckRecipe, } from '@kepler.gl/components';
2
+ import { AddDataButtonFactory, ContainerFactory, injector as createInjector, DndContextFactory, FilterPanelHeaderFactory, flattenDeps, MapControlTooltipFactory, MapDrawPanelFactory, MapLegendFactory, MapLegendPanelFactory, PanelTitleFactory, SourceDataSelectorFactory, typeCheckRecipe, } from '@kepler.gl/components';
3
3
  import { CustomDndContextFactory } from './CustomDndContext';
4
4
  import { CustomFilterPanelHeaderFactory } from './CustomFilterPanelHeader';
5
5
  import { CustomMapControlTooltipFactory } from './CustomMapControlTooltipFactory';
6
+ import { CustomMapDrawPanelFactory } from './CustomMapDrawPanel';
6
7
  import { CustomMapLegendFactory } from './CustomMapLegend';
7
8
  import { CustomMapLegendPanelFactory } from './CustomMapLegendPanel';
9
+ import { CustomSourceDataSelectorFactory } from './CustomSourceDataSelector';
8
10
  export const CustomAddDataButtonFactory = () => {
9
11
  return () => null;
10
12
  };
@@ -20,6 +22,8 @@ const defaultRecipes = [
20
22
  [MapLegendPanelFactory, CustomMapLegendPanelFactory],
21
23
  [MapLegendFactory, CustomMapLegendFactory],
22
24
  [MapControlTooltipFactory, CustomMapControlTooltipFactory],
25
+ [MapDrawPanelFactory, CustomMapDrawPanelFactory],
26
+ [SourceDataSelectorFactory, CustomSourceDataSelectorFactory],
23
27
  ];
24
28
  let customRecipes = [];
25
29
  let injector = createKeplerInjector();
@@ -1 +1 @@
1
- {"version":3,"file":"KeplerInjector.js","sourceRoot":"","sources":["../../src/components/KeplerInjector.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sourcesContent":["import {\n AddDataButtonFactory,\n ContainerFactory,\n injector as createInjector,\n DndContextFactory,\n Factory,\n FilterPanelHeaderFactory,\n flattenDeps,\n MapControlTooltipFactory,\n MapLegendFactory,\n MapLegendPanelFactory,\n PanelTitleFactory,\n typeCheckRecipe,\n type InjectorType,\n} from '@kepler.gl/components';\nimport React, {PropsWithChildren} from 'react';\nimport {CustomDndContextFactory} from './CustomDndContext';\nimport {CustomFilterPanelHeaderFactory} from './CustomFilterPanelHeader';\nimport {CustomMapControlTooltipFactory} from './CustomMapControlTooltipFactory';\nimport {CustomMapLegendFactory} from './CustomMapLegend';\nimport {CustomMapLegendPanelFactory} from './CustomMapLegendPanel';\n\nexport const CustomAddDataButtonFactory = () => {\n return () => null;\n};\n\nexport const CustomPanelTitleFactory = () => {\n const PanelTitle: React.FC<PropsWithChildren> = ({children}) => (\n <div className=\"flex items-center justify-end\">{children}</div>\n );\n\n return PanelTitle;\n};\n\nexport type KeplerFactory<TReturn = unknown> = (..._args: any[]) => TReturn;\nexport type KeplerFactoryRecipe = [KeplerFactory, KeplerFactory];\nexport type KeplerFactoryRecipeMode = 'append' | 'replace';\n\nconst defaultRecipes: KeplerFactoryRecipe[] = [\n [AddDataButtonFactory, CustomAddDataButtonFactory],\n [PanelTitleFactory, CustomPanelTitleFactory],\n [DndContextFactory, CustomDndContextFactory],\n [FilterPanelHeaderFactory, CustomFilterPanelHeaderFactory],\n [MapLegendPanelFactory, CustomMapLegendPanelFactory],\n [MapLegendFactory, CustomMapLegendFactory],\n [MapControlTooltipFactory, CustomMapControlTooltipFactory],\n];\n\nlet customRecipes: KeplerFactoryRecipe[] = [];\nlet injector = createKeplerInjector();\n\nfunction createBaseInjector() {\n const allDependencies = flattenDeps(\n [],\n ContainerFactory as unknown as Factory,\n );\n return allDependencies.reduce(\n (current, factory) => current.provide(factory, factory),\n createInjector(),\n );\n}\n\n/**\n * Applies factory replacement recipes on top of a fresh Kepler injector while\n * preserving explicit replacement targets.\n *\n * Kepler's default `provideRecipesToInjector` pre-provides all replacement\n * dependencies as identity mappings (`dep -> dep`) before applying each recipe.\n * That can unintentionally override factories that were already replaced by\n * earlier recipes, and emits noisy \"already injected\" warnings.\n *\n * This helper keeps the same high-level flow (process recipes in order and then\n * eagerly resolve the configured factories), but skips identity-providing any\n * dependency that is itself an explicit replacement target in the current\n * recipe set. As a result:\n * - earlier explicit replacements are not overwritten by later dependency setup\n * - replacement ordering remains deterministic\n * - configured factories are still warmed via `get(factoryToReplace)`\n */\nfunction provideRecipesToInjectorSafely(\n recipes: KeplerFactoryRecipe[],\n baseInjector: InjectorType,\n) {\n const replacementTargets = new Set(\n recipes\n .filter((recipe) =>\n typeCheckRecipe(recipe as unknown as [Factory, Factory]),\n )\n .map((recipe) => recipe[0]),\n );\n\n const provided = new Map();\n\n const injectorWithRecipes = recipes.reduce((currentInjector, recipe) => {\n if (!typeCheckRecipe(recipe as unknown as [Factory, Factory])) {\n return currentInjector;\n }\n\n const [factoryToReplace, replacementFactory] = recipe;\n const customDependencies = flattenDeps(\n [],\n replacementFactory as unknown as Factory,\n );\n\n const injectorWithDependencies = customDependencies.reduce(\n (dependencyInjector, dependencyFactory) => {\n // If a dependency has an explicit replacement recipe, skip self-injecting it.\n // This avoids overriding previous replacements and warning noise.\n if (\n replacementTargets.has(dependencyFactory as unknown as KeplerFactory)\n ) {\n return dependencyInjector;\n }\n return dependencyInjector.provide(dependencyFactory, dependencyFactory);\n },\n currentInjector,\n );\n\n provided.set(factoryToReplace, replacementFactory);\n return injectorWithDependencies.provide(\n factoryToReplace,\n replacementFactory,\n );\n }, baseInjector);\n\n provided.forEach((_, factoryToReplace) => {\n injectorWithRecipes.get(factoryToReplace);\n });\n\n return injectorWithRecipes;\n}\n\nfunction createKeplerInjector(recipes: KeplerFactoryRecipe[] = []) {\n return provideRecipesToInjectorSafely(\n [...defaultRecipes, ...recipes],\n createBaseInjector(),\n );\n}\n\nexport function configureKeplerInjector(\n recipes: KeplerFactoryRecipe[],\n options: {mode?: KeplerFactoryRecipeMode} = {},\n) {\n const mode = options.mode ?? 'append';\n customRecipes =\n mode === 'replace' ? [...recipes] : [...customRecipes, ...recipes];\n injector = createKeplerInjector(customRecipes);\n}\n\nexport function resetKeplerInjectorRecipes() {\n customRecipes = [];\n injector = createKeplerInjector();\n}\n\nexport function getKeplerInjector() {\n return injector;\n}\n\n// Cache resolved components per injector so we keep a stable component\n// reference across re-renders. Invalidated when injector is replaced (configure/reset).\nconst injectorToFactoryCache = new WeakMap<\n object,\n Map<KeplerFactory, React.ComponentType<Record<string, unknown>>>\n>();\n\n// Cache wrapper components per factory so callers always get a stable component type.\nconst factoryToWrapperCache = new Map<\n KeplerFactory,\n React.ComponentType<Record<string, unknown>>\n>();\n\nexport function getKeplerFactory<TFactory extends KeplerFactory>(\n factory: TFactory,\n): ReturnType<TFactory> {\n let Wrapped = factoryToWrapperCache.get(factory);\n if (Wrapped === undefined) {\n const WrappedComponent = function KeplerFactoryWrapper(\n props: Record<string, unknown>,\n ) {\n // Resolve at top level of render (not inside useMemo) so injector.get()\n // running the factory chain does not run hooks inside a hook.\n const injectorInstance = getKeplerInjector();\n let byFactory = injectorToFactoryCache.get(injectorInstance as object);\n if (byFactory === undefined) {\n byFactory = new Map();\n injectorToFactoryCache.set(injectorInstance as object, byFactory);\n }\n let Component = byFactory.get(factory);\n if (Component === undefined) {\n Component = injectorInstance.get(\n factory as unknown as Factory,\n ) as React.ComponentType<Record<string, unknown>>;\n byFactory.set(factory, Component);\n }\n // eslint-disable-next-line react-hooks/static-components -- Kepler factory components resolved at render by design\n return <Component {...props} />;\n };\n\n const factoryName = factory.name || 'Anonymous';\n WrappedComponent.displayName = `KeplerFactory(${factoryName})`;\n Wrapped = WrappedComponent;\n factoryToWrapperCache.set(factory, WrappedComponent);\n }\n return Wrapped as unknown as ReturnType<TFactory>;\n}\n\n/**\n * Stable access to Kepler factories. Prefer calling `get()` at module scope\n * (or in a constant initializer) so the returned component type is reused.\n */\nexport const KeplerInjector = {\n get<TFactory extends KeplerFactory>(factory: TFactory) {\n return getKeplerFactory(factory);\n },\n};\n"]}
1
+ {"version":3,"file":"KeplerInjector.js","sourceRoot":"","sources":["../../src/components/KeplerInjector.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,QAAQ,IAAI,cAAc,EAC1B,iBAAiB,EAEjB,wBAAwB,EACxB,WAAW,EACX,wBAAwB,EACxB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,yBAAyB,EACzB,eAAe,GAEhB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAC,8BAA8B,EAAC,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAC,8BAA8B,EAAC,MAAM,kCAAkC,CAAC;AAChF,OAAO,EAAC,yBAAyB,EAAC,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAC,sBAAsB,EAAC,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAC,2BAA2B,EAAC,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAC,+BAA+B,EAAC,MAAM,4BAA4B,CAAC;AAE3E,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,EAAE;IAC7C,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,EAAE;IAC1C,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;AAMF,MAAM,cAAc,GAA0B;IAC5C,CAAC,oBAAoB,EAAE,0BAA0B,CAAC;IAClD,CAAC,iBAAiB,EAAE,uBAAuB,CAAC;IAC5C,CAAC,iBAAiB,EAAE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AChD,gBAAgB,CAAC,WAAW,GAAG,iBAAiB,WAAW,GAAG,CAAC;QAC/D,OAAO,GAAG,gBAAgB,CAAC;QAC3B,qBAAqB,CAAC,GAAG,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,OAA0C,CAAC;AACpD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,GAAG,CAAiC,OAAiB;QACnD,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;CACF,CAAC","sourcesContent":["import {\n AddDataButtonFactory,\n ContainerFactory,\n injector as createInjector,\n DndContextFactory,\n Factory,\n FilterPanelHeaderFactory,\n flattenDeps,\n MapControlTooltipFactory,\n MapDrawPanelFactory,\n MapLegendFactory,\n MapLegendPanelFactory,\n PanelTitleFactory,\n SourceDataSelectorFactory,\n typeCheckRecipe,\n type InjectorType,\n} from '@kepler.gl/components';\nimport React, {PropsWithChildren} from 'react';\nimport {CustomDndContextFactory} from './CustomDndContext';\nimport {CustomFilterPanelHeaderFactory} from './CustomFilterPanelHeader';\nimport {CustomMapControlTooltipFactory} from './CustomMapControlTooltipFactory';\nimport {CustomMapDrawPanelFactory} from './CustomMapDrawPanel';\nimport {CustomMapLegendFactory} from './CustomMapLegend';\nimport {CustomMapLegendPanelFactory} from './CustomMapLegendPanel';\nimport {CustomSourceDataSelectorFactory} from './CustomSourceDataSelector';\n\nexport const CustomAddDataButtonFactory = () => {\n return () => null;\n};\n\nexport const CustomPanelTitleFactory = () => {\n const PanelTitle: React.FC<PropsWithChildren> = ({children}) => (\n <div className=\"flex items-center justify-end\">{children}</div>\n );\n\n return PanelTitle;\n};\n\nexport type KeplerFactory<TReturn = unknown> = (..._args: any[]) => TReturn;\nexport type KeplerFactoryRecipe = [KeplerFactory, KeplerFactory];\nexport type KeplerFactoryRecipeMode = 'append' | 'replace';\n\nconst defaultRecipes: KeplerFactoryRecipe[] = [\n [AddDataButtonFactory, CustomAddDataButtonFactory],\n [PanelTitleFactory, CustomPanelTitleFactory],\n [DndContextFactory, CustomDndContextFactory],\n [FilterPanelHeaderFactory, CustomFilterPanelHeaderFactory],\n [MapLegendPanelFactory, CustomMapLegendPanelFactory],\n [MapLegendFactory, CustomMapLegendFactory],\n [MapControlTooltipFactory, CustomMapControlTooltipFactory],\n [MapDrawPanelFactory, CustomMapDrawPanelFactory],\n [SourceDataSelectorFactory, CustomSourceDataSelectorFactory],\n];\n\nlet customRecipes: KeplerFactoryRecipe[] = [];\nlet injector = createKeplerInjector();\n\nfunction createBaseInjector() {\n const allDependencies = flattenDeps(\n [],\n ContainerFactory as unknown as Factory,\n );\n return allDependencies.reduce(\n (current, factory) => current.provide(factory, factory),\n createInjector(),\n );\n}\n\n/**\n * Applies factory replacement recipes on top of a fresh Kepler injector while\n * preserving explicit replacement targets.\n *\n * Kepler's default `provideRecipesToInjector` pre-provides all replacement\n * dependencies as identity mappings (`dep -> dep`) before applying each recipe.\n * That can unintentionally override factories that were already replaced by\n * earlier recipes, and emits noisy \"already injected\" warnings.\n *\n * This helper keeps the same high-level flow (process recipes in order and then\n * eagerly resolve the configured factories), but skips identity-providing any\n * dependency that is itself an explicit replacement target in the current\n * recipe set. As a result:\n * - earlier explicit replacements are not overwritten by later dependency setup\n * - replacement ordering remains deterministic\n * - configured factories are still warmed via `get(factoryToReplace)`\n */\nfunction provideRecipesToInjectorSafely(\n recipes: KeplerFactoryRecipe[],\n baseInjector: InjectorType,\n) {\n const replacementTargets = new Set(\n recipes\n .filter((recipe) =>\n typeCheckRecipe(recipe as unknown as [Factory, Factory]),\n )\n .map((recipe) => recipe[0]),\n );\n\n const provided = new Map();\n\n const injectorWithRecipes = recipes.reduce((currentInjector, recipe) => {\n if (!typeCheckRecipe(recipe as unknown as [Factory, Factory])) {\n return currentInjector;\n }\n\n const [factoryToReplace, replacementFactory] = recipe;\n const customDependencies = flattenDeps(\n [],\n replacementFactory as unknown as Factory,\n );\n\n const injectorWithDependencies = customDependencies.reduce(\n (dependencyInjector, dependencyFactory) => {\n // If a dependency has an explicit replacement recipe, skip self-injecting it.\n // This avoids overriding previous replacements and warning noise.\n if (\n replacementTargets.has(dependencyFactory as unknown as KeplerFactory)\n ) {\n return dependencyInjector;\n }\n return dependencyInjector.provide(dependencyFactory, dependencyFactory);\n },\n currentInjector,\n );\n\n provided.set(factoryToReplace, replacementFactory);\n return injectorWithDependencies.provide(\n factoryToReplace,\n replacementFactory,\n );\n }, baseInjector);\n\n provided.forEach((_, factoryToReplace) => {\n injectorWithRecipes.get(factoryToReplace);\n });\n\n return injectorWithRecipes;\n}\n\nfunction createKeplerInjector(recipes: KeplerFactoryRecipe[] = []) {\n return provideRecipesToInjectorSafely(\n [...defaultRecipes, ...recipes],\n createBaseInjector(),\n );\n}\n\nexport function configureKeplerInjector(\n recipes: KeplerFactoryRecipe[],\n options: {mode?: KeplerFactoryRecipeMode} = {},\n) {\n const mode = options.mode ?? 'append';\n customRecipes =\n mode === 'replace' ? [...recipes] : [...customRecipes, ...recipes];\n injector = createKeplerInjector(customRecipes);\n}\n\nexport function resetKeplerInjectorRecipes() {\n customRecipes = [];\n injector = createKeplerInjector();\n}\n\nexport function getKeplerInjector() {\n return injector;\n}\n\n// Cache resolved components per injector so we keep a stable component\n// reference across re-renders. Invalidated when injector is replaced (configure/reset).\nconst injectorToFactoryCache = new WeakMap<\n object,\n Map<KeplerFactory, React.ComponentType<Record<string, unknown>>>\n>();\n\n// Cache wrapper components per factory so callers always get a stable component type.\nconst factoryToWrapperCache = new Map<\n KeplerFactory,\n React.ComponentType<Record<string, unknown>>\n>();\n\nexport function getKeplerFactory<TFactory extends KeplerFactory>(\n factory: TFactory,\n): ReturnType<TFactory> {\n let Wrapped = factoryToWrapperCache.get(factory);\n if (Wrapped === undefined) {\n const WrappedComponent = function KeplerFactoryWrapper(\n props: Record<string, unknown>,\n ) {\n // Resolve at top level of render (not inside useMemo) so injector.get()\n // running the factory chain does not run hooks inside a hook.\n const injectorInstance = getKeplerInjector();\n let byFactory = injectorToFactoryCache.get(injectorInstance as object);\n if (byFactory === undefined) {\n byFactory = new Map();\n injectorToFactoryCache.set(injectorInstance as object, byFactory);\n }\n let Component = byFactory.get(factory);\n if (Component === undefined) {\n Component = injectorInstance.get(\n factory as unknown as Factory,\n ) as React.ComponentType<Record<string, unknown>>;\n byFactory.set(factory, Component);\n }\n // eslint-disable-next-line react-hooks/static-components -- Kepler factory components resolved at render by design\n return <Component {...props} />;\n };\n\n const factoryName = factory.name || 'Anonymous';\n WrappedComponent.displayName = `KeplerFactory(${factoryName})`;\n Wrapped = WrappedComponent;\n factoryToWrapperCache.set(factory, WrappedComponent);\n }\n return Wrapped as unknown as ReturnType<TFactory>;\n}\n\n/**\n * Stable access to Kepler factories. Prefer calling `get()` at module scope\n * (or in a constant initializer) so the returned component type is reused.\n */\nexport const KeplerInjector = {\n get<TFactory extends KeplerFactory>(factory: TFactory) {\n return getKeplerFactory(factory);\n },\n};\n"]}
@@ -1 +1 @@
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
+ {"version":3,"file":"KeplerMapContainer.d.ts","sourceRoot":"","sources":["../../src/components/KeplerMapContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,EAAE,EAAuC,MAAM,OAAO,CAAC;AAgP/D,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;CACf,CAMA,CAAC"}
@@ -7,6 +7,7 @@ import { getKeplerFactory } from './KeplerInjector';
7
7
  import { KeplerProvider } from './KeplerProvider';
8
8
  import { useKeplerStateActions } from '../hooks/useKeplerStateActions';
9
9
  import { useStoreWithKepler } from '../KeplerSlice';
10
+ import { SplitMapIndexContext } from './SplitMapIndexContext';
10
11
  const MapContainer = getKeplerFactory(MapContainerFactory);
11
12
  const BottomWidget = getKeplerFactory(BottomWidgetFactory);
12
13
  const GeoCoderPanel = getKeplerFactory(GeocoderPanelFactory);
@@ -36,15 +37,22 @@ const CustomWidgetcontainer = styled.div `
36
37
  margin-top: 0 !important;
37
38
  }
38
39
  `;
40
+ const SplitMapsContainer = styled.div `
41
+ display: flex;
42
+ width: 100%;
43
+ height: 100%;
44
+ position: relative;
45
+ `;
39
46
  const KeplerGl = ({ mapId }) => {
40
47
  const bottomWidgetRef = useRef(null);
41
48
  const [containerRef, size] = useDimensions();
42
49
  const [containerNode, setContainerNode] = useState(null);
43
50
  const theme = useTheme();
44
51
  const basicKeplerProps = useStoreWithKepler((state) => state.kepler.basicKeplerProps);
52
+ const modalPortalTarget = useStoreWithKepler((state) => state.kepler.modalPortalTarget);
45
53
  const { keplerActions, keplerState } = useKeplerStateActions({ mapId });
46
54
  const interactionConfig = keplerState?.visState?.interactionConfig;
47
- // Capture the current container DOM node outside of render logic
55
+ // Capture container DOM node outside of render for portal use
48
56
  useEffect(() => {
49
57
  setContainerNode(containerRef.current);
50
58
  }, [containerRef]);
@@ -70,22 +78,53 @@ const KeplerGl = ({ mapId }) => {
70
78
  // dont need height
71
79
  size || DEFAULT_DIMENSIONS)
72
80
  : null;
81
+ const splitMaps = keplerState?.visState?.splitMaps;
82
+ const isSplit = splitMaps && splitMaps.length > 1;
73
83
  const mapFields = useMemo(() => (keplerState?.visState ? mapFieldsSelector(mergedKeplerProps) : null), [keplerState, mergedKeplerProps]);
84
+ const mapFieldsSplit = useMemo(() => isSplit && keplerState?.visState
85
+ ? splitMaps.map((_, index) => mapFieldsSelector(mergedKeplerProps, index))
86
+ : null, [keplerState, mergedKeplerProps, isSplit, splitMaps]);
74
87
  // Check if there are filters or animatable layers (e.g., Trip layers)
75
88
  const hasFilters = Boolean(keplerState?.visState.filters?.length);
76
89
  const hasAnimatableLayers = useMemo(() => {
77
90
  const layers = keplerState?.visState?.layers || [];
78
91
  return getAnimatableVisibleLayers(layers).length > 0;
79
92
  }, [keplerState?.visState?.layers]);
80
- const bottomWidgetFields = hasFilters || hasAnimatableLayers
81
- ? bottomWidgetSelector(mergedKeplerProps, theme)
82
- : null;
93
+ const bottomWidgetFields = useMemo(() => {
94
+ if (!hasFilters && !hasAnimatableLayers)
95
+ return null;
96
+ const fields = bottomWidgetSelector(mergedKeplerProps, theme);
97
+ // The legend is rendered as a draggable, portaled overlay so the
98
+ // BottomWidget should not shrink to reserve space for it. Mask
99
+ // mapLegend.active so the upstream spaceForLegendWidth stays 0.
100
+ return {
101
+ ...fields,
102
+ uiState: {
103
+ ...fields.uiState,
104
+ mapControls: {
105
+ ...fields.uiState.mapControls,
106
+ mapLegend: {
107
+ ...fields.uiState.mapControls?.mapLegend,
108
+ show: fields.uiState.mapControls?.mapLegend?.show ?? false,
109
+ active: false,
110
+ },
111
+ },
112
+ },
113
+ };
114
+ }, [hasFilters, hasAnimatableLayers, mergedKeplerProps, theme]);
115
+ const modalPortalNode = useMemo(() => {
116
+ if (modalPortalTarget === 'body') {
117
+ return typeof document !== 'undefined' ? document.body : null;
118
+ }
119
+ return containerNode;
120
+ }, [modalPortalTarget, containerNode]);
83
121
  const modalContainerFields = keplerState?.visState
84
- ? modalContainerSelector(mergedKeplerProps, containerNode)
122
+ ? modalContainerSelector(mergedKeplerProps, modalPortalNode)
85
123
  : null;
86
124
  const mapboxApiAccessToken = mapFields?.mapStyle?.mapboxApiAccessToken ||
87
125
  basicKeplerProps?.mapboxApiAccessToken;
88
- return (_jsx(RootContext.Provider, { value: containerRef, children: _jsxs(CustomWidgetcontainer, { ref: containerRef, className: "kepler-gl relative flex h-full w-full flex-col justify-between", children: [mapFields?.mapState ? (_jsx(MapViewStateContextProvider, { mapState: mapFields.mapState, children: _jsx(MapContainer, { primary: true, containerId: 0, index: 0, ...mapFields, mapboxApiAccessToken: mapboxApiAccessToken || '' }, 0) })) : null, geoCoderPanelFields && interactionConfig?.geocoder?.enabled ? (_jsx(GeoCoderPanel, { ...geoCoderPanelFields, index: 0, unsyncedViewports: false, mapboxApiAccessToken: mapboxApiAccessToken || '' })) : null, size && bottomWidgetFields ? (_jsx(BottomWidget, { rootRef: bottomWidgetRef, ...bottomWidgetFields, theme: theme, containerW: size?.width })) : null, size && size.width && size.height && modalContainerFields ? (_jsx(ModalContainer, { ...modalContainerFields, containerW: size?.width, containerH: size?.height })) : null] }) }));
126
+ return (_jsx(RootContext.Provider, { value: containerRef, children: _jsxs(CustomWidgetcontainer, { ref: containerRef, className: "kepler-gl relative flex h-full w-full flex-col justify-between", children: [isSplit && mapFieldsSplit ? (_jsx(SplitMapsContainer, { children: _jsx(MapViewStateContextProvider, { mapState: (mapFieldsSplit[0]?.mapState ??
127
+ mapFields?.mapState), children: mapFieldsSplit.map((fields, index) => (_jsx(SplitMapIndexContext.Provider, { value: index, children: _jsx(MapContainer, { index: index, primary: index === 1, containerId: index, ...fields, mapboxApiAccessToken: mapboxApiAccessToken || '' }) }, index))) }) })) : mapFields?.mapState ? (_jsx(MapViewStateContextProvider, { mapState: mapFields.mapState, children: _jsx(MapContainer, { primary: true, containerId: 0, index: 0, ...mapFields, mapboxApiAccessToken: mapboxApiAccessToken || '' }, 0) })) : null, geoCoderPanelFields && interactionConfig?.geocoder?.enabled ? (_jsx(GeoCoderPanel, { ...geoCoderPanelFields, index: 0, unsyncedViewports: false, mapboxApiAccessToken: mapboxApiAccessToken || '' })) : null, size && bottomWidgetFields ? (_jsx(BottomWidget, { rootRef: bottomWidgetRef, ...bottomWidgetFields, theme: theme, containerW: size?.width })) : null, size && size.width && size.height && modalContainerFields ? (_jsx(ModalContainer, { ...modalContainerFields, containerW: size?.width, containerH: size?.height })) : null] }) }));
89
128
  };
90
129
  export const KeplerMapContainer = ({ mapId }) => {
91
130
  return (_jsx(KeplerProvider, { mapId: mapId, children: _jsx(KeplerGl, { mapId: mapId }) }));