x-group-list 0.3.0 → 0.3.2
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/package.json +21 -20
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -128
- package/dist/utils/groupList.d.ts +0 -37
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "x-group-list",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -12,35 +12,36 @@
|
|
|
12
12
|
"dev": "vite",
|
|
13
13
|
"build": "vue-tsc && vite build",
|
|
14
14
|
"preview": "vite preview",
|
|
15
|
-
"lint": "eslint
|
|
15
|
+
"lint": "eslint --fix .",
|
|
16
16
|
"format": "prettier --write .",
|
|
17
17
|
"lint-staged": "lint-staged",
|
|
18
18
|
"prepare": "husky"
|
|
19
19
|
},
|
|
20
20
|
"lint-staged": {
|
|
21
|
-
"*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}": "eslint --fix",
|
|
21
|
+
"*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}": "eslint --fix .",
|
|
22
22
|
"*": "prettier --write ."
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"vue": "^3.5.
|
|
26
|
-
"vuetify": "^3.7.
|
|
25
|
+
"vue": "^3.5.12",
|
|
26
|
+
"vuetify": "^3.7.2"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@types/node": "^
|
|
31
|
-
"@vitejs/plugin-vue": "^5.
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"eslint": "^
|
|
35
|
-
"eslint-plugin-vue": "^9.
|
|
36
|
-
"husky": "^9.
|
|
37
|
-
"lint-staged": "^15.2.
|
|
29
|
+
"@eslint/js": "^10.0.0",
|
|
30
|
+
"@types/node": "^22.7.6",
|
|
31
|
+
"@vitejs/plugin-vue": "^5.1.4",
|
|
32
|
+
"eslint": "^9.12.0",
|
|
33
|
+
"eslint-config-prettier": "^9.1.0",
|
|
34
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
35
|
+
"eslint-plugin-vue": "^9.29.0",
|
|
36
|
+
"husky": "^9.1.6",
|
|
37
|
+
"lint-staged": "^15.2.10",
|
|
38
38
|
"prettier": "3.3.3",
|
|
39
|
-
"sass": "^1.
|
|
40
|
-
"typescript": "^5.
|
|
41
|
-
"
|
|
42
|
-
"vite
|
|
43
|
-
"vite-plugin-
|
|
44
|
-
"
|
|
39
|
+
"sass": "^1.80.0",
|
|
40
|
+
"typescript": "^5.6.3",
|
|
41
|
+
"typescript-eslint": "^8.9.0",
|
|
42
|
+
"vite": "^5.4.9",
|
|
43
|
+
"vite-plugin-css-injected-by-js": "^3.5.2",
|
|
44
|
+
"vite-plugin-vuetify": "^2.0.4",
|
|
45
|
+
"vue-tsc": "^2.1.6"
|
|
45
46
|
}
|
|
46
47
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './utils/groupList';
|
package/dist/index.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
function d(s, l) {
|
|
2
|
-
const o = [];
|
|
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);
|
|
7
|
-
const a = [];
|
|
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
|
-
const e = [];
|
|
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
|
-
}
|
|
19
|
-
function r(s, l) {
|
|
20
|
-
return s.value.find((o) => o.id === l);
|
|
21
|
-
}
|
|
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
|
-
console.assert(!1, "type must be 0");
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
for (a.collapse = o, f++; f < s.value.length && (a = s.value[f], a.type !== 0); f++)
|
|
31
|
-
a.show = !o;
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function g(s) {
|
|
37
|
-
return !!s.value.find((l) => l.type === 0 && l.detail);
|
|
38
|
-
}
|
|
39
|
-
function E(s, l) {
|
|
40
|
-
s.value.forEach((o) => {
|
|
41
|
-
o.type === 0 && (o.detail = o.id === l);
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
function b(s, l) {
|
|
45
|
-
s.value.forEach((o) => {
|
|
46
|
-
o.type !== 0 && (o.select = o.id === l);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
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
|
-
s.value.splice(o, 0, t);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
let e;
|
|
57
|
-
for (let t = 0; t < s.value.length; t++) {
|
|
58
|
-
const n = s.value[t];
|
|
59
|
-
if (n.type === 0)
|
|
60
|
-
e = n;
|
|
61
|
-
else if (n.type === 1) {
|
|
62
|
-
if (!e) {
|
|
63
|
-
console.assert(!1);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (n.group !== e.id) {
|
|
67
|
-
if (n.group = e.id, e.collapse) {
|
|
68
|
-
let p = t;
|
|
69
|
-
for (t++; t < s.value.length; t++) {
|
|
70
|
-
const c = s.value[t];
|
|
71
|
-
if (c.type === 0 || c.show)
|
|
72
|
-
break;
|
|
73
|
-
const h = s.value[p];
|
|
74
|
-
s.value[p] = c, s.value[t] = h, p = t;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
} else
|
|
80
|
-
console.assert(!1);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
const a = [], u = [];
|
|
84
|
-
s.value.forEach((e) => {
|
|
85
|
-
e.type === 0 ? a.push(e) : e.type === 1 ? u.push(e) : console.assert(!1);
|
|
86
|
-
});
|
|
87
|
-
const i = [];
|
|
88
|
-
a.forEach((e, t) => {
|
|
89
|
-
e.position = t;
|
|
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
|
-
}
|
|
96
|
-
function I(s) {
|
|
97
|
-
const l = {};
|
|
98
|
-
return s.value.forEach((o) => {
|
|
99
|
-
o.type === 0 ? l[o.id] = {
|
|
100
|
-
id: o.id,
|
|
101
|
-
group: "",
|
|
102
|
-
position: o.position
|
|
103
|
-
} : o.type === 1 ? l[o.id] = {
|
|
104
|
-
id: o.id,
|
|
105
|
-
group: o.group,
|
|
106
|
-
position: o.position
|
|
107
|
-
} : console.assert(!1);
|
|
108
|
-
}), l;
|
|
109
|
-
}
|
|
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;
|
|
117
|
-
}
|
|
118
|
-
export {
|
|
119
|
-
D as diffPosInfos,
|
|
120
|
-
r as getListEntry,
|
|
121
|
-
g as hasDetail,
|
|
122
|
-
k as onDragEnd,
|
|
123
|
-
b as selectItem,
|
|
124
|
-
v as setCollapse,
|
|
125
|
-
d as tidyList,
|
|
126
|
-
I as toPosInfos,
|
|
127
|
-
E as toggleDetail
|
|
128
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Ref } from 'vue';
|
|
2
|
-
export interface ListGroup {
|
|
3
|
-
id: string;
|
|
4
|
-
type: 0;
|
|
5
|
-
name: string;
|
|
6
|
-
position: number;
|
|
7
|
-
collapse: boolean;
|
|
8
|
-
detail?: boolean;
|
|
9
|
-
count?: number;
|
|
10
|
-
}
|
|
11
|
-
export interface ListItem {
|
|
12
|
-
id: string;
|
|
13
|
-
type: 1;
|
|
14
|
-
name: string;
|
|
15
|
-
position: number;
|
|
16
|
-
group: string;
|
|
17
|
-
select?: boolean;
|
|
18
|
-
show?: boolean;
|
|
19
|
-
}
|
|
20
|
-
export type ListEntry = ListGroup | ListItem;
|
|
21
|
-
export declare function tidyList(entryList: ListEntry[], clean: boolean): ListEntry[];
|
|
22
|
-
export declare function getListEntry(entryList: Ref<ListEntry[]>, id: string): ListEntry | undefined;
|
|
23
|
-
export declare function setCollapse(entryList: Ref<ListEntry[]>, id: string, collapse: boolean): void;
|
|
24
|
-
export declare function hasDetail(entryList: Ref<ListEntry[]>): boolean;
|
|
25
|
-
export declare function toggleDetail(entryList: Ref<ListEntry[]>, id: string): void;
|
|
26
|
-
export declare function selectItem(entryList: Ref<ListEntry[]>, id: string): void;
|
|
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
|
-
}
|
|
33
|
-
export type PosInfos = {
|
|
34
|
-
[key: string]: PosInfo;
|
|
35
|
-
};
|
|
36
|
-
export declare function toPosInfos(entryList: Ref<ListEntry[]>): PosInfos;
|
|
37
|
-
export declare function diffPosInfos(oldPosInfos: PosInfos, newPosInfos: PosInfos): PosInfo[];
|