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