react-arborist 3.2.0 → 3.3.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.
Files changed (213) hide show
  1. package/dist/main/components/cursor.d.ts +1 -0
  2. package/dist/main/components/cursor.js +20 -0
  3. package/dist/{components → main/components}/default-container.d.ts +1 -2
  4. package/dist/main/components/default-container.js +238 -0
  5. package/dist/main/components/default-cursor.js +35 -0
  6. package/dist/{components → main/components}/default-drag-preview.d.ts +1 -2
  7. package/dist/main/components/default-drag-preview.js +57 -0
  8. package/dist/{components → main/components}/default-node.d.ts +1 -2
  9. package/dist/main/components/default-node.js +32 -0
  10. package/dist/{components → main/components}/default-row.d.ts +1 -2
  11. package/dist/main/components/default-row.js +8 -0
  12. package/dist/main/components/drag-preview-container.d.ts +1 -0
  13. package/dist/main/components/drag-preview-container.js +21 -0
  14. package/dist/{components → main/components}/list-inner-element.d.ts +1 -1
  15. package/dist/main/components/list-inner-element.js +25 -0
  16. package/dist/main/components/list-outer-element.d.ts +2 -0
  17. package/dist/main/components/list-outer-element.js +38 -0
  18. package/dist/main/components/outer-drop.js +9 -0
  19. package/dist/{components → main/components}/provider.d.ts +2 -2
  20. package/dist/main/components/provider.js +52 -0
  21. package/dist/{components → main/components}/row-container.d.ts +2 -2
  22. package/dist/main/components/row-container.js +84 -0
  23. package/dist/main/components/tree-container.d.ts +1 -0
  24. package/dist/main/components/tree-container.js +12 -0
  25. package/dist/{components → main/components}/tree.d.ts +1 -1
  26. package/dist/main/components/tree.js +15 -0
  27. package/dist/{context.d.ts → main/context.d.ts} +4 -4
  28. package/dist/main/context.js +33 -0
  29. package/dist/main/data/create-index.js +10 -0
  30. package/dist/main/data/create-list.js +62 -0
  31. package/dist/main/data/create-root.js +43 -0
  32. package/dist/main/data/make-tree.d.ts +5 -0
  33. package/dist/main/data/make-tree.js +40 -0
  34. package/dist/{data → main/data}/simple-tree.d.ts +1 -1
  35. package/dist/main/data/simple-tree.js +100 -0
  36. package/dist/{dnd → main/dnd}/compute-drop.d.ts +6 -6
  37. package/dist/main/dnd/compute-drop.js +129 -0
  38. package/dist/main/dnd/drag-hook.js +46 -0
  39. package/dist/{dnd → main/dnd}/drop-hook.d.ts +2 -2
  40. package/dist/main/dnd/drop-hook.js +42 -0
  41. package/dist/main/dnd/measure-hover.d.ts +8 -0
  42. package/dist/main/dnd/measure-hover.js +21 -0
  43. package/dist/main/dnd/outer-drop-hook.js +45 -0
  44. package/dist/main/hooks/use-fresh-node.js +18 -0
  45. package/dist/{hooks → main/hooks}/use-simple-tree.d.ts +1 -1
  46. package/dist/main/hooks/use-simple-tree.js +35 -0
  47. package/dist/main/hooks/use-validated-props.js +29 -0
  48. package/dist/main/index.js +27 -0
  49. package/dist/{interfaces → main/interfaces}/node-api.d.ts +2 -1
  50. package/dist/main/interfaces/node-api.js +164 -0
  51. package/dist/{interfaces → main/interfaces}/tree-api.d.ts +90 -7
  52. package/dist/main/interfaces/tree-api.js +649 -0
  53. package/dist/main/interfaces/tree-api.test.d.ts +1 -0
  54. package/dist/main/interfaces/tree-api.test.js +14 -0
  55. package/dist/{state → main/state}/dnd-slice.d.ts +4 -4
  56. package/dist/main/state/dnd-slice.js +35 -0
  57. package/dist/{state → main/state}/drag-slice.d.ts +4 -2
  58. package/dist/main/state/drag-slice.js +24 -0
  59. package/dist/{state → main/state}/edit-slice.d.ts +1 -1
  60. package/dist/main/state/edit-slice.js +18 -0
  61. package/dist/{state → main/state}/focus-slice.d.ts +1 -1
  62. package/dist/main/state/focus-slice.js +26 -0
  63. package/dist/main/state/initial.js +29 -0
  64. package/dist/{state → main/state}/open-slice.d.ts +2 -2
  65. package/dist/main/state/open-slice.js +48 -0
  66. package/dist/main/state/root-reducer.d.ts +96 -0
  67. package/dist/main/state/root-reducer.js +20 -0
  68. package/dist/{state → main/state}/selection-slice.d.ts +1 -1
  69. package/dist/main/state/selection-slice.js +59 -0
  70. package/dist/{types → main/types}/dnd.d.ts +2 -2
  71. package/dist/main/types/dnd.js +2 -0
  72. package/dist/{types → main/types}/handlers.d.ts +5 -5
  73. package/dist/main/types/handlers.js +2 -0
  74. package/dist/{types → main/types}/renderers.d.ts +4 -4
  75. package/dist/main/types/renderers.js +2 -0
  76. package/dist/main/types/state.d.ts +2 -0
  77. package/dist/main/types/state.js +2 -0
  78. package/dist/main/types/tree-props.js +2 -0
  79. package/dist/{types → main/types}/utils.d.ts +5 -5
  80. package/dist/main/types/utils.js +2 -0
  81. package/dist/{utils.d.ts → main/utils.d.ts} +2 -2
  82. package/dist/main/utils.js +183 -0
  83. package/dist/module/components/cursor.d.ts +1 -0
  84. package/dist/module/components/cursor.js +16 -0
  85. package/dist/module/components/default-container.d.ts +6 -0
  86. package/dist/module/components/default-container.js +234 -0
  87. package/dist/module/components/default-cursor.d.ts +3 -0
  88. package/dist/module/components/default-cursor.js +29 -0
  89. package/dist/module/components/default-drag-preview.d.ts +2 -0
  90. package/dist/module/components/default-drag-preview.js +53 -0
  91. package/dist/module/components/default-node.d.ts +2 -0
  92. package/dist/module/components/default-node.js +28 -0
  93. package/dist/module/components/default-row.d.ts +2 -0
  94. package/dist/module/components/default-row.js +4 -0
  95. package/dist/module/components/drag-preview-container.d.ts +1 -0
  96. package/dist/module/components/drag-preview-container.js +17 -0
  97. package/dist/module/components/list-inner-element.d.ts +2 -0
  98. package/dist/module/components/list-inner-element.js +22 -0
  99. package/dist/module/components/list-outer-element.d.ts +2 -0
  100. package/dist/module/components/list-outer-element.js +35 -0
  101. package/dist/module/components/outer-drop.d.ts +4 -0
  102. package/dist/module/components/outer-drop.js +5 -0
  103. package/dist/module/components/provider.d.ts +10 -0
  104. package/dist/module/components/provider.js +48 -0
  105. package/dist/module/components/row-container.d.ts +7 -0
  106. package/dist/module/components/row-container.js +58 -0
  107. package/dist/module/components/tree-container.d.ts +1 -0
  108. package/dist/module/components/tree-container.js +8 -0
  109. package/dist/module/components/tree.d.ts +8 -0
  110. package/dist/module/components/tree.js +12 -0
  111. package/dist/module/context.d.ts +22 -0
  112. package/dist/module/context.js +26 -0
  113. package/dist/module/data/create-index.d.ts +4 -0
  114. package/dist/module/data/create-index.js +6 -0
  115. package/dist/module/data/create-list.d.ts +3 -0
  116. package/dist/module/data/create-list.js +58 -0
  117. package/dist/module/data/create-root.d.ts +4 -0
  118. package/dist/module/data/create-root.js +39 -0
  119. package/dist/module/data/make-tree.d.ts +5 -0
  120. package/dist/module/data/make-tree.js +36 -0
  121. package/dist/module/data/simple-tree.d.ts +44 -0
  122. package/dist/module/data/simple-tree.js +96 -0
  123. package/dist/module/dnd/compute-drop.d.ts +37 -0
  124. package/dist/module/dnd/compute-drop.js +125 -0
  125. package/dist/module/dnd/drag-hook.d.ts +3 -0
  126. package/dist/module/dnd/drag-hook.js +42 -0
  127. package/dist/module/dnd/drop-hook.d.ts +8 -0
  128. package/dist/module/dnd/drop-hook.js +38 -0
  129. package/dist/module/dnd/measure-hover.d.ts +8 -0
  130. package/dist/module/dnd/measure-hover.js +17 -0
  131. package/dist/module/dnd/outer-drop-hook.d.ts +1 -0
  132. package/dist/module/dnd/outer-drop-hook.js +41 -0
  133. package/dist/module/hooks/use-fresh-node.d.ts +1 -0
  134. package/dist/module/hooks/use-fresh-node.js +14 -0
  135. package/dist/module/hooks/use-simple-tree.d.ts +12 -0
  136. package/dist/module/hooks/use-simple-tree.js +31 -0
  137. package/dist/module/hooks/use-validated-props.d.ts +2 -0
  138. package/dist/module/hooks/use-validated-props.js +25 -0
  139. package/dist/module/index.d.ts +8 -0
  140. package/dist/module/index.js +9 -0
  141. package/dist/module/interfaces/node-api.d.ts +71 -0
  142. package/dist/module/interfaces/node-api.js +160 -0
  143. package/dist/module/interfaces/tree-api.d.ts +214 -0
  144. package/dist/module/interfaces/tree-api.js +622 -0
  145. package/dist/module/interfaces/tree-api.test.d.ts +1 -0
  146. package/dist/module/interfaces/tree-api.test.js +12 -0
  147. package/dist/module/state/dnd-slice.d.ts +29 -0
  148. package/dist/module/state/dnd-slice.js +31 -0
  149. package/dist/module/state/drag-slice.d.ts +9 -0
  150. package/dist/module/state/drag-slice.js +20 -0
  151. package/dist/module/state/edit-slice.d.ts +8 -0
  152. package/dist/module/state/edit-slice.js +13 -0
  153. package/dist/module/state/focus-slice.d.ts +12 -0
  154. package/dist/module/state/focus-slice.js +20 -0
  155. package/dist/module/state/initial.d.ts +3 -0
  156. package/dist/module/state/initial.js +25 -0
  157. package/dist/module/state/open-slice.d.ts +30 -0
  158. package/dist/module/state/open-slice.js +44 -0
  159. package/dist/module/state/root-reducer.d.ts +96 -0
  160. package/dist/module/state/root-reducer.js +17 -0
  161. package/dist/module/state/selection-slice.d.ts +42 -0
  162. package/dist/module/state/selection-slice.js +55 -0
  163. package/dist/module/types/dnd.d.ts +8 -0
  164. package/dist/module/types/dnd.js +1 -0
  165. package/dist/module/types/handlers.d.ts +30 -0
  166. package/dist/module/types/handlers.js +1 -0
  167. package/dist/module/types/renderers.d.ts +29 -0
  168. package/dist/module/types/renderers.js +1 -0
  169. package/dist/module/types/state.d.ts +2 -0
  170. package/dist/module/types/state.js +1 -0
  171. package/dist/module/types/tree-props.d.ts +56 -0
  172. package/dist/module/types/tree-props.js +1 -0
  173. package/dist/module/types/utils.d.ts +17 -0
  174. package/dist/module/types/utils.js +1 -0
  175. package/dist/module/utils.d.ts +24 -0
  176. package/dist/module/utils.js +162 -0
  177. package/package.json +26 -25
  178. package/src/components/default-container.tsx +2 -0
  179. package/src/components/provider.tsx +3 -2
  180. package/src/components/row-container.tsx +1 -1
  181. package/src/dnd/compute-drop.ts +6 -3
  182. package/src/dnd/drag-hook.ts +1 -1
  183. package/src/dnd/drop-hook.ts +1 -1
  184. package/src/interfaces/node-api.ts +10 -0
  185. package/src/interfaces/tree-api.ts +16 -3
  186. package/src/state/dnd-slice.ts +2 -2
  187. package/src/state/drag-slice.ts +27 -11
  188. package/src/state/initial.ts +6 -1
  189. package/src/utils.ts +2 -2
  190. package/dist/components/cursor.d.ts +0 -2
  191. package/dist/components/drag-preview-container.d.ts +0 -2
  192. package/dist/components/list-outer-element.d.ts +0 -2
  193. package/dist/components/tree-container.d.ts +0 -2
  194. package/dist/index.js +0 -2414
  195. package/dist/index.js.map +0 -1
  196. package/dist/module.js +0 -2387
  197. package/dist/module.js.map +0 -1
  198. package/dist/state/root-reducer.d.ts +0 -13
  199. package/dist/types/state.d.ts +0 -2
  200. package/jest.config.js +0 -5
  201. package/tsconfig.json +0 -4
  202. /package/dist/{components → main/components}/default-cursor.d.ts +0 -0
  203. /package/dist/{components → main/components}/outer-drop.d.ts +0 -0
  204. /package/dist/{data → main/data}/create-index.d.ts +0 -0
  205. /package/dist/{data → main/data}/create-list.d.ts +0 -0
  206. /package/dist/{data → main/data}/create-root.d.ts +0 -0
  207. /package/dist/{dnd → main/dnd}/drag-hook.d.ts +0 -0
  208. /package/dist/{dnd → main/dnd}/outer-drop-hook.d.ts +0 -0
  209. /package/dist/{hooks → main/hooks}/use-fresh-node.d.ts +0 -0
  210. /package/dist/{hooks → main/hooks}/use-validated-props.d.ts +0 -0
  211. /package/dist/{index.d.ts → main/index.d.ts} +0 -0
  212. /package/dist/{state → main/state}/initial.d.ts +0 -0
  213. /package/dist/{types → main/types}/tree-props.d.ts +0 -0
@@ -0,0 +1,214 @@
1
+ import { EditResult } from "../types/handlers";
2
+ import { Identity, IdObj } from "../types/utils";
3
+ import { TreeProps } from "../types/tree-props";
4
+ import { MutableRefObject } from "react";
5
+ import { Align, FixedSizeList, ListOnItemsRenderedProps } from "react-window";
6
+ import { DefaultRow } from "../components/default-row";
7
+ import { DefaultNode } from "../components/default-node";
8
+ import { NodeApi } from "./node-api";
9
+ import { Actions, RootState } from "../state/root-reducer";
10
+ import { DefaultDragPreview } from "../components/default-drag-preview";
11
+ import { DefaultContainer } from "../components/default-container";
12
+ import { Cursor } from "../dnd/compute-drop";
13
+ import { Store } from "redux";
14
+ export declare class TreeApi<T> {
15
+ store: Store<RootState, Actions>;
16
+ props: TreeProps<T>;
17
+ list: MutableRefObject<FixedSizeList | null>;
18
+ listEl: MutableRefObject<HTMLDivElement | null>;
19
+ static editPromise: null | ((args: EditResult) => void);
20
+ root: NodeApi<T>;
21
+ visibleNodes: NodeApi<T>[];
22
+ visibleStartIndex: number;
23
+ visibleStopIndex: number;
24
+ idToIndex: {
25
+ [id: string]: number;
26
+ };
27
+ constructor(store: Store<RootState, Actions>, props: TreeProps<T>, list: MutableRefObject<FixedSizeList | null>, listEl: MutableRefObject<HTMLDivElement | null>);
28
+ update(props: TreeProps<T>): void;
29
+ dispatch(action: Actions): {
30
+ type: "FOCUS";
31
+ id: string | null;
32
+ } | {
33
+ readonly type: "TREE_BLUR";
34
+ } | {
35
+ type: "EDIT";
36
+ id: string | null;
37
+ } | import("../types/utils").ActionTypes<{
38
+ open(id: string, filtered: boolean): {
39
+ type: "VISIBILITY_OPEN";
40
+ id: string;
41
+ filtered: boolean;
42
+ };
43
+ close(id: string, filtered: boolean): {
44
+ type: "VISIBILITY_CLOSE";
45
+ id: string;
46
+ filtered: boolean;
47
+ };
48
+ toggle(id: string, filtered: boolean): {
49
+ type: "VISIBILITY_TOGGLE";
50
+ id: string;
51
+ filtered: boolean;
52
+ };
53
+ clear(filtered: boolean): {
54
+ type: "VISIBILITY_CLEAR";
55
+ filtered: boolean;
56
+ };
57
+ }> | import("../types/utils").ActionTypes<{
58
+ clear: () => {
59
+ type: "SELECTION_CLEAR";
60
+ };
61
+ only: (id: string | IdObj) => {
62
+ type: "SELECTION_ONLY";
63
+ id: string;
64
+ };
65
+ add: (id: string | IdObj | string[] | IdObj[]) => {
66
+ type: "SELECTION_ADD";
67
+ ids: string[];
68
+ };
69
+ remove: (id: string | IdObj | string[] | IdObj[]) => {
70
+ type: "SELECTION_REMOVE";
71
+ ids: string[];
72
+ };
73
+ set: (args: {
74
+ ids: Set<string>;
75
+ anchor: string | null;
76
+ mostRecent: string | null;
77
+ }) => {
78
+ ids: Set<string>;
79
+ anchor: string | null;
80
+ mostRecent: string | null;
81
+ type: "SELECTION_SET";
82
+ };
83
+ mostRecent: (id: string | IdObj | null) => {
84
+ type: "SELECTION_MOST_RECENT";
85
+ id: string | null;
86
+ };
87
+ anchor: (id: string | IdObj | null) => {
88
+ type: "SELECTION_ANCHOR";
89
+ id: string | null;
90
+ };
91
+ }> | import("../types/utils").ActionTypes<{
92
+ cursor(cursor: Cursor): {
93
+ type: "DND_CURSOR";
94
+ cursor: Cursor;
95
+ };
96
+ dragStart(id: string, dragIds: string[]): {
97
+ type: "DND_DRAG_START";
98
+ id: string;
99
+ dragIds: string[];
100
+ };
101
+ dragEnd(): {
102
+ type: "DND_DRAG_END";
103
+ };
104
+ hovering(parentId: string | null, index: number | null): {
105
+ type: "DND_HOVERING";
106
+ parentId: string | null;
107
+ index: number | null;
108
+ };
109
+ }>;
110
+ get state(): {
111
+ nodes: {
112
+ focus: import("../state/focus-slice").FocusState;
113
+ edit: import("../state/edit-slice").EditState;
114
+ open: import("../state/open-slice").OpenSlice;
115
+ selection: import("../state/selection-slice").SelectionState;
116
+ drag: import("../state/drag-slice").DragSlice;
117
+ };
118
+ dnd: import("../state/dnd-slice").DndState;
119
+ };
120
+ get openState(): import("../state/open-slice").OpenMap;
121
+ get width(): string | number;
122
+ get height(): number;
123
+ get indent(): number;
124
+ get rowHeight(): number;
125
+ get overscanCount(): number;
126
+ get searchTerm(): string;
127
+ get matchFn(): (node: NodeApi<T>) => boolean;
128
+ accessChildren(data: T): T[] | null;
129
+ accessId(data: T): string;
130
+ get firstNode(): NodeApi<T>;
131
+ get lastNode(): NodeApi<T>;
132
+ get focusedNode(): NodeApi<T> | null;
133
+ get mostRecentNode(): NodeApi<T> | null;
134
+ get nextNode(): NodeApi<T> | null;
135
+ get prevNode(): NodeApi<T> | null;
136
+ get(id: string | null): NodeApi<T> | null;
137
+ at(index: number): NodeApi<T> | null;
138
+ nodesBetween(startId: string | null, endId: string | null): NodeApi<T>[];
139
+ indexOf(id: string | null | IdObj): number | null;
140
+ get editingId(): string | null;
141
+ createInternal(): Promise<void>;
142
+ createLeaf(): Promise<void>;
143
+ create(opts?: {
144
+ type?: "internal" | "leaf";
145
+ parentId?: null | string;
146
+ index?: null | number;
147
+ }): Promise<void>;
148
+ delete(node: string | IdObj | null | string[] | IdObj[]): Promise<void>;
149
+ edit(node: string | IdObj): Promise<EditResult>;
150
+ submit(identity: Identity, value: string): Promise<void>;
151
+ reset(): void;
152
+ activate(id: string | IdObj | null): void;
153
+ private resolveEdit;
154
+ get selectedIds(): Set<string>;
155
+ get selectedNodes(): NodeApi<T>[];
156
+ focus(node: Identity, opts?: {
157
+ scroll?: boolean;
158
+ }): void;
159
+ pageUp(): void;
160
+ pageDown(): void;
161
+ select(node: Identity, opts?: {
162
+ align?: Align;
163
+ focus?: boolean;
164
+ }): void;
165
+ deselect(node: Identity): void;
166
+ selectMulti(identity: Identity): void;
167
+ selectContiguous(identity: Identity): void;
168
+ deselectAll(): void;
169
+ selectAll(): void;
170
+ setSelection(args: {
171
+ ids: (IdObj | string)[] | null;
172
+ anchor: IdObj | string | null;
173
+ mostRecent: IdObj | string | null;
174
+ }): void;
175
+ get cursorParentId(): string | null;
176
+ get cursorOverFolder(): boolean;
177
+ get dragNodes(): NodeApi<T>[];
178
+ get dragNode(): NodeApi<T> | null;
179
+ get dragDestinationParent(): NodeApi<T> | null;
180
+ get dragDestinationIndex(): number | null;
181
+ canDrop(): boolean;
182
+ hideCursor(): void;
183
+ showCursor(cursor: Cursor): void;
184
+ open(identity: Identity): void;
185
+ close(identity: Identity): void;
186
+ toggle(identity: Identity): void;
187
+ openParents(identity: Identity): void;
188
+ openSiblings(node: NodeApi<T>): void;
189
+ openAll(): void;
190
+ closeAll(): void;
191
+ scrollTo(identity: Identity, align?: Align): Promise<void> | undefined;
192
+ get isEditing(): boolean;
193
+ get isFiltered(): boolean;
194
+ get hasFocus(): boolean;
195
+ get hasNoSelection(): boolean;
196
+ get hasOneSelection(): boolean;
197
+ get hasMultipleSelections(): boolean;
198
+ isSelected(id?: string): boolean;
199
+ isOpen(id?: string): boolean;
200
+ isEditable(data: T): boolean;
201
+ isDraggable(data: T): boolean;
202
+ isDragging(node: string | IdObj | null): boolean;
203
+ isFocused(id: string): boolean;
204
+ isMatch(node: NodeApi<T>): boolean;
205
+ willReceiveDrop(node: string | IdObj | null): boolean;
206
+ onFocus(): void;
207
+ onBlur(): void;
208
+ onItemsRendered(args: ListOnItemsRenderedProps): void;
209
+ get renderContainer(): import("react").ElementType<{}> | typeof DefaultContainer;
210
+ get renderRow(): import("react").ElementType<import("..").RowRendererProps<T>> | typeof DefaultRow;
211
+ get renderNode(): import("react").ElementType<import("..").NodeRendererProps<T>> | typeof DefaultNode;
212
+ get renderDragPreview(): import("react").ElementType<import("..").DragPreviewProps> | typeof DefaultDragPreview;
213
+ get renderCursor(): import("react").ElementType<import("..").CursorProps> | import("react").NamedExoticComponent<import("..").CursorProps>;
214
+ }