@fairys/taro-tools-react 1.0.4 → 1.0.6

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.
Files changed (50) hide show
  1. package/esm/context/auth.data.instance.d.ts +3 -3
  2. package/esm/context/auth.data.instance.js +6 -6
  3. package/esm/context/global.data.instance.d.ts +4 -0
  4. package/esm/context/global.data.instance.js +5 -0
  5. package/esm/context/page.info.data.instance.d.ts +1 -1
  6. package/lib/components/EnterLoading/index.d.ts +14 -0
  7. package/lib/components/EnterLoading/index.js +112 -0
  8. package/lib/components/MainPage/index.d.ts +10 -0
  9. package/lib/components/MainPage/index.js +102 -0
  10. package/lib/components/Mesage/index.d.ts +48 -0
  11. package/lib/components/Mesage/index.js +172 -0
  12. package/lib/components/Portal/index.d.ts +8 -0
  13. package/lib/components/Portal/index.js +45 -0
  14. package/lib/components/Toast/index.d.ts +1 -0
  15. package/lib/components/Toast/index.js +54 -0
  16. package/lib/components/connectToastMessage/index.d.ts +10 -0
  17. package/lib/components/connectToastMessage/index.js +62 -0
  18. package/lib/components/index.d.ts +6 -0
  19. package/lib/components/index.js +105 -0
  20. package/lib/context/auth.data.instance.d.ts +81 -0
  21. package/lib/context/auth.data.instance.js +155 -0
  22. package/lib/context/global.data.instance.d.ts +54 -0
  23. package/lib/context/global.data.instance.js +122 -0
  24. package/lib/context/global.setting.data.instance.d.ts +56 -0
  25. package/lib/context/global.setting.data.instance.js +79 -0
  26. package/lib/context/index.d.ts +5 -0
  27. package/lib/context/index.js +96 -0
  28. package/lib/context/page.data.instance.d.ts +151 -0
  29. package/lib/context/page.data.instance.js +382 -0
  30. package/lib/context/page.info.data.instance.d.ts +93 -0
  31. package/lib/context/page.info.data.instance.js +226 -0
  32. package/lib/index.d.ts +3 -0
  33. package/lib/styles/index.css +715 -0
  34. package/lib/utils/index.d.ts +4 -0
  35. package/lib/utils/index.js +87 -0
  36. package/lib/utils/navigate.d.ts +109 -0
  37. package/lib/utils/navigate.js +99 -0
  38. package/lib/utils/request.d.ts +179 -0
  39. package/lib/utils/request.js +358 -0
  40. package/lib/utils/useId.d.ts +2 -0
  41. package/lib/utils/useId.js +50 -0
  42. package/lib/utils/valtio/index.d.ts +9 -0
  43. package/lib/utils/valtio/index.js +99 -0
  44. package/lib/utils/valtio/instance.d.ts +17 -0
  45. package/lib/utils/valtio/instance.js +80 -0
  46. package/package.json +4 -3
  47. package/src/context/auth.data.instance.ts +6 -6
  48. package/src/context/global.data.instance.ts +11 -0
  49. package/src/context/page.info.data.instance.tsx +1 -1
  50. package/src/utils/navigate.ts +1 -0
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ GlobalSettingDataInstance: ()=>GlobalSettingDataInstance,
28
+ useGlobalSettingData: ()=>useGlobalSettingData,
29
+ globalSettingDataInstance: ()=>globalSettingDataInstance
30
+ });
31
+ const external_valtio_namespaceObject = require("valtio");
32
+ const instance_js_namespaceObject = require("../utils/valtio/instance.js");
33
+ class GlobalSettingDataInstance extends instance_js_namespaceObject.ProxyInstanceObjectBase {
34
+ defaultStore = {
35
+ requestSuccessCode: 200,
36
+ tokenFieldName: 'token',
37
+ headerTokenName: 'token',
38
+ tokenExpiredCode: 401,
39
+ loginPageRoute: 'pages/login/index',
40
+ ignoreAuthRoutes: [],
41
+ useAuthHasMenuPermission: true,
42
+ isEnableAuth: true
43
+ };
44
+ store = (0, external_valtio_namespaceObject.proxy)({
45
+ ...this.defaultStore
46
+ });
47
+ extendStore = (state)=>{
48
+ this._setValues({
49
+ ...this.defaultStore,
50
+ ...state
51
+ });
52
+ };
53
+ isIgnoreAuthRoutes = (route)=>{
54
+ const _route = route.replace(/^\//, '');
55
+ const _loginPageRoute = this.store.loginPageRoute.replace(/^\//, '');
56
+ if (_route === _loginPageRoute) return true;
57
+ return (this.store.ignoreAuthRoutes || []).includes(_route) || (this.store.ignoreAuthRoutes || []).includes(route);
58
+ };
59
+ }
60
+ const globalSettingDataInstance = new GlobalSettingDataInstance();
61
+ const useGlobalSettingData = ()=>{
62
+ const store = (0, external_valtio_namespaceObject.useSnapshot)(globalSettingDataInstance.store);
63
+ return [
64
+ store,
65
+ globalSettingDataInstance,
66
+ store.__defaultValue
67
+ ];
68
+ };
69
+ exports.GlobalSettingDataInstance = __webpack_exports__.GlobalSettingDataInstance;
70
+ exports.globalSettingDataInstance = __webpack_exports__.globalSettingDataInstance;
71
+ exports.useGlobalSettingData = __webpack_exports__.useGlobalSettingData;
72
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
73
+ "GlobalSettingDataInstance",
74
+ "globalSettingDataInstance",
75
+ "useGlobalSettingData"
76
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
77
+ Object.defineProperty(exports, '__esModule', {
78
+ value: true
79
+ });
@@ -0,0 +1,5 @@
1
+ export * from './global.data.instance';
2
+ export * from './page.data.instance';
3
+ export * from './page.info.data.instance';
4
+ export * from './auth.data.instance';
5
+ export * from './global.setting.data.instance';
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __webpack_modules__ = {
3
+ "./auth.data.instance": function(module) {
4
+ module.exports = require("./auth.data.instance.js");
5
+ },
6
+ "./global.data.instance": function(module) {
7
+ module.exports = require("./global.data.instance.js");
8
+ },
9
+ "./global.setting.data.instance": function(module) {
10
+ module.exports = require("./global.setting.data.instance.js");
11
+ },
12
+ "./page.data.instance": function(module) {
13
+ module.exports = require("./page.data.instance.js");
14
+ },
15
+ "./page.info.data.instance": function(module) {
16
+ module.exports = require("./page.info.data.instance.js");
17
+ }
18
+ };
19
+ var __webpack_module_cache__ = {};
20
+ function __webpack_require__(moduleId) {
21
+ var cachedModule = __webpack_module_cache__[moduleId];
22
+ if (void 0 !== cachedModule) return cachedModule.exports;
23
+ var module = __webpack_module_cache__[moduleId] = {
24
+ exports: {}
25
+ };
26
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
27
+ return module.exports;
28
+ }
29
+ (()=>{
30
+ __webpack_require__.n = (module)=>{
31
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
32
+ __webpack_require__.d(getter, {
33
+ a: getter
34
+ });
35
+ return getter;
36
+ };
37
+ })();
38
+ (()=>{
39
+ __webpack_require__.d = (exports1, definition)=>{
40
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
41
+ enumerable: true,
42
+ get: definition[key]
43
+ });
44
+ };
45
+ })();
46
+ (()=>{
47
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
48
+ })();
49
+ (()=>{
50
+ __webpack_require__.r = (exports1)=>{
51
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
52
+ value: 'Module'
53
+ });
54
+ Object.defineProperty(exports1, '__esModule', {
55
+ value: true
56
+ });
57
+ };
58
+ })();
59
+ var __webpack_exports__ = {};
60
+ (()=>{
61
+ __webpack_require__.r(__webpack_exports__);
62
+ var _global_data_instance__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./global.data.instance");
63
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
64
+ for(var __WEBPACK_IMPORT_KEY__ in _global_data_instance__WEBPACK_IMPORTED_MODULE_0__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
65
+ return _global_data_instance__WEBPACK_IMPORTED_MODULE_0__[key];
66
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
67
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
68
+ var _page_data_instance__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./page.data.instance");
69
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
70
+ for(var __WEBPACK_IMPORT_KEY__ in _page_data_instance__WEBPACK_IMPORTED_MODULE_1__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
71
+ return _page_data_instance__WEBPACK_IMPORTED_MODULE_1__[key];
72
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
73
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
74
+ var _page_info_data_instance__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./page.info.data.instance");
75
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
76
+ for(var __WEBPACK_IMPORT_KEY__ in _page_info_data_instance__WEBPACK_IMPORTED_MODULE_2__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
77
+ return _page_info_data_instance__WEBPACK_IMPORTED_MODULE_2__[key];
78
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
79
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
80
+ var _auth_data_instance__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./auth.data.instance");
81
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
82
+ for(var __WEBPACK_IMPORT_KEY__ in _auth_data_instance__WEBPACK_IMPORTED_MODULE_3__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
83
+ return _auth_data_instance__WEBPACK_IMPORTED_MODULE_3__[key];
84
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
85
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
86
+ var _global_setting_data_instance__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./global.setting.data.instance");
87
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
88
+ for(var __WEBPACK_IMPORT_KEY__ in _global_setting_data_instance__WEBPACK_IMPORTED_MODULE_4__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
89
+ return _global_setting_data_instance__WEBPACK_IMPORTED_MODULE_4__[key];
90
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
91
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
92
+ })();
93
+ for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
94
+ Object.defineProperty(exports, '__esModule', {
95
+ value: true
96
+ });
@@ -0,0 +1,151 @@
1
+ import { ProxyInstanceObjectBase } from '../utils/valtio/instance';
2
+ export interface PageDataInstanceState extends Object {
3
+ /**loading存储*/
4
+ loading?: Record<string, boolean>;
5
+ /**当前页*/
6
+ page?: number;
7
+ /**分页数*/
8
+ pageSize?: number;
9
+ /**默认分页数*/
10
+ defaultPageSize?: number;
11
+ /**总数*/
12
+ total?: number;
13
+ /**是否最后一页*/
14
+ hasLastPage?: boolean;
15
+ /**查询条件*/
16
+ search?: Record<string, any>;
17
+ /**表格数据*/
18
+ dataList?: any[];
19
+ /**选择行数据*/
20
+ selectedRows?: any[];
21
+ selectedRowKeys?: any[];
22
+ /**一下是tab多页签使用*/
23
+ tabKey?: string;
24
+ /**tab多页签配置*/
25
+ tabItems?: {
26
+ /**tab页签key*/
27
+ key: string;
28
+ /**tab页签显示名称*/
29
+ label: string;
30
+ /**tab页签接口*/
31
+ api?: (payload: any, tabKey: string, instance: PageDataInstance) => Promise<{
32
+ code?: number;
33
+ data?: any;
34
+ message?: string;
35
+ }>;
36
+ /**tab页签默认查询参数*/
37
+ query?: Record<string, any>;
38
+ [s: string]: any;
39
+ }[];
40
+ /**是否是tab多页签*/
41
+ isTabs?: boolean;
42
+ /**是否展开查询条件*/
43
+ expandSearch?: boolean;
44
+ /**数据默认值不使用*/
45
+ __defaultValue?: string;
46
+ [s: string]: any;
47
+ }
48
+ export declare class PageDataInstance<T extends PageDataInstanceState = PageDataInstanceState> extends ProxyInstanceObjectBase<T> {
49
+ /**不使用ref存储的字段*/
50
+ notRefFields: string[];
51
+ /**请求之前处理参数*/
52
+ onBefore?: (payload: any, store: T, instance: PageDataInstance<T>) => Partial<T>;
53
+ /**请求接口*/
54
+ getList?: (payload: any, instance: PageDataInstance<T>) => Promise<{
55
+ code?: number;
56
+ data?: any;
57
+ message?: string;
58
+ }>;
59
+ /**请求之后处理返回值进行存储*/
60
+ onAfter?: (data: Record<string, any>, instance: PageDataInstance<T>) => Partial<T>;
61
+ /**额外数据处理*/
62
+ onExtraData?: (data: Record<string, any>, instance: PageDataInstance<T>) => Record<string, any>;
63
+ /** code!==1 时 触发*/
64
+ onError?: (data: Record<string, any>, instance: PageDataInstance<T>) => void;
65
+ /**重置获取值的方法*/
66
+ getResetValues?: (instance: PageDataInstance<T>) => Record<string, any>;
67
+ /**默认查询参数*/
68
+ defaultQuery?: Record<string, any>;
69
+ /**那些字段取值对象 code值*/
70
+ codeFields?: string[];
71
+ /**那些字段取值对象的 value 值 */
72
+ valueFields?: string[];
73
+ /**是否滚动加载分页*/
74
+ is_scroll_page: boolean;
75
+ /**默认值*/
76
+ defaultInital: T;
77
+ store: T;
78
+ ctor: (options?: PageDataOptions<T>) => void;
79
+ /**初始化状态值*/
80
+ main_page_store: (initalValues?: Partial<T>, file?: string[]) => this;
81
+ /**格式化请求参数*/
82
+ formateParams: (params: Record<string, any>) => {};
83
+ /**更新查询条件*/
84
+ updatedSearch: (value?: Record<string, any>) => void;
85
+ /**更新页面级的 pageLoading */
86
+ updatedPageLoading: (loading?: boolean) => void;
87
+ /**更新页面级的 loadMore */
88
+ updatedLoading: (value: Record<string, boolean>) => void;
89
+ /**内置——查询列表*/
90
+ main_getList: () => Promise<void>;
91
+ /**内置——翻页*/
92
+ main_onPageChange: (page: number) => void;
93
+ /**内置——翻页切换*/
94
+ main_onShowSizeChange: (_: number, pageSize: number) => void;
95
+ /**弹框内字段重置,如果没有获取字段值的方法,则直接清理所有字段值*/
96
+ main_onReset: () => void;
97
+ /**内置——查询方法*/
98
+ main_onSearch: () => void;
99
+ /**加载更多*/
100
+ main_onLoadMore: () => Promise<void>;
101
+ }
102
+ export interface PageDataOptions<T extends PageDataInstanceState = PageDataInstanceState> {
103
+ /**初始值*/
104
+ initialValues?: Partial<T>;
105
+ /**是否滚动加载更多*/
106
+ is_scroll_page?: boolean;
107
+ /**默认tab key*/
108
+ defaultTabKey?: string;
109
+ /**tab多页签配置*/
110
+ tabItems?: PageDataInstanceState['tabItems'];
111
+ /**默认分页数*/
112
+ defaultPageSize?: number;
113
+ }
114
+ /**初始化实例*/
115
+ export declare function usePageDataInstance<T extends PageDataInstanceState = PageDataInstanceState>(instance?: PageDataInstance<T>): PageDataInstance<T>;
116
+ /**页面级数据状态管理上下文*/
117
+ export declare const PageDataInstanceContext: import("react").Context<PageDataInstance<PageDataInstanceState>>;
118
+ /**获取上下文实例*/
119
+ export declare const usePageDataInstanceContext: <T extends PageDataInstanceState = PageDataInstanceState>() => PageDataInstance<T>;
120
+ export interface PageDataInstanceContextProviderProps<T extends PageDataInstanceState = PageDataInstanceState> extends PageDataOptions<T> {
121
+ instance?: PageDataInstance<T>;
122
+ children: React.ReactNode;
123
+ /**请求之前处理参数*/
124
+ onBefore?: PageDataInstance<T>['onBefore'];
125
+ /**请求接口*/
126
+ getList?: PageDataInstance<T>['getList'];
127
+ /**请求之后处理返回值进行存储*/
128
+ onAfter?: PageDataInstance<T>['onAfter'];
129
+ /** 额外数据处理*/
130
+ onExtraData?: PageDataInstance<T>['onExtraData'];
131
+ /** code!== 200 时 触发*/
132
+ onError?: PageDataInstance<T>['onError'];
133
+ /**获取弹框内重置参数*/
134
+ getResetValues?: PageDataInstance<T>['getResetValues'];
135
+ /**默认查询参数*/
136
+ defaultQuery?: PageDataInstance<T>['defaultQuery'];
137
+ /**那些字段取值对象 code值*/
138
+ codeFields?: PageDataInstance<T>['codeFields'];
139
+ /**那些字段取值对象的 value 值 */
140
+ valueFields?: PageDataInstance<T>['valueFields'];
141
+ /**是否是第一次加载*/
142
+ isMountLoad?: boolean;
143
+ /**页面标题*/
144
+ title?: string;
145
+ }
146
+ /**页面级数据状态管理上下文提供者*/
147
+ export declare function PageDataInstanceContextProvider<T extends PageDataInstanceState = PageDataInstanceState>(props: PageDataInstanceContextProviderProps<T>): import("react/jsx-runtime").JSX.Element;
148
+ /**
149
+ * 页面级数据状态管理
150
+ */
151
+ export declare const usePageDataInstanceState: <T extends PageDataInstanceState = PageDataInstanceState>() => [T, PageDataInstance<T>, string | undefined];