@headless-tree/core 1.2.1 → 1.4.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/CHANGELOG.md +31 -0
- package/dist/index.d.mts +580 -0
- package/dist/index.d.ts +580 -0
- package/dist/index.js +2347 -0
- package/dist/index.mjs +2302 -0
- package/package.json +18 -10
- package/src/core/create-tree.ts +26 -15
- package/src/features/async-data-loader/feature.ts +5 -0
- package/src/features/async-data-loader/types.ts +2 -0
- package/src/features/checkboxes/checkboxes.spec.ts +20 -5
- package/src/features/checkboxes/feature.ts +31 -16
- package/src/features/checkboxes/types.ts +1 -0
- package/src/features/drag-and-drop/drag-and-drop.spec.ts +11 -2
- package/src/features/drag-and-drop/feature.ts +107 -24
- package/src/features/drag-and-drop/types.ts +21 -0
- package/src/features/drag-and-drop/utils.ts +8 -6
- package/src/features/keyboard-drag-and-drop/feature.ts +10 -1
- package/src/features/keyboard-drag-and-drop/keyboard-drag-and-drop.spec.ts +34 -3
- package/src/features/main/types.ts +0 -2
- package/src/features/sync-data-loader/feature.ts +5 -1
- package/src/features/tree/feature.ts +4 -3
- package/src/features/tree/tree.spec.ts +14 -4
- package/src/test-utils/test-tree-do.ts +2 -0
- package/src/test-utils/test-tree.ts +1 -0
- package/tsconfig.json +1 -4
- package/vitest.config.ts +3 -1
- package/lib/cjs/core/build-proxified-instance.d.ts +0 -2
- package/lib/cjs/core/build-proxified-instance.js +0 -58
- package/lib/cjs/core/build-static-instance.d.ts +0 -2
- package/lib/cjs/core/build-static-instance.js +0 -26
- package/lib/cjs/core/create-tree.d.ts +0 -2
- package/lib/cjs/core/create-tree.js +0 -191
- package/lib/cjs/features/async-data-loader/feature.d.ts +0 -2
- package/lib/cjs/features/async-data-loader/feature.js +0 -135
- package/lib/cjs/features/async-data-loader/types.d.ts +0 -47
- package/lib/cjs/features/async-data-loader/types.js +0 -2
- package/lib/cjs/features/checkboxes/feature.d.ts +0 -2
- package/lib/cjs/features/checkboxes/feature.js +0 -94
- package/lib/cjs/features/checkboxes/types.d.ts +0 -26
- package/lib/cjs/features/checkboxes/types.js +0 -9
- package/lib/cjs/features/drag-and-drop/feature.d.ts +0 -2
- package/lib/cjs/features/drag-and-drop/feature.js +0 -205
- package/lib/cjs/features/drag-and-drop/types.d.ts +0 -71
- package/lib/cjs/features/drag-and-drop/types.js +0 -9
- package/lib/cjs/features/drag-and-drop/utils.d.ts +0 -27
- package/lib/cjs/features/drag-and-drop/utils.js +0 -182
- package/lib/cjs/features/expand-all/feature.d.ts +0 -2
- package/lib/cjs/features/expand-all/feature.js +0 -70
- package/lib/cjs/features/expand-all/types.d.ts +0 -19
- package/lib/cjs/features/expand-all/types.js +0 -2
- package/lib/cjs/features/hotkeys-core/feature.d.ts +0 -2
- package/lib/cjs/features/hotkeys-core/feature.js +0 -107
- package/lib/cjs/features/hotkeys-core/types.d.ts +0 -27
- package/lib/cjs/features/hotkeys-core/types.js +0 -2
- package/lib/cjs/features/keyboard-drag-and-drop/feature.d.ts +0 -2
- package/lib/cjs/features/keyboard-drag-and-drop/feature.js +0 -206
- package/lib/cjs/features/keyboard-drag-and-drop/types.d.ts +0 -27
- package/lib/cjs/features/keyboard-drag-and-drop/types.js +0 -11
- package/lib/cjs/features/main/types.d.ts +0 -47
- package/lib/cjs/features/main/types.js +0 -2
- package/lib/cjs/features/prop-memoization/feature.d.ts +0 -2
- package/lib/cjs/features/prop-memoization/feature.js +0 -70
- package/lib/cjs/features/prop-memoization/types.d.ts +0 -15
- package/lib/cjs/features/prop-memoization/types.js +0 -2
- package/lib/cjs/features/renaming/feature.d.ts +0 -2
- package/lib/cjs/features/renaming/feature.js +0 -86
- package/lib/cjs/features/renaming/types.d.ts +0 -27
- package/lib/cjs/features/renaming/types.js +0 -2
- package/lib/cjs/features/search/feature.d.ts +0 -2
- package/lib/cjs/features/search/feature.js +0 -119
- package/lib/cjs/features/search/types.d.ts +0 -32
- package/lib/cjs/features/search/types.js +0 -2
- package/lib/cjs/features/selection/feature.d.ts +0 -2
- package/lib/cjs/features/selection/feature.js +0 -132
- package/lib/cjs/features/selection/types.d.ts +0 -21
- package/lib/cjs/features/selection/types.js +0 -2
- package/lib/cjs/features/sync-data-loader/feature.d.ts +0 -2
- package/lib/cjs/features/sync-data-loader/feature.js +0 -49
- package/lib/cjs/features/sync-data-loader/types.d.ts +0 -28
- package/lib/cjs/features/sync-data-loader/types.js +0 -2
- package/lib/cjs/features/tree/feature.d.ts +0 -2
- package/lib/cjs/features/tree/feature.js +0 -244
- package/lib/cjs/features/tree/types.d.ts +0 -63
- package/lib/cjs/features/tree/types.js +0 -2
- package/lib/cjs/index.d.ts +0 -33
- package/lib/cjs/index.js +0 -51
- package/lib/cjs/mddocs-entry.d.ts +0 -121
- package/lib/cjs/mddocs-entry.js +0 -17
- package/lib/cjs/test-utils/test-tree-do.d.ts +0 -23
- package/lib/cjs/test-utils/test-tree-do.js +0 -112
- package/lib/cjs/test-utils/test-tree-expect.d.ts +0 -17
- package/lib/cjs/test-utils/test-tree-expect.js +0 -66
- package/lib/cjs/test-utils/test-tree.d.ts +0 -48
- package/lib/cjs/test-utils/test-tree.js +0 -207
- package/lib/cjs/types/core.d.ts +0 -84
- package/lib/cjs/types/core.js +0 -2
- package/lib/cjs/types/deep-merge.d.ts +0 -13
- package/lib/cjs/types/deep-merge.js +0 -2
- package/lib/cjs/utilities/create-on-drop-handler.d.ts +0 -3
- package/lib/cjs/utilities/create-on-drop-handler.js +0 -20
- package/lib/cjs/utilities/errors.d.ts +0 -2
- package/lib/cjs/utilities/errors.js +0 -9
- package/lib/cjs/utilities/insert-items-at-target.d.ts +0 -3
- package/lib/cjs/utilities/insert-items-at-target.js +0 -40
- package/lib/cjs/utilities/remove-items-from-parents.d.ts +0 -2
- package/lib/cjs/utilities/remove-items-from-parents.js +0 -32
- package/lib/cjs/utils.d.ts +0 -6
- package/lib/cjs/utils.js +0 -53
- package/lib/esm/core/build-proxified-instance.d.ts +0 -2
- package/lib/esm/core/build-proxified-instance.js +0 -54
- package/lib/esm/core/build-static-instance.d.ts +0 -2
- package/lib/esm/core/build-static-instance.js +0 -22
- package/lib/esm/core/create-tree.d.ts +0 -2
- package/lib/esm/core/create-tree.js +0 -187
- package/lib/esm/features/async-data-loader/feature.d.ts +0 -2
- package/lib/esm/features/async-data-loader/feature.js +0 -132
- package/lib/esm/features/async-data-loader/types.d.ts +0 -47
- package/lib/esm/features/async-data-loader/types.js +0 -1
- package/lib/esm/features/checkboxes/feature.d.ts +0 -2
- package/lib/esm/features/checkboxes/feature.js +0 -91
- package/lib/esm/features/checkboxes/types.d.ts +0 -26
- package/lib/esm/features/checkboxes/types.js +0 -6
- package/lib/esm/features/drag-and-drop/feature.d.ts +0 -2
- package/lib/esm/features/drag-and-drop/feature.js +0 -202
- package/lib/esm/features/drag-and-drop/types.d.ts +0 -71
- package/lib/esm/features/drag-and-drop/types.js +0 -6
- package/lib/esm/features/drag-and-drop/utils.d.ts +0 -27
- package/lib/esm/features/drag-and-drop/utils.js +0 -172
- package/lib/esm/features/expand-all/feature.d.ts +0 -2
- package/lib/esm/features/expand-all/feature.js +0 -67
- package/lib/esm/features/expand-all/types.d.ts +0 -19
- package/lib/esm/features/expand-all/types.js +0 -1
- package/lib/esm/features/hotkeys-core/feature.d.ts +0 -2
- package/lib/esm/features/hotkeys-core/feature.js +0 -104
- package/lib/esm/features/hotkeys-core/types.d.ts +0 -27
- package/lib/esm/features/hotkeys-core/types.js +0 -1
- package/lib/esm/features/keyboard-drag-and-drop/feature.d.ts +0 -2
- package/lib/esm/features/keyboard-drag-and-drop/feature.js +0 -203
- package/lib/esm/features/keyboard-drag-and-drop/types.d.ts +0 -27
- package/lib/esm/features/keyboard-drag-and-drop/types.js +0 -8
- package/lib/esm/features/main/types.d.ts +0 -47
- package/lib/esm/features/main/types.js +0 -1
- package/lib/esm/features/prop-memoization/feature.d.ts +0 -2
- package/lib/esm/features/prop-memoization/feature.js +0 -67
- package/lib/esm/features/prop-memoization/types.d.ts +0 -15
- package/lib/esm/features/prop-memoization/types.js +0 -1
- package/lib/esm/features/renaming/feature.d.ts +0 -2
- package/lib/esm/features/renaming/feature.js +0 -83
- package/lib/esm/features/renaming/types.d.ts +0 -27
- package/lib/esm/features/renaming/types.js +0 -1
- package/lib/esm/features/search/feature.d.ts +0 -2
- package/lib/esm/features/search/feature.js +0 -116
- package/lib/esm/features/search/types.d.ts +0 -32
- package/lib/esm/features/search/types.js +0 -1
- package/lib/esm/features/selection/feature.d.ts +0 -2
- package/lib/esm/features/selection/feature.js +0 -129
- package/lib/esm/features/selection/types.d.ts +0 -21
- package/lib/esm/features/selection/types.js +0 -1
- package/lib/esm/features/sync-data-loader/feature.d.ts +0 -2
- package/lib/esm/features/sync-data-loader/feature.js +0 -46
- package/lib/esm/features/sync-data-loader/types.d.ts +0 -28
- package/lib/esm/features/sync-data-loader/types.js +0 -1
- package/lib/esm/features/tree/feature.d.ts +0 -2
- package/lib/esm/features/tree/feature.js +0 -241
- package/lib/esm/features/tree/types.d.ts +0 -63
- package/lib/esm/features/tree/types.js +0 -1
- package/lib/esm/index.d.ts +0 -33
- package/lib/esm/index.js +0 -32
- package/lib/esm/mddocs-entry.d.ts +0 -121
- package/lib/esm/mddocs-entry.js +0 -1
- package/lib/esm/test-utils/test-tree-do.d.ts +0 -23
- package/lib/esm/test-utils/test-tree-do.js +0 -108
- package/lib/esm/test-utils/test-tree-expect.d.ts +0 -17
- package/lib/esm/test-utils/test-tree-expect.js +0 -62
- package/lib/esm/test-utils/test-tree.d.ts +0 -48
- package/lib/esm/test-utils/test-tree.js +0 -203
- package/lib/esm/types/core.d.ts +0 -84
- package/lib/esm/types/core.js +0 -1
- package/lib/esm/types/deep-merge.d.ts +0 -13
- package/lib/esm/types/deep-merge.js +0 -1
- package/lib/esm/utilities/create-on-drop-handler.d.ts +0 -3
- package/lib/esm/utilities/create-on-drop-handler.js +0 -16
- package/lib/esm/utilities/errors.d.ts +0 -2
- package/lib/esm/utilities/errors.js +0 -4
- package/lib/esm/utilities/insert-items-at-target.d.ts +0 -3
- package/lib/esm/utilities/insert-items-at-target.js +0 -36
- package/lib/esm/utilities/remove-items-from-parents.d.ts +0 -2
- package/lib/esm/utilities/remove-items-from-parents.js +0 -28
- package/lib/esm/utils.d.ts +0 -6
- package/lib/esm/utils.js +0 -46
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { ItemInstance, SetStateFn, TreeInstance } from "../../types/core";
|
|
2
|
-
export interface ItemMeta {
|
|
3
|
-
itemId: string;
|
|
4
|
-
parentId: string;
|
|
5
|
-
level: number;
|
|
6
|
-
index: number;
|
|
7
|
-
setSize: number;
|
|
8
|
-
posInSet: number;
|
|
9
|
-
}
|
|
10
|
-
export interface TreeItemDataRef {
|
|
11
|
-
memoizedValues: Record<string, any>;
|
|
12
|
-
memoizedDeps: Record<string, any[] | undefined>;
|
|
13
|
-
}
|
|
14
|
-
export type TreeFeatureDef<T> = {
|
|
15
|
-
state: {
|
|
16
|
-
expandedItems: string[];
|
|
17
|
-
focusedItem: string | null;
|
|
18
|
-
};
|
|
19
|
-
config: {
|
|
20
|
-
isItemFolder: (item: ItemInstance<T>) => boolean;
|
|
21
|
-
getItemName: (item: ItemInstance<T>) => string;
|
|
22
|
-
onPrimaryAction?: (item: ItemInstance<T>) => void;
|
|
23
|
-
scrollToItem?: (item: ItemInstance<T>) => void;
|
|
24
|
-
setExpandedItems?: SetStateFn<string[]>;
|
|
25
|
-
setFocusedItem?: SetStateFn<string | null>;
|
|
26
|
-
};
|
|
27
|
-
treeInstance: {
|
|
28
|
-
/** @internal */
|
|
29
|
-
getItemsMeta: () => ItemMeta[];
|
|
30
|
-
getFocusedItem: () => ItemInstance<T>;
|
|
31
|
-
getRootItem: () => ItemInstance<T>;
|
|
32
|
-
focusNextItem: () => void;
|
|
33
|
-
focusPreviousItem: () => void;
|
|
34
|
-
updateDomFocus: () => void;
|
|
35
|
-
/** Pass to the container rendering the tree children. The `treeLabel` parameter
|
|
36
|
-
* will be passed as `aria-label` parameter, and is recommended to be set. */
|
|
37
|
-
getContainerProps: (treeLabel?: string) => Record<string, any>;
|
|
38
|
-
};
|
|
39
|
-
itemInstance: {
|
|
40
|
-
getId: () => string;
|
|
41
|
-
getKey: () => string;
|
|
42
|
-
getProps: () => Record<string, any>;
|
|
43
|
-
getItemName: () => string;
|
|
44
|
-
getItemData: () => T;
|
|
45
|
-
equals: (other?: ItemInstance<any> | null) => boolean;
|
|
46
|
-
expand: () => void;
|
|
47
|
-
collapse: () => void;
|
|
48
|
-
isExpanded: () => boolean;
|
|
49
|
-
isDescendentOf: (parentId: string) => boolean;
|
|
50
|
-
isFocused: () => boolean;
|
|
51
|
-
isFolder: () => boolean;
|
|
52
|
-
setFocused: () => void;
|
|
53
|
-
getParent: () => ItemInstance<T> | undefined;
|
|
54
|
-
getChildren: () => ItemInstance<T>[];
|
|
55
|
-
getIndexInParent: () => number;
|
|
56
|
-
primaryAction: () => void;
|
|
57
|
-
getTree: () => TreeInstance<T>;
|
|
58
|
-
getItemAbove: () => ItemInstance<T> | undefined;
|
|
59
|
-
getItemBelow: () => ItemInstance<T> | undefined;
|
|
60
|
-
scrollTo: (scrollIntoViewArg?: boolean | ScrollIntoViewOptions) => Promise<void>;
|
|
61
|
-
};
|
|
62
|
-
hotkeys: "focusNextItem" | "focusPreviousItem" | "expandOrDown" | "collapseOrUp" | "focusFirstItem" | "focusLastItem";
|
|
63
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/esm/index.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export * from "./types/core";
|
|
2
|
-
export * from "./core/create-tree";
|
|
3
|
-
export * from "./features/tree/types";
|
|
4
|
-
export { MainFeatureDef, InstanceBuilder } from "./features/main/types";
|
|
5
|
-
export * from "./features/drag-and-drop/types";
|
|
6
|
-
export * from "./features/keyboard-drag-and-drop/types";
|
|
7
|
-
export * from "./features/selection/types";
|
|
8
|
-
export * from "./features/checkboxes/types";
|
|
9
|
-
export * from "./features/async-data-loader/types";
|
|
10
|
-
export * from "./features/sync-data-loader/types";
|
|
11
|
-
export * from "./features/hotkeys-core/types";
|
|
12
|
-
export * from "./features/search/types";
|
|
13
|
-
export * from "./features/renaming/types";
|
|
14
|
-
export * from "./features/expand-all/types";
|
|
15
|
-
export * from "./features/prop-memoization/types";
|
|
16
|
-
export * from "./features/selection/feature";
|
|
17
|
-
export * from "./features/checkboxes/feature";
|
|
18
|
-
export * from "./features/hotkeys-core/feature";
|
|
19
|
-
export * from "./features/async-data-loader/feature";
|
|
20
|
-
export * from "./features/sync-data-loader/feature";
|
|
21
|
-
export * from "./features/drag-and-drop/feature";
|
|
22
|
-
export * from "./features/keyboard-drag-and-drop/feature";
|
|
23
|
-
export * from "./features/search/feature";
|
|
24
|
-
export * from "./features/renaming/feature";
|
|
25
|
-
export * from "./features/expand-all/feature";
|
|
26
|
-
export * from "./features/prop-memoization/feature";
|
|
27
|
-
export * from "./utilities/create-on-drop-handler";
|
|
28
|
-
export * from "./utilities/insert-items-at-target";
|
|
29
|
-
export * from "./utilities/remove-items-from-parents";
|
|
30
|
-
export * from "./core/build-proxified-instance";
|
|
31
|
-
export * from "./core/build-static-instance";
|
|
32
|
-
export { makeStateUpdater } from "./utils";
|
|
33
|
-
export { isOrderedDragTarget } from "./features/drag-and-drop/utils";
|
package/lib/esm/index.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export * from "./types/core";
|
|
2
|
-
export * from "./core/create-tree";
|
|
3
|
-
export * from "./features/tree/types";
|
|
4
|
-
export * from "./features/drag-and-drop/types";
|
|
5
|
-
export * from "./features/keyboard-drag-and-drop/types";
|
|
6
|
-
export * from "./features/selection/types";
|
|
7
|
-
export * from "./features/checkboxes/types";
|
|
8
|
-
export * from "./features/async-data-loader/types";
|
|
9
|
-
export * from "./features/sync-data-loader/types";
|
|
10
|
-
export * from "./features/hotkeys-core/types";
|
|
11
|
-
export * from "./features/search/types";
|
|
12
|
-
export * from "./features/renaming/types";
|
|
13
|
-
export * from "./features/expand-all/types";
|
|
14
|
-
export * from "./features/prop-memoization/types";
|
|
15
|
-
export * from "./features/selection/feature";
|
|
16
|
-
export * from "./features/checkboxes/feature";
|
|
17
|
-
export * from "./features/hotkeys-core/feature";
|
|
18
|
-
export * from "./features/async-data-loader/feature";
|
|
19
|
-
export * from "./features/sync-data-loader/feature";
|
|
20
|
-
export * from "./features/drag-and-drop/feature";
|
|
21
|
-
export * from "./features/keyboard-drag-and-drop/feature";
|
|
22
|
-
export * from "./features/search/feature";
|
|
23
|
-
export * from "./features/renaming/feature";
|
|
24
|
-
export * from "./features/expand-all/feature";
|
|
25
|
-
export * from "./features/prop-memoization/feature";
|
|
26
|
-
export * from "./utilities/create-on-drop-handler";
|
|
27
|
-
export * from "./utilities/insert-items-at-target";
|
|
28
|
-
export * from "./utilities/remove-items-from-parents";
|
|
29
|
-
export * from "./core/build-proxified-instance";
|
|
30
|
-
export * from "./core/build-static-instance";
|
|
31
|
-
export { makeStateUpdater } from "./utils";
|
|
32
|
-
export { isOrderedDragTarget } from "./features/drag-and-drop/utils";
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { MainFeatureDef } from "./features/main/types";
|
|
2
|
-
import { DragAndDropFeatureDef } from "./features/drag-and-drop/types";
|
|
3
|
-
import { AsyncDataLoaderFeatureDef } from "./features/async-data-loader/types";
|
|
4
|
-
import { ExpandAllFeatureDef } from "./features/expand-all/types";
|
|
5
|
-
import { HotkeysCoreFeatureDef } from "./features/hotkeys-core/types";
|
|
6
|
-
import { RenamingFeatureDef } from "./features/renaming/types";
|
|
7
|
-
import { SearchFeatureDef } from "./features/search/types";
|
|
8
|
-
import { SelectionFeatureDef } from "./features/selection/types";
|
|
9
|
-
import { SyncDataLoaderFeatureDef } from "./features/sync-data-loader/types";
|
|
10
|
-
import { TreeFeatureDef } from "./features/tree/types";
|
|
11
|
-
import { PropMemoizationFeatureDef } from "./features/prop-memoization/types";
|
|
12
|
-
import { KeyboardDragAndDropFeatureDef } from "./features/keyboard-drag-and-drop/types";
|
|
13
|
-
export * from ".";
|
|
14
|
-
/** @interface */
|
|
15
|
-
export type AsyncDataLoaderFeatureConfig<T> = AsyncDataLoaderFeatureDef<T>["config"];
|
|
16
|
-
/** @interface */
|
|
17
|
-
export type AsyncDataLoaderFeatureState<T> = AsyncDataLoaderFeatureDef<T>["state"];
|
|
18
|
-
/** @interface */
|
|
19
|
-
export type AsyncDataLoaderFeatureTreeInstance<T> = AsyncDataLoaderFeatureDef<T>["treeInstance"];
|
|
20
|
-
/** @interface */
|
|
21
|
-
export type AsyncDataLoaderFeatureItemInstance<T> = AsyncDataLoaderFeatureDef<T>["itemInstance"];
|
|
22
|
-
export type AsyncDataLoaderFeatureHotkeys<T> = AsyncDataLoaderFeatureDef<T>["hotkeys"];
|
|
23
|
-
/** @interface */
|
|
24
|
-
export type DragAndDropFeatureConfig<T> = DragAndDropFeatureDef<T>["config"];
|
|
25
|
-
/** @interface */
|
|
26
|
-
export type DragAndDropFeatureState<T> = DragAndDropFeatureDef<T>["state"];
|
|
27
|
-
/** @interface */
|
|
28
|
-
export type DragAndDropFeatureTreeInstance<T> = DragAndDropFeatureDef<T>["treeInstance"];
|
|
29
|
-
/** @interface */
|
|
30
|
-
export type DragAndDropFeatureItemInstance<T> = DragAndDropFeatureDef<T>["itemInstance"];
|
|
31
|
-
export type DragAndDropFeatureHotkeys<T> = DragAndDropFeatureDef<T>["hotkeys"];
|
|
32
|
-
/** @interface */
|
|
33
|
-
export type KeyboardDragAndDropFeatureConfig<T> = KeyboardDragAndDropFeatureDef<T>["config"];
|
|
34
|
-
/** @interface */
|
|
35
|
-
export type KeyboardDragAndDropFeatureState<T> = KeyboardDragAndDropFeatureDef<T>["state"];
|
|
36
|
-
/** @interface */
|
|
37
|
-
export type KeyboardDragAndDropFeatureTreeInstance<T> = KeyboardDragAndDropFeatureDef<T>["treeInstance"];
|
|
38
|
-
/** @interface */
|
|
39
|
-
export type KeyboardDragAndDropFeatureItemInstance<T> = KeyboardDragAndDropFeatureDef<T>["itemInstance"];
|
|
40
|
-
export type KeyboardDragAndDropFeatureHotkeys<T> = KeyboardDragAndDropFeatureDef<T>["hotkeys"];
|
|
41
|
-
/** @interface */
|
|
42
|
-
export type ExpandAllFeatureConfig = ExpandAllFeatureDef["config"];
|
|
43
|
-
/** @interface */
|
|
44
|
-
export type ExpandAllFeatureState = ExpandAllFeatureDef["state"];
|
|
45
|
-
/** @interface */
|
|
46
|
-
export type ExpandAllFeatureTreeInstance = ExpandAllFeatureDef["treeInstance"];
|
|
47
|
-
/** @interface */
|
|
48
|
-
export type ExpandAllFeatureItemInstance = ExpandAllFeatureDef["itemInstance"];
|
|
49
|
-
export type ExpandAllFeatureHotkeys = ExpandAllFeatureDef["hotkeys"];
|
|
50
|
-
/** @interface */
|
|
51
|
-
export type HotkeysCoreFeatureConfig<T> = HotkeysCoreFeatureDef<T>["config"];
|
|
52
|
-
/** @interface */
|
|
53
|
-
export type HotkeysCoreFeatureState<T> = HotkeysCoreFeatureDef<T>["state"];
|
|
54
|
-
/** @interface */
|
|
55
|
-
export type HotkeysCoreFeatureTreeInstance<T> = HotkeysCoreFeatureDef<T>["treeInstance"];
|
|
56
|
-
/** @interface */
|
|
57
|
-
export type HotkeysCoreFeatureItemInstance<T> = HotkeysCoreFeatureDef<T>["itemInstance"];
|
|
58
|
-
export type HotkeysCoreFeatureHotkeys<T> = HotkeysCoreFeatureDef<T>["hotkeys"];
|
|
59
|
-
/** @interface */
|
|
60
|
-
export type MainFeatureConfig = MainFeatureDef["config"];
|
|
61
|
-
/** @interface */
|
|
62
|
-
export type MainFeatureState = MainFeatureDef["state"];
|
|
63
|
-
/** @interface */
|
|
64
|
-
export type MainFeatureTreeInstance = MainFeatureDef["treeInstance"];
|
|
65
|
-
/** @interface */
|
|
66
|
-
export type MainFeatureItemInstance = MainFeatureDef["itemInstance"];
|
|
67
|
-
export type MainFeatureHotkeys = MainFeatureDef["hotkeys"];
|
|
68
|
-
/** @interface */
|
|
69
|
-
export type PropMemoizationConfig = PropMemoizationFeatureDef["config"];
|
|
70
|
-
/** @interface */
|
|
71
|
-
export type PropMemoizationState = PropMemoizationFeatureDef["state"];
|
|
72
|
-
/** @interface */
|
|
73
|
-
export type PropMemoizationTreeInstance = PropMemoizationFeatureDef["treeInstance"];
|
|
74
|
-
/** @interface */
|
|
75
|
-
export type PropMemoizationItemInstance = PropMemoizationFeatureDef["itemInstance"];
|
|
76
|
-
export type PropMemoizationHotkeys = PropMemoizationFeatureDef["hotkeys"];
|
|
77
|
-
/** @interface */
|
|
78
|
-
export type RenamingFeatureConfig<T> = RenamingFeatureDef<T>["config"];
|
|
79
|
-
/** @interface */
|
|
80
|
-
export type RenamingFeatureState<T> = RenamingFeatureDef<T>["state"];
|
|
81
|
-
/** @interface */
|
|
82
|
-
export type RenamingFeatureTreeInstance<T> = RenamingFeatureDef<T>["treeInstance"];
|
|
83
|
-
/** @interface */
|
|
84
|
-
export type RenamingFeatureItemInstance<T> = RenamingFeatureDef<T>["itemInstance"];
|
|
85
|
-
export type RenamingFeatureHotkeys<T> = RenamingFeatureDef<T>["hotkeys"];
|
|
86
|
-
/** @interface */
|
|
87
|
-
export type SearchFeatureConfig<T> = SearchFeatureDef<T>["config"];
|
|
88
|
-
/** @interface */
|
|
89
|
-
export type SearchFeatureState<T> = SearchFeatureDef<T>["state"];
|
|
90
|
-
/** @interface */
|
|
91
|
-
export type SearchFeatureTreeInstance<T> = SearchFeatureDef<T>["treeInstance"];
|
|
92
|
-
/** @interface */
|
|
93
|
-
export type SearchFeatureItemInstance<T> = SearchFeatureDef<T>["itemInstance"];
|
|
94
|
-
export type SearchFeatureHotkeys<T> = SearchFeatureDef<T>["hotkeys"];
|
|
95
|
-
/** @interface */
|
|
96
|
-
export type SelectionFeatureConfig<T> = SelectionFeatureDef<T>["config"];
|
|
97
|
-
/** @interface */
|
|
98
|
-
export type SelectionFeatureState<T> = SelectionFeatureDef<T>["state"];
|
|
99
|
-
/** @interface */
|
|
100
|
-
export type SelectionFeatureTreeInstance<T> = SelectionFeatureDef<T>["treeInstance"];
|
|
101
|
-
/** @interface */
|
|
102
|
-
export type SelectionFeatureItemInstance<T> = SelectionFeatureDef<T>["itemInstance"];
|
|
103
|
-
export type SelectionFeatureHotkeys<T> = SelectionFeatureDef<T>["hotkeys"];
|
|
104
|
-
/** @interface */
|
|
105
|
-
export type SyncDataLoaderFeatureConfig<T> = SyncDataLoaderFeatureDef<T>["config"];
|
|
106
|
-
/** @interface */
|
|
107
|
-
export type SyncDataLoaderFeatureState<T> = SyncDataLoaderFeatureDef<T>["state"];
|
|
108
|
-
/** @interface */
|
|
109
|
-
export type SyncDataLoaderFeatureTreeInstance<T> = SyncDataLoaderFeatureDef<T>["treeInstance"];
|
|
110
|
-
/** @interface */
|
|
111
|
-
export type SyncDataLoaderFeatureItemInstance<T> = SyncDataLoaderFeatureDef<T>["itemInstance"];
|
|
112
|
-
export type SyncDataLoaderFeatureHotkeys<T> = SyncDataLoaderFeatureDef<T>["hotkeys"];
|
|
113
|
-
/** @interface */
|
|
114
|
-
export type TreeFeatureConfig<T> = TreeFeatureDef<T>["config"];
|
|
115
|
-
/** @interface */
|
|
116
|
-
export type TreeFeatureState<T> = TreeFeatureDef<T>["state"];
|
|
117
|
-
/** @interface */
|
|
118
|
-
export type TreeFeatureTreeInstance<T> = TreeFeatureDef<T>["treeInstance"];
|
|
119
|
-
/** @interface */
|
|
120
|
-
export type TreeFeatureItemInstance<T> = TreeFeatureDef<T>["itemInstance"];
|
|
121
|
-
export type TreeFeatureHotkeys<T> = TreeFeatureDef<T>["hotkeys"];
|
package/lib/esm/mddocs-entry.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from ".";
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { DragEvent } from "react";
|
|
2
|
-
import { TestTree } from "./test-tree";
|
|
3
|
-
import { HotkeyName } from "../types/core";
|
|
4
|
-
export declare class TestTreeDo<T> {
|
|
5
|
-
protected tree: TestTree<T>;
|
|
6
|
-
protected itemInstance(itemId: string): import("../types/core").ItemInstance<T>;
|
|
7
|
-
protected itemProps(itemId: string): Record<string, any>;
|
|
8
|
-
constructor(tree: TestTree<T>);
|
|
9
|
-
selectItem(id: string): void;
|
|
10
|
-
shiftSelectItem(id: string): void;
|
|
11
|
-
ctrlSelectItem(id: string): void;
|
|
12
|
-
ctrlShiftSelectItem(id: string): void;
|
|
13
|
-
selectMultiple(...ids: string[]): void;
|
|
14
|
-
hotkey(hotkey: HotkeyName, e?: Partial<KeyboardEvent>): void;
|
|
15
|
-
startDrag(itemId: string, event?: DragEvent): DragEvent<Element>;
|
|
16
|
-
dragOver(itemId: string, event?: DragEvent): DragEvent<Element>;
|
|
17
|
-
dragOverNotAllowed(itemId: string, event?: DragEvent): DragEvent<Element>;
|
|
18
|
-
dragLeave(itemId: string): void;
|
|
19
|
-
dragEnd(itemId: string, event?: DragEvent): DragEvent<Element>;
|
|
20
|
-
drop(itemId: string, event?: DragEvent): Promise<DragEvent<Element>>;
|
|
21
|
-
dragOverAndDrop(itemId: string, event?: DragEvent): Promise<DragEvent<Element>>;
|
|
22
|
-
private consistentCalls;
|
|
23
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { expect, vi } from "vitest";
|
|
11
|
-
import { TestTree } from "./test-tree";
|
|
12
|
-
export class TestTreeDo {
|
|
13
|
-
itemInstance(itemId) {
|
|
14
|
-
return this.tree.instance.getItemInstance(itemId);
|
|
15
|
-
}
|
|
16
|
-
itemProps(itemId) {
|
|
17
|
-
return this.itemInstance(itemId).getProps();
|
|
18
|
-
}
|
|
19
|
-
constructor(tree) {
|
|
20
|
-
this.tree = tree;
|
|
21
|
-
}
|
|
22
|
-
selectItem(id) {
|
|
23
|
-
this.itemProps(id).onClick({});
|
|
24
|
-
}
|
|
25
|
-
shiftSelectItem(id) {
|
|
26
|
-
this.itemProps(id).onClick({ shiftKey: true });
|
|
27
|
-
}
|
|
28
|
-
ctrlSelectItem(id) {
|
|
29
|
-
this.itemProps(id).onClick({ ctrlKey: true });
|
|
30
|
-
}
|
|
31
|
-
ctrlShiftSelectItem(id) {
|
|
32
|
-
this.itemProps(id).onClick({ shiftKey: true, ctrlKey: true });
|
|
33
|
-
}
|
|
34
|
-
selectMultiple(...ids) {
|
|
35
|
-
ids.forEach((id) => this.ctrlSelectItem(id));
|
|
36
|
-
}
|
|
37
|
-
hotkey(hotkey, e = {}) {
|
|
38
|
-
var _a, _b;
|
|
39
|
-
const hotkeyConfig = Object.assign(Object.assign({}, this.tree.instance.getHotkeyPresets()[hotkey]), (_a = this.tree.instance.getConfig().hotkeys) === null || _a === void 0 ? void 0 : _a[hotkey]);
|
|
40
|
-
if (hotkeyConfig.isEnabled &&
|
|
41
|
-
!((_b = hotkeyConfig.isEnabled) === null || _b === void 0 ? void 0 : _b.call(hotkeyConfig, this.tree.instance))) {
|
|
42
|
-
throw new Error(`Hotkey "${hotkey}" is disabled`);
|
|
43
|
-
}
|
|
44
|
-
if (!hotkeyConfig.handler) {
|
|
45
|
-
throw new Error(`Hotkey "${hotkey}" has no handler`);
|
|
46
|
-
}
|
|
47
|
-
hotkeyConfig.handler(Object.assign(Object.assign({}, e), { stopPropagation: () => { }, preventDefault: () => { } }), this.tree.instance);
|
|
48
|
-
}
|
|
49
|
-
startDrag(itemId, event) {
|
|
50
|
-
if (!this.itemProps(itemId).draggable) {
|
|
51
|
-
throw new Error(`Can't drag item ${itemId}, has attribute draggable=false`);
|
|
52
|
-
}
|
|
53
|
-
const e = event !== null && event !== void 0 ? event : TestTree.dragEvent();
|
|
54
|
-
this.itemProps(itemId).onDragStart(e);
|
|
55
|
-
return e;
|
|
56
|
-
}
|
|
57
|
-
dragOver(itemId, event) {
|
|
58
|
-
const e = event !== null && event !== void 0 ? event : TestTree.dragEvent();
|
|
59
|
-
e.preventDefault.mockClear();
|
|
60
|
-
this.itemProps(itemId).onDragOver(e);
|
|
61
|
-
this.itemProps(itemId).onDragOver(e);
|
|
62
|
-
this.itemProps(itemId).onDragOver(e);
|
|
63
|
-
expect(e.preventDefault).toBeCalledTimes(3);
|
|
64
|
-
this.consistentCalls(e.preventDefault);
|
|
65
|
-
this.consistentCalls(e.stopPropagation);
|
|
66
|
-
return e;
|
|
67
|
-
}
|
|
68
|
-
dragOverNotAllowed(itemId, event) {
|
|
69
|
-
const e = event !== null && event !== void 0 ? event : TestTree.dragEvent();
|
|
70
|
-
e.preventDefault.mockClear();
|
|
71
|
-
this.itemProps(itemId).onDragOver(e);
|
|
72
|
-
this.itemProps(itemId).onDragOver(e);
|
|
73
|
-
this.itemProps(itemId).onDragOver(e);
|
|
74
|
-
expect(e.preventDefault).toBeCalledTimes(0);
|
|
75
|
-
this.consistentCalls(e.preventDefault);
|
|
76
|
-
this.consistentCalls(e.stopPropagation);
|
|
77
|
-
return e;
|
|
78
|
-
}
|
|
79
|
-
dragLeave(itemId) {
|
|
80
|
-
this.itemProps(itemId).onDragLeave({});
|
|
81
|
-
}
|
|
82
|
-
dragEnd(itemId, event) {
|
|
83
|
-
const e = event !== null && event !== void 0 ? event : TestTree.dragEvent();
|
|
84
|
-
this.itemProps(itemId).onDragEnd(e);
|
|
85
|
-
return e;
|
|
86
|
-
}
|
|
87
|
-
drop(itemId, event) {
|
|
88
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
const e = event !== null && event !== void 0 ? event : TestTree.dragEvent();
|
|
90
|
-
yield this.itemProps(itemId).onDrop(e);
|
|
91
|
-
return e;
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
dragOverAndDrop(itemId, event) {
|
|
95
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
-
const e = event !== null && event !== void 0 ? event : TestTree.dragEvent();
|
|
97
|
-
this.dragOver(itemId, e);
|
|
98
|
-
return this.drop(itemId, e);
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
consistentCalls(fn) {
|
|
102
|
-
if (!vi.isMockFunction(fn)) {
|
|
103
|
-
throw new Error("fn is not a mock");
|
|
104
|
-
}
|
|
105
|
-
expect(fn.mock.calls.length, "function called inconsistent times").toBeOneOf([0, 3]);
|
|
106
|
-
expect(new Set(fn.mock.calls.map((call) => call.join("__"))).size, "function called with inconsistent parameters").toBeOneOf([0, 1]);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { DragEvent } from "react";
|
|
2
|
-
import { TestTree } from "./test-tree";
|
|
3
|
-
import { DragTarget } from "../features/drag-and-drop/types";
|
|
4
|
-
import { TreeState } from "../types/core";
|
|
5
|
-
export declare class TestTreeExpect<T> {
|
|
6
|
-
private tree;
|
|
7
|
-
protected itemInstance(itemId: string): import("../types/core").ItemInstance<T>;
|
|
8
|
-
protected itemProps(itemId: string): Record<string, any>;
|
|
9
|
-
constructor(tree: TestTree<T>);
|
|
10
|
-
foldersExpanded(...itemIds: string[]): void;
|
|
11
|
-
foldersCollapsed(...itemIds: string[]): void;
|
|
12
|
-
hasChildren(itemId: string, children: string[]): void;
|
|
13
|
-
substate<K extends keyof TreeState<T>>(key: K, value: TreeState<T>[K]): void;
|
|
14
|
-
dropped(draggedItems: string[], target: DragTarget<any>): void;
|
|
15
|
-
dragOverNotAllowed(itemId: string, event?: DragEvent): DragEvent<Element>;
|
|
16
|
-
defaultDragLineProps(indent?: number): void;
|
|
17
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
-
import { expect } from "vitest";
|
|
3
|
-
import { TestTree } from "./test-tree";
|
|
4
|
-
export class TestTreeExpect {
|
|
5
|
-
itemInstance(itemId) {
|
|
6
|
-
return this.tree.instance.getItemInstance(itemId);
|
|
7
|
-
}
|
|
8
|
-
itemProps(itemId) {
|
|
9
|
-
return this.itemInstance(itemId).getProps();
|
|
10
|
-
}
|
|
11
|
-
constructor(tree) {
|
|
12
|
-
this.tree = tree;
|
|
13
|
-
}
|
|
14
|
-
foldersExpanded(...itemIds) {
|
|
15
|
-
for (const itemId of itemIds) {
|
|
16
|
-
expect(this.tree.instance.getItemInstance(itemId).isExpanded(), `Expected ${itemId} to be expanded`).toBe(true);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
foldersCollapsed(...itemIds) {
|
|
20
|
-
for (const itemId of itemIds) {
|
|
21
|
-
expect(this.tree.instance.getItemInstance(itemId).isExpanded(), `Expected ${itemId} to be collapsed`).toBe(false);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
hasChildren(itemId, children) {
|
|
25
|
-
const item = this.tree.instance.getItemInstance(itemId);
|
|
26
|
-
const itemChildren = item.getChildren().map((child) => child.getId());
|
|
27
|
-
expect(itemChildren).toEqual(children);
|
|
28
|
-
}
|
|
29
|
-
substate(key, value) {
|
|
30
|
-
expect(this.tree.instance.getState()[key]).toEqual(value);
|
|
31
|
-
}
|
|
32
|
-
dropped(draggedItems, target) {
|
|
33
|
-
expect(this.tree.instance.getConfig().onDrop).toBeCalledWith(draggedItems.map((id) => this.tree.item(id)), target);
|
|
34
|
-
}
|
|
35
|
-
dragOverNotAllowed(itemId, event) {
|
|
36
|
-
const e = event !== null && event !== void 0 ? event : TestTree.dragEvent();
|
|
37
|
-
e.preventDefault.mockClear();
|
|
38
|
-
this.itemProps(itemId).onDragOver(e);
|
|
39
|
-
this.itemProps(itemId).onDragOver(e);
|
|
40
|
-
this.itemProps(itemId).onDragOver(e);
|
|
41
|
-
expect(e.preventDefault, "onDragOver shouldn't call e.preventDefault if drag is not allowed").not.toBeCalled();
|
|
42
|
-
this.itemProps(itemId).onDrop(e);
|
|
43
|
-
expect(e.preventDefault, "onDrop shouldn't call e.preventDefault if drag is not allowed").not.toBeCalled();
|
|
44
|
-
expect(this.tree.instance.getConfig().onDrop, "onDrop handler shouldn't be called if drag is not allowed").not.toBeCalled();
|
|
45
|
-
return e;
|
|
46
|
-
}
|
|
47
|
-
defaultDragLineProps(indent = 0) {
|
|
48
|
-
expect(this.tree.instance.getDragLineData()).toEqual({
|
|
49
|
-
indent,
|
|
50
|
-
left: indent * 20,
|
|
51
|
-
width: 100 - indent * 20,
|
|
52
|
-
top: 0,
|
|
53
|
-
});
|
|
54
|
-
expect(this.tree.instance.getDragLineStyle(0, 0)).toEqual({
|
|
55
|
-
position: "absolute",
|
|
56
|
-
left: `${indent * 20}px`,
|
|
57
|
-
pointerEvents: "none",
|
|
58
|
-
top: "0px",
|
|
59
|
-
width: `${100 - indent * 20}px`,
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { DragEvent } from "react";
|
|
2
|
-
import { TreeConfig, TreeInstance } from "../types/core";
|
|
3
|
-
import { TestTreeDo } from "./test-tree-do";
|
|
4
|
-
import { TestTreeExpect } from "./test-tree-expect";
|
|
5
|
-
export declare class TestTree<T = string> {
|
|
6
|
-
private config;
|
|
7
|
-
readonly do: TestTreeDo<T>;
|
|
8
|
-
readonly expect: TestTreeExpect<T>;
|
|
9
|
-
private treeInstance;
|
|
10
|
-
private static asyncLoaderResolvers;
|
|
11
|
-
private asyncDataLoaderImp;
|
|
12
|
-
suits: {
|
|
13
|
-
sync: () => {
|
|
14
|
-
tree: TestTree<T>;
|
|
15
|
-
title: string;
|
|
16
|
-
};
|
|
17
|
-
async: () => {
|
|
18
|
-
tree: TestTree<T>;
|
|
19
|
-
title: string;
|
|
20
|
-
};
|
|
21
|
-
proxifiedSync: () => {
|
|
22
|
-
tree: TestTree<T>;
|
|
23
|
-
title: string;
|
|
24
|
-
};
|
|
25
|
-
proxifiedAsync: () => {
|
|
26
|
-
tree: TestTree<T>;
|
|
27
|
-
title: string;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
forSuits(runSuite: (tree: TestTree<T>) => void): void;
|
|
31
|
-
get instance(): TreeInstance<T>;
|
|
32
|
-
private constructor();
|
|
33
|
-
static resolveAsyncLoaders(): Promise<void>;
|
|
34
|
-
resolveAsyncVisibleItems(): Promise<void>;
|
|
35
|
-
static default(config: Partial<TreeConfig<string>>): TestTree<string>;
|
|
36
|
-
with(config: Partial<TreeConfig<T>>): TestTree<T>;
|
|
37
|
-
resetBeforeEach(): void;
|
|
38
|
-
createTestCaseTree(): Promise<this>;
|
|
39
|
-
withFeatures(...features: any): TestTree<T>;
|
|
40
|
-
mockedHandler(handlerName: keyof TreeConfig<T>): import("vitest").Mock<(...args: any[]) => any>;
|
|
41
|
-
item(itemId: string): import("../types/core").ItemInstance<T>;
|
|
42
|
-
reset(): void;
|
|
43
|
-
debug(): void;
|
|
44
|
-
setElementBoundingBox(itemId: string, bb?: Partial<DOMRect>): void;
|
|
45
|
-
static dragEvent(clientX?: number, clientY?: number): DragEvent;
|
|
46
|
-
createTopDragEvent(indent?: number): DragEvent<Element>;
|
|
47
|
-
createBottomDragEvent(indent?: number): DragEvent<Element>;
|
|
48
|
-
}
|