{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "definitions": {
        "CellType": {
            "enum": [
                "button",
                "checkbox",
                "datepicker",
                "file-uploader",
                "number-field",
                "select",
                "text",
                "text-field",
                "timepicker"
            ],
            "type": "string"
        },
        "DraymanTableButtonCell": {
            "properties": {
                "buttonStyle": {
                },
                "disabled": {
                    "description": "Wether button should be disabled.",
                    "type": "boolean"
                },
                "icon": {
                    "description": "Name of the [Material icon](https://material.io/resources/icons) printed inside button.",
                    "type": "string"
                },
                "imgUrl": {
                    "description": "Image shown on hover.",
                    "type": "string"
                },
                "selectionButton": {
                    "description": "Show this button only when some rows are selected.",
                    "type": "boolean"
                },
                "style": {
                },
                "tooltip": {
                    "description": "Tooltip shown on hover.",
                    "type": "string"
                },
                "type": {
                    "enum": [
                        "button"
                    ],
                    "type": "string"
                },
                "value": {
                    "type": "string"
                },
                "view": {
                    "description": "Material style of the button.\n`basic` by default.",
                    "enum": [
                        "basic",
                        "fab",
                        "flat",
                        "icon",
                        "miniFab",
                        "raised",
                        "stroked"
                    ],
                    "type": "string"
                }
            },
            "required": [
                "type",
                "value"
            ],
            "type": "object"
        },
        "DraymanTableCheckboxCell": {
            "properties": {
                "disabled": {
                    "description": "Whether the control is disabled.",
                    "type": "boolean"
                },
                "style": {
                },
                "type": {
                    "enum": [
                        "checkbox"
                    ],
                    "type": "string"
                },
                "value": {
                    "type": "boolean"
                }
            },
            "required": [
                "type",
                "value"
            ],
            "type": "object"
        },
        "DraymanTableColumn": {
            "properties": {
                "field": {
                    "type": "string"
                },
                "label": {
                    "type": "string"
                },
                "pinned": {
                    "enum": [
                        "left",
                        "right"
                    ],
                    "type": "string"
                },
                "style": {
                },
                "type": {
                    "$ref": "#/definitions/CellType",
                    "description": "Type of the column. \nCan be overridden by cell type."
                }
            },
            "required": [
                "field",
                "label"
            ],
            "type": "object"
        },
        "DraymanTableDatepickerCell": {
            "properties": {
                "dateFormat": {
                    "description": "In which format date will be displayed. \nDefaults to `YYYY-MM-DD`.",
                    "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"
                },
                "showTodayButton": {
                    "description": "Wether to show today button or not.",
                    "type": "boolean"
                },
                "style": {
                },
                "type": {
                    "enum": [
                        "datepicker"
                    ],
                    "type": "string"
                },
                "value": {
                    "type": "string"
                }
            },
            "required": [
                "type",
                "value"
            ],
            "type": "object"
        },
        "DraymanTableFileUploaderCell": {
            "properties": {
                "allowMultiple": {
                    "description": "Wether multiple file upload is allowed or not.",
                    "type": "boolean"
                },
                "initialFiles": {
                    "description": "Array of files to show when uploader element appears.",
                    "items": {
                        "properties": {
                            "downloadUrl": {
                                "description": "URL that starts a download of this file.",
                                "type": "string"
                            },
                            "fileName": {
                                "description": "Name of the uploaded file.",
                                "type": "string"
                            },
                            "id": {
                                "description": "Unique file ID.",
                                "type": "string"
                            },
                            "length": {
                                "description": "Size of the file in bytes.",
                                "type": "number"
                            }
                        },
                        "required": [
                            "downloadUrl",
                            "fileName",
                            "id",
                            "length"
                        ],
                        "type": "object"
                    },
                    "type": "array"
                },
                "style": {
                },
                "type": {
                    "enum": [
                        "file-uploader"
                    ],
                    "type": "string"
                },
                "value": {
                    "type": "string"
                }
            },
            "required": [
                "type",
                "value"
            ],
            "type": "object"
        },
        "DraymanTableNumberFieldCell": {
            "properties": {
                "disabled": {
                    "description": "Whether the control is disabled.",
                    "type": "boolean"
                },
                "error": {
                    "description": "Error text to be shown underneath the form field control.",
                    "type": "string"
                },
                "style": {
                },
                "suggestions": {
                    "description": "Array of options that populate the autocomplete.",
                    "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"
                    ]
                },
                "type": {
                    "enum": [
                        "number-field"
                    ],
                    "type": "string"
                },
                "updateOnBlur": {
                    "description": "Wether value of the field should be emitted when user is blurred out of the control.",
                    "type": "boolean"
                },
                "value": {
                    "type": "number"
                }
            },
            "required": [
                "type",
                "value"
            ],
            "type": "object"
        },
        "DraymanTableSelectCell": {
            "properties": {
                "disabled": {
                    "description": "Whether the control is disabled.",
                    "type": "boolean"
                },
                "error": {
                    "description": "Error text to be shown underneath the form field control.",
                    "type": "string"
                },
                "multiple": {
                    "description": "Whether the user should be allowed to select multiple options.",
                    "type": "boolean"
                },
                "options": {
                    "description": "Array of options that populate the select menu.",
                    "items": {
                        "$ref": "#/definitions/SelectOption"
                    },
                    "type": "array"
                },
                "style": {
                },
                "type": {
                    "enum": [
                        "select"
                    ],
                    "type": "string"
                },
                "value": {
                    "type": "string"
                }
            },
            "required": [
                "type",
                "value"
            ],
            "type": "object"
        },
        "DraymanTableTextCell": {
            "properties": {
                "style": {
                },
                "type": {
                    "enum": [
                        "text"
                    ],
                    "type": "string"
                },
                "value": {
                    "type": "string"
                }
            },
            "required": [
                "type",
                "value"
            ],
            "type": "object"
        },
        "DraymanTableTextFieldCell": {
            "properties": {
                "disabled": {
                    "description": "Whether the control is disabled.",
                    "type": "boolean"
                },
                "error": {
                    "description": "Error text to be shown underneath the form field control.",
                    "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"
                },
                "style": {
                },
                "suggestions": {
                    "description": "Array of options that populate the autocomplete.",
                    "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"
                    ]
                },
                "type": {
                    "enum": [
                        "text-field"
                    ],
                    "type": "string"
                },
                "updateOnBlur": {
                    "description": "Wether value of the field should be emitted when user is blurred out of the control.",
                    "type": "boolean"
                },
                "value": {
                    "type": "string"
                }
            },
            "required": [
                "type",
                "value"
            ],
            "type": "object"
        },
        "DraymanTableTimepickerCell": {
            "properties": {
                "disabled": {
                    "description": "Whether the control is disabled.",
                    "type": "boolean"
                },
                "error": {
                    "description": "Error text to be shown underneath the form field control.",
                    "type": "string"
                },
                "showNowButton": {
                    "description": "Wether to show now button or not.",
                    "type": "boolean"
                },
                "style": {
                },
                "type": {
                    "enum": [
                        "timepicker"
                    ],
                    "type": "string"
                },
                "value": {
                    "type": "string"
                }
            },
            "required": [
                "type",
                "value"
            ],
            "type": "object"
        },
        "DraymanToolbarButton": {
            "properties": {
                "buttonStyle": {
                },
                "disabled": {
                    "description": "Wether button should be disabled.",
                    "type": "boolean"
                },
                "icon": {
                    "description": "Name of the [Material icon](https://material.io/resources/icons) printed inside button.",
                    "type": "string"
                },
                "imgUrl": {
                    "description": "Image shown on hover.",
                    "type": "string"
                },
                "label": {
                    "type": "string"
                },
                "selectionButton": {
                    "description": "Show this button only when some rows are selected.",
                    "type": "boolean"
                },
                "tooltip": {
                    "description": "Tooltip shown on hover.",
                    "type": "string"
                },
                "view": {
                    "description": "Material style of the button.\n`basic` by default.",
                    "enum": [
                        "basic",
                        "fab",
                        "flat",
                        "icon",
                        "miniFab",
                        "raised",
                        "stroked"
                    ],
                    "type": "string"
                }
            },
            "type": "object"
        },
        "SelectOption": {
            "properties": {
                "label": {
                    "type": "string"
                },
                "value": {
                }
            },
            "required": [
                "label",
                "value"
            ],
            "type": "object"
        }
    },
    "description": "# drayman-table\n\nTable powered by [Angular Material](https://material.angular.io/) library.\n\n## Example of usage\n\n### Simple table with built-in pagination, sort and search.\n![](media://drayman-table-default.gif)\n\n```typescript\nmodule.exports = async () => {\n    const data = [\n        { name: { value: 'Carbon' }, weight: { value: 12.0107 }, symbol: { value: 'C' } },\n        { name: { value: 'Hydrogen' }, weight: { value: 1.0079 }, symbol: { value: 'H' } },\n        { name: { value: 'Fluorine' }, weight: { value: 18.9984 }, symbol: { value: 'F' } },\n        { name: { value: 'Boron' }, weight: { value: 10.811 }, symbol: { value: 'B' } },\n        { name: { value: 'Lithium' }, weight: { value: 6.941 }, symbol: { value: 'Li' } },\n        { name: { value: 'Helium' }, weight: { value: 4.0026 }, symbol: { value: 'He' } },\n        { name: { value: 'Neon' }, weight: { value: 20.1797 }, symbol: { value: 'Ne' } },\n        { name: { value: 'Nitrogen' }, weight: { value: 14.0067 }, symbol: { value: 'N' } },\n        { name: { value: 'Oxygen' }, weight: { value: 15.9994 }, symbol: { value: 'O' } },\n        { name: { value: 'Beryllium' }, weight: { value: 9.0122 }, symbol: { value: 'Be' } },\n    ];\n\n    const columns = [{\n        field: 'name',\n        label: 'Name',\n    }, {\n        field: 'weight',\n        label: 'Weight',\n    }, {\n        field: 'symbol',\n        label: 'Symbol',\n    }];\n\n    return () => <drayman-table key=\"table\" pagination sort search columns={columns} data={data} />;\n}\n```\n\n### Table with remote data, pagination and search (`disableInternalProcessing` set to `true`).\n![](media://drayman-table-server-side.gif)\n\n```typescript\nimport axios from 'axios';\n\nmodule.exports = async ({ forceUpdate }) => {\n\n     let data = [];\n     let itemCount;\n     let pageIndex = 0;\n     let searchValue = 'brea';\n\n     const getMovieResponse = async () => {\n         const page = pageIndex + 1;\n         const result = await axios.get(`https://api.themoviedb.org/3/search/movie?api_key=API_KEY&query=${searchValue}&page=${page}`);\n         data = getTableData(result.data.results.map(x => ({ title: x.title, rating: x.vote_average })));\n         pageIndex = result.data.page - 1;\n         itemCount = result.data.total_results;\n     }\n\n     await getMovieResponse();\n\n     return () => {\n         const options: DraymanTable = {\n             data,\n             columns: [{\n                 field: 'title',\n                 label: 'Title',\n             }, {\n                 field: 'rating',\n                 label: 'Rating',\n             }],\n             pagination: true,\n             pageSizeOptions: [],\n             pageSize: 20,\n             search: true,\n             disableInternalProcessing: true,\n             itemCount,\n             pageIndex,\n             initialSearchValue: searchValue,\n             onPageChange: async (data) => {\n                 pageIndex = data.pageIndex;\n                 await getMovieResponse();\n                 await forceUpdate();\n             },\n             onSearchChange: async ({ value }) => {\n                 searchValue = value;\n                 await getMovieResponse();\n                 await forceUpdate();\n             },\n         }\n\n         return <drayman-table key=\"table\" {...options} />;\n     };\n}\n\nfunction getTableData(data) {\n     return data.map(x => Object.fromEntries(\n         Object.entries(x).map(([key, value]) => [key, { value }])\n     ));\n}\n```\n\n### Table with editable fields\n![](media://drayman-table-editable.gif)\n\n```typescript\nmodule.exports = async ({ forceUpdate }) => {\n\n     const data = [];\n\n     const options: DraymanTable = {\n         data,\n         columns: [{\n             field: 'name',\n             label: 'Name',\n             type: 'text-field',\n         }, {\n             field: 'age',\n             label: 'Age',\n             type: 'number-field',\n         }],\n         toolbarButtons: [{\n             view: 'icon',\n             icon: 'add'\n         }],\n         onToolbarButtonClick: async ({ selectedRows, buttonDefinition }) => {\n             data.push({\n                 name: { value: null },\n                 age: { value: null },\n                 id: { value: data.length },\n             });\n             await forceUpdate();\n         },\n         title: 'Editable data grid',\n         onCellValueChange: async ({ row, field, value }) => {\n             const rowToEdit = data.find(x => x.id.value === row.id.value);\n             rowToEdit[field].value = value;\n             rowToEdit[field].error = field === 'age' && value < 18 ? 'Too young' : null;\n             await forceUpdate();\n         }\n     }\n\n     return () => {\n         return <drayman-table key=\"table\" {...options} />;\n     };\n}\n```",
    "properties": {
        "columns": {
            "description": "Table column definitions.",
            "items": {
                "$ref": "#/definitions/DraymanTableColumn"
            },
            "type": "array"
        },
        "data": {
            "description": "Table row data.",
            "items": {
                "additionalProperties": {
                    "anyOf": [
                        {
                            "$ref": "#/definitions/DraymanTableTextCell"
                        },
                        {
                            "$ref": "#/definitions/DraymanTableSelectCell"
                        },
                        {
                            "$ref": "#/definitions/DraymanTableFileUploaderCell"
                        },
                        {
                            "$ref": "#/definitions/DraymanTableTextFieldCell"
                        },
                        {
                            "$ref": "#/definitions/DraymanTableCheckboxCell"
                        },
                        {
                            "$ref": "#/definitions/DraymanTableDatepickerCell"
                        },
                        {
                            "$ref": "#/definitions/DraymanTableTimepickerCell"
                        },
                        {
                            "$ref": "#/definitions/DraymanTableNumberFieldCell"
                        },
                        {
                            "$ref": "#/definitions/DraymanTableButtonCell"
                        }
                    ]
                },
                "type": "object"
            },
            "type": "array"
        },
        "disableHeader": {
            "description": "Controls appearance of the column header.",
            "type": "boolean"
        },
        "disableInternalProcessing": {
            "description": "Disables internal pagination, sorting and search algorithms applied after every data change and firing of event.\nAllows to apply custom logic for pagination, sort and search.",
            "type": "boolean"
        },
        "initialSearchValue": {
            "description": "Initial value for search bar.",
            "type": "string"
        },
        "itemCount": {
            "description": "Controls item count number shown in paginator if `disableInternalProcessing` is enabled.",
            "type": "number"
        },
        "onCellButtonClick": {
            "description": "Event fired when user clicks a cell with the `button` type.",
            "type": "object"
        },
        "onCellClick": {
            "description": "Event fired when user clicks a cell.",
            "type": "object"
        },
        "onCellDblClick": {
            "description": "Event fired when user double-clicks a cell.",
            "type": "object"
        },
        "onCellFocus": {
            "description": "Manages `onFocus` event.",
            "type": "object"
        },
        "onCellValueChange": {
            "description": "Event fired when user changes a value of cell with the `text-field`, `number-field` or `selection`.",
            "type": "object"
        },
        "onCellValueChangeStart": {
            "type": "object"
        },
        "onFileUpload": {
            "description": "Executed when file is uploaded.\nThis function contains uploaded file and must return a unique file ID.\nThis unique ID is then used to revert uploads.",
            "type": "object"
        },
        "onPageChange": {
            "description": "Event fired when user changes a page or page size.",
            "type": "object"
        },
        "onRemoveUploadedFile": {
            "description": "Executed when user wants to remove a file.\nReceives unique file ID `fileId`.\nThis function is usually used to remove a specific file from file system.",
            "type": "object"
        },
        "onRowDragEnd": {
            "description": "Event fired when user rearranges some row.",
            "type": "object"
        },
        "onSearchChange": {
            "description": "Event fired when user performs a search.",
            "type": "object"
        },
        "onSelectSearchChange": {
            "description": "This function can be used to override default cells with `select` type search algorithm.\nAccepts value of the search input. Can be `null`.\nIf this function is not defined, options will be filtered client-side.",
            "type": "object"
        },
        "onSortChange": {
            "description": "Event fired when user performs a sort on some column.",
            "type": "object"
        },
        "onToolbarButtonClick": {
            "description": "Event fired when user clicks a toolbar button.",
            "type": "object"
        },
        "pageIndex": {
            "description": "Controls page index shown in paginator if `disableInternalProcessing` is enabled.",
            "type": "number"
        },
        "pageSize": {
            "description": "Controls page size number shown in paginator if `disableInternalProcessing` is enabled.",
            "type": "number"
        },
        "pageSizeOptions": {
            "description": "The set of provided page size options to display to the user.\nDefaults to `[5, 10, 25, 100]`.",
            "items": {
                "type": "number"
            },
            "type": "array"
        },
        "pagination": {
            "description": "Enables paginator.",
            "type": "boolean"
        },
        "rowDrag": {
            "description": "Used to rearrange rows by dragging the row with the mouse.\nRow dragging will be disabled if `pagination`, `sort` or `search` is enabled.",
            "type": "boolean"
        },
        "rowStyle": {
            "description": "Style for each row in data.",
            "items": {
            },
            "type": "array"
        },
        "search": {
            "description": "Enables search bar.",
            "type": "boolean"
        },
        "select": {
            "description": "Wether to enable row selection or not.",
            "type": "boolean"
        },
        "sort": {
            "description": "Enables column sorting.",
            "type": "boolean"
        },
        "title": {
            "description": "Title of the table.\n`Table` by default.",
            "type": "string"
        },
        "toolbarButtons": {
            "description": "List of toolbar buttons.",
            "items": {
                "$ref": "#/definitions/DraymanToolbarButton"
            },
            "type": "array"
        }
    },
    "required": [
        "columns",
        "data"
    ],
    "type": "object"
}

