@nexxtmove/ui 1.37.0 → 1.38.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/components/molecules/Tree/Tree.vue.d.ts +25 -0
- package/dist/components/molecules/Tree/tree-drop.d.ts +81 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +786 -508
- package/package.json +1 -1
- package/src/components/molecules/Tree/Tree.vue +573 -72
- package/src/components/molecules/Tree/tree-drop.ts +155 -0
- package/src/index.ts +1 -0
|
@@ -6,12 +6,35 @@ export interface NexxtTreeNode {
|
|
|
6
6
|
icon?: NexxtIconName;
|
|
7
7
|
/** A node with children gets a chevron and can be folded. */
|
|
8
8
|
children?: NexxtTreeNode[];
|
|
9
|
+
/** Whether this node accepts drops when it currently has no children. */
|
|
10
|
+
canHaveChildren?: boolean;
|
|
11
|
+
/** Whether this node can be dragged when the tree's `draggable` prop is enabled. */
|
|
12
|
+
draggable?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface NexxtTreeMove {
|
|
15
|
+
/** The node being moved. */
|
|
16
|
+
id: string;
|
|
17
|
+
/** The node that will contain the moved node, or `null` for the tree root. */
|
|
18
|
+
parentId: string | null;
|
|
19
|
+
/** The zero-based position in the target parent's children. */
|
|
20
|
+
index: number;
|
|
9
21
|
}
|
|
10
22
|
export interface NexxtTreeProps {
|
|
11
23
|
/** The top-level nodes; nest `children` for deeper levels. */
|
|
12
24
|
nodes: NexxtTreeNode[];
|
|
13
25
|
/** Accessible name for the tree, e.g. the heading above it. */
|
|
14
26
|
label: string;
|
|
27
|
+
/** Enables native drag-and-drop for rows and emits the intended new position. */
|
|
28
|
+
draggable?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Decides per spot whether the dragged node may land there, on top of the built-in rules (no
|
|
31
|
+
* drop into its own subtree, only into nodes that can have children). Gets the same shape as
|
|
32
|
+
* the `move` payload. A refused spot shows no ghost row and drops nothing, like letting go
|
|
33
|
+
* outside the tree. It runs on every `dragover` — which the browser keeps firing while the
|
|
34
|
+
* pointer rests — and on every touch move, so keep it cheap and pure: the same spot must always
|
|
35
|
+
* get the same answer.
|
|
36
|
+
*/
|
|
37
|
+
canDrop?: (target: NexxtTreeMove) => boolean;
|
|
15
38
|
}
|
|
16
39
|
export type NexxtTreeSlots = {
|
|
17
40
|
/** Actions at the end of a row, e.g. a delete button. Hidden until the row is hovered or holds focus, and always shown on a coarse pointer. Clicks and keys inside it never reach the tree, so they neither select the row nor move focus. Put `tabindex` on every focusable element in it: it is `0` only on the row that is the tree's tab stop, which keeps one extra Tab stop for the whole tree. Keep the content at most 24px high, or the rows grow. */
|
|
@@ -31,9 +54,11 @@ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
|
31
54
|
declare const __VLS_base: import('vue').DefineComponent<__VLS_PublicProps, {
|
|
32
55
|
focusNode: (id: string) => Promise<boolean>;
|
|
33
56
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
57
|
+
move: (move: NexxtTreeMove) => any;
|
|
34
58
|
"update:selected": (value: string | null) => any;
|
|
35
59
|
"update:collapsed": (value: string[]) => any;
|
|
36
60
|
}, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
61
|
+
onMove?: ((move: NexxtTreeMove) => any) | undefined;
|
|
37
62
|
"onUpdate:selected"?: ((value: string | null) => any) | undefined;
|
|
38
63
|
"onUpdate:collapsed"?: ((value: string[]) => any) | undefined;
|
|
39
64
|
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { NexxtTreeNode } from './Tree.vue';
|
|
2
|
+
/** A visible row of the tree, in document order. */
|
|
3
|
+
export interface TreeRow {
|
|
4
|
+
node: NexxtTreeNode;
|
|
5
|
+
depth: number;
|
|
6
|
+
parentId: string | null;
|
|
7
|
+
expandable: boolean;
|
|
8
|
+
canHaveChildren: boolean;
|
|
9
|
+
draggable: boolean;
|
|
10
|
+
expanded: boolean;
|
|
11
|
+
/** One-based position among its siblings. */
|
|
12
|
+
position: number;
|
|
13
|
+
setSize: number;
|
|
14
|
+
}
|
|
15
|
+
export type DropMarker = 'before' | 'inside' | 'after';
|
|
16
|
+
export interface TreeDrop {
|
|
17
|
+
/** The row the pointer was over when this spot was picked. */
|
|
18
|
+
rowId: string;
|
|
19
|
+
parentId: string | null;
|
|
20
|
+
index: number;
|
|
21
|
+
marker: DropMarker;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Where a row sits with the ghost row taken out, relative to the top of the tree. `bottom` takes
|
|
25
|
+
* in the gap below the row: a gap belongs to the row above it, so moving across it never reads
|
|
26
|
+
* as leaving the tree.
|
|
27
|
+
*/
|
|
28
|
+
export interface RestSlot {
|
|
29
|
+
id: string;
|
|
30
|
+
top: number;
|
|
31
|
+
height: number;
|
|
32
|
+
bottom: number;
|
|
33
|
+
}
|
|
34
|
+
export interface DropLayout {
|
|
35
|
+
slots: RestSlot[];
|
|
36
|
+
/** The ghost row as it is laid out now, gap included; `null` while there is none. */
|
|
37
|
+
ghost: {
|
|
38
|
+
top: number;
|
|
39
|
+
bottom: number;
|
|
40
|
+
} | null;
|
|
41
|
+
}
|
|
42
|
+
/** `keep` leaves the current spot as it is: the pointer is on the ghost row, or there are no rows. */
|
|
43
|
+
export type DropHit = {
|
|
44
|
+
kind: 'keep';
|
|
45
|
+
} | {
|
|
46
|
+
kind: 'row';
|
|
47
|
+
id: string;
|
|
48
|
+
ratio: number;
|
|
49
|
+
};
|
|
50
|
+
export declare const containsNode: (node: NexxtTreeNode, id: string) => boolean;
|
|
51
|
+
export declare const findNode: (nodes: NexxtTreeNode[], id: string) => NexxtTreeNode | null;
|
|
52
|
+
/**
|
|
53
|
+
* Reads the pointer against where the rows land without the ghost row, not against what is under
|
|
54
|
+
* it now. The ghost pushes rows aside, so reading what is under the pointer would find a shifted
|
|
55
|
+
* row or the ghost itself, pick another spot, move the ghost and flicker. Measured this way the
|
|
56
|
+
* same pointer always gives the same answer, however the ghost moves.
|
|
57
|
+
*
|
|
58
|
+
* @param layout - The rows at rest and the ghost row as it is laid out now.
|
|
59
|
+
* @param y - The pointer, relative to the top of the tree.
|
|
60
|
+
*/
|
|
61
|
+
export declare const hitTest: ({ slots, ghost }: DropLayout, y: number) => DropHit;
|
|
62
|
+
/**
|
|
63
|
+
* The spot a pointer at `ratio` of `row` stands for. A group splits into before (top 30%),
|
|
64
|
+
* inside and after (bottom 30%), a leaf into before and after at the middle. Inside always lands
|
|
65
|
+
* as the first child, right under the group row, so the ghost shows up next to the pointer. The
|
|
66
|
+
* dragged node and everything inside it are no target at all.
|
|
67
|
+
*/
|
|
68
|
+
export declare const resolveDrop: (row: TreeRow, ratio: number, moving: NexxtTreeNode) => TreeDrop | null;
|
|
69
|
+
/** A spot where the dragged row already is: dropping there changes nothing, so it is no target. */
|
|
70
|
+
export declare const isNoOp: (drop: TreeDrop, source: TreeRow) => boolean;
|
|
71
|
+
/** Two spots are the same when they land the node in the same place, whichever row picked them. */
|
|
72
|
+
export declare const samePlace: (a: TreeDrop | null, b: TreeDrop | null) => boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Where the ghost row goes among the visible rows, and how deep. Right before the row of the
|
|
75
|
+
* sibling now at `index`, or after the last visible row inside the parent when `index` is past
|
|
76
|
+
* its last child. `null` for a spot inside a collapsed group: that group row marks itself.
|
|
77
|
+
*/
|
|
78
|
+
export declare const ghostSlot: (rows: TreeRow[], nodes: NexxtTreeNode[], drop: TreeDrop | null) => {
|
|
79
|
+
at: number;
|
|
80
|
+
depth: number;
|
|
81
|
+
} | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type { NexxtTabItem } from './components/molecules/Tabs/Tabs.vue';
|
|
|
8
8
|
export type { NexxtPageCardProps, NexxtPageCardSlots, } from './components/molecules/PageCard/PageCard.vue';
|
|
9
9
|
export type { NexxtPageMockupType } from './components/molecules/PageMockup/PageMockup.vue';
|
|
10
10
|
export type { NexxtPickerGroupData, NexxtPickerItemData, } from './components/molecules/PickerList/PickerList.vue';
|
|
11
|
-
export type { NexxtTreeNode, NexxtTreeProps, NexxtTreeSlots, } from './components/molecules/Tree/Tree.vue';
|
|
11
|
+
export type { NexxtTreeMove, NexxtTreeNode, NexxtTreeProps, NexxtTreeSlots, } from './components/molecules/Tree/Tree.vue';
|
|
12
12
|
export type { NexxtPlaceholderGroup, NexxtPlaceholderInputMessages, NexxtPlaceholderInputProps, } from './components/molecules/PlaceholderInput/PlaceholderInput.vue';
|
|
13
13
|
export type { EditorAlignItemsMessages, EditorAlignItemsValue, } from './components/editor/molecules/EditorAlignItems/EditorAlignItems.vue';
|
|
14
14
|
export type { EditorBackgroundSizeMessages, EditorBackgroundSizeValue, } from './components/editor/molecules/EditorBackgroundSize/EditorBackgroundSize.vue';
|