diff --git a/types/jstree/index.d.ts b/types/jstree/index.d.ts index 21e07de80d..1aeaf07761 100644 --- a/types/jstree/index.d.ts +++ b/types/jstree/index.d.ts @@ -1,8 +1,7 @@ -// Type definitions for jsTree v3.3.3 +// Type definitions for jsTree v3.3.4 // Project: http://www.jstree.com/ // Definitions by: Adam PluciƄski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 /// @@ -15,6 +14,11 @@ interface JQueryStatic { * @type {JSTreeStatic} */ jstree?: JSTreeStatic; + + /** + * helpers + */ + vakata?: VakataStatic; } interface JQuery { @@ -96,25 +100,25 @@ interface JSTreeStatic { core(id: number): void; /** - * get a reference to an existing instance - * - * __Examples__ - * - * // provided a container with an ID of "tree", and a nested node with an ID of "branch" - * // all of there will return the same instance - * $.jstree.reference('tree'); - * $.jstree.reference('#tree'); + * get a reference to an existing instance + * + * __Examples__ + * + * // provided a container with an ID of "tree", and a nested node with an ID of "branch" + * // all of there will return the same instance + * $.jstree.reference('tree'); + * $.jstree.reference('#tree'); * $.jstree.reference($('#tree')); * $.jstree.reference(document.getElementByID('tree')); - * $.jstree.reference('branch'); - * $.jstree.reference('#branch'); - * $.jstree.reference($('#branch')); + * $.jstree.reference('branch'); + * $.jstree.reference('#branch'); + * $.jstree.reference($('#branch')); * $.jstree.reference(document.getElementByID('branch')); - * + * * @name $.jstree.reference(needle) * @param {DOMElement|jQuery|String} needle * @return {jsTree|null} the instance or `null` if not found - */ + */ reference(needle: HTMLElement|JQuery|string): JSTree; } @@ -282,7 +286,7 @@ interface JSTreeStaticDefaultsCore { * $('#tree').jstree({ * 'core' : { * 'check_callback' : function (operation, node, node_parent, node_position, more) { - * // operation can be 'create_node', 'rename_node', 'delete_node', 'move_node' or 'copy_node' + * // operation can be 'create_node', 'rename_node', 'delete_node', 'move_node', 'copy_node' or 'edit' * // in case of 'rename_node' node_position is filled with the new node name * return operation === 'rename_node' ? true : false; * } @@ -445,6 +449,20 @@ interface JSTreeStaticDefaultsCheckbox { * @plugin checkbox */ tie_selection: boolean; + + /** + * This setting controls if cascading down affects disabled checkboxes + * @name $.jstree.defaults.checkbox.cascade_to_disabled + * @plugin checkbox + */ + cascade_to_disabled : boolean; + + /** + * This setting controls if cascading down affects hidden checkboxes + * @name $.jstree.defaults.checkbox.cascade_to_hidden + * @plugin checkbox + */ + cascade_to_hidden : boolean; } interface JSTreeStaticDefaultsContextMenu { @@ -708,6 +726,43 @@ interface JSTreeStaticDefaultsUnique { duplicate: (name: string, counter: number) => string; } +interface VakataStatic { + /** + * collect attributes + */ + attributes: (node: any, with_values: any) => any; + + /** + * returns array with unique elements + */ + array_unique: (array: Array) => Array; + + /** + * remove item from array + */ + array_remove: (array: Array, from: number) => Array; + + /** + * remove item from array + */ + array_remove_item: (array: Array, item: any) => Array; + + /** + * filter array + */ + array_filter: (c: any, a: any, b: any, d: Array, e: any) => Array; + + context: any; + + html: any; + + dnd: any; + + search: any; + + storage: any; +} + interface JSTree extends JQuery { /** * used to decorate an instance with a plugin. Used internally. @@ -871,12 +926,12 @@ interface JSTree extends JQuery { get_parent: (obj: any) => string; /** - * get a jQuery collection of all the children of a node (node must be rendered) + * get a jQuery collection of all the children of a node (node must be rendered), returns false on error * @name get_children_dom(obj) * @param {mixed} obj * @return {jQuery} */ - get_children_dom: (obj: any) => JQuery; + get_children_dom: (obj: any) => JQuery|boolean; /** * checks if a node has children @@ -1686,6 +1741,21 @@ interface JSTree extends JQuery { */ enable_checkbox: (obj: any) => boolean; + /** + * Unchecks a node and all its descendants. This function does NOT affect hidden and disabled nodes (or their descendants). + * However if these unaffected nodes are already selected their ids will be included in the returned array. + * @param id + * @param checkedState + * @returns {Array} Array of all node id's (in this tree branch) that are checked. + */ + _cascade_new_checked_state: (id: string, checkedState: string) => string[]; + + /** + * Gets ids of nodes selected in branch (of tree) specified by id (does not include the node specified by id) + * @param id + */ + get_checked_descendants: (id: string) => string[]; + /** * check a node (only if tie_selection in checkbox settings is false, otherwise select_node will be called internally) * @name check_node(obj) diff --git a/types/jstree/jstree-tests.ts b/types/jstree/jstree-tests.ts index 208ae9b979..d939bb6b29 100644 --- a/types/jstree/jstree-tests.ts +++ b/types/jstree/jstree-tests.ts @@ -1,5 +1,3 @@ - - // gets version of lib var version: string = $.jstree.version;