@sqlrooms/kepler 0.29.0-rc.6 → 0.29.0-rc.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +2 -1
- package/README.md +121 -4
- package/dist/KeplerSlice.d.ts +58 -2
- package/dist/KeplerSlice.d.ts.map +1 -1
- package/dist/KeplerSlice.js +152 -24
- package/dist/KeplerSlice.js.map +1 -1
- package/dist/components/CustomFilterManager.d.ts.map +1 -1
- package/dist/components/CustomFilterManager.js +16 -4
- package/dist/components/CustomFilterManager.js.map +1 -1
- package/dist/components/CustomLayerManager.d.ts.map +1 -1
- package/dist/components/CustomLayerManager.js +23 -110
- package/dist/components/CustomLayerManager.js.map +1 -1
- package/dist/components/CustomMapLegendPanel.d.ts +1 -1
- package/dist/components/CustomMapLegendPanel.d.ts.map +1 -1
- package/dist/components/CustomMapLegendPanel.js +14 -6
- package/dist/components/CustomMapLegendPanel.js.map +1 -1
- package/dist/components/CustomSourceDataSelector.d.ts +18 -0
- package/dist/components/CustomSourceDataSelector.d.ts.map +1 -0
- package/dist/components/CustomSourceDataSelector.js +130 -0
- package/dist/components/CustomSourceDataSelector.js.map +1 -0
- 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 +9 -2
- package/dist/components/KeplerMapContainer.js.map +1 -1
- package/dist/components/KeplerProvider.d.ts.map +1 -1
- package/dist/components/KeplerProvider.js +3 -1
- package/dist/components/KeplerProvider.js.map +1 -1
- package/dist/components/KeplerTableSourceSelector.d.ts +20 -0
- package/dist/components/KeplerTableSourceSelector.d.ts.map +1 -0
- package/dist/components/KeplerTableSourceSelector.js +21 -0
- package/dist/components/KeplerTableSourceSelector.js.map +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/keplerTableSelection.d.ts +142 -0
- package/dist/keplerTableSelection.d.ts.map +1 -0
- package/dist/keplerTableSelection.js +231 -0
- package/dist/keplerTableSelection.js.map +1 -0
- package/dist/styles/theme.d.ts +12 -0
- package/dist/styles/theme.d.ts.map +1 -1
- package/dist/styles/theme.js +12 -0
- package/dist/styles/theme.js.map +1 -1
- package/package.json +13 -7
|
@@ -1 +1 @@
|
|
|
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/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;AACxC,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAGlD,MAAM,SAAS,GAAG,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;AACrD,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,wBAAwB,CAAC,CAAC;AACrE,MAAM,UAAU,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;AAEvD,MAAM,kBAAkB,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE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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};\ntype TypeaheadListItemComponent =\n (typeof Typeahead.defaultProps)['customListItemComponent'];\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={\n TableListItem as unknown as TypeaheadListItemComponent\n }\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"]}
|
|
1
|
+
{"version":3,"file":"CustomLayerManager.js","sourceRoot":"","sources":["../../src/components/CustomLayerManager.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAC,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AACnC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAC,kBAAkB,EAAE,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAAC,oBAAoB,EAAC,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAEL,qBAAqB,GACtB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,6BAA6B,GAG9B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAC,yBAAyB,EAAC,MAAM,6BAA6B,CAAC;AAEtE,MAAM,SAAS,GAAG,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;AACrD,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,wBAAwB,CAAC,CAAC;AACrE,MAAM,UAAU,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;AAEvD,MAAM,kBAAkB,GAAG,cAAc,CAA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,QAAQ,GACvC,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, useState} from 'react';\nimport {useIntl} from 'react-intl';\nimport styled from 'styled-components';\n\nimport {\n LayerListFactory,\n DatasetLayerGroupFactory,\n PanelTitleFactory,\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';\nimport {Plus} from 'lucide-react';\nimport {Button} from '@sqlrooms/ui';\n\nimport {getKeplerFactory} from './KeplerInjector';\nimport {\n KeplerActions,\n useKeplerStateActions,\n} from '../hooks/useKeplerStateActions';\nimport {\n buildKeplerTableSourceOptions,\n type KeplerSourceDataset,\n type KeplerTableSourceOption,\n} from '../keplerTableSelection';\nimport {useStoreWithKepler} from '../KeplerSlice';\nimport type {RGBColor} from '@kepler.gl/types';\nimport {KeplerTableSourceSelector} from './KeplerTableSourceSelector';\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\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 datasets: Record<string, KeplerSourceDataset>;\n disabled?: boolean;\n}> = ({onAdd, datasets, disabled}) => {\n const [isAdding, setIsAdding] = useState(false);\n const intl = useIntl();\n\n const dbTables = useStoreWithKepler((state) => state.db.tables);\n const tableSelection = useStoreWithKepler(\n (state) => state.kepler.tableSelection,\n );\n\n const options = useMemo(() => {\n return buildKeplerTableSourceOptions({\n dbTables,\n datasets,\n tableSelection,\n });\n }, [datasets, dbTables, tableSelection]);\n\n const handleSelect = useCallback(\n (option: KeplerTableSourceOption) => {\n setIsAdding(true);\n onAdd(option.value)\n .catch((e) => console.error('Failed to add layer:', e))\n .finally(() => setIsAdding(false));\n },\n [onAdd],\n );\n\n return (\n <KeplerTableSourceSelector\n disabled={!options.length || disabled || isAdding}\n options={options}\n popoverAlign=\"end\"\n searchPlaceholder={\n intl ? intl.formatMessage({id: 'placeholder.search'}) : 'Search'\n }\n onSelect={handleSelect}\n renderTrigger={({disabled: isDisabled}) => (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"xs\"\n className=\"add-layer-button\"\n disabled={isDisabled}\n >\n <Plus className=\"h-3.5 w-3.5\" />\n {intl.formatMessage({id: 'layerManager.addLayer'})}\n </Button>\n )}\n />\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 onAddTableLayer = useCallback(\n async (tableName: string) => {\n const keplerDatasets = keplerState?.visState.datasets;\n if (!keplerDatasets?.[tableName]) {\n await addTableToMap({\n mapId,\n tableName,\n options: {\n autoCreateLayers: true,\n centerMap: true,\n },\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 datasets={keplerState.visState.datasets}\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,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MapControlTooltipFactory, MapControlPanelFactory, MapLegendFactory, MapLegendPanelFactory } from '@kepler.gl/components';
|
|
2
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
4
|
var deps: (typeof MapControlTooltipFactory | typeof MapControlPanelFactory | typeof MapLegendFactory)[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomMapLegendPanel.d.ts","sourceRoot":"","sources":["../../src/components/CustomMapLegendPanel.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,sBAAsB,EACtB,
|
|
1
|
+
{"version":3,"file":"CustomMapLegendPanel.d.ts","sourceRoot":"","sources":["../../src/components/CustomMapLegendPanel.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,wBAAwB,EACxB,sBAAsB,EACtB,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,CAsE1C;yBA1Ee,2BAA2B"}
|
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
3
|
import { Icons, MapControlButton, MapLegendPanelFactory, } from '@kepler.gl/components';
|
|
4
4
|
CustomMapLegendPanelFactory.deps = MapLegendPanelFactory.deps;
|
|
5
5
|
export function CustomMapLegendPanelFactory(MapControlTooltip, MapControlPanel, MapLegend) {
|
|
6
6
|
const OriginalMapLegendPanel = MapLegendPanelFactory(MapControlTooltip, MapControlPanel, MapLegend);
|
|
7
7
|
const SplitPaneLegend = (props) => {
|
|
8
|
-
const [isActive, setIsActive] = useState(false);
|
|
9
8
|
const mapLegend = props.mapControls?.mapLegend;
|
|
9
|
+
const isActive = mapLegend?.active;
|
|
10
|
+
const { onToggleMapControl } = props;
|
|
10
11
|
const toggleLegend = useCallback((e) => {
|
|
11
12
|
e?.preventDefault();
|
|
12
|
-
|
|
13
|
-
}, []);
|
|
13
|
+
onToggleMapControl('mapLegend');
|
|
14
|
+
}, [onToggleMapControl]);
|
|
14
15
|
if (!mapLegend?.show)
|
|
15
16
|
return null;
|
|
16
|
-
|
|
17
|
+
// The secondary (right) pane only shows the toggle button
|
|
18
|
+
if (props.mapIndex !== 0) {
|
|
19
|
+
return (_jsx(MapControlTooltip, { id: "show-legend", message: isActive ? 'tooltip.hideLegend' : 'tooltip.showLegend', children: _jsx(MapControlButton, { className: "map-control-button show-legend", active: isActive, onClick: toggleLegend, children: _jsx(Icons.Legend, { height: "22px" }) }) }));
|
|
20
|
+
}
|
|
21
|
+
// Primary (left) pane: render the full draggable legend panel
|
|
22
|
+
// (OriginalMapLegendPanel handles DraggableLegend + createPortal,
|
|
23
|
+
// and MapControlPanel renders "Unlock Viewport" / "Sync Zoom" in its header)
|
|
24
|
+
return (_jsxs(_Fragment, { children: [_jsx("style", { children: `.draggable-legend .map-control__panel-header:not(.map-control__panel-split-viewport-tools) { display: none !important; }` }), _jsx(OriginalMapLegendPanel, { ...props })] }));
|
|
17
25
|
};
|
|
18
26
|
const CustomMapLegendPanel = (props) => {
|
|
19
27
|
if (props.isSplit) {
|
|
20
28
|
return _jsx(SplitPaneLegend, { ...props });
|
|
21
29
|
}
|
|
22
|
-
return (_jsxs(_Fragment, { children: [_jsx("style", { children: `.draggable-legend .map-control__panel-header { display: none !important; }` }), _jsx(OriginalMapLegendPanel, { ...props })] }));
|
|
30
|
+
return (_jsxs(_Fragment, { children: [_jsx("style", { children: `.draggable-legend .map-control__panel-header:not(.map-control__panel-split-viewport-tools) { display: none !important; }` }), _jsx(OriginalMapLegendPanel, { ...props })] }));
|
|
23
31
|
};
|
|
24
32
|
CustomMapLegendPanel.displayName = 'CustomMapLegendPanel';
|
|
25
33
|
return CustomMapLegendPanel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomMapLegendPanel.js","sourceRoot":"","sources":["../../src/components/CustomMapLegendPanel.tsx"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"CustomMapLegendPanel.js","sourceRoot":"","sources":["../../src/components/CustomMapLegendPanel.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAC,WAAW,EAAC,MAAM,OAAO,CAAC;AACzC,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,KAAmE,EACnE,EAAE;QACF,MAAM,SAAS,GAAG,KAAK,CAAC,WAAW,EAAE,SAAS,CAAC;QAC/C,MAAM,QAAQ,G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CAAC;AAC9B,CAAC","sourcesContent":["import React, {useCallback} from 'react';\nimport {\n Icons,\n MapControlButton,\n MapControlTooltipFactory,\n MapControlPanelFactory,\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; isSplit?: boolean},\n ) => {\n const mapLegend = props.mapControls?.mapLegend;\n const isActive = mapLegend?.active;\n const {onToggleMapControl} = props;\n\n const toggleLegend = useCallback(\n (e?: React.MouseEvent) => {\n e?.preventDefault();\n onToggleMapControl('mapLegend');\n },\n [onToggleMapControl],\n );\n\n if (!mapLegend?.show) return null;\n\n // The secondary (right) pane only shows the toggle button\n if (props.mapIndex !== 0) {\n return (\n <MapControlTooltip\n id=\"show-legend\"\n message={isActive ? 'tooltip.hideLegend' : 'tooltip.showLegend'}\n >\n <MapControlButton\n className=\"map-control-button show-legend\"\n active={isActive}\n onClick={toggleLegend}\n >\n <Icons.Legend height=\"22px\" />\n </MapControlButton>\n </MapControlTooltip>\n );\n }\n\n // Primary (left) pane: render the full draggable legend panel\n // (OriginalMapLegendPanel handles DraggableLegend + createPortal,\n // and MapControlPanel renders \"Unlock Viewport\" / \"Sync Zoom\" in its header)\n return (\n <>\n <style>{`.draggable-legend .map-control__panel-header:not(.map-control__panel-split-viewport-tools) { display: none !important; }`}</style>\n <OriginalMapLegendPanel {...props} />\n </>\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:not(.map-control__panel-split-viewport-tools) { display: none !important; }`}</style>\n <OriginalMapLegendPanel {...props} />\n </>\n );\n };\n\n CustomMapLegendPanel.displayName = 'CustomMapLegendPanel';\n return CustomMapLegendPanel;\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SourceDataSelectorProps } from '@kepler.gl/components';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
type SourceDataSelectorContent = React.ComponentType<SourceDataSelectorProps>;
|
|
4
|
+
type CustomSourceDataSelectorProps = SourceDataSelectorProps & {
|
|
5
|
+
id?: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Kepler uses the same SourceDataSelector in layer config and filter config.
|
|
9
|
+
* Layer config passes a layer id, so only that version includes unloaded
|
|
10
|
+
* SQLRooms table options. Filter selectors use the same UI with loaded Kepler
|
|
11
|
+
* datasets only because a filter needs a loaded dataset to expose fields.
|
|
12
|
+
*/
|
|
13
|
+
export declare function CustomSourceDataSelectorFactory(_DataSourceSelectorContent: SourceDataSelectorContent): React.FC<CustomSourceDataSelectorProps>;
|
|
14
|
+
export declare namespace CustomSourceDataSelectorFactory {
|
|
15
|
+
var deps: typeof import("@kepler.gl/components/dist/side-panel/common/source-data-selector-content").default[];
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=CustomSourceDataSelector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomSourceDataSelector.d.ts","sourceRoot":"","sources":["../../src/components/CustomSourceDataSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAuC,MAAM,OAAO,CAAC;AAW5D,KAAK,yBAAyB,GAAG,KAAK,CAAC,aAAa,CAAC,uBAAuB,CAAC,CAAC;AAC9E,KAAK,6BAA6B,GAAG,uBAAuB,GAAG;IAC7D,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAyCF;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,0BAA0B,EAAE,yBAAyB,GACpD,KAAK,CAAC,EAAE,CAAC,6BAA6B,CAAC,CAoJzC;yBAtJe,+BAA+B"}
|
|
@@ -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;AAC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BAC7D,MAAM,YAAY,GAAG,cAAc,EAAE,KAAK,IAAI,aAAa,CAAC;wBAC5D,MAAM,YAAY,GAAG,cAAc,EAAE,KAAK,IAAI,aAAa,CAAC;wBAE5D,OAAO,CACL,MAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,WAAW,EACnB,SAAS,EAAE,EAAE,CACX,SAAS,EACT,kFAAkF,CACnF,EACD,QAAQ,EAAE,eAAe,aAEzB,eACE,SAAS,EAAC,sBAAsB,EAChC,KAAK,EAAE;wCACL,eAAe,EAAE,OAAO,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG;qCAClD,GACD,EACF,eAAM,SAAS,EAAC,kBAAkB,YAAE,YAAY,GAAQ,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeplerInjector.d.ts","sourceRoot":"","sources":["../../src/components/KeplerInjector.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"KeplerInjector.d.ts","sourceRoot":"","sources":["../../src/components/KeplerInjector.tsx"],"names":[],"mappings":"AAAA,OAAO,EAeL,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAA0B,MAAM,OAAO,CAAC;AAS/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,EAAE,aAAa,CAAC,CAAC;AACjE,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,SAAS,CAAC;AAyG3D,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,mBAAmB,EAAE,EAC9B,OAAO,GAAE;IAAC,IAAI,CAAC,EAAE,uBAAuB,CAAA;CAAM,QAM/C;AAED,wBAAgB,0BAA0B,SAGzC;AAED,wBAAgB,iBAAiB,iBAEhC;AAeD,wBAAgB,gBAAgB,CAAC,QAAQ,SAAS,aAAa,EAC7D,OAAO,EAAE,QAAQ,GAChB,UAAU,CAAC,QAAQ,CAAC,CA+BtB;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc;QACrB,QAAQ,SAAS,aAAa,WAAW,QAAQ;CAGtD,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { AddDataButtonFactory, ContainerFactory, injector as createInjector, DndContextFactory, FilterPanelHeaderFactory, flattenDeps, MapControlTooltipFactory, MapDrawPanelFactory, 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
6
|
import { CustomMapDrawPanelFactory } from './CustomMapDrawPanel';
|
|
7
7
|
import { CustomMapLegendFactory } from './CustomMapLegend';
|
|
8
8
|
import { CustomMapLegendPanelFactory } from './CustomMapLegendPanel';
|
|
9
|
+
import { CustomSourceDataSelectorFactory } from './CustomSourceDataSelector';
|
|
9
10
|
export const CustomAddDataButtonFactory = () => {
|
|
10
11
|
return () => null;
|
|
11
12
|
};
|
|
@@ -22,6 +23,7 @@ const defaultRecipes = [
|
|
|
22
23
|
[MapLegendFactory, CustomMapLegendFactory],
|
|
23
24
|
[MapControlTooltipFactory, CustomMapControlTooltipFactory],
|
|
24
25
|
[MapDrawPanelFactory, CustomMapDrawPanelFactory],
|
|
26
|
+
[SourceDataSelectorFactory, CustomSourceDataSelectorFactory],
|
|
25
27
|
];
|
|
26
28
|
let customRecipes = [];
|
|
27
29
|
let injector = createKeplerInjector();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeplerInjector.js","sourceRoot":"","sources":["../../src/components/KeplerInjector.t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,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 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';\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];\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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D,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;YACpC,CAAC;YACD,mHAAmH;YACnH,OAAO,KAAC,SAAS,OAAK,KAAK,GAAI,CAAC;QAClC,CAAC,CAAC;QAEF,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,IAAI,WAAW,CAAC;QAChD,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;
|
|
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"}
|
|
@@ -49,9 +49,10 @@ const KeplerGl = ({ mapId }) => {
|
|
|
49
49
|
const [containerNode, setContainerNode] = useState(null);
|
|
50
50
|
const theme = useTheme();
|
|
51
51
|
const basicKeplerProps = useStoreWithKepler((state) => state.kepler.basicKeplerProps);
|
|
52
|
+
const modalPortalTarget = useStoreWithKepler((state) => state.kepler.modalPortalTarget);
|
|
52
53
|
const { keplerActions, keplerState } = useKeplerStateActions({ mapId });
|
|
53
54
|
const interactionConfig = keplerState?.visState?.interactionConfig;
|
|
54
|
-
// Capture
|
|
55
|
+
// Capture container DOM node outside of render for portal use
|
|
55
56
|
useEffect(() => {
|
|
56
57
|
setContainerNode(containerRef.current);
|
|
57
58
|
}, [containerRef]);
|
|
@@ -111,8 +112,14 @@ const KeplerGl = ({ mapId }) => {
|
|
|
111
112
|
},
|
|
112
113
|
};
|
|
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]);
|
|
114
121
|
const modalContainerFields = keplerState?.visState
|
|
115
|
-
? modalContainerSelector(mergedKeplerProps,
|
|
122
|
+
? modalContainerSelector(mergedKeplerProps, modalPortalNode)
|
|
116
123
|
: null;
|
|
117
124
|
const mapboxApiAccessToken = mapFields?.mapStyle?.mapboxApiAccessToken ||
|
|
118
125
|
basicKeplerProps?.mapboxApiAccessToken;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeplerMapContainer.js","sourceRoot":"","sources":["../../src/components/KeplerMapContainer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAK,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE/D,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACn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,IACc,GACH,CACxB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAE1B,CAAC,EAAC,KAAK,EAAC,EAAE,EAAE;IACf,OAAO,CACL,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,YAC1B,KAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,GAAI,GACX,CAClB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {FC, useMemo, useRef, useEffect, useState} from 'react';\n\nimport {\n MapContainerFactory,\n BottomWidgetFactory,\n GeocoderPanelFactory,\n mapFieldsSelector,\n bottomWidgetSelector,\n geoCoderPanelSelector,\n modalContainerSelector,\n MapViewStateContextProvider,\n RootContext,\n ModalContainerFactory,\n} from '@kepler.gl/components';\nimport {useDimensions, getAnimatableVisibleLayers} from '@kepler.gl/utils';\nimport styled, {useTheme} from 'styled-components';\n\nimport {getKeplerFactory} from './KeplerInjector';\nimport {KeplerProvider} from './KeplerProvider';\nimport {useKeplerStateActions} from '../hooks/useKeplerStateActions';\nimport {useStoreWithKepler} from '../KeplerSlice';\nimport {SplitMapIndexContext} from './SplitMapIndexContext';\n\nconst MapContainer = getKeplerFactory(MapContainerFactory);\nconst BottomWidget = getKeplerFactory(BottomWidgetFactory);\nconst GeoCoderPanel = getKeplerFactory(GeocoderPanelFactory);\nconst ModalContainer = getKeplerFactory(ModalContainerFactory);\n\nconst DEFAULT_DIMENSIONS = {\n width: 0,\n height: 0,\n};\nconst KEPLER_PROPS = {\n mapboxApiUrl: 'https://api.mapbox.com',\n appName: 'kepler.gl',\n sidePanelWidth: 0,\n};\n// overide kepler default style\nconst CustomWidgetcontainer = styled.div`\n .bottom-widget--inner {\n margin-top: 0;\n }\n\n .map-popover {\n z-index: 50;\n }\n\n /* Remove top margin from Trip layer timeline */\n .kepler-gl .bottom-widget--container .animation-control-container,\n .bottom-widget--container .animation-control-container {\n margin-top: 0 !important;\n }\n`;\n\nconst SplitMapsContainer = styled.div`\n display: flex;\n width: 100%;\n height: 100%;\n position: relative;\n`;\n\ntype KeplerGLProps = Parameters<typeof geoCoderPanelSelector>[0];\n\nconst KeplerGl: FC<{\n mapId: string;\n}> = ({mapId}) => {\n const bottomWidgetRef = useRef(null);\n const [containerRef, size] = useDimensions<HTMLDivElement>();\n const [containerNode, setContainerNode] = useState<HTMLElement | null>(null);\n const theme = useTheme();\n const basicKeplerProps = useStoreWithKepler(\n (state) => state.kepler.basicKeplerProps,\n );\n\n const {keplerActions, keplerState} = useKeplerStateActions({mapId});\n const interactionConfig = keplerState?.visState?.interactionConfig;\n\n // Capture the current container DOM node outside of render logic\n useEffect(() => {\n setContainerNode(containerRef.current);\n }, [containerRef]);\n\n // Update export image settings when size changes\n useEffect(() => {\n if (size?.width && size?.height) {\n keplerActions.uiStateActions.setExportImageSetting({\n mapW: size.width,\n mapH: size.height,\n });\n }\n }, [size?.width, size?.height, keplerActions.uiStateActions]);\n\n const mergedKeplerProps = useMemo(() => {\n return {\n ...KEPLER_PROPS,\n ...keplerState,\n ...keplerActions,\n id: mapId,\n } as KeplerGLProps;\n }, [keplerState, keplerActions, mapId]);\n const geoCoderPanelFields = keplerState?.visState\n ? geoCoderPanelSelector(\n mergedKeplerProps,\n // dont need height\n size || DEFAULT_DIMENSIONS,\n )\n : null;\n\n const splitMaps = keplerState?.visState?.splitMaps;\n const isSplit = splitMaps && splitMaps.length > 1;\n\n const mapFields = useMemo(\n () => (keplerState?.visState ? mapFieldsSelector(mergedKeplerProps) : null),\n [keplerState, mergedKeplerProps],\n );\n const mapFieldsSplit = useMemo(\n () =>\n isSplit && keplerState?.visState\n ? splitMaps.map((_, index) =>\n mapFieldsSelector(mergedKeplerProps, index),\n )\n : null,\n [keplerState, mergedKeplerProps, isSplit, splitMaps],\n );\n\n // Check if there are filters or animatable layers (e.g., Trip layers)\n const hasFilters = Boolean(keplerState?.visState.filters?.length);\n const hasAnimatableLayers = useMemo(() => {\n const layers = keplerState?.visState?.layers || [];\n return getAnimatableVisibleLayers(layers).length > 0;\n }, [keplerState?.visState?.layers]);\n\n const bottomWidgetFields = useMemo(() => {\n if (!hasFilters && !hasAnimatableLayers) return null;\n const fields = bottomWidgetSelector(mergedKeplerProps, theme);\n // The legend is rendered as a draggable, portaled overlay so the\n // BottomWidget should not shrink to reserve space for it. Mask\n // mapLegend.active so the upstream spaceForLegendWidth stays 0.\n return {\n ...fields,\n uiState: {\n ...fields.uiState,\n mapControls: {\n ...fields.uiState.mapControls,\n mapLegend: {\n ...fields.uiState.mapControls?.mapLegend,\n show: fields.uiState.mapControls?.mapLegend?.show ?? false,\n active: false,\n },\n },\n },\n };\n }, [hasFilters, hasAnimatableLayers, mergedKeplerProps, theme]);\n\n const modalContainerFields = keplerState?.visState\n ? modalContainerSelector(mergedKeplerProps, containerNode)\n : null;\n\n const mapboxApiAccessToken =\n mapFields?.mapStyle?.mapboxApiAccessToken ||\n basicKeplerProps?.mapboxApiAccessToken;\n return (\n <RootContext.Provider value={containerRef}>\n <CustomWidgetcontainer\n ref={containerRef}\n className=\"kepler-gl relative flex h-full w-full flex-col justify-between\"\n >\n {isSplit && mapFieldsSplit ? (\n <SplitMapsContainer>\n <MapViewStateContextProvider\n mapState={\n (mapFieldsSplit[0]?.mapState ??\n mapFields?.mapState) as NonNullable<\n typeof mapFields\n >['mapState']\n }\n >\n {mapFieldsSplit.map((fields, index) => (\n <SplitMapIndexContext.Provider key={index} value={index}>\n <MapContainer\n index={index}\n primary={index === 1}\n containerId={index}\n {...fields}\n mapboxApiAccessToken={mapboxApiAccessToken || ''}\n />\n </SplitMapIndexContext.Provider>\n ))}\n </MapViewStateContextProvider>\n </SplitMapsContainer>\n ) : mapFields?.mapState ? (\n <MapViewStateContextProvider mapState={mapFields.mapState}>\n <MapContainer\n primary={true}\n containerId={0}\n key={0}\n index={0}\n {...mapFields}\n mapboxApiAccessToken={mapboxApiAccessToken || ''}\n />\n </MapViewStateContextProvider>\n ) : null}\n {geoCoderPanelFields && interactionConfig?.geocoder?.enabled ? (\n <GeoCoderPanel\n {...geoCoderPanelFields}\n index={0}\n unsyncedViewports={false}\n mapboxApiAccessToken={mapboxApiAccessToken || ''}\n />\n ) : null}\n {size && bottomWidgetFields ? (\n <BottomWidget\n rootRef={bottomWidgetRef}\n {...bottomWidgetFields}\n theme={theme}\n containerW={size?.width}\n />\n ) : null}\n {size && size.width && size.height && modalContainerFields ? (\n <ModalContainer\n {...modalContainerFields}\n containerW={size?.width}\n containerH={size?.height}\n />\n ) : null}\n </CustomWidgetcontainer>\n </RootContext.Provider>\n );\n};\n\nexport const KeplerMapContainer: FC<{\n mapId: string;\n}> = ({mapId}) => {\n return (\n <KeplerProvider mapId={mapId}>\n <KeplerGl mapId={mapId} />\n </KeplerProvider>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"KeplerMapContainer.js","sourceRoot":"","sources":["../../src/components/KeplerMapContainer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAK,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE/D,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,2BAA2B,EAC3B,WAAW,EACX,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAC,aAAa,EAAE,0BAA0B,EAAC,MAAM,kBAAkB,CAAC;AAC3E,OAAO,MAAM,EAAE,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAC,qBAAqB,EAAC,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAE5D,MAAM,YAAY,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C,cAAc,IAAC,KAAK,EAAE,KAAK,YAC1B,KAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,GAAI,GACX,CAClB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {FC, useMemo, useRef, useEffect, useState} from 'react';\n\nimport {\n MapContainerFactory,\n BottomWidgetFactory,\n GeocoderPanelFactory,\n mapFieldsSelector,\n bottomWidgetSelector,\n geoCoderPanelSelector,\n modalContainerSelector,\n MapViewStateContextProvider,\n RootContext,\n ModalContainerFactory,\n} from '@kepler.gl/components';\nimport {useDimensions, getAnimatableVisibleLayers} from '@kepler.gl/utils';\nimport styled, {useTheme} from 'styled-components';\n\nimport {getKeplerFactory} from './KeplerInjector';\nimport {KeplerProvider} from './KeplerProvider';\nimport {useKeplerStateActions} from '../hooks/useKeplerStateActions';\nimport {useStoreWithKepler} from '../KeplerSlice';\nimport {SplitMapIndexContext} from './SplitMapIndexContext';\n\nconst MapContainer = getKeplerFactory(MapContainerFactory);\nconst BottomWidget = getKeplerFactory(BottomWidgetFactory);\nconst GeoCoderPanel = getKeplerFactory(GeocoderPanelFactory);\nconst ModalContainer = getKeplerFactory(ModalContainerFactory);\n\nconst DEFAULT_DIMENSIONS = {\n width: 0,\n height: 0,\n};\nconst KEPLER_PROPS = {\n mapboxApiUrl: 'https://api.mapbox.com',\n appName: 'kepler.gl',\n sidePanelWidth: 0,\n};\n// overide kepler default style\nconst CustomWidgetcontainer = styled.div`\n .bottom-widget--inner {\n margin-top: 0;\n }\n\n .map-popover {\n z-index: 50;\n }\n\n /* Remove top margin from Trip layer timeline */\n .kepler-gl .bottom-widget--container .animation-control-container,\n .bottom-widget--container .animation-control-container {\n margin-top: 0 !important;\n }\n`;\n\nconst SplitMapsContainer = styled.div`\n display: flex;\n width: 100%;\n height: 100%;\n position: relative;\n`;\n\ntype KeplerGLProps = Parameters<typeof geoCoderPanelSelector>[0];\n\nconst KeplerGl: FC<{\n mapId: string;\n}> = ({mapId}) => {\n const bottomWidgetRef = useRef(null);\n const [containerRef, size] = useDimensions<HTMLDivElement>();\n const [containerNode, setContainerNode] = useState<HTMLElement | null>(null);\n const theme = useTheme();\n const basicKeplerProps = useStoreWithKepler(\n (state) => state.kepler.basicKeplerProps,\n );\n const modalPortalTarget = useStoreWithKepler(\n (state) => state.kepler.modalPortalTarget,\n );\n\n const {keplerActions, keplerState} = useKeplerStateActions({mapId});\n const interactionConfig = keplerState?.visState?.interactionConfig;\n\n // Capture container DOM node outside of render for portal use\n useEffect(() => {\n setContainerNode(containerRef.current);\n }, [containerRef]);\n\n // Update export image settings when size changes\n useEffect(() => {\n if (size?.width && size?.height) {\n keplerActions.uiStateActions.setExportImageSetting({\n mapW: size.width,\n mapH: size.height,\n });\n }\n }, [size?.width, size?.height, keplerActions.uiStateActions]);\n\n const mergedKeplerProps = useMemo(() => {\n return {\n ...KEPLER_PROPS,\n ...keplerState,\n ...keplerActions,\n id: mapId,\n } as KeplerGLProps;\n }, [keplerState, keplerActions, mapId]);\n const geoCoderPanelFields = keplerState?.visState\n ? geoCoderPanelSelector(\n mergedKeplerProps,\n // dont need height\n size || DEFAULT_DIMENSIONS,\n )\n : null;\n\n const splitMaps = keplerState?.visState?.splitMaps;\n const isSplit = splitMaps && splitMaps.length > 1;\n\n const mapFields = useMemo(\n () => (keplerState?.visState ? mapFieldsSelector(mergedKeplerProps) : null),\n [keplerState, mergedKeplerProps],\n );\n const mapFieldsSplit = useMemo(\n () =>\n isSplit && keplerState?.visState\n ? splitMaps.map((_, index) =>\n mapFieldsSelector(mergedKeplerProps, index),\n )\n : null,\n [keplerState, mergedKeplerProps, isSplit, splitMaps],\n );\n\n // Check if there are filters or animatable layers (e.g., Trip layers)\n const hasFilters = Boolean(keplerState?.visState.filters?.length);\n const hasAnimatableLayers = useMemo(() => {\n const layers = keplerState?.visState?.layers || [];\n return getAnimatableVisibleLayers(layers).length > 0;\n }, [keplerState?.visState?.layers]);\n\n const bottomWidgetFields = useMemo(() => {\n if (!hasFilters && !hasAnimatableLayers) return null;\n const fields = bottomWidgetSelector(mergedKeplerProps, theme);\n // The legend is rendered as a draggable, portaled overlay so the\n // BottomWidget should not shrink to reserve space for it. Mask\n // mapLegend.active so the upstream spaceForLegendWidth stays 0.\n return {\n ...fields,\n uiState: {\n ...fields.uiState,\n mapControls: {\n ...fields.uiState.mapControls,\n mapLegend: {\n ...fields.uiState.mapControls?.mapLegend,\n show: fields.uiState.mapControls?.mapLegend?.show ?? false,\n active: false,\n },\n },\n },\n };\n }, [hasFilters, hasAnimatableLayers, mergedKeplerProps, theme]);\n\n const modalPortalNode = useMemo(() => {\n if (modalPortalTarget === 'body') {\n return typeof document !== 'undefined' ? document.body : null;\n }\n return containerNode;\n }, [modalPortalTarget, containerNode]);\n\n const modalContainerFields = keplerState?.visState\n ? modalContainerSelector(mergedKeplerProps, modalPortalNode)\n : null;\n\n const mapboxApiAccessToken =\n mapFields?.mapStyle?.mapboxApiAccessToken ||\n basicKeplerProps?.mapboxApiAccessToken;\n return (\n <RootContext.Provider value={containerRef}>\n <CustomWidgetcontainer\n ref={containerRef}\n className=\"kepler-gl relative flex h-full w-full flex-col justify-between\"\n >\n {isSplit && mapFieldsSplit ? (\n <SplitMapsContainer>\n <MapViewStateContextProvider\n mapState={\n (mapFieldsSplit[0]?.mapState ??\n mapFields?.mapState) as NonNullable<\n typeof mapFields\n >['mapState']\n }\n >\n {mapFieldsSplit.map((fields, index) => (\n <SplitMapIndexContext.Provider key={index} value={index}>\n <MapContainer\n index={index}\n primary={index === 1}\n containerId={index}\n {...fields}\n mapboxApiAccessToken={mapboxApiAccessToken || ''}\n />\n </SplitMapIndexContext.Provider>\n ))}\n </MapViewStateContextProvider>\n </SplitMapsContainer>\n ) : mapFields?.mapState ? (\n <MapViewStateContextProvider mapState={mapFields.mapState}>\n <MapContainer\n primary={true}\n containerId={0}\n key={0}\n index={0}\n {...mapFields}\n mapboxApiAccessToken={mapboxApiAccessToken || ''}\n />\n </MapViewStateContextProvider>\n ) : null}\n {geoCoderPanelFields && interactionConfig?.geocoder?.enabled ? (\n <GeoCoderPanel\n {...geoCoderPanelFields}\n index={0}\n unsyncedViewports={false}\n mapboxApiAccessToken={mapboxApiAccessToken || ''}\n />\n ) : null}\n {size && bottomWidgetFields ? (\n <BottomWidget\n rootRef={bottomWidgetRef}\n {...bottomWidgetFields}\n theme={theme}\n containerW={size?.width}\n />\n ) : null}\n {size && size.width && size.height && modalContainerFields ? (\n <ModalContainer\n {...modalContainerFields}\n containerW={size?.width}\n containerH={size?.height}\n />\n ) : null}\n </CustomWidgetcontainer>\n </RootContext.Provider>\n );\n};\n\nexport const KeplerMapContainer: FC<{\n mapId: string;\n}> = ({mapId}) => {\n return (\n <KeplerProvider mapId={mapId}>\n <KeplerGl mapId={mapId} />\n </KeplerProvider>\n );\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeplerProvider.d.ts","sourceRoot":"","sources":["../../src/components/KeplerProvider.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,iBAAiB,EAAU,MAAM,OAAO,CAAC;AASjD,KAAK,mBAAmB,GAAG,iBAAiB,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC;CACf,CAAC,CAAC;AAGH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"KeplerProvider.d.ts","sourceRoot":"","sources":["../../src/components/KeplerProvider.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,iBAAiB,EAAU,MAAM,OAAO,CAAC;AASjD,KAAK,mBAAmB,GAAG,iBAAiB,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC;CACf,CAAC,CAAC;AAGH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAiCxD,CAAC"}
|
|
@@ -10,6 +10,8 @@ import { Provider } from 'react-redux';
|
|
|
10
10
|
// Provide intl, theme, context, and redux store to the kepler
|
|
11
11
|
export const KeplerProvider = ({ children, mapId, }) => {
|
|
12
12
|
const reduxProviderStore = useStoreWithKepler((state) => state.kepler.__reduxProviderStore);
|
|
13
|
+
const keplerTheme = useStoreWithKepler((state) => state.kepler.keplerTheme);
|
|
14
|
+
const resolvedTheme = useMemo(() => keplerTheme ?? darkTheme, [keplerTheme]);
|
|
13
15
|
const keplerContext = useMemo(() => ({
|
|
14
16
|
selector: (state) => state[mapId],
|
|
15
17
|
id: mapId,
|
|
@@ -17,6 +19,6 @@ export const KeplerProvider = ({ children, mapId, }) => {
|
|
|
17
19
|
if (!reduxProviderStore) {
|
|
18
20
|
return null;
|
|
19
21
|
}
|
|
20
|
-
return (_jsx(IntlProvider, { locale: "en", messages: messages['en'], children: _jsx(Provider, { store: reduxProviderStore, children: _jsx(StyleSheetManager, { shouldForwardProp: shouldForwardProp, children: _jsx(ThemeProvider, { theme:
|
|
22
|
+
return (_jsx(IntlProvider, { locale: "en", messages: messages['en'], children: _jsx(Provider, { store: reduxProviderStore, children: _jsx(StyleSheetManager, { shouldForwardProp: shouldForwardProp, children: _jsx(ThemeProvider, { theme: resolvedTheme, children: _jsx(KeplerGlContext.Provider, { value: keplerContext, children: _jsx(_Fragment, { children: children }) }) }) }) }) }));
|
|
21
23
|
};
|
|
22
24
|
//# sourceMappingURL=KeplerProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeplerProvider.js","sourceRoot":"","sources":["../../src/components/KeplerProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAoB,OAAO,EAAC,MAAM,OAAO,CAAC;AACjD,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AACxC,OAAO,EAAC,aAAa,EAAE,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAqB,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAEtE,OAAO,EAAC,eAAe,EAAE,iBAAiB,EAAC,MAAM,u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AE,CAAC,WAAW,IAAI,SAAS,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAE7E,MAAM,aAAa,GAAG,OAAO,CAC3B,GAAG,EAAE,CAAC,CAAC;QACL,QAAQ,EAAE,CAAC,KAAyB,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC;QACrD,EAAE,EAAE,KAAK;KACV,CAAC,EACF,CAAC,KAAK,CAAC,CACR,CAAC;IACF,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,CACL,KAAC,YAAY,IAAC,MAAM,EAAC,IAAI,EAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,YAChD,KAAC,QAAQ,IAAC,KAAK,EAAE,kBAAkB,YACjC,KAAC,iBAAiB,IAAC,iBAAiB,EAAE,iBAAiB,YACrD,KAAC,aAAa,IAAC,KAAK,EAAE,aAAa,YACjC,KAAC,eAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,aAAa,YAC5C,4BAAG,QAAQ,GAAI,GACU,GACb,GACE,GACX,GACE,CAChB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {messages} from '@kepler.gl/localization';\nimport {PropsWithChildren, useMemo} from 'react';\nimport {IntlProvider} from 'react-intl';\nimport {ThemeProvider, StyleSheetManager} from 'styled-components';\nimport {KeplerGlReduxState, useStoreWithKepler} from '../KeplerSlice';\n\nimport {KeplerGlContext, shouldForwardProp} from '@kepler.gl/components';\nimport {darkTheme} from '../styles/theme';\nimport {Provider} from 'react-redux';\n\ntype KeplerProviderProps = PropsWithChildren<{\n mapId: string;\n}>;\n\n// Provide intl, theme, context, and redux store to the kepler\nexport const KeplerProvider: React.FC<KeplerProviderProps> = ({\n children,\n mapId,\n}) => {\n const reduxProviderStore = useStoreWithKepler(\n (state) => state.kepler.__reduxProviderStore,\n );\n const keplerTheme = useStoreWithKepler((state) => state.kepler.keplerTheme);\n const resolvedTheme = useMemo(() => keplerTheme ?? darkTheme, [keplerTheme]);\n\n const keplerContext = useMemo(\n () => ({\n selector: (state: KeplerGlReduxState) => state[mapId],\n id: mapId,\n }),\n [mapId],\n );\n if (!reduxProviderStore) {\n return null;\n }\n return (\n <IntlProvider locale=\"en\" messages={messages['en']}>\n <Provider store={reduxProviderStore}>\n <StyleSheetManager shouldForwardProp={shouldForwardProp}>\n <ThemeProvider theme={resolvedTheme}>\n <KeplerGlContext.Provider value={keplerContext}>\n <>{children}</>\n </KeplerGlContext.Provider>\n </ThemeProvider>\n </StyleSheetManager>\n </Provider>\n </IntlProvider>\n );\n};\n"]}
|