mapcomplete/UI/InputElement/InputHelper.svelte

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
782 B
Svelte
Raw Normal View History

2023-03-29 17:21:20 +02:00
<script lang="ts">
/**
* Constructs an input helper element for the given type.
* Note that all values are stringified
*/
2023-03-29 17:21:20 +02:00
import { UIEventSource } from "../../Logic/UIEventSource";
import type { ValidatorType } from "./Validators";
import InputHelpers from "./InputHelpers";
import ToSvelte from "../Base/ToSvelte.svelte";
import type { Feature } from "geojson";
2023-03-29 17:21:20 +02:00
export let type: ValidatorType;
export let value: UIEventSource<string>;
export let feature: Feature;
export let args: (string | number | boolean)[] = undefined;
2023-03-29 17:21:20 +02:00
let properties = { feature, args: args ?? [] };
let construct = InputHelpers.AvailableInputHelpers[type];
2023-03-29 17:21:20 +02:00
</script>
{#if construct !== undefined}
<ToSvelte construct={() => construct(value, properties)} />
{/if}