x-group-list 0.4.11 → 0.4.13

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 CHANGED
@@ -1 +1,53 @@
1
- export * from './utils/groupList';
1
+ import { Ref } from 'vue';
2
+
3
+ export declare function diffPosInfos(oldPosInfos: PosInfos, newPosInfos: PosInfos): PosInfo[];
4
+
5
+ export declare function getListEntry(entryList: Ref<ListEntry[]>, id: string): ListEntry | undefined;
6
+
7
+ export declare function hasDetail(entryList: Ref<ListEntry[]>): boolean;
8
+
9
+ export declare type ListEntry = ListGroup | ListItem;
10
+
11
+ export declare interface ListGroup {
12
+ id: string;
13
+ type: 0;
14
+ name: string;
15
+ position: number;
16
+ collapse: boolean;
17
+ detail?: boolean;
18
+ count?: number;
19
+ }
20
+
21
+ export declare interface ListItem {
22
+ id: string;
23
+ type: 1;
24
+ name: string;
25
+ position: number;
26
+ group: string;
27
+ select?: boolean;
28
+ show?: boolean;
29
+ }
30
+
31
+ export declare function onDragEnd(entryList: Ref<ListEntry[]>, draggingType: 0 | 1, oldIndex: number, newIndex: number): void;
32
+
33
+ export declare interface PosInfo {
34
+ id: string;
35
+ group: string;
36
+ position: number;
37
+ }
38
+
39
+ export declare type PosInfos = {
40
+ [key: string]: PosInfo;
41
+ };
42
+
43
+ export declare function selectItem(entryList: Ref<ListEntry[]>, id: string): void;
44
+
45
+ export declare function setCollapse(entryList: Ref<ListEntry[]>, id: string, collapse: boolean): void;
46
+
47
+ export declare function tidyList(entryList: ListEntry[], clean: boolean): ListEntry[];
48
+
49
+ export declare function toggleDetail(entryList: Ref<ListEntry[]>, id: string): void;
50
+
51
+ export declare function toPosInfos(entryList: Ref<ListEntry[]>): PosInfos;
52
+
53
+ export { }
package/dist/index.js CHANGED
@@ -1,73 +1,75 @@
1
- function tidyList(e, r) {
2
- let i = [], a = [];
1
+ import "vue";
2
+ //#region src/utils/groupList.ts
3
+ function e(e, t) {
4
+ let n = [], r = [];
3
5
  e.forEach((e) => {
4
- e.type === 0 ? i.push(e) : e.type === 1 ? a.push(e) : console.assert(!1);
5
- }), i.sort((e, r) => e.position - r.position), a.sort((e, r) => e.position - r.position);
6
- let o = [];
7
- a.forEach((e) => {
8
- i.find((r) => r.id === e.group) || o.push(e.id);
9
- }), a = a.filter((e) => !o.find((r) => r === e.id));
10
- let s = [];
11
- return i.forEach((e) => {
12
- let i = [];
13
- a.forEach((r) => {
14
- r.group === e.id && (r.show = !e.collapse, i.push(r));
15
- }), e.count = i.length, e.count > 0 ? (s.push(e), s.push(...i)) : r || s.push(e);
16
- }), s;
6
+ e.type === 0 ? n.push(e) : e.type === 1 ? r.push(e) : console.assert(!1);
7
+ }), n.sort((e, t) => e.position - t.position), r.sort((e, t) => e.position - t.position);
8
+ let i = [];
9
+ r.forEach((e) => {
10
+ n.find((t) => t.id === e.group) || i.push(e.id);
11
+ }), r = r.filter((e) => !i.find((t) => t === e.id));
12
+ let a = [];
13
+ return n.forEach((e) => {
14
+ let n = [];
15
+ r.forEach((t) => {
16
+ t.group === e.id && (t.show = !e.collapse, n.push(t));
17
+ }), e.count = n.length, e.count > 0 ? (a.push(e), a.push(...n)) : t || a.push(e);
18
+ }), a;
17
19
  }
18
- function getListEntry(e, r) {
19
- return e.value.find((e) => e.id === r);
20
+ function t(e, t) {
21
+ return e.value.find((e) => e.id === t);
20
22
  }
21
- function setCollapse(e, r, i) {
22
- for (let a = 0; a < e.value.length; a++) {
23
- let o = e.value[a];
24
- if (o.id === r) {
25
- if (o.type !== 0) {
23
+ function n(e, t, n) {
24
+ for (let r = 0; r < e.value.length; r++) {
25
+ let i = e.value[r];
26
+ if (i.id === t) {
27
+ if (i.type !== 0) {
26
28
  console.assert(!1, "type must be 0");
27
29
  break;
28
30
  }
29
- for (o.collapse = i, a++; a < e.value.length && (o = e.value[a], o.type !== 0); a++) o.show = !i;
31
+ for (i.collapse = n, r++; r < e.value.length && (i = e.value[r], i.type !== 0); r++) i.show = !n;
30
32
  break;
31
33
  }
32
34
  }
33
35
  }
34
- function hasDetail(e) {
36
+ function r(e) {
35
37
  return !!e.value.find((e) => e.type === 0 && e.detail);
36
38
  }
37
- function toggleDetail(e, r) {
39
+ function i(e, t) {
38
40
  e.value.forEach((e) => {
39
- e.type === 0 && (e.detail = e.id === r);
41
+ e.type === 0 && (e.detail = e.id === t);
40
42
  });
41
43
  }
42
- function selectItem(e, r) {
44
+ function a(e, t) {
43
45
  e.value.forEach((e) => {
44
- e.type !== 0 && (e.select = e.id === r);
46
+ e.type !== 0 && (e.select = e.id === t);
45
47
  });
46
48
  }
47
- function onDragEnd(e, r, i, a) {
48
- if (r === 1) {
49
- if (a === 0) {
50
- let r = e.value.splice(a, 1)[0];
51
- e.value.splice(i, 0, r);
49
+ function o(e, t, n, r) {
50
+ if (t === 1) {
51
+ if (r === 0) {
52
+ let t = e.value.splice(r, 1)[0];
53
+ e.value.splice(n, 0, t);
52
54
  return;
53
55
  }
54
- let r;
55
- for (let i = 0; i < e.value.length; i++) {
56
- let a = e.value[i];
57
- if (a.type === 0) r = a;
58
- else if (a.type === 1) {
59
- if (!r) {
56
+ let t;
57
+ for (let n = 0; n < e.value.length; n++) {
58
+ let r = e.value[n];
59
+ if (r.type === 0) t = r;
60
+ else if (r.type === 1) {
61
+ if (!t) {
60
62
  console.assert(!1);
61
63
  return;
62
64
  }
63
- if (a.group !== r.id) {
64
- if (a.group = r.id, r.collapse) {
65
- let r = i;
66
- for (i++; i < e.value.length; i++) {
67
- let a = e.value[i];
68
- if (a.type === 0 || a.show) break;
69
- let o = e.value[r];
70
- e.value[r] = a, e.value[i] = o, r = i;
65
+ if (r.group !== t.id) {
66
+ if (r.group = t.id, t.collapse) {
67
+ let t = n;
68
+ for (n++; n < e.value.length; n++) {
69
+ let r = e.value[n];
70
+ if (r.type === 0 || r.show) break;
71
+ let i = e.value[t];
72
+ e.value[t] = r, e.value[n] = i, t = n;
71
73
  }
72
74
  }
73
75
  break;
@@ -75,39 +77,40 @@ function onDragEnd(e, r, i, a) {
75
77
  } else console.assert(!1);
76
78
  }
77
79
  }
78
- let o = [], s = [];
80
+ let i = [], a = [];
79
81
  e.value.forEach((e) => {
80
- e.type === 0 ? o.push(e) : e.type === 1 ? s.push(e) : console.assert(!1);
82
+ e.type === 0 ? i.push(e) : e.type === 1 ? a.push(e) : console.assert(!1);
81
83
  });
82
- let c = [];
83
- o.forEach((e, r) => {
84
- e.position = r;
85
- let i = [];
86
- s.forEach((r) => {
87
- r.group === e.id && (r.position = i.length, i.push(r));
88
- }), e.count = i.length, c.push(e), c.push(...i);
89
- }), e.value = c;
84
+ let o = [];
85
+ i.forEach((e, t) => {
86
+ e.position = t;
87
+ let n = [];
88
+ a.forEach((t) => {
89
+ t.group === e.id && (t.position = n.length, n.push(t));
90
+ }), e.count = n.length, o.push(e), o.push(...n);
91
+ }), e.value = o;
90
92
  }
91
- function toPosInfos(e) {
92
- let r = {};
93
+ function s(e) {
94
+ let t = {};
93
95
  return e.value.forEach((e) => {
94
- e.type === 0 ? r[e.id] = {
96
+ e.type === 0 ? t[e.id] = {
95
97
  id: e.id,
96
98
  group: "",
97
99
  position: e.position
98
- } : e.type === 1 ? r[e.id] = {
100
+ } : e.type === 1 ? t[e.id] = {
99
101
  id: e.id,
100
102
  group: e.group,
101
103
  position: e.position
102
104
  } : console.assert(!1);
103
- }), r;
105
+ }), t;
104
106
  }
105
- function diffPosInfos(e, r) {
106
- let i = [];
107
- for (let a in r) {
108
- let o = r[a], s = e[a];
109
- (!s || o.group !== s.group || o.position !== s.position) && i.push({ ...o });
107
+ function c(e, t) {
108
+ let n = [];
109
+ for (let r in t) {
110
+ let i = t[r], a = e[r];
111
+ (!a || i.group !== a.group || i.position !== a.position) && n.push({ ...i });
110
112
  }
111
- return i;
113
+ return n;
112
114
  }
113
- export { diffPosInfos, getListEntry, hasDetail, onDragEnd, selectItem, setCollapse, tidyList, toPosInfos, toggleDetail };
115
+ //#endregion
116
+ export { c as diffPosInfos, t as getListEntry, r as hasDetail, o as onDragEnd, a as selectItem, n as setCollapse, e as tidyList, s as toPosInfos, i as toggleDetail };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "x-group-list",
3
3
  "private": false,
4
- "version": "0.4.11",
4
+ "version": "0.4.13",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -22,31 +22,32 @@
22
22
  "*": "prettier --write ."
23
23
  },
24
24
  "dependencies": {
25
- "vue": "^3.5.29",
26
- "vuetify": "^4.0.0"
25
+ "vue": "^3.5.32",
26
+ "vuetify": "^4.0.5"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@eslint/js": "^10.0.1",
30
- "@types/node": "^25.3.0",
31
- "@vitejs/plugin-vue": "^6.0.4",
32
- "eslint": "^10.0.2",
30
+ "@tsconfig/node24": "^24.0.4",
31
+ "@types/node": "^25.5.2",
32
+ "@vitejs/plugin-vue": "^6.0.5",
33
+ "@vue/tsconfig": "^0.9.1",
34
+ "eslint": "^10.2.0",
33
35
  "eslint-config-prettier": "^10.1.8",
34
36
  "eslint-plugin-prettier": "^5.5.5",
37
+ "eslint-plugin-simple-import-sort": "^13.0.0",
35
38
  "eslint-plugin-vue": "^10.8.0",
36
- "globals": "^17.3.0",
39
+ "globals": "^17.4.0",
37
40
  "husky": "^9.1.7",
38
- "lint-staged": "^16.2.7",
41
+ "lint-staged": "^16.4.0",
39
42
  "prettier": "3.8.1",
40
- "sass": "^1.97.3",
43
+ "sass": "^1.99.0",
41
44
  "typescript": "^5.9.3",
42
- "typescript-eslint": "^8.56.1",
43
- "vite": "npm:rolldown-vite@7.3.1",
44
- "vite-plugin-css-injected-by-js": "^3.5.2",
45
+ "typescript-eslint": "^8.58.1",
46
+ "vite": "^8.0.7",
47
+ "vite-plugin-css-injected-by-js": "^4.0.1",
48
+ "vite-plugin-dts": "^4.5.4",
45
49
  "vite-plugin-vuetify": "^2.1.3",
46
50
  "vue-eslint-parser": "^10.4.0",
47
- "vue-tsc": "^3.2.5"
48
- },
49
- "overrides": {
50
- "vite": "npm:rolldown-vite@7.3.1"
51
+ "vue-tsc": "^3.2.6"
51
52
  }
52
53
  }
@@ -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[];