@boxcustodia/library 0.0.7 → 0.0.8

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.
Files changed (272) hide show
  1. package/dist/index.d.ts +6 -1
  2. package/dist/index.es100.js +4 -4
  3. package/dist/index.es101.js +4 -14
  4. package/dist/index.es102.js +3 -4
  5. package/dist/index.es103.js +14 -57
  6. package/dist/index.es104.js +5 -29
  7. package/dist/index.es105.js +57 -12
  8. package/dist/index.es106.js +29 -11
  9. package/dist/index.es111.js +243 -1046
  10. package/dist/index.es112.js +12 -4
  11. package/dist/index.es113.js +11 -4
  12. package/dist/index.es114.js +7 -7
  13. package/dist/index.es117.js +14 -14
  14. package/dist/index.es118.js +813 -55
  15. package/dist/index.es119.js +9 -822
  16. package/dist/index.es120.js +5 -3
  17. package/dist/index.es121.js +64 -11
  18. package/dist/index.es122.js +88 -11
  19. package/dist/index.es123.js +11 -88
  20. package/dist/index.es124.js +4 -216
  21. package/dist/index.es127.js +5 -5
  22. package/dist/index.es128.js +216 -4
  23. package/dist/index.es129.js +2 -2
  24. package/dist/index.es134.js +1 -1
  25. package/dist/index.es137.js +20 -11
  26. package/dist/index.es138.js +37 -205
  27. package/dist/index.es139.js +10 -10
  28. package/dist/index.es140.js +11 -20
  29. package/dist/index.es141.js +205 -37
  30. package/dist/index.es142.js +10 -10
  31. package/dist/index.es143.js +5 -6
  32. package/dist/index.es144.js +2 -65
  33. package/dist/index.es145.js +44 -11
  34. package/dist/index.es146.js +5 -123
  35. package/dist/index.es147.js +58 -128
  36. package/dist/index.es148.js +11 -14
  37. package/dist/index.es149.js +122 -30
  38. package/dist/index.es150.js +134 -14
  39. package/dist/index.es151.js +12 -7
  40. package/dist/index.es152.js +32 -49
  41. package/dist/index.es153.js +14 -5
  42. package/dist/index.es154.js +9 -2
  43. package/dist/index.es155.js +48 -648
  44. package/dist/index.es156.js +5 -5
  45. package/dist/index.es157.js +649 -3
  46. package/dist/index.es158.js +4 -4
  47. package/dist/index.es159.js +3 -45
  48. package/dist/index.es160.js +45 -7
  49. package/dist/index.es161.js +7 -5
  50. package/dist/index.es162.js +6 -28
  51. package/dist/index.es163.js +27 -43
  52. package/dist/index.es164.js +3 -3
  53. package/dist/index.es166.js +5 -5
  54. package/dist/index.es168.js +2 -2
  55. package/dist/index.es179.js +1 -1
  56. package/dist/index.es180.js +1 -1
  57. package/dist/index.es181.js +2 -2
  58. package/dist/index.es182.js +1 -1
  59. package/dist/index.es184.js +1 -1
  60. package/dist/index.es207.js +1 -1
  61. package/dist/index.es240.js +1 -1
  62. package/dist/index.es241.js +24 -177
  63. package/dist/index.es242.js +5 -5
  64. package/dist/index.es243.js +2 -2
  65. package/dist/index.es246.js +1 -1
  66. package/dist/index.es247.js +1 -1
  67. package/dist/index.es248.js +3 -3
  68. package/dist/index.es249.js +178 -2
  69. package/dist/index.es250.js +25 -397
  70. package/dist/index.es251.js +4 -722
  71. package/dist/index.es252.js +7 -282
  72. package/dist/index.es253.js +13 -60
  73. package/dist/index.es254.js +13 -9
  74. package/dist/index.es255.js +134 -28
  75. package/dist/index.es256.js +32 -199
  76. package/dist/index.es257.js +462 -25
  77. package/dist/index.es258.js +131 -4
  78. package/dist/index.es259.js +27 -8
  79. package/dist/index.es260.js +4 -13
  80. package/dist/index.es261.js +26 -13
  81. package/dist/index.es262.js +7 -134
  82. package/dist/index.es263.js +11 -31
  83. package/dist/index.es264.js +26 -460
  84. package/dist/index.es265.js +47 -130
  85. package/dist/index.es266.js +31 -27
  86. package/dist/index.es267.js +43 -4
  87. package/dist/index.es268.js +158 -26
  88. package/dist/index.es269.js +32 -6
  89. package/dist/index.es27.js +1 -1
  90. package/dist/index.es270.js +2 -12
  91. package/dist/index.es271.js +77 -26
  92. package/dist/index.es272.js +18 -48
  93. package/dist/index.es273.js +2 -31
  94. package/dist/index.es274.js +397 -43
  95. package/dist/index.es275.js +715 -151
  96. package/dist/index.es276.js +278 -29
  97. package/dist/index.es277.js +61 -2
  98. package/dist/index.es278.js +8 -78
  99. package/dist/index.es279.js +28 -18
  100. package/dist/index.es28.js +3 -3
  101. package/dist/index.es280.js +199 -25
  102. package/dist/index.es281.js +15 -16
  103. package/dist/index.es282.js +3 -8
  104. package/dist/index.es283.js +16 -4
  105. package/dist/index.es284.js +8 -14
  106. package/dist/index.es285.js +4 -15
  107. package/dist/index.es286.js +14 -15
  108. package/dist/index.es287.js +15 -3
  109. package/dist/index.es29.js +6 -6
  110. package/dist/index.es31.js +2 -2
  111. package/dist/index.es32.js +2 -2
  112. package/dist/index.es322.js +3 -3
  113. package/dist/index.es323.js +3 -3
  114. package/dist/index.es325.js +1 -1
  115. package/dist/index.es326.js +5 -5
  116. package/dist/index.es327.js +1 -1
  117. package/dist/index.es336.js +6 -2
  118. package/dist/index.es337.js +34 -2
  119. package/dist/index.es338.js +26 -6
  120. package/dist/index.es339.js +18 -34
  121. package/dist/index.es34.js +5 -5
  122. package/dist/index.es340.js +4 -25
  123. package/dist/index.es341.js +231 -18
  124. package/dist/index.es342.js +100 -5
  125. package/dist/index.es343.js +26 -229
  126. package/dist/index.es344.js +35 -80
  127. package/dist/index.es345.js +2 -28
  128. package/dist/index.es346.js +2 -55
  129. package/dist/index.es347.js +334 -2
  130. package/dist/index.es348.js +31 -106
  131. package/dist/index.es349.js +16 -75
  132. package/dist/index.es35.js +2 -2
  133. package/dist/index.es350.js +29 -35
  134. package/dist/index.es351.js +3 -64
  135. package/dist/index.es352.js +107 -34
  136. package/dist/index.es353.js +71 -60
  137. package/dist/index.es354.js +34 -111
  138. package/dist/index.es355.js +60 -90
  139. package/dist/index.es356.js +32 -41
  140. package/dist/index.es357.js +66 -3
  141. package/dist/index.es358.js +113 -3
  142. package/dist/index.es359.js +94 -3
  143. package/dist/index.es360.js +43 -3
  144. package/dist/index.es361.js +2 -2
  145. package/dist/index.es362.js +2 -2
  146. package/dist/index.es363.js +2 -2
  147. package/dist/index.es364.js +2 -2
  148. package/dist/index.es365.js +2 -2
  149. package/dist/index.es366.js +4 -241
  150. package/dist/index.es367.js +4 -384
  151. package/dist/index.es368.js +4 -169
  152. package/dist/index.es369.js +4 -153
  153. package/dist/index.es370.js +187 -88
  154. package/dist/index.es371.js +384 -4
  155. package/dist/index.es372.js +169 -4
  156. package/dist/index.es373.js +153 -4
  157. package/dist/index.es374.js +142 -4
  158. package/dist/index.es375.js +2 -2
  159. package/dist/index.es376.js +2 -2
  160. package/dist/index.es377.js +2 -334
  161. package/dist/index.es378.js +2 -31
  162. package/dist/index.es379.js +2 -17
  163. package/dist/index.es38.js +51 -46
  164. package/dist/index.es380.js +2 -29
  165. package/dist/index.es381.js +2 -2
  166. package/dist/index.es382.js +1 -1
  167. package/dist/index.es384.js +1 -1
  168. package/dist/index.es385.js +1 -1
  169. package/dist/index.es39.js +2 -2
  170. package/dist/index.es394.js +68 -5
  171. package/dist/index.es395.js +31 -3
  172. package/dist/index.es396.js +16 -24
  173. package/dist/index.es397.js +141 -110
  174. package/dist/index.es398.js +113 -15
  175. package/dist/index.es399.js +5 -6
  176. package/dist/index.es40.js +3 -3
  177. package/dist/index.es400.js +3 -2
  178. package/dist/index.es401.js +23 -7
  179. package/dist/index.es402.js +108 -325
  180. package/dist/index.es403.js +15 -49
  181. package/dist/index.es404.js +518 -3
  182. package/dist/index.es405.js +113 -505
  183. package/dist/index.es406.js +120 -121
  184. package/dist/index.es407.js +5 -125
  185. package/dist/index.es408.js +2 -68
  186. package/dist/index.es409.js +8 -31
  187. package/dist/index.es41.js +1 -1
  188. package/dist/index.es410.js +327 -16
  189. package/dist/index.es411.js +48 -139
  190. package/dist/index.es412.js +4 -114
  191. package/dist/index.es416.js +1 -1
  192. package/dist/index.es418.js +1 -1
  193. package/dist/index.es419.js +4 -4
  194. package/dist/index.es42.js +1 -1
  195. package/dist/index.es437.js +21 -271
  196. package/dist/index.es438.js +10 -79
  197. package/dist/index.es439.js +31 -164
  198. package/dist/index.es44.js +1 -1
  199. package/dist/index.es440.js +29 -24
  200. package/dist/index.es441.js +11 -10
  201. package/dist/index.es442.js +274 -32
  202. package/dist/index.es443.js +79 -29
  203. package/dist/index.es444.js +165 -11
  204. package/dist/index.es448.js +2 -2
  205. package/dist/index.es45.js +1 -1
  206. package/dist/index.es454.js +1 -1
  207. package/dist/index.es455.js +1 -1
  208. package/dist/index.es461.js +1 -1
  209. package/dist/index.es476.js +1 -1
  210. package/dist/index.es477.js +1 -1
  211. package/dist/index.es50.js +2 -2
  212. package/dist/index.es51.js +1 -1
  213. package/dist/index.es52.js +4 -4
  214. package/dist/index.es55.js +1 -1
  215. package/dist/index.es56.js +1 -1
  216. package/dist/index.es57.js +2 -2
  217. package/dist/index.es59.js +2 -2
  218. package/dist/index.es62.js +1 -1
  219. package/dist/index.es63.js +1 -1
  220. package/dist/index.es65.js +2 -2
  221. package/dist/index.es66.js +2 -2
  222. package/dist/index.es754.js +13 -21
  223. package/dist/index.es755.js +18 -79
  224. package/dist/index.es756.js +82 -13
  225. package/dist/index.es757.js +14 -2
  226. package/dist/index.es758.js +60 -2
  227. package/dist/index.es759.js +2 -14
  228. package/dist/index.es760.js +2 -60
  229. package/dist/index.es768.js +2 -5
  230. package/dist/index.es769.js +2 -17
  231. package/dist/index.es770.js +5 -2
  232. package/dist/index.es771.js +17 -2
  233. package/dist/index.es772.js +1 -1
  234. package/dist/index.es773.js +2 -2
  235. package/dist/index.es78.js +1 -1
  236. package/dist/index.es781.js +1 -1
  237. package/dist/index.es784.js +1 -1
  238. package/dist/index.es787.js +56 -26
  239. package/dist/index.es788.js +10 -3
  240. package/dist/index.es789.js +14 -57
  241. package/dist/index.es79.js +1 -1
  242. package/dist/index.es790.js +3 -6
  243. package/dist/index.es791.js +28 -15
  244. package/dist/index.es792.js +3 -7
  245. package/dist/index.es808.js +1 -1
  246. package/dist/index.es811.js +5 -5
  247. package/dist/index.es812.js +2 -2
  248. package/dist/index.es813.js +1 -1
  249. package/dist/index.es815.js +2 -2
  250. package/dist/index.es827.js +64 -15
  251. package/dist/index.es828.js +11 -7
  252. package/dist/index.es829.js +38 -61
  253. package/dist/index.es830.js +54 -7
  254. package/dist/index.es831.js +16 -40
  255. package/dist/index.es832.js +17 -57
  256. package/dist/index.es833.js +7 -20
  257. package/dist/index.es834.js +1 -1
  258. package/dist/index.es86.js +55 -33
  259. package/dist/index.es87.js +53 -44
  260. package/dist/index.es88.js +89 -29
  261. package/dist/index.es89.js +37 -30
  262. package/dist/index.es90.js +24 -9
  263. package/dist/index.es91.js +30 -55
  264. package/dist/index.es92.js +31 -53
  265. package/dist/index.es93.js +46 -90
  266. package/dist/index.es94.js +29 -36
  267. package/dist/index.es95.js +29 -23
  268. package/dist/index.es96.js +9 -30
  269. package/dist/index.es97.js +12 -259
  270. package/dist/index.es98.js +1062 -12
  271. package/dist/index.es99.js +2 -2
  272. package/package.json +1 -1
@@ -1,465 +1,31 @@
1
- import * as T from "./index.es265.js";
2
- import { access as p, identifyNull as D, getInsertParentId as R, getInsertIndex as O, isDescendant as C, dfs as P, walk as x, waitFor as A } from "./index.es265.js";
3
- import { DefaultCursor as E } from "./index.es266.js";
4
- import { DefaultRow as M } from "./index.es267.js";
5
- import { DefaultNode as B } from "./index.es268.js";
6
- import { edit as m } from "./index.es269.js";
7
- import { focus as u, treeBlur as L } from "./index.es270.js";
8
- import { createRoot as I, ROOT_ID as k } from "./index.es263.js";
9
- import { actions as b } from "./index.es271.js";
10
- import { actions as d } from "./index.es272.js";
11
- import { actions as w } from "./index.es273.js";
12
- import { DefaultDragPreview as z } from "./index.es274.js";
13
- import { DefaultContainer as $ } from "./index.es275.js";
14
- import { createList as _ } from "./index.es276.js";
15
- import { createIndex as S } from "./index.es277.js";
16
- var N = function(y, t, e, s) {
17
- function i(n) {
18
- return n instanceof e ? n : new e(function(r) {
19
- r(n);
20
- });
1
+ const s = {
2
+ open(e, r) {
3
+ return { type: "VISIBILITY_OPEN", id: e, filtered: r };
4
+ },
5
+ close(e, r) {
6
+ return { type: "VISIBILITY_CLOSE", id: e, filtered: r };
7
+ },
8
+ toggle(e, r) {
9
+ return { type: "VISIBILITY_TOGGLE", id: e, filtered: r };
10
+ },
11
+ clear(e) {
12
+ return { type: "VISIBILITY_CLEAR", filtered: e };
21
13
  }
22
- return new (e || (e = Promise))(function(n, r) {
23
- function h(c) {
24
- try {
25
- g(s.next(c));
26
- } catch (v) {
27
- r(v);
28
- }
29
- }
30
- function F(c) {
31
- try {
32
- g(s.throw(c));
33
- } catch (v) {
34
- r(v);
35
- }
36
- }
37
- function g(c) {
38
- c.done ? n(c.value) : i(c.value).then(h, F);
39
- }
40
- g((s = s.apply(y, t || [])).next());
41
- });
42
14
  };
43
- const { safeRun: o, identify: a, identifyNull: l } = T;
44
- class f {
45
- constructor(t, e, s, i) {
46
- this.store = t, this.props = e, this.list = s, this.listEl = i, this.visibleStartIndex = 0, this.visibleStopIndex = 0, this.root = I(this), this.visibleNodes = _(this), this.idToIndex = S(this.visibleNodes);
47
- }
48
- /* Changes here must also be made in constructor() */
49
- update(t) {
50
- this.props = t, this.root = I(this), this.visibleNodes = _(this), this.idToIndex = S(this.visibleNodes);
51
- }
52
- /* Store helpers */
53
- dispatch(t) {
54
- return this.store.dispatch(t);
55
- }
56
- get state() {
57
- return this.store.getState();
58
- }
59
- get openState() {
60
- return this.state.nodes.open.unfiltered;
61
- }
62
- /* Tree Props */
63
- get width() {
64
- var t;
65
- return (t = this.props.width) !== null && t !== void 0 ? t : 300;
66
- }
67
- get height() {
68
- var t;
69
- return (t = this.props.height) !== null && t !== void 0 ? t : 500;
70
- }
71
- get indent() {
72
- var t;
73
- return (t = this.props.indent) !== null && t !== void 0 ? t : 24;
74
- }
75
- get rowHeight() {
76
- var t;
77
- return (t = this.props.rowHeight) !== null && t !== void 0 ? t : 24;
78
- }
79
- get overscanCount() {
80
- var t;
81
- return (t = this.props.overscanCount) !== null && t !== void 0 ? t : 1;
82
- }
83
- get searchTerm() {
84
- return (this.props.searchTerm || "").trim();
85
- }
86
- get matchFn() {
87
- var t;
88
- const e = (t = this.props.searchMatch) !== null && t !== void 0 ? t : (s, i) => JSON.stringify(Object.values(s.data)).toLocaleLowerCase().includes(i.toLocaleLowerCase());
89
- return (s) => e(s, this.searchTerm);
90
- }
91
- accessChildren(t) {
92
- var e;
93
- const s = this.props.childrenAccessor || "children";
94
- return (e = p(t, s)) !== null && e !== void 0 ? e : null;
95
- }
96
- accessId(t) {
97
- const e = this.props.idAccessor || "id", s = p(t, e);
98
- if (!s)
99
- throw new Error("Data must contain an 'id' property or props.idAccessor must return a string");
100
- return s;
101
- }
102
- /* Node Access */
103
- get firstNode() {
104
- var t;
105
- return (t = this.visibleNodes[0]) !== null && t !== void 0 ? t : null;
106
- }
107
- get lastNode() {
108
- var t;
109
- return (t = this.visibleNodes[this.visibleNodes.length - 1]) !== null && t !== void 0 ? t : null;
110
- }
111
- get focusedNode() {
112
- var t;
113
- return (t = this.get(this.state.nodes.focus.id)) !== null && t !== void 0 ? t : null;
114
- }
115
- get mostRecentNode() {
116
- var t;
117
- return (t = this.get(this.state.nodes.selection.mostRecent)) !== null && t !== void 0 ? t : null;
118
- }
119
- get nextNode() {
120
- const t = this.indexOf(this.focusedNode);
121
- return t === null ? null : this.at(t + 1);
122
- }
123
- get prevNode() {
124
- const t = this.indexOf(this.focusedNode);
125
- return t === null ? null : this.at(t - 1);
126
- }
127
- get(t) {
128
- return t && t in this.idToIndex && this.visibleNodes[this.idToIndex[t]] || null;
129
- }
130
- at(t) {
131
- return this.visibleNodes[t] || null;
132
- }
133
- nodesBetween(t, e) {
134
- var s;
135
- if (t === null || e === null)
136
- return [];
137
- const i = (s = this.indexOf(t)) !== null && s !== void 0 ? s : 0, n = this.indexOf(e);
138
- if (n === null)
139
- return [];
140
- const r = Math.min(i, n), h = Math.max(i, n);
141
- return this.visibleNodes.slice(r, h + 1);
142
- }
143
- indexOf(t) {
144
- const e = D(t);
145
- return e ? this.idToIndex[e] : null;
146
- }
147
- /* Data Operations */
148
- get editingId() {
149
- return this.state.nodes.edit.id;
150
- }
151
- createInternal() {
152
- return this.create({ type: "internal" });
153
- }
154
- createLeaf() {
155
- return this.create({ type: "leaf" });
156
- }
157
- create(t = {}) {
158
- var e, s;
159
- return N(this, void 0, void 0, function* () {
160
- const i = t.parentId === void 0 ? R(this) : t.parentId, n = (e = t.index) !== null && e !== void 0 ? e : O(this), r = (s = t.type) !== null && s !== void 0 ? s : "leaf", h = yield o(this.props.onCreate, {
161
- type: r,
162
- parentId: i,
163
- index: n,
164
- parentNode: this.get(i)
165
- });
166
- h && (this.focus(h), setTimeout(() => {
167
- this.edit(h).then(() => {
168
- this.select(h), this.activate(h);
169
- });
170
- }));
171
- });
172
- }
173
- delete(t) {
174
- return N(this, void 0, void 0, function* () {
175
- if (!t)
176
- return;
177
- const s = (Array.isArray(t) ? t : [t]).map(a), i = s.map((n) => this.get(n)).filter((n) => !!n);
178
- yield o(this.props.onDelete, { nodes: i, ids: s });
179
- });
180
- }
181
- edit(t) {
182
- const e = a(t);
183
- return this.resolveEdit({ cancelled: !0 }), this.scrollTo(e), this.dispatch(m(e)), new Promise((s) => {
184
- f.editPromise = s;
185
- });
186
- }
187
- submit(t, e) {
188
- return N(this, void 0, void 0, function* () {
189
- if (!t)
190
- return;
191
- const s = a(t);
192
- yield o(this.props.onRename, {
193
- id: s,
194
- name: e,
195
- node: this.get(s)
196
- }), this.dispatch(m(null)), this.resolveEdit({ cancelled: !1, value: e }), setTimeout(() => this.onFocus());
197
- });
198
- }
199
- reset() {
200
- this.dispatch(m(null)), this.resolveEdit({ cancelled: !0 }), setTimeout(() => this.onFocus());
201
- }
202
- activate(t) {
203
- const e = this.get(l(t));
204
- e && o(this.props.onActivate, e);
205
- }
206
- resolveEdit(t) {
207
- const e = f.editPromise;
208
- e && e(t), f.editPromise = null;
209
- }
210
- /* Focus and Selection */
211
- get selectedIds() {
212
- return this.state.nodes.selection.ids;
213
- }
214
- get selectedNodes() {
215
- let t = [];
216
- for (let e of Array.from(this.selectedIds)) {
217
- const s = this.get(e);
218
- s && t.push(s);
219
- }
220
- return t;
221
- }
222
- focus(t, e = {}) {
223
- t && (this.props.selectionFollowsFocus ? this.select(t) : (this.dispatch(u(a(t))), e.scroll !== !1 && this.scrollTo(t), this.focusedNode && o(this.props.onFocus, this.focusedNode)));
224
- }
225
- pageUp() {
226
- var t, e;
227
- const s = this.visibleStartIndex, n = this.visibleStopIndex - s;
228
- let r = (e = (t = this.focusedNode) === null || t === void 0 ? void 0 : t.rowIndex) !== null && e !== void 0 ? e : 0;
229
- r > s ? r = s : r = Math.max(s - n, 0), this.focus(this.at(r));
230
- }
231
- pageDown() {
232
- var t, e;
233
- const s = this.visibleStartIndex, i = this.visibleStopIndex, n = i - s;
234
- let r = (e = (t = this.focusedNode) === null || t === void 0 ? void 0 : t.rowIndex) !== null && e !== void 0 ? e : 0;
235
- r < i ? r = i : r = Math.min(r + n, this.visibleNodes.length - 1), this.focus(this.at(r));
236
- }
237
- select(t, e = {}) {
238
- if (!t)
239
- return;
240
- const s = e.focus !== !1, i = a(t);
241
- s && this.dispatch(u(i)), this.dispatch(d.only(i)), this.dispatch(d.anchor(i)), this.dispatch(d.mostRecent(i)), this.scrollTo(i, e.align), this.focusedNode && s && o(this.props.onFocus, this.focusedNode), o(this.props.onSelect, this.selectedNodes);
242
- }
243
- deselect(t) {
244
- if (!t)
245
- return;
246
- const e = a(t);
247
- this.dispatch(d.remove(e));
248
- }
249
- selectMulti(t) {
250
- const e = this.get(l(t));
251
- e && (this.dispatch(u(e.id)), this.dispatch(d.add(e.id)), this.dispatch(d.anchor(e.id)), this.dispatch(d.mostRecent(e.id)), this.scrollTo(e), this.focusedNode && o(this.props.onFocus, this.focusedNode), o(this.props.onSelect, this.selectedNodes));
252
- }
253
- selectContiguous(t) {
254
- if (!t)
255
- return;
256
- const e = a(t), { anchor: s, mostRecent: i } = this.state.nodes.selection;
257
- this.dispatch(u(e)), this.dispatch(d.remove(this.nodesBetween(s, i))), this.dispatch(d.add(this.nodesBetween(s, l(e)))), this.dispatch(d.mostRecent(e)), this.scrollTo(e), this.focusedNode && o(this.props.onFocus, this.focusedNode), o(this.props.onSelect, this.selectedNodes);
258
- }
259
- deselectAll() {
260
- this.setSelection({ ids: [], anchor: null, mostRecent: null }), o(this.props.onSelect, this.selectedNodes);
261
- }
262
- selectAll() {
263
- var t;
264
- this.setSelection({
265
- ids: Object.keys(this.idToIndex),
266
- anchor: this.firstNode,
267
- mostRecent: this.lastNode
268
- }), this.dispatch(u((t = this.lastNode) === null || t === void 0 ? void 0 : t.id)), this.focusedNode && o(this.props.onFocus, this.focusedNode), o(this.props.onSelect, this.selectedNodes);
269
- }
270
- setSelection(t) {
271
- var e;
272
- const s = new Set((e = t.ids) === null || e === void 0 ? void 0 : e.map(a)), i = l(t.anchor), n = l(t.mostRecent);
273
- this.dispatch(d.set({ ids: s, anchor: i, mostRecent: n })), o(this.props.onSelect, this.selectedNodes);
274
- }
275
- /* Drag and Drop */
276
- get cursorParentId() {
277
- const { cursor: t } = this.state.dnd;
278
- switch (t.type) {
279
- case "highlight":
280
- return t.id;
281
- default:
282
- return null;
283
- }
284
- }
285
- get cursorOverFolder() {
286
- return this.state.dnd.cursor.type === "highlight";
287
- }
288
- get dragNodes() {
289
- return this.state.dnd.dragIds.map((t) => this.get(t)).filter((t) => !!t);
290
- }
291
- get dragNode() {
292
- return this.get(this.state.nodes.drag.id);
293
- }
294
- get dragDestinationParent() {
295
- return this.get(this.state.nodes.drag.destinationParentId);
296
- }
297
- get dragDestinationIndex() {
298
- return this.state.nodes.drag.destinationIndex;
299
- }
300
- canDrop() {
301
- var t;
302
- if (this.isFiltered)
303
- return !1;
304
- const e = (t = this.get(this.state.dnd.parentId)) !== null && t !== void 0 ? t : this.root, s = this.dragNodes, i = this.props.disableDrop;
305
- for (const n of s)
306
- if (!n || !e || n.isInternal && C(e, n))
307
- return !1;
308
- return typeof i == "function" ? !i({
309
- parentNode: e,
310
- dragNodes: this.dragNodes,
311
- index: this.state.dnd.index || 0
312
- }) : typeof i == "string" ? !e.data[i] : typeof i == "boolean" ? !i : !0;
313
- }
314
- hideCursor() {
315
- this.dispatch(w.cursor({ type: "none" }));
316
- }
317
- showCursor(t) {
318
- this.dispatch(w.cursor(t));
319
- }
320
- /* Visibility */
321
- open(t) {
322
- const e = l(t);
323
- e && (this.isOpen(e) || (this.dispatch(b.open(e, this.isFiltered)), o(this.props.onToggle, e)));
324
- }
325
- close(t) {
326
- const e = l(t);
327
- e && this.isOpen(e) && (this.dispatch(b.close(e, this.isFiltered)), o(this.props.onToggle, e));
328
- }
329
- toggle(t) {
330
- const e = l(t);
331
- if (e)
332
- return this.isOpen(e) ? this.close(e) : this.open(e);
333
- }
334
- openParents(t) {
335
- const e = l(t);
336
- if (!e)
337
- return;
338
- const s = P(this.root, e);
339
- let i = s == null ? void 0 : s.parent;
340
- for (; i; )
341
- this.open(i.id), i = i.parent;
342
- }
343
- openSiblings(t) {
344
- const e = t.parent;
345
- if (!e)
346
- this.toggle(t.id);
347
- else if (e.children) {
348
- const s = t.isOpen;
349
- for (let i of e.children)
350
- i.isInternal && (s ? this.close(i.id) : this.open(i.id));
351
- this.scrollTo(this.focusedNode);
352
- }
353
- }
354
- openAll() {
355
- x(this.root, (t) => {
356
- t.isInternal && t.open();
357
- });
358
- }
359
- closeAll() {
360
- x(this.root, (t) => {
361
- t.isInternal && t.close();
362
- });
363
- }
364
- /* Scrolling */
365
- scrollTo(t, e = "smart") {
366
- if (!t)
367
- return;
368
- const s = a(t);
369
- return this.openParents(s), A(() => s in this.idToIndex).then(() => {
370
- var i;
371
- const n = this.idToIndex[s];
372
- n !== void 0 && ((i = this.list.current) === null || i === void 0 || i.scrollToItem(n, e));
373
- }).catch(() => {
374
- });
375
- }
376
- /* State Checks */
377
- get isEditing() {
378
- return this.state.nodes.edit.id !== null;
379
- }
380
- get isFiltered() {
381
- var t;
382
- return !!(!((t = this.props.searchTerm) === null || t === void 0) && t.trim());
383
- }
384
- get hasFocus() {
385
- return this.state.nodes.focus.treeFocused;
386
- }
387
- get hasNoSelection() {
388
- return this.state.nodes.selection.ids.size === 0;
389
- }
390
- get hasOneSelection() {
391
- return this.state.nodes.selection.ids.size === 1;
392
- }
393
- get hasMultipleSelections() {
394
- return this.state.nodes.selection.ids.size > 1;
395
- }
396
- isSelected(t) {
397
- return t ? this.state.nodes.selection.ids.has(t) : !1;
398
- }
399
- isOpen(t) {
400
- var e, s, i;
401
- if (!t)
402
- return !1;
403
- if (t === k)
404
- return !0;
405
- const n = (e = this.props.openByDefault) !== null && e !== void 0 ? e : !0;
406
- return this.isFiltered ? (s = this.state.nodes.open.filtered[t]) !== null && s !== void 0 ? s : !0 : (i = this.state.nodes.open.unfiltered[t]) !== null && i !== void 0 ? i : n;
407
- }
408
- isEditable(t) {
409
- var e;
410
- const s = this.props.disableEdit || (() => !1);
411
- return (e = !p(t, s)) !== null && e !== void 0 ? e : !0;
412
- }
413
- isDraggable(t) {
414
- var e;
415
- const s = this.props.disableDrag || (() => !1);
416
- return (e = !p(t, s)) !== null && e !== void 0 ? e : !0;
417
- }
418
- isDragging(t) {
419
- const e = l(t);
420
- return e ? this.state.nodes.drag.id === e : !1;
421
- }
422
- isFocused(t) {
423
- return this.hasFocus && this.state.nodes.focus.id === t;
424
- }
425
- isMatch(t) {
426
- return this.matchFn(t);
427
- }
428
- willReceiveDrop(t) {
429
- const e = l(t);
430
- if (!e)
431
- return !1;
432
- const { destinationParentId: s, destinationIndex: i } = this.state.nodes.drag;
433
- return e === s && i === null;
434
- }
435
- /* Tree Event Handlers */
436
- onFocus() {
437
- const t = this.focusedNode || this.firstNode;
438
- t && this.dispatch(u(t.id));
439
- }
440
- onBlur() {
441
- this.dispatch(L());
442
- }
443
- onItemsRendered(t) {
444
- this.visibleStartIndex = t.visibleStartIndex, this.visibleStopIndex = t.visibleStopIndex;
445
- }
446
- /* Get Renderers */
447
- get renderContainer() {
448
- return this.props.renderContainer || $;
449
- }
450
- get renderRow() {
451
- return this.props.renderRow || M;
452
- }
453
- get renderNode() {
454
- return this.props.children || B;
455
- }
456
- get renderDragPreview() {
457
- return this.props.renderDragPreview || z;
458
- }
459
- get renderCursor() {
460
- return this.props.renderCursor || E;
461
- }
15
+ function I(e = {}, r) {
16
+ if (r.type === "VISIBILITY_OPEN")
17
+ return Object.assign(Object.assign({}, e), { [r.id]: !0 });
18
+ if (r.type === "VISIBILITY_CLOSE")
19
+ return Object.assign(Object.assign({}, e), { [r.id]: !1 });
20
+ if (r.type === "VISIBILITY_TOGGLE") {
21
+ const n = e[r.id];
22
+ return Object.assign(Object.assign({}, e), { [r.id]: !n });
23
+ } else return r.type === "VISIBILITY_CLEAR" ? {} : e;
24
+ }
25
+ function t(e = { filtered: {}, unfiltered: {} }, r) {
26
+ return r.type.startsWith("VISIBILITY") ? r.filtered ? Object.assign(Object.assign({}, e), { filtered: I(e.filtered, r) }) : Object.assign(Object.assign({}, e), { unfiltered: I(e.unfiltered, r) }) : e;
462
27
  }
463
28
  export {
464
- f as TreeApi
29
+ s as actions,
30
+ t as reducer
465
31
  };
@@ -1,134 +1,51 @@
1
- function d(n, t, e) {
2
- return Math.max(Math.min(n, e), t);
3
- }
4
- function a(n) {
5
- return n && n.isLeaf;
6
- }
7
- function h(n) {
8
- return n && n.isInternal && !n.isOpen;
9
- }
10
- function p(n) {
11
- var t;
12
- return n && n.isOpen && !(!((t = n.children) === null || t === void 0) && t.length);
13
- }
14
- const m = (n, t) => {
15
- let e = n;
16
- for (; e; ) {
17
- if (e.id === t.id)
18
- return !0;
19
- e = e.parent;
20
- }
21
- return !1;
22
- }, v = (n) => {
23
- if (!n.parent)
24
- throw Error("Node does not have a parent");
25
- return n.parent.children.findIndex((t) => t.id === n.id);
1
+ import { identify as n } from "./index.es258.js";
2
+ import { initialState as O } from "./index.es338.js";
3
+ const c = {
4
+ clear: () => ({ type: "SELECTION_CLEAR" }),
5
+ only: (e) => ({
6
+ type: "SELECTION_ONLY",
7
+ id: n(e)
8
+ }),
9
+ add: (e) => ({
10
+ type: "SELECTION_ADD",
11
+ ids: (Array.isArray(e) ? e : [e]).map(n)
12
+ }),
13
+ remove: (e) => ({
14
+ type: "SELECTION_REMOVE",
15
+ ids: (Array.isArray(e) ? e : [e]).map(n)
16
+ }),
17
+ set: (e) => Object.assign({ type: "SELECTION_SET" }, e),
18
+ mostRecent: (e) => ({
19
+ type: "SELECTION_MOST_RECENT",
20
+ id: e === null ? null : n(e)
21
+ }),
22
+ anchor: (e) => ({
23
+ type: "SELECTION_ANCHOR",
24
+ id: e === null ? null : n(e)
25
+ })
26
26
  };
27
- function b() {
28
- }
29
- function l(n, t) {
30
- if (!n)
31
- return null;
32
- if (n.id === t)
33
- return n;
34
- if (n.children)
35
- for (let e of n.children) {
36
- const i = l(e, t);
37
- if (i)
38
- return i;
39
- }
40
- return null;
41
- }
42
- function f(n, t) {
43
- if (t(n), n.children)
44
- for (let e of n.children)
45
- f(e, t);
46
- }
47
- function x(n) {
48
- const t = u(n);
49
- let e;
50
- for (let i = 0; i < t.length; ++i)
51
- if (t[i] === n) {
52
- e = o(t, i);
53
- break;
54
- }
55
- e == null || e.focus();
56
- }
57
- function y(n) {
58
- const t = u(n);
59
- let e;
60
- for (let i = 0; i < t.length; ++i)
61
- if (t[i] === n) {
62
- e = c(t, i);
63
- break;
64
- }
65
- e == null || e.focus();
66
- }
67
- function o(n, t) {
68
- return t + 1 < n.length ? n[t + 1] : n[0];
69
- }
70
- function c(n, t) {
71
- return t - 1 >= 0 ? n[t - 1] : n[n.length - 1];
72
- }
73
- function u(n) {
74
- return Array.from(document.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled]), details:not([disabled]), summary:not(:disabled)')).filter((t) => t === n || !n.contains(t));
75
- }
76
- function I(n, t) {
77
- return typeof t == "boolean" ? t : typeof t == "string" ? n[t] : t(n);
78
- }
79
- function g(n) {
80
- return n === null ? null : s(n);
81
- }
82
- function s(n) {
83
- return typeof n == "string" ? n : n.id;
84
- }
85
- function O(...n) {
86
- return (t) => {
87
- n.forEach((e) => {
88
- typeof e == "function" ? e(t) : e != null && (e.current = t);
89
- });
90
- };
91
- }
92
- function w(n, ...t) {
93
- if (n)
94
- return n(...t);
95
- }
96
- function E(n) {
97
- return new Promise((t, e) => {
98
- let i = 0;
99
- function r() {
100
- i += 1, i === 100 && e(), n() ? t() : setTimeout(r, 10);
101
- }
102
- r();
103
- });
104
- }
105
- function N(n) {
106
- var t, e;
107
- const i = n.focusedNode;
108
- return i ? i.isOpen ? 0 : i.parent ? i.childIndex + 1 : 0 : (e = (t = n.root.children) === null || t === void 0 ? void 0 : t.length) !== null && e !== void 0 ? e : 0;
109
- }
110
- function k(n) {
111
- const t = n.focusedNode;
112
- return t ? t.isOpen ? t.id : t.parent && !t.parent.isRoot ? t.parent.id : null : null;
27
+ function d(e = O().nodes.selection, s) {
28
+ const r = e.ids;
29
+ switch (s.type) {
30
+ case "SELECTION_CLEAR":
31
+ return Object.assign(Object.assign({}, e), { ids: /* @__PURE__ */ new Set() });
32
+ case "SELECTION_ONLY":
33
+ return Object.assign(Object.assign({}, e), { ids: /* @__PURE__ */ new Set([s.id]) });
34
+ case "SELECTION_ADD":
35
+ return s.ids.length === 0 ? e : (s.ids.forEach((E) => r.add(E)), Object.assign(Object.assign({}, e), { ids: new Set(r) }));
36
+ case "SELECTION_REMOVE":
37
+ return s.ids.length === 0 ? e : (s.ids.forEach((E) => r.delete(E)), Object.assign(Object.assign({}, e), { ids: new Set(r) }));
38
+ case "SELECTION_SET":
39
+ return Object.assign(Object.assign({}, e), { ids: s.ids, mostRecent: s.mostRecent, anchor: s.anchor });
40
+ case "SELECTION_MOST_RECENT":
41
+ return Object.assign(Object.assign({}, e), { mostRecent: s.id });
42
+ case "SELECTION_ANCHOR":
43
+ return Object.assign(Object.assign({}, e), { anchor: s.id });
44
+ default:
45
+ return e;
46
+ }
113
47
  }
114
48
  export {
115
- I as access,
116
- d as bound,
117
- l as dfs,
118
- x as focusNextElement,
119
- y as focusPrevElement,
120
- N as getInsertIndex,
121
- k as getInsertParentId,
122
- s as identify,
123
- g as identifyNull,
124
- v as indexOf,
125
- h as isClosed,
126
- m as isDescendant,
127
- a as isItem,
128
- p as isOpenWithEmptyChildren,
129
- O as mergeRefs,
130
- b as noop,
131
- w as safeRun,
132
- E as waitFor,
133
- f as walk
49
+ c as actions,
50
+ d as reducer
134
51
  };