forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jstree.d.ts
1822 lines (1615 loc) · 64.4 KB
/
jstree.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Type definitions for jsTree v3.0.9
// Project: http://www.jstree.com/
// Definitions by: Adam Pluciński <https://github.com/adaskothebeast>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// 45 commit df38535 2015-03-02 13:23 +2:00
///<reference path="../jquery/jquery.d.ts" />
interface JQueryStatic {
/**
* holds all jstree related functions and variables,
* including the actual class and methods to create,
* access and manipulate instances.
* @property jstree
* @type {JSTreeStatic}
*/
jstree?: JSTreeStatic;
}
interface JQuery {
/**
* Create an instance, get an instance or invoke a command on a instance.
*
* If there is no instance associated with the current node a new one is created
* and `arg` is used to extend `$.jstree.defaults` for this new instance. There would be no return value (chaining is not broken).
*
* If there is an existing instance and `arg` is a string the command specified by `arg` is executed on the instance,
* with any additional arguments passed to the function. If the function returns a value it will be returned (chaining could break depending on function).
*
* If there is an existing instance and `arg` is not a string the instance itself is returned (similar to `$.jstree.reference`).
*
* In any other case - nothing is returned and chaining is not broken.
*
* __Examples__
*
* $('#tree1').jstree(); // creates an instance
* $('#tree2').jstree({ plugins : [] }); // create an instance with some options
* $('#tree1').jstree('open_node', '#branch_1'); // call a method on an existing instance, passing additional arguments
* $('#tree2').jstree(); // get an existing instance (or create an instance)
* $('#tree2').jstree(true); // get an existing instance (will not create new instance)
* $('#branch_1').jstree().select_node('#branch_1'); // get an instance (using a nested element and call a method)
*
* @name $().jstree([arg])
* @param {String|Object} arg
* @return {Mixed}
*/
jstree(): JSTree;
jstree(options: JSTreeStaticDefaults): JSTree;
jstree(arg: boolean): JSTree;
jstree(...args: any[]): any;
}
interface JSTreeStatic {
/**
* specifies the jstree version in use
* @name $.jstree.version
*/
version: string;
/**
* holds all the default options used when creating new instances
* @name $.jstree.defaults
*/
defaults: JSTreeStaticDefaults;
/**
* stores all loaded jstree plugins (used internally)
*/
plugins: any[];
path: string;
idregex: any;
/**
* creates a jstree instance
* @name $.jstree.create(el [, options])
* @param {DOMElement|jQuery|String} el the element to create the instance on, can be jQuery extended or a selector
* @param {Object} options options for this instance (extends `$.jstree.defaults`)
* @return {jsTree} the new instance
*/
create(el: any, options?: JSTreeStaticDefaults): JSTree;
/**
* remove all traces of jstree from the DOM and destroy all instances
* @name $.jstree.destroy()
*/
destroy(): void;
/**
* the jstree class constructor, used only internally
* @private
* @name $.jstree.core(id)
* @param {Number} id this instance's index
*/
core(id: number): void;
/**
* get a reference to an existing instance
*
* __Examples__
*
* $.jstree.reference('tree');
* $.jstree.reference('#tree');
* $.jstree.reference('branch');
* $.jstree.reference('#branch');
*
* @param {String} selector
* @returns {JSTree|null} the instance or `null` if not found
*/
reference(selector: string): JSTree;
/**
* get a reference to an existing instance
*
* __Examples__
*
* $.jstree.reference(document.getElementByID('tree'));
* $.jstree.reference(document.getElementByID('branch'));
*
* @param {HTMLElement} element
* @returns {JSTree|null} the instance or `null` if not found
*/
reference(element: HTMLElement): JSTree;
/**
* get a reference to an existing instance
*
* __Examples__
*
* $.jstree.reference($('#tree'));
* $.jstree.reference($('#branch'));
*
* @param {JQuery} object
* @returns {JSTree|null} the instance or `null` if not found
*/
reference(object: JQuery): JSTree;
}
interface JSTreeStaticDefaults {
/**
* configure which plugins will be active on an instance.
* Should be an array of strings, where each element is a plugin name.
* The default is `[]`
* @name $.jstree.defaults.plugins
*/
plugins: string[];
/**
* stores all defaults for the core
* @name $.jstree.defaults.core
*/
core: JSTreeStaticDefaultsCore;
/**
* stores all defaults for the checkbox plugin
*/
checkbox?: JSTreeStaticDefaultsCheckbox;
/**
* stores all defaults for the contextmenu plugin
*/
contextmenu?: JSTreeStaticDefaultsContextMenu;
/**
* stores all defaults for the drag'n'drop plugin
*/
dnd?: JSTreeStaticDefaultsDragNDrop;
/**
* Adds massload functionality to jsTree, so that multiple nodes can be loaded in a single request (only useful with lazy loading).
*/
massload?: JSTreeStaticDefaultsMassload;
/**
* stores all defaults for the search plugin
*/
search?: JSTreeStaticDefaultsSearch;
/**
* the settings function used to sort the nodes.
* It is executed in the tree's context, accepts two nodes as arguments and should return `1` or `-1`.
* @name $.jstree.defaults.sort
* @plugin sort
*/
sort?: (x: any, y: any) => number;
/**
* stores all defaults for the state plugin
*/
state?: JSTreeStaticDefaultsState;
/**
* An object storing all types as key value pairs,
* where the key is the type name and the value is an object
* that could contain following keys (all optional).
* max_children the maximum number of immediate children this node type can have.
* Do not specify or set to -1 for unlimited.
* max_depth the maximum number of nesting this node type can have.
* A value of 1 would mean that the node can have children, but no grandchildren.
* Do not specify or set to -1 for unlimited.
* valid_children an array of node type strings, that nodes of this type can have as children.
* Do not specify or set to -1 for no limits.
* icon a string - can be a path to an icon or a className, if using an image
* that is in the current directory use a ./ prefix, otherwise it will be detected as a class.
* Omit to use the default icon from your theme.
* There are two predefined types:
* # represents the root of the tree, for example max_children would control the maximum number of root nodes.
* default represents the default node - any settings here will be applied to all nodes that do not have a type specified.
*/
types?: any;
/**
* stores all defaults for the unique plugin
* @name $.jstree.defaults.unique
* @plugin unique
*/
unique?: JSTreeStaticDefaultsUnique;
}
interface JSTreeStaticDefaultsCore {
/**
* data configuration
*
* If left as `false` the HTML inside the jstree container element is used to populate the tree (that should be an unordered list with list items).
*
* You can also pass in a HTML string or a JSON array here.
*
* It is possible to pass in a standard jQuery-like AJAX config and jstree will automatically determine if the response is JSON or HTML and use that to populate the tree.
* In addition to the standard jQuery ajax options here you can suppy functions for `data` and `url`, the functions will be run in the current instance's scope and a param will be passed indicating which node is being loaded, the return value of those functions will be used.
*
* The last option is to specify a function, that function will receive the node being loaded as argument and a second param which is a function which should be called with the result.
*
* __Examples__
*
* // AJAX
* $('#tree').jstree({
* 'core' : {
* 'data' : {
* 'url' : '/get/children/',
* 'data' : function (node) {
* return { 'id' : node.id };
* }
* }
* });
*
* // direct data
* $('#tree').jstree({
* 'core' : {
* 'data' : [
* 'Simple root node',
* {
* 'id' : 'node_2',
* 'text' : 'Root node with options',
* 'state' : { 'opened' : true, 'selected' : true },
* 'children' : [ { 'text' : 'Child 1' }, 'Child 2']
* }
* ]
* });
*
* // function
* $('#tree').jstree({
* 'core' : {
* 'data' : function (obj, callback) {
* callback.call(this, ['Root 1', 'Root 2']);
* }
* });
*
* @name $.jstree.defaults.core.data
*/
data?: any;
/**
* configure the various strings used throughout the tree
*
* You can use an object where the key is the string you need to replace and the value is your replacement.
* Another option is to specify a function which will be called with an argument of the needed string and should return the replacement.
* If left as `false` no replacement is made.
*
* __Examples__
*
* $('#tree').jstree({
* 'core' : {
* 'strings' : {
* 'Loading ...' : 'Please wait ...'
* }
* }
* });
*
* @name $.jstree.defaults.core.strings
*/
strings?: any;
/**
* determines what happens when a user tries to modify the structure of the tree
* If left as `false` all operations like create, rename, delete, move or copy are prevented.
* You can set this to `true` to allow all interactions or use a function to have better control.
*
* __Examples__
*
* $('#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'
* // in case of 'rename_node' node_position is filled with the new node name
* return operation === 'rename_node' ? true : false;
* }
* }
* });
*
* @name $.jstree.defaults.core.check_callback
*/
check_callback?: any;
/**
* a callback called with a single object parameter in the instance's scope when something goes wrong (operation prevented, ajax failed, etc)
* @name $.jstree.defaults.core.error
*/
error: () => any;
/**
* the open / close animation duration in milliseconds - set this to `false` to disable the animation (default is `200`)
* @name $.jstree.defaults.core.animation
*/
animation?: any;
/**
* a boolean indicating if multiple nodes can be selected
* @name $.jstree.defaults.core.multiple
*/
multiple?: boolean;
/**
* theme configuration object
* @name $.jstree.defaults.core.themes
*/
themes?: JSTreeStaticDefaultsCoreThemes;
/**
* if left as `true` all parents of all selected nodes will be opened once the tree loads (so that all selected nodes are visible to the user)
* @name $.jstree.defaults.core.expand_selected_onload
*/
expand_selected_onload?: boolean;
/**
* if left as `true` web workers will be used to parse incoming JSON data where possible, so that the UI will not be blocked by large requests.
* Workers are however about 30% slower. Defaults to `true`
* @name $.jstree.defaults.core.worker
*/
worker?: boolean;
/**
* Force node text to plain text (and escape HTML). Defaults to `false`
* @name $.jstree.defaults.core.force_text
*/
force_text?: boolean;
/**
* Should the node should be toggled if the text is double clicked . Defaults to `true`
* @name $.jstree.defaults.core.dblclick_toggle
*/
dblclick_toggle?: boolean;
}
interface JSTreeStaticDefaultsCoreThemes {
/**
* the name of the theme to use (if left as `false` the default theme is used)
* @name $.jstree.defaults.core.themes.name
*/
name?: string;
/**
* the URL of the theme's CSS file, leave this as `false` if you have manually included the theme CSS (recommended). You can set this to `true` too which will try to autoload the theme.
* @name $.jstree.defaults.core.themes.url
*/
url?: string;
/**
* the location of all jstree themes - only used if `url` is set to `true`
* @name $.jstree.defaults.core.themes.dir
*/
dir?: string;
/**
* a boolean indicating if connecting dots are shown
* @name $.jstree.defaults.core.themes.dots
*/
dots?: boolean;
/**
* a boolean indicating if node icons are shown
* @name $.jstree.defaults.core.themes.icons
*/
icons?: boolean;
/**
* a boolean indicating if the tree background is striped
* @name $.jstree.defaults.core.themes.stripes
*/
stripes?: boolean;
/**
* a string (or boolean `false`) specifying the theme variant to use (if the theme supports variants)
* @name $.jstree.defaults.core.themes.variant
*/
variant?: any;
/**
* a boolean specifying if a reponsive version of the theme should kick in on smaller screens (if the theme supports it). Defaults to `false`.
* @name $.jstree.defaults.core.themes.responsive
*/
responsive?: boolean;
}
interface JSTreeStaticDefaultsCheckbox {
/**
* a boolean indicating if checkboxes should be visible (can be changed at a later time using `show_checkboxes()` and `hide_checkboxes`). Defaults to `true`.
* @name $.jstree.defaults.checkbox.visible
* @plugin checkbox
*/
visible: boolean;
/**
* a boolean indicating if checkboxes should cascade down and have an undetermined state. Defaults to `true`.
* @name $.jstree.defaults.checkbox.three_state
* @plugin checkbox
*/
three_state: boolean;
/**
* a boolean indicating if clicking anywhere on the node should act as clicking on the checkbox. Defaults to `true`.
* @name $.jstree.defaults.checkbox.whole_node
* @plugin checkbox
*/
whole_node: boolean;
/**
* a boolean indicating if the selected style of a node should be kept, or removed. Defaults to `true`.
* @name $.jstree.defaults.checkbox.keep_selected_style
* @plugin checkbox
*/
keep_selected_style: boolean;
/**
* This setting controls how cascading and undetermined nodes are applied.
* If 'up' is in the string - cascading up is enabled, if 'down' is in the string - cascading down is enabled, if 'undetermined' is in the string - undetermined nodes will be used.
* If `three_state` is set to `true` this setting is automatically set to 'up+down+undetermined'. Defaults to ''.
* @name $.jstree.defaults.checkbox.cascade
* @plugin checkbox
*/
cascade: boolean;
/**
* This setting controls if checkbox are bound to the general tree selection
* or to an internal array maintained by the checkbox plugin.
* Defaults to `true`, only set to `false` if you know exactly what you are doing.
* @name $.jstree.defaults.checkbox.tie_selection
* @plugin checkbox
*/
tie_selection: boolean;
}
interface JSTreeStaticDefaultsContextMenu {
/**
* a boolean indicating if the node should be selected when the context menu is invoked on it. Defaults to `true`.
* @name $.jstree.defaults.contextmenu.select_node
* @plugin contextmenu
*/
select_node: boolean;
/**
* a boolean indicating if the menu should be shown aligned with the node. Defaults to `true`, otherwise the mouse coordinates are used.
* @name $.jstree.defaults.contextmenu.show_at_node
* @plugin contextmenu
*/
show_at_node: boolean;
/**
* an object of actions, or a function that accepts a node and a callback function and calls the callback function with an object of actions available for that node (you can also return the items too).
*
* Each action consists of a key (a unique name) and a value which is an object with the following properties (only label and action are required):
*
* * `separator_before` - a boolean indicating if there should be a separator before this item
* * `separator_after` - a boolean indicating if there should be a separator after this item
* * `_disabled` - a boolean indicating if this action should be disabled
* * `label` - a string - the name of the action (could be a function returning a string)
* * `action` - a function to be executed if this item is chosen
* * `icon` - a string, can be a path to an icon or a className, if using an image that is in the current directory use a `./` prefix, otherwise it will be detected as a class
* * `shortcut` - keyCode which will trigger the action if the menu is open (for example `113` for rename, which equals F2)
* * `shortcut_label` - shortcut label (like for example `F2` for rename)
*
* @name $.jstree.defaults.contextmenu.items
* @plugin contextmenu
*/
items: any;
}
interface JSTreeStaticDefaultsDragNDrop {
/**
* a boolean indicating if a copy should be possible while dragging (by pressint the meta key or Ctrl). Defaults to `true`.
* @name $.jstree.defaults.dnd.copy
* @plugin dnd
*/
copy: boolean;
/**
* a number indicating how long a node should remain hovered while dragging to be opened. Defaults to `500`.
* @name $.jstree.defaults.dnd.open_timeout
* @plugin dnd
*/
open_timeout: number;
/**
* a function invoked each time a node is about to be dragged, invoked in the tree's scope and receives the nodes about to be dragged as an argument (array) - return `false` to prevent dragging
* @name $.jstree.defaults.dnd.is_draggable
* @plugin dnd
*/
is_draggable: boolean;
/**
* a boolean indicating if checks should constantly be made while the user is dragging the node (as opposed to checking only on drop), default is `true`
* @name $.jstree.defaults.dnd.check_while_dragging
* @plugin dnd
*/
check_while_dragging: boolean;
/**
* a boolean indicating if nodes from this tree should only be copied with dnd (as opposed to moved), default is `false`
* @name $.jstree.defaults.dnd.always_copy
* @plugin dnd
*/
always_copy: boolean;
/**
* when dropping a node "inside", this setting indicates the position the node should go to - it can be an integer or a string: "first" (same as 0) or "last", default is `0`
* @name $.jstree.defaults.dnd.inside_pos
* @plugin dnd
*/
inside_pos: any;
/**
* when starting the drag on a node that is selected this setting controls if all selected nodes are dragged or only the single node, default is `true`, which means all selected nodes are dragged when the drag is started on a selected node
* @name $.jstree.defaults.dnd.drag_selection
* @plugin dnd
*/
drag_selection: boolean;
/**
* controls whether dnd works on touch devices. If left as boolean true dnd will work the same as in desktop browsers, which in some cases may impair scrolling. If set to boolean false dnd will not work on touch devices. There is a special third option - string "selected" which means only selected nodes can be dragged on touch devices.
* @name $.jstree.defaults.dnd.touch
* @plugin dnd
*/
touch: boolean;
/**
* controls whether items can be dropped anywhere on the node, not just on the anchor, by default only the node anchor is a valid drop target. Works best with the wholerow plugin. If enabled on mobile depending on the interface it might be hard for the user to cancel the drop, since the whole tree container will be a valid drop target.
* @name $.jstree.defaults.dnd.large_drop_target
* @plugin dnd
*/
large_drop_target: boolean;
/**
* controls whether a drag can be initiated from any part of the node and not just the text/icon part, works best with the wholerow plugin. Keep in mind it can cause problems with tree scrolling on mobile depending on the interface - in that case set the touch option to "selected".
* @name $.jstree.defaults.dnd.large_drag_target
* @plugin dnd
*/
large_drag_target: boolean;
}
interface JSTreeStaticDefaultsMassload {
/**
* massload configuration
*
* It is possible to set this to a standard jQuery-like AJAX config.
* In addition to the standard jQuery ajax options here you can supply functions for `data` and `url`, the functions will be run in the current instance's scope and a param will be passed indicating which node IDs need to be loaded, the return value of those functions will be used.
*
* You can also set this to a function, that function will receive the node IDs being loaded as argument and a second param which is a function (callback) which should be called with the result.
*
* Both the AJAX and the function approach rely on the same return value - an object where the keys are the node IDs, and the value is the children of that node as an array.
*
* {
* "id1" : [{ "text" : "Child of ID1", "id" : "c1" }, { "text" : "Another child of ID1", "id" : "c2" }],
* "id2" : [{ "text" : "Child of ID2", "id" : "c3" }]
* }
*
* @name $.jstree.defaults.massload
* @plugin massload
*/
url: any;
data: any;
}
interface JSTreeStaticDefaultsSearch {
/**
* a jQuery-like AJAX config, which jstree uses if a server should be queried for results.
*
* A `str` (which is the search string) parameter will be added with the request,
* an optional `inside` parameter will be added if the search is limited to a node id.
* The expected result is a JSON array with nodes that need to be opened so that matching nodes will be revealed.
* Leave this setting as `false` to not query the server. You can also set this to a function,
* which will be invoked in the instance's scope and receive 3 parameters - the search string,
* the callback to call with the array of nodes to load, and the optional node ID to limit the search to
* @name $.jstree.defaults.search.ajax
* @plugin search
*/
ajax: any;
/**
* Indicates if the search should be fuzzy or not (should `chnd3` match `child node 3`). Default is `true`.
* @name $.jstree.defaults.search.fuzzy
* @plugin search
*/
fuzzy: boolean;
/**
* Indicates if the search should be case sensitive. Default is `false`.
* @name $.jstree.defaults.search.case_sensitive
* @plugin search
*/
case_sensitive: boolean;
/**
* Indicates if the tree should be filtered (by default) to show only matching nodes
* (keep in mind this can be a heavy on large trees in old browsers).
* This setting can be changed at runtime when calling the search method. Default is `false`.
* @name $.jstree.defaults.search.show_only_matches
* @plugin search
*/
show_only_matches: boolean;
/**
* Indicates if all nodes opened to reveal the search result,
* should be closed when the search is cleared or a new search is performed. Default is `true`.
* @name $.jstree.defaults.search.close_opened_onclear
* @plugin search
*/
close_opened_onclear: boolean;
/**
* Indicates if only leaf nodes should be included in search results. Default is `false`.
* @name $.jstree.defaults.search.search_leaves_only
* @plugin search
*/
search_leaves_only: boolean;
/**
* If set to a function it wil be called in the instance's scope with two arguments -
* search string and node (where node will be every node in the structure, so use with caution).
* If the function returns a truthy value the node will be considered a match
* (it might not be displayed if search_only_leaves is set to true and the node is not a leaf). Default is `false`.
* @name $.jstree.defaults.search.search_callback
* @plugin search
*/
search_callback: any;
}
interface JSTreeStaticDefaultsState {
/**
* A string for the key to use when saving the current tree (change if using multiple trees in your project). Defaults to `jstree`.
* @name $.jstree.defaults.state.key
* @plugin state
*/
key: string;
/**
* A space separated list of events that trigger a state save. Defaults to `changed.jstree open_node.jstree close_node.jstree`.
* @name $.jstree.defaults.state.events
* @plugin state
*/
events: string;
/**
* Time in milliseconds after which the state will expire. Defaults to 'false' meaning - no expire.
* @name $.jstree.defaults.state.ttl
* @plugin state
*/
ttl: any;
/**
* A function that will be executed prior to restoring state with one argument - the state object. Can be used to clear unwanted parts of the state.
* @name $.jstree.defaults.state.filter
* @plugin state
*/
filter: any;
}
interface JSTreeStaticDefaultsUnique {
/**
* Indicates if the comparison should be case sensitive. Default is `false`.
* @name $.jstree.defaults.unique.case_sensitive
* @plugin unique
*/
case_sensitive: boolean;
/**
* A callback executed in the instance's scope when a new node is created
* and the name is already taken, the two arguments are the conflicting name and the counter.
* The default will produce results like `New node (2)`.
* @name $.jstree.defaults.unique.duplicate
* @plugin unique
*/
duplicate: (name: string, counter: number) => string;
}
interface JSTree extends JQuery {
/**
* used to decorate an instance with a plugin. Used internally.
* @private
* @name plugin(deco [, opts])
* @param {String} deco the plugin to decorate with
* @param {Object} opts options for the plugin
* @return {jsTree}
*/
plugin: (deco: string, opts?: any) => JSTree;
/**
* used to decorate an instance with a plugin. Used internally.
* @private
* @name init(el, options)
* @param {DOMElement|jQuery|String} el the element we are transforming
* @param {Object} options options for this instance
* @trigger init.jstree, loading.jstree, loaded.jstree, ready.jstree, changed.jstree
*/
init: (el:any, options:any) => void;
/**
* destroy an instance
* @name destroy()
* @param {Boolean} keep_html if not set to `true` the container will be emptied, otherwise the current DOM elements will be kept intact
*/
destroy: (keep_html?: boolean) => void;
/**
* part of the destroying of an instance. Used internally.
* @private
* @name teardown()
*/
teardown: () => void;
/**
* bind all events. Used internally.
* @private
* @name bind()
*/
bind: () => any;
/**
* part of the destroying of an instance. Used internally.
* @private
* @name unbind()
*/
unbind: () => any;
/**
* trigger an event. Used internally.
* @private
* @name trigger(ev [, data])
* @param {String} ev the name of the event to trigger
* @param {Object} data additional data to pass with the event
*/
/*
* defined in JQuery
*/
// trigger: (ev: string, data?: Object) => any;
/**
* returns the jQuery extended instance container
* @name get_container()
* @return {jQuery}
*/
get_container: () => JQuery;
/**
* returns the jQuery extended main UL node inside the instance container. Used internally.
* @private
* @name get_container_ul()
* @return {jQuery}
*/
get_container_ul: () => JQuery;
/**
* gets string replacements (localization). Used internally.
* @private
* @name get_string(key)
* @param {String} key
* @return {String}
*/
get_string: (key: string) => string;
/**
* gets the first child of a DOM node. Used internally.
* @private
* @name _firstChild(dom)
* @param {DOMElement} dom
* @return {DOMElement}
*/
_firstChild: (dom: HTMLElement) => HTMLElement;
/**
* gets the next sibling of a DOM node. Used internally.
* @private
* @name _nextSibling(dom)
* @param {DOMElement} dom
* @return {DOMElement}
*/
_nextSibling: (dom: HTMLElement) => HTMLElement;
/**
* gets the previous sibling of a DOM node. Used internally.
* @private
* @name _previousSibling(dom)
* @param {DOMElement} dom
* @return {DOMElement}
*/
_previousSibling: (dom: HTMLElement) => HTMLElement;
/**
* get the JSON representation of a node (or the actual jQuery extended DOM node) by using any input (child DOM element, ID string, selector, etc)
* @name get_node(obj [, as_dom])
* @param {mixed} obj
* @param {Boolean} as_dom
* @return {Object|jQuery}
*/
get_node: (obj: any, as_dom?: boolean) => any;
/**
* get the path to a node, either consisting of node texts, or of node IDs, optionally glued together (otherwise an array)
* @name get_path(obj [, glue, ids])
* @param {mixed} obj the node
* @param {String} glue if you want the path as a string - pass the glue here (for example '/'), if a falsy value is supplied here, an array is returned
* @param {Boolean} ids if set to true build the path using ID, otherwise node text is used
* @return {mixed}
*/
get_path: (obj: any, glue: string, ids: boolean) => any;
/**
* get the next visible node that is below the `obj` node. If `strict` is set to `true` only sibling nodes are returned.
* @name get_next_dom(obj [, strict])
* @param {mixed} obj
* @param {Boolean} strict
* @return {jQuery}
*/
get_next_dom: (obj: any, strict?: boolean) => JQuery;
/**
* get the previous visible node that is above the `obj` node. If `strict` is set to `true` only sibling nodes are returned.
* @name get_prev_dom(obj [, strict])
* @param {mixed} obj
* @param {Boolean} strict
* @return {jQuery}
*/
get_prev_dom: (obj: any, strict?: boolean) => JQuery;
/**
* get the parent ID of a node
* @name get_parent(obj)
* @param {mixed} obj
* @return {String}
*/
get_parent: (obj: any) => string;
/**
* get a jQuery collection of all the children of a node (node must be rendered)
* @name get_children_dom(obj)
* @param {mixed} obj
* @return {jQuery}
*/
get_children_dom: (obj: any) => JQuery;
/**
* checks if a node has children
* @name is_parent(obj)
* @param {mixed} obj
* @return {Boolean}
*/
is_parent: (obj: any) => boolean;
/**
* checks if a node is loaded (its children are available)
* @name is_loaded(obj)
* @param {mixed} obj
* @return {Boolean}
*/
is_loaded: (obj: any) => boolean;
/**
* check if a node is currently loading (fetching children)
* @name is_loading(obj)
* @param {mixed} obj
* @return {Boolean}
*/
is_loading: (obj: any) => boolean;
/**
* check if a node is opened
* @name is_open(obj)
* @param {mixed} obj
* @return {Boolean}
*/
is_open: (obj: any) => boolean;
/**
* check if a node is in a closed state
* @name is_closed(obj)
* @param {mixed} obj
* @return {Boolean}
*/
is_closed: (obj: any) => boolean;
/**
* check if a node has no children
* @name is_leaf(obj)
* @param {mixed} obj
* @return {Boolean}
*/
is_leaf: (obj: any) => boolean;
/**
* loads a node (fetches its children using the `core.data` setting). Multiple nodes can be passed to by using an array.
* @name load_node(obj [, callback])
* @param {mixed} obj
* @param {function} callback a function to be executed once loading is conplete, the function is executed in the instance's scope
* and receives two arguments - the node and a boolean status
* @return {Boolean}
* @trigger load_node.jstree
*/
load_node: (obj: any, callback: (node: any, status: boolean) => void) => boolean;
/**
* load an array of nodes (will also load unavailable nodes as soon as the appear in the structure). Used internally.
* @private
* @name _load_nodes(nodes [, callback])
* @param {array} nodes
* @param {function} callback a function to be executed once loading is complete, the function is executed in the instance's scope and receives one argument - the array passed to _load_nodes
* @param {Boolean} is_callback - if false reloads node (AP - original comment missing in source code)
*/
_load_nodes: (nodes: any[], callback?: (nodes: any[]) => void, is_callback?: boolean) => void;
/**
* loads all unloaded nodes
* @name load_all([obj, callback])
* @param {mixed} obj the node to load recursively, omit to load all nodes in the tree
* @param {function} callback a function to be executed once loading all the nodes is complete,
* @trigger load_all.jstree
*/
load_all: (obj: any, callback: () => void) => void;
/**
* handles the actual loading of a node. Used only internally.
* @private
* @name _load_node(obj [, callback])
* @param {mixed} obj
* @param {function} callback a function to be executed once loading is complete, the function is executed in the instance's scope and receives one argument - a boolean status
* @return {Boolean}
*/
_load_node: (obj: any, callback?: (status: boolean) => void) => boolean;
/**
* adds a node to the list of nodes to redraw. Used only internally.
* @private
* @name _node_changed(obj)
* @param {mixed} obj
*/
_node_changed: (obj: any) => void;
/**
* appends HTML content to the tree. Used internally.
* @private
* @name _append_html_data(obj, data)
* @param {mixed} obj the node to append to
* @param {String} data the HTML string to parse and append
* @param {function} callback function which takes boolean flag executes after append (AP: originally lack of comment)
* @trigger model.jstree, changed.jstree
*/
_append_html_data: (dom: any, data: string, cb: (flag: boolean) => void) => void;
/**
* appends JSON content to the tree. Used internally.
* @private
* @name _append_json_data(obj, data)
* @param {mixed} dom the node to append to
* @param {String} data the JSON object to parse and append
* @param {function} cb function which takes boolean flag executes after append (AP: originally lack of comment)
* @param {Boolean} force_processing internal param - do not set
* @trigger model.jstree, changed.jstree
*/
_append_json_data: (dom: any, data: string, cb: (flag: boolean) => void, force_processing: boolean) => void;
/**
* parses a node from a jQuery object and appends them to the in memory tree model. Used internally.
* @private
* @name _parse_model_from_html(d [, p, ps])
* @param {jQuery} d the jQuery object to parse
* @param {String} p the parent ID
* @param {Array} ps list of all parents
* @return {String} the ID of the object added to the model
*/
_parse_model_from_html: (d: JQuery, p?: string, ps?: any[]) => string;
/**
* parses a node from a JSON object (used when dealing with flat data, which has no nesting of children, but has id and parent properties) and appends it to the in memory tree model. Used internally.