{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "definitions": {
        "SelectOption": {
            "properties": {
                "label": {
                    "type": "string"
                },
                "value": {
                }
            },
            "required": [
                "label",
                "value"
            ],
            "type": "object"
        }
    },
    "description": "# drayman-text-field\n\nText field powered by [Angular Material](https://material.angular.io/) and [ngx-mask](https://jsdaddy.github.io/ngx-mask-page) libraries.\n\n## Example of usage\n\n### Simple text field\n\n![](media://drayman-text-field.gif)\n\n```typescript\nmodule.exports = async ({ forceUpdate }) => {\n     let name = '';\n     let typing = false;\n\n     return () => {\n         // User started typing\n         const onValueChangeStart = async () => {\n             typing = true;\n             await forceUpdate();\n         }\n\n         // User stopped typing with some `value`\n         const onValueChange = async ({ value }) => {\n             typing = false;\n             name = value;\n             await forceUpdate();\n         }\n\n         return [\n             <drayman-text-field\n                 key=\"default-text-field\"\n                 label=\"Name\"\n                 value={name}\n                 onValueChangeStart={onValueChangeStart}\n                 onValueChange={onValueChange}\n             />,\n             <html key=\"info\">\n                 {name && <p>Hello, {name}!</p>}\n                 <p>{typing ? `You are typing!` : `You aren't typing!`}</p>\n             </html>\n         ]\n     };\n}\n```\n\n### Text field with autocomplete and remote result caching.\n\n![](media://drayman-text-field-autocomplete.gif)\n\n```typescript\nimport axios from 'axios';\nimport _ from 'lodash';\n\nconst getCountriesFromCache = _.memoize(async (value) => {\n     const result = await axios.get(`https://api.first.org/data/v1/countries?q=${value}&limit=10`);\n     return Object.values(result.data.data).map(x => ({ value: x.country, label: x.country }));\n});\n\nmodule.exports = async ({ forceUpdate }) => {\n\n     let countries: { value: string; label: string; }[] = [];\n     let searchValue = '';\n\n     const getCountries = async () => {\n         countries = await getCountriesFromCache(searchValue);\n         await forceUpdate();\n     }\n\n     return () => {\n         return (\n             <drayman-text-field\n                 key=\"countries\"\n                 label=\"Country\"\n                 value={searchValue}\n                 suggestions={countries}\n                 onFocus={async () => {\n                     if (!countries.length) {\n                         await getCountries();\n                     }\n                 }}\n                 onValueChange={async ({ value }) => {\n                     searchValue = value;\n                     await getCountries();\n                 }}\n             />\n         );\n     }\n}\n```",
    "properties": {
        "appearance": {
            "description": "Appearance style for the field.\nWether `outline` (default), `legacy`, `fill` or `standard`.",
            "enum": [
                "fill",
                "legacy",
                "outline",
                "standard"
            ],
            "type": "string"
        },
        "disabled": {
            "description": "Whether the control is disabled.",
            "type": "boolean"
        },
        "error": {
            "description": "Error text to be shown underneath the form field control.",
            "type": "string"
        },
        "helpText": {
            "description": "Hint text to be shown underneath the form field control.",
            "type": "string"
        },
        "label": {
            "description": "The floating label for a field.",
            "type": "string"
        },
        "mask": {
            "description": "Input mask options.",
            "properties": {
                "allowNegativeNumbers": {
                    "description": "If mask will allow the use of negative numbers.",
                    "type": "boolean"
                },
                "emitSpecialCharacters": {
                    "description": "Should value be emitted with charaters added by mask.",
                    "type": "boolean"
                },
                "expression": {
                    "description": "Expression that constrains user input.\nIf it exists, autocomplete suggestions will not work.\nYou can check available `mask` options here - https://jsdaddy.github.io/ngx-mask-page.",
                    "type": "string"
                },
                "leadZeroDateTime": {
                    "description": "If the `leadZeroDateTime` parameter is `true`, skipped symbols of date or time will be replaced by 0.",
                    "type": "boolean"
                },
                "prefix": {
                    "description": "Prefix for the input.",
                    "type": "string"
                },
                "showMaskTyped": {
                    "description": "If mask is shown while typing, or not.",
                    "type": "boolean"
                },
                "suffix": {
                    "description": "Suffix for the input.",
                    "type": "string"
                },
                "thousandSeparator": {
                    "description": "If mask is `separator`, defines which character will separate thousands.",
                    "type": "string"
                }
            },
            "type": "object"
        },
        "onFocus": {
            "description": "Executed when autocomplete field is focused.",
            "type": "object"
        },
        "onValueChange": {
            "description": "Executed with an input value from user.",
            "type": "object"
        },
        "onValueChangeStart": {
            "description": "Executed when user starts typing.",
            "type": "object"
        },
        "placeholder": {
            "description": "The placeholder text.",
            "type": "string"
        },
        "suggestions": {
            "description": "Autocomplete suggestions.",
            "items": {
                "$ref": "#/definitions/SelectOption"
            },
            "type": "array"
        },
        "suggestionsPanelWidth": {
            "description": "Specify the width of the autocomplete panel. Can be any CSS sizing value, otherwise it will match the width of its host.",
            "type": [
                "string",
                "number"
            ]
        },
        "updateOnBlur": {
            "description": "Wether value of the field should be emitted when user is blurred out of the control.",
            "type": "boolean"
        },
        "value": {
            "description": "Value of the input.",
            "type": "string"
        }
    },
    "type": "object"
}

