@sg-front-core/store-v1 1.0.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.
@@ -0,0 +1,204 @@
1
+ import type { TabsProps } from 'antd';
2
+ export declare enum LazilyKey {
3
+ userReq = 1,
4
+ menuReq = 2
5
+ }
6
+ export type SgTemplateUserLocal<TUser = any> = {
7
+ get: () => TUser;
8
+ set: (user: TUser) => void;
9
+ };
10
+ export type SgTemplateSystemDeps<TUserResp = any, TMenuResp = any, TUser = any, TMenu = any, TFlattenRoute = any, TPane = any, TLayoutStyle = any> = {
11
+ request: <T = unknown>(config: {
12
+ url: string;
13
+ method?: string;
14
+ headers?: Record<string, unknown> | undefined;
15
+ params?: unknown;
16
+ data?: unknown;
17
+ }) => Promise<T>;
18
+ userLocal: SgTemplateUserLocal<TUser>;
19
+ routesConfig: any[];
20
+ transConfig: (menuData: any, rootRoute: any) => void;
21
+ transMenu: (routesChildren: any) => TMenu[];
22
+ flattenRoutesFormat: (routes: any[]) => TFlattenRoute[];
23
+ initPane: TPane;
24
+ menuStyle: TLayoutStyle;
25
+ devTools?: boolean;
26
+ };
27
+ export declare function createSgTemplateSystemStore<TUserResp extends {
28
+ code: number;
29
+ data?: any;
30
+ } = any, TMenuResp extends {
31
+ code: number;
32
+ data?: any;
33
+ } = any, TUser = any, TMenu = any, TFlattenRoute = any, TPane = TabsProps['items'], TLayoutStyle = any>(deps: SgTemplateSystemDeps<TUserResp, TMenuResp, TUser, TMenu, TFlattenRoute, TPane, TLayoutStyle>): {
34
+ StoreProvider: import("react").FC<{
35
+ children?: import("react").ReactNode | undefined;
36
+ }>;
37
+ useSystemStore: (depsFn?: import("./types").DepsFn<{
38
+ 1: import("ahooks/lib/useRequest/src/types").Result<TUserResp, []>;
39
+ 2: import("ahooks/lib/useRequest/src/types").Result<TMenuResp, []>;
40
+ userReq: import("ahooks/lib/useRequest/src/types").Result<TUserResp, []>;
41
+ menuReq: import("ahooks/lib/useRequest/src/types").Result<TMenuResp, []>;
42
+ Routes: any[];
43
+ menus: TMenu[];
44
+ user: TUser;
45
+ activeTopLabel: string;
46
+ setActiveTopLabel: import("react").Dispatch<import("react").SetStateAction<string>>;
47
+ dynamicFlatternRouteScale: (newRoute: any) => void;
48
+ layoutStyle: TLayoutStyle;
49
+ setLayoutStyle: import("react").Dispatch<import("react").SetStateAction<TLayoutStyle>>;
50
+ topRootMenus: {
51
+ label: any;
52
+ key: any;
53
+ }[];
54
+ activeLeftMenuChildren: any;
55
+ flattenRoutes: any;
56
+ panes: TPane;
57
+ setPanes: import("react").Dispatch<import("react").SetStateAction<TPane>>;
58
+ resetTabs: () => void;
59
+ activeKey: string;
60
+ setActiveKey: import("react").Dispatch<import("react").SetStateAction<string>>;
61
+ closeTab: () => void;
62
+ recoverConfig: () => void;
63
+ }> | undefined) => {
64
+ 1: import("ahooks/lib/useRequest/src/types").Result<TUserResp, []>;
65
+ 2: import("ahooks/lib/useRequest/src/types").Result<TMenuResp, []>;
66
+ userReq: import("ahooks/lib/useRequest/src/types").Result<TUserResp, []>;
67
+ menuReq: import("ahooks/lib/useRequest/src/types").Result<TMenuResp, []>;
68
+ Routes: any[];
69
+ menus: TMenu[];
70
+ user: TUser;
71
+ activeTopLabel: string;
72
+ setActiveTopLabel: import("react").Dispatch<import("react").SetStateAction<string>>;
73
+ dynamicFlatternRouteScale: (newRoute: any) => void;
74
+ layoutStyle: TLayoutStyle;
75
+ setLayoutStyle: import("react").Dispatch<import("react").SetStateAction<TLayoutStyle>>;
76
+ topRootMenus: {
77
+ label: any;
78
+ key: any;
79
+ }[];
80
+ activeLeftMenuChildren: any;
81
+ flattenRoutes: any;
82
+ panes: TPane;
83
+ setPanes: import("react").Dispatch<import("react").SetStateAction<TPane>>;
84
+ resetTabs: () => void;
85
+ activeKey: string;
86
+ setActiveKey: import("react").Dispatch<import("react").SetStateAction<string>>;
87
+ closeTab: () => void;
88
+ recoverConfig: () => void;
89
+ };
90
+ getSystemStore: () => {
91
+ 1: import("ahooks/lib/useRequest/src/types").Result<TUserResp, []>;
92
+ 2: import("ahooks/lib/useRequest/src/types").Result<TMenuResp, []>;
93
+ userReq: import("ahooks/lib/useRequest/src/types").Result<TUserResp, []>;
94
+ menuReq: import("ahooks/lib/useRequest/src/types").Result<TMenuResp, []>;
95
+ Routes: any[];
96
+ menus: TMenu[];
97
+ user: TUser;
98
+ activeTopLabel: string;
99
+ setActiveTopLabel: import("react").Dispatch<import("react").SetStateAction<string>>;
100
+ dynamicFlatternRouteScale: (newRoute: any) => void;
101
+ layoutStyle: TLayoutStyle;
102
+ setLayoutStyle: import("react").Dispatch<import("react").SetStateAction<TLayoutStyle>>;
103
+ topRootMenus: {
104
+ label: any;
105
+ key: any;
106
+ }[];
107
+ activeLeftMenuChildren: any;
108
+ flattenRoutes: any;
109
+ panes: TPane;
110
+ setPanes: import("react").Dispatch<import("react").SetStateAction<TPane>>;
111
+ resetTabs: () => void;
112
+ activeKey: string;
113
+ setActiveKey: import("react").Dispatch<import("react").SetStateAction<string>>;
114
+ closeTab: () => void;
115
+ recoverConfig: () => void;
116
+ } | undefined;
117
+ useLazilyStore: (depsFn?: import("./types").DepsFn<{
118
+ 1: import("ahooks/lib/useRequest/src/types").Result<TUserResp, []>;
119
+ 2: import("ahooks/lib/useRequest/src/types").Result<TMenuResp, []>;
120
+ userReq: import("ahooks/lib/useRequest/src/types").Result<TUserResp, []>;
121
+ menuReq: import("ahooks/lib/useRequest/src/types").Result<TMenuResp, []>;
122
+ Routes: any[];
123
+ menus: TMenu[];
124
+ user: TUser;
125
+ activeTopLabel: string;
126
+ setActiveTopLabel: import("react").Dispatch<import("react").SetStateAction<string>>;
127
+ dynamicFlatternRouteScale: (newRoute: any) => void;
128
+ layoutStyle: TLayoutStyle;
129
+ setLayoutStyle: import("react").Dispatch<import("react").SetStateAction<TLayoutStyle>>;
130
+ topRootMenus: {
131
+ label: any;
132
+ key: any;
133
+ }[];
134
+ activeLeftMenuChildren: any;
135
+ flattenRoutes: any;
136
+ panes: TPane;
137
+ setPanes: import("react").Dispatch<import("react").SetStateAction<TPane>>;
138
+ resetTabs: () => void;
139
+ activeKey: string;
140
+ setActiveKey: import("react").Dispatch<import("react").SetStateAction<string>>;
141
+ closeTab: () => void;
142
+ recoverConfig: () => void;
143
+ }> | undefined) => {
144
+ 1: import("ahooks/lib/useRequest/src/types").Result<TUserResp, []>;
145
+ 2: import("ahooks/lib/useRequest/src/types").Result<TMenuResp, []>;
146
+ userReq: import("ahooks/lib/useRequest/src/types").Result<TUserResp, []>;
147
+ menuReq: import("ahooks/lib/useRequest/src/types").Result<TMenuResp, []>;
148
+ Routes: any[];
149
+ menus: TMenu[];
150
+ user: TUser;
151
+ activeTopLabel: string;
152
+ setActiveTopLabel: import("react").Dispatch<import("react").SetStateAction<string>>;
153
+ dynamicFlatternRouteScale: (newRoute: any) => void;
154
+ layoutStyle: TLayoutStyle;
155
+ setLayoutStyle: import("react").Dispatch<import("react").SetStateAction<TLayoutStyle>>;
156
+ topRootMenus: {
157
+ label: any;
158
+ key: any;
159
+ }[];
160
+ activeLeftMenuChildren: any;
161
+ flattenRoutes: any;
162
+ panes: TPane;
163
+ setPanes: import("react").Dispatch<import("react").SetStateAction<TPane>>;
164
+ resetTabs: () => void;
165
+ activeKey: string;
166
+ setActiveKey: import("react").Dispatch<import("react").SetStateAction<string>>;
167
+ closeTab: () => void;
168
+ recoverConfig: () => void;
169
+ };
170
+ getLazilyStore: () => {
171
+ 1: import("ahooks/lib/useRequest/src/types").Result<TUserResp, []>;
172
+ 2: import("ahooks/lib/useRequest/src/types").Result<TMenuResp, []>;
173
+ userReq: import("ahooks/lib/useRequest/src/types").Result<TUserResp, []>;
174
+ menuReq: import("ahooks/lib/useRequest/src/types").Result<TMenuResp, []>;
175
+ Routes: any[];
176
+ menus: TMenu[];
177
+ user: TUser;
178
+ activeTopLabel: string;
179
+ setActiveTopLabel: import("react").Dispatch<import("react").SetStateAction<string>>;
180
+ dynamicFlatternRouteScale: (newRoute: any) => void;
181
+ layoutStyle: TLayoutStyle;
182
+ setLayoutStyle: import("react").Dispatch<import("react").SetStateAction<TLayoutStyle>>;
183
+ topRootMenus: {
184
+ label: any;
185
+ key: any;
186
+ }[];
187
+ activeLeftMenuChildren: any;
188
+ flattenRoutes: any;
189
+ panes: TPane;
190
+ setPanes: import("react").Dispatch<import("react").SetStateAction<TPane>>;
191
+ resetTabs: () => void;
192
+ activeKey: string;
193
+ setActiveKey: import("react").Dispatch<import("react").SetStateAction<string>>;
194
+ closeTab: () => void;
195
+ recoverConfig: () => void;
196
+ } | undefined;
197
+ useAppDispatch: () => undefined;
198
+ useAppSelector: () => undefined;
199
+ injectReducer: () => undefined;
200
+ removeReducer: () => undefined;
201
+ registerPersistSlice: () => undefined;
202
+ unregisterPersistSlice: () => undefined;
203
+ };
204
+ //# sourceMappingURL=sg-template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sg-template.d.ts","sourceRoot":"","sources":["../src/sg-template.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AAMrC,oBAAY,SAAS;IACnB,OAAO,IAAI;IACX,OAAO,IAAI;CACZ;AAED,MAAM,MAAM,mBAAmB,CAAC,KAAK,GAAG,GAAG,IAAI;IAC7C,GAAG,EAAE,MAAM,KAAK,CAAA;IAChB,GAAG,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,oBAAoB,CAC9B,SAAS,GAAG,GAAG,EACf,SAAS,GAAG,GAAG,EACf,KAAK,GAAG,GAAG,EACX,KAAK,GAAG,GAAG,EACX,aAAa,GAAG,GAAG,EACnB,KAAK,GAAG,GAAG,EACX,YAAY,GAAG,GAAG,IAChB;IACF,OAAO,EAAE,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE;QAC7B,GAAG,EAAE,MAAM,CAAA;QACX,MAAM,CAAC,EAAE,MAAM,C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;;;;;;;;;;8CAAH,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;8CAAH,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;8CAAH,GAAG;;;;;;;;;;;;;;;;;;;;;;;EAwEnD"}
@@ -0,0 +1,2 @@
1
+ export type DepsFn<T> = (data: T) => unknown[];
2
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,EAAE,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { Container } from './container';
2
+ import { DepsFn } from './types';
3
+ export declare function useDataFromContainer<T, P>(container: Container<T, P>, depsFn?: DepsFn<T>): T;
4
+ //# sourceMappingURL=use-data-from-container.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-data-from-container.d.ts","sourceRoot":"","sources":["../src/use-data-from-container.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhC,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,CAAC,EACvC,SAAS,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,GACjB,CAAC,CAyBH"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@sg-front-core/store-v1",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "files": [
6
+ "dist"
7
+ ],
8
+ "main": "./dist/core-store.umd.cjs",
9
+ "module": "./dist/core-store.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/core-store.js",
15
+ "require": "./dist/core-store.umd.cjs"
16
+ }
17
+ },
18
+ "browserslist": [
19
+ "> 0.2%",
20
+ "not dead",
21
+ "mot op_mini all"
22
+ ],
23
+ "peerDependencies": {
24
+ "react": ">=18.2.0",
25
+ "react-dom": ">=18.2.0"
26
+ },
27
+ "engines": {
28
+ "node": ">=20.19.0"
29
+ },
30
+ "dependencies": {
31
+ "ahooks": "^3.7.7"
32
+ },
33
+ "devDependencies": {
34
+ "@types/react": "^18.3.27",
35
+ "@types/react-dom": "^18.3.7",
36
+ "antd": "^5.24.3"
37
+ },
38
+ "scripts": {
39
+ "dev": "vite",
40
+ "build": "tsc && vite build && tsc -p tsconfig.build.json",
41
+ "build:watch": "vite build --watch"
42
+ }
43
+ }