diff --git a/package.json b/package.json index dd23858c8..a2c0b0a6a 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "build-ci": "npm ci --workspaces --include-workspace-root --install-links", "test": "lerna run test --parallel --no-bail", "watch": "lerna run watch --parallel --stream", - "lint": "lerna run lint:prettier:check,lint:eslint:check --parallel --no-bail", + "lint": "lerna run lint:prettier:check,lint:eslint:check,lint:svelte:check --parallel --no-bail", "lint:fix": "lerna run lint:prettier:fix,lint:eslint:fix --parallel --no-bail", "build-package-lock": "lerna run build-package-lock", "storybook": "lerna run --scope=@opendatasoft/visualizations-react storybook" diff --git a/packages/visualizations-react/src/index.ts b/packages/visualizations-react/src/index.ts index 72ee97818..481e1be5c 100644 --- a/packages/visualizations-react/src/index.ts +++ b/packages/visualizations-react/src/index.ts @@ -16,7 +16,7 @@ import type { MarkdownTextProps, ChoroplethGeoJsonProps, ChoroplethVectorTilesProps, - MapPoiProps, + PoiMapProps, TableProps, } from '@opendatasoft/visualizations'; import reactifySvelte from 'reactify'; @@ -39,5 +39,5 @@ export const ChoroplethSvg = reactifySvelte( _ChoroplethSvg, 'ods-visualizations-choropleth-svg' ); -export const PoiMap = reactifySvelte(_PoiMap, 'ods-visualizations-poi-map'); +export const PoiMap = reactifySvelte(_PoiMap, 'ods-visualizations-poi-map'); export const Table = reactifySvelte(_Table, 'ods-visualizations-table'); diff --git a/packages/visualizations-react/stories/Poi/PoiMap.stories.tsx b/packages/visualizations-react/stories/Poi/PoiMap.stories.tsx index 2f78b9bf7..18cf127df 100644 --- a/packages/visualizations-react/stories/Poi/PoiMap.stories.tsx +++ b/packages/visualizations-react/stories/Poi/PoiMap.stories.tsx @@ -154,7 +154,7 @@ const meta: ComponentMeta = { export default meta; -const Template: ComponentStory = (args) => ( +const Template: ComponentStory = args => (
["value"]["sources"] = { cities : { type: 'geojson', data: { diff --git a/packages/visualizations-react/stories/Table/data.ts b/packages/visualizations-react/stories/Table/data.ts index e3017b246..527627f32 100644 --- a/packages/visualizations-react/stories/Table/data.ts +++ b/packages/visualizations-react/stories/Table/data.ts @@ -8,6 +8,7 @@ export default [ wordCount: 1200, readingTime: 5.5, url: 'https://example.com/lorem-ipsum', + geopoint: [2.357573,48.837904], }, { title: 'pellentesque nec blog post', @@ -19,6 +20,7 @@ export default [ wordCount: 800, readingTime: 3.8, url: 'https://example.com/pellentesque-nec', + geopoint: [2.357573,48.837904], }, { title: 'fusce sit amet blog post', @@ -30,6 +32,7 @@ export default [ wordCount: 1500, readingTime: 7.2, url: 'https://example.com/fusce-sit-amet', + geopoint: [2.357573,48.837904], }, { title: 'vestibulum nec blog post', @@ -40,6 +43,7 @@ export default [ wordCount: 1000, readingTime: 4.5, url: 'https://example.com/vestibulum-nec', + geopoint: [2.357573,48.837904], }, { title: 'Cras At Blog Post', @@ -51,6 +55,7 @@ export default [ wordCount: 1300, readingTime: 6.0, url: 'https://example.com/cras-at', + geopoint: [2.357573,48.837904], }, { title: 'Quisque A Blog Post', @@ -62,6 +67,7 @@ export default [ wordCount: 900, readingTime: 4.0, url: 'https://example.com/quisque-a', + geopoint: [2.357573,48.837904], }, { title: 'Ut Vitae Blog Post', @@ -73,6 +79,7 @@ export default [ wordCount: 1100, readingTime: 5.0, url: 'https://example.com/ut-vitae', + geopoint: [2.357573,48.837904], }, { title: 'Integer Id Blog Post', @@ -84,6 +91,7 @@ export default [ wordCount: 950, readingTime: 4.2, url: 'https://example.com/integer-id', + geopoint: [2.357573,48.837904], }, { title: 'Undefined row', @@ -94,6 +102,7 @@ export default [ wordCount: undefined, readingTime: null, url: undefined, + geopoint: undefined, }, { title: 'Empty row', diff --git a/packages/visualizations-react/stories/Table/options.ts b/packages/visualizations-react/stories/Table/options.ts index 4fe14796a..1a360a977 100644 --- a/packages/visualizations-react/stories/Table/options.ts +++ b/packages/visualizations-react/stories/Table/options.ts @@ -71,6 +71,43 @@ export const columns: Column[] = [ display: () => 'link', }, }, + { + title: 'Geo point', + key: 'geopoint', + dataFormat: 'geo', + options: { + mapOptions: { + style: 'https://demotiles.maplibre.org/style.json', + interactive: false, + }, + display: (v: unknown) => `longitude: ${(v as number[])[0]}, latitude: ${(v as number[])[1]}`, + sources: (coordinates: unknown) => ({ + 'table-stories' : { + type: 'geojson', + data: { + type: 'FeatureCollection', + features: [ + { + id: 1, + type: 'Feature', + geometry: { + type: 'Point', + coordinates, + }, + }, + ], + } + }, + }), + layers: () => ([{ + id:'table-stories-layer', + source: 'table-stories', + type: 'circle', + color: 'black', + borderColor: 'white', + }]) + }, + }, ]; const options: TableOptions = { diff --git a/packages/visualizations/src/components/Map/Svg/Choropleth.svelte b/packages/visualizations/src/components/ChoroplethMap/Svg/Choropleth.svelte similarity index 100% rename from packages/visualizations/src/components/Map/Svg/Choropleth.svelte rename to packages/visualizations/src/components/ChoroplethMap/Svg/Choropleth.svelte diff --git a/packages/visualizations/src/components/Map/Svg/Map.svelte b/packages/visualizations/src/components/ChoroplethMap/Svg/Map.svelte similarity index 100% rename from packages/visualizations/src/components/Map/Svg/Map.svelte rename to packages/visualizations/src/components/ChoroplethMap/Svg/Map.svelte diff --git a/packages/visualizations/src/components/Map/Svg/index.ts b/packages/visualizations/src/components/ChoroplethMap/Svg/index.ts similarity index 100% rename from packages/visualizations/src/components/Map/Svg/index.ts rename to packages/visualizations/src/components/ChoroplethMap/Svg/index.ts diff --git a/packages/visualizations/src/components/Map/Svg/types.ts b/packages/visualizations/src/components/ChoroplethMap/Svg/types.ts similarity index 100% rename from packages/visualizations/src/components/Map/Svg/types.ts rename to packages/visualizations/src/components/ChoroplethMap/Svg/types.ts diff --git a/packages/visualizations/src/components/Map/WebGl/ChoroplethGeoJson.svelte b/packages/visualizations/src/components/ChoroplethMap/WebGl/ChoroplethGeoJson.svelte similarity index 100% rename from packages/visualizations/src/components/Map/WebGl/ChoroplethGeoJson.svelte rename to packages/visualizations/src/components/ChoroplethMap/WebGl/ChoroplethGeoJson.svelte diff --git a/packages/visualizations/src/components/Map/WebGl/ChoroplethVectorTiles.svelte b/packages/visualizations/src/components/ChoroplethMap/WebGl/ChoroplethVectorTiles.svelte similarity index 100% rename from packages/visualizations/src/components/Map/WebGl/ChoroplethVectorTiles.svelte rename to packages/visualizations/src/components/ChoroplethMap/WebGl/ChoroplethVectorTiles.svelte diff --git a/packages/visualizations/src/components/Map/WebGl/MapRender.svelte b/packages/visualizations/src/components/ChoroplethMap/WebGl/MapRender.svelte similarity index 99% rename from packages/visualizations/src/components/Map/WebGl/MapRender.svelte rename to packages/visualizations/src/components/ChoroplethMap/WebGl/MapRender.svelte index ec02ee310..637c1e7ae 100644 --- a/packages/visualizations/src/components/Map/WebGl/MapRender.svelte +++ b/packages/visualizations/src/components/ChoroplethMap/WebGl/MapRender.svelte @@ -1,5 +1,3 @@ - - + +
+ {#if title || subtitle} +
+ {#if title} +

+ {title} +

+ {/if} + {#if subtitle} +

+ {subtitle} +

+ {/if} +
+ {/if} +
+ {#key options.style} + + {/key} +
+ {#if description} +

{description}

+ {/if} + {#if legend} + + {/if} + {#if sourceLink} + + {/if} +
+ + diff --git a/packages/visualizations/src/components/Map/Poi/constants.ts b/packages/visualizations/src/components/Map/Poi/constants.ts new file mode 100644 index 000000000..363c10060 --- /dev/null +++ b/packages/visualizations/src/components/Map/Poi/constants.ts @@ -0,0 +1,2 @@ +// eslint-disable-next-line import/prefer-default-export +export const DEFAULT_ASPECT_RATIO = 1; diff --git a/packages/visualizations/src/components/Map/Poi/index.ts b/packages/visualizations/src/components/Map/Poi/index.ts new file mode 100644 index 000000000..01da635af --- /dev/null +++ b/packages/visualizations/src/components/Map/Poi/index.ts @@ -0,0 +1,3 @@ +import PoiMap from './Poi.svelte'; + +export default PoiMap; diff --git a/packages/visualizations/src/components/Map/Poi/types.ts b/packages/visualizations/src/components/Map/Poi/types.ts new file mode 100644 index 000000000..64e41573a --- /dev/null +++ b/packages/visualizations/src/components/Map/Poi/types.ts @@ -0,0 +1,20 @@ +import type { Async } from '../../../types'; +import type { Source } from '../../types'; +import type { WebGlMapData, WebGlMapOptions } from '../WebGl/types'; +import type { CategoryLegend } from '../../Legend/types'; + +export type PoiMapData = Async; + +export type PoiMapOptions = WebGlMapOptions & { + title?: string; + subtitle?: string; + description?: string; + legend?: CategoryLegend; + /** Link button to source */ + sourceLink?: Source; +}; + +export type PoiMapProps = { + data: PoiMapData; + options: PoiMapOptions; +}; diff --git a/packages/visualizations/src/components/Map/WebGl/WebGl.svelte b/packages/visualizations/src/components/Map/WebGl/WebGl.svelte new file mode 100644 index 000000000..238aa0d7d --- /dev/null +++ b/packages/visualizations/src/components/Map/WebGl/WebGl.svelte @@ -0,0 +1,256 @@ + + +
+ + diff --git a/packages/visualizations/src/components/MapPoi/Map.ts b/packages/visualizations/src/components/Map/WebGl/WebGl.ts similarity index 99% rename from packages/visualizations/src/components/MapPoi/Map.ts rename to packages/visualizations/src/components/Map/WebGl/WebGl.ts index 0af0261d9..dc733d5aa 100644 --- a/packages/visualizations/src/components/MapPoi/Map.ts +++ b/packages/visualizations/src/components/Map/WebGl/WebGl.ts @@ -29,6 +29,7 @@ import { POPUP_WIDTH, POPUP_NAVIGATION_CONTROLS_OFFSET_CLASSNAME, DEFAULT_SORT_KEY_VALUE, + POPUP_DISPLAY, } from './constants'; import type { PopupConfigurationByLayers, @@ -36,7 +37,6 @@ import type { PopupDisplayTypes, Images, } from './types'; -import { POPUP_DISPLAY } from './types'; const CURSOR = { DEFAULT: 'default', diff --git a/packages/visualizations/src/components/MapPoi/constants.ts b/packages/visualizations/src/components/Map/WebGl/constants.ts similarity index 52% rename from packages/visualizations/src/components/MapPoi/constants.ts rename to packages/visualizations/src/components/Map/WebGl/constants.ts index 4a6787173..f34c2442c 100644 --- a/packages/visualizations/src/components/MapPoi/constants.ts +++ b/packages/visualizations/src/components/Map/WebGl/constants.ts @@ -1,11 +1,12 @@ import type { - ControlPosition, DataDrivenPropertyValueSpecification, - PopupOptions, StyleSpecification, + ControlPosition, + PopupOptions, } from 'maplibre-gl'; -import type { Color } from '../types'; -import { POPUP_DISPLAY, PopupDisplayTypes } from './types'; +import type { Color } from '../../types'; + +import type { PopupDisplayTypes } from './types'; export const DEFAULT_BASEMAP_STYLE: StyleSpecification = { version: 8, @@ -13,9 +14,6 @@ export const DEFAULT_BASEMAP_STYLE: StyleSpecification = { sources: {}, layers: [], }; - -export const DEFAULT_ASPECT_RATIO = 1; - export const DEFAULT_DARK_GREY: Color = '#515457'; export const DEFAULT_SORT_KEY_VALUE: DataDrivenPropertyValueSpecification = [ @@ -25,24 +23,35 @@ export const DEFAULT_SORT_KEY_VALUE: DataDrivenPropertyValueSpecification = { [POPUP_DISPLAY.tooltip]: `${POPUP_CLASSNAME}--as-tooltip`, @@ -51,7 +60,7 @@ export const POPUP_DISPLAY_CLASSNAME_MODIFIER: Record }; export const POPUP_OPTIONS: PopupOptions = { - className: POPUP_CLASSNAME, closeButton: false, closeOnClick: false, + maxWidth: 'none', }; diff --git a/packages/visualizations/src/components/Map/WebGl/index.ts b/packages/visualizations/src/components/Map/WebGl/index.ts index 1838ef4cc..3349a9dcf 100644 --- a/packages/visualizations/src/components/Map/WebGl/index.ts +++ b/packages/visualizations/src/components/Map/WebGl/index.ts @@ -1,4 +1,4 @@ +import WebGl from './WebGl.svelte'; import 'maplibre-gl/dist/maplibre-gl.css'; -export { default as ChoroplethGeoJson } from './ChoroplethGeoJson.svelte'; -export { default as ChoroplethVectorTiles } from './ChoroplethVectorTiles.svelte'; +export default WebGl; diff --git a/packages/visualizations/src/components/MapPoi/types.ts b/packages/visualizations/src/components/Map/WebGl/types.ts similarity index 85% rename from packages/visualizations/src/components/MapPoi/types.ts rename to packages/visualizations/src/components/Map/WebGl/types.ts index 7ac3457be..988e7c702 100644 --- a/packages/visualizations/src/components/MapPoi/types.ts +++ b/packages/visualizations/src/components/Map/WebGl/types.ts @@ -1,35 +1,30 @@ import type { CircleLayerSpecification, - SymbolLayerSpecification, - StyleSpecification, GeoJSONFeature, + GestureOptions, LngLatLike, RequestTransformFunction, - GestureOptions, StyleImageMetadata, + StyleSpecification, + SymbolLayerSpecification, } from 'maplibre-gl'; + import type { BBox, GeoJsonProperties } from 'geojson'; -import type { Async } from '../../types'; -import type { Color, Source } from '../types'; -import type { CategoryLegend } from '../Legend/types'; +import type { POPUP_DISPLAY } from './constants'; +import type { Color } from '../../types'; -// To render data layers on the map -export type PoiMapData = Partial<{ +export type WebGlMapData = Partial<{ sources: StyleSpecification['sources']; layers: Layer[]; }>; -export type Images = Record< - string, - { id: string; url: string; options?: Partial } ->; -export interface PoiMapOptions { +export interface WebGlMapOptions { /* * To render a basemap. Could be: * - A MapLibre style URL; See https://maplibre.org/maplibre-gl-js/docs/API/types/maplibregl.MapOptions. * - Or an object with a 'sources' and a 'layers' keys. Useful when using a Raster or WMS basemap. */ - style?: string | PoiMapStyleOption; + style?: string | WebGlMapStyleOption; /** * A callback run before the Map makes a request for an external URL. * The callback can be used to modify the url, set headers, or set the credentials property for cross-origin requests. @@ -51,12 +46,6 @@ export interface PoiMapOptions { aspectRatio?: number; // Is the map interactive for the user (zoom, move, tooltips...) interactive?: boolean; - title?: string; - subtitle?: string; - description?: string; - legend?: CategoryLegend; - /** Link button to source */ - sourceLink?: Source; cooperativeGestures?: boolean | GestureOptions; /** If true, the map's canvas can be exported to an image using toDataURL. This is false by default as a performance optimization. */ preserveDrawingBuffer?: boolean; @@ -64,7 +53,7 @@ export interface PoiMapOptions { images?: Images; } -export type PoiMapStyleOption = Partial>; +export type WebGlMapStyleOption = Partial>; // Supported layers export type LayerSpecification = CircleLayerSpecification | SymbolLayerSpecification; @@ -116,13 +105,10 @@ export type SymbolLayer = BaseLayer & { export type Layer = CircleLayer | SymbolLayer; -export const POPUP_DISPLAY = { - tooltip: 'tooltip', - sidebar: 'sidebar', - modal: 'modal', -} as const; - -export type PopupDisplayTypes = keyof typeof POPUP_DISPLAY; +export type GeoPoint = { + lat: number; + lon: number; +}; export type PopupLayer = { /** @@ -136,16 +122,14 @@ export type PopupLayer = { getLoadingContent: () => string; }; -export type GeoPoint = { - lat: number; - lon: number; -}; +export type PopupDisplayTypes = keyof typeof POPUP_DISPLAY; + /** A configuration map for popups where keys are layer ids and values are PopupLayer object. */ export type PopupConfigurationByLayers = { [key: string]: PopupLayer }; export type CenterZoomOptions = { zoom?: number; center?: LngLatLike }; -export type MapPoiProps = { - data: Async; - options: PoiMapOptions; -}; +export type Images = Record< + string, + { id: string; url: string; options?: Partial } +>; diff --git a/packages/visualizations/src/components/MapPoi/utils.ts b/packages/visualizations/src/components/Map/WebGl/utils.ts similarity index 88% rename from packages/visualizations/src/components/MapPoi/utils.ts rename to packages/visualizations/src/components/Map/WebGl/utils.ts index 9ad5d9e8f..e93331dd3 100644 --- a/packages/visualizations/src/components/MapPoi/utils.ts +++ b/packages/visualizations/src/components/Map/WebGl/utils.ts @@ -1,38 +1,33 @@ import type { CircleLayerSpecification, ExpressionSpecification, - MapOptions, + MapOptions as MapLibreMapOptions, StyleSpecification, ExpressionInputType, SymbolLayerSpecification, FilterSpecification, } from 'maplibre-gl'; -import { isGroupByForMatchExpression, Color } from '../types'; +import { isGroupByForMatchExpression, Color } from '../../types'; import type { - CenterZoomOptions, CircleLayer, LayerSpecification, Layer, - PoiMapData, - PoiMapOptions, + WebGlMapData, + WebGlMapOptions, PopupConfigurationByLayers, SymbolLayer, + CenterZoomOptions, } from './types'; -import { - DEFAULT_DARK_GREY, - DEFAULT_BASEMAP_STYLE, - DEFAULT_ASPECT_RATIO, - DEFAULT_SORT_KEY_VALUE, -} from './constants'; +import { DEFAULT_DARK_GREY, DEFAULT_BASEMAP_STYLE, DEFAULT_SORT_KEY_VALUE } from './constants'; -export const getMapStyle = (style: PoiMapOptions['style']): MapOptions['style'] => { +export const getMapStyle = (style: WebGlMapOptions['style']): MapLibreMapOptions['style'] => { if (!style) return DEFAULT_BASEMAP_STYLE; if (typeof style === 'string') return style; return { ...DEFAULT_BASEMAP_STYLE, ...style }; }; -export const getMapSources = (sources: PoiMapData['sources']): StyleSpecification['sources'] => { +export const getMapSources = (sources: WebGlMapData['sources']): StyleSpecification['sources'] => { if (!sources) return DEFAULT_BASEMAP_STYLE.sources; return sources; }; @@ -156,38 +151,26 @@ export const getPopupConfigurationByLayers = (layers?: Layer[]): PopupConfigurat return configurationByLayers; }; -export const getMapOptions = (options: PoiMapOptions) => { +export const getMapOptions = (options: WebGlMapOptions) => { const { - aspectRatio = DEFAULT_ASPECT_RATIO, bbox, zoom, maxZoom, minZoom, center, interactive = true, - title, - subtitle, - description, - legend, - sourceLink, transformRequest, cooperativeGestures, preserveDrawingBuffer = false, images, } = options; return { - aspectRatio, bbox, zoom, minZoom, maxZoom, center, interactive, - title, - subtitle, - description, - legend, - sourceLink, transformRequest, cooperativeGestures, preserveDrawingBuffer, diff --git a/packages/visualizations/src/components/Map/index.ts b/packages/visualizations/src/components/Map/index.ts new file mode 100644 index 000000000..08ecd636f --- /dev/null +++ b/packages/visualizations/src/components/Map/index.ts @@ -0,0 +1,7 @@ +export { default as WebGlMap } from './WebGl'; +export { default as PoiMap } from './Poi'; + +export { POPUP_DISPLAY } from './WebGl/constants'; + +export * from './WebGl/types'; +export * from './Poi/types'; diff --git a/packages/visualizations/src/components/MapPoi/Map.svelte b/packages/visualizations/src/components/MapPoi/Map.svelte deleted file mode 100644 index 6e9328027..000000000 --- a/packages/visualizations/src/components/MapPoi/Map.svelte +++ /dev/null @@ -1,77 +0,0 @@ - - -
- {#key style} - - {/key} -
diff --git a/packages/visualizations/src/components/MapPoi/MapRender.svelte b/packages/visualizations/src/components/MapPoi/MapRender.svelte deleted file mode 100644 index 0fc415138..000000000 --- a/packages/visualizations/src/components/MapPoi/MapRender.svelte +++ /dev/null @@ -1,320 +0,0 @@ - - - - -
- {#if title || subtitle} -
- {#if title} -

- {title} -

- {/if} - {#if subtitle} -

- {subtitle} -

- {/if} -
- {/if} -
-
-
- {#if description} -

{description}

- {/if} - {#if legend} - - {/if} - {#if sourceLink} - - {/if} -
- - diff --git a/packages/visualizations/src/components/MapPoi/index.ts b/packages/visualizations/src/components/MapPoi/index.ts deleted file mode 100644 index ed9b59944..000000000 --- a/packages/visualizations/src/components/MapPoi/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import PoiMap from './Map.svelte'; - -import 'maplibre-gl/dist/maplibre-gl.css'; - -export default PoiMap; diff --git a/packages/visualizations/src/components/MapPoi/mapStyles.ts b/packages/visualizations/src/components/MapPoi/mapStyles.ts deleted file mode 100644 index d16fd5232..000000000 --- a/packages/visualizations/src/components/MapPoi/mapStyles.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { StyleSpecification } from 'maplibre-gl'; - -// eslint-disable-next-line import/prefer-default-export -export const BLANK: StyleSpecification = { - version: 8, - sources: {}, - metadata: {}, - layers: [], -}; diff --git a/packages/visualizations/src/components/Pagination/Pagination.svelte b/packages/visualizations/src/components/Pagination/Pagination.svelte index 28248cbbb..c71f33fbe 100644 --- a/packages/visualizations/src/components/Pagination/Pagination.svelte +++ b/packages/visualizations/src/components/Pagination/Pagination.svelte @@ -9,7 +9,8 @@ export let onPageChange: (page: number) => void; export let totalRecords: number; export let recordsPerPage: number; - export let pageSizeSelect: PageSizeSelect; + // eslint-disable-next-line no-undef-init + export let pageSizeSelect: PageSizeSelect | undefined = undefined; export let labels: Pagination['labels'] = {}; $: totalPages = Math.ceil(totalRecords / recordsPerPage); diff --git a/packages/visualizations/src/components/Table/Cell/Format/GeoFormat.svelte b/packages/visualizations/src/components/Table/Cell/Format/GeoFormat.svelte new file mode 100644 index 000000000..587cd6d48 --- /dev/null +++ b/packages/visualizations/src/components/Table/Cell/Format/GeoFormat.svelte @@ -0,0 +1,62 @@ + + +
{ + showMap = true; + }, + onUntrigger: () => { + showMap = false; + }, + }} +> + +
{display(rawValue)}
+ + {#if showMap} +
+ +
+ {/if} +
+ + diff --git a/packages/visualizations/src/components/Table/Cell/Format/index.ts b/packages/visualizations/src/components/Table/Cell/Format/index.ts index 7c6c60fb8..3d6d9469b 100644 --- a/packages/visualizations/src/components/Table/Cell/Format/index.ts +++ b/packages/visualizations/src/components/Table/Cell/Format/index.ts @@ -4,6 +4,7 @@ import NumberFormat from './NumberFormat.svelte'; import URLFormat from './URLFormat.svelte'; import ShortTextFormat from './ShortTextFormat.svelte'; import LongTextFormat from './LongTextFormat.svelte'; +import GeoFormat from './GeoFormat.svelte'; import { isValidRawValue } from './utils'; const Format = { @@ -13,6 +14,7 @@ const Format = { 'long-text': LongTextFormat, url: URLFormat, number: NumberFormat, + geo: GeoFormat, }; export { isValidRawValue }; diff --git a/packages/visualizations/src/components/Table/Headers/SortButton.svelte b/packages/visualizations/src/components/Table/Headers/SortButton.svelte index 75b1fbc5e..d9fc05dec 100644 --- a/packages/visualizations/src/components/Table/Headers/SortButton.svelte +++ b/packages/visualizations/src/components/Table/Headers/SortButton.svelte @@ -1,5 +1,6 @@ diff --git a/packages/visualizations/src/components/Table/constants.ts b/packages/visualizations/src/components/Table/constants.ts index e78d688d4..48ff4380c 100644 --- a/packages/visualizations/src/components/Table/constants.ts +++ b/packages/visualizations/src/components/Table/constants.ts @@ -6,4 +6,5 @@ export const DATA_FORMAT = { number: 'number', boolean: 'boolean', url: 'url', + geo: 'geo', } as const; diff --git a/packages/visualizations/src/components/Table/types.ts b/packages/visualizations/src/components/Table/types.ts index e0050e832..ee519df3d 100644 --- a/packages/visualizations/src/components/Table/types.ts +++ b/packages/visualizations/src/components/Table/types.ts @@ -2,6 +2,7 @@ import type { DataFrame, Source } from '../types'; import type { DATA_FORMAT } from './constants'; import type { Pagination } from '../Pagination/types'; import type { Async } from '../../types'; +import type { WebGlMapData, WebGlMapOptions } from '../Map'; type DataFormatKey = keyof typeof DATA_FORMAT; export type DataFormat = typeof DATA_FORMAT[DataFormatKey]; @@ -85,13 +86,24 @@ export type URLColumn = BaseColumn & { }; }; +export type GeoColumn = BaseColumn & { + dataFormat: typeof DATA_FORMAT.geo; + options?: Partial<{ + mapOptions: WebGlMapOptions; + display: (v: unknown) => string; + sources: (v: unknown) => WebGlMapData['sources']; + layers: (v: unknown) => WebGlMapData['layers']; + }>; +}; + export type Column = | ShortTextColumn | LongTextColumn | NumberColumn | DateColumn | BooleanColumn - | URLColumn; + | URLColumn + | GeoColumn; export type TableOptions = { columns: Column[]; diff --git a/packages/visualizations/src/components/utils/MiniMap.svelte b/packages/visualizations/src/components/utils/MiniMap.svelte index 1e71f7b90..2dbf71580 100644 --- a/packages/visualizations/src/components/utils/MiniMap.svelte +++ b/packages/visualizations/src/components/utils/MiniMap.svelte @@ -1,8 +1,8 @@