@feltmaps/js-sdk 1.7.0-next.21 → 1.7.0-next.22

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.
@@ -4124,7 +4124,7 @@ interface ElementChangeCallbackParams {
4124
4124
  *
4125
4125
  * If the user is editing an existing element, this will be false.
4126
4126
  *
4127
- * For elements that are created programatically, this will be false.
4127
+ * For elements that are created programmatically, this will be false.
4128
4128
  */
4129
4129
  isBeingCreated: boolean;
4130
4130
  }
@@ -4251,7 +4251,7 @@ interface ElementsController {
4251
4251
  * @example
4252
4252
  * ```typescript
4253
4253
  * const unsubscribe = felt.onElementCreate({
4254
- * handler: (element) => console.log(element.id),
4254
+ * handler: ({isBeingCreated, element}) => console.log(element.id),
4255
4255
  * });
4256
4256
  *
4257
4257
  * // later on...
@@ -4262,7 +4262,7 @@ interface ElementsController {
4262
4262
  /**
4263
4263
  * The handler that is called when an element is created.
4264
4264
  *
4265
- * This will fire when elements are created programatically, or when the
4265
+ * This will fire when elements are created programmatically, or when the
4266
4266
  * user starts creating an element with a drawing tool.
4267
4267
  *
4268
4268
  * When the user creates an element with a drawing tool, it can begin in
@@ -4294,7 +4294,7 @@ interface ElementsController {
4294
4294
  * @event
4295
4295
  * @example
4296
4296
  * ```typescript
4297
- * const unsubscribe = felt.onToolCreatedElement({
4297
+ * const unsubscribe = felt.onElementCreateEnd({
4298
4298
  * handler: (params) => console.log(params),
4299
4299
  * });
4300
4300
  *
@@ -4316,7 +4316,7 @@ interface ElementsController {
4316
4316
  * Adds a listener for when an element changes.
4317
4317
  *
4318
4318
  * This will fire when an element is being edited, either on the map by the user
4319
- * or programatically.
4319
+ * or programmatically.
4320
4320
  *
4321
4321
  * Like the {@link ElementsController.onElementCreate | `onElementCreate`} listener, this will fire when an element is
4322
4322
  * still being created by a drawing tool.
@@ -4416,19 +4416,21 @@ interface ElementsController {
4416
4416
  */
4417
4417
  createElement(element: ElementCreate): Promise<Element>;
4418
4418
  /**
4419
- * Update an element on the map.
4419
+ * Update an element on the map. The element type must be specified.
4420
4420
  *
4421
4421
  * @example
4422
4422
  * ```typescript
4423
4423
  * // Update a place element's coordinates
4424
4424
  * await felt.updateElement({
4425
4425
  * id: "element-1",
4426
+ * type: "Place",
4426
4427
  * coordinates: [10, 20]
4427
4428
  * });
4428
4429
  *
4429
4430
  * // Update a polygon's style
4430
4431
  * await felt.updateElement({
4431
4432
  * id: "element-2",
4433
+ * type: "Polygon",
4432
4434
  * color: "#ABC123",
4433
4435
  * fillOpacity: 0.5
4434
4436
  * });
@@ -4754,7 +4756,7 @@ interface GeoJsonUrlVectorSource extends zInfer<typeof GeoJsonUrlVectorSourceSch
4754
4756
  }
4755
4757
  /**
4756
4758
  * A GeoJSON data source is a layer that is populated from GeoJSON data, such as
4757
- * from a local file, or programatically-created data.
4759
+ * from a local file, or programmatically-created data.
4758
4760
  *
4759
4761
  * @group Layer sources
4760
4762
  */
@@ -6784,7 +6786,7 @@ interface LayersController {
6784
6786
  * // first get the current style
6785
6787
  * const oldStyle = (await felt.getLayer("layer-1")).style;
6786
6788
  *
6787
- * felt.setLayerStyle({ id: "layer-1", style: {
6789
+ * await felt.setLayerStyle({ id: "layer-1", style: {
6788
6790
  * ...oldStyle,
6789
6791
  * paint: {
6790
6792
  * ...oldStyle.paint,
@@ -6866,7 +6868,7 @@ interface LayersController {
6866
6868
  *
6867
6869
  * const layerFromUrl = await felt.createLayersFromGeoJson({
6868
6870
  * source: {
6869
- * sourceType: "geoJsonUrl",
6871
+ * type: "geoJsonUrl",
6870
6872
  * url: "https://example.com/parcels.geojson",
6871
6873
  * },
6872
6874
  * name: "Parcels",
@@ -7447,15 +7449,18 @@ interface LayersController {
7447
7449
  * averages, sums, etc. You can focus your calculation on specific areas or subsets
7448
7450
  * of your data using boundaries and filters.
7449
7451
  *
7450
- * When no aggregation is specified, it counts features. When an aggregation is provided,
7451
- * it performs that calculation (average, sum, etc.) on the specified attribute.
7452
+ * When you request an aggregation other than count, you must specify an attribute to
7453
+ * aggregate on.
7452
7454
  *
7453
7455
  * @example
7454
7456
  * ```typescript
7455
7457
  * // Count all residential buildings
7456
7458
  * const residentialCount = await felt.getAggregates({
7457
7459
  * layerId: "buildings",
7458
- * filters: ["type", "eq", "residential"]
7460
+ * filters: ["type", "eq", "residential"],
7461
+ * aggregation: {
7462
+ * methods: ["count"],
7463
+ * }
7459
7464
  * });
7460
7465
  *
7461
7466
  * // Calculate average home value in a specific neighborhood
@@ -7833,7 +7838,7 @@ interface SelectionController {
7833
7838
  */
7834
7839
  selectFeature(params: FeatureSelection): Promise<void>;
7835
7840
  /**
7836
- * Clears the current selection. This clears the selection of
7841
+ * Clears the current selection (elements, features or both)
7837
7842
  *
7838
7843
  * @example
7839
7844
  * ```typescript
@@ -10354,70 +10359,54 @@ declare const uiPanelSchema: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.e
10354
10359
  }, ...args: unknown[]) => void) | undefined;
10355
10360
  }>;
10356
10361
  /**
10357
- * Represents a panel in the UI.
10358
- * It can be added to the map by using the {@link UiController.createOrUpdatePanel} method.
10359
- *
10360
- * A panel is a container for other UI elements.
10361
- * It can have a title, a body, a footer as well as a close button.
10362
+ * A UI panel that can be added to the map using {@link UiController.createOrUpdatePanel}.
10362
10363
  *
10363
- * The body and footer are arrays of UI elements and turn into vertical stacks of elements.
10364
- *
10365
- * The close button is a button rendered in the top right corner of the panel that can be
10366
- * used to close the panel and is only visible if `onClickClose` is provided.
10367
- * Usually, you want to call {@link UiController.deletePanel} when the close button is clicked,
10368
- * e.g. `onClickClose: () => felt.deletePanel("my-panel")`.
10364
+ * Panels are containers for UI elements with title, body, footer, and close button.
10365
+ * Body and footer elements are arranged in vertical stacks.
10369
10366
  *
10370
10367
  * #### Body
10371
- * Body is the main content of the panel. It is scrollable which means
10372
- * that it can contain a lot of elements.
10368
+ * Main content area that scrolls when content exceeds available space.
10373
10369
  *
10374
10370
  * #### Footer
10375
- * Footer is sticky to the bottom of the panel, and can be used to add actions to the panel (e.g. save, cancel, etc.).
10376
- *
10377
- * @example
10378
- * #### basic
10379
- * ```typescript
10380
- * {
10381
- * title: "My Panel",
10382
- * body: [
10383
- * { type: "Text", text: "Hello" },
10384
- * ],
10385
- * }
10386
- * ```
10371
+ * Sticky bottom section for action buttons (e.g., Save, Cancel).
10387
10372
  *
10388
- * @example
10389
- * #### closable
10390
- * ```typescript
10391
- * {
10392
- * id: "my-panel",
10393
- * title: "My Panel",
10394
- * onClickClose: () => felt.deletePanel("my-panel"),
10395
- * }
10373
+ * #### Close Button
10374
+ * Optional close icon in header. When `onClickClose` is provided, you must handle
10375
+ * panel cleanup and removal.
10396
10376
  *
10397
10377
  * @example
10398
- * #### form
10399
10378
  * ```typescript
10400
- * {
10401
- * title: "My Panel",
10402
- * body: [
10403
- * { type: "Text", text: "Introduce your name and last name" },
10404
- * { type: "TextInput", label: "Name", value: "", placeholder: "John", onChange: (value) => setName(value) },
10405
- * { type: "TextInput", label: "Last name", value: "", placeholder: "Doe", onChange: (value) => setLastName(value) },
10406
- * ],
10407
- * footer: [
10408
- * {
10409
- * type: "Grid",
10410
- * grid: "auto-flow / 1fr auto auto",
10411
- * items: [
10412
- * { type: "FlexibleSpace" }, // this will make the buttons to be aligned to the end of the panel
10413
- * { type: "Button", label: "Reset", onClick: () => alert("Reset") },
10414
- * { type: "Button", label: "Save", onClick: () => alert("Save") },
10415
- * ],
10416
- * },
10417
- * ],
10418
- * }
10379
+ * // 1. Create panel ID
10380
+ * const panelId = await felt.createPanelId();
10381
+ *
10382
+ * // 2. Create panel with close button and footer
10383
+ * await felt.createOrUpdatePanel({
10384
+ * panel: {
10385
+ * id: panelId,
10386
+ * title: "My Panel",
10387
+ * body: [
10388
+ * { type: "Text", content: "Hello, world!" },
10389
+ * { type: "TextInput", label: "Name", placeholder: "Enter your name" }
10390
+ * ],
10391
+ * footer: [
10392
+ * {
10393
+ * type: "ButtonRow",
10394
+ * align: "end",
10395
+ * items: [
10396
+ * { type: "Button", label: "Cancel", onClick: () => handleCancel() },
10397
+ * { type: "Button", label: "Save", onClick: () => handleSave() }
10398
+ * ]
10399
+ * }
10400
+ * ],
10401
+ * onClickClose: (args) => {
10402
+ * // Clean up any state or resources
10403
+ * cleanupResources();
10404
+ * // Close the panel
10405
+ * felt.deletePanel(panelId);
10406
+ * }
10407
+ * }
10408
+ * });
10419
10409
  * ```
10420
- *
10421
10410
  */
10422
10411
  interface UIPanel extends UIElementBase, Omit<zInfer<typeof uiPanelSchema>, "onClickClose" | "body" | "footer" | "onCreate" | "onDestroy" | "id"> {
10423
10412
  /**
@@ -13086,10 +13075,10 @@ interface UiController {
13086
13075
  * ```typescript
13087
13076
  * await felt.createActionTrigger({
13088
13077
  * actionTrigger: {
13089
- * id: "layerTurnPurple", // not required but useful for further updates
13090
- * label: "Turn layer purple",
13078
+ * id: "enablePolygonTool", // optional. Required if you want to update the action trigger later
13079
+ * label: "Draw polygon",
13091
13080
  * onTrigger: async () => {
13092
- * await felt.setLayerStyle("layer-1", { ..., paint: { color: "purple" } });
13081
+ * felt.setTool("polygon");
13093
13082
  * },
13094
13083
  * disabled: false, // optional, defaults to false
13095
13084
  * },
@@ -13111,8 +13100,8 @@ interface UiController {
13111
13100
  * @example
13112
13101
  * ```typescript
13113
13102
  * await felt.updateActionTrigger({
13114
- * id: "layerTurnPurple",
13115
- * label: "Turn layer points purple", // only label changes
13103
+ * id: "enablePolygonTool",
13104
+ * label: "Enable polygon tool", // only label changes
13116
13105
  * });
13117
13106
  * ```
13118
13107
  */
@@ -13124,7 +13113,7 @@ interface UiController {
13124
13113
  *
13125
13114
  * @example
13126
13115
  * ```typescript
13127
- * await felt.deleteActionTrigger("layerTurnPurple");
13116
+ * await felt.deleteActionTrigger("enablePolygonTool");
13128
13117
  * ```
13129
13118
  */
13130
13119
  deleteActionTrigger(id: string): void;
@@ -13142,66 +13131,72 @@ interface UiController {
13142
13131
  /**
13143
13132
  * Creates or updates a panel.
13144
13133
  *
13145
- * Panels are rendered on map's right sidebar and are useful to extend Felt UI for your own use cases
13146
- * (e.g. a form, a settings panel, etc.) using Felt UI elements (e.g. Text, Button, etc.).
13147
- * This way it is possible to cover new use cases while keeping the user experience consistent with the rest of Felt.
13134
+ * Panels are rendered on the map's right sidebar and allow you to extend Felt UI
13135
+ * for your own use cases using Felt UI elements (e.g., Text, Button, etc.).
13148
13136
  *
13149
- * A panel is identified by its ID and must come from {@link createPanelId}.
13150
- * Custom IDs are not supported in order to prevent conflicts with other panels.
13137
+ * A panel is identified by its ID, which must be created using {@link createPanelId}.
13138
+ * Custom IDs are not supported to prevent conflicts with other panels.
13151
13139
  *
13152
- * Panels have two sections:
13153
- * - `body` - Body of the panel, scrollable.
13154
- * - `footer` - It sticks to the bottom of the panel, useful to add submit buttons.
13140
+ * Panels have two main sections:
13141
+ * - `body` - The main content area of the panel, which is scrollable.
13142
+ * - `footer` - A section that sticks to the bottom of the panel, useful for
13143
+ * action buttons like "Submit" or "Cancel".
13155
13144
  *
13156
- * Regarding panel placement, by default it is added to the end of the panels stack but you can
13157
- * specify a different placement by using the `initialPlacement` parameter.
13158
- * This placement cannot be updated later.
13145
+ * Panel placement is controlled by the `initialPlacement` parameter. By default,
13146
+ * panels are added to the end of the panel stack, but you can specify a different
13147
+ * placement. Note that this placement cannot be changed after the panel is created.
13159
13148
  *
13160
- * When adding a panel, its elements' ids are optional though it is recommended to make
13161
- * it easier to update or delete them later.
13149
+ * Element IDs are required for targeted updates and deletions using the other
13150
+ * panel management methods. For complete panel refreshes with this method,
13151
+ * element IDs are optional but recommended for consistency.
13162
13152
  *
13163
- * Once created, you can add elements to the panel by using the {@link createPanelElements} method,
13164
- * perform partial updates of elements by using the {@link updatePanelElements} method or
13165
- * delete elements by using the {@link deletePanelElements} method.
13153
+ * For dynamic content management, consider these approaches:
13154
+ * - Use this method for complete panel refreshes (replaces all content)
13155
+ * - Use {@link createPanelElements} to add new elements to existing panels
13156
+ * - Use {@link updatePanelElements} to modify specific existing elements
13157
+ * - Use {@link deletePanelElements} to remove specific elements
13166
13158
  *
13167
- * @param args - The arguments for the method.
13168
- * @param args.panel - The panel to add.
13169
- * @param args.initialPlacement - The placement of the panel when added. Optional. Defaults to `{ at: "end" }`.
13170
- * - `{ at: "start" }` - Add the panel to the start of the stack.
13171
- * - `{ at: "end" }` - Add the panel to the end of the stack.
13172
- * - `{ after: "panel-1" }` - Add the panel after the panel with the id `panel-1`.
13173
- * - `{ before: "panel-1" }` - Add the panel before the panel with the id `panel-1`.
13159
+ * @param args - The arguments for creating or updating the panel.
13160
+ * @param args.panel - The panel configuration to create or update.
13161
+ * @param args.initialPlacement - The placement of the panel when first added.
13162
+ * Optional. Defaults to `{ at: "end" }`.
13163
+ * - `{ at: "start" }` - Add the panel to the start of the stack.
13164
+ * - `{ at: "end" }` - Add the panel to the end of the stack.
13165
+ * - `{ after: "panel-1" }` - Add the panel after the panel with the id `panel-1`.
13166
+ * - `{ before: "panel-1" }` - Add the panel before the panel with the id `panel-1`.
13174
13167
  *
13175
13168
  * @example
13176
13169
  * ```typescript
13177
- * const id = await felt.createPanelId();
13170
+ * // 1. Create panel ID first (required)
13171
+ * const panelId = await felt.createPanelId();
13178
13172
  *
13173
+ * // 2. Define reusable elements
13174
+ * const SELECT = { id: "layer-select", type: "Select", label: "Layer", options: [...] };
13175
+ * const ANALYZE_BTN = { id: "analyze-btn", type: "Button", label: "Analyze", onClick: handleAnalyze };
13176
+ * const STATUS_TEXT = { id: "status-text", type: "Text", content: "" };
13177
+ * const CLEAR_BTN = { id: "clear-btn", type: "Button", label: "Clear", onClick: handleClear };
13178
+ *
13179
+ * // 3. Initial state
13179
13180
  * await felt.createOrUpdatePanel({
13180
- * panel: {
13181
- * id,
13182
- * title: "My Panel",
13183
- * body: [
13184
- * {
13185
- * type: "Text",
13186
- * content: "Hello, world!",
13187
- * },
13188
- * {
13189
- * type: "TextInput",
13190
- * label: "Name",
13191
- * placeholder: "Enter your name",
13192
- * value: "",
13193
- * onChange: ({ value }) => setName(value),
13194
- * },
13195
- * ],
13196
- * footer: [
13197
- * {
13198
- * type: "Button",
13199
- * label: "Submit",
13200
- * onClick: () => submitForm(),
13201
- * },
13202
- * ],
13203
- * },
13204
- * initialPlacement: { at: "start" }, // when added, the panel will be added to the start of the stack
13181
+ * panel: { id: panelId, title: "Data Analyzer", body: [SELECT, ANALYZE_BTN] }
13182
+ * });
13183
+ *
13184
+ * // 4. Loading state (replaces entire panel)
13185
+ * await felt.createOrUpdatePanel({
13186
+ * panel: {
13187
+ * id: panelId,
13188
+ * title: "Data Analyzer",
13189
+ * body: [SELECT, ANALYZE_BTN, { ...STATUS_TEXT, content: "Loading..." }]
13190
+ * }
13191
+ * });
13192
+ *
13193
+ * // 5. Results state (replaces entire panel)
13194
+ * await felt.createOrUpdatePanel({
13195
+ * panel: {
13196
+ * id: panelId,
13197
+ * title: "Data Analyzer",
13198
+ * body: [SELECT, ANALYZE_BTN, { ...STATUS_TEXT, content: "**Results:**\n- Found 150 features" }, CLEAR_BTN]
13199
+ * }
13205
13200
  * });
13206
13201
  * ```
13207
13202
  */
@@ -13254,22 +13249,36 @@ interface UiController {
13254
13249
  */
13255
13250
  createPanelElements(args: CreatePanelElementsParams): Promise<UIPanel>;
13256
13251
  /**
13257
- * Updates an element in a panel.
13252
+ * Updates an existing element in a panel. This method can only update elements that
13253
+ * already exist in the panel and have an ID.
13258
13254
  *
13259
13255
  * @param args - The arguments for the method.
13260
13256
  * @param args.panelId - The id of the panel to update the element in.
13261
- * @param args.elements - Array of elements to update (`id` and `type` are required to identify the element to update).
13257
+ * @param args.elements - Array of elements to update. Each element must have an `id` and `type`
13258
+ * to identify which existing element to update. The element must already exist in the panel.
13262
13259
  *
13263
13260
  * @example
13264
13261
  * ```typescript
13262
+ * // 1. Create panel with initial elements
13263
+ * const panelId = await felt.createPanelId();
13264
+ * const STATUS_TEXT = { id: "status-text", type: "Text", content: "Ready" };
13265
+ *
13266
+ * await felt.createOrUpdatePanel({
13267
+ * panel: {
13268
+ * id: panelId,
13269
+ * title: "My Panel",
13270
+ * body: [STATUS_TEXT]
13271
+ * }
13272
+ * });
13273
+ *
13274
+ * // 2. Update the existing element
13265
13275
  * await felt.updatePanelElements({
13266
13276
  * panelId,
13267
13277
  * elements: [
13268
13278
  * {
13269
13279
  * element: {
13270
- * id: "element-1",
13271
- * type: "Text",
13272
- * content: "Hello, world!",
13280
+ * ...STATUS_TEXT, // Reuse the same element structure
13281
+ * content: "Updated content" // Only change what needs updating
13273
13282
  * },
13274
13283
  * },
13275
13284
  * ],