UNPKG

@mapeo/schema

Version:

JSON schema and flow types for Mapeo

130 lines (129 loc) 4.66 kB
{ "$schema": "http://json-schema.org/draft-07/schema#", "$id": "http://mapeo.world/schemas/field.json", "title": "Field", "description": "A field defines a form field that will be shown to the user when creating or editing a map entity. Presets define which fields are shown to the user for a particular map entity. The field definition defines whether the field should show as a text box, multiple choice, single-select, etc. It defines what tag-value is set when the field is entered.", "type": "object", "properties": { "id": { "description": "Unique value that identifies this element", "type": "string" }, "key": { "description": "They key in a tags object that this field applies to. For nested properties, key can be an array e.g. for tags = `{ foo: { bar: 1 } }` the key is `['foo', 'bar']`", "oneOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }] }, "type": { "description": "Type of field - defines how the field is displayed to the user.", "type": "string", "meta:enum": { "text": "Freeform text field", "localized": "Text field with localization abilities (e.g. name=*, name:es=*, etc.). Currently only supported in Mapeo Desktop territory view.", "number": "Allows only numbers", "select_one": "Select one item from a list of pre-defined options", "select_multiple": "Select any number of items from a list of pre-defined options", "date": "Select a date", "datetime": "Select a date and time" }, "enum": [ "text", "localized", "number", "select_one", "select_multiple", "date", "datetime" ] }, "label": { "description": "Default language label for the form field label", "type": "string" }, "readonly": { "description": "Field is displayed, but it can't be edited", "type": "boolean", "default": false }, "appearance": { "description": "For text fields, display as a single-line or multi-line field", "type": "string", "meta:enum": { "singleline": "Text will be cut-off if more than one line", "multiline": "Text will wrap to multiple lines within text field" }, "enum": ["singleline", "multiline"], "default": "multiline" }, "snake_case": { "description": "Convert field value into snake_case (replace spaces with underscores and convert to lowercase)", "type": "boolean", "default": false }, "options": { "description": "List of options the user can select for single- or multi-select fields", "type": "array", "items": { "anyOf": [{ "type": "string" }, { "type": "boolean" }, { "type": "number" }, { "type": "null" }, { "type": "object", "properties": { "label": { "description": "Label in default language to display to the user for this option", "type": "string" }, "value": { "description": "Value for tag when this option is selected", "anyOf": [{ "type": "string" }, { "type": "boolean" }, { "type": "number" }, { "type": "null" }] } }, "required": ["value"] }] } }, "universal": { "description": "If true, this field will appear in the Add Field list for all presets", "type": "boolean", "default": false }, "placeholder": { "description": "Displayed as a placeholder in an empty text or number field before the user begins typing. Use 'helperText' for important information, because the placeholder is not visible after the user has entered data.", "type": "string" }, "helperText": { "description": "Additional context about the field, e.g. hints about how to answer the question.", "type": "string" }, "min_value": { "description": "Minimum field value (number, date or datetime fields only). For date or datetime fields, is seconds since unix epoch", "type": "integer" }, "max_value": { "description": "Maximum field value (number, date or datetime fields only). For date or datetime fields, is seconds since unix epoch", "type": "integer" } }, "required": ["id", "key", "type"], "additionalProperties": false }