x-group-list 0.1.3 → 0.1.5
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.d.ts +1 -35
- package/dist/index.js +30 -35
- package/dist/utils/groupList.d.ts +27 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,35 +1 @@
|
|
|
1
|
-
|
|
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 selectItem(entryList: Ref<ListEntry[]>, id: string)
|
|
1
|
+
export * from './utils/groupList';
|
package/dist/index.js
CHANGED
|
@@ -1,61 +1,56 @@
|
|
|
1
|
-
function
|
|
2
|
-
return s.position < t.position ? -1 : s.position > t.position ? 1 : 0;
|
|
3
|
-
}
|
|
4
|
-
function c(s, t) {
|
|
1
|
+
function n(o, t) {
|
|
5
2
|
const i = [];
|
|
6
|
-
let
|
|
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 = [];
|
|
3
|
+
let s = [];
|
|
11
4
|
o.forEach((e) => {
|
|
12
|
-
i.
|
|
13
|
-
}),
|
|
14
|
-
|
|
15
|
-
)
|
|
16
|
-
|
|
5
|
+
e.type === 0 ? i.find((l) => l.id === e.id) ? console.assert(!1, "duplicate group", e) : i.push(e) : e.type === 1 ? s.find((l) => l.id === e.id) ? console.assert(!1, "duplicate item", e) : s.push(e) : console.assert(!1, "invalid type", e);
|
|
6
|
+
}), i.sort((e, l) => e.position - l.position), s.sort((e, l) => e.position - l.position);
|
|
7
|
+
const f = [];
|
|
8
|
+
s.forEach((e) => {
|
|
9
|
+
i.find((l) => l.id === e.group) || f.push(e.id);
|
|
10
|
+
}), s = s.filter((e) => !f.find((l) => l === e.id));
|
|
11
|
+
const a = [];
|
|
17
12
|
return i.forEach((e) => {
|
|
18
13
|
const l = [];
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}), e.count = l.length, e.count > 0 ? (
|
|
22
|
-
}),
|
|
14
|
+
s.forEach((c) => {
|
|
15
|
+
c.group === e.id && (c.show = !e.collapse, l.push(c));
|
|
16
|
+
}), e.count = l.length, e.count > 0 ? (a.push(e), a.push(...l)) : t || a.push(e);
|
|
17
|
+
}), a;
|
|
23
18
|
}
|
|
24
|
-
function
|
|
25
|
-
return
|
|
19
|
+
function u(o, t) {
|
|
20
|
+
return o.value.find((i) => i.id === t);
|
|
26
21
|
}
|
|
27
|
-
function p(
|
|
28
|
-
for (let
|
|
29
|
-
let f =
|
|
22
|
+
function p(o, t, i) {
|
|
23
|
+
for (let s = 0; s < o.value.length; s++) {
|
|
24
|
+
let f = o.value[s];
|
|
30
25
|
if (f.id === t) {
|
|
31
26
|
if (f.type !== 0) {
|
|
32
27
|
console.assert(!1, "type must be 0");
|
|
33
28
|
break;
|
|
34
29
|
}
|
|
35
|
-
for (f.collapse = i,
|
|
30
|
+
for (f.collapse = i, s++; s < o.value.length && (f = o.value[s], f.type !== 0); s++)
|
|
36
31
|
f.show = !i;
|
|
37
32
|
break;
|
|
38
33
|
}
|
|
39
34
|
}
|
|
40
35
|
}
|
|
41
|
-
function
|
|
42
|
-
return
|
|
36
|
+
function d(o) {
|
|
37
|
+
return !!o.value.find((t) => t.type === 0 && t.detail);
|
|
43
38
|
}
|
|
44
|
-
function
|
|
45
|
-
|
|
39
|
+
function h(o, t) {
|
|
40
|
+
o.value.forEach((i) => {
|
|
46
41
|
i.type === 0 && (i.detail = i.id === t);
|
|
47
42
|
});
|
|
48
43
|
}
|
|
49
|
-
function
|
|
50
|
-
|
|
44
|
+
function r(o, t) {
|
|
45
|
+
o.value.forEach((i) => {
|
|
51
46
|
i.type !== 0 && (i.select = i.id === t);
|
|
52
47
|
});
|
|
53
48
|
}
|
|
54
49
|
export {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
u as getListEntry,
|
|
51
|
+
d as hasDetail,
|
|
52
|
+
r as selectItem,
|
|
58
53
|
p as setCollapse,
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
n as tidyList,
|
|
55
|
+
h as toggleDetail
|
|
61
56
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
count: number;
|
|
9
|
+
detail?: boolean;
|
|
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
|
+
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 {};
|