@webx-ui/core 0.9.0 → 0.11.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/README.md +21 -3
- package/dist/components/Descriptions/types.d.ts +2 -0
- package/dist/components/SelectionArea/SelectionArea.d.ts +2 -0
- package/dist/components/SelectionArea/types.d.ts +10 -1
- package/dist/components/Steps/Steps.d.ts +7 -2
- package/dist/components/Steps/types.d.ts +5 -0
- package/dist/components/Table/Table.d.ts +3 -2
- package/dist/components/Table/types.d.ts +57 -0
- package/dist/components/Transfer/Transfer.d.ts +57 -0
- package/dist/components/Transfer/index.d.ts +2 -0
- package/dist/components/Transfer/types.d.ts +40 -0
- package/dist/components/Tree/Tree.d.ts +79 -0
- package/dist/components/Tree/index.d.ts +2 -0
- package/dist/components/Tree/types.d.ts +105 -0
- package/dist/components/TreeSelect/TreeSelect.d.ts +47 -0
- package/dist/components/TreeSelect/index.d.ts +2 -0
- package/dist/components/TreeSelect/types.d.ts +76 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/composables/useTreeNodes.d.ts +96 -0
- package/dist/index.js +6143 -4999
- package/dist/index.js.map +1 -1
- package/dist/internal/nodes.d.ts +10 -0
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { MaybeRefOrGetter, Ref } from 'vue';
|
|
2
|
+
export type TreeKey = string | number;
|
|
3
|
+
/** Where a dragged node lands relative to the one it was dropped on. */
|
|
4
|
+
export type TreeDropZone = 'before' | 'after' | 'inside';
|
|
5
|
+
/**
|
|
6
|
+
* How to read one node. Everything else here works through these four, which is what
|
|
7
|
+
* lets the same machinery drive a tree of its own and a table whose rows happen to
|
|
8
|
+
* nest: neither has to agree with the other on what a node looks like.
|
|
9
|
+
*/
|
|
10
|
+
export interface TreeAccessors<T> {
|
|
11
|
+
key: (node: T, path: number[]) => TreeKey;
|
|
12
|
+
children: (node: T) => T[] | undefined;
|
|
13
|
+
/** Called when a branch that had no `children` array needs one. */
|
|
14
|
+
setChildren: (node: T, children: T[]) => void;
|
|
15
|
+
label?: (node: T) => string;
|
|
16
|
+
disabled?: (node: T) => boolean;
|
|
17
|
+
/** Says a node has nothing under it — only needed with `lazy`, where an empty
|
|
18
|
+
* `children` cannot tell "not loaded yet" from "nothing there". */
|
|
19
|
+
leaf?: (node: T) => boolean;
|
|
20
|
+
}
|
|
21
|
+
/** One node and everything about where it sits, kept for the whole tree. */
|
|
22
|
+
export interface TreeEntry<T> {
|
|
23
|
+
node: T;
|
|
24
|
+
key: TreeKey;
|
|
25
|
+
depth: number;
|
|
26
|
+
/** The array this node currently lives in — moving is a splice on it. */
|
|
27
|
+
siblings: T[];
|
|
28
|
+
index: number;
|
|
29
|
+
parent: T | null;
|
|
30
|
+
parentKey: TreeKey | null;
|
|
31
|
+
children: T[];
|
|
32
|
+
}
|
|
33
|
+
/** A node as the screen shows it: visible, in order, at a depth. */
|
|
34
|
+
export interface TreeRow<T> extends TreeEntry<T> {
|
|
35
|
+
expandable: boolean;
|
|
36
|
+
expanded: boolean;
|
|
37
|
+
loading: boolean;
|
|
38
|
+
disabled: boolean;
|
|
39
|
+
/** Matched the filter itself, as opposed to merely leading to a match. */
|
|
40
|
+
matched: boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface UseTreeNodesOptions<T> {
|
|
43
|
+
/**
|
|
44
|
+
* The tree. A getter or a plain array is enough for a tree that is only read; a
|
|
45
|
+
* `ref` is what a tree that can be rearranged wants, since a move splices the array
|
|
46
|
+
* the caller is holding.
|
|
47
|
+
*/
|
|
48
|
+
nodes: MaybeRefOrGetter<T[]>;
|
|
49
|
+
accessors: TreeAccessors<T>;
|
|
50
|
+
/** Keys of the open branches. Owned by the caller, so `v-model:expanded` works. */
|
|
51
|
+
expanded: Ref<TreeKey[]>;
|
|
52
|
+
/** Only branches matching this, and the branches leading to them, are shown. */
|
|
53
|
+
filter?: MaybeRefOrGetter<string | undefined>;
|
|
54
|
+
/** Opening a branch closes the others at its level. */
|
|
55
|
+
accordion?: MaybeRefOrGetter<boolean>;
|
|
56
|
+
/** Children arrive when a branch opens. Requires `load`. */
|
|
57
|
+
lazy?: MaybeRefOrGetter<boolean>;
|
|
58
|
+
load?: (node: T) => T[] | Promise<T[]>;
|
|
59
|
+
/** Vetoes a move before it happens. */
|
|
60
|
+
allowDrop?: (drag: T, drop: T, zone: TreeDropZone) => boolean;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The parts of a tree that have nothing to do with how it looks: what is where, what is
|
|
64
|
+
* open, what a filter leaves standing, and what a move does to the arrays underneath.
|
|
65
|
+
*/
|
|
66
|
+
export declare function useTreeNodes<T>(options: UseTreeNodesOptions<T>): {
|
|
67
|
+
rows: import('vue').ComputedRef<TreeRow<T>[]>;
|
|
68
|
+
entries: import('vue').ComputedRef<Map<TreeKey, TreeEntry<T>>>;
|
|
69
|
+
entry: (key: TreeKey) => TreeEntry<T> | undefined;
|
|
70
|
+
keyOf: (node: T, path?: number[]) => TreeKey;
|
|
71
|
+
filtered: import('vue').ComputedRef<{
|
|
72
|
+
keep: Set<TreeKey>;
|
|
73
|
+
matched: Set<TreeKey>;
|
|
74
|
+
} | null>;
|
|
75
|
+
isExpanded: (key: TreeKey) => boolean;
|
|
76
|
+
expand: (key: TreeKey) => Promise<void>;
|
|
77
|
+
collapse: (key: TreeKey) => void;
|
|
78
|
+
toggle: (key: TreeKey) => void | Promise<void>;
|
|
79
|
+
expandAll: () => void;
|
|
80
|
+
collapseAll: () => void;
|
|
81
|
+
reveal: (key: TreeKey) => void;
|
|
82
|
+
openPath: (keys: TreeKey[]) => Promise<boolean>;
|
|
83
|
+
ancestors: (key: TreeKey) => TreeEntry<T>[];
|
|
84
|
+
path: (key: TreeKey) => TreeEntry<T>[];
|
|
85
|
+
descendants: (key: TreeKey) => TreeEntry<T>[];
|
|
86
|
+
isAncestorOf: (key: TreeKey, other: TreeKey) => boolean;
|
|
87
|
+
canDrop: (dragKey: TreeKey, dropKey: TreeKey, zone: TreeDropZone) => boolean;
|
|
88
|
+
move: (dragKey: TreeKey, dropKey: TreeKey, zone: TreeDropZone) => {
|
|
89
|
+
node: T;
|
|
90
|
+
parent: T | null;
|
|
91
|
+
siblings: T[];
|
|
92
|
+
index: number;
|
|
93
|
+
} | null;
|
|
94
|
+
loading: Ref<Set<TreeKey> & Omit<Set<TreeKey>, keyof Set<any>>, Set<TreeKey> | (Set<TreeKey> & Omit<Set<TreeKey>, keyof Set<any>>)>;
|
|
95
|
+
};
|
|
96
|
+
export type UseTreeNodes<T> = ReturnType<typeof useTreeNodes<T>>;
|