mapcomplete/Docs/SpecialInputElements.md

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

245 lines
6.9 KiB
Markdown
Raw Normal View History

2023-02-12 23:08:57 +01:00
[//]: # (WARNING: this file is automatically generated. Please find the sources at the bottom and edit those sources)
2022-02-14 04:59:49 +01:00
2024-04-28 03:46:56 +02:00
Available types for text fields
===============================
2022-02-14 04:59:49 +01:00
The listed types here trigger a special input element. Use them in `tagrendering.freeform.type` of your tagrendering to activate them
2024-04-28 03:46:56 +02:00
### Table of contents
1. [string](#string)
2. [text](#text)
3. [date](#date)
4. [nat](#nat)
5. [int](#int)
6. [distance](#distance)
7. [direction](#direction)
8. [Input helper](#input-helper)
9. [wikidata](#wikidata)
10. [Helper arguments](#helper-arguments)
11. [Example usage](#example-usage)
12. [pnat](#pnat)
13. [float](#float)
14. [pfloat](#pfloat)
15. [email](#email)
16. [url](#url)
17. [phone](#phone)
18. [opening\_hours](#opening_hours)
19. [Helper arguments](#helper-arguments)
20. [Example usage](#example-usage)
21. [color](#color)
22. [image](#image)
23. [simple\_tag](#simple_tag)
24. [tag](#tag)
25. [key](#key)
26. [translation](#translation)
27. [icon](#icon)
28. [fediverse](#fediverse)
29. [id](#id)
30. [slope](#slope)
31. [velopark](#velopark)
32. [currency](#currency)
### string
2021-05-11 10:14:33 +02:00
2022-02-14 23:23:34 +01:00
A simple piece of text
2024-04-28 03:46:56 +02:00
### text
2021-07-24 02:42:37 +02:00
2023-02-10 01:49:06 +01:00
A longer piece of text. Uses an textArea instead of a textField
2024-04-28 03:46:56 +02:00
### date
2021-11-30 22:50:48 +01:00
2022-02-14 23:23:34 +01:00
A date with date picker
2024-04-28 03:46:56 +02:00
### nat
2022-02-14 04:59:49 +01:00
2024-04-28 03:46:56 +02:00
A whole, positive number or zero
2022-02-14 04:59:49 +01:00
2024-04-28 03:46:56 +02:00
### int
2022-02-14 23:23:34 +01:00
A whole number, either positive, negative or zero
2024-04-28 03:46:56 +02:00
### distance
2021-11-30 22:50:48 +01:00
2024-04-28 03:46:56 +02:00
A geographical distance in meters (rounded at two points). Will give an extra minimap with a measurement tool. Arguments: \[ zoomlevel, preferredBackgroundMapType (comma separated) \], e.g. \`\["21", "map,photo"\]
2022-02-14 23:23:34 +01:00
2024-04-28 03:46:56 +02:00
### direction
2022-02-14 23:23:34 +01:00
A geographical direction, in degrees. 0° is north, 90° is east, ... Will return a value between 0 (incl) and 360 (excl).
### Input helper
This element has an input helper showing a map and 'viewport' indicating the direction. By default, this map is zoomed to zoomlevel 17, but this can be changed with the first argument
2022-02-14 23:23:34 +01:00
2024-04-28 03:46:56 +02:00
### wikidata
2022-02-14 23:23:34 +01:00
2024-04-28 03:46:56 +02:00
A wikidata identifier, e.g. Q42.
2022-02-14 23:23:34 +01:00
2024-04-28 03:46:56 +02:00
### Helper arguments
2022-02-14 04:59:49 +01:00
2024-04-28 03:46:56 +02:00
name
2022-02-14 04:59:49 +01:00
2024-04-28 03:46:56 +02:00
doc
2024-04-28 03:46:56 +02:00
key
2024-04-28 03:46:56 +02:00
the value of this tag will initialize search (default: name). This can be a ';'-separated list in which case every key will be inspected. The non-null value will be used as search
2024-04-28 03:46:56 +02:00
options
2021-11-08 02:36:01 +01:00
2024-04-28 03:46:56 +02:00
A JSON-object of type `{ removePrefixes: string[], removePostfixes: string[] }`.
2022-02-14 04:59:49 +01:00
2024-04-28 03:46:56 +02:00
subarg | doc -------- | ----- removePrefixes | remove these snippets of text from the start of the passed string to search. This is either a list OR a hash of languages to a list. The individual strings are interpreted as case ignoring regexes removePostfixes | remove these snippets of text from the end of the passed string to search. This is either a list OR a hash of languages to a list. The individual strings are interpreted as case ignoring regexes. instanceOf | A list of Q-identifier which indicates that the search results _must_ be an entity of this type, e.g. [`Q5`](https://www.wikidata.org/wiki/Q5) for humans notInstanceof | A list of Q-identifiers which indicates that the search results _must not_ be an entity of this type, e.g. [`Q79007`](https://www.wikidata.org/wiki/Q79007) to filter away all streets from the search results
2021-10-29 03:59:28 +02:00
2024-04-28 03:46:56 +02:00
### Example usage
2024-04-28 03:46:56 +02:00
The following is the 'freeform'-part of a layer config which will trigger a search for the wikidata item corresponding with the name of the selected feature. It will also remove '-street', '-square', ... if found at the end of the name
2024-04-28 03:46:56 +02:00
"freeform": {
"key": "name:etymology:wikidata",
"type": "wikidata",
"helperArgs": [
2024-04-28 03:46:56 +02:00
"name",
{
"removePostfixes": {"en": [
"street",
"boulevard",
"path",
"square",
"plaza",
],
"nl": ["straat","plein","pad","weg",laan"],
"fr":["route (de|de la|de l'| de le)"]
},
"#": "Remove streets and parks from the search results:"
"notInstanceOf": ["Q79007","Q22698"]
}
]
}
2024-04-28 03:46:56 +02:00
Another example is to search for species and trees:
2024-04-28 03:46:56 +02:00
"freeform": {
"key": "species:wikidata",
"type": "wikidata",
"helperArgs": [
"species",
{
"instanceOf": [10884, 16521]
}]
}
2022-02-14 04:59:49 +01:00
2024-04-28 03:46:56 +02:00
### pnat
2021-05-11 10:14:33 +02:00
A strict positive number
2024-04-28 03:46:56 +02:00
### float
2021-05-11 10:14:33 +02:00
A decimal number
2024-04-28 03:46:56 +02:00
### pfloat
2021-05-11 10:14:33 +02:00
A positive decimal number or zero
2024-04-28 03:46:56 +02:00
### email
2021-11-30 22:50:48 +01:00
An email adress
2024-04-28 03:46:56 +02:00
### url
2024-04-28 03:46:56 +02:00
The validatedTextField will format URLs to always be valid and have a [https://-header](https://-header) (even though the 'https'-part will be hidden from the user. Furthermore, some tracking parameters will be removed
2021-11-30 22:50:48 +01:00
2024-04-28 03:46:56 +02:00
### phone
2021-11-30 22:50:48 +01:00
A phone number
2024-04-28 03:46:56 +02:00
### opening\_hours
2024-04-28 03:46:56 +02:00
Has extra elements to easily input when a POI is opened.
2021-11-30 22:50:48 +01:00
2024-04-28 03:46:56 +02:00
### Helper arguments
2022-02-14 04:59:49 +01:00
2024-04-28 03:46:56 +02:00
name
2024-04-28 03:46:56 +02:00
doc
2024-04-28 03:46:56 +02:00
options
2024-04-28 03:46:56 +02:00
A JSON-object of type `{ prefix: string, postfix: string }`.
2022-02-14 04:59:49 +01:00
2024-04-28 03:46:56 +02:00
subarg | doc -------- | ----- prefix | Piece of text that will always be added to the front of the generated opening hours. If the OSM-data does not start with this, it will fail to parse. postfix | Piece of text that will always be added to the end of the generated opening hours
2024-04-28 03:46:56 +02:00
### Example usage
2024-04-28 03:46:56 +02:00
To add a conditional (based on time) access restriction:
2021-10-29 03:59:28 +02:00
2024-04-28 03:46:56 +02:00
"freeform": {
"key": "access:conditional",
"type": "opening_hours",
"helperArgs": [
{
"prefix":"no @ (",
"postfix":")"
}
]
}
2022-02-14 04:59:49 +01:00
2024-04-28 03:46:56 +02:00
_Don't forget to pass the prefix and postfix in the rendering as well_: `{opening_hours_table(opening_hours,yes @ &LPARENS, &RPARENS )`
2021-05-11 10:14:33 +02:00
2024-04-28 03:46:56 +02:00
### color
2021-05-11 10:14:33 +02:00
2023-06-22 14:03:24 +02:00
Shows a color picker
2024-04-28 03:46:56 +02:00
### image
2023-06-22 14:03:24 +02:00
Same as the URL-parameter, except that it checks that the URL ends with `.jpg`, `.png` or some other typical image format
2024-04-28 03:46:56 +02:00
### simple\_tag
2023-06-22 14:03:24 +02:00
2024-04-28 03:46:56 +02:00
A simple tag of the format `key=value` where `key` conforms to a normal key \`
2023-06-22 14:03:24 +02:00
2024-04-28 03:46:56 +02:00
### tag
2023-08-24 12:22:45 +02:00
A simple tag of the format `key=value` OR a tagExpression
2024-04-28 03:46:56 +02:00
### key
2023-06-22 14:03:24 +02:00
2023-07-28 00:29:21 +02:00
Validates a key, mostly that no weird characters are used
2021-11-08 02:36:01 +01:00
2024-04-28 03:46:56 +02:00
### translation
2023-07-28 00:29:21 +02:00
2024-04-28 03:46:56 +02:00
Makes sure the the string is of format `Record<string, string>`
2023-07-28 00:29:21 +02:00
2024-04-28 03:46:56 +02:00
### icon
2023-08-24 12:22:45 +02:00
Makes sure that a valid .svg-path is added
2024-04-28 03:46:56 +02:00
### fediverse
2023-08-24 12:22:45 +02:00
2024-04-28 03:46:56 +02:00
Validates fediverse addresses and normalizes them into `@username@server`\-format
2023-08-24 12:22:45 +02:00
2024-04-28 03:46:56 +02:00
### id
2023-10-07 03:04:29 +02:00
2023-12-21 01:46:18 +01:00
Checks for valid identifiers for layers, will automatically replace spaces and uppercase
2024-04-28 03:46:56 +02:00
### slope
2023-12-21 01:46:18 +01:00
2024-02-12 12:52:28 +01:00
Validates that the slope is a valid number.The accompanying input element uses the gyroscope and the compass to determine the correct incline. The sign of the incline will be set automatically. The bearing of the way is compared to the bearing of the compass, as such, the device knows if it is measuring in the forward or backward direction.
2024-04-28 03:46:56 +02:00
### velopark
2024-02-12 12:52:28 +01:00
2024-04-28 01:49:01 +02:00
A special URL-validator that checks the domain name and rewrites to the correct velopark format.
2024-04-28 03:46:56 +02:00
### currency
2024-04-28 01:49:01 +02:00
2024-04-28 03:46:56 +02:00
Validates monetary amounts
2021-11-08 02:36:01 +01:00
2023-07-20 13:28:38 +02:00
This document is autogenerated from [src/UI/InputElement/Validators.ts](https://github.com/pietervdvn/MapComplete/blob/develop/src/UI/InputElement/Validators.ts)