x-group-list 0.1.0
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/README.md +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +61 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# x-group-list
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Ref } from 'vue'
|
|
2
|
+
|
|
3
|
+
type Type = 0 | 1
|
|
4
|
+
|
|
5
|
+
interface ListEntry {
|
|
6
|
+
id: string
|
|
7
|
+
type: Type
|
|
8
|
+
name: string
|
|
9
|
+
position: number
|
|
10
|
+
// group
|
|
11
|
+
count?: number
|
|
12
|
+
collapse?: boolean
|
|
13
|
+
detail?: boolean
|
|
14
|
+
// item
|
|
15
|
+
group?: string
|
|
16
|
+
select?: boolean
|
|
17
|
+
show?: boolean
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export declare function tidyList(
|
|
21
|
+
entryList: ListEntry[],
|
|
22
|
+
clean: boolean
|
|
23
|
+
): ListEntry[]
|
|
24
|
+
export declare function getListEntry(
|
|
25
|
+
entryList: Ref<ListEntry[]>,
|
|
26
|
+
id: string
|
|
27
|
+
): ListEntry | undefined
|
|
28
|
+
export declare function setCollapse(
|
|
29
|
+
entryList: Ref<ListEntry[]>,
|
|
30
|
+
id: string,
|
|
31
|
+
collapse: boolean
|
|
32
|
+
)
|
|
33
|
+
export declare function hasDetail(entryList: Ref<ListEntry[]>): boolean
|
|
34
|
+
export declare function toggleDetail(entryList: Ref<ListEntry[]>, id: string)
|
|
35
|
+
export declare function seleteItem(entryList: Ref<ListEntry[]>, id: string)
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
function u(s, t) {
|
|
2
|
+
return s.position < t.position ? -1 : s.position > t.position ? 1 : 0;
|
|
3
|
+
}
|
|
4
|
+
function d(s, t) {
|
|
5
|
+
const i = [];
|
|
6
|
+
let o = [];
|
|
7
|
+
s.forEach((e) => {
|
|
8
|
+
e.type === 0 ? i.findIndex((l) => l.id === e.id) === -1 ? i.push(e) : console.assert(!1, "duplicate group", e) : e.type === 1 ? o.findIndex((l) => l.id === e.id) === -1 ? o.push(e) : console.assert(!1, "duplicate item", e) : console.assert(!1, "invalid type", e);
|
|
9
|
+
}), i.sort(u), o.sort(u);
|
|
10
|
+
const f = [];
|
|
11
|
+
o.forEach((e) => {
|
|
12
|
+
i.findIndex((l) => l.id === e.group) === -1 && f.push(e.id);
|
|
13
|
+
}), o = o.filter(
|
|
14
|
+
(e) => f.findIndex((l) => l === e.id) === -1
|
|
15
|
+
);
|
|
16
|
+
const n = [];
|
|
17
|
+
return i.forEach((e) => {
|
|
18
|
+
const l = [];
|
|
19
|
+
o.forEach((a) => {
|
|
20
|
+
a.group === e.id && (a.show = !e.collapse, l.push(a));
|
|
21
|
+
}), e.count = l.length, e.count > 0 ? (n.push(e), n.push(...l)) : t || n.push(e);
|
|
22
|
+
}), n;
|
|
23
|
+
}
|
|
24
|
+
function c(s, t) {
|
|
25
|
+
return s.value.find((i) => i.id === t);
|
|
26
|
+
}
|
|
27
|
+
function p(s, t, i) {
|
|
28
|
+
for (let o = 0; o < s.value.length; o++) {
|
|
29
|
+
let f = s.value[o];
|
|
30
|
+
if (f.id === t) {
|
|
31
|
+
if (f.type !== 0) {
|
|
32
|
+
console.assert(!1, "type must be 0");
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
for (f.collapse = i, o++; o < s.value.length && (f = s.value[o], f.type !== 0); o++)
|
|
36
|
+
f.show = !i;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function h(s) {
|
|
42
|
+
return s.value.findIndex((t) => t.type === 0 && t.detail) !== -1;
|
|
43
|
+
}
|
|
44
|
+
function r(s, t) {
|
|
45
|
+
s.value.forEach((i) => {
|
|
46
|
+
i.type === 0 && (i.detail = i.id === t);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function v(s, t) {
|
|
50
|
+
s.value.forEach((i) => {
|
|
51
|
+
i.type !== 0 && (i.select = i.id === t);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
c as getListEntry,
|
|
56
|
+
h as hasDetail,
|
|
57
|
+
v as seleteItem,
|
|
58
|
+
p as setCollapse,
|
|
59
|
+
d as tidyList,
|
|
60
|
+
r as toggleDetail
|
|
61
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "x-group-list",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"dev": "vite",
|
|
13
|
+
"build": "vue-tsc && vite build",
|
|
14
|
+
"preview": "vite preview",
|
|
15
|
+
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix",
|
|
16
|
+
"format": "prettier --write .",
|
|
17
|
+
"lint-staged": "lint-staged",
|
|
18
|
+
"prepare": "husky"
|
|
19
|
+
},
|
|
20
|
+
"lint-staged": {
|
|
21
|
+
"*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}": "eslint --fix",
|
|
22
|
+
"*": "prettier --write ."
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"vue": "^3.4.23",
|
|
26
|
+
"vuetify": "^3.5.16"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@rushstack/eslint-patch": "^1.8.0",
|
|
30
|
+
"@types/node": "^20.12.2",
|
|
31
|
+
"@vitejs/plugin-vue": "^5.0.4",
|
|
32
|
+
"@vue/eslint-config-prettier": "^9.0.0",
|
|
33
|
+
"@vue/eslint-config-typescript": "^13.0.0",
|
|
34
|
+
"eslint": "^8.57.0",
|
|
35
|
+
"eslint-plugin-vue": "^9.24.1",
|
|
36
|
+
"husky": "^9.0.11",
|
|
37
|
+
"lint-staged": "^15.2.2",
|
|
38
|
+
"prettier": "3.2.5",
|
|
39
|
+
"rollup-plugin-copy": "^3.5.0",
|
|
40
|
+
"sass": "^1.74.1",
|
|
41
|
+
"typescript": "^5.2.2",
|
|
42
|
+
"vite": "^5.2.0",
|
|
43
|
+
"vite-plugin-css-injected-by-js": "^3.5.0",
|
|
44
|
+
"vue-tsc": "^2.0.6"
|
|
45
|
+
}
|
|
46
|
+
}
|