From 8ad0b3b6d25c65739a93e22b3a763fd702e98825 Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Mon, 17 Mar 2025 13:58:22 +0100 Subject: [PATCH 1/5] feat: add showLayerDataTable method with sorting capability --- docs/Layers/LayersController.md | 38 ++++++ docs/Main/FeltController.md | 38 ++++++ docs/Shared/README.md | 2 + docs/Shared/SortConfig.md | 21 +++ docs/Shared/SortDirection.md | 5 + etc/js-sdk.api.md | 228 ++++++++++++++++--------------- src/modules/layers/controller.ts | 30 +++- src/modules/layers/schema.ts | 17 ++- src/modules/shared/index.ts | 2 + src/modules/shared/types.ts | 30 ++++ 10 files changed, 300 insertions(+), 111 deletions(-) create mode 100644 docs/Shared/SortConfig.md create mode 100644 docs/Shared/SortDirection.md diff --git a/docs/Layers/LayersController.md b/docs/Layers/LayersController.md index cec1e8c..3ae76d5 100644 --- a/docs/Layers/LayersController.md +++ b/docs/Layers/LayersController.md @@ -642,6 +642,44 @@ const maxNewBuildingHeight = await felt.getAggregates({ }); ``` +*** + +## showLayerDataTable() + +> **showLayerDataTable**(`params`: \{ `layerId`: `string`; `sorting`: [`SortConfig`](../Shared/SortConfig.md); }): `Promise`\<`void`> + +Shows a data table view for the specified layer, optionally sorted by a given attribute. + +### Parameters + +| Parameter | Type | +| ----------------- | ----------------------------------------------------------------------------- | +| `params` | \{ `layerId`: `string`; `sorting`: [`SortConfig`](../Shared/SortConfig.md); } | +| `params.layerId` | `string` | +| `params.sorting`? | [`SortConfig`](../Shared/SortConfig.md) | + +### Returns + +`Promise`\<`void`> + +### Example + +```typescript +// Show data table with default sorting +await felt.showLayerDataTable({ + layerId: "buildingsLayerId" +}); + +// Show data table sorted by height in descending order +await felt.showLayerDataTable({ + layerId: "buildingsLayerId", + sorting: { + attribute: "height", + direction: "desc" + } +}); +``` + # Events ## onLayerChange() diff --git a/docs/Main/FeltController.md b/docs/Main/FeltController.md index 761e7a9..7127698 100644 --- a/docs/Main/FeltController.md +++ b/docs/Main/FeltController.md @@ -875,6 +875,44 @@ const maxNewBuildingHeight = await felt.getAggregates({ *** +## showLayerDataTable() + +> **showLayerDataTable**(`params`: \{ `layerId`: `string`; `sorting`: [`SortConfig`](../Shared/SortConfig.md); }): `Promise`\<`void`> + +Shows a data table view for the specified layer, optionally sorted by a given attribute. + +### Parameters + +| Parameter | Type | +| ----------------- | ----------------------------------------------------------------------------- | +| `params` | \{ `layerId`: `string`; `sorting`: [`SortConfig`](../Shared/SortConfig.md); } | +| `params.layerId` | `string` | +| `params.sorting`? | [`SortConfig`](../Shared/SortConfig.md) | + +### Returns + +`Promise`\<`void`> + +### Example + +```typescript +// Show data table with default sorting +await felt.showLayerDataTable({ + layerId: "buildingsLayerId" +}); + +// Show data table sorted by height in descending order +await felt.showLayerDataTable({ + layerId: "buildingsLayerId", + sorting: { + attribute: "height", + direction: "desc" + } +}); +``` + +*** + ## getMapDetails() > **getMapDetails**(): `Promise`\<[`MapDetails`](../Misc/MapDetails.md)> diff --git a/docs/Shared/README.md b/docs/Shared/README.md index 1a98f27..2c51775 100644 --- a/docs/Shared/README.md +++ b/docs/Shared/README.md @@ -10,10 +10,12 @@ These are generic types that are used across multiple modules. * [MultiPolygonGeometry](MultiPolygonGeometry.md) * [LineStringGeometry](LineStringGeometry.md) * [MultiLineStringGeometry](MultiLineStringGeometry.md) +* [SortConfig](SortConfig.md) * [LngLatTuple](LngLatTuple.md) * [Geometry](Geometry.md) * [FeltZoom](FeltZoom.md) * [FeltBoundary](FeltBoundary.md) +* [SortDirection](SortDirection.md) # Visibility diff --git a/docs/Shared/SortConfig.md b/docs/Shared/SortConfig.md new file mode 100644 index 0000000..532e837 --- /dev/null +++ b/docs/Shared/SortConfig.md @@ -0,0 +1,21 @@ +*** + +Configuration for sorting data by a specific attribute + +# Properties + +## attribute + +> **attribute**: `string` + +The attribute to sort by. What this represents depends on the context. +For instance, when sorting features in a data table, the attribute is +the column to sort by. + +*** + +## direction + +> **direction**: `"asc"` | `"desc"` = `SortDirectionSchema` + +The direction to sort in diff --git a/docs/Shared/SortDirection.md b/docs/Shared/SortDirection.md new file mode 100644 index 0000000..5c58459 --- /dev/null +++ b/docs/Shared/SortDirection.md @@ -0,0 +1,5 @@ +*** + +> **SortDirection**: `"asc"` | `"desc"` + +Specifies the direction to sort data in diff --git a/etc/js-sdk.api.md b/etc/js-sdk.api.md index 15e48f6..b79b1fc 100644 --- a/etc/js-sdk.api.md +++ b/etc/js-sdk.api.md @@ -4,112 +4,114 @@ ```ts -import { ao as AggregationConfig } from './types-NOlNQi4k.js'; -import { A as AggregationMethod } from './types-NOlNQi4k.js'; -import { Q as CircleElementCreate } from './types-NOlNQi4k.js'; -import { R as CircleElementRead } from './types-NOlNQi4k.js'; -import { U as CircleElementUpdate } from './types-NOlNQi4k.js'; -import { aF as CircleToolSettings } from './types-NOlNQi4k.js'; -import { C as ConfigurableToolType } from './types-NOlNQi4k.js'; -import { E as Element_2 } from './types-NOlNQi4k.js'; -import { d as ElementChangeCallbackParams } from './types-NOlNQi4k.js'; -import { f as ElementCreate } from './types-NOlNQi4k.js'; -import { b as ElementGroup } from './types-NOlNQi4k.js'; -import { e as ElementGroupChangeCallbackParams } from './types-NOlNQi4k.js'; -import { ar as ElementGroupNode } from './types-NOlNQi4k.js'; -import { as as ElementNode } from './types-NOlNQi4k.js'; -import { g as ElementUpdate } from './types-NOlNQi4k.js'; -import { z as EntityNode } from './types-NOlNQi4k.js'; -import { s as Feature } from './types-NOlNQi4k.js'; -import { at as FeatureNode } from './types-NOlNQi4k.js'; -import { B as FeatureSelection } from './types-NOlNQi4k.js'; -import { aw as FeltBoundary } from './types-NOlNQi4k.js'; -import { ax as FeltZoom } from './types-NOlNQi4k.js'; -import { al as FilterExpression } from './types-NOlNQi4k.js'; -import { am as FilterLogicGate } from './types-NOlNQi4k.js'; -import { F as Filters } from './types-NOlNQi4k.js'; -import { an as FilterTernary } from './types-NOlNQi4k.js'; -import { G as Geometry } from './types-NOlNQi4k.js'; -import { c as GetElementGroupsConstraint } from './types-NOlNQi4k.js'; -import { a as GetElementsConstraint } from './types-NOlNQi4k.js'; -import { x as GetLayerCalculationParams } from './types-NOlNQi4k.js'; -import { u as GetLayerCategoriesGroup } from './types-NOlNQi4k.js'; -import { t as GetLayerCategoriesParams } from './types-NOlNQi4k.js'; -import { k as GetLayerGroupsConstraint } from './types-NOlNQi4k.js'; -import { w as GetLayerHistogramBin } from './types-NOlNQi4k.js'; -import { v as GetLayerHistogramParams } from './types-NOlNQi4k.js'; -import { h as GetLayersConstraint } from './types-NOlNQi4k.js'; -import { r as GetRenderedFeaturesConstraint } from './types-NOlNQi4k.js'; -import { W as HighlighterElementCreate } from './types-NOlNQi4k.js'; -import { X as HighlighterElementRead } from './types-NOlNQi4k.js'; -import { Y as HighlighterElementUpdate } from './types-NOlNQi4k.js'; -import { aG as HighlighterToolSettings } from './types-NOlNQi4k.js'; -import { Z as ImageElementCreate } from './types-NOlNQi4k.js'; -import { _ as ImageElementRead } from './types-NOlNQi4k.js'; -import { $ as ImageElementUpdate } from './types-NOlNQi4k.js'; -import { I as InputToolSettings } from './types-NOlNQi4k.js'; -import { J } from './types-NOlNQi4k.js'; -import { ay as LatLng } from './types-NOlNQi4k.js'; -import { L as Layer } from './types-NOlNQi4k.js'; -import { i as LayerChangeCallbackParams } from './types-NOlNQi4k.js'; -import { q as LayerFilters } from './types-NOlNQi4k.js'; -import { j as LayerGroup } from './types-NOlNQi4k.js'; -import { l as LayerGroupChangeCallbackParams } from './types-NOlNQi4k.js'; -import { au as LayerGroupNode } from './types-NOlNQi4k.js'; -import { av as LayerNode } from './types-NOlNQi4k.js'; -import { aj as LayerProcessingStatus } from './types-NOlNQi4k.js'; -import { n as LegendItem } from './types-NOlNQi4k.js'; -import { p as LegendItemChangeCallbackParams } from './types-NOlNQi4k.js'; -import { m as LegendItemIdentifier } from './types-NOlNQi4k.js'; -import { o as LegendItemsConstraint } from './types-NOlNQi4k.js'; -import { az as LineStringGeometry } from './types-NOlNQi4k.js'; -import { aH as LineToolSettings } from './types-NOlNQi4k.js'; -import { a0 as LinkElementRead } from './types-NOlNQi4k.js'; -import { aA as LngLatTuple } from './types-NOlNQi4k.js'; -import { y as MapDetails } from './types-NOlNQi4k.js'; -import { M as MapInteractionEvent } from './types-NOlNQi4k.js'; -import { a1 as MarkerElementCreate } from './types-NOlNQi4k.js'; -import { a2 as MarkerElementRead } from './types-NOlNQi4k.js'; -import { a3 as MarkerElementUpdate } from './types-NOlNQi4k.js'; -import { aI as MarkerToolSettings } from './types-NOlNQi4k.js'; -import { ap as MultiAggregationConfig } from './types-NOlNQi4k.js'; -import { aB as MultiLineStringGeometry } from './types-NOlNQi4k.js'; -import { aC as MultiPolygonGeometry } from './types-NOlNQi4k.js'; -import { a4 as NoteElementCreate } from './types-NOlNQi4k.js'; -import { a5 as NoteElementRead } from './types-NOlNQi4k.js'; -import { a6 as NoteElementUpdate } from './types-NOlNQi4k.js'; -import { aJ as NoteToolSettings } from './types-NOlNQi4k.js'; -import { a7 as PathElementCreate } from './types-NOlNQi4k.js'; -import { a8 as PathElementRead } from './types-NOlNQi4k.js'; -import { a9 as PathElementUpdate } from './types-NOlNQi4k.js'; -import { aK as PinToolSettings } from './types-NOlNQi4k.js'; -import { aa as PlaceElementCreate } from './types-NOlNQi4k.js'; -import { ab as PlaceElementRead } from './types-NOlNQi4k.js'; -import { ac as PlaceElementUpdate } from './types-NOlNQi4k.js'; -import { aL as PlaceFrame } from './types-NOlNQi4k.js'; -import { aM as PlaceSymbol } from './types-NOlNQi4k.js'; -import { aD as PointGeometry } from './types-NOlNQi4k.js'; -import { ad as PolygonElementCreate } from './types-NOlNQi4k.js'; -import { ae as PolygonElementRead } from './types-NOlNQi4k.js'; -import { af as PolygonElementUpdate } from './types-NOlNQi4k.js'; -import { aE as PolygonGeometry } from './types-NOlNQi4k.js'; -import { aN as PolygonToolSettings } from './types-NOlNQi4k.js'; -import { ak as RasterValue } from './types-NOlNQi4k.js'; -import { aO as RouteToolSettings } from './types-NOlNQi4k.js'; -import { K as SetViewportCenterZoomParams } from './types-NOlNQi4k.js'; -import { S as SetVisibilityRequest } from './types-NOlNQi4k.js'; -import { ag as TextElementCreate } from './types-NOlNQi4k.js'; -import { ah as TextElementRead } from './types-NOlNQi4k.js'; -import { ai as TextElementUpdate } from './types-NOlNQi4k.js'; -import { aP as TextToolSettings } from './types-NOlNQi4k.js'; -import { H as ToolSettingsChangeEvent } from './types-NOlNQi4k.js'; -import { D as ToolSettingsMap } from './types-NOlNQi4k.js'; -import { T as ToolType } from './types-NOlNQi4k.js'; -import { aq as ValueConfiguration } from './types-NOlNQi4k.js'; -import { P as ViewportCenterZoom } from './types-NOlNQi4k.js'; -import { N as ViewportConstraints } from './types-NOlNQi4k.js'; -import { O as ViewportFitBoundsParams } from './types-NOlNQi4k.js'; -import { V as ViewportState } from './types-NOlNQi4k.js'; +import { ap as AggregationConfig } from './types-Bw55doND.js'; +import { A as AggregationMethod } from './types-Bw55doND.js'; +import { R as CircleElementCreate } from './types-Bw55doND.js'; +import { U as CircleElementRead } from './types-Bw55doND.js'; +import { W as CircleElementUpdate } from './types-Bw55doND.js'; +import { aH as CircleToolSettings } from './types-Bw55doND.js'; +import { D as ConfigurableToolType } from './types-Bw55doND.js'; +import { E as Element_2 } from './types-Bw55doND.js'; +import { d as ElementChangeCallbackParams } from './types-Bw55doND.js'; +import { f as ElementCreate } from './types-Bw55doND.js'; +import { b as ElementGroup } from './types-Bw55doND.js'; +import { e as ElementGroupChangeCallbackParams } from './types-Bw55doND.js'; +import { as as ElementGroupNode } from './types-Bw55doND.js'; +import { at as ElementNode } from './types-Bw55doND.js'; +import { g as ElementUpdate } from './types-Bw55doND.js'; +import { B as EntityNode } from './types-Bw55doND.js'; +import { s as Feature } from './types-Bw55doND.js'; +import { au as FeatureNode } from './types-Bw55doND.js'; +import { C as FeatureSelection } from './types-Bw55doND.js'; +import { ax as FeltBoundary } from './types-Bw55doND.js'; +import { ay as FeltZoom } from './types-Bw55doND.js'; +import { am as FilterExpression } from './types-Bw55doND.js'; +import { an as FilterLogicGate } from './types-Bw55doND.js'; +import { F as Filters } from './types-Bw55doND.js'; +import { ao as FilterTernary } from './types-Bw55doND.js'; +import { G as Geometry } from './types-Bw55doND.js'; +import { c as GetElementGroupsConstraint } from './types-Bw55doND.js'; +import { a as GetElementsConstraint } from './types-Bw55doND.js'; +import { x as GetLayerCalculationParams } from './types-Bw55doND.js'; +import { u as GetLayerCategoriesGroup } from './types-Bw55doND.js'; +import { t as GetLayerCategoriesParams } from './types-Bw55doND.js'; +import { k as GetLayerGroupsConstraint } from './types-Bw55doND.js'; +import { w as GetLayerHistogramBin } from './types-Bw55doND.js'; +import { v as GetLayerHistogramParams } from './types-Bw55doND.js'; +import { h as GetLayersConstraint } from './types-Bw55doND.js'; +import { r as GetRenderedFeaturesConstraint } from './types-Bw55doND.js'; +import { X as HighlighterElementCreate } from './types-Bw55doND.js'; +import { Y as HighlighterElementRead } from './types-Bw55doND.js'; +import { Z as HighlighterElementUpdate } from './types-Bw55doND.js'; +import { aI as HighlighterToolSettings } from './types-Bw55doND.js'; +import { _ as ImageElementCreate } from './types-Bw55doND.js'; +import { $ as ImageElementRead } from './types-Bw55doND.js'; +import { a0 as ImageElementUpdate } from './types-Bw55doND.js'; +import { I as InputToolSettings } from './types-Bw55doND.js'; +import { K } from './types-Bw55doND.js'; +import { az as LatLng } from './types-Bw55doND.js'; +import { L as Layer } from './types-Bw55doND.js'; +import { i as LayerChangeCallbackParams } from './types-Bw55doND.js'; +import { q as LayerFilters } from './types-Bw55doND.js'; +import { j as LayerGroup } from './types-Bw55doND.js'; +import { l as LayerGroupChangeCallbackParams } from './types-Bw55doND.js'; +import { av as LayerGroupNode } from './types-Bw55doND.js'; +import { aw as LayerNode } from './types-Bw55doND.js'; +import { ak as LayerProcessingStatus } from './types-Bw55doND.js'; +import { n as LegendItem } from './types-Bw55doND.js'; +import { p as LegendItemChangeCallbackParams } from './types-Bw55doND.js'; +import { m as LegendItemIdentifier } from './types-Bw55doND.js'; +import { o as LegendItemsConstraint } from './types-Bw55doND.js'; +import { aA as LineStringGeometry } from './types-Bw55doND.js'; +import { aJ as LineToolSettings } from './types-Bw55doND.js'; +import { a1 as LinkElementRead } from './types-Bw55doND.js'; +import { aB as LngLatTuple } from './types-Bw55doND.js'; +import { z as MapDetails } from './types-Bw55doND.js'; +import { M as MapInteractionEvent } from './types-Bw55doND.js'; +import { a2 as MarkerElementCreate } from './types-Bw55doND.js'; +import { a3 as MarkerElementRead } from './types-Bw55doND.js'; +import { a4 as MarkerElementUpdate } from './types-Bw55doND.js'; +import { aK as MarkerToolSettings } from './types-Bw55doND.js'; +import { aq as MultiAggregationConfig } from './types-Bw55doND.js'; +import { aC as MultiLineStringGeometry } from './types-Bw55doND.js'; +import { aD as MultiPolygonGeometry } from './types-Bw55doND.js'; +import { a5 as NoteElementCreate } from './types-Bw55doND.js'; +import { a6 as NoteElementRead } from './types-Bw55doND.js'; +import { a7 as NoteElementUpdate } from './types-Bw55doND.js'; +import { aL as NoteToolSettings } from './types-Bw55doND.js'; +import { a8 as PathElementCreate } from './types-Bw55doND.js'; +import { a9 as PathElementRead } from './types-Bw55doND.js'; +import { aa as PathElementUpdate } from './types-Bw55doND.js'; +import { aM as PinToolSettings } from './types-Bw55doND.js'; +import { ab as PlaceElementCreate } from './types-Bw55doND.js'; +import { ac as PlaceElementRead } from './types-Bw55doND.js'; +import { ad as PlaceElementUpdate } from './types-Bw55doND.js'; +import { aN as PlaceFrame } from './types-Bw55doND.js'; +import { aO as PlaceSymbol } from './types-Bw55doND.js'; +import { aE as PointGeometry } from './types-Bw55doND.js'; +import { ae as PolygonElementCreate } from './types-Bw55doND.js'; +import { af as PolygonElementRead } from './types-Bw55doND.js'; +import { ag as PolygonElementUpdate } from './types-Bw55doND.js'; +import { aF as PolygonGeometry } from './types-Bw55doND.js'; +import { aP as PolygonToolSettings } from './types-Bw55doND.js'; +import { al as RasterValue } from './types-Bw55doND.js'; +import { aQ as RouteToolSettings } from './types-Bw55doND.js'; +import { N as SetViewportCenterZoomParams } from './types-Bw55doND.js'; +import { S as SetVisibilityRequest } from './types-Bw55doND.js'; +import { y as SortConfig } from './types-Bw55doND.js'; +import { aG as SortDirection } from './types-Bw55doND.js'; +import { ah as TextElementCreate } from './types-Bw55doND.js'; +import { ai as TextElementRead } from './types-Bw55doND.js'; +import { aj as TextElementUpdate } from './types-Bw55doND.js'; +import { aR as TextToolSettings } from './types-Bw55doND.js'; +import { J as ToolSettingsChangeEvent } from './types-Bw55doND.js'; +import { H as ToolSettingsMap } from './types-Bw55doND.js'; +import { T as ToolType } from './types-Bw55doND.js'; +import { ar as ValueConfiguration } from './types-Bw55doND.js'; +import { Q as ViewportCenterZoom } from './types-Bw55doND.js'; +import { O as ViewportConstraints } from './types-Bw55doND.js'; +import { P as ViewportFitBoundsParams } from './types-Bw55doND.js'; +import { V as ViewportState } from './types-Bw55doND.js'; import { z } from 'zod'; export { AggregationConfig } @@ -205,7 +207,7 @@ export interface FeltController extends ViewportController, UiController, Layers // Warning: (ae-forgotten-export) The symbol "FeltEmbedOptionsSchema" needs to be exported by the entry point client.d.ts // // @public -export interface FeltEmbedOptions extends J { +export interface FeltEmbedOptions extends K { // (undocumented) initialViewport?: ViewportCenterZoom; // (undocumented) @@ -429,6 +431,10 @@ export interface LayersController { show?: Array; hide?: Array; }): Promise; + showLayerDataTable(params: { + layerId: string; + sorting?: SortConfig; + }): Promise; } export { LegendItem } @@ -481,7 +487,7 @@ export { NoteToolSettings } // Warning: (ae-forgotten-export) The symbol "UiOnMapInteractionsOptionsSchema" needs to be exported by the entry point client.d.ts // // @public -export interface OnMapInteractionsOptions extends J { +export interface OnMapInteractionsOptions extends K { } export { PathElementCreate } @@ -537,6 +543,10 @@ export { SetViewportCenterZoomParams } export { SetVisibilityRequest } +export { SortConfig } + +export { SortDirection } + export { TextElementCreate } export { TextElementRead } @@ -574,7 +584,7 @@ export interface UiController { // Warning: (ae-forgotten-export) The symbol "UiControlsOptionsSchema" needs to be exported by the entry point client.d.ts // // @public (undocumented) -export interface UiControlsOptions extends J { +export interface UiControlsOptions extends K { } // @internal (undocumented) diff --git a/src/modules/layers/controller.ts b/src/modules/layers/controller.ts index a7ea1fe..ddeb5fa 100644 --- a/src/modules/layers/controller.ts +++ b/src/modules/layers/controller.ts @@ -1,5 +1,5 @@ import { listener, method } from "~/lib/interface"; -import type { SetVisibilityRequest } from "~/modules/shared/types"; +import type { SetVisibilityRequest, SortConfig } from "~/modules/shared/types"; import type { Filters, LayerFilters } from "./filters/types"; import type { AggregationMethod, @@ -63,6 +63,9 @@ export const layersController = (feltWindow: Window): LayersController => ({ getCategoryData: method(feltWindow, "getCategoryData"), getHistogramData: method(feltWindow, "getHistogramData"), getAggregates: method(feltWindow, "getAggregates"), + + // new method + showLayerDataTable: method(feltWindow, "showLayerDataTable"), }); /** @@ -579,4 +582,29 @@ export interface LayersController { getAggregates( params: GetLayerCalculationParams, ): Promise>; + + /** + * Shows a data table view for the specified layer, optionally sorted by a given attribute. + * + * @example + * ```typescript + * // Show data table with default sorting + * await felt.showLayerDataTable({ + * layerId: "buildingsLayerId" + * }); + * + * // Show data table sorted by height in descending order + * await felt.showLayerDataTable({ + * layerId: "buildingsLayerId", + * sorting: { + * attribute: "height", + * direction: "desc" + * } + * }); + * ``` + */ + showLayerDataTable(params: { + layerId: string; + sorting?: SortConfig; + }): Promise; } diff --git a/src/modules/layers/schema.ts b/src/modules/layers/schema.ts index d6ae54c..2181ecd 100644 --- a/src/modules/layers/schema.ts +++ b/src/modules/layers/schema.ts @@ -7,7 +7,10 @@ import { methodMessage, } from "~/lib/builders"; import type { zInfer } from "~/lib/utils"; -import { SetVisibilityRequestSchema } from "~/modules/shared/types"; +import { + SetVisibilityRequestSchema, + SortConfigSchema, +} from "~/modules/shared/types"; import { FiltersSchema, type LayerFilters } from "./filters/types"; import { type AggregationMethod, @@ -128,6 +131,14 @@ const GetLayerCalculationMessage = methodMessage( GetLayerCalculationParamsSchema, ); +const ShowLayerDataTableMessage = methodMessage( + "showLayerDataTable", + z.object({ + layerId: z.string(), + sorting: SortConfigSchema.optional(), + }), +); + export const layersSchema = { methods: [ GetLayerMessage, @@ -153,6 +164,8 @@ export const layersSchema = { GetLayerCategoriesMessage, GetLayerHistogramMessage, GetLayerCalculationMessage, + + ShowLayerDataTableMessage, ], listeners: [ OnLayerChangeMessage, @@ -223,6 +236,8 @@ export type LayersSchema = { zInfer, Record >; + + showLayerDataTable: Method, void>; }; listeners: { onLayerChange: Listener< diff --git a/src/modules/shared/index.ts b/src/modules/shared/index.ts index aaa0b74..4d7b664 100644 --- a/src/modules/shared/index.ts +++ b/src/modules/shared/index.ts @@ -15,4 +15,6 @@ export type { PointGeometry, PolygonGeometry, SetVisibilityRequest, + SortConfig, + SortDirection, } from "./types"; diff --git a/src/modules/shared/types.ts b/src/modules/shared/types.ts index c4b55b2..a600114 100644 --- a/src/modules/shared/types.ts +++ b/src/modules/shared/types.ts @@ -151,3 +151,33 @@ export const SetVisibilityRequestSchema = z.object({ show: z.array(z.string()).optional(), hide: z.array(z.string()).optional(), }); + +/** + * Specifies the direction to sort data in + * + * @group Types + */ +export type SortDirection = z.infer; +/** @ignore */ +const SortDirectionSchema = z.enum(["asc", "desc"]); + +/** + * Configuration for sorting data by a specific attribute + * + * @group Types + */ +export interface SortConfig extends zInfer {} +/** @ignore */ +export const SortConfigSchema = z.object({ + /** + * The attribute to sort by. What this represents depends on the context. + * For instance, when sorting features in a data table, the attribute is + * the column to sort by. + */ + attribute: z.string(), + + /** + * The direction to sort in + */ + direction: SortDirectionSchema, +}); From 9a22723b1d83b8740b0f9f6f51908d118a605d15 Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Mon, 17 Mar 2025 14:05:46 +0100 Subject: [PATCH 2/5] docs(changeset): Add showLayerDataTable method --- .changeset/little-apples-dream.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/little-apples-dream.md diff --git a/.changeset/little-apples-dream.md b/.changeset/little-apples-dream.md new file mode 100644 index 0000000..abc7adc --- /dev/null +++ b/.changeset/little-apples-dream.md @@ -0,0 +1,5 @@ +--- +"@feltmaps/js-sdk": minor +--- + +Add showLayerDataTable and hideLayerDataTable methods From ab750e5c1a013234f6311411d5ea11d024a7b6ce Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Mon, 17 Mar 2025 15:23:43 +0100 Subject: [PATCH 3/5] Add hide method --- docs/Layers/LayersController.md | 26 ++++++++++++++++++++++---- docs/Main/FeltController.md | 26 ++++++++++++++++++++++---- etc/js-sdk.api.md | 1 + src/modules/layers/controller.ts | 19 +++++++++++++++---- src/modules/layers/schema.ts | 7 +++++++ 5 files changed, 67 insertions(+), 12 deletions(-) diff --git a/docs/Layers/LayersController.md b/docs/Layers/LayersController.md index 3ae76d5..c0acf05 100644 --- a/docs/Layers/LayersController.md +++ b/docs/Layers/LayersController.md @@ -667,19 +667,37 @@ Shows a data table view for the specified layer, optionally sorted by a given at ```typescript // Show data table with default sorting await felt.showLayerDataTable({ - layerId: "buildingsLayerId" + layerId: "layer-1", }); // Show data table sorted by height in descending order await felt.showLayerDataTable({ - layerId: "buildingsLayerId", + layerId: "layer-1", sorting: { attribute: "height", - direction: "desc" - } + direction: "desc", + }, }); ``` +*** + +## hideLayerDataTable() + +> **hideLayerDataTable**(): `Promise`\<`void`> + +Hides the data table. + +### Returns + +`Promise`\<`void`> + +### Example + +```typescript +await felt.hideLayerDataTable(); +``` + # Events ## onLayerChange() diff --git a/docs/Main/FeltController.md b/docs/Main/FeltController.md index 7127698..728a0d6 100644 --- a/docs/Main/FeltController.md +++ b/docs/Main/FeltController.md @@ -898,21 +898,39 @@ Shows a data table view for the specified layer, optionally sorted by a given at ```typescript // Show data table with default sorting await felt.showLayerDataTable({ - layerId: "buildingsLayerId" + layerId: "layer-1", }); // Show data table sorted by height in descending order await felt.showLayerDataTable({ - layerId: "buildingsLayerId", + layerId: "layer-1", sorting: { attribute: "height", - direction: "desc" - } + direction: "desc", + }, }); ``` *** +## hideLayerDataTable() + +> **hideLayerDataTable**(): `Promise`\<`void`> + +Hides the data table. + +### Returns + +`Promise`\<`void`> + +### Example + +```typescript +await felt.hideLayerDataTable(); +``` + +*** + ## getMapDetails() > **getMapDetails**(): `Promise`\<[`MapDetails`](../Misc/MapDetails.md)> diff --git a/etc/js-sdk.api.md b/etc/js-sdk.api.md index b79b1fc..1940cc9 100644 --- a/etc/js-sdk.api.md +++ b/etc/js-sdk.api.md @@ -397,6 +397,7 @@ export interface LayersController { getLegendItems(constraint?: LegendItemsConstraint): Promise>; getRenderedFeatures( params?: GetRenderedFeaturesConstraint): Promise>; + hideLayerDataTable(): Promise; onLayerChange(args: { options: { id: string; diff --git a/src/modules/layers/controller.ts b/src/modules/layers/controller.ts index ddeb5fa..0c0d9ca 100644 --- a/src/modules/layers/controller.ts +++ b/src/modules/layers/controller.ts @@ -66,6 +66,7 @@ export const layersController = (feltWindow: Window): LayersController => ({ // new method showLayerDataTable: method(feltWindow, "showLayerDataTable"), + hideLayerDataTable: method(feltWindow, "hideLayerDataTable"), }); /** @@ -590,16 +591,16 @@ export interface LayersController { * ```typescript * // Show data table with default sorting * await felt.showLayerDataTable({ - * layerId: "buildingsLayerId" + * layerId: "layer-1", * }); * * // Show data table sorted by height in descending order * await felt.showLayerDataTable({ - * layerId: "buildingsLayerId", + * layerId: "layer-1", * sorting: { * attribute: "height", - * direction: "desc" - * } + * direction: "desc", + * }, * }); * ``` */ @@ -607,4 +608,14 @@ export interface LayersController { layerId: string; sorting?: SortConfig; }): Promise; + + /** + * Hides the data table. + * + * @example + * ```typescript + * await felt.hideLayerDataTable(); + * ``` + */ + hideLayerDataTable(): Promise; } diff --git a/src/modules/layers/schema.ts b/src/modules/layers/schema.ts index 2181ecd..e9d8acf 100644 --- a/src/modules/layers/schema.ts +++ b/src/modules/layers/schema.ts @@ -139,6 +139,11 @@ const ShowLayerDataTableMessage = methodMessage( }), ); +const HideLayerDataTableMessage = methodMessage( + "hideLayerDataTable", + z.undefined(), +); + export const layersSchema = { methods: [ GetLayerMessage, @@ -166,6 +171,7 @@ export const layersSchema = { GetLayerCalculationMessage, ShowLayerDataTableMessage, + HideLayerDataTableMessage, ], listeners: [ OnLayerChangeMessage, @@ -238,6 +244,7 @@ export type LayersSchema = { >; showLayerDataTable: Method, void>; + hideLayerDataTable: Method, void>; }; listeners: { onLayerChange: Listener< From 6da99807e4ec69713f2e1c6ee65838913b8e18d3 Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Mon, 17 Mar 2025 16:27:50 +0100 Subject: [PATCH 4/5] Move to UiController --- docs/Layers/LayersController.md | 56 -------- docs/Main/FeltController.md | 112 +++++++-------- docs/UI/UiController.md | 62 ++++++++- etc/js-sdk.api.md | 232 +++++++++++++++---------------- src/modules/layers/controller.ts | 41 +----- src/modules/layers/schema.ts | 24 +--- src/modules/ui/controller.ts | 45 +++++- src/modules/ui/schema.ts | 26 +++- 8 files changed, 302 insertions(+), 296 deletions(-) diff --git a/docs/Layers/LayersController.md b/docs/Layers/LayersController.md index c0acf05..cec1e8c 100644 --- a/docs/Layers/LayersController.md +++ b/docs/Layers/LayersController.md @@ -642,62 +642,6 @@ const maxNewBuildingHeight = await felt.getAggregates({ }); ``` -*** - -## showLayerDataTable() - -> **showLayerDataTable**(`params`: \{ `layerId`: `string`; `sorting`: [`SortConfig`](../Shared/SortConfig.md); }): `Promise`\<`void`> - -Shows a data table view for the specified layer, optionally sorted by a given attribute. - -### Parameters - -| Parameter | Type | -| ----------------- | ----------------------------------------------------------------------------- | -| `params` | \{ `layerId`: `string`; `sorting`: [`SortConfig`](../Shared/SortConfig.md); } | -| `params.layerId` | `string` | -| `params.sorting`? | [`SortConfig`](../Shared/SortConfig.md) | - -### Returns - -`Promise`\<`void`> - -### Example - -```typescript -// Show data table with default sorting -await felt.showLayerDataTable({ - layerId: "layer-1", -}); - -// Show data table sorted by height in descending order -await felt.showLayerDataTable({ - layerId: "layer-1", - sorting: { - attribute: "height", - direction: "desc", - }, -}); -``` - -*** - -## hideLayerDataTable() - -> **hideLayerDataTable**(): `Promise`\<`void`> - -Hides the data table. - -### Returns - -`Promise`\<`void`> - -### Example - -```typescript -await felt.hideLayerDataTable(); -``` - # Events ## onLayerChange() diff --git a/docs/Main/FeltController.md b/docs/Main/FeltController.md index 728a0d6..a461cdf 100644 --- a/docs/Main/FeltController.md +++ b/docs/Main/FeltController.md @@ -875,62 +875,6 @@ const maxNewBuildingHeight = await felt.getAggregates({ *** -## showLayerDataTable() - -> **showLayerDataTable**(`params`: \{ `layerId`: `string`; `sorting`: [`SortConfig`](../Shared/SortConfig.md); }): `Promise`\<`void`> - -Shows a data table view for the specified layer, optionally sorted by a given attribute. - -### Parameters - -| Parameter | Type | -| ----------------- | ----------------------------------------------------------------------------- | -| `params` | \{ `layerId`: `string`; `sorting`: [`SortConfig`](../Shared/SortConfig.md); } | -| `params.layerId` | `string` | -| `params.sorting`? | [`SortConfig`](../Shared/SortConfig.md) | - -### Returns - -`Promise`\<`void`> - -### Example - -```typescript -// Show data table with default sorting -await felt.showLayerDataTable({ - layerId: "layer-1", -}); - -// Show data table sorted by height in descending order -await felt.showLayerDataTable({ - layerId: "layer-1", - sorting: { - attribute: "height", - direction: "desc", - }, -}); -``` - -*** - -## hideLayerDataTable() - -> **hideLayerDataTable**(): `Promise`\<`void`> - -Hides the data table. - -### Returns - -`Promise`\<`void`> - -### Example - -```typescript -await felt.hideLayerDataTable(); -``` - -*** - ## getMapDetails() > **getMapDetails**(): `Promise`\<[`MapDetails`](../Misc/MapDetails.md)> @@ -1220,6 +1164,62 @@ will still be selected when clicked. *** +## showLayerDataTable() + +> **showLayerDataTable**(`params`: \{ `layerId`: `string`; `sorting`: [`SortConfig`](../Shared/SortConfig.md); }): `Promise`\<`void`> + +Shows a data table view for the specified layer, optionally sorted by a given attribute. + +### Parameters + +| Parameter | Type | +| ----------------- | ----------------------------------------------------------------------------- | +| `params` | \{ `layerId`: `string`; `sorting`: [`SortConfig`](../Shared/SortConfig.md); } | +| `params.layerId` | `string` | +| `params.sorting`? | [`SortConfig`](../Shared/SortConfig.md) | + +### Returns + +`Promise`\<`void`> + +### Example + +```typescript +// Show data table with default sorting +await felt.showLayerDataTable({ + layerId: "layer-1", +}); + +// Show data table sorted by height in descending order +await felt.showLayerDataTable({ + layerId: "layer-1", + sorting: { + attribute: "height", + direction: "desc", + }, +}); +``` + +*** + +## hideLayerDataTable() + +> **hideLayerDataTable**(): `Promise`\<`void`> + +Hides the data table. + +### Returns + +`Promise`\<`void`> + +### Example + +```typescript +await felt.hideLayerDataTable(); +``` + +*** + ## getViewport() > **getViewport**(): `Promise`\<[`ViewportState`](../Viewport/ViewportState.md)> diff --git a/docs/UI/UiController.md b/docs/UI/UiController.md index 7553822..dabe130 100644 --- a/docs/UI/UiController.md +++ b/docs/UI/UiController.md @@ -1,7 +1,9 @@ *** -The UI controller allows you to enable and disable UI controls on the -embedded map. +The UI controller allows you to control various aspects of the Felt UI in your embedded map. + +This includes enabling/disabling UI controls, managing on-map interactions, and controlling +the visibility of UI components like the data table. # Extended by @@ -50,3 +52,59 @@ will still be selected when clicked. ### Returns `void` + +*** + +## showLayerDataTable() + +> **showLayerDataTable**(`params`: \{ `layerId`: `string`; `sorting`: [`SortConfig`](../Shared/SortConfig.md); }): `Promise`\<`void`> + +Shows a data table view for the specified layer, optionally sorted by a given attribute. + +### Parameters + +| Parameter | Type | +| ----------------- | ----------------------------------------------------------------------------- | +| `params` | \{ `layerId`: `string`; `sorting`: [`SortConfig`](../Shared/SortConfig.md); } | +| `params.layerId` | `string` | +| `params.sorting`? | [`SortConfig`](../Shared/SortConfig.md) | + +### Returns + +`Promise`\<`void`> + +### Example + +```typescript +// Show data table with default sorting +await felt.showLayerDataTable({ + layerId: "layer-1", +}); + +// Show data table sorted by height in descending order +await felt.showLayerDataTable({ + layerId: "layer-1", + sorting: { + attribute: "height", + direction: "desc", + }, +}); +``` + +*** + +## hideLayerDataTable() + +> **hideLayerDataTable**(): `Promise`\<`void`> + +Hides the data table. + +### Returns + +`Promise`\<`void`> + +### Example + +```typescript +await felt.hideLayerDataTable(); +``` diff --git a/etc/js-sdk.api.md b/etc/js-sdk.api.md index 1940cc9..b61ff3c 100644 --- a/etc/js-sdk.api.md +++ b/etc/js-sdk.api.md @@ -4,114 +4,114 @@ ```ts -import { ap as AggregationConfig } from './types-Bw55doND.js'; -import { A as AggregationMethod } from './types-Bw55doND.js'; -import { R as CircleElementCreate } from './types-Bw55doND.js'; -import { U as CircleElementRead } from './types-Bw55doND.js'; -import { W as CircleElementUpdate } from './types-Bw55doND.js'; -import { aH as CircleToolSettings } from './types-Bw55doND.js'; -import { D as ConfigurableToolType } from './types-Bw55doND.js'; -import { E as Element_2 } from './types-Bw55doND.js'; -import { d as ElementChangeCallbackParams } from './types-Bw55doND.js'; -import { f as ElementCreate } from './types-Bw55doND.js'; -import { b as ElementGroup } from './types-Bw55doND.js'; -import { e as ElementGroupChangeCallbackParams } from './types-Bw55doND.js'; -import { as as ElementGroupNode } from './types-Bw55doND.js'; -import { at as ElementNode } from './types-Bw55doND.js'; -import { g as ElementUpdate } from './types-Bw55doND.js'; -import { B as EntityNode } from './types-Bw55doND.js'; -import { s as Feature } from './types-Bw55doND.js'; -import { au as FeatureNode } from './types-Bw55doND.js'; -import { C as FeatureSelection } from './types-Bw55doND.js'; -import { ax as FeltBoundary } from './types-Bw55doND.js'; -import { ay as FeltZoom } from './types-Bw55doND.js'; -import { am as FilterExpression } from './types-Bw55doND.js'; -import { an as FilterLogicGate } from './types-Bw55doND.js'; -import { F as Filters } from './types-Bw55doND.js'; -import { ao as FilterTernary } from './types-Bw55doND.js'; -import { G as Geometry } from './types-Bw55doND.js'; -import { c as GetElementGroupsConstraint } from './types-Bw55doND.js'; -import { a as GetElementsConstraint } from './types-Bw55doND.js'; -import { x as GetLayerCalculationParams } from './types-Bw55doND.js'; -import { u as GetLayerCategoriesGroup } from './types-Bw55doND.js'; -import { t as GetLayerCategoriesParams } from './types-Bw55doND.js'; -import { k as GetLayerGroupsConstraint } from './types-Bw55doND.js'; -import { w as GetLayerHistogramBin } from './types-Bw55doND.js'; -import { v as GetLayerHistogramParams } from './types-Bw55doND.js'; -import { h as GetLayersConstraint } from './types-Bw55doND.js'; -import { r as GetRenderedFeaturesConstraint } from './types-Bw55doND.js'; -import { X as HighlighterElementCreate } from './types-Bw55doND.js'; -import { Y as HighlighterElementRead } from './types-Bw55doND.js'; -import { Z as HighlighterElementUpdate } from './types-Bw55doND.js'; -import { aI as HighlighterToolSettings } from './types-Bw55doND.js'; -import { _ as ImageElementCreate } from './types-Bw55doND.js'; -import { $ as ImageElementRead } from './types-Bw55doND.js'; -import { a0 as ImageElementUpdate } from './types-Bw55doND.js'; -import { I as InputToolSettings } from './types-Bw55doND.js'; -import { K } from './types-Bw55doND.js'; -import { az as LatLng } from './types-Bw55doND.js'; -import { L as Layer } from './types-Bw55doND.js'; -import { i as LayerChangeCallbackParams } from './types-Bw55doND.js'; -import { q as LayerFilters } from './types-Bw55doND.js'; -import { j as LayerGroup } from './types-Bw55doND.js'; -import { l as LayerGroupChangeCallbackParams } from './types-Bw55doND.js'; -import { av as LayerGroupNode } from './types-Bw55doND.js'; -import { aw as LayerNode } from './types-Bw55doND.js'; -import { ak as LayerProcessingStatus } from './types-Bw55doND.js'; -import { n as LegendItem } from './types-Bw55doND.js'; -import { p as LegendItemChangeCallbackParams } from './types-Bw55doND.js'; -import { m as LegendItemIdentifier } from './types-Bw55doND.js'; -import { o as LegendItemsConstraint } from './types-Bw55doND.js'; -import { aA as LineStringGeometry } from './types-Bw55doND.js'; -import { aJ as LineToolSettings } from './types-Bw55doND.js'; -import { a1 as LinkElementRead } from './types-Bw55doND.js'; -import { aB as LngLatTuple } from './types-Bw55doND.js'; -import { z as MapDetails } from './types-Bw55doND.js'; -import { M as MapInteractionEvent } from './types-Bw55doND.js'; -import { a2 as MarkerElementCreate } from './types-Bw55doND.js'; -import { a3 as MarkerElementRead } from './types-Bw55doND.js'; -import { a4 as MarkerElementUpdate } from './types-Bw55doND.js'; -import { aK as MarkerToolSettings } from './types-Bw55doND.js'; -import { aq as MultiAggregationConfig } from './types-Bw55doND.js'; -import { aC as MultiLineStringGeometry } from './types-Bw55doND.js'; -import { aD as MultiPolygonGeometry } from './types-Bw55doND.js'; -import { a5 as NoteElementCreate } from './types-Bw55doND.js'; -import { a6 as NoteElementRead } from './types-Bw55doND.js'; -import { a7 as NoteElementUpdate } from './types-Bw55doND.js'; -import { aL as NoteToolSettings } from './types-Bw55doND.js'; -import { a8 as PathElementCreate } from './types-Bw55doND.js'; -import { a9 as PathElementRead } from './types-Bw55doND.js'; -import { aa as PathElementUpdate } from './types-Bw55doND.js'; -import { aM as PinToolSettings } from './types-Bw55doND.js'; -import { ab as PlaceElementCreate } from './types-Bw55doND.js'; -import { ac as PlaceElementRead } from './types-Bw55doND.js'; -import { ad as PlaceElementUpdate } from './types-Bw55doND.js'; -import { aN as PlaceFrame } from './types-Bw55doND.js'; -import { aO as PlaceSymbol } from './types-Bw55doND.js'; -import { aE as PointGeometry } from './types-Bw55doND.js'; -import { ae as PolygonElementCreate } from './types-Bw55doND.js'; -import { af as PolygonElementRead } from './types-Bw55doND.js'; -import { ag as PolygonElementUpdate } from './types-Bw55doND.js'; -import { aF as PolygonGeometry } from './types-Bw55doND.js'; -import { aP as PolygonToolSettings } from './types-Bw55doND.js'; -import { al as RasterValue } from './types-Bw55doND.js'; -import { aQ as RouteToolSettings } from './types-Bw55doND.js'; -import { N as SetViewportCenterZoomParams } from './types-Bw55doND.js'; -import { S as SetVisibilityRequest } from './types-Bw55doND.js'; -import { y as SortConfig } from './types-Bw55doND.js'; -import { aG as SortDirection } from './types-Bw55doND.js'; -import { ah as TextElementCreate } from './types-Bw55doND.js'; -import { ai as TextElementRead } from './types-Bw55doND.js'; -import { aj as TextElementUpdate } from './types-Bw55doND.js'; -import { aR as TextToolSettings } from './types-Bw55doND.js'; -import { J as ToolSettingsChangeEvent } from './types-Bw55doND.js'; -import { H as ToolSettingsMap } from './types-Bw55doND.js'; -import { T as ToolType } from './types-Bw55doND.js'; -import { ar as ValueConfiguration } from './types-Bw55doND.js'; -import { Q as ViewportCenterZoom } from './types-Bw55doND.js'; -import { O as ViewportConstraints } from './types-Bw55doND.js'; -import { P as ViewportFitBoundsParams } from './types-Bw55doND.js'; -import { V as ViewportState } from './types-Bw55doND.js'; +import { ap as AggregationConfig } from './types-CZ8IFPkE.js'; +import { A as AggregationMethod } from './types-CZ8IFPkE.js'; +import { R as CircleElementCreate } from './types-CZ8IFPkE.js'; +import { U as CircleElementRead } from './types-CZ8IFPkE.js'; +import { W as CircleElementUpdate } from './types-CZ8IFPkE.js'; +import { aH as CircleToolSettings } from './types-CZ8IFPkE.js'; +import { C as ConfigurableToolType } from './types-CZ8IFPkE.js'; +import { E as Element_2 } from './types-CZ8IFPkE.js'; +import { d as ElementChangeCallbackParams } from './types-CZ8IFPkE.js'; +import { f as ElementCreate } from './types-CZ8IFPkE.js'; +import { b as ElementGroup } from './types-CZ8IFPkE.js'; +import { e as ElementGroupChangeCallbackParams } from './types-CZ8IFPkE.js'; +import { as as ElementGroupNode } from './types-CZ8IFPkE.js'; +import { at as ElementNode } from './types-CZ8IFPkE.js'; +import { g as ElementUpdate } from './types-CZ8IFPkE.js'; +import { z as EntityNode } from './types-CZ8IFPkE.js'; +import { s as Feature } from './types-CZ8IFPkE.js'; +import { au as FeatureNode } from './types-CZ8IFPkE.js'; +import { B as FeatureSelection } from './types-CZ8IFPkE.js'; +import { ax as FeltBoundary } from './types-CZ8IFPkE.js'; +import { ay as FeltZoom } from './types-CZ8IFPkE.js'; +import { am as FilterExpression } from './types-CZ8IFPkE.js'; +import { an as FilterLogicGate } from './types-CZ8IFPkE.js'; +import { F as Filters } from './types-CZ8IFPkE.js'; +import { ao as FilterTernary } from './types-CZ8IFPkE.js'; +import { G as Geometry } from './types-CZ8IFPkE.js'; +import { c as GetElementGroupsConstraint } from './types-CZ8IFPkE.js'; +import { a as GetElementsConstraint } from './types-CZ8IFPkE.js'; +import { x as GetLayerCalculationParams } from './types-CZ8IFPkE.js'; +import { u as GetLayerCategoriesGroup } from './types-CZ8IFPkE.js'; +import { t as GetLayerCategoriesParams } from './types-CZ8IFPkE.js'; +import { k as GetLayerGroupsConstraint } from './types-CZ8IFPkE.js'; +import { w as GetLayerHistogramBin } from './types-CZ8IFPkE.js'; +import { v as GetLayerHistogramParams } from './types-CZ8IFPkE.js'; +import { h as GetLayersConstraint } from './types-CZ8IFPkE.js'; +import { r as GetRenderedFeaturesConstraint } from './types-CZ8IFPkE.js'; +import { X as HighlighterElementCreate } from './types-CZ8IFPkE.js'; +import { Y as HighlighterElementRead } from './types-CZ8IFPkE.js'; +import { Z as HighlighterElementUpdate } from './types-CZ8IFPkE.js'; +import { aI as HighlighterToolSettings } from './types-CZ8IFPkE.js'; +import { _ as ImageElementCreate } from './types-CZ8IFPkE.js'; +import { $ as ImageElementRead } from './types-CZ8IFPkE.js'; +import { a0 as ImageElementUpdate } from './types-CZ8IFPkE.js'; +import { I as InputToolSettings } from './types-CZ8IFPkE.js'; +import { J } from './types-CZ8IFPkE.js'; +import { az as LatLng } from './types-CZ8IFPkE.js'; +import { L as Layer } from './types-CZ8IFPkE.js'; +import { i as LayerChangeCallbackParams } from './types-CZ8IFPkE.js'; +import { q as LayerFilters } from './types-CZ8IFPkE.js'; +import { j as LayerGroup } from './types-CZ8IFPkE.js'; +import { l as LayerGroupChangeCallbackParams } from './types-CZ8IFPkE.js'; +import { av as LayerGroupNode } from './types-CZ8IFPkE.js'; +import { aw as LayerNode } from './types-CZ8IFPkE.js'; +import { ak as LayerProcessingStatus } from './types-CZ8IFPkE.js'; +import { n as LegendItem } from './types-CZ8IFPkE.js'; +import { p as LegendItemChangeCallbackParams } from './types-CZ8IFPkE.js'; +import { m as LegendItemIdentifier } from './types-CZ8IFPkE.js'; +import { o as LegendItemsConstraint } from './types-CZ8IFPkE.js'; +import { aA as LineStringGeometry } from './types-CZ8IFPkE.js'; +import { aJ as LineToolSettings } from './types-CZ8IFPkE.js'; +import { a1 as LinkElementRead } from './types-CZ8IFPkE.js'; +import { aB as LngLatTuple } from './types-CZ8IFPkE.js'; +import { y as MapDetails } from './types-CZ8IFPkE.js'; +import { M as MapInteractionEvent } from './types-CZ8IFPkE.js'; +import { a2 as MarkerElementCreate } from './types-CZ8IFPkE.js'; +import { a3 as MarkerElementRead } from './types-CZ8IFPkE.js'; +import { a4 as MarkerElementUpdate } from './types-CZ8IFPkE.js'; +import { aK as MarkerToolSettings } from './types-CZ8IFPkE.js'; +import { aq as MultiAggregationConfig } from './types-CZ8IFPkE.js'; +import { aC as MultiLineStringGeometry } from './types-CZ8IFPkE.js'; +import { aD as MultiPolygonGeometry } from './types-CZ8IFPkE.js'; +import { a5 as NoteElementCreate } from './types-CZ8IFPkE.js'; +import { a6 as NoteElementRead } from './types-CZ8IFPkE.js'; +import { a7 as NoteElementUpdate } from './types-CZ8IFPkE.js'; +import { aL as NoteToolSettings } from './types-CZ8IFPkE.js'; +import { a8 as PathElementCreate } from './types-CZ8IFPkE.js'; +import { a9 as PathElementRead } from './types-CZ8IFPkE.js'; +import { aa as PathElementUpdate } from './types-CZ8IFPkE.js'; +import { aM as PinToolSettings } from './types-CZ8IFPkE.js'; +import { ab as PlaceElementCreate } from './types-CZ8IFPkE.js'; +import { ac as PlaceElementRead } from './types-CZ8IFPkE.js'; +import { ad as PlaceElementUpdate } from './types-CZ8IFPkE.js'; +import { aN as PlaceFrame } from './types-CZ8IFPkE.js'; +import { aO as PlaceSymbol } from './types-CZ8IFPkE.js'; +import { aE as PointGeometry } from './types-CZ8IFPkE.js'; +import { ae as PolygonElementCreate } from './types-CZ8IFPkE.js'; +import { af as PolygonElementRead } from './types-CZ8IFPkE.js'; +import { ag as PolygonElementUpdate } from './types-CZ8IFPkE.js'; +import { aF as PolygonGeometry } from './types-CZ8IFPkE.js'; +import { aP as PolygonToolSettings } from './types-CZ8IFPkE.js'; +import { al as RasterValue } from './types-CZ8IFPkE.js'; +import { aQ as RouteToolSettings } from './types-CZ8IFPkE.js'; +import { N as SetViewportCenterZoomParams } from './types-CZ8IFPkE.js'; +import { S as SetVisibilityRequest } from './types-CZ8IFPkE.js'; +import { K as SortConfig } from './types-CZ8IFPkE.js'; +import { aG as SortDirection } from './types-CZ8IFPkE.js'; +import { ah as TextElementCreate } from './types-CZ8IFPkE.js'; +import { ai as TextElementRead } from './types-CZ8IFPkE.js'; +import { aj as TextElementUpdate } from './types-CZ8IFPkE.js'; +import { aR as TextToolSettings } from './types-CZ8IFPkE.js'; +import { H as ToolSettingsChangeEvent } from './types-CZ8IFPkE.js'; +import { D as ToolSettingsMap } from './types-CZ8IFPkE.js'; +import { T as ToolType } from './types-CZ8IFPkE.js'; +import { ar as ValueConfiguration } from './types-CZ8IFPkE.js'; +import { Q as ViewportCenterZoom } from './types-CZ8IFPkE.js'; +import { O as ViewportConstraints } from './types-CZ8IFPkE.js'; +import { P as ViewportFitBoundsParams } from './types-CZ8IFPkE.js'; +import { V as ViewportState } from './types-CZ8IFPkE.js'; import { z } from 'zod'; export { AggregationConfig } @@ -207,7 +207,7 @@ export interface FeltController extends ViewportController, UiController, Layers // Warning: (ae-forgotten-export) The symbol "FeltEmbedOptionsSchema" needs to be exported by the entry point client.d.ts // // @public -export interface FeltEmbedOptions extends K { +export interface FeltEmbedOptions extends J { // (undocumented) initialViewport?: ViewportCenterZoom; // (undocumented) @@ -397,7 +397,6 @@ export interface LayersController { getLegendItems(constraint?: LegendItemsConstraint): Promise>; getRenderedFeatures( params?: GetRenderedFeaturesConstraint): Promise>; - hideLayerDataTable(): Promise; onLayerChange(args: { options: { id: string; @@ -432,10 +431,6 @@ export interface LayersController { show?: Array; hide?: Array; }): Promise; - showLayerDataTable(params: { - layerId: string; - sorting?: SortConfig; - }): Promise; } export { LegendItem } @@ -488,7 +483,7 @@ export { NoteToolSettings } // Warning: (ae-forgotten-export) The symbol "UiOnMapInteractionsOptionsSchema" needs to be exported by the entry point client.d.ts // // @public -export interface OnMapInteractionsOptions extends K { +export interface OnMapInteractionsOptions extends J { } export { PathElementCreate } @@ -578,14 +573,19 @@ export { ToolType } // @public export interface UiController { + hideLayerDataTable(): Promise; setOnMapInteractionsUi(options: OnMapInteractionsOptions): void; + showLayerDataTable(params: { + layerId: string; + sorting?: SortConfig; + }): Promise; updateUiControls(controls: UiControlsOptions): void; } // Warning: (ae-forgotten-export) The symbol "UiControlsOptionsSchema" needs to be exported by the entry point client.d.ts // // @public (undocumented) -export interface UiControlsOptions extends K { +export interface UiControlsOptions extends J { } // @internal (undocumented) diff --git a/src/modules/layers/controller.ts b/src/modules/layers/controller.ts index 0c0d9ca..a7ea1fe 100644 --- a/src/modules/layers/controller.ts +++ b/src/modules/layers/controller.ts @@ -1,5 +1,5 @@ import { listener, method } from "~/lib/interface"; -import type { SetVisibilityRequest, SortConfig } from "~/modules/shared/types"; +import type { SetVisibilityRequest } from "~/modules/shared/types"; import type { Filters, LayerFilters } from "./filters/types"; import type { AggregationMethod, @@ -63,10 +63,6 @@ export const layersController = (feltWindow: Window): LayersController => ({ getCategoryData: method(feltWindow, "getCategoryData"), getHistogramData: method(feltWindow, "getHistogramData"), getAggregates: method(feltWindow, "getAggregates"), - - // new method - showLayerDataTable: method(feltWindow, "showLayerDataTable"), - hideLayerDataTable: method(feltWindow, "hideLayerDataTable"), }); /** @@ -583,39 +579,4 @@ export interface LayersController { getAggregates( params: GetLayerCalculationParams, ): Promise>; - - /** - * Shows a data table view for the specified layer, optionally sorted by a given attribute. - * - * @example - * ```typescript - * // Show data table with default sorting - * await felt.showLayerDataTable({ - * layerId: "layer-1", - * }); - * - * // Show data table sorted by height in descending order - * await felt.showLayerDataTable({ - * layerId: "layer-1", - * sorting: { - * attribute: "height", - * direction: "desc", - * }, - * }); - * ``` - */ - showLayerDataTable(params: { - layerId: string; - sorting?: SortConfig; - }): Promise; - - /** - * Hides the data table. - * - * @example - * ```typescript - * await felt.hideLayerDataTable(); - * ``` - */ - hideLayerDataTable(): Promise; } diff --git a/src/modules/layers/schema.ts b/src/modules/layers/schema.ts index e9d8acf..d6ae54c 100644 --- a/src/modules/layers/schema.ts +++ b/src/modules/layers/schema.ts @@ -7,10 +7,7 @@ import { methodMessage, } from "~/lib/builders"; import type { zInfer } from "~/lib/utils"; -import { - SetVisibilityRequestSchema, - SortConfigSchema, -} from "~/modules/shared/types"; +import { SetVisibilityRequestSchema } from "~/modules/shared/types"; import { FiltersSchema, type LayerFilters } from "./filters/types"; import { type AggregationMethod, @@ -131,19 +128,6 @@ const GetLayerCalculationMessage = methodMessage( GetLayerCalculationParamsSchema, ); -const ShowLayerDataTableMessage = methodMessage( - "showLayerDataTable", - z.object({ - layerId: z.string(), - sorting: SortConfigSchema.optional(), - }), -); - -const HideLayerDataTableMessage = methodMessage( - "hideLayerDataTable", - z.undefined(), -); - export const layersSchema = { methods: [ GetLayerMessage, @@ -169,9 +153,6 @@ export const layersSchema = { GetLayerCategoriesMessage, GetLayerHistogramMessage, GetLayerCalculationMessage, - - ShowLayerDataTableMessage, - HideLayerDataTableMessage, ], listeners: [ OnLayerChangeMessage, @@ -242,9 +223,6 @@ export type LayersSchema = { zInfer, Record >; - - showLayerDataTable: Method, void>; - hideLayerDataTable: Method, void>; }; listeners: { onLayerChange: Listener< diff --git a/src/modules/ui/controller.ts b/src/modules/ui/controller.ts index ffe6c79..33b810f 100644 --- a/src/modules/ui/controller.ts +++ b/src/modules/ui/controller.ts @@ -1,4 +1,5 @@ import { method } from "~/lib/interface"; +import type { SortConfig } from "~/modules/shared/types"; import type { UiControlsOptions, UiOnMapInteractionsOptions } from "./types"; /** @@ -7,11 +8,16 @@ import type { UiControlsOptions, UiOnMapInteractionsOptions } from "./types"; export const uiController = (feltWindow: Window): UiController => ({ updateUiControls: method(feltWindow, "updateUiControls"), setOnMapInteractionsUi: method(feltWindow, "setOnMapInteractionsUi"), + + showLayerDataTable: method(feltWindow, "showLayerDataTable"), + hideLayerDataTable: method(feltWindow, "hideLayerDataTable"), }); /** - * The UI controller allows you to enable and disable UI controls on the - * embedded map. + * The UI controller allows you to control various aspects of the Felt UI in your embedded map. + * + * This includes enabling/disabling UI controls, managing on-map interactions, and controlling + * the visibility of UI components like the data table. * * @group Controller * @public @@ -36,4 +42,39 @@ export interface UiController { * will still be selected when clicked. */ setOnMapInteractionsUi(options: UiOnMapInteractionsOptions): void; + + /** + * Shows a data table view for the specified layer, optionally sorted by a given attribute. + * + * @example + * ```typescript + * // Show data table with default sorting + * await felt.showLayerDataTable({ + * layerId: "layer-1", + * }); + * + * // Show data table sorted by height in descending order + * await felt.showLayerDataTable({ + * layerId: "layer-1", + * sorting: { + * attribute: "height", + * direction: "desc", + * }, + * }); + * ``` + */ + showLayerDataTable(params: { + layerId: string; + sorting?: SortConfig; + }): Promise; + + /** + * Hides the data table. + * + * @example + * ```typescript + * await felt.hideLayerDataTable(); + * ``` + */ + hideLayerDataTable(): Promise; } diff --git a/src/modules/ui/schema.ts b/src/modules/ui/schema.ts index ea55f9b..6ad844b 100644 --- a/src/modules/ui/schema.ts +++ b/src/modules/ui/schema.ts @@ -1,6 +1,8 @@ +import { z } from "zod"; import type { ModuleSchema } from "~/lib/ModuleSchema"; import { type Method, methodMessage } from "~/lib/builders"; import type { zInfer } from "~/lib/utils"; +import { SortConfigSchema } from "../shared/types"; import { UiControlsOptionsSchema, UiOnMapInteractionsOptionsSchema, @@ -16,8 +18,27 @@ const OnMapInteractionsMessage = methodMessage( UiOnMapInteractionsOptionsSchema, ); +const ShowLayerDataTableMessage = methodMessage( + "showLayerDataTable", + z.object({ + layerId: z.string(), + sorting: SortConfigSchema.optional(), + }), +); + +const HideLayerDataTableMessage = methodMessage( + "hideLayerDataTable", + z.undefined(), +); + export const uiSchema = { - methods: [UiControlsMessage, OnMapInteractionsMessage], + methods: [ + UiControlsMessage, + OnMapInteractionsMessage, + + ShowLayerDataTableMessage, + HideLayerDataTableMessage, + ], listeners: null, } satisfies ModuleSchema; @@ -28,6 +49,9 @@ export type UiSchema = { zInfer, void >; + + showLayerDataTable: Method, void>; + hideLayerDataTable: Method, void>; }; listeners: {}; }; From ffb05e9cda27812d711962de551aef17fe677526 Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Thu, 20 Mar 2025 09:44:42 +0100 Subject: [PATCH 5/5] Allow opening table pane with no layer --- docs/Main/FeltController.md | 9 ++++++--- docs/UI/UiController.md | 9 ++++++--- etc/js-sdk.api.md | 2 +- src/modules/ui/controller.ts | 5 ++++- src/modules/ui/schema.ts | 10 ++++++---- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/docs/Main/FeltController.md b/docs/Main/FeltController.md index a461cdf..64eda44 100644 --- a/docs/Main/FeltController.md +++ b/docs/Main/FeltController.md @@ -1166,7 +1166,7 @@ will still be selected when clicked. ## showLayerDataTable() -> **showLayerDataTable**(`params`: \{ `layerId`: `string`; `sorting`: [`SortConfig`](../Shared/SortConfig.md); }): `Promise`\<`void`> +> **showLayerDataTable**(`params`?: \{ `layerId`: `string`; `sorting`: [`SortConfig`](../Shared/SortConfig.md); }): `Promise`\<`void`> Shows a data table view for the specified layer, optionally sorted by a given attribute. @@ -1174,8 +1174,8 @@ Shows a data table view for the specified layer, optionally sorted by a given at | Parameter | Type | | ----------------- | ----------------------------------------------------------------------------- | -| `params` | \{ `layerId`: `string`; `sorting`: [`SortConfig`](../Shared/SortConfig.md); } | -| `params.layerId` | `string` | +| `params`? | \{ `layerId`: `string`; `sorting`: [`SortConfig`](../Shared/SortConfig.md); } | +| `params.layerId`? | `string` | | `params.sorting`? | [`SortConfig`](../Shared/SortConfig.md) | ### Returns @@ -1198,6 +1198,9 @@ await felt.showLayerDataTable({ direction: "desc", }, }); + +// Show the data table pane with no table visible +await felt.showLayerDataTable(); ``` *** diff --git a/docs/UI/UiController.md b/docs/UI/UiController.md index dabe130..5670891 100644 --- a/docs/UI/UiController.md +++ b/docs/UI/UiController.md @@ -57,7 +57,7 @@ will still be selected when clicked. ## showLayerDataTable() -> **showLayerDataTable**(`params`: \{ `layerId`: `string`; `sorting`: [`SortConfig`](../Shared/SortConfig.md); }): `Promise`\<`void`> +> **showLayerDataTable**(`params`?: \{ `layerId`: `string`; `sorting`: [`SortConfig`](../Shared/SortConfig.md); }): `Promise`\<`void`> Shows a data table view for the specified layer, optionally sorted by a given attribute. @@ -65,8 +65,8 @@ Shows a data table view for the specified layer, optionally sorted by a given at | Parameter | Type | | ----------------- | ----------------------------------------------------------------------------- | -| `params` | \{ `layerId`: `string`; `sorting`: [`SortConfig`](../Shared/SortConfig.md); } | -| `params.layerId` | `string` | +| `params`? | \{ `layerId`: `string`; `sorting`: [`SortConfig`](../Shared/SortConfig.md); } | +| `params.layerId`? | `string` | | `params.sorting`? | [`SortConfig`](../Shared/SortConfig.md) | ### Returns @@ -89,6 +89,9 @@ await felt.showLayerDataTable({ direction: "desc", }, }); + +// Show the data table pane with no table visible +await felt.showLayerDataTable(); ``` *** diff --git a/etc/js-sdk.api.md b/etc/js-sdk.api.md index b61ff3c..97dfec0 100644 --- a/etc/js-sdk.api.md +++ b/etc/js-sdk.api.md @@ -575,7 +575,7 @@ export { ToolType } export interface UiController { hideLayerDataTable(): Promise; setOnMapInteractionsUi(options: OnMapInteractionsOptions): void; - showLayerDataTable(params: { + showLayerDataTable(params?: { layerId: string; sorting?: SortConfig; }): Promise; diff --git a/src/modules/ui/controller.ts b/src/modules/ui/controller.ts index 33b810f..af14557 100644 --- a/src/modules/ui/controller.ts +++ b/src/modules/ui/controller.ts @@ -61,9 +61,12 @@ export interface UiController { * direction: "desc", * }, * }); + * + * // Show the data table pane with no table visible + * await felt.showLayerDataTable(); * ``` */ - showLayerDataTable(params: { + showLayerDataTable(params?: { layerId: string; sorting?: SortConfig; }): Promise; diff --git a/src/modules/ui/schema.ts b/src/modules/ui/schema.ts index 6ad844b..08b0618 100644 --- a/src/modules/ui/schema.ts +++ b/src/modules/ui/schema.ts @@ -20,10 +20,12 @@ const OnMapInteractionsMessage = methodMessage( const ShowLayerDataTableMessage = methodMessage( "showLayerDataTable", - z.object({ - layerId: z.string(), - sorting: SortConfigSchema.optional(), - }), + z + .object({ + layerId: z.string(), + sorting: SortConfigSchema.optional(), + }) + .optional(), ); const HideLayerDataTableMessage = methodMessage(