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
Available types for text fields
2021-10-29 13:53:00 +02:00
=================================
2022-02-14 04:59:49 +01:00
2022-01-14 19:34:00 +01:00
## Table of contents
2021-10-29 13:53:00 +02:00
2021-11-30 22:50:48 +01:00
1. [Available types for text fields ](#available-types-for-text-fields )
+ [string ](#string )
+ [text ](#text )
+ [date ](#date )
2022-02-14 23:23:34 +01:00
+ [nat ](#nat )
+ [int ](#int )
2022-06-22 15:29:10 +02:00
+ [distance ](#distance )
2021-11-30 22:50:48 +01:00
+ [direction ](#direction )
+ [wikidata ](#wikidata )
+ [pnat ](#pnat )
+ [float ](#float )
+ [pfloat ](#pfloat )
+ [email ](#email )
+ [url ](#url )
+ [phone ](#phone )
+ [opening_hours ](#opening_hours )
+ [color ](#color )
2023-06-22 14:03:24 +02:00
+ [image ](#image )
+ [simple_tag ](#simple_tag )
2023-08-24 12:22:45 +02:00
+ [tag ](#tag )
2023-06-22 14:03:24 +02:00
+ [key ](#key )
2023-07-28 00:29:21 +02:00
+ [translation ](#translation )
2023-08-24 12:22:45 +02:00
+ [icon ](#icon )
+ [fediverse ](#fediverse )
2023-10-07 03:04:29 +02:00
+ [id ](#id )
2021-05-11 10:14:33 +02:00
2022-01-14 19:34:00 +01:00
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
### string
2021-05-11 10:14:33 +02:00
2022-02-14 23:23:34 +01:00
A simple piece of text
2022-01-14 19:34:00 +01:00
2022-02-14 04:59:49 +01: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
2022-01-14 19:34:00 +01:00
2022-02-14 04:59:49 +01:00
### date
2021-11-30 22:50:48 +01:00
2022-02-14 23:23:34 +01:00
A date with date picker
2022-01-14 19:34:00 +01:00
2022-02-14 04:59:49 +01:00
2022-02-14 23:23:34 +01:00
### nat
2022-02-14 04:59:49 +01:00
2021-11-30 22:50:48 +01:00
2023-04-15 03:15:17 +02:00
A whole, positive number or zero
2022-02-14 23:23:34 +01:00
2022-01-14 19:34:00 +01:00
2022-02-14 23:23:34 +01:00
### int
2023-04-15 03:15:17 +02:00
A whole number, either positive, negative or zero
2022-01-14 19:34:00 +01:00
2021-11-30 22:50:48 +01:00
2022-02-14 23:23:34 +01:00
2022-06-22 15:29:10 +02:00
### distance
2022-02-14 04:59:49 +01:00
2022-06-22 15:29:10 +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 04:59:49 +01:00
2022-02-14 23:23:34 +01:00
### direction
2023-04-19 13:23:46 +02: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
2022-02-14 04:59:49 +01:00
### wikidata
2021-07-24 02:42:37 +02:00
2022-02-14 04:59:49 +01:00
A wikidata identifier, e.g. Q42.
### Helper arguments
2021-10-29 03:42:33 +02:00
name | doc
------ | -----
key | the value of this tag will initialize search (default: name)
2022-02-14 04:59:49 +01:00
options | A JSON-object of type `{ removePrefixes: string[], removePostfixes: string[] }` .
2021-10-29 03:42:33 +02:00
2022-12-06 03:41:27 +01:00
subarg \| doc
2023-09-19 13:44:31 +02:00
-------- \| -----
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:42:33 +02:00
2022-02-14 04:59:49 +01:00
2021-11-08 02:36:01 +01:00
2022-02-14 04:59:49 +01:00
### Example usage
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
2021-10-29 03:59:28 +02:00
2022-05-06 17:26:00 +02:00
```json
2021-10-29 03:59:28 +02:00
"freeform": {
2021-10-29 13:35:33 +02:00
"key": "name:etymology:wikidata",
"type": "wikidata",
"helperArgs": [
"name",
{
2022-06-24 03:52:54 +02:00
"removePostfixes": {"en": [
2021-10-29 13:35:33 +02:00
"street",
"boulevard",
"path",
"square",
"plaza",
2022-05-06 17:26:00 +02:00
],
2023-03-08 19:17:03 +01:00
"nl": ["straat","plein","pad","weg",laan"],
"fr":["route (de|de la|de l'| de le)"]
2022-06-24 03:52:54 +02:00
},
2023-01-17 03:18:39 +01:00
2022-05-06 17:26:00 +02:00
"#": "Remove streets and parks from the search results:"
2023-01-17 03:18:39 +01:00
"notInstanceOf": ["Q79007","Q22698"]
2021-10-29 13:35:33 +02:00
}
2023-01-17 03:18:39 +01:00
2021-10-29 13:35:33 +02:00
]
}
2022-01-14 19:34:00 +01:00
```
2022-05-06 17:26:00 +02:00
Another example is to search for species and trees:
```json
"freeform": {
"key": "species:wikidata",
"type": "wikidata",
"helperArgs": [
"species",
{
"instanceOf": [10884, 16521]
}]
}
```
2022-02-14 04:59:49 +01:00
### pnat
2021-05-11 10:14:33 +02:00
2022-01-14 19:34:00 +01:00
A strict positive number
2022-02-14 04:59:49 +01:00
### float
2021-05-11 10:14:33 +02:00
2023-04-15 03:15:17 +02:00
A decimal number
2022-01-14 19:34:00 +01:00
2022-02-14 04:59:49 +01:00
### pfloat
2021-05-11 10:14:33 +02:00
2023-04-15 03:15:17 +02:00
A positive decimal number or zero
2022-01-14 19:34:00 +01:00
2022-02-14 04:59:49 +01:00
### email
2021-11-30 22:50:48 +01:00
2022-01-14 19:34:00 +01:00
An email adress
2021-11-30 22:50:48 +01:00
2022-02-14 04:59:49 +01:00
### url
2023-04-15 03:15:17 +02:00
The validatedTextField will format URLs to always be valid and have a https://-header (even though the 'https'-part will be hidden from the user. Furthermore, some tracking parameters will be removed
2022-02-14 04:59:49 +01:00
### phone
2021-11-30 22:50:48 +01:00
2022-01-14 19:34:00 +01:00
A phone number
2021-11-30 22:50:48 +01:00
2022-02-14 04:59:49 +01:00
### opening_hours
Has extra elements to easily input when a POI is opened.
### Helper arguments
2021-10-29 03:42:33 +02:00
name | doc
------ | -----
2022-02-14 04:59:49 +01:00
options | A JSON-object of type `{ prefix: string, postfix: string }` .
2021-10-29 03:42:33 +02:00
2022-12-06 03:41:27 +01:00
subarg \| doc
2023-09-19 13:44:31 +02:00
-------- \| -----
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
2021-10-29 03:42:33 +02:00
2022-02-14 04:59:49 +01:00
### Example usage
2021-10-29 03:42:33 +02:00
2022-02-14 04:59:49 +01:00
To add a conditional (based on time) access restriction:
2021-10-29 03:42:33 +02:00
```
2021-10-29 03:59:28 +02:00
2021-10-29 13:35:33 +02:00
"freeform": {
"key": "access:conditional",
"type": "opening_hours",
"helperArgs": [
{
"prefix":"no @ (",
"postfix":")"
}
]
}
```
2022-02-14 04:59:49 +01:00
*Don't forget to pass the prefix and postfix in the rendering as well*: `{opening_hours_table(opening_hours,yes @ &LPARENS, &RPARENS )`
### color
2021-05-11 10:14:33 +02:00
2023-06-22 14:03:24 +02:00
Shows a color picker
### image
Same as the URL-parameter, except that it checks that the URL ends with `.jpg` , `.png` or some other typical image format
### simple_tag
A simple tag of the format `key=value` where `key` conforms to a normal key `
2023-08-24 12:22:45 +02:00
### tag
A simple tag of the format `key=value` OR a tagExpression
2023-06-22 14:03:24 +02:00
### key
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
2023-07-28 00:29:21 +02:00
### translation
2023-08-24 12:22:45 +02:00
Makes sure the the string is of format `Record<string, string>`
### icon
Makes sure that a valid .svg-path is added
### fediverse
2023-10-07 03:04:29 +02:00
Validates fediverse addresses and normalizes them into `@username@server` -format
### id
Checks for valid identifiers for layers, will automatically replace spaces and uppercase
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 )