x-group-list 0.2.0 → 0.2.7
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/index.js +119 -36
- package/dist/utils/groupList.d.ts +10 -2
- package/package.json +3 -5
package/dist/index.js
CHANGED
|
@@ -1,56 +1,139 @@
|
|
|
1
|
-
function
|
|
2
|
-
const
|
|
3
|
-
let
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}),
|
|
1
|
+
function d(s, p) {
|
|
2
|
+
const o = [];
|
|
3
|
+
let i = [];
|
|
4
|
+
s.forEach((l) => {
|
|
5
|
+
l.type === 0 ? o.push(l) : l.type === 1 ? i.push(l) : console.assert(!1);
|
|
6
|
+
}), o.sort((l, e) => l.position - e.position), i.sort((l, e) => l.position - e.position);
|
|
7
7
|
const f = [];
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}),
|
|
8
|
+
i.forEach((l) => {
|
|
9
|
+
o.find((e) => e.id === l.group) || f.push(l.id);
|
|
10
|
+
}), i = i.filter((l) => !f.find((e) => e === l.id));
|
|
11
11
|
const a = [];
|
|
12
|
-
return
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}),
|
|
12
|
+
return o.forEach((l) => {
|
|
13
|
+
const e = [];
|
|
14
|
+
i.forEach((t) => {
|
|
15
|
+
t.group === l.id && (t.show = !l.collapse, e.push(t));
|
|
16
|
+
}), l.count = e.length, l.count > 0 ? (a.push(l), a.push(...e)) : p || a.push(l);
|
|
17
17
|
}), a;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return
|
|
19
|
+
function r(s, p) {
|
|
20
|
+
return s.value.find((o) => o.id === p);
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
for (let
|
|
24
|
-
let f =
|
|
25
|
-
if (f.id ===
|
|
22
|
+
function v(s, p, o) {
|
|
23
|
+
for (let i = 0; i < s.value.length; i++) {
|
|
24
|
+
let f = s.value[i];
|
|
25
|
+
if (f.id === p) {
|
|
26
26
|
if (f.type !== 0) {
|
|
27
27
|
console.assert(!1, "type must be 0");
|
|
28
28
|
break;
|
|
29
29
|
}
|
|
30
|
-
for (f.collapse =
|
|
31
|
-
f.show = !
|
|
30
|
+
for (f.collapse = o, i++; i < s.value.length && (f = s.value[i], f.type !== 0); i++)
|
|
31
|
+
f.show = !o;
|
|
32
32
|
break;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
return !!
|
|
36
|
+
function g(s) {
|
|
37
|
+
return !!s.value.find((p) => p.type === 0 && p.detail);
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
function E(s, p) {
|
|
40
|
+
s.value.forEach((o) => {
|
|
41
|
+
o.type === 0 && (o.detail = o.id === p);
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
function b(s, p) {
|
|
45
|
+
s.value.forEach((o) => {
|
|
46
|
+
o.type !== 0 && (o.select = o.id === p);
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
+
function k(s, p, o, i) {
|
|
50
|
+
if (p === 1) {
|
|
51
|
+
if (i === 0) {
|
|
52
|
+
const t = s.value.splice(i, 1)[0];
|
|
53
|
+
s.value.splice(o, 0, t);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
let e;
|
|
57
|
+
for (let t = 0; t < s.value.length; t++) {
|
|
58
|
+
const u = s.value[t];
|
|
59
|
+
if (u.type === 0)
|
|
60
|
+
e = u;
|
|
61
|
+
else if (u.type === 1) {
|
|
62
|
+
if (!e) {
|
|
63
|
+
console.assert(!1);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (u.group !== e.id) {
|
|
67
|
+
if (u.group = e.id, e.collapse) {
|
|
68
|
+
let c = t;
|
|
69
|
+
for (t++; t < s.value.length; t++) {
|
|
70
|
+
const n = s.value[t];
|
|
71
|
+
if (n.type === 0 || n.show)
|
|
72
|
+
break;
|
|
73
|
+
const h = s.value[c];
|
|
74
|
+
s.value[c] = n, s.value[t] = h, c = t;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
} else
|
|
80
|
+
console.assert(!1);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const f = [], a = [];
|
|
84
|
+
s.value.forEach((e) => {
|
|
85
|
+
e.type === 0 ? f.push(e) : e.type === 1 ? a.push(e) : console.assert(!1);
|
|
86
|
+
});
|
|
87
|
+
const l = [];
|
|
88
|
+
f.forEach((e, t) => {
|
|
89
|
+
e.position = t;
|
|
90
|
+
const u = [];
|
|
91
|
+
a.forEach((c) => {
|
|
92
|
+
c.group === e.id && (c.position = u.length, u.push(c));
|
|
93
|
+
}), e.count = u.length, l.push(e), l.push(...u);
|
|
94
|
+
}), s.value = l;
|
|
95
|
+
}
|
|
96
|
+
function D(s) {
|
|
97
|
+
const p = {};
|
|
98
|
+
return s.value.forEach((o) => {
|
|
99
|
+
o.type === 0 ? p[o.id] = {
|
|
100
|
+
position: o.position
|
|
101
|
+
} : o.type === 1 ? p[o.id] = {
|
|
102
|
+
group: o.group,
|
|
103
|
+
position: o.position
|
|
104
|
+
} : console.assert(!1);
|
|
105
|
+
}), p;
|
|
106
|
+
}
|
|
107
|
+
function I(s, p) {
|
|
108
|
+
const o = {};
|
|
109
|
+
return s.value.forEach((i) => {
|
|
110
|
+
if (i.type === 0) {
|
|
111
|
+
const f = p[i.id];
|
|
112
|
+
if (i.position === (f == null ? void 0 : f.position))
|
|
113
|
+
return;
|
|
114
|
+
o[i.id] = {
|
|
115
|
+
position: i.position
|
|
116
|
+
};
|
|
117
|
+
} else if (i.type === 1) {
|
|
118
|
+
const f = p[i.id];
|
|
119
|
+
if (i.group === (f == null ? void 0 : f.group) && i.position === (f == null ? void 0 : f.position))
|
|
120
|
+
return;
|
|
121
|
+
o[i.id] = {
|
|
122
|
+
group: i.group,
|
|
123
|
+
position: i.position
|
|
124
|
+
};
|
|
125
|
+
} else
|
|
126
|
+
console.assert(!1);
|
|
127
|
+
}), o;
|
|
128
|
+
}
|
|
49
129
|
export {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
r as
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
130
|
+
D as backupPosInfos,
|
|
131
|
+
I as diffPosInfos,
|
|
132
|
+
r as getListEntry,
|
|
133
|
+
g as hasDetail,
|
|
134
|
+
k as onDragEnd,
|
|
135
|
+
b as selectItem,
|
|
136
|
+
v as setCollapse,
|
|
137
|
+
d as tidyList,
|
|
138
|
+
E as toggleDetail
|
|
56
139
|
};
|
|
@@ -17,11 +17,19 @@ export interface ListItem {
|
|
|
17
17
|
select?: boolean;
|
|
18
18
|
show?: boolean;
|
|
19
19
|
}
|
|
20
|
-
type ListEntry = ListGroup | ListItem;
|
|
20
|
+
export type ListEntry = ListGroup | ListItem;
|
|
21
21
|
export declare function tidyList(entryList: ListEntry[], clean: boolean): ListEntry[];
|
|
22
22
|
export declare function getListEntry(entryList: Ref<ListEntry[]>, id: string): ListEntry | undefined;
|
|
23
23
|
export declare function setCollapse(entryList: Ref<ListEntry[]>, id: string, collapse: boolean): void;
|
|
24
24
|
export declare function hasDetail(entryList: Ref<ListEntry[]>): boolean;
|
|
25
25
|
export declare function toggleDetail(entryList: Ref<ListEntry[]>, id: string): void;
|
|
26
26
|
export declare function selectItem(entryList: Ref<ListEntry[]>, id: string): void;
|
|
27
|
-
export
|
|
27
|
+
export declare function onDragEnd(entryList: Ref<ListEntry[]>, draggingType: 0 | 1, oldIndex: number, newIndex: number): void;
|
|
28
|
+
export type PosInfos = {
|
|
29
|
+
[key: string]: {
|
|
30
|
+
group?: string;
|
|
31
|
+
position: number;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export declare function backupPosInfos(entryList: Ref<ListEntry[]>): PosInfos;
|
|
35
|
+
export declare function diffPosInfos(entryList: Ref<ListEntry[]>, backup: PosInfos): PosInfos;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "x-group-list",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.7",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"*": "prettier --write ."
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"vue": "^3.4.
|
|
26
|
-
"vuetify": "^3.6.
|
|
25
|
+
"vue": "^3.4.30",
|
|
26
|
+
"vuetify": "^3.6.10"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@rushstack/eslint-patch": "^1.8.0",
|
|
@@ -36,12 +36,10 @@
|
|
|
36
36
|
"husky": "^9.0.11",
|
|
37
37
|
"lint-staged": "^15.2.2",
|
|
38
38
|
"prettier": "3.2.5",
|
|
39
|
-
"rollup-plugin-copy": "^3.5.0",
|
|
40
39
|
"sass": "^1.74.1",
|
|
41
40
|
"typescript": "^5.2.2",
|
|
42
41
|
"vite": "^5.2.0",
|
|
43
42
|
"vite-plugin-css-injected-by-js": "^3.5.0",
|
|
44
|
-
"vite-plugin-externals": "^0.6.2",
|
|
45
43
|
"vite-plugin-vuetify": "^2.0.3",
|
|
46
44
|
"vue-tsc": "^2.0.6"
|
|
47
45
|
}
|