Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cuddly-wasps-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@feltmaps/js-sdk": patch
---

Fix feature action types and documentation
23 changes: 13 additions & 10 deletions docs/Main/FeltController.md
Original file line number Diff line number Diff line change
Expand Up @@ -1897,7 +1897,7 @@ await felt.deleteActionTrigger("enablePolygonTool");

## createFeatureAction()

> **createFeatureAction**(`args`: [`CreateFeatureActionParams`](../UI/CreateFeatureActionParams.md)): `Promise`\<[`uiFeatureAction`](../UI/uiFeatureAction.md)>
> **createFeatureAction**(`args`: [`CreateFeatureActionParams`](../UI/CreateFeatureActionParams.md)): `Promise`\<[`UIFeatureAction`](../UI/UIFeatureAction.md)>

Creates a feature contextual action.

Expand All @@ -1909,28 +1909,29 @@ Creates a feature contextual action.

### Returns

`Promise`\<[`uiFeatureAction`](../UI/uiFeatureAction.md)>
`Promise`\<[`UIFeatureAction`](../UI/UIFeatureAction.md)>

### Example

```typescript
const myAction = await felt.createFeatureAction({
action: {
label: "Edit feature",
onTrigger: async ({ featureId, layerId }) => {
console.log(`Editing feature ${featureId} in layer ${layerId}`);
label: "Add to selection",
onTrigger: async ({ feature }) => {
console.log(`Adding feature ${feature.id} from layer ${feature.layerId} to selection`);
},
layerIds: ["layer-1", "layer-2"],
layerIds: ["layer-1", "layer-2"], // Display the feature action only on these layers
},
placement: { at: "start" }, // optional, defaults to { at: "end" }
});

```

***

## updateFeatureAction()

> **updateFeatureAction**(`args`: [`UpdateFeatureActionParams`](../UI/UpdateFeatureActionParams.md)): `Promise`\<[`uiFeatureAction`](../UI/uiFeatureAction.md)>
> **updateFeatureAction**(`args`: [`UpdateFeatureActionParams`](../UI/UpdateFeatureActionParams.md)): `Promise`\<[`UIFeatureAction`](../UI/UIFeatureAction.md)>

Updates a feature contextual action.

Expand All @@ -1944,7 +1945,7 @@ Feature contextual action to update is identified by the `id` property.

### Returns

`Promise`\<[`uiFeatureAction`](../UI/uiFeatureAction.md)>
`Promise`\<[`UIFeatureAction`](../UI/UIFeatureAction.md)>

### Remarks

Expand All @@ -1953,8 +1954,9 @@ Properties provided will override the existing properties.
### Example

```typescript
const myAction = await felt.createFeatureAction({ ... });
await felt.updateFeatureAction({
id: "my-action",
id: myAction.id,
label: "Updated action label", // only label changes
});
```
Expand All @@ -1980,7 +1982,8 @@ Deletes a feature contextual action.
### Example

```typescript
await felt.deleteFeatureAction("my-action");
const myAction = await felt.createFeatureAction({ ... });
await felt.deleteFeatureAction(myAction.id);
```

***
Expand Down
2 changes: 1 addition & 1 deletion docs/UI/CreateFeatureActionParams.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## action

> **action**: [`uiFeatureActionCreate`](uiFeatureActionCreate.md)
> **action**: [`UIFeatureActionCreate`](UIFeatureActionCreate.md)

***

Expand Down
4 changes: 2 additions & 2 deletions docs/UI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ UI features such as the legend and the full screen button.
* [UIDividerElement](UIDividerElement.md)
* [UIDividerElementCreate](UIDividerElementCreate.md)
* [UIDividerElementUpdate](UIDividerElementUpdate.md)
* [uiFeatureActionCreate](uiFeatureActionCreate.md)
* [UIFeatureActionCreate](UIFeatureActionCreate.md)
* [UIFeatureAction](UIFeatureAction.md)
* [UIFlexibleSpaceElement](UIFlexibleSpaceElement.md)
* [UIFlexibleSpaceElementCreate](UIFlexibleSpaceElementCreate.md)
* [UIFlexibleSpaceElementUpdate](UIFlexibleSpaceElementUpdate.md)
Expand Down Expand Up @@ -63,7 +64,6 @@ UI features such as the legend and the full screen button.

# Type Aliases

* [uiFeatureAction](uiFeatureAction.md)
* [PlacementForUIElement](PlacementForUIElement.md)
* [UIPanelElement](UIPanelElement.md)
* [UIPanelElementCreate](UIPanelElementCreate.md)
Expand Down
96 changes: 96 additions & 0 deletions docs/UI/UIFeatureAction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
***

Represents a feature action after creation (with generated id).

# Properties

## label

> **label**: `string`

The label of the feature action.

***

## onTrigger()

> **onTrigger**: (`args`: \{ `feature`: [`LayerFeature`](../Layers/LayerFeature.md); }) => `void`

The function to call when the feature action is triggered.

### Parameters

| Parameter | Type | Description |
| -------------- | ------------------------------------------------------------ | -------------------------------------- |
| `args` | \{ `feature`: [`LayerFeature`](../Layers/LayerFeature.md); } | The arguments passed to the function. |
| `args.feature` | [`LayerFeature`](../Layers/LayerFeature.md) | The feature that triggered the action. |

### Returns

`void`

***

## id

> **id**: `string`

***

## layerIds?

> `optional` **layerIds**: `string`\[]

The layers to add the action to. Optional. Defaults to all layers.

***

## geometryTypes?

> `optional` **geometryTypes**: (`"Polygon"` | `"Point"` | `"Line"` | `"Raster"`)\[]

The geometry type of the features to add the action to. Optional. Defaults to all geometry types.

***

## type?

> `optional` **type**: `undefined`

***

## onCreate()?

> `optional` **onCreate**: (`args`: \{ `id`: `string`; }) => `void`

A function to call when the element is created.

### Parameters

| Parameter | Type | Description |
| --------- | -------------------- | ------------------------------------- |
| `args` | \{ `id`: `string`; } | The arguments passed to the function. |
| `args.id` | `string` | The id of the element. |

### Returns

`void`

***

## onDestroy()?

> `optional` **onDestroy**: (`args`: \{ `id`: `string`; }) => `void`

A function to call when the element is destroyed.

### Parameters

| Parameter | Type | Description |
| --------- | -------------------- | ------------------------------------- |
| `args` | \{ `id`: `string`; } | The arguments passed to the function. |
| `args.id` | `string` | The id of the element. |

### Returns

`void`
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ The function to call when the feature action is triggered.

***

## id?

> `optional` **id**: `string`

***

## layerIds?

> `optional` **layerIds**: `string`\[]
Expand Down
23 changes: 13 additions & 10 deletions docs/UI/UiController.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ await felt.deleteActionTrigger("enablePolygonTool");

## createFeatureAction()

> **createFeatureAction**(`args`: [`CreateFeatureActionParams`](CreateFeatureActionParams.md)): `Promise`\<[`uiFeatureAction`](uiFeatureAction.md)>
> **createFeatureAction**(`args`: [`CreateFeatureActionParams`](CreateFeatureActionParams.md)): `Promise`\<[`UIFeatureAction`](UIFeatureAction.md)>

Creates a feature contextual action.

Expand All @@ -121,28 +121,29 @@ Creates a feature contextual action.

### Returns

`Promise`\<[`uiFeatureAction`](uiFeatureAction.md)>
`Promise`\<[`UIFeatureAction`](UIFeatureAction.md)>

### Example

```typescript
const myAction = await felt.createFeatureAction({
action: {
label: "Edit feature",
onTrigger: async ({ featureId, layerId }) => {
console.log(`Editing feature ${featureId} in layer ${layerId}`);
label: "Add to selection",
onTrigger: async ({ feature }) => {
console.log(`Adding feature ${feature.id} from layer ${feature.layerId} to selection`);
},
layerIds: ["layer-1", "layer-2"],
layerIds: ["layer-1", "layer-2"], // Display the feature action only on these layers
},
placement: { at: "start" }, // optional, defaults to { at: "end" }
});

```

***

## updateFeatureAction()

> **updateFeatureAction**(`args`: [`UpdateFeatureActionParams`](UpdateFeatureActionParams.md)): `Promise`\<[`uiFeatureAction`](uiFeatureAction.md)>
> **updateFeatureAction**(`args`: [`UpdateFeatureActionParams`](UpdateFeatureActionParams.md)): `Promise`\<[`UIFeatureAction`](UIFeatureAction.md)>

Updates a feature contextual action.

Expand All @@ -156,7 +157,7 @@ Feature contextual action to update is identified by the `id` property.

### Returns

`Promise`\<[`uiFeatureAction`](uiFeatureAction.md)>
`Promise`\<[`UIFeatureAction`](UIFeatureAction.md)>

### Remarks

Expand All @@ -165,8 +166,9 @@ Properties provided will override the existing properties.
### Example

```typescript
const myAction = await felt.createFeatureAction({ ... });
await felt.updateFeatureAction({
id: "my-action",
id: myAction.id,
label: "Updated action label", // only label changes
});
```
Expand All @@ -192,7 +194,8 @@ Deletes a feature contextual action.
### Example

```typescript
await felt.deleteFeatureAction("my-action");
const myAction = await felt.createFeatureAction({ ... });
await felt.deleteFeatureAction(myAction.id);
```

***
Expand Down
60 changes: 56 additions & 4 deletions docs/UI/UpdateFeatureActionParams.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,82 @@

> `optional` **label**: `string`

The label of the feature action.

***

## layerIds?

> `optional` **layerIds**: `string`\[]

The layers to add the action to. Optional. Defaults to all layers.

***

## geometryTypes?

> `optional` **geometryTypes**: (`"Polygon"` | `"Point"` | `"Line"` | `"Raster"`)\[]

The geometry type of the features to add the action to. Optional. Defaults to all geometry types.

***

## type?

> `optional` **type**: `undefined`

***

## onTrigger()?

> `optional` **onTrigger**: (`args`: \{ `feature`: [`LayerFeature`](../Layers/LayerFeature.md); }) => `void`

The function to call when the feature action is triggered.

### Parameters

| Parameter | Type | Description |
| -------------- | ------------------------------------------------------------ | -------------------------------------- |
| `args` | \{ `feature`: [`LayerFeature`](../Layers/LayerFeature.md); } | The arguments passed to the function. |
| `args.feature` | [`LayerFeature`](../Layers/LayerFeature.md) | The feature that triggered the action. |

### Returns

`void`

***

## onCreate()?

> `optional` **onCreate**: (`args`: \{ `id`: `string`; }) => `void`

A function to call when the element is created.

### Parameters

| Parameter | Type | Description |
| --------- | -------------------- | ------------------------------------- |
| `args` | \{ `id`: `string`; } | The arguments passed to the function. |
| `args.id` | `string` | The id of the element. |

### Returns

`void`

***

## onDestroy()?

> `optional` **onDestroy**: (`args`: \{ `id`: `string`; }) => `void`

A function to call when the element is destroyed.

### Parameters

| Parameter | Type |
| -------------- | ------------------------------------------------------------ |
| `args` | \{ `feature`: [`LayerFeature`](../Layers/LayerFeature.md); } |
| `args.feature` | [`LayerFeature`](../Layers/LayerFeature.md) |
| Parameter | Type | Description |
| --------- | -------------------- | ------------------------------------- |
| `args` | \{ `id`: `string`; } | The arguments passed to the function. |
| `args.id` | `string` | The id of the element. |

### Returns

Expand Down
Loading