import { ElementRef, EventEmitter, OnInit } from '@angular/core'; import { CfCoreComponent } from '../core/core.component'; import { TreeviewModel } from '../../models/treeview/treeview.model'; import { JsonEditorModel } from '../../models/json-editor/json-editor.model'; import { JsonEditorStylingModel } from '../../models/json-editor/json-editor-styling.model'; import { JsonEditorRowButtonModel } from '../../models/json-editor/json-editor-row-button.model'; import { TemplateService } from '../../services/template-service/template.service'; import { CfTreeviewComponent } from '../../components/treeview/treeview.component'; /** *
cf-json-editor component is based on cf-treeview
*Example of using:
***/ export declare class CfJsonEditorComponent extends CfCoreComponent implements OnInit { /** @hidden * Link to the cf-treeview-component */ treeviewElement: CfTreeviewComponent; /** *<cf-json-editor [properties]="myJsonEditor" * [styling]="myJsonEditorStyles"></cf-json-editor>*
JsonEditorModel object.
*Example of model:
*
* {{'{'}}
* data: this.myJsonObject,
* lockKeys: true,
* showButtons: "hover",
* rowButtons: [
* [
* {{'{'}} "name": "moveUp", "icon": "keyboard_arrow_up" {{'}'}},
* {{'{'}} "name": "moveDown", "icon": "keyboard_arrow_down" {{'}'}}
* ],
* [
* {{'{'}} "name": "indent", "icon": "format_indent_increase" {{'}'}},
* {{'{'}} "name": "outdent", "icon": "format_indent_decrease" {{'}'}}
* ],
* [
* {{'{'}} "name": "clone", "icon": "content_copy" {{'}'}},
* {{'{'}} "name": "delete", "icon": "delete" {{'}'}},
* {{'{'}} "name": "insert", "icon": "playlist_add" {{'}'}}
* ]
* ]
* {{'}'}}
*
* JSON input to be converted into tree
*Whether to prevent keys from being edited. Default: true.
*Array of buttons to be rendered per level
*Circumstances to show buttons in. Can be: hover, select or always.
*/ properties: JsonEditorModel; /** * Object for all styling properties: *Styling properties for main json-editor container
*Styling properties for header section
*Styling properties for cf-treeview
*/ styling: JsonEditorStylingModel; /** *Whether to prevent keys from being edited. Default: true.
*/ lockKeys: boolean; /** *Circumstances to show buttons in. Can be: hover, select or always.
*/ showButtons: string; /** *JSON input to be converted into tree
*/ data: any; /** *Array of buttons to be rendered per level
*/ rowButtons: [JsonEditorRowButtonModel[]]; /** * Emit event with action (name with icon) and optional item from which action was triggered */ onCustomAction: EventEmitterString being filtered on
*/ filterBy: string; /**@hidden *toggled to true to flash a red warning sometimes
*/ illegalOperation: boolean; /**@hidden *the array that the tree will be built around, since the Treeview takes an array, not JSON
*/ tree: Array<{}>; /**@hidden *Model for the underlying treeview component
*/ treeViewModel: TreeviewModel; /**@hidden *property for output JSON to be written to
*/ JsonOutput: any; /**@hidden */ constructor(el: ElementRef, templateService: TemplateService); /** @hidden *optional custom filter function--return true to show that node when filtering
*/ filterFunction(node: any): any; /**@hidden */ ngOnInit(): void; /**@hidden * Creates the base array for the Treeview, called later for nodes with children to create arrays of children * @param json input JSON to convert to array of nodes * @param lockEdit whether to prevent editing of these nodes */ createChildren(json: {}, lockEdit?: boolean): Array<{}>; /**@hidden * Creates a tree node from a JSON key-value pair * @param key string to be used for the key * @param value the value of the key-value pair * @param lockEdit whether to prevent editing of this node */ createTreeNode(key: string, value: any, lockEdit: any): { key: string; value: any; type: "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"; _id: string; _expanded: boolean; _name: string; _children: any; isArray: boolean; lockEdit: any; }; /** * Updates the Treeview */ updateTree(): void; /**@hidden * Taking the whole tree and a node, returns the node, its parent node, its parent array, and its level in the tree * @param tree the tree or section or tree to locate the node in * @param node the node you are locating * @param level the level at which this was called, default top level (0) */ findNode(tree: any, node: any, level?: number): any; /**@hidden * Removes node from parent * @param parent the node containing the node to be removed * @param node the node you are removing */ removeNode(parent: any, node: any): void; /**@hidden * Locates a node within a given tree and removes it * @param tree the tree containing the node to be removed * @param node the node you are removing */ findAndRemoveNode(tree: any, node: any): void; /**@hidden * Inserts a node as a child of another node at the given position * @param parent the node to be given the child * @param node the node make the child */ insertNode(parent: any, node: any, idx?: number): void; /**@hidden * Inserts a blank node as the last child of another node * @param parent the node to be given the child */ addBlankNode(parent: any): void; /**@hidden * Takes a node and creates an identical node and adds it as a sibling * @param tree a tree containing of the node to be cloned * @param node the node to be cloned */ duplicateNode(tree: any, node: any): void; /**@hidden * Replaces a node with a different node * @param tree a tree containing the node to be replaced * @param oldNode the node to be replaced * @param newNode the node to replace it with */ replaceNode(tree: any, oldNode: any, newNode: any): void; /**@hidden * Given a node, makes a copy * @param node the node to be cloned * @param highest whether the node is on the highest level, so that there are no duplicate keys */ cloneNode(node: any, highest?: boolean, arrayLength?: number): { key: any; value: any; type: any; lockEdit: boolean; _id: number; _name: string; _expanded: boolean; _children: any[]; isArray: any; }; /**@hidden * Given a node, changes the value of a field * @param value the new value for the field * @param node the node to be edited * @param field the field to be edited */ editNode(value: any, node: any, field: any): void; /**@hidden * Bumps a node up or down among its siblings * @param parent the containing node of the node to be moved * @param node the node to be moved * @param direction 'up' or 'down' */ moveNode(tree: any, node: any, direction: any): void; /**@hidden * Makes a node the child of the node before it or creates a parent to make it a child of * @param tree the containing tree of the node to be indented * @param node the node to be indented */ indentNode(tree: any, node: any): void; /**@hidden * Makes a child the sibling of its parent * @param tree the containing tree of the node to be outdented * @param node the node to be outdented */ outdentNode(tree: any, node: any): void; /**@hidden * Is called when a node is moved * @param e the event */ onMoveNode(e: any): void; /** * expands all nodes */ expandAll(): void; /** * collapses all nodes */ collapseAll(): void; /**@hidden * checks to see if a node is at the highest level in a given tree * @param tree the containing tree * @param node the node being checked */ isTopLevel(tree: any, node: any): any; /** * filters the tree using the filter function when the filter input changes * @param e the change event */ onFilterChange(e: any): void; /**@hidden * converts a node to an array of its type when the box is checked * @param e the change event * @param node the node being changed */ onArrayCheck(e: any, node: any): void; /**@hidden * changes the type or key of a node when its field is changed * @param e the change event * @param node the node being changed * @param field the field being changed */ valueChange(e: any, node: any, field: any): void; /**@hidden * toggles the lockEdit property of a node and its children * @param node the node to be locked or unlocked * @param lock locks if true, unlocks if false */ toggleLock(node: any, lock?: any): void; /**@hidden * creates new blank node if enter is pressed on the last child in a tree * @param e the event emitted * @param tree the tree that contains the node * @param node the node that the key was pressed on */ onKeyUp(e: any, tree: any, node: any): void; /**@hidden * takes the array of nodes at the root of the tree and converts back to JSON schema * @param treeItems the items of the treeview */ convertToJSON(treeItems: any): {}; /**@hidden * converts a given node back to JSON * @param node the node input */ convertJSONNode(node: any): any; /** * converts a given node back to JSON * @param node the node input */ convertData(): void; /**@hidden * changes illegalOperation to true briefly to flash red */ flashIllegal(): void; /**@hidden * Method to select which function to run * @param name function alias * @param item item from which action was triggered */ runAction(name: any, item: any): void; }