Skip to content

Commit e94f997

Browse files
authored
Merge pull request #31 from wu-component/feature/ui-component-marvin
feat:add tree compoonent
2 parents 47c1891 + ff01ea5 commit e94f997

File tree

21 files changed

+3390
-30
lines changed

21 files changed

+3390
-30
lines changed

packages/web-core-plus/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@canyuegongzi/web-core-plus",
3-
"version": "0.0.40",
3+
"version": "0.0.41",
44
"description": "> TODO: description",
55
"author": "Marvin <[email protected]>",
66
"homepage": "",
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import { resolve } from "path";
2+
import { nodeResolve } from "@rollup/plugin-node-resolve";
3+
import commonjs from "@rollup/plugin-commonjs";
4+
import postcss from "rollup-plugin-postcss";
5+
import typescript from "rollup-plugin-typescript2";
6+
import json from "@rollup/plugin-json";
7+
import replace from "@rollup/plugin-replace";
8+
import scss from 'rollup-plugin-scss'
9+
import autoprefixer from 'autoprefixer'
10+
import url from '@rollup/plugin-url';
11+
12+
const input = resolve(__dirname, "../src/packages");
13+
const output = resolve(__dirname, "../dist-lib");
14+
const getPath = _path => resolve(__dirname, _path)
15+
const extensions = [
16+
'.js',
17+
'.ts',
18+
'.tsx'
19+
]
20+
let defaults = { compilerOptions: { declaration: true } };
21+
const config = []
22+
// 整合打;包
23+
config.push({
24+
input: resolve(__dirname, "../src/packages/wu-tree/index.tsx"),
25+
plugins: [
26+
url({
27+
include: ['**/*.woff', '**/*.woff2', '**/*.ttf'],
28+
// setting infinite limit will ensure that the files
29+
// are always bundled with the code, not copied to /dist
30+
limit: Infinity,
31+
}),
32+
nodeResolve(),
33+
commonjs(),
34+
postcss({
35+
extensions: [ '.css', 'scss' ],
36+
name: 'index',
37+
to: `${output}/index.css`,
38+
plugins: [
39+
autoprefixer()
40+
],
41+
extract: false
42+
}),
43+
typescript({
44+
tsconfig: getPath('../tsconfig.json'), // 导入本地ts配置
45+
tsconfigDefaults: defaults,
46+
tsconfigOverride: {
47+
compilerOptions: {
48+
declaration: true
49+
}
50+
},
51+
extensions
52+
}),
53+
json(),
54+
replace({
55+
preventAssignment: true
56+
})
57+
],
58+
output: [
59+
{
60+
name: 'webUIPlusTree',
61+
file: `${output}/web-plus-tree.umd.js`,
62+
format: 'umd',
63+
globals: {
64+
'@canyuegongzi/web-core-plus': 'webCorePlus'
65+
}
66+
},
67+
// { file: `${output}/web-plus.cjs.js`, format: 'cjs' },
68+
// { file: `${output}/web-plus.esm.js`, format: 'es' }
69+
70+
],
71+
external: [/web-core-plus$/],
72+
})
73+
export default config;
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
declare const bigdata: {
2+
text: string;
3+
id: number;
4+
parentid: any;
5+
children: {
6+
text: string;
7+
id: number;
8+
parentid: number;
9+
}[];
10+
}[];
11+
declare const listdata: ({
12+
id: string;
13+
text: string;
14+
state: any;
15+
checked: boolean;
16+
attributes: {
17+
stopflag: number;
18+
objectcode: string;
19+
parents: string;
20+
showTitle?: undefined;
21+
};
22+
parentid: string;
23+
hasParent: boolean;
24+
hasChildren: boolean;
25+
icon: any;
26+
$level: number;
27+
$show: boolean;
28+
children?: undefined;
29+
$pId?: undefined;
30+
} | {
31+
id: string;
32+
text: string;
33+
state: any;
34+
checked: boolean;
35+
attributes: {
36+
stopflag: number;
37+
objectcode: string;
38+
showTitle: string;
39+
parents: string;
40+
};
41+
children: any;
42+
parentid: string;
43+
hasParent: boolean;
44+
hasChildren: boolean;
45+
icon: any;
46+
$level: number;
47+
$show: boolean;
48+
$pId: string;
49+
} | {
50+
id: string;
51+
text: string;
52+
state: any;
53+
checked: boolean;
54+
attributes: {
55+
stopflag: number;
56+
objectcode: string;
57+
showTitle: string;
58+
parents: string;
59+
};
60+
parentid: string;
61+
hasParent: boolean;
62+
hasChildren: boolean;
63+
icon: any;
64+
$level: number;
65+
$show: boolean;
66+
$pId: string;
67+
children?: undefined;
68+
})[];
69+
export { bigdata, listdata };
Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,78 @@
1-
export declare class WuTree {
1+
import { OnConnected, WuComponent } from '@canyuegongzi/web-core-plus';
2+
interface DataOptions {
3+
id: string;
4+
label: string;
5+
disabled: string;
26
}
7+
declare type TypeEnums = 'checkbox' | 'radio' | false;
8+
export declare class WuTree extends WuComponent implements OnConnected {
9+
constructor();
10+
private tree;
11+
connected(shadowRoot: ShadowRoot): void;
12+
nodeClick(params: any): any;
13+
checkChange(params: any): any;
14+
moveChange(params: any): any;
15+
width: string;
16+
height: string;
17+
options: DataOptions;
18+
lineHeight: number;
19+
selectType: TypeEnums;
20+
canMove: boolean;
21+
data: any;
22+
defaultCheckedKeys: any;
23+
defaultExpandedKeys: any;
24+
/**
25+
* 获取选中数据
26+
*/
27+
getChecked(): {
28+
nodes: any;
29+
keys: any;
30+
};
31+
/**
32+
* 选中全部,justResult为true则仅选择当前搜索结果
33+
* @param justResult
34+
*/
35+
checkAll(justResult?: boolean): void;
36+
/**
37+
* 清空所选项
38+
*/
39+
clearAll(): void;
40+
/**
41+
* 设置选中节点,keys为选中的节点id的数组
42+
*/
43+
setCheckedKeys(keys: string[]): void;
44+
/**
45+
* 设置选中节点,nodes为选中节点的数组
46+
*/
47+
setCheckedNodes(nodes: any[]): void;
48+
/**
49+
* 编辑节点
50+
*/
51+
editNode(nodes: any): void;
52+
/**
53+
* 添加节点,id:添加到的父节点id,当添加根节点时id为null,node新节点数据
54+
*/
55+
addNode(id: string, nodes: any): void;
56+
/**
57+
* 删除节点
58+
*/
59+
deleteNode(id: string): void;
60+
/**
61+
* :获取某个节点数据
62+
*/
63+
getNodeById(id: string): any;
64+
/**
65+
* :重新计算容器高度
66+
*/
67+
resize(): any;
68+
/**
69+
* :重新绘制
70+
*/
71+
refreshDom(justScroll?: boolean, needLocate?: boolean): void;
72+
/**
73+
* :销毁实例,主要用于清除绑定事件
74+
*/
75+
destory(): void;
76+
render(_renderProps?: {}, _store?: {}): any;
77+
}
78+
export {};
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
export declare const defaultOption: {
2+
defaultCheckedKeys: any[];
3+
defaultExpandedKeys: any[];
4+
label: string;
5+
id: string;
6+
lineHeight: number;
7+
dataType: string;
8+
lazyLoad: boolean;
9+
selectType: string;
10+
checkDisabled: (d: any) => boolean;
11+
autoOpen: (d: any, level: any) => boolean;
12+
checkSticky: {
13+
on: string;
14+
off: string;
15+
};
16+
editNode: (d: any) => boolean;
17+
deleteNode: (d: any) => boolean;
18+
addChildNode: (d: any) => boolean;
19+
};
20+
export declare class Tree {
21+
readonly container: any;
22+
private option;
23+
private data;
24+
private flatList;
25+
private totalNum;
26+
private readonly flatListKeys;
27+
private topIndex;
28+
private bottomIndex;
29+
private readonly slidedownHTML;
30+
private readonly iconHTML;
31+
private readonly selectHTML;
32+
private clicked;
33+
private readonly checked;
34+
private resizeObserver;
35+
private index;
36+
private searchKeyword;
37+
private scrollDom;
38+
private openNumber;
39+
private seachKeys;
40+
private dom;
41+
private movedom;
42+
private calcCurrent;
43+
private searchKeysJson;
44+
private currentNumber;
45+
private clickFunc;
46+
private mouseoverFunc;
47+
private mousedownFunc;
48+
private mousemoveFunc;
49+
private scrollFunc;
50+
private mouseupFunc;
51+
private dblclickFunc;
52+
constructor(container: any, data: any, option: any);
53+
addResizeObserve(): void;
54+
init(): void;
55+
addMoveDom(): string;
56+
rendDom(): void;
57+
setScrollWidth(): void;
58+
private _rendHTML;
59+
private _rendOneNode;
60+
search(keyword: any, func: any, containChild: any): void;
61+
treeFindPath(tree: any, func: any, path: any[], result: any[], containChild: any, hasP?: any): any[];
62+
addEvent(): void;
63+
refreshDom(justScroll?: boolean, needLocate?: boolean): void;
64+
moveItem(el: any): void;
65+
renderOneTree(treeData: any, level: any, open: any): NodeListOf<ChildNode>;
66+
_getItemById(id: any): any;
67+
getMovePos($dom: any, e: any): any[];
68+
setNodesShow(node: any): void;
69+
setSelectKey(key: any, triggerClick: any, needLocate: any): void;
70+
clickLabelEvent($item: any, $t: any, e: any): void;
71+
radioEvent($t: any): void;
72+
checkEvent($t: any): void;
73+
delArrayFromArray(fromArray: any, delArray: any): any[];
74+
setCheckedKeys(keys: any, ...args: any[]): void;
75+
trigger(type: any, data: any, ...arg: any[]): void;
76+
setCheckedNodes(nodes: any): void;
77+
getChecked(): {
78+
nodes: any;
79+
keys: any;
80+
};
81+
checkAll(justResult: any): void;
82+
clearAll(): void;
83+
editNode(node: any): void;
84+
addNodes(id: any, nodes: any, open: any): void;
85+
_addOneNode(id: any, node: any, open?: any): void;
86+
addNode(id: any, node: any): void;
87+
insertAfter(insert_element: any, target_element: any): void;
88+
deleteNode(id: any): void;
89+
_deleteDomFromId(id: any): void;
90+
getFlatData(): void;
91+
_literalFlatTree(pNode: any, list: any, arry: any, arrykeys: any, level: any, dontSetData: any, list1?: any): void;
92+
getNodeById(id: any): any;
93+
_literalGetNode(list: any, id: any): any;
94+
openChildren(node: any): void;
95+
slideEvent($t: any): Promise<void>;
96+
findChildren(p: any, plevel: any): any;
97+
resetOption(option: any): void;
98+
replaceKey(text: any, keyword: any): any;
99+
destory(): void;
100+
revertListToTree(data: any): any;
101+
revertTreeToList(treedata: any): any[];
102+
_revertTreeToListFunc(treedata: any, list: any): void;
103+
getData(): any;
104+
returnFlatData(): {};
105+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare function XNQuery(el: any): any;
2+
declare namespace XNQuery {
3+
var extend: any;
4+
}
5+
export default XNQuery;

0 commit comments

Comments
 (0)