tree-element 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +221 -0
- package/lib/animation.d.ts +5 -0
- package/lib/animation.d.ts.map +1 -0
- package/lib/animation.js +39 -0
- package/lib/animation.js.map +1 -0
- package/lib/classNames.d.ts +34 -0
- package/lib/classNames.d.ts.map +1 -0
- package/lib/classNames.js +39 -0
- package/lib/classNames.js.map +1 -0
- package/lib/dataLoader.d.ts +25 -0
- package/lib/dataLoader.d.ts.map +1 -0
- package/lib/dataLoader.js +69 -0
- package/lib/dataLoader.js.map +1 -0
- package/lib/dragAndDropHandler/binarySearch.d.ts +3 -0
- package/lib/dragAndDropHandler/binarySearch.d.ts.map +1 -0
- package/lib/dragAndDropHandler/binarySearch.js +23 -0
- package/lib/dragAndDropHandler/binarySearch.js.map +1 -0
- package/lib/dragAndDropHandler/dragElement.d.ts +20 -0
- package/lib/dragAndDropHandler/dragElement.d.ts.map +1 -0
- package/lib/dragAndDropHandler/dragElement.js +39 -0
- package/lib/dragAndDropHandler/dragElement.js.map +1 -0
- package/lib/dragAndDropHandler/generateHitAreas.d.ts +13 -0
- package/lib/dragAndDropHandler/generateHitAreas.d.ts.map +1 -0
- package/lib/dragAndDropHandler/generateHitAreas.js +130 -0
- package/lib/dragAndDropHandler/generateHitAreas.js.map +1 -0
- package/lib/dragAndDropHandler/index.d.ts +76 -0
- package/lib/dragAndDropHandler/index.d.ts.map +1 -0
- package/lib/dragAndDropHandler/index.js +311 -0
- package/lib/dragAndDropHandler/index.js.map +1 -0
- package/lib/dragAndDropHandler/iterateVisibleNodes.d.ts +11 -0
- package/lib/dragAndDropHandler/iterateVisibleNodes.d.ts.map +1 -0
- package/lib/dragAndDropHandler/iterateVisibleNodes.js +54 -0
- package/lib/dragAndDropHandler/iterateVisibleNodes.js.map +1 -0
- package/lib/dragAndDropHandler/types.d.ts +11 -0
- package/lib/dragAndDropHandler/types.d.ts.map +1 -0
- package/lib/elementsRenderer.d.ts +53 -0
- package/lib/elementsRenderer.d.ts.map +1 -0
- package/lib/elementsRenderer.js +251 -0
- package/lib/elementsRenderer.js.map +1 -0
- package/lib/events.d.ts +224 -0
- package/lib/events.d.ts.map +1 -0
- package/lib/index.d.ts +367 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +1098 -0
- package/lib/index.js.map +1 -0
- package/lib/keyHandler.d.ts +29 -0
- package/lib/keyHandler.d.ts.map +1 -0
- package/lib/keyHandler.js +107 -0
- package/lib/keyHandler.js.map +1 -0
- package/lib/methodTypes.d.ts +21 -0
- package/lib/methodTypes.d.ts.map +1 -0
- package/lib/mouseHandler.d.ts +60 -0
- package/lib/mouseHandler.d.ts.map +1 -0
- package/lib/mouseHandler.js +283 -0
- package/lib/mouseHandler.js.map +1 -0
- package/lib/mouseUtils.d.ts +9 -0
- package/lib/mouseUtils.d.ts.map +1 -0
- package/lib/mouseUtils.js +15 -0
- package/lib/mouseUtils.js.map +1 -0
- package/lib/node.d.ts +320 -0
- package/lib/node.d.ts.map +1 -0
- package/lib/node.js +737 -0
- package/lib/node.js.map +1 -0
- package/lib/nodeElement/borderDropHint.d.ts +9 -0
- package/lib/nodeElement/borderDropHint.d.ts.map +1 -0
- package/lib/nodeElement/borderDropHint.js +24 -0
- package/lib/nodeElement/borderDropHint.js.map +1 -0
- package/lib/nodeElement/folderElement.d.ts +22 -0
- package/lib/nodeElement/folderElement.d.ts.map +1 -0
- package/lib/nodeElement/folderElement.js +100 -0
- package/lib/nodeElement/folderElement.js.map +1 -0
- package/lib/nodeElement/ghostDropHint.d.ts +18 -0
- package/lib/nodeElement/ghostDropHint.d.ts.map +1 -0
- package/lib/nodeElement/ghostDropHint.js +67 -0
- package/lib/nodeElement/ghostDropHint.js.map +1 -0
- package/lib/nodeElement/index.d.ts +28 -0
- package/lib/nodeElement/index.d.ts.map +1 -0
- package/lib/nodeElement/index.js +66 -0
- package/lib/nodeElement/index.js.map +1 -0
- package/lib/nodeUtils.d.ts +7 -0
- package/lib/nodeUtils.d.ts.map +1 -0
- package/lib/nodeUtils.js +4 -0
- package/lib/nodeUtils.js.map +1 -0
- package/lib/options.d.ts +310 -0
- package/lib/options.d.ts.map +1 -0
- package/lib/package.json +3 -0
- package/lib/positionUtils.d.ts +8 -0
- package/lib/positionUtils.d.ts.map +1 -0
- package/lib/positionUtils.js +14 -0
- package/lib/positionUtils.js.map +1 -0
- package/lib/requestUrl.d.ts +9 -0
- package/lib/requestUrl.d.ts.map +1 -0
- package/lib/requestUrl.js +37 -0
- package/lib/requestUrl.js.map +1 -0
- package/lib/saveStateHandler.d.ts +46 -0
- package/lib/saveStateHandler.d.ts.map +1 -0
- package/lib/saveStateHandler.js +204 -0
- package/lib/saveStateHandler.js.map +1 -0
- package/lib/scrollHandler/containerScrollParent.d.ts +12 -0
- package/lib/scrollHandler/containerScrollParent.d.ts.map +1 -0
- package/lib/scrollHandler/containerScrollParent.js +49 -0
- package/lib/scrollHandler/containerScrollParent.js.map +1 -0
- package/lib/scrollHandler/createScrollParent.d.ts +4 -0
- package/lib/scrollHandler/createScrollParent.d.ts.map +1 -0
- package/lib/scrollHandler/createScrollParent.js +38 -0
- package/lib/scrollHandler/createScrollParent.js.map +1 -0
- package/lib/scrollHandler/documentScrollParent.d.ts +22 -0
- package/lib/scrollHandler/documentScrollParent.d.ts.map +1 -0
- package/lib/scrollHandler/documentScrollParent.js +71 -0
- package/lib/scrollHandler/documentScrollParent.js.map +1 -0
- package/lib/scrollHandler/scrollParent.d.ts +26 -0
- package/lib/scrollHandler/scrollParent.d.ts.map +1 -0
- package/lib/scrollHandler/scrollParent.js +79 -0
- package/lib/scrollHandler/scrollParent.js.map +1 -0
- package/lib/scrollHandler.d.ts +20 -0
- package/lib/scrollHandler.d.ts.map +1 -0
- package/lib/scrollHandler.js +41 -0
- package/lib/scrollHandler.js.map +1 -0
- package/lib/selectNodeHandler.d.ts +38 -0
- package/lib/selectNodeHandler.d.ts.map +1 -0
- package/lib/selectNodeHandler.js +166 -0
- package/lib/selectNodeHandler.js.map +1 -0
- package/lib/setDefaultOptions.d.ts +4 -0
- package/lib/setDefaultOptions.d.ts.map +1 -0
- package/lib/setDefaultOptions.js +86 -0
- package/lib/setDefaultOptions.js.map +1 -0
- package/lib/triggerCustomEvent.d.ts +3 -0
- package/lib/triggerCustomEvent.d.ts.map +1 -0
- package/lib/triggerCustomEvent.js +13 -0
- package/lib/triggerCustomEvent.js.map +1 -0
- package/lib/util.d.ts +3 -0
- package/lib/util.d.ts.map +1 -0
- package/lib/util.js +5 -0
- package/lib/util.js.map +1 -0
- package/lib/version.d.ts +3 -0
- package/lib/version.d.ts.map +1 -0
- package/lib/version.js +5 -0
- package/lib/version.js.map +1 -0
- package/package.json +110 -0
- package/src/animation.ts +48 -0
- package/src/classNames.ts +70 -0
- package/src/dataLoader.ts +92 -0
- package/src/dragAndDropHandler/binarySearch.ts +27 -0
- package/src/dragAndDropHandler/dragElement.ts +62 -0
- package/src/dragAndDropHandler/generateHitAreas.ts +195 -0
- package/src/dragAndDropHandler/index.ts +442 -0
- package/src/dragAndDropHandler/iterateVisibleNodes.ts +91 -0
- package/src/dragAndDropHandler/types.ts +12 -0
- package/src/elementsRenderer.ts +367 -0
- package/src/events.ts +237 -0
- package/src/header.txt +16 -0
- package/src/index.ts +1290 -0
- package/src/keyHandler.ts +139 -0
- package/src/methodTypes.ts +44 -0
- package/src/mouseHandler.ts +391 -0
- package/src/mouseUtils.ts +23 -0
- package/src/node.ts +831 -0
- package/src/nodeElement/borderDropHint.ts +37 -0
- package/src/nodeElement/folderElement.ts +140 -0
- package/src/nodeElement/ghostDropHint.ts +84 -0
- package/src/nodeElement/index.ts +103 -0
- package/src/nodeUtils.ts +12 -0
- package/src/options.ts +325 -0
- package/src/positionUtils.ts +18 -0
- package/src/requestUrl.ts +41 -0
- package/src/saveStateHandler.ts +279 -0
- package/src/scrollHandler/containerScrollParent.ts +71 -0
- package/src/scrollHandler/createScrollParent.ts +51 -0
- package/src/scrollHandler/documentScrollParent.ts +104 -0
- package/src/scrollHandler/scrollParent.ts +117 -0
- package/src/scrollHandler.ts +55 -0
- package/src/selectNodeHandler.ts +192 -0
- package/src/setDefaultOptions.ts +79 -0
- package/src/triggerCustomEvent.ts +14 -0
- package/src/util.ts +5 -0
- package/src/version.ts +4 -0
- package/tree_element.css +195 -0
- package/tree_element.debug.js +4153 -0
- package/tree_element.debug.js.map +1 -0
- package/tree_element.js +21 -0
- package/tree_element.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Marco Braak
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# Html-tree
|
|
2
|
+
|
|
3
|
+
Tree widget in plain javascript. No jQuery, no framework, no runtime dependencies.
|
|
4
|
+
|
|
5
|
+
- Loads data from a javascript array or from a url
|
|
6
|
+
- Drag and drop, with autoscroll
|
|
7
|
+
- Keyboard support
|
|
8
|
+
- Saves the open and selected nodes to local storage
|
|
9
|
+
- Right-to-left support
|
|
10
|
+
- Written in Typescript, ships with type declarations
|
|
11
|
+
|
|
12
|
+
Full documentation: https://mbraak.github.io/tree-element/
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm install tree-element
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Or use the bundle directly with a script tag; it exposes a global `TreeElement`:
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<link rel="stylesheet" href="tree_element.css" />
|
|
24
|
+
<script src="tree_element.js"></script>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
```js fixture=standalone
|
|
30
|
+
import TreeElement from "tree-element";
|
|
31
|
+
import "tree-element/tree_element.css";
|
|
32
|
+
|
|
33
|
+
const tree = new TreeElement({
|
|
34
|
+
htmlElement: document.getElementById("tree"),
|
|
35
|
+
data: [
|
|
36
|
+
{
|
|
37
|
+
name: "Saurischia",
|
|
38
|
+
id: 1,
|
|
39
|
+
children: [
|
|
40
|
+
{ name: "Herrerasaurians", id: 2 },
|
|
41
|
+
{ name: "Theropods", id: 3 },
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
autoOpen: 0,
|
|
46
|
+
dragAndDrop: true,
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`htmlElement` is required. Every other key is an option.
|
|
51
|
+
|
|
52
|
+
Nodes are plain objects. `name` is displayed, `children` nests, and `id` is
|
|
53
|
+
optional but needed for `getNodeById` and for saving state. Any other key you
|
|
54
|
+
set is kept on the node and can be read back with `getNodesByProperty`.
|
|
55
|
+
|
|
56
|
+
### Loading from a url
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
new TreeElement({
|
|
60
|
+
htmlElement: document.getElementById("tree"),
|
|
61
|
+
dataUrl: "/nodes/",
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The url can also be set with a `data-url` attribute on the element. Pass a
|
|
66
|
+
function to compute it per node, which is how load-on-demand works: set
|
|
67
|
+
`load_on_demand: true` on a node and its children are fetched when it opens.
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
new TreeElement({
|
|
71
|
+
htmlElement: document.getElementById("tree"),
|
|
72
|
+
dataUrl: (node) => (node ? `/nodes/?node=${node.id}` : "/nodes/"),
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Options
|
|
77
|
+
|
|
78
|
+
| Option | Default | Description |
|
|
79
|
+
| ----------------- | -------------------- | --------------------------------------------------------------------------------- |
|
|
80
|
+
| `animationSpeed` | `"fast"` | `"fast"`, `"slow"`, or a number of milliseconds |
|
|
81
|
+
| `autoEscape` | `true` | Escape node names. Set to `false` to render html in a name |
|
|
82
|
+
| `autoOpen` | `false` | `true` opens everything, a number opens that many levels (`0` is the first level) |
|
|
83
|
+
| `buttonLeft` | `true` | Put the open/close button left of the title |
|
|
84
|
+
| `classPrefix` | `"tree-element"` | The prefix of all css classes |
|
|
85
|
+
| `closedIcon` | `►` (`◄` in rtl) | Html string or element |
|
|
86
|
+
| `commonClassName` | `"tree-element-common"` | The class that every element gets |
|
|
87
|
+
| `data` | | The nodes to display |
|
|
88
|
+
| `dataFilter` | | Transforms the response of `dataUrl` into node data |
|
|
89
|
+
| `dataUrl` | `data-url` attribute | Url, or a function returning a url |
|
|
90
|
+
| `dragAndDrop` | `false` | Enable drag and drop |
|
|
91
|
+
| `keyboardSupport` | `true` | Navigate with the arrow keys |
|
|
92
|
+
| `nodeClass` | `Node` | Subclass of `Node` to use for nodes |
|
|
93
|
+
| `openFolderDelay` | `500` | Milliseconds before a folder opens while dragging over it. `false` disables it |
|
|
94
|
+
| `openedIcon` | `▼` | Html string or element |
|
|
95
|
+
| `rtl` | `data-rtl` attribute | Right-to-left rendering |
|
|
96
|
+
| `saveState` | `false` | `true`, or a string to use as the storage key |
|
|
97
|
+
| `selectable` | `true` | Allow selecting nodes |
|
|
98
|
+
| `showEmptyFolder` | `false` | Show the open/close button for nodes without children |
|
|
99
|
+
| `slide` | `true` | Animate opening and closing |
|
|
100
|
+
| `startDndDelay` | `300` | Milliseconds to hold before a drag starts |
|
|
101
|
+
| `tabIndex` | `0` | Tab index of the tree element |
|
|
102
|
+
| `treeClassName` | `"tree-element"` | The class of the root `ul` |
|
|
103
|
+
| `useContextMenu` | `true` | Fire `tree.contextmenu` on right click |
|
|
104
|
+
|
|
105
|
+
### Callbacks
|
|
106
|
+
|
|
107
|
+
| Option | Signature | Description |
|
|
108
|
+
| ----------------------- | ----------------------------------------- | ------------------------------------------------------------------------- |
|
|
109
|
+
| `onCanMove` | `(node) => boolean` | May this node be dragged? |
|
|
110
|
+
| `onCanMoveTo` | `(node, targetNode, position) => boolean` | May it be dropped here? `position` is `"before"`, `"after"` or `"inside"` |
|
|
111
|
+
| `onCanSelectNode` | `(node) => boolean` | May this node be selected? |
|
|
112
|
+
| `onCreateLi` | `(node, li, isSelected) => void` | Customise the `li` element of a node |
|
|
113
|
+
| `onDragMove` | `(node, event) => void` | Called while dragging |
|
|
114
|
+
| `onDragStop` | `(node, event) => void` | Called when a drag ends |
|
|
115
|
+
| `onGetStateFromStorage` | `() => string` | Read saved state yourself |
|
|
116
|
+
| `onSetStateFromStorage` | `(data) => void` | Write saved state yourself |
|
|
117
|
+
| `onIsMoveHandle` | `(element) => boolean` | Is this element a drag handle? |
|
|
118
|
+
|
|
119
|
+
## Events
|
|
120
|
+
|
|
121
|
+
Events are `CustomEvent`s dispatched on the tree element. They bubble, and the
|
|
122
|
+
payload is on `event.detail`.
|
|
123
|
+
|
|
124
|
+
```js
|
|
125
|
+
element.addEventListener("tree.select", (e) => {
|
|
126
|
+
console.log(e.detail.node);
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
| Event | `detail` |
|
|
131
|
+
| ------------------- | -------------------------------------------------------------------------------------------------- |
|
|
132
|
+
| `tree.init` | |
|
|
133
|
+
| `tree.click` | `node`, `originalEvent` |
|
|
134
|
+
| `tree.dblclick` | `node`, `originalEvent` |
|
|
135
|
+
| `tree.contextmenu` | `node`, `originalEvent` |
|
|
136
|
+
| `tree.select` | `node`, `deselectedNode` |
|
|
137
|
+
| `tree.deselect` | `node` |
|
|
138
|
+
| `tree.open` | `node` |
|
|
139
|
+
| `tree.close` | `node` |
|
|
140
|
+
| `tree.move` | `moveInfo` with `movedNode`, `targetNode`, `position`, `previousParent`, `doMove`, `originalEvent` |
|
|
141
|
+
| `tree.refresh` | |
|
|
142
|
+
| `tree.set_data` | `treeData`, `node` |
|
|
143
|
+
| `tree.loading_data` | `node`, `element` |
|
|
144
|
+
| `tree.loaded_data` | `node`, `element` |
|
|
145
|
+
| `tree.load_failed` | `response` |
|
|
146
|
+
|
|
147
|
+
`tree.click` and `tree.move` act on `event.preventDefault()`: it stops the node
|
|
148
|
+
from being selected, and stops the move. For `tree.move`, call
|
|
149
|
+
`e.detail.moveInfo.doMove()` later to perform the move yourself. The other
|
|
150
|
+
events are dispatched as cancelable, but nothing acts on it.
|
|
151
|
+
|
|
152
|
+
## Methods
|
|
153
|
+
|
|
154
|
+
Nodes are `Node` instances. Get one with `getNodeById`, `getNodeByName`,
|
|
155
|
+
`getNodeByCallback`, `getNodesByProperty` or `getNode` (from a dom element).
|
|
156
|
+
|
|
157
|
+
**Data**: `loadData(data, parentNode?)`, `loadDataFromUrl(url?, parentNode?)`, `toJson()`, `refresh()`
|
|
158
|
+
|
|
159
|
+
**Nodes**: `appendNode(data, parentNode)`, `prependNode(data, parentNode)`, `addNodeAfter(data, node)`, `addNodeBefore(data, node)`, `addParentNode(data, node)`, `updateNode(node, data)`, `removeNode(node)`, `moveNode(node, targetNode, position)`
|
|
160
|
+
|
|
161
|
+
**Opening**: `openNode(node, slide?)`, `closeNode(node, slide?)`, `toggle(node, slide?)`
|
|
162
|
+
|
|
163
|
+
**Selection**: `selectNode(node, options?)`, `getSelectedNode()`, `getSelectedNodes()`, `isNodeSelected(node)`, `addToSelection(node, mustSetFocus?)`, `removeFromSelection(node)`, `moveUp()`, `moveDown()`
|
|
164
|
+
|
|
165
|
+
**State**: `getState()`, `setState(state)`, `getStateFromStorage()`
|
|
166
|
+
|
|
167
|
+
**Other**: `scrollToNode(node)`, `isDragging()`, `refreshHitAreas()`, `setOption(name, value)`, `getTree()`, `getVersion()`, `deinit()`
|
|
168
|
+
|
|
169
|
+
## Typescript
|
|
170
|
+
|
|
171
|
+
The public types are exported from the package entry point:
|
|
172
|
+
|
|
173
|
+
```ts fixture=standalone
|
|
174
|
+
import TreeElement from "tree-element";
|
|
175
|
+
import type {
|
|
176
|
+
TreeElementOptions,
|
|
177
|
+
Node,
|
|
178
|
+
NodeData,
|
|
179
|
+
NodeId,
|
|
180
|
+
SavedState,
|
|
181
|
+
} from "tree-element";
|
|
182
|
+
|
|
183
|
+
const options: Partial<TreeElementOptions> = { dragAndDrop: true };
|
|
184
|
+
const data: NodeData[] = [{ name: "root", id: 1 }];
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
`Node` is exported as a type only, so it cannot be used with `instanceof`.
|
|
188
|
+
|
|
189
|
+
## Entry points
|
|
190
|
+
|
|
191
|
+
| | |
|
|
192
|
+
| ------------------------- | ------------------------------------------------------------ |
|
|
193
|
+
| `import "tree-element"` | `lib/index.js`, unbundled es modules |
|
|
194
|
+
| `require`, script tag | `tree_element.js`, minified iife exposing the global `TreeElement` |
|
|
195
|
+
| `tree-element/tree_element.css` | The stylesheet |
|
|
196
|
+
|
|
197
|
+
`tree_element.debug.js` is the same bundle without minification.
|
|
198
|
+
|
|
199
|
+
The es modules in `lib` are minified by your own bundler. Private members are
|
|
200
|
+
prefixed with `_`, so add the same terser setting the bundled build uses to get
|
|
201
|
+
the same size:
|
|
202
|
+
|
|
203
|
+
```js ignore
|
|
204
|
+
terser({ mangle: { properties: { regex: /^_/ } } });
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Development
|
|
208
|
+
|
|
209
|
+
```sh
|
|
210
|
+
pnpm install
|
|
211
|
+
pnpm devserver # http://localhost:8080
|
|
212
|
+
pnpm production # build the bundles, lib and the css
|
|
213
|
+
pnpm docs-check # type-check the code snippets in the docs
|
|
214
|
+
pnpm ci # lint, typecheck, check the docs and test
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
`pnpm test` runs the vitest unit tests and the playwright browser tests.
|
|
218
|
+
|
|
219
|
+
## License
|
|
220
|
+
|
|
221
|
+
Apache-2.0. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type AnimationSpeed = "fast" | "slow" | number;
|
|
2
|
+
export declare const getAnimationDuration: (duration: AnimationSpeed) => number;
|
|
3
|
+
export declare const slideDown: (element: HTMLElement, animationSpeed: AnimationSpeed, onFinished: () => void) => void;
|
|
4
|
+
export declare const slideUp: (element: HTMLElement, animationSpeed: AnimationSpeed, onFinished: () => void) => void;
|
|
5
|
+
//# sourceMappingURL=animation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation.d.ts","sourceRoot":"","sources":["../src/animation.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEtD,eAAO,MAAM,oBAAoB,GAAI,UAAU,cAAc,KAAG,MAM/D,CAAC;AAEF,eAAO,MAAM,SAAS,GACpB,SAAS,WAAW,EACpB,gBAAgB,cAAc,EAC9B,YAAY,MAAM,IAAI,KACrB,IAcF,CAAC;AAEF,eAAO,MAAM,OAAO,GAClB,SAAS,WAAW,EACpB,gBAAgB,cAAc,EAC9B,YAAY,MAAM,IAAI,KACrB,IAaF,CAAC"}
|
package/lib/animation.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const getAnimationDuration = duration => {
|
|
2
|
+
if (typeof duration === "number") {
|
|
3
|
+
return duration;
|
|
4
|
+
}
|
|
5
|
+
return duration === "slow" ? 600 : 200;
|
|
6
|
+
};
|
|
7
|
+
const slideDown = (element, animationSpeed, onFinished) => {
|
|
8
|
+
element.style.display = "block";
|
|
9
|
+
const animation = element.animate([{
|
|
10
|
+
height: "0",
|
|
11
|
+
overflow: "hidden"
|
|
12
|
+
}, {
|
|
13
|
+
height: `${element.scrollHeight}px`,
|
|
14
|
+
overflow: "hidden"
|
|
15
|
+
}], {
|
|
16
|
+
duration: getAnimationDuration(animationSpeed)
|
|
17
|
+
});
|
|
18
|
+
animation.onfinish = () => {
|
|
19
|
+
onFinished();
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
const slideUp = (element, animationSpeed, onFinished) => {
|
|
23
|
+
const animation = element.animate([{
|
|
24
|
+
height: `${element.scrollHeight}px`,
|
|
25
|
+
overflow: "hidden"
|
|
26
|
+
}, {
|
|
27
|
+
height: "0",
|
|
28
|
+
overflow: "hidden"
|
|
29
|
+
}], {
|
|
30
|
+
duration: getAnimationDuration(animationSpeed)
|
|
31
|
+
});
|
|
32
|
+
animation.onfinish = () => {
|
|
33
|
+
element.style.display = "none";
|
|
34
|
+
onFinished();
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { getAnimationDuration, slideDown, slideUp };
|
|
39
|
+
//# sourceMappingURL=animation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation.js","sources":["../src/animation.ts"],"sourcesContent":["export type AnimationSpeed = \"fast\" | \"slow\" | number;\n\nexport const getAnimationDuration = (duration: AnimationSpeed): number => {\n if (typeof duration === \"number\") {\n return duration;\n }\n\n return duration === \"slow\" ? 600 : 200;\n};\n\nexport const slideDown = (\n element: HTMLElement,\n animationSpeed: AnimationSpeed,\n onFinished: () => void,\n): void => {\n element.style.display = \"block\";\n\n const animation = element.animate(\n [\n { height: \"0\", overflow: \"hidden\" },\n { height: `${element.scrollHeight}px`, overflow: \"hidden\" },\n ],\n { duration: getAnimationDuration(animationSpeed) },\n );\n\n animation.onfinish = () => {\n onFinished();\n };\n};\n\nexport const slideUp = (\n element: HTMLElement,\n animationSpeed: AnimationSpeed,\n onFinished: () => void,\n): void => {\n const animation = element.animate(\n [\n { height: `${element.scrollHeight}px`, overflow: \"hidden\" },\n { height: \"0\", overflow: \"hidden\" },\n ],\n { duration: getAnimationDuration(animationSpeed) },\n );\n\n animation.onfinish = () => {\n element.style.display = \"none\";\n onFinished();\n };\n};"],"names":[],"mappings":"AAEO,MAAM,oBAAoB,GAAI,QAAwB,IAAa;AACxE,EAAA,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;AAChC,IAAA,OAAO,QAAQ;AACjB,EAAA;AAEA,EAAA,OAAO,QAAQ,KAAK,MAAM,GAAG,GAAG,GAAG,GAAG;AACxC;AAEO,MAAM,SAAS,GAAG,CACvB,OAAoB,EACpB,cAA8B,EAC9B,UAAsB,KACb;AACT,EAAA,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,OAAO;AAE/B,EAAA,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAC/B,CACE;AAAE,IAAA,MAAM,EAAE,GAAG;AAAE,IAAA,QAAQ,EAAE;AAAS,GAAC,EACnC;AAAE,IAAA,MAAM,EAAE,CAAA,EAAG,OAAO,CAAC,YAAY,CAAA,EAAA,CAAI;AAAE,IAAA,QAAQ,EAAE;AAAS,GAAC,CAC5D,EACD;IAAE,QAAQ,EAAE,oBAAoB,CAAC,cAAc;AAAE,GACnD,CAAC;EAED,SAAS,CAAC,QAAQ,GAAG,MAAM;AACzB,IAAA,UAAU,EAAE;EACd,CAAC;AACH;AAEO,MAAM,OAAO,GAAG,CACrB,OAAoB,EACpB,cAA8B,EAC9B,UAAsB,KACb;AACT,EAAA,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAC/B,CACE;AAAE,IAAA,MAAM,EAAE,CAAA,EAAG,OAAO,CAAC,YAAY,CAAA,EAAA,CAAI;AAAE,IAAA,QAAQ,EAAE;AAAS,GAAC,EAC3D;AAAE,IAAA,MAAM,EAAE,GAAG;AAAE,IAAA,QAAQ,EAAE;AAAS,GAAC,CACpC,EACD;IAAE,QAAQ,EAAE,oBAAoB,CAAC,cAAc;AAAE,GACnD,CAAC;EAED,SAAS,CAAC,QAAQ,GAAG,MAAM;AACzB,IAAA,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM;AAC9B,IAAA,UAAU,EAAE;EACd,CAAC;AACH;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface ClassNames {
|
|
2
|
+
border: string;
|
|
3
|
+
circle: string;
|
|
4
|
+
closed: string;
|
|
5
|
+
common: string;
|
|
6
|
+
dnd: string;
|
|
7
|
+
dragging: string;
|
|
8
|
+
element: string;
|
|
9
|
+
folder: string;
|
|
10
|
+
ghost: string;
|
|
11
|
+
inside: string;
|
|
12
|
+
line: string;
|
|
13
|
+
loading: string;
|
|
14
|
+
moving: string;
|
|
15
|
+
rtl: string;
|
|
16
|
+
selected: string;
|
|
17
|
+
title: string;
|
|
18
|
+
titleButtonLeft: string;
|
|
19
|
+
titleButtonRight: string;
|
|
20
|
+
titleFolder: string;
|
|
21
|
+
toggler: string;
|
|
22
|
+
togglerLeft: string;
|
|
23
|
+
togglerRight: string;
|
|
24
|
+
tree: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ClassNamesOptions {
|
|
27
|
+
classPrefix: string;
|
|
28
|
+
commonClassName?: string;
|
|
29
|
+
treeClassName?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare const DEFAULT_CLASS_PREFIX = "tree-element";
|
|
32
|
+
declare const createClassNames: ({ classPrefix, commonClassName, treeClassName, }: ClassNamesOptions) => ClassNames;
|
|
33
|
+
export default createClassNames;
|
|
34
|
+
//# sourceMappingURL=classNames.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classNames.d.ts","sourceRoot":"","sources":["../src/classNames.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,oBAAoB,iBAAiB,CAAC;AAOnD,QAAA,MAAM,gBAAgB,GAAI,kDAIvB,iBAAiB,KAAG,UAwBrB,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const DEFAULT_CLASS_PREFIX = "tree-element";
|
|
2
|
+
|
|
3
|
+
/* Create the class names that the widget puts on the elements it creates.
|
|
4
|
+
* They are all derived from classPrefix, except for the class of the root
|
|
5
|
+
* element and the class that every element gets, which have an option of
|
|
6
|
+
* their own.
|
|
7
|
+
*/
|
|
8
|
+
const createClassNames = ({
|
|
9
|
+
classPrefix,
|
|
10
|
+
commonClassName,
|
|
11
|
+
treeClassName
|
|
12
|
+
}) => ({
|
|
13
|
+
border: `${classPrefix}-border`,
|
|
14
|
+
circle: `${classPrefix}-circle`,
|
|
15
|
+
closed: `${classPrefix}-closed`,
|
|
16
|
+
common: commonClassName ?? `${classPrefix}-common`,
|
|
17
|
+
dnd: `${classPrefix}-dnd`,
|
|
18
|
+
dragging: `${classPrefix}-dragging`,
|
|
19
|
+
element: `${classPrefix}-element`,
|
|
20
|
+
folder: `${classPrefix}-folder`,
|
|
21
|
+
ghost: `${classPrefix}-ghost`,
|
|
22
|
+
inside: `${classPrefix}-inside`,
|
|
23
|
+
line: `${classPrefix}-line`,
|
|
24
|
+
loading: `${classPrefix}-loading`,
|
|
25
|
+
moving: `${classPrefix}-moving`,
|
|
26
|
+
rtl: `${classPrefix}-rtl`,
|
|
27
|
+
selected: `${classPrefix}-selected`,
|
|
28
|
+
title: `${classPrefix}-title`,
|
|
29
|
+
titleButtonLeft: `${classPrefix}-title-button-left`,
|
|
30
|
+
titleButtonRight: `${classPrefix}-title-button-right`,
|
|
31
|
+
titleFolder: `${classPrefix}-title-folder`,
|
|
32
|
+
toggler: `${classPrefix}-toggler`,
|
|
33
|
+
togglerLeft: `${classPrefix}-toggler-left`,
|
|
34
|
+
togglerRight: `${classPrefix}-toggler-right`,
|
|
35
|
+
tree: treeClassName ?? classPrefix
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export { DEFAULT_CLASS_PREFIX, createClassNames as default };
|
|
39
|
+
//# sourceMappingURL=classNames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classNames.js","sources":["../src/classNames.ts"],"sourcesContent":["export interface ClassNames {\n border: string;\n circle: string;\n closed: string;\n common: string;\n dnd: string;\n dragging: string;\n element: string;\n folder: string;\n ghost: string;\n inside: string;\n line: string;\n loading: string;\n moving: string;\n rtl: string;\n selected: string;\n title: string;\n titleButtonLeft: string;\n titleButtonRight: string;\n titleFolder: string;\n toggler: string;\n togglerLeft: string;\n togglerRight: string;\n tree: string;\n}\n\nexport interface ClassNamesOptions {\n classPrefix: string;\n commonClassName?: string;\n treeClassName?: string;\n}\n\nexport const DEFAULT_CLASS_PREFIX = \"tree-element\";\n\n/* Create the class names that the widget puts on the elements it creates.\n * They are all derived from classPrefix, except for the class of the root\n * element and the class that every element gets, which have an option of\n * their own.\n */\nconst createClassNames = ({\n classPrefix,\n commonClassName,\n treeClassName,\n}: ClassNamesOptions): ClassNames => ({\n border: `${classPrefix}-border`,\n circle: `${classPrefix}-circle`,\n closed: `${classPrefix}-closed`,\n common: commonClassName ?? `${classPrefix}-common`,\n dnd: `${classPrefix}-dnd`,\n dragging: `${classPrefix}-dragging`,\n element: `${classPrefix}-element`,\n folder: `${classPrefix}-folder`,\n ghost: `${classPrefix}-ghost`,\n inside: `${classPrefix}-inside`,\n line: `${classPrefix}-line`,\n loading: `${classPrefix}-loading`,\n moving: `${classPrefix}-moving`,\n rtl: `${classPrefix}-rtl`,\n selected: `${classPrefix}-selected`,\n title: `${classPrefix}-title`,\n titleButtonLeft: `${classPrefix}-title-button-left`,\n titleButtonRight: `${classPrefix}-title-button-right`,\n titleFolder: `${classPrefix}-title-folder`,\n toggler: `${classPrefix}-toggler`,\n togglerLeft: `${classPrefix}-toggler-left`,\n togglerRight: `${classPrefix}-toggler-right`,\n tree: treeClassName ?? classPrefix,\n});\n\nexport default createClassNames;\n"],"names":[],"mappings":"AAgCO,MAAM,oBAAoB,GAAG;;AAEpC;AACA;AACA;AACA;AACA;AACA,MAAM,gBAAgB,GAAG,CAAC;EACtB,WAAW;EACX,eAAe;AACf,EAAA;AACe,CAAC,MAAkB;EAClC,MAAM,EAAE,CAAA,EAAG,WAAW,CAAA,OAAA,CAAS;EAC/B,MAAM,EAAE,CAAA,EAAG,WAAW,CAAA,OAAA,CAAS;EAC/B,MAAM,EAAE,CAAA,EAAG,WAAW,CAAA,OAAA,CAAS;AAC/B,EAAA,MAAM,EAAE,eAAe,IAAI,CAAA,EAAG,WAAW,CAAA,OAAA,CAAS;EAClD,GAAG,EAAE,CAAA,EAAG,WAAW,CAAA,IAAA,CAAM;EACzB,QAAQ,EAAE,CAAA,EAAG,WAAW,CAAA,SAAA,CAAW;EACnC,OAAO,EAAE,CAAA,EAAG,WAAW,CAAA,QAAA,CAAU;EACjC,MAAM,EAAE,CAAA,EAAG,WAAW,CAAA,OAAA,CAAS;EAC/B,KAAK,EAAE,CAAA,EAAG,WAAW,CAAA,MAAA,CAAQ;EAC7B,MAAM,EAAE,CAAA,EAAG,WAAW,CAAA,OAAA,CAAS;EAC/B,IAAI,EAAE,CAAA,EAAG,WAAW,CAAA,KAAA,CAAO;EAC3B,OAAO,EAAE,CAAA,EAAG,WAAW,CAAA,QAAA,CAAU;EACjC,MAAM,EAAE,CAAA,EAAG,WAAW,CAAA,OAAA,CAAS;EAC/B,GAAG,EAAE,CAAA,EAAG,WAAW,CAAA,IAAA,CAAM;EACzB,QAAQ,EAAE,CAAA,EAAG,WAAW,CAAA,SAAA,CAAW;EACnC,KAAK,EAAE,CAAA,EAAG,WAAW,CAAA,MAAA,CAAQ;EAC7B,eAAe,EAAE,CAAA,EAAG,WAAW,CAAA,kBAAA,CAAoB;EACnD,gBAAgB,EAAE,CAAA,EAAG,WAAW,CAAA,mBAAA,CAAqB;EACrD,WAAW,EAAE,CAAA,EAAG,WAAW,CAAA,aAAA,CAAe;EAC1C,OAAO,EAAE,CAAA,EAAG,WAAW,CAAA,QAAA,CAAU;EACjC,WAAW,EAAE,CAAA,EAAG,WAAW,CAAA,aAAA,CAAe;EAC1C,YAAY,EAAE,CAAA,EAAG,WAAW,CAAA,cAAA,CAAgB;EAC5C,IAAI,EAAE,aAAa,IAAI;AAC3B,CAAC;;"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ClassNames } from "./classNames.js";
|
|
2
|
+
import type { LoadData, TriggerEvent } from "./methodTypes.js";
|
|
3
|
+
import type { Node } from "./node.js";
|
|
4
|
+
import type { DataFilter } from "./options.js";
|
|
5
|
+
import type RequestUrl from "./requestUrl.js";
|
|
6
|
+
interface DataLoaderParams {
|
|
7
|
+
classNames: ClassNames;
|
|
8
|
+
dataFilter?: DataFilter;
|
|
9
|
+
loadData: LoadData;
|
|
10
|
+
treeElement: HTMLElement;
|
|
11
|
+
triggerEvent: TriggerEvent;
|
|
12
|
+
}
|
|
13
|
+
export default class DataLoader {
|
|
14
|
+
private abortController;
|
|
15
|
+
private classNames;
|
|
16
|
+
private dataFilter?;
|
|
17
|
+
private loadData;
|
|
18
|
+
private treeElement;
|
|
19
|
+
private triggerEvent;
|
|
20
|
+
constructor({ classNames, dataFilter, loadData, treeElement, triggerEvent, }: DataLoaderParams);
|
|
21
|
+
deinit(): void;
|
|
22
|
+
loadFromUrl(url: RequestUrl, node?: Node): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=dataLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataLoader.d.ts","sourceRoot":"","sources":["../src/dataLoader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAY,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAE3C,UAAU,gBAAgB;IACtB,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,WAAW,CAAC;IACzB,YAAY,EAAE,YAAY,CAAC;CAC9B;AAED,MAAM,CAAC,OAAO,OAAO,UAAU;IAC3B,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,UAAU,CAAC,CAAa;IAChC,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,YAAY,CAAe;gBAEvB,EACR,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,YAAY,GACf,EAAE,gBAAgB;IASZ,MAAM,IAAI,IAAI;IAIR,WAAW,CACpB,GAAG,EAAE,UAAU,EACf,IAAI,CAAC,EAAE,IAAI,GACZ,OAAO,CAAC,IAAI,CAAC;CA+CnB"}
|