@ditari/store 5.0.8 → 5.0.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/cjs/modules/useMenuStore.cjs +39 -1
- package/dist/cjs/modules/useMenuStore.cjs.map +1 -1
- package/dist/esm/modules/useMenuStore.mjs +39 -1
- package/dist/esm/modules/useMenuStore.mjs.map +1 -1
- package/dist/types/modules/useMenuStore.d.ts +7 -3
- package/dist/types/modules/useMenuStore.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -6,6 +6,25 @@ var pinia = require('pinia');
|
|
|
6
6
|
var types = require('../types.cjs');
|
|
7
7
|
|
|
8
8
|
"use strict";
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __defProps = Object.defineProperties;
|
|
11
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
12
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
15
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
16
|
+
var __spreadValues = (a, b) => {
|
|
17
|
+
for (var prop in b || (b = {}))
|
|
18
|
+
if (__hasOwnProp.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
if (__getOwnPropSymbols)
|
|
21
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
22
|
+
if (__propIsEnum.call(b, prop))
|
|
23
|
+
__defNormalProp(a, prop, b[prop]);
|
|
24
|
+
}
|
|
25
|
+
return a;
|
|
26
|
+
};
|
|
27
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
9
28
|
const useMenuStore = pinia.defineStore(types.MENU_ID, {
|
|
10
29
|
state: () => {
|
|
11
30
|
return {
|
|
@@ -16,11 +35,30 @@ const useMenuStore = pinia.defineStore(types.MENU_ID, {
|
|
|
16
35
|
},
|
|
17
36
|
actions: {
|
|
18
37
|
save(data) {
|
|
19
|
-
this.data = data;
|
|
38
|
+
this.data = _addMenuIds(data);
|
|
20
39
|
}
|
|
21
40
|
},
|
|
22
41
|
persist: true
|
|
23
42
|
});
|
|
43
|
+
function _addMenuIds(menuData, parentId = null, idPrefix = "") {
|
|
44
|
+
let counter = 0;
|
|
45
|
+
return menuData.map((menuItem) => {
|
|
46
|
+
const id = `${idPrefix}${counter++}`;
|
|
47
|
+
const newItem = __spreadProps(__spreadValues({}, menuItem), {
|
|
48
|
+
id,
|
|
49
|
+
key: id,
|
|
50
|
+
parentId
|
|
51
|
+
});
|
|
52
|
+
if (menuItem.children) {
|
|
53
|
+
newItem.children = _addMenuIds(
|
|
54
|
+
menuItem.children,
|
|
55
|
+
id,
|
|
56
|
+
`${id}-`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
return newItem;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
24
62
|
|
|
25
63
|
exports.default = useMenuStore;
|
|
26
64
|
//# sourceMappingURL=useMenuStore.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMenuStore.cjs","sources":["../../../src/modules/useMenuStore.ts"],"sourcesContent":["import { defineStore } from \"pinia\";\r\n\r\nimport { MENU_ID } from \"../types\";\r\nimport type { ItemType } from \"ant-design-vue\";\r\n\r\
|
|
1
|
+
{"version":3,"file":"useMenuStore.cjs","sources":["../../../src/modules/useMenuStore.ts"],"sourcesContent":["import { defineStore } from \"pinia\";\r\n\r\nimport { MENU_ID } from \"../types\";\r\nimport type { ItemType } from \"ant-design-vue\";\r\n\r\nexport type ExtendedItemType = ItemType & {\r\n id?: string;\r\n parentId?: string;\r\n};\r\n\r\nexport interface Menu {\r\n openKeys: string[];\r\n selectedKeys: string[];\r\n data: ExtendedItemType[];\r\n}\r\n\r\nconst useMenuStore = defineStore(MENU_ID, {\r\n state: (): Menu => {\r\n return {\r\n openKeys: [],\r\n selectedKeys: [],\r\n data: []\r\n };\r\n },\r\n actions: {\r\n save(data: ExtendedItemType[]) {\r\n this.data = _addMenuIds(data);\r\n }\r\n },\r\n persist: true\r\n});\r\n\r\nfunction _addMenuIds(\r\n menuData: any,\r\n parentId: any = null,\r\n idPrefix = \"\"\r\n) {\r\n let counter = 0;\r\n\r\n return menuData.map((menuItem: any) => {\r\n const id = `${idPrefix}${counter++}`;\r\n const newItem = {\r\n ...menuItem,\r\n id,\r\n key: id,\r\n parentId\r\n };\r\n\r\n if (menuItem.children) {\r\n newItem.children = _addMenuIds(\r\n menuItem.children,\r\n id,\r\n `${id}-`\r\n );\r\n }\r\n\r\n return newItem;\r\n });\r\n}\r\n\r\nexport default useMenuStore;\r\n"],"names":["defineStore","MENU_ID"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBM,MAAA,YAAA,GAAeA,kBAAYC,aAAS,EAAA;AAAA,EACxC,OAAO,MAAY;AACjB,IAAO,OAAA;AAAA,MACL,UAAU,EAAC;AAAA,MACX,cAAc,EAAC;AAAA,MACf,MAAM;AAAC,KACT;AAAA,GACF;AAAA,EACA,OAAS,EAAA;AAAA,IACP,KAAK,IAA0B,EAAA;AAC7B,MAAK,IAAA,CAAA,IAAA,GAAO,YAAY,IAAI,CAAA;AAAA;AAC9B,GACF;AAAA,EACA,OAAS,EAAA;AACX,CAAC;AAED,SAAS,WACP,CAAA,QAAA,EACA,QAAgB,GAAA,IAAA,EAChB,WAAW,EACX,EAAA;AACA,EAAA,IAAI,OAAU,GAAA,CAAA;AAEd,EAAO,OAAA,QAAA,CAAS,GAAI,CAAA,CAAC,QAAkB,KAAA;AACrC,IAAA,MAAM,EAAK,GAAA,CAAA,EAAG,QAAQ,CAAA,EAAG,OAAS,EAAA,CAAA,CAAA;AAClC,IAAM,MAAA,OAAA,GAAU,iCACX,QADW,CAAA,EAAA;AAAA,MAEd,EAAA;AAAA,MACA,GAAK,EAAA,EAAA;AAAA,MACL;AAAA,KACF,CAAA;AAEA,IAAA,IAAI,SAAS,QAAU,EAAA;AACrB,MAAA,OAAA,CAAQ,QAAW,GAAA,WAAA;AAAA,QACjB,QAAS,CAAA,QAAA;AAAA,QACT,EAAA;AAAA,QACA,GAAG,EAAE,CAAA,CAAA;AAAA,OACP;AAAA;AAGF,IAAO,OAAA,OAAA;AAAA,GACR,CAAA;AACH;;;;"}
|
|
@@ -2,6 +2,25 @@ import { defineStore } from 'pinia';
|
|
|
2
2
|
import { MENU_ID } from '../types.mjs';
|
|
3
3
|
|
|
4
4
|
"use strict";
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __defProps = Object.defineProperties;
|
|
7
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
5
24
|
const useMenuStore = defineStore(MENU_ID, {
|
|
6
25
|
state: () => {
|
|
7
26
|
return {
|
|
@@ -12,11 +31,30 @@ const useMenuStore = defineStore(MENU_ID, {
|
|
|
12
31
|
},
|
|
13
32
|
actions: {
|
|
14
33
|
save(data) {
|
|
15
|
-
this.data = data;
|
|
34
|
+
this.data = _addMenuIds(data);
|
|
16
35
|
}
|
|
17
36
|
},
|
|
18
37
|
persist: true
|
|
19
38
|
});
|
|
39
|
+
function _addMenuIds(menuData, parentId = null, idPrefix = "") {
|
|
40
|
+
let counter = 0;
|
|
41
|
+
return menuData.map((menuItem) => {
|
|
42
|
+
const id = `${idPrefix}${counter++}`;
|
|
43
|
+
const newItem = __spreadProps(__spreadValues({}, menuItem), {
|
|
44
|
+
id,
|
|
45
|
+
key: id,
|
|
46
|
+
parentId
|
|
47
|
+
});
|
|
48
|
+
if (menuItem.children) {
|
|
49
|
+
newItem.children = _addMenuIds(
|
|
50
|
+
menuItem.children,
|
|
51
|
+
id,
|
|
52
|
+
`${id}-`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
return newItem;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
20
58
|
|
|
21
59
|
export { useMenuStore as default };
|
|
22
60
|
//# sourceMappingURL=useMenuStore.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMenuStore.mjs","sources":["../../../src/modules/useMenuStore.ts"],"sourcesContent":["import { defineStore } from \"pinia\";\r\n\r\nimport { MENU_ID } from \"../types\";\r\nimport type { ItemType } from \"ant-design-vue\";\r\n\r\
|
|
1
|
+
{"version":3,"file":"useMenuStore.mjs","sources":["../../../src/modules/useMenuStore.ts"],"sourcesContent":["import { defineStore } from \"pinia\";\r\n\r\nimport { MENU_ID } from \"../types\";\r\nimport type { ItemType } from \"ant-design-vue\";\r\n\r\nexport type ExtendedItemType = ItemType & {\r\n id?: string;\r\n parentId?: string;\r\n};\r\n\r\nexport interface Menu {\r\n openKeys: string[];\r\n selectedKeys: string[];\r\n data: ExtendedItemType[];\r\n}\r\n\r\nconst useMenuStore = defineStore(MENU_ID, {\r\n state: (): Menu => {\r\n return {\r\n openKeys: [],\r\n selectedKeys: [],\r\n data: []\r\n };\r\n },\r\n actions: {\r\n save(data: ExtendedItemType[]) {\r\n this.data = _addMenuIds(data);\r\n }\r\n },\r\n persist: true\r\n});\r\n\r\nfunction _addMenuIds(\r\n menuData: any,\r\n parentId: any = null,\r\n idPrefix = \"\"\r\n) {\r\n let counter = 0;\r\n\r\n return menuData.map((menuItem: any) => {\r\n const id = `${idPrefix}${counter++}`;\r\n const newItem = {\r\n ...menuItem,\r\n id,\r\n key: id,\r\n parentId\r\n };\r\n\r\n if (menuItem.children) {\r\n newItem.children = _addMenuIds(\r\n menuItem.children,\r\n id,\r\n `${id}-`\r\n );\r\n }\r\n\r\n return newItem;\r\n });\r\n}\r\n\r\nexport default useMenuStore;\r\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgBM,MAAA,YAAA,GAAe,YAAY,OAAS,EAAA;AAAA,EACxC,OAAO,MAAY;AACjB,IAAO,OAAA;AAAA,MACL,UAAU,EAAC;AAAA,MACX,cAAc,EAAC;AAAA,MACf,MAAM;AAAC,KACT;AAAA,GACF;AAAA,EACA,OAAS,EAAA;AAAA,IACP,KAAK,IAA0B,EAAA;AAC7B,MAAK,IAAA,CAAA,IAAA,GAAO,YAAY,IAAI,CAAA;AAAA;AAC9B,GACF;AAAA,EACA,OAAS,EAAA;AACX,CAAC;AAED,SAAS,WACP,CAAA,QAAA,EACA,QAAgB,GAAA,IAAA,EAChB,WAAW,EACX,EAAA;AACA,EAAA,IAAI,OAAU,GAAA,CAAA;AAEd,EAAO,OAAA,QAAA,CAAS,GAAI,CAAA,CAAC,QAAkB,KAAA;AACrC,IAAA,MAAM,EAAK,GAAA,CAAA,EAAG,QAAQ,CAAA,EAAG,OAAS,EAAA,CAAA,CAAA;AAClC,IAAM,MAAA,OAAA,GAAU,iCACX,QADW,CAAA,EAAA;AAAA,MAEd,EAAA;AAAA,MACA,GAAK,EAAA,EAAA;AAAA,MACL;AAAA,KACF,CAAA;AAEA,IAAA,IAAI,SAAS,QAAU,EAAA;AACrB,MAAA,OAAA,CAAQ,QAAW,GAAA,WAAA;AAAA,QACjB,QAAS,CAAA,QAAA;AAAA,QACT,EAAA;AAAA,QACA,GAAG,EAAE,CAAA,CAAA;AAAA,OACP;AAAA;AAGF,IAAO,OAAA,OAAA;AAAA,GACR,CAAA;AACH;;;;"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import type { ItemType } from "ant-design-vue";
|
|
2
|
-
|
|
2
|
+
export type ExtendedItemType = ItemType & {
|
|
3
|
+
id?: string;
|
|
4
|
+
parentId?: string;
|
|
5
|
+
};
|
|
6
|
+
export interface Menu {
|
|
3
7
|
openKeys: string[];
|
|
4
8
|
selectedKeys: string[];
|
|
5
|
-
data:
|
|
9
|
+
data: ExtendedItemType[];
|
|
6
10
|
}
|
|
7
11
|
declare const useMenuStore: import("pinia").StoreDefinition<"_STORE_MENU_ID", Menu, {}, {
|
|
8
|
-
save(data:
|
|
12
|
+
save(data: ExtendedItemType[]): void;
|
|
9
13
|
}>;
|
|
10
14
|
export default useMenuStore;
|
|
11
15
|
//# sourceMappingURL=useMenuStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMenuStore.d.ts","sourceRoot":"","sources":["../../../src/modules/useMenuStore.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,
|
|
1
|
+
{"version":3,"file":"useMenuStore.d.ts","sourceRoot":"","sources":["../../../src/modules/useMenuStore.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG;IACxC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,IAAI;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,IAAI,EAAE,gBAAgB,EAAE,CAAC;CAC1B;AAED,QAAA,MAAM,YAAY;eASH,gBAAgB,EAAE;EAK/B,CAAC;AA8BH,eAAe,YAAY,CAAC"}
|