react-arborist 3.7.0 → 3.8.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/dist/main/components/cursor.js +1 -2
- package/dist/main/components/default-container.js +31 -2
- package/dist/main/components/default-cursor.js +1 -1
- package/dist/main/components/default-drag-preview.d.ts +1 -1
- package/dist/main/components/default-drag-preview.js +1 -1
- package/dist/main/components/default-row.d.ts +1 -1
- package/dist/main/components/default-row.js +1 -1
- package/dist/main/components/list-outer-element.js +1 -1
- package/dist/main/components/provider.d.ts +1 -1
- package/dist/main/components/provider.js +2 -2
- package/dist/main/components/provider.test.js +70 -0
- package/dist/main/components/row-container.d.ts +1 -1
- package/dist/main/components/row-container.js +2 -3
- package/dist/main/dnd/drag-hook.js +1 -0
- package/dist/main/hooks/use-validated-props.js +1 -2
- package/dist/main/interfaces/node-api.js +4 -1
- package/dist/main/interfaces/tree-api.d.ts +27 -5
- package/dist/main/interfaces/tree-api.js +98 -14
- package/dist/main/interfaces/tree-api.test.js +31 -0
- package/dist/main/state/drag-slice.js +1 -2
- package/dist/main/types/state.d.ts +1 -1
- package/dist/main/types/tree-props.d.ts +3 -1
- package/dist/module/components/cursor.js +1 -2
- package/dist/module/components/default-container.js +32 -3
- package/dist/module/components/default-cursor.js +1 -1
- package/dist/module/components/default-drag-preview.d.ts +1 -1
- package/dist/module/components/default-drag-preview.js +1 -1
- package/dist/module/components/default-row.d.ts +1 -1
- package/dist/module/components/default-row.js +1 -1
- package/dist/module/components/list-outer-element.js +1 -1
- package/dist/module/components/provider.d.ts +1 -1
- package/dist/module/components/provider.js +4 -4
- package/dist/module/components/provider.test.js +71 -1
- package/dist/module/components/row-container.d.ts +1 -1
- package/dist/module/components/row-container.js +2 -3
- package/dist/module/dnd/compute-drop.js +1 -1
- package/dist/module/dnd/drag-hook.js +1 -0
- package/dist/module/hooks/use-validated-props.js +1 -2
- package/dist/module/interfaces/node-api.js +4 -1
- package/dist/module/interfaces/tree-api.d.ts +27 -5
- package/dist/module/interfaces/tree-api.js +98 -14
- package/dist/module/interfaces/tree-api.test.js +31 -0
- package/dist/module/state/drag-slice.js +1 -2
- package/dist/module/types/state.d.ts +1 -1
- package/dist/module/types/tree-props.d.ts +3 -1
- package/package.json +27 -27
- package/src/components/cursor.tsx +1 -2
- package/src/components/default-container.tsx +40 -19
- package/src/components/default-cursor.tsx +1 -5
- package/src/components/default-drag-preview.tsx +3 -16
- package/src/components/default-node.tsx +0 -1
- package/src/components/default-row.tsx +2 -13
- package/src/components/drag-preview-container.tsx +1 -1
- package/src/components/list-inner-element.tsx +1 -1
- package/src/components/list-outer-element.tsx +2 -3
- package/src/components/provider.test.tsx +85 -9
- package/src/components/provider.tsx +8 -23
- package/src/components/row-container.tsx +4 -9
- package/src/components/tree.tsx +2 -6
- package/src/context.ts +2 -3
- package/src/data/create-index.ts +0 -1
- package/src/data/create-list.ts +1 -2
- package/src/data/create-root.ts +2 -9
- package/src/data/simple-tree.ts +5 -3
- package/src/dnd/compute-drop.ts +6 -15
- package/src/dnd/drag-hook.ts +1 -0
- package/src/dnd/measure-hover.ts +2 -6
- package/src/dnd/outer-drop-hook.ts +1 -1
- package/src/hooks/use-fresh-node.ts +0 -1
- package/src/hooks/use-simple-tree.ts +2 -8
- package/src/hooks/use-validated-props.ts +4 -8
- package/src/interfaces/node-api.ts +2 -2
- package/src/interfaces/tree-api.test.ts +35 -0
- package/src/interfaces/tree-api.ts +103 -36
- package/src/state/dnd-slice.ts +1 -1
- package/src/state/drag-slice.ts +2 -5
- package/src/state/edit-slice.ts +1 -4
- package/src/state/focus-slice.ts +1 -1
- package/src/state/open-slice.ts +2 -5
- package/src/state/selection-slice.ts +2 -6
- package/src/types/handlers.ts +1 -3
- package/src/types/renderers.ts +0 -1
- package/src/types/state.ts +1 -1
- package/src/types/tree-props.ts +6 -10
- package/src/types/utils.ts +2 -3
- package/src/utils.ts +5 -14
package/src/types/utils.ts
CHANGED
|
@@ -9,9 +9,8 @@ export type Identity = string | IdObj | null;
|
|
|
9
9
|
|
|
10
10
|
export type BoolFunc<T> = (data: T) => boolean;
|
|
11
11
|
|
|
12
|
-
export type ActionTypes<
|
|
13
|
-
Actions
|
|
14
|
-
> = ReturnType<Actions[keyof Actions]>;
|
|
12
|
+
export type ActionTypes<Actions extends { [name: string]: (...args: any[]) => AnyAction }> =
|
|
13
|
+
ReturnType<Actions[keyof Actions]>;
|
|
15
14
|
|
|
16
15
|
export type SelectOptions = { multi?: boolean; contiguous?: boolean };
|
|
17
16
|
|
package/src/utils.ts
CHANGED
|
@@ -49,10 +49,7 @@ export function dfs(node: NodeApi<any>, id: string): NodeApi<any> | null {
|
|
|
49
49
|
return null;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
export function walk(
|
|
53
|
-
node: NodeApi<any>,
|
|
54
|
-
fn: (node: NodeApi<any>) => void
|
|
55
|
-
): void {
|
|
52
|
+
export function walk(node: NodeApi<any>, fn: (node: NodeApi<any>) => void): void {
|
|
56
53
|
fn(node);
|
|
57
54
|
if (node.children) {
|
|
58
55
|
for (let child of node.children) {
|
|
@@ -110,15 +107,12 @@ function prevItem(list: HTMLElement[], index: number) {
|
|
|
110
107
|
function getFocusable(target: HTMLElement) {
|
|
111
108
|
return Array.from(
|
|
112
109
|
document.querySelectorAll(
|
|
113
|
-
'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)'
|
|
114
|
-
)
|
|
110
|
+
'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)',
|
|
111
|
+
),
|
|
115
112
|
).filter((e) => e === target || !target.contains(e)) as HTMLElement[];
|
|
116
113
|
}
|
|
117
114
|
|
|
118
|
-
export function access<T = boolean>(
|
|
119
|
-
obj: any,
|
|
120
|
-
accessor: string | boolean | Function
|
|
121
|
-
): T {
|
|
115
|
+
export function access<T = boolean>(obj: any, accessor: string | boolean | Function): T {
|
|
122
116
|
if (typeof accessor === "boolean") return accessor as unknown as T;
|
|
123
117
|
if (typeof accessor === "string") return obj[accessor] as T;
|
|
124
118
|
return accessor(obj) as T;
|
|
@@ -234,10 +228,7 @@ const defaultTreeLineChars: TreeLineChars = {
|
|
|
234
228
|
* getTreeLinePrefix(node, { last: "`- ", middle: "|- ", pipe: "|", blank: " " })
|
|
235
229
|
* ```
|
|
236
230
|
*/
|
|
237
|
-
export function getTreeLinePrefix(
|
|
238
|
-
node: NodeApi<any>,
|
|
239
|
-
chars: Partial<TreeLineChars> = {}
|
|
240
|
-
): string {
|
|
231
|
+
export function getTreeLinePrefix(node: NodeApi<any>, chars: Partial<TreeLineChars> = {}): string {
|
|
241
232
|
const c = { ...defaultTreeLineChars, ...chars };
|
|
242
233
|
if (node.level === 0) return "";
|
|
243
234
|
|