@firstnoodle-ui/bui 0.0.33 → 0.0.34
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/tree-list/TreeList.vue.d.ts +1 -1
- package/dist/components/tree-list/index.d.ts +2 -1
- package/dist/components/tree-list/{types.d.ts → tree-list-types.d.ts} +10 -1
- package/dist/components/tree-list/tree-list-utils.d.ts +29 -0
- package/dist/index.mjs +449 -355
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TreeNode, TreeNodeActionEvent, TreeNodeEvent } from './types';
|
|
1
|
+
import { TreeNode, TreeNodeActionEvent, TreeNodeEvent } from './tree-list-types';
|
|
2
2
|
declare const _default: <T extends object>(__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
3
|
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
|
|
4
4
|
readonly onSelect?: ((data: TreeNodeEvent<T>) => any) | undefined;
|
|
@@ -8,7 +8,7 @@ export type TreeNode<T> = {
|
|
|
8
8
|
id: string | number;
|
|
9
9
|
label: string;
|
|
10
10
|
open: boolean;
|
|
11
|
-
|
|
11
|
+
data: T;
|
|
12
12
|
children?: TreeNode<T>[];
|
|
13
13
|
actions: TreeNodeAction<T>[];
|
|
14
14
|
};
|
|
@@ -19,3 +19,12 @@ export type TreeNodeEvent<T> = {
|
|
|
19
19
|
export type TreeNodeActionEvent<T> = TreeNodeEvent<T> & {
|
|
20
20
|
action: TreeNodeAction<T>;
|
|
21
21
|
};
|
|
22
|
+
export type TreeNodeIdKey<T> = {
|
|
23
|
+
[K in keyof T]: T[K] extends number | string ? K : never;
|
|
24
|
+
}[keyof T];
|
|
25
|
+
export type TreeNodeParentIdKey<T> = {
|
|
26
|
+
[K in keyof T]: T[K] extends number | string | null ? K : never;
|
|
27
|
+
}[keyof T];
|
|
28
|
+
export type TreeNodeLabelKey<T> = {
|
|
29
|
+
[K in keyof T]: T[K] extends string ? K : never;
|
|
30
|
+
}[keyof T];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { TreeNode, TreeNodeAction, TreeNodeIdKey, TreeNodeLabelKey, TreeNodeParentIdKey } from './tree-list-types';
|
|
2
|
+
export declare const openPath: <T>(path: TreeNode<T>[]) => void;
|
|
3
|
+
export declare const getNodeValueByPath: <T, K extends keyof TreeNode<T>>(root: TreeNode<T>, path: TreeNode<T>[], key: K) => TreeNode<T>[K] | undefined;
|
|
4
|
+
export declare const setNodeValueByPath: <T, K extends keyof TreeNode<T>>(root: TreeNode<T>, path: TreeNode<T>[], key: K, newValue: TreeNode<T>[K]) => boolean;
|
|
5
|
+
export declare const setNodeObjectValueByPath: <T, K extends keyof T>(root: TreeNode<T>, path: TreeNode<T>[], key: K, newValue: T[K]) => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Flattens a tree structure into an array of nodes with their paths
|
|
8
|
+
* @param root The root node of the tree
|
|
9
|
+
* @param path Optional initial path (used internally for recursion)
|
|
10
|
+
* @returns Array of objects containing the node and its path from root
|
|
11
|
+
*/
|
|
12
|
+
export declare const flattenTree: <T>(root: TreeNode<T>, path?: TreeNode<T>[]) => Array<{
|
|
13
|
+
node: TreeNode<T>;
|
|
14
|
+
path: TreeNode<T>[];
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* Alternative flatten function that returns just the nodes in depth-first order
|
|
18
|
+
* @param root The root node of the tree
|
|
19
|
+
* @returns Array of all nodes in depth-first traversal order
|
|
20
|
+
*/
|
|
21
|
+
export declare const flattenTreeNodes: <T>(root: TreeNode<T>) => TreeNode<T>[];
|
|
22
|
+
export declare const buildTree: <T extends object>({ items, itemIdField, parentIdField, labelField, treeIsOpen, actions, }: {
|
|
23
|
+
items: T[];
|
|
24
|
+
itemIdField: TreeNodeIdKey<T>;
|
|
25
|
+
parentIdField: TreeNodeParentIdKey<T>;
|
|
26
|
+
labelField: TreeNodeLabelKey<T>;
|
|
27
|
+
treeIsOpen: boolean;
|
|
28
|
+
actions: TreeNodeAction<T>[];
|
|
29
|
+
}) => TreeNode<T> | null;
|