@cocoar/vue-ui 2.6.0 → 2.7.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/listbox/CoarListbox.vue.d.ts.map +1 -1
- package/dist/components/tree/CoarTree.vue.d.ts +98 -3
- package/dist/components/tree/CoarTree.vue.d.ts.map +1 -1
- package/dist/components/tree/CoarTreeNode.vue.d.ts +6 -11
- package/dist/components/tree/CoarTreeNode.vue.d.ts.map +1 -1
- package/dist/components/tree/index.d.ts +2 -2
- package/dist/components/tree/index.d.ts.map +1 -1
- package/dist/components/tree/internal/selection.d.ts +58 -0
- package/dist/components/tree/internal/selection.d.ts.map +1 -0
- package/dist/components/tree/tree-builder.d.ts +198 -12
- package/dist/components/tree/tree-builder.d.ts.map +1 -1
- package/dist/components/tree/tree-types.d.ts +161 -1
- package/dist/components/tree/tree-types.d.ts.map +1 -1
- package/dist/components/tree/useTree.d.ts +1 -1
- package/dist/components/tree/useTree.d.ts.map +1 -1
- package/dist/composables/useVirtualList.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1492 -770
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoarListbox.vue.d.ts","sourceRoot":"","sources":["../../../src/components/listbox/CoarListbox.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CoarListbox.vue.d.ts","sourceRoot":"","sources":["../../../src/components/listbox/CoarListbox.vue"],"names":[],"mappings":"AAg9BA,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,yBAAyB,EACzB,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,SAAS,CAAC;AAIjB,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,OAAO;IAC3C,uBAAuB;IACvB,OAAO,CAAC,EAAE,iBAAiB,CAAC,CAAC,C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AAE;qBACzB,MAAM,GAAG,IAAI;mBACf,MAAM,GAAG,IAAI;kBACd,OAAO;;eAID,SAAS,iBAAiB,CAAC,CAAC,CAAC,EAAE;iBAAW,MAAM,GAAG,IAAI;mEAi3BlC;EAEvC,KACQ,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AAh7BzE,wBAg7B4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
|
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
import { CoarTreeDropPosition, CoarTreeFilesDropEvent, CoarTreeNodeMoveEvent, CoarTreeNodeSlotProps, CoarTreeRenameEvent, CoarTreeVirtualizeProp } from './tree-types';
|
|
1
|
+
import { CoarTreeDensity, CoarTreeDropPosition, CoarTreeFilesDropEvent, CoarTreeFilterMode, CoarTreeLabels, CoarTreeLoadChildrenContext, CoarTreeLoadErrorEvent, CoarTreeNodeMoveEvent, CoarTreeNodeSlotProps, CoarTreeRenameEvent, CoarTreeSelectEvent, CoarTreeSelectionMode, CoarTreeVirtualizeProp } from './tree-types';
|
|
2
2
|
import { TreeBuilder } from './tree-builder';
|
|
3
3
|
declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
4
|
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
|
|
5
|
+
readonly onSelect?: ((payload: CoarTreeSelectEvent<T>) => any) | undefined;
|
|
5
6
|
readonly "onUpdate:expanded"?: ((value: Set<string>) => any) | undefined;
|
|
6
7
|
readonly "onUpdate:selected"?: ((value: string | null) => any) | undefined;
|
|
8
|
+
readonly "onUpdate:selectedIds"?: ((value: Set<string>) => any) | undefined;
|
|
9
|
+
readonly "onUpdate:checkedIds"?: ((value: Set<string>) => any) | undefined;
|
|
7
10
|
readonly onActivate?: ((node: T) => any) | undefined;
|
|
8
11
|
readonly "onFiles-drop"?: ((payload: CoarTreeFilesDropEvent<T>) => any) | undefined;
|
|
9
12
|
readonly "onNode-move"?: ((payload: CoarTreeNodeMoveEvent<T>) => any) | undefined;
|
|
10
13
|
readonly onRename?: ((payload: CoarTreeRenameEvent<T>) => any) | undefined;
|
|
11
14
|
readonly "onRename-cancel"?: ((node: T) => any) | undefined;
|
|
15
|
+
readonly "onLoad-error"?: ((payload: CoarTreeLoadErrorEvent<T>) => any) | undefined;
|
|
12
16
|
readonly "onContext-menu"?: ((node: T | null, ev: MouseEvent) => any) | undefined;
|
|
13
|
-
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onUpdate:expanded" | "onUpdate:selected" | "onActivate" | "onFiles-drop" | "onNode-move" | "onRename" | "onRename-cancel" | "onContext-menu"> & ({
|
|
17
|
+
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onSelect" | "onUpdate:expanded" | "onUpdate:selected" | "onUpdate:selectedIds" | "onUpdate:checkedIds" | "onActivate" | "onFiles-drop" | "onNode-move" | "onRename" | "onRename-cancel" | "onLoad-error" | "onContext-menu"> & ({
|
|
14
18
|
expanded?: Set<string>;
|
|
15
19
|
selected?: string | null;
|
|
20
|
+
selectedIds?: Set<string>;
|
|
21
|
+
checkedIds?: Set<string>;
|
|
16
22
|
} & {
|
|
17
23
|
/** Fluent builder from `useTree()`. When set, the other config props are ignored. */
|
|
18
24
|
builder?: TreeBuilder<T>;
|
|
@@ -21,11 +27,66 @@ declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>
|
|
|
21
27
|
getChildren?: (node: T) => readonly T[] | null | undefined;
|
|
22
28
|
getLabel?: (node: T) => string;
|
|
23
29
|
isExpandable?: (node: T) => boolean;
|
|
30
|
+
/** Mark nodes non-interactive (no select/activate/check/keyboard-focus; `aria-disabled`). */
|
|
31
|
+
isDisabled?: (node: T) => boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Lazily fetch a node's children on first expand. The 2nd arg carries an
|
|
34
|
+
* `AbortSignal` that fires if the folder collapses / leaves the tree. See
|
|
35
|
+
* the builder's `loadChildren`.
|
|
36
|
+
*/
|
|
37
|
+
loadChildren?: (node: T, ctx: CoarTreeLoadChildrenContext) => void | Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Max simultaneous in-flight `loadChildren` calls; extra ones queue. `0`
|
|
40
|
+
* (default) = unlimited. Set a small number (e.g. 6) for rate-limited
|
|
41
|
+
* backends so an expand-all / state-restore can't fan out unbounded.
|
|
42
|
+
*/
|
|
43
|
+
maxConcurrentLoads?: number;
|
|
24
44
|
draggable?: boolean | ((node: T) => boolean);
|
|
25
45
|
canDrop?: (source: T, target: T | null, position: CoarTreeDropPosition) => boolean;
|
|
46
|
+
/** Custom drag ghost for a node: return an `HTMLElement` or an HTML string (else the default row image). */
|
|
47
|
+
getDragImage?: (node: T) => HTMLElement | string | null | undefined;
|
|
48
|
+
/** Fire `activate` on a single click too (not only double-click / Enter). Default false. */
|
|
49
|
+
activateOnClick?: boolean;
|
|
26
50
|
acceptsFiles?: boolean;
|
|
27
51
|
autoExpandDelay?: number;
|
|
28
52
|
virtualize?: CoarTreeVirtualizeProp;
|
|
53
|
+
/**
|
|
54
|
+
* Selection behavior: `'single'` (default, `v-model:selected`), `'multiple'`
|
|
55
|
+
* (`v-model:selectedIds`, Ctrl/Shift/Ctrl+A), or `'checkbox'` (per-row
|
|
56
|
+
* tri-state checkbox, `v-model:checkedIds`, independent of the highlight).
|
|
57
|
+
*/
|
|
58
|
+
selectionMode?: CoarTreeSelectionMode;
|
|
59
|
+
/**
|
|
60
|
+
* Checkbox mode only: when `true`, checks don't cascade to parent/children and
|
|
61
|
+
* nothing is ever indeterminate. Default `false` (cascade + tri-state).
|
|
62
|
+
*/
|
|
63
|
+
checkStrictly?: boolean;
|
|
64
|
+
/** Row density (`xs`/`s`/`m`/`l`, default `m`). Sets the spacing CSS variables. */
|
|
65
|
+
density?: CoarTreeDensity;
|
|
66
|
+
/** Accessible name for the tree (`aria-label` on the `role="tree"` element). */
|
|
67
|
+
ariaLabel?: string;
|
|
68
|
+
/** Id of an external label element (`aria-labelledby` on the `role="tree"` element). */
|
|
69
|
+
ariaLabelledby?: string;
|
|
70
|
+
/** Override built-in UI / screen-reader strings for i18n. Unset fields use English defaults. */
|
|
71
|
+
labels?: Partial<CoarTreeLabels>;
|
|
72
|
+
/**
|
|
73
|
+
* Search-hit ids. The tree exposes `isMatch` / `isMatchAncestor` to the slot
|
|
74
|
+
* (for highlighting) and auto-expands the ancestors of every match so hits
|
|
75
|
+
* are visible.
|
|
76
|
+
*/
|
|
77
|
+
matchedIds?: Set<string>;
|
|
78
|
+
/**
|
|
79
|
+
* With `matchedIds` set, hide non-matches (off by default = highlight-only).
|
|
80
|
+
* What's kept around a match is controlled by `filterMode`.
|
|
81
|
+
*/
|
|
82
|
+
filter?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* How `filter` prunes (mirrors PrimeVue). `'strict'` (default) = matches +
|
|
85
|
+
* their ancestor path only (a matched folder's non-matching children stay
|
|
86
|
+
* hidden — the VS Code / react-arborist convention). `'lenient'` = a matched
|
|
87
|
+
* folder reveals its whole subtree. See {@link CoarTreeFilterMode}.
|
|
88
|
+
*/
|
|
89
|
+
filterMode?: CoarTreeFilterMode;
|
|
29
90
|
/**
|
|
30
91
|
* Opt into the built-in inline rename UI. With this on, `api.startRename(id)`
|
|
31
92
|
* + `@rename` work and `<CoarTreeNodeLabel>` swaps to an `<input>` while the
|
|
@@ -33,9 +94,29 @@ declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>
|
|
|
33
94
|
* label component stays a plain `<span>` (back-compat for existing consumers).
|
|
34
95
|
*/
|
|
35
96
|
renamable?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Suppress the built-in spinner the tree shows in the chevron while a node's
|
|
99
|
+
* children lazily load (see `loadChildren`). Set this when you render your
|
|
100
|
+
* own loading indicator from the `isLoading` slot prop — e.g. replacing the
|
|
101
|
+
* row icon with a spinner.
|
|
102
|
+
*/
|
|
103
|
+
hideLoadingSpinner?: boolean;
|
|
36
104
|
}) & Partial<{}>> & import('vue').PublicProps;
|
|
37
105
|
expose(exposed: import('vue').ShallowUnwrapRef<{
|
|
106
|
+
/**
|
|
107
|
+
* Move keyboard focus to a node. The template-ref form has been focus-only
|
|
108
|
+
* since 2.4.0 (note: the builder `api.focusNode` selects + focuses). Prefer
|
|
109
|
+
* `selectNode` / `revealNode` for explicit intent.
|
|
110
|
+
*/
|
|
38
111
|
focusNode(id: string): void;
|
|
112
|
+
/** Highlight-select AND focus a node (the "reveal & select" action). */
|
|
113
|
+
selectNode(id: string): void;
|
|
114
|
+
/**
|
|
115
|
+
* Force `loadChildren` to (re)run for `id` — retry after an error or refresh
|
|
116
|
+
* an already-loaded folder. No-op if `loadChildren` isn't set or `id` isn't
|
|
117
|
+
* in the tree.
|
|
118
|
+
*/
|
|
119
|
+
reloadChildren: (id: string) => void;
|
|
39
120
|
/**
|
|
40
121
|
* Enter inline-rename mode on `id`. No-op if `:renamable` isn't set or
|
|
41
122
|
* the id isn't in the visible-row list. Use from context menu items,
|
|
@@ -43,6 +124,18 @@ declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>
|
|
|
43
124
|
* the next frame.
|
|
44
125
|
*/
|
|
45
126
|
startRename: (id: string) => void;
|
|
127
|
+
/** Expand every expandable, currently-loaded node. */
|
|
128
|
+
expandAll: () => void;
|
|
129
|
+
/** Collapse everything. */
|
|
130
|
+
collapseAll: () => void;
|
|
131
|
+
/** Expand all loaded ancestors of `id` so its row becomes visible. */
|
|
132
|
+
expandTo: (id: string) => void;
|
|
133
|
+
/** Scroll a node into view without changing focus or selection. */
|
|
134
|
+
revealNode: (id: string) => void;
|
|
135
|
+
/** Resolve a node by id from the loaded tree, or `null`. */
|
|
136
|
+
getNode: (id: string) => T | null;
|
|
137
|
+
/** Move a node (keyboard / a11y equivalent of drag-drop); runs cycle + canDrop guards. */
|
|
138
|
+
moveNode: (sourceId: string, targetId: string | null, position: CoarTreeDropPosition) => boolean;
|
|
46
139
|
}>): void;
|
|
47
140
|
attrs: any;
|
|
48
141
|
slots: Readonly<{
|
|
@@ -54,12 +147,14 @@ declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>
|
|
|
54
147
|
};
|
|
55
148
|
emit: {
|
|
56
149
|
(e: "activate", node: T): void;
|
|
150
|
+
(e: "select", payload: CoarTreeSelectEvent<T>): void;
|
|
57
151
|
(e: "context-menu", node: T | null, ev: MouseEvent): void;
|
|
58
152
|
(e: "files-drop", payload: CoarTreeFilesDropEvent<T>): void;
|
|
59
153
|
(e: "node-move", payload: CoarTreeNodeMoveEvent<T>): void;
|
|
60
154
|
(e: "rename", payload: CoarTreeRenameEvent<T>): void;
|
|
61
155
|
(e: "rename-cancel", node: T): void;
|
|
62
|
-
|
|
156
|
+
(e: "load-error", payload: CoarTreeLoadErrorEvent<T>): void;
|
|
157
|
+
} & (((evt: "update:expanded", value: Set<string>) => void) & ((evt: "update:selected", value: string | null) => void) & ((evt: "update:selectedIds", value: Set<string>) => void) & ((evt: "update:checkedIds", value: Set<string>) => void));
|
|
63
158
|
}>) => import('vue').VNode & {
|
|
64
159
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
65
160
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoarTree.vue.d.ts","sourceRoot":"","sources":["../../../src/components/tree/CoarTree.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CoarTree.vue.d.ts","sourceRoot":"","sources":["../../../src/components/tree/Coar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x7DM,qBAAqB,CAAC,CAAC,CAAC,GAAG,OAAO;iBACxC,OAAO;;uBADD,qBAAqB,CAAC,CAAC,CAAC,GAAG,OAAO;iBACxC,OAAO;;UAy7DX;YAt8DD,UAAU,QAAQ,CAAC,GAAG,IAAI;YAC1B,QAAQ,WAAW,mBAAmB,CAAC,CAAC,CAAC,GAAG,IAAI;YAChD,cAAc,QAAQ,CAAC,GAAG,IAAI,MAAM,UAAU,GAAG,IAAI;YACrD,YAAY,WAAW,sBAAsB,CAAC,CAAC,CAAC,GAAG,IAAI;YACvD,WAAW,WAAW,qBAAqB,CAAC,CAAC,CAAC,GAAG,IAAI;YACrD,QAAQ,WAAW,mBAAmB,CAAC,CAAC,CAAC,GAAG,IAAI;YAChD,eAAe,QAAQ,CAAC,GAAG,IAAI;YAC/B,YAAY,WAAW,sBAAsB,CAAC,CAAC,CAAC,GAAG,IAAI;kPA+7DlB;EAEvC,KACQ,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AAzkEzE,wBAykE4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
|
|
@@ -1,31 +1,24 @@
|
|
|
1
|
-
import { CoarTreeDropPosition } from './tree-types';
|
|
2
1
|
declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
3
2
|
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
|
|
4
3
|
readonly "onRow-click"?: ((node: T, ev: MouseEvent) => any) | undefined;
|
|
5
4
|
readonly "onRow-dblclick"?: ((node: T, ev: MouseEvent) => any) | undefined;
|
|
6
5
|
readonly "onRow-context-menu"?: ((node: T, ev: MouseEvent) => any) | undefined;
|
|
7
|
-
readonly "onRow-
|
|
6
|
+
readonly "onRow-check-toggle"?: ((node: T) => any) | undefined;
|
|
7
|
+
readonly "onRow-retry"?: ((node: T) => any) | undefined;
|
|
8
8
|
readonly "onChevron-click"?: ((node: T) => any) | undefined;
|
|
9
|
+
readonly "onRow-dragstart"?: ((node: T, ev: DragEvent) => any) | undefined;
|
|
9
10
|
readonly "onRow-dragend"?: ((node: T) => any) | undefined;
|
|
10
11
|
readonly "onRow-dragleave"?: ((node: T, ev: DragEvent) => any) | undefined;
|
|
11
12
|
readonly "onRow-dragover"?: ((node: T, el: HTMLElement, ev: DragEvent) => any) | undefined;
|
|
12
13
|
readonly "onRow-drop"?: ((node: T, el: HTMLElement, ev: DragEvent) => any) | undefined;
|
|
13
|
-
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onRow-click" | "onRow-dblclick" | "onRow-context-menu" | "onRow-
|
|
14
|
+
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onRow-click" | "onRow-dblclick" | "onRow-context-menu" | "onRow-check-toggle" | "onRow-retry" | "onChevron-click" | "onRow-dragstart" | "onRow-dragend" | "onRow-dragleave" | "onRow-dragover" | "onRow-drop"> & {
|
|
14
15
|
node: T;
|
|
15
16
|
nodeId: string;
|
|
16
17
|
depth: number;
|
|
17
18
|
isExpandable: boolean;
|
|
18
|
-
isExpanded: boolean;
|
|
19
|
-
isSelected: boolean;
|
|
20
|
-
isFocused: boolean;
|
|
21
|
-
isRenaming: boolean;
|
|
22
19
|
draggable: boolean;
|
|
23
20
|
posInSet: number;
|
|
24
21
|
setSize: number;
|
|
25
|
-
/** Drop-position indicator when an internal drag is over this row. */
|
|
26
|
-
dropIndicator: CoarTreeDropPosition | null;
|
|
27
|
-
/** Whole-row highlight when an OS file drag is over this folder. */
|
|
28
|
-
fileDropActive: boolean;
|
|
29
22
|
} & Partial<{}>> & import('vue').PublicProps;
|
|
30
23
|
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
31
24
|
attrs: any;
|
|
@@ -34,6 +27,8 @@ declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>
|
|
|
34
27
|
(e: "row-click", node: T, ev: MouseEvent): void;
|
|
35
28
|
(e: "row-dblclick", node: T, ev: MouseEvent): void;
|
|
36
29
|
(e: "row-context-menu", node: T, ev: MouseEvent): void;
|
|
30
|
+
(e: "row-check-toggle", node: T): void;
|
|
31
|
+
(e: "row-retry", node: T): void;
|
|
37
32
|
(e: "chevron-click", node: T): void;
|
|
38
33
|
(e: "row-dragstart", node: T, ev: DragEvent): void;
|
|
39
34
|
(e: "row-dragend", node: T): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoarTreeNode.vue.d.ts","sourceRoot":"","sources":["../../../src/components/tree/CoarTreeNode.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CoarTreeNode.vue.d.ts","sourceRoot":"","sources":["../../../src/components/tree/CoarTreeNode.vue"],"names":[],"mappings":"yBAwXiB,CAAC,EACjB,aAAa,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,EAC9D,YAAY,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,EAC3G,eAAe,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,EACjE;WAoWO,mBAAmB,CAAC;;;;;;;;;;;;;cAlWpB,CAAC;gBACC,MAAM;eACP,MAAM;sBACC,OAAO;mBACV,OAAO;kBACR,MAAM;iBACP,MAAM;mBA4V6E,CAAC,4BAA2B;oBACzG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;;YApTL,WAAW,QAAQ,CAAC,MAAM,UAAU,GAAG,IAAI;YAC3C,cAAc,QAAQ,CAAC,MAAM,UAAU,GAAG,IAAI;YAC9C,kBAAkB,QAAQ,CAAC,MAAM,UAAU,GAAG,IAAI;YAClD,kBAAkB,QAAQ,CAAC,GAAG,IAAI;YAClC,WAAW,QAAQ,CAAC,GAAG,IAAI;YAC3B,eAAe,QAAQ,CAAC,GAAG,IAAI;YAC/B,eAAe,QAAQ,CAAC,MAAM,SAAS,GAAG,IAAI;YAC9C,aAAa,QAAQ,CAAC,GAAG,IAAI;YAC7B,cAAc,QAAQ,CAAC,MAAM,WAAW,MAAM,SAAS,GAAG,IAAI;YAC9D,eAAe,QAAQ,CAAC,MAAM,SAAS,GAAG,IAAI;YAC9C,UAAU,QAAQ,CAAC,MAAM,WAAW,MAAM,SAAS,GAAG,IAAI;;EA8S5D,KACQ,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AA/WzE,wBA+W4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { default as CoarTree } from './CoarTree.vue';
|
|
2
2
|
export { default as CoarTreeNodeLabel } from './CoarTreeNodeLabel.vue';
|
|
3
|
-
export type { CoarTreeDropPosition, CoarTreeFilesDropEvent, CoarTreeNodeMoveEvent, CoarTreeNodeSlotProps, CoarTreeRenameContext, CoarTreeRenameEvent, CoarTreeMenuItem, CoarTreeMenuEntry, } from './tree-types';
|
|
4
|
-
export { COAR_TREE_DRAG_MIME, COAR_TREE_RENAME_KEY, COAR_TREE_ROW_ID_KEY } from './tree-types';
|
|
3
|
+
export type { CoarTreeDensity, CoarTreeDropPosition, CoarTreeFilesDropEvent, CoarTreeFilterMode, CoarTreeLabels, CoarTreeLoadChildrenContext, CoarTreeLoadErrorEvent, CoarTreeNodeMoveEvent, CoarTreeNodeSlotProps, CoarTreeRenameContext, CoarTreeRenameEvent, CoarTreeSelectEvent, CoarTreeSelectionMode, CoarTreeMenuItem, CoarTreeMenuEntry, CoarTreeVirtualizeProp, CoarTreeVirtualOptions, } from './tree-types';
|
|
4
|
+
export { COAR_TREE_DRAG_MIME, COAR_TREE_RENAME_KEY, COAR_TREE_ROW_ID_KEY, DEFAULT_TREE_LABELS, } from './tree-types';
|
|
5
5
|
export { useTree } from './useTree';
|
|
6
6
|
export { TreeBuilder } from './tree-builder';
|
|
7
7
|
export type { TreeApi, TreeBuilderState } from './tree-builder';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/tree/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACvE,YAAY,EACV,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/tree/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACvE,YAAY,EACV,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,EACd,2BAA2B,EAC3B,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure checkbox-cascade engine for `<CoarTree :selection-mode="'checkbox'">`.
|
|
3
|
+
*
|
|
4
|
+
* All functions are side-effect-free and operate on a {@link TreeIndex} (a flat
|
|
5
|
+
* id→relations view of the *loaded* tree), so they're trivially unit-testable
|
|
6
|
+
* and never touch Vue reactivity. The component builds the index from its
|
|
7
|
+
* config and feeds the result back into the `checkedIds` model.
|
|
8
|
+
*
|
|
9
|
+
* **Model.** `checkedIds` holds every node considered fully checked — leaves AND
|
|
10
|
+
* parents whose loaded children are all checked. The invariant maintained by
|
|
11
|
+
* {@link applyCheckToggle} is: *a parent is in the set iff all its loaded
|
|
12
|
+
* children are*. "Indeterminate" (some-but-not-all descendants checked) is never
|
|
13
|
+
* stored — it's derived on demand by {@link computeIndeterminate}.
|
|
14
|
+
*
|
|
15
|
+
* **Lazy inheritance.** A checked folder whose children aren't loaded yet keeps
|
|
16
|
+
* its id in the set; when the children arrive, {@link reconcileChecked}
|
|
17
|
+
* propagates the check down to them. See `loadChildren` on the tree.
|
|
18
|
+
*
|
|
19
|
+
* `checkStrictly` mode bypasses cascade entirely — callers just add/remove the
|
|
20
|
+
* single id and skip reconcile + indeterminate.
|
|
21
|
+
*/
|
|
22
|
+
/** Flat, O(1)-lookup view of the loaded tree. Unloaded/leaf nodes map to `[]`. */
|
|
23
|
+
export interface TreeIndex {
|
|
24
|
+
/** Loaded child ids for each node id, in order. */
|
|
25
|
+
children: Map<string, string[]>;
|
|
26
|
+
/** Parent id for each node id; root nodes map to `null`. */
|
|
27
|
+
parent: Map<string, string | null>;
|
|
28
|
+
/** All node ids in DFS pre-order (parent before its children). */
|
|
29
|
+
order: string[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Build a {@link TreeIndex} from the loaded node tree. Walks every node reachable
|
|
33
|
+
* via `getChildren` (regardless of expand state) so cascade works on collapsed
|
|
34
|
+
* subtrees too. Unloaded lazy folders (`getChildren` → null/undefined) contribute
|
|
35
|
+
* no children, so cascade never descends into data that doesn't exist yet.
|
|
36
|
+
*/
|
|
37
|
+
export declare function indexTree<T>(roots: readonly T[], getId: (n: T) => string, getChildren: (n: T) => readonly T[] | null | undefined): TreeIndex;
|
|
38
|
+
/**
|
|
39
|
+
* Toggle `id` (and its whole loaded subtree) to `value`, then re-normalize every
|
|
40
|
+
* ancestor so a parent ends up checked exactly when all its loaded children are.
|
|
41
|
+
* Returns a NEW set; the input is left untouched.
|
|
42
|
+
*/
|
|
43
|
+
export declare function applyCheckToggle(checked: ReadonlySet<string>, id: string, value: boolean, index: TreeIndex): Set<string>;
|
|
44
|
+
/**
|
|
45
|
+
* Propagate checks downward from every checked node. The only mutation is
|
|
46
|
+
* *adding* inherited descendants, so it's safe to run on any tree change: newly
|
|
47
|
+
* loaded children under a checked folder become checked, and a consumer that
|
|
48
|
+
* sets `checkedIds` to just a few ancestor ids gets the full closure for free.
|
|
49
|
+
* Returns the input set unchanged (same reference) when nothing was added.
|
|
50
|
+
*/
|
|
51
|
+
export declare function reconcileChecked(checked: ReadonlySet<string>, index: TreeIndex): Set<string>;
|
|
52
|
+
/**
|
|
53
|
+
* Derive the indeterminate set: nodes NOT in `checked` that have at least one
|
|
54
|
+
* checked descendant. Walks in reverse DFS order (children before parents) so
|
|
55
|
+
* each node aggregates its already-computed subtree in one pass.
|
|
56
|
+
*/
|
|
57
|
+
export declare function computeIndeterminate(checked: ReadonlySet<string>, index: TreeIndex): Set<string>;
|
|
58
|
+
//# sourceMappingURL=selection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection.d.ts","sourceRoot":"","sources":["../../../../src/components/tree/internal/selection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,kFAAkF;AAClF,MAAM,WAAW,SAAS;IACxB,mDAAmD;IACnD,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAChC,4DAA4D;IAC5D,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IACnC,kEAAkE;IAClE,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,EACzB,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,EACvB,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,SAAS,CAAC,EAAE,GAAG,IAAI,GAAG,SAAS,GACrD,SAAS,CAwBX;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,EAC5B,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,SAAS,GACf,GAAG,CAAC,MAAM,CAAC,CAwBb;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,CAe5F;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,CAahG"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MaybeRefOrGetter, Ref } from 'vue';
|
|
2
|
-
import { CoarTreeDropPosition, CoarTreeFilesDropEvent, CoarTreeMenuEntry, CoarTreeNodeMoveEvent, CoarTreeVirtualizeProp } from './tree-types';
|
|
2
|
+
import { CoarTreeDensity, CoarTreeDropPosition, CoarTreeFilesDropEvent, CoarTreeFilterMode, CoarTreeLabels, CoarTreeLoadChildrenContext, CoarTreeLoadErrorEvent, CoarTreeMenuEntry, CoarTreeNodeMoveEvent, CoarTreeRenameEvent, CoarTreeSelectEvent, CoarTreeSelectionMode, CoarTreeVirtualizeProp } from './tree-types';
|
|
3
3
|
/**
|
|
4
4
|
* Internal mutable state owned by the builder. Held as `shallowReactive` so
|
|
5
5
|
* mid-session mutations (e.g. `builder.draggable(true)` after mount) trigger
|
|
@@ -11,16 +11,47 @@ export interface TreeBuilderState<T> {
|
|
|
11
11
|
getChildren?: (n: T) => readonly T[] | null | undefined;
|
|
12
12
|
getLabel?: (n: T) => string;
|
|
13
13
|
isExpandable?: (n: T) => boolean;
|
|
14
|
+
isDisabled?: (n: T) => boolean;
|
|
14
15
|
draggable: MaybeRefOrGetter<boolean | ((n: T) => boolean)>;
|
|
15
16
|
canDrop?: (s: T, t: T | null, p: CoarTreeDropPosition) => boolean;
|
|
17
|
+
getDragImage?: (n: T) => HTMLElement | string | null | undefined;
|
|
18
|
+
activateOnClick: MaybeRefOrGetter<boolean>;
|
|
16
19
|
acceptsFiles: MaybeRefOrGetter<boolean>;
|
|
17
20
|
autoExpandDelay: MaybeRefOrGetter<number>;
|
|
18
21
|
virtualize: MaybeRefOrGetter<CoarTreeVirtualizeProp>;
|
|
22
|
+
hideLoadingSpinner: MaybeRefOrGetter<boolean>;
|
|
23
|
+
/** Opt into the built-in inline-rename UI (see `renamable` setter). */
|
|
24
|
+
renamable: MaybeRefOrGetter<boolean>;
|
|
25
|
+
onRename?: (e: CoarTreeRenameEvent<T>) => void;
|
|
26
|
+
onRenameCancel?: (node: T) => void;
|
|
27
|
+
selectionMode: MaybeRefOrGetter<CoarTreeSelectionMode>;
|
|
28
|
+
/** Checkbox-mode only: independent parent/child checks, no cascade / indeterminate. */
|
|
29
|
+
checkStrictly: MaybeRefOrGetter<boolean>;
|
|
30
|
+
density: MaybeRefOrGetter<CoarTreeDensity>;
|
|
31
|
+
ariaLabel: MaybeRefOrGetter<string | undefined>;
|
|
32
|
+
ariaLabelledby: MaybeRefOrGetter<string | undefined>;
|
|
33
|
+
labels: MaybeRefOrGetter<Partial<CoarTreeLabels> | undefined>;
|
|
34
|
+
/** Search-hit ids — drives `isMatch`/`isMatchAncestor` + auto-expand-to-match. */
|
|
35
|
+
matchedIds: MaybeRefOrGetter<Set<string> | undefined>;
|
|
36
|
+
/** With `matchedIds`, hide non-matches. `filterMode` controls what's kept around a match. */
|
|
37
|
+
filter: MaybeRefOrGetter<boolean>;
|
|
38
|
+
filterMode: MaybeRefOrGetter<CoarTreeFilterMode>;
|
|
19
39
|
expanded: Ref<Set<string>>;
|
|
40
|
+
/** Single-mode highlight selection. */
|
|
20
41
|
selected: Ref<string | null>;
|
|
42
|
+
/** Multiple/checkbox-mode highlight selection. */
|
|
43
|
+
selectedIds: Ref<Set<string>>;
|
|
44
|
+
/** Checkbox-mode checked set (fully-checked nodes; indeterminate is derived). */
|
|
45
|
+
checkedIds: Ref<Set<string>>;
|
|
21
46
|
onActivate?: (node: T) => void;
|
|
47
|
+
onSelect?: (e: CoarTreeSelectEvent<T>) => void;
|
|
22
48
|
onNodeMove?: (e: CoarTreeNodeMoveEvent<T>) => void;
|
|
23
49
|
onFilesDrop?: (e: CoarTreeFilesDropEvent<T>) => void;
|
|
50
|
+
/** Lazily fetch a node's children when it's expanded (see `loadChildren` setter). */
|
|
51
|
+
loadChildren?: (node: T, ctx: CoarTreeLoadChildrenContext) => void | Promise<void>;
|
|
52
|
+
/** Max simultaneous in-flight loads; extra ones queue. 0/undefined = unlimited. */
|
|
53
|
+
maxConcurrentLoads: MaybeRefOrGetter<number>;
|
|
54
|
+
onLoadError?: (e: CoarTreeLoadErrorEvent<T>) => void;
|
|
24
55
|
/** Declarative menus — `<CoarTree>` renders the menu itself when these are set. */
|
|
25
56
|
folderMenu?: (folder: T) => readonly CoarTreeMenuEntry[];
|
|
26
57
|
leafMenu?: (leaf: T) => readonly CoarTreeMenuEntry[];
|
|
@@ -30,25 +61,71 @@ export interface TreeBuilderState<T> {
|
|
|
30
61
|
onLeafContextMenu?: (leaf: T, ev: MouseEvent) => void;
|
|
31
62
|
onViewportContextMenu?: (ev: MouseEvent) => void;
|
|
32
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* The imperative operations `<CoarTree>` registers on mount. The {@link TreeApi}
|
|
66
|
+
* delegates to these; before mount they're absent, so action methods warn +
|
|
67
|
+
* no-op and `getNode` returns `null`.
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
export interface TreeApiImpls<T> {
|
|
71
|
+
focusNode(id: string): void;
|
|
72
|
+
selectNode(id: string): void;
|
|
73
|
+
reloadChildren(id: string): void;
|
|
74
|
+
startRename(id: string): void;
|
|
75
|
+
expandAll(): void;
|
|
76
|
+
collapseAll(): void;
|
|
77
|
+
expandTo(id: string): void;
|
|
78
|
+
revealNode(id: string): void;
|
|
79
|
+
getNode(id: string): T | null;
|
|
80
|
+
moveNode(sourceId: string, targetId: string | null, position: CoarTreeDropPosition): boolean;
|
|
81
|
+
}
|
|
33
82
|
/**
|
|
34
83
|
* Public, narrow imperative interface returned by `useTree().api`. Keeps
|
|
35
|
-
* component refs out of consumer code: you call `api.
|
|
36
|
-
* of digging into a template ref. Readonly refs (`selectedId`, `expandedIds
|
|
84
|
+
* component refs out of consumer code: you call `api.selectNode('x')` instead
|
|
85
|
+
* of digging into a template ref. Readonly refs (`selectedId`, `expandedIds`, …)
|
|
37
86
|
* mirror the builder state so consumers can `watch()` them without owning
|
|
38
|
-
* the writable refs themselves.
|
|
87
|
+
* the writable refs themselves. Action methods are no-ops (with a DEV warning)
|
|
88
|
+
* until `<CoarTree>` mounts.
|
|
39
89
|
*/
|
|
40
|
-
export interface TreeApi {
|
|
41
|
-
/**
|
|
90
|
+
export interface TreeApi<T = unknown> {
|
|
91
|
+
/** Highlight-select AND focus a node (the "reveal & select" action). Preferred over `focusNode`. */
|
|
92
|
+
selectNode(id: string): void;
|
|
93
|
+
/** Alias of {@link selectNode} (selects + focuses) — retained for back-compat since 2.4.0. */
|
|
42
94
|
focusNode(id: string): void;
|
|
43
|
-
/**
|
|
95
|
+
/** Force `loadChildren` to (re)run for a node — retry after error / refresh. */
|
|
96
|
+
reloadChildren(id: string): void;
|
|
97
|
+
/** Enter inline-rename mode on a node (requires `renamable`). */
|
|
98
|
+
startRename(id: string): void;
|
|
99
|
+
/** Expand every expandable, currently-loaded node. */
|
|
100
|
+
expandAll(): void;
|
|
101
|
+
/** Collapse everything. */
|
|
102
|
+
collapseAll(): void;
|
|
103
|
+
/** Expand all loaded ancestors of `id` so its row becomes visible. */
|
|
104
|
+
expandTo(id: string): void;
|
|
105
|
+
/** Scroll a node into view without changing focus or selection (expands ancestors first). */
|
|
106
|
+
revealNode(id: string): void;
|
|
107
|
+
/** Resolve a node by id from the loaded tree, or `null` (also `null` before mount). */
|
|
108
|
+
getNode(id: string): T | null;
|
|
109
|
+
/**
|
|
110
|
+
* Programmatically move a node — the keyboard / a11y-accessible equivalent of a
|
|
111
|
+
* drag-drop. Runs the same cycle + `canDrop` guards and fires `node-move`.
|
|
112
|
+
* Returns `true` if the move was emitted, `false` if rejected (or before mount).
|
|
113
|
+
*/
|
|
114
|
+
moveNode(sourceId: string, targetId: string | null, position: CoarTreeDropPosition): boolean;
|
|
115
|
+
/** Selected node id (read-only, single mode). */
|
|
44
116
|
readonly selectedId: Ref<string | null>;
|
|
117
|
+
/** Highlight-selected ids (read-only, multiple/checkbox mode). */
|
|
118
|
+
readonly selectedIds: Ref<Set<string>>;
|
|
119
|
+
/** Checked ids (read-only, checkbox mode). */
|
|
120
|
+
readonly checkedIds: Ref<Set<string>>;
|
|
45
121
|
/** Currently expanded ids (read-only). */
|
|
46
122
|
readonly expandedIds: Ref<Set<string>>;
|
|
47
123
|
}
|
|
48
124
|
export declare class TreeBuilder<T> {
|
|
49
125
|
readonly state: TreeBuilderState<T>;
|
|
50
|
-
readonly api: TreeApi
|
|
51
|
-
private
|
|
126
|
+
readonly api: TreeApi<T>;
|
|
127
|
+
private _impls;
|
|
128
|
+
private _warnUnmounted;
|
|
52
129
|
private constructor();
|
|
53
130
|
/** Factory — keeps construction sites consistent across call sites. */
|
|
54
131
|
static create<T>(): TreeBuilder<T>;
|
|
@@ -64,9 +141,48 @@ export declare class TreeBuilder<T> {
|
|
|
64
141
|
* before their children are fetched.
|
|
65
142
|
*/
|
|
66
143
|
isExpandable(fn: (n: T) => boolean): this;
|
|
144
|
+
/**
|
|
145
|
+
* Mark nodes as non-interactive: disabled rows can't be selected, activated,
|
|
146
|
+
* directly checked, focused by keyboard, or matched by type-ahead, and render
|
|
147
|
+
* `aria-disabled`. (Cascade from a checked ancestor still includes them.)
|
|
148
|
+
*/
|
|
149
|
+
isDisabled(fn: (n: T) => boolean): this;
|
|
150
|
+
/**
|
|
151
|
+
* Lazily fetch a node's children the first time it's expanded while it has no
|
|
152
|
+
* loaded children yet. Return a `Promise` and the tree shows a spinner on the
|
|
153
|
+
* row until it settles; on rejection the row flips to an error state and
|
|
154
|
+
* `onLoadError` fires. Pair with `.isExpandable(() => true)` (or per-node) so
|
|
155
|
+
* folders render expandable BEFORE their children exist — the consumer attaches
|
|
156
|
+
* the fetched children to its own `nodes`.
|
|
157
|
+
*
|
|
158
|
+
* Attach so `nodes` updates reactively: produce a NEW root reference
|
|
159
|
+
* (`nodes.value = [...]`) or keep `nodes` deeply reactive. A pure in-place
|
|
160
|
+
* mutation on a shallow source won't re-render the row (the spinner persists).
|
|
161
|
+
*
|
|
162
|
+
* The 2nd arg carries an `AbortSignal` that fires if the folder collapses or
|
|
163
|
+
* leaves the tree mid-flight — forward it to `fetch` so a cancelled load
|
|
164
|
+
* doesn't waste work or race a later reopen.
|
|
165
|
+
*/
|
|
166
|
+
loadChildren(fn: (node: T, ctx: CoarTreeLoadChildrenContext) => void | Promise<void>): this;
|
|
167
|
+
/**
|
|
168
|
+
* Cap simultaneous in-flight `loadChildren` calls; extra ones queue. `0`
|
|
169
|
+
* (default) = unlimited. Set a small number (e.g. 6) for rate-limited backends.
|
|
170
|
+
*/
|
|
171
|
+
maxConcurrentLoads(n: MaybeRefOrGetter<number>): this;
|
|
67
172
|
/** Enable internal drag-to-reorder. Accepts a per-node predicate. */
|
|
68
173
|
draggable(d: MaybeRefOrGetter<boolean | ((n: T) => boolean)>): this;
|
|
174
|
+
/**
|
|
175
|
+
* Veto drops. Return `false` to disallow dropping `source` at `position`
|
|
176
|
+
* relative to `target` (`null` target = the root background). Advisory: `source`
|
|
177
|
+
* is the dragstart snapshot (not re-resolved per `dragover`), so read identity,
|
|
178
|
+
* not mutable fields. Integrity (no node into its own descendant) is always
|
|
179
|
+
* guaranteed by the built-in cycle guard regardless of what `canDrop` returns.
|
|
180
|
+
*/
|
|
69
181
|
canDrop(fn: (source: T, target: T | null, position: CoarTreeDropPosition) => boolean): this;
|
|
182
|
+
/** Custom drag ghost for a node: return an `HTMLElement` or HTML string (else the default row image). */
|
|
183
|
+
getDragImage(fn: (n: T) => HTMLElement | string | null | undefined): this;
|
|
184
|
+
/** Fire `onActivate` on a single click too (not only double-click / Enter). Default false. */
|
|
185
|
+
activateOnClick(b: MaybeRefOrGetter<boolean>): this;
|
|
70
186
|
acceptsFiles(b: MaybeRefOrGetter<boolean>): this;
|
|
71
187
|
autoExpandDelay(ms: MaybeRefOrGetter<number>): this;
|
|
72
188
|
/**
|
|
@@ -78,20 +194,90 @@ export declare class TreeBuilder<T> {
|
|
|
78
194
|
* height (or put it in a sized flex/grid cell) so the viewport is measurable.
|
|
79
195
|
*/
|
|
80
196
|
virtualize(v: MaybeRefOrGetter<CoarTreeVirtualizeProp>): this;
|
|
197
|
+
/**
|
|
198
|
+
* Suppress the built-in spinner the tree shows in the chevron while a node's
|
|
199
|
+
* children lazily load. Set this when you render your own loading indicator
|
|
200
|
+
* from the `isLoading` slot prop (e.g. replacing the row icon).
|
|
201
|
+
*/
|
|
202
|
+
hideLoadingSpinner(b: MaybeRefOrGetter<boolean>): this;
|
|
203
|
+
/**
|
|
204
|
+
* Enable the built-in inline-rename UI. With it on, `api.startRename(id)` and
|
|
205
|
+
* F2 on the focused row swap `<CoarTreeNodeLabel>` to an `<input>`; commit on
|
|
206
|
+
* Enter / blur fires `onRename`, Escape / empty fires `onRenameCancel`.
|
|
207
|
+
*/
|
|
208
|
+
renamable(b: MaybeRefOrGetter<boolean>): this;
|
|
209
|
+
/**
|
|
210
|
+
* Selection behavior: `'single'` (default), `'multiple'` (Ctrl/Shift/Ctrl+A on
|
|
211
|
+
* `selectedIds`), or `'checkbox'` (per-row tri-state checkbox on `checkedIds`,
|
|
212
|
+
* independent of the highlight selection). See {@link CoarTreeSelectionMode}.
|
|
213
|
+
*/
|
|
214
|
+
selectionMode(m: MaybeRefOrGetter<CoarTreeSelectionMode>): this;
|
|
215
|
+
/**
|
|
216
|
+
* Checkbox mode only: when `true`, checking a node does NOT cascade to its
|
|
217
|
+
* parent/children and no node is ever indeterminate. Default `false`
|
|
218
|
+
* (cascade + tri-state, the file-tree convention).
|
|
219
|
+
*/
|
|
220
|
+
checkStrictly(b: MaybeRefOrGetter<boolean>): this;
|
|
221
|
+
/** Row density (`xs`/`s`/`m`/`l`, default `m`). Sets the spacing CSS variables. */
|
|
222
|
+
density(d: MaybeRefOrGetter<CoarTreeDensity>): this;
|
|
223
|
+
/** Accessible name for the tree (`aria-label` on the `role="tree"` element). */
|
|
224
|
+
ariaLabel(label: MaybeRefOrGetter<string | undefined>): this;
|
|
225
|
+
/** Id of an external label element (`aria-labelledby` on the `role="tree"` element). */
|
|
226
|
+
ariaLabelledby(id: MaybeRefOrGetter<string | undefined>): this;
|
|
227
|
+
/** Override built-in UI / screen-reader strings for i18n (unset fields use English defaults). */
|
|
228
|
+
labels(l: MaybeRefOrGetter<Partial<CoarTreeLabels> | undefined>): this;
|
|
229
|
+
/**
|
|
230
|
+
* Search-hit ids. Drives `isMatch` / `isMatchAncestor` slot props and
|
|
231
|
+
* auto-expands the ancestors of every match. Filtering the node set is still
|
|
232
|
+
* the consumer's job (e.g. a computed passed to `.nodes()`).
|
|
233
|
+
*/
|
|
234
|
+
matchedIds(ids: MaybeRefOrGetter<Set<string> | undefined>): this;
|
|
235
|
+
/**
|
|
236
|
+
* With `matchedIds` set, hide everything that isn't a match, an ancestor of a
|
|
237
|
+
* match (kept as a "virtual parent" for context), or a descendant of a match.
|
|
238
|
+
* Default false (highlight-only).
|
|
239
|
+
*/
|
|
240
|
+
filter(b: MaybeRefOrGetter<boolean>): this;
|
|
241
|
+
/**
|
|
242
|
+
* How `filter` prunes: `'strict'` (default) = matches + ancestor path only;
|
|
243
|
+
* `'lenient'` = a matched folder reveals its whole subtree. See {@link CoarTreeFilterMode}.
|
|
244
|
+
*/
|
|
245
|
+
filterMode(m: MaybeRefOrGetter<CoarTreeFilterMode>): this;
|
|
81
246
|
/**
|
|
82
247
|
* Bind the set of expanded folder ids. Must be a writable `Ref` — `api`
|
|
83
248
|
* and folder toggles need to write back. Getters are rejected at runtime
|
|
84
249
|
* because they would silently lose writes.
|
|
85
250
|
*/
|
|
86
251
|
expanded(r: Ref<Set<string>>): this;
|
|
87
|
-
/** Bind the selected-node id. Must be a writable `Ref<string | null>`. */
|
|
252
|
+
/** Bind the selected-node id (single mode). Must be a writable `Ref<string | null>`. */
|
|
88
253
|
selected(r: Ref<string | null>): this;
|
|
254
|
+
/**
|
|
255
|
+
* Bind the highlight-selection set (multiple / checkbox modes). Must be a
|
|
256
|
+
* writable `Ref<Set<string>>` — Ctrl/Shift/Ctrl+A and `api` write back.
|
|
257
|
+
*/
|
|
258
|
+
selectedIds(r: Ref<Set<string>>): this;
|
|
259
|
+
/**
|
|
260
|
+
* Bind the checked set (checkbox mode). Must be a writable `Ref<Set<string>>`.
|
|
261
|
+
* Holds every fully-checked node; the indeterminate set is derived internally.
|
|
262
|
+
*/
|
|
263
|
+
checkedIds(r: Ref<Set<string>>): this;
|
|
89
264
|
/** Fires on double-click or Enter on the focused row. */
|
|
90
265
|
onActivate(h: (node: T) => void): this;
|
|
266
|
+
/**
|
|
267
|
+
* Fires whenever the highlight selection changes, with the primary node, the
|
|
268
|
+
* full selected-id set, and whether it was a user gesture or an `api` call.
|
|
269
|
+
*/
|
|
270
|
+
onSelect(h: (e: CoarTreeSelectEvent<T>) => void): this;
|
|
91
271
|
/** Fires after an internal drag-drop completes. The consumer mutates the tree. */
|
|
92
272
|
onNodeMove(h: (e: CoarTreeNodeMoveEvent<T>) => void): this;
|
|
93
273
|
/** Fires when OS files are dropped onto a folder or the empty background. */
|
|
94
274
|
onFilesDrop(h: (e: CoarTreeFilesDropEvent<T>) => void): this;
|
|
275
|
+
/** Fires when an inline rename is committed (Enter / blur with a non-empty name). */
|
|
276
|
+
onRename(h: (e: CoarTreeRenameEvent<T>) => void): this;
|
|
277
|
+
/** Fires when an inline rename is cancelled (Escape, or committed empty). */
|
|
278
|
+
onRenameCancel(h: (node: T) => void): this;
|
|
279
|
+
/** Fires when a lazy `loadChildren` promise rejects. */
|
|
280
|
+
onLoadError(h: (e: CoarTreeLoadErrorEvent<T>) => void): this;
|
|
95
281
|
/**
|
|
96
282
|
* Items shown when right-clicking a folder row. When set (and the
|
|
97
283
|
* `onFolderContextMenu` escape hatch is NOT set), `<CoarTree>` renders a
|
|
@@ -118,7 +304,7 @@ export declare class TreeBuilder<T> {
|
|
|
118
304
|
onLeafContextMenu(h: (leaf: T, ev: MouseEvent) => void): this;
|
|
119
305
|
/** Same as {@link onFolderContextMenu} for the empty background. Overrides {@link viewportMenu}. */
|
|
120
306
|
onViewportContextMenu(h: (ev: MouseEvent) => void): this;
|
|
121
|
-
/** @internal — `<CoarTree>` registers its
|
|
122
|
-
|
|
307
|
+
/** @internal — `<CoarTree>` registers its imperative impls on mount, clears (null) on unmount. */
|
|
308
|
+
_bindImpls(impls: TreeApiImpls<T> | null): void;
|
|
123
309
|
}
|
|
124
310
|
//# sourceMappingURL=tree-builder.d.ts.map
|