@fairys/taro-tools-react 1.0.3 → 1.0.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.
Files changed (51) hide show
  1. package/esm/context/auth.data.instance.d.ts +10 -2
  2. package/esm/context/auth.data.instance.js +19 -3
  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/index.d.ts +1 -0
  6. package/esm/context/index.js +1 -0
  7. package/lib/components/EnterLoading/index.d.ts +14 -0
  8. package/lib/components/EnterLoading/index.js +112 -0
  9. package/lib/components/MainPage/index.d.ts +10 -0
  10. package/lib/components/MainPage/index.js +102 -0
  11. package/lib/components/Mesage/index.d.ts +48 -0
  12. package/lib/components/Mesage/index.js +172 -0
  13. package/lib/components/Portal/index.d.ts +8 -0
  14. package/lib/components/Portal/index.js +45 -0
  15. package/lib/components/Toast/index.d.ts +1 -0
  16. package/lib/components/Toast/index.js +54 -0
  17. package/lib/components/connectToastMessage/index.d.ts +10 -0
  18. package/lib/components/connectToastMessage/index.js +62 -0
  19. package/lib/components/index.d.ts +6 -0
  20. package/lib/components/index.js +105 -0
  21. package/lib/context/auth.data.instance.d.ts +81 -0
  22. package/lib/context/auth.data.instance.js +155 -0
  23. package/lib/context/global.data.instance.d.ts +54 -0
  24. package/lib/context/global.data.instance.js +122 -0
  25. package/lib/context/global.setting.data.instance.d.ts +56 -0
  26. package/lib/context/global.setting.data.instance.js +79 -0
  27. package/lib/context/index.d.ts +5 -0
  28. package/lib/context/index.js +96 -0
  29. package/lib/context/page.data.instance.d.ts +151 -0
  30. package/lib/context/page.data.instance.js +382 -0
  31. package/lib/context/page.info.data.instance.d.ts +93 -0
  32. package/lib/context/page.info.data.instance.js +226 -0
  33. package/lib/index.d.ts +3 -0
  34. package/lib/styles/index.css +715 -0
  35. package/lib/utils/index.d.ts +4 -0
  36. package/lib/utils/index.js +87 -0
  37. package/lib/utils/navigate.d.ts +109 -0
  38. package/lib/utils/navigate.js +99 -0
  39. package/lib/utils/request.d.ts +179 -0
  40. package/lib/utils/request.js +358 -0
  41. package/lib/utils/useId.d.ts +2 -0
  42. package/lib/utils/useId.js +50 -0
  43. package/lib/utils/valtio/index.d.ts +9 -0
  44. package/lib/utils/valtio/index.js +99 -0
  45. package/lib/utils/valtio/instance.d.ts +17 -0
  46. package/lib/utils/valtio/instance.js +80 -0
  47. package/package.json +4 -3
  48. package/src/context/auth.data.instance.ts +27 -3
  49. package/src/context/global.data.instance.ts +11 -0
  50. package/src/context/index.ts +1 -0
  51. package/src/utils/navigate.ts +1 -0
@@ -58,13 +58,21 @@ export declare class AuthDataInstance<T = any> {
58
58
  * @param menuPermission 菜单权限
59
59
  * @returns 是否有指定菜单权限
60
60
  */
61
- hasMenuPermission(menuPermission: string): boolean;
61
+ hasMenuPermission: (menuPermission: string) => boolean;
62
62
  /**
63
63
  * 判断是否有指定权限
64
64
  * @param permission 权限
65
65
  * @returns 是否有指定权限
66
66
  */
67
- hasPermission(permission: string): boolean;
67
+ hasPermission: (permission: string) => boolean;
68
+ /**
69
+ * 清除登录凭证(token)、权限列表、菜单权限列表、用户信息
70
+ */
71
+ clear: () => void;
72
+ /**
73
+ * 初始化认证数据实例
74
+ */
75
+ constructor();
68
76
  }
69
77
  export declare const authDataInstance: AuthDataInstance<any>;
70
78
  /**
@@ -68,13 +68,29 @@ class AuthDataInstance {
68
68
  }
69
69
  return this.store.menusPermissions || [];
70
70
  }
71
- hasMenuPermission(menuPermission) {
71
+ hasMenuPermission = (menuPermission)=>{
72
72
  if (!globalSettingDataInstance.store.isEnableAuth) return true;
73
73
  return this.menusPermissions.includes(menuPermission);
74
- }
75
- hasPermission(permission) {
74
+ };
75
+ hasPermission = (permission)=>{
76
76
  if (!globalSettingDataInstance.store.isEnableAuth) return true;
77
77
  return this.permissions.includes(permission);
78
+ };
79
+ clear = ()=>{
80
+ this.token = '';
81
+ this.permissions = [];
82
+ this.menusPermissions = [];
83
+ this.userInfo = void 0;
84
+ };
85
+ constructor(){
86
+ try {
87
+ this.store.userInfo = this.userInfo;
88
+ this.store.token = this.token;
89
+ this.store.permissions = this.permissions;
90
+ this.store.menusPermissions = this.menusPermissions;
91
+ } catch (error) {
92
+ console.error("\u521D\u59CB\u5316\u8BA4\u8BC1\u6570\u636E\u5B9E\u4F8B\u5931\u8D25", error);
93
+ }
78
94
  }
79
95
  }
80
96
  const authDataInstance = new AuthDataInstance();
@@ -37,6 +37,10 @@ export declare class GlobalDataInstance extends ProxyInstanceObjectBase<GlobalDa
37
37
  showToast: (config?: Partial<ToastDataType>) => void;
38
38
  /**隐藏Toast */
39
39
  hideToast: () => void;
40
+ /**
41
+ * 跳转登录页面前执行
42
+ */
43
+ onBeforetToLoginPage?: () => boolean | void;
40
44
  /**跳转登录页面*/
41
45
  toLoginPage: () => void;
42
46
  }
@@ -45,7 +45,12 @@ class GlobalDataInstance extends ProxyInstanceObjectBase {
45
45
  visible: false
46
46
  });
47
47
  };
48
+ onBeforetToLoginPage;
48
49
  toLoginPage = ()=>{
50
+ if (this.onBeforetToLoginPage) {
51
+ const f = this.onBeforetToLoginPage();
52
+ if (false === f) return;
53
+ }
49
54
  const loginPageRoute = globalSettingDataInstance.store.loginPageRoute || '';
50
55
  const isLoginPage = utils_navigate.isCurrentPage(loginPageRoute || '');
51
56
  const _loginPageRoute = `${loginPageRoute || ''}`.replace(/^\//, '');
@@ -1,4 +1,5 @@
1
1
  export * from './global.data.instance';
2
2
  export * from './page.data.instance';
3
3
  export * from './page.info.data.instance';
4
+ export * from './auth.data.instance';
4
5
  export * from './global.setting.data.instance';
@@ -1,4 +1,5 @@
1
1
  export * from "./global.data.instance.js";
2
2
  export * from "./page.data.instance.js";
3
3
  export * from "./page.info.data.instance.js";
4
+ export * from "./auth.data.instance.js";
4
5
  export * from "./global.setting.data.instance.js";
@@ -0,0 +1,14 @@
1
+ import { ViewProps } from '@tarojs/components';
2
+ import { ReactNode } from 'react';
3
+ export interface FairysTaroLoadingProps extends ViewProps {
4
+ /**加载标题*/
5
+ title?: ReactNode;
6
+ /**加载提示*/
7
+ tips?: ReactNode;
8
+ /**是否显示加载动画*/
9
+ loading?: boolean;
10
+ /**是否显示在 Portal 中*/
11
+ isPortal?: boolean;
12
+ }
13
+ export declare const FairysTaroLoadingMain: import("react").ForwardRefExoticComponent<Omit<Omit<FairysTaroLoadingProps, "loading" | "isPortal">, "ref"> & import("react").RefAttributes<ViewProps>>;
14
+ export declare const FairysTaroLoading: import("react").ForwardRefExoticComponent<Omit<FairysTaroLoadingProps, "ref"> & import("react").RefAttributes<ViewProps>>;
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ FairysTaroLoading: ()=>FairysTaroLoading,
37
+ FairysTaroLoadingMain: ()=>FairysTaroLoadingMain
38
+ });
39
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
40
+ const external_clsx_namespaceObject = require("clsx");
41
+ var external_clsx_default = /*#__PURE__*/ __webpack_require__.n(external_clsx_namespaceObject);
42
+ const components_namespaceObject = require("@tarojs/components");
43
+ const external_react_namespaceObject = require("react");
44
+ const index_js_namespaceObject = require("../Portal/index.js");
45
+ const FairysTaroLoadingMain = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)((props, ref)=>{
46
+ const { title = '', tips = "\u8F7D\u5165\u4E2D", className, ...rest } = props;
47
+ const classNames = (0, external_react_namespaceObject.useMemo)(()=>external_clsx_default()('fairys_taro_loading fairystaro__bg-white_xg_90', className), [
48
+ className
49
+ ]);
50
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_namespaceObject.Fragment, {
51
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(components_namespaceObject.View, {
52
+ ...rest,
53
+ ref: ref,
54
+ className: classNames,
55
+ children: [
56
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(components_namespaceObject.View, {
57
+ className: "fairys_taro_loading-main",
58
+ children: [
59
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.View, {
60
+ className: "square"
61
+ }),
62
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.View, {
63
+ className: "square"
64
+ }),
65
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.View, {
66
+ className: "square"
67
+ }),
68
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.View, {
69
+ className: "square"
70
+ })
71
+ ]
72
+ }),
73
+ title ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.View, {
74
+ className: "name",
75
+ children: title
76
+ }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_namespaceObject.Fragment, {}),
77
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(components_namespaceObject.View, {
78
+ className: "tips",
79
+ children: [
80
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.Text, {
81
+ children: tips
82
+ }),
83
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.Text, {
84
+ className: "loading-dots"
85
+ })
86
+ ]
87
+ })
88
+ ]
89
+ })
90
+ });
91
+ });
92
+ const FairysTaroLoading = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)((props, ref)=>{
93
+ const { loading = false, isPortal = true, ...rest } = props;
94
+ return loading ? isPortal ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.FairysTaroPortal, {
95
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FairysTaroLoadingMain, {
96
+ ...rest,
97
+ ref: ref
98
+ })
99
+ }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FairysTaroLoadingMain, {
100
+ ...rest,
101
+ ref: ref
102
+ }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_namespaceObject.Fragment, {});
103
+ });
104
+ exports.FairysTaroLoading = __webpack_exports__.FairysTaroLoading;
105
+ exports.FairysTaroLoadingMain = __webpack_exports__.FairysTaroLoadingMain;
106
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
107
+ "FairysTaroLoading",
108
+ "FairysTaroLoadingMain"
109
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
110
+ Object.defineProperty(exports, '__esModule', {
111
+ value: true
112
+ });
@@ -0,0 +1,10 @@
1
+ import { ViewProps } from '@tarojs/components';
2
+ export interface FairysTaroMainPageProps extends ViewProps {
3
+ }
4
+ export declare const FairysTaroMainPage: (props: FairysTaroMainPageProps) => import("react/jsx-runtime").JSX.Element;
5
+ /**查询*/
6
+ export declare const FairysTaroMainPageSearch: (props: FairysTaroMainPageProps) => import("react/jsx-runtime").JSX.Element;
7
+ /**内容*/
8
+ export declare const FairysTaroMainPageBody: (props: FairysTaroMainPageProps) => import("react/jsx-runtime").JSX.Element;
9
+ /**底部*/
10
+ export declare const FairysTaroMainPageFooter: (props: FairysTaroMainPageProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ FairysTaroMainPageFooter: ()=>FairysTaroMainPageFooter,
37
+ FairysTaroMainPage: ()=>FairysTaroMainPage,
38
+ FairysTaroMainPageSearch: ()=>FairysTaroMainPageSearch,
39
+ FairysTaroMainPageBody: ()=>FairysTaroMainPageBody
40
+ });
41
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
42
+ const components_namespaceObject = require("@tarojs/components");
43
+ const external_clsx_namespaceObject = require("clsx");
44
+ var external_clsx_default = /*#__PURE__*/ __webpack_require__.n(external_clsx_namespaceObject);
45
+ const external_react_namespaceObject = require("react");
46
+ const FairysTaroMainPage = (props)=>{
47
+ const { className: itemClassName, children, ...rest } = props;
48
+ const cls = (0, external_react_namespaceObject.useMemo)(()=>external_clsx_default()('fairys_taro-ui-main-page fairystaro__box-border fairystaro__w-full fairystaro__h-full fairystaro__flex fairystaro__flex-col fairystaro__overflow-auto', itemClassName), [
49
+ itemClassName
50
+ ]);
51
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.View, {
52
+ className: cls,
53
+ ...rest,
54
+ children: children
55
+ });
56
+ };
57
+ const FairysTaroMainPageSearch = (props)=>{
58
+ const { className: itemClassName, children, ...rest } = props;
59
+ const cls = (0, external_react_namespaceObject.useMemo)(()=>external_clsx_default()('fairys_taro-ui-main-page-search fairystaro__box-border fairystaro__w-full', itemClassName), [
60
+ itemClassName
61
+ ]);
62
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.View, {
63
+ className: cls,
64
+ ...rest,
65
+ children: children
66
+ });
67
+ };
68
+ const FairysTaroMainPageBody = (props)=>{
69
+ const { className: itemClassName, children, ...rest } = props;
70
+ const cls = (0, external_react_namespaceObject.useMemo)(()=>external_clsx_default()('fairys_taro-ui-main-page-body fairystaro__box-border fairystaro__w-full fairystaro__flex-1 fairystaro__overflow-auto', itemClassName), [
71
+ itemClassName
72
+ ]);
73
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.View, {
74
+ className: cls,
75
+ ...rest,
76
+ children: children
77
+ });
78
+ };
79
+ const FairysTaroMainPageFooter = (props)=>{
80
+ const { className: itemClassName, children, ...rest } = props;
81
+ const cls = (0, external_react_namespaceObject.useMemo)(()=>external_clsx_default()('fairys_taro-ui-main-page-footer fairystaro__box-border fairystaro__w-full', itemClassName), [
82
+ itemClassName
83
+ ]);
84
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.View, {
85
+ className: cls,
86
+ ...rest,
87
+ children: children
88
+ });
89
+ };
90
+ exports.FairysTaroMainPage = __webpack_exports__.FairysTaroMainPage;
91
+ exports.FairysTaroMainPageBody = __webpack_exports__.FairysTaroMainPageBody;
92
+ exports.FairysTaroMainPageFooter = __webpack_exports__.FairysTaroMainPageFooter;
93
+ exports.FairysTaroMainPageSearch = __webpack_exports__.FairysTaroMainPageSearch;
94
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
95
+ "FairysTaroMainPage",
96
+ "FairysTaroMainPageBody",
97
+ "FairysTaroMainPageFooter",
98
+ "FairysTaroMainPageSearch"
99
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
100
+ Object.defineProperty(exports, '__esModule', {
101
+ value: true
102
+ });
@@ -0,0 +1,48 @@
1
+ import { ViewProps } from '@tarojs/components';
2
+ export interface FairysTaroMessageItemProps extends Omit<ViewProps, 'style'> {
3
+ /**
4
+ * 提示内容
5
+ */
6
+ title?: React.ReactNode;
7
+ /**
8
+ * 提示框类型
9
+ * @default none
10
+ */
11
+ type?: 'none' | 'success' | 'error' | 'warning' | 'info';
12
+ /**
13
+ * 自定义图标
14
+ */
15
+ icon?: React.ReactNode;
16
+ /**消息项是否显示边框*/
17
+ bordered?: boolean;
18
+ /**图标 className*/
19
+ iconClassName?: string;
20
+ /**图标 style*/
21
+ iconStyle?: React.CSSProperties;
22
+ /**标题 className*/
23
+ titleClassName?: string;
24
+ /**标题 style*/
25
+ titleStyle?: React.CSSProperties;
26
+ /**内容 className*/
27
+ bodyClassName?: string;
28
+ /**内容 style*/
29
+ bodyStyle?: React.CSSProperties;
30
+ /**样式*/
31
+ style?: React.CSSProperties;
32
+ /**图标颜色*/
33
+ iconColor?: string;
34
+ /**边框颜色*/
35
+ borderColor?: string;
36
+ /**背景颜色*/
37
+ backgroundColor?: string;
38
+ /**文本颜色*/
39
+ color?: string;
40
+ /**是否显示图标*/
41
+ showIcon?: boolean;
42
+ }
43
+ export declare const FairysTaroMessageItem: (props: FairysTaroMessageItemProps) => import("react/jsx-runtime").JSX.Element;
44
+ export interface FairysTaroMessageProps extends ViewProps {
45
+ }
46
+ export declare const FairysTaroMessage: (props: FairysTaroMessageProps) => import("react/jsx-runtime").JSX.Element;
47
+ /**消息组件(用于全局消息提示)*/
48
+ export declare const FairysTaroPortalMessage: (props: FairysTaroMessageProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ FairysTaroMessage: ()=>FairysTaroMessage,
37
+ FairysTaroMessageItem: ()=>FairysTaroMessageItem,
38
+ FairysTaroPortalMessage: ()=>FairysTaroPortalMessage
39
+ });
40
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
41
+ const external_react_namespaceObject = require("react");
42
+ const components_namespaceObject = require("@tarojs/components");
43
+ const global_data_instance_js_namespaceObject = require("../../context/global.data.instance.js");
44
+ const index_js_namespaceObject = require("../Portal/index.js");
45
+ const external_clsx_namespaceObject = require("clsx");
46
+ var external_clsx_default = /*#__PURE__*/ __webpack_require__.n(external_clsx_namespaceObject);
47
+ const FairysTaroMessageItem = (props)=>{
48
+ const { title, children, type = 'info', className: itemClassName, bordered = true, iconClassName, iconStyle = {}, titleClassName, titleStyle, bodyClassName, bodyStyle, icon, iconColor, borderColor, backgroundColor, style = {}, color, showIcon = true, ...rest } = props;
49
+ const isIcon = !!icon;
50
+ const isIconString = 'string' == typeof icon;
51
+ const className = (0, external_react_namespaceObject.useMemo)(()=>external_clsx_default()('fairys_taro-ui-message-item', `fairys_taro-ui-message-icon-${type}`, 'fairystaro__box-border fairystaro__flex fairystaro__flex-row fairystaro__gap-_zkh1_0_dl_4rem_zhk2_ fairystaro__p-y-_zkh1_0_dl_4rem_zhk2_ fairystaro__p-x-_zkh1_0_dl_4rem_zhk2_ fairystaro__rounded-md fairystaro__text-_zkh1_0_dl_8rem_zhk2_', {
52
+ 'fairystaro__border fairystaro__border-solid': bordered
53
+ }, itemClassName), [
54
+ type,
55
+ itemClassName,
56
+ bordered
57
+ ]);
58
+ const classIconName = (0, external_react_namespaceObject.useMemo)(()=>external_clsx_default()('fairys_taro-ui-message-icon fairystaro__box-border fairystaro__text-_zkh1_0_dl_6rem_zhk2_', iconClassName, {
59
+ 'ant-design--close-circle-outlined': 'error' === type && !isIcon,
60
+ 'ant-design--exclamation-circle-outlined': 'warning' === type && !isIcon,
61
+ 'ant-design--check-circle-outlined': 'success' === type && !isIcon,
62
+ 'ant-design--info-circle-outlined': 'info' === type && !isIcon,
63
+ 'fairystaro__text-color-_zkh1_red_zhk2_': 'error' === type,
64
+ 'fairystaro__text-color-_zkh1_orange_zhk2_': 'warning' === type,
65
+ 'fairystaro__text-color-_zkh1_green_zhk2_': 'success' === type,
66
+ 'fairystaro__text-color-_zkh1_blue_zhk2_': 'info' === type
67
+ }), [
68
+ type,
69
+ iconClassName,
70
+ isIcon
71
+ ]);
72
+ const lastIconClassName = (0, external_react_namespaceObject.useMemo)(()=>external_clsx_default()(classIconName, isIconString ? icon : ''), [
73
+ classIconName,
74
+ isIconString,
75
+ icon
76
+ ]);
77
+ const titleClassNames = (0, external_react_namespaceObject.useMemo)(()=>external_clsx_default()('fairys_taro-ui-message-item-title fairystaro__font-bold fairystaro__text-_zkh1_0_dl_6rem_zhk2_', titleClassName), [
78
+ titleClassName
79
+ ]);
80
+ const _iconStyle = {
81
+ ...iconStyle
82
+ };
83
+ if (iconColor) _iconStyle.color = iconColor;
84
+ const _style = {
85
+ ...style
86
+ };
87
+ if (borderColor) _style.borderColor = borderColor;
88
+ if (backgroundColor) _style.backgroundColor = backgroundColor;
89
+ if (color) _style.color = color;
90
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(components_namespaceObject.View, {
91
+ className: className,
92
+ ...rest,
93
+ style: _style,
94
+ children: [
95
+ showIcon ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(components_namespaceObject.View, {
96
+ className: "fairystaro__flex fairystaro__flex-row fairystaro__justify-center fairystaro__p-t-_zkh1_0_dl_15rem_zhk2_",
97
+ children: [
98
+ isIcon ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_namespaceObject.Fragment, {}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.View, {
99
+ className: classIconName,
100
+ style: _iconStyle
101
+ }),
102
+ isIcon && !isIconString ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.View, {
103
+ className: classIconName,
104
+ style: _iconStyle,
105
+ children: icon
106
+ }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_namespaceObject.Fragment, {}),
107
+ isIcon && isIconString ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.View, {
108
+ className: lastIconClassName,
109
+ style: _iconStyle
110
+ }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_namespaceObject.Fragment, {})
111
+ ]
112
+ }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_namespaceObject.Fragment, {}),
113
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(components_namespaceObject.View, {
114
+ children: [
115
+ title ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.View, {
116
+ className: titleClassNames,
117
+ style: titleStyle,
118
+ children: title
119
+ }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_namespaceObject.Fragment, {}),
120
+ children ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.View, {
121
+ className: external_clsx_default()('fairys_taro-ui-message-item-body fairystaro__text-_zkh1_0_dl_6rem_zhk2_', bodyClassName),
122
+ style: bodyStyle,
123
+ children: children
124
+ }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_namespaceObject.Fragment, {})
125
+ ]
126
+ })
127
+ ]
128
+ });
129
+ };
130
+ const FairysTaroMessage = (props)=>{
131
+ const { className: messageClassName, ...rest } = props;
132
+ const classNames = (0, external_react_namespaceObject.useMemo)(()=>external_clsx_default()('fairys_taro-ui-message fairystaro__box-border fairystaro__p-2 fairystaro__flex fairystaro__flex-col fairystaro__items-center fairystaro__gap-2 fairystaro__max-w-full fairystaro__max-h-full', messageClassName), [
133
+ messageClassName
134
+ ]);
135
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.View, {
136
+ ...rest,
137
+ className: classNames
138
+ });
139
+ };
140
+ const FairysTaroPortalMessage = (props)=>{
141
+ const { className: messageClassName, ...rest } = props;
142
+ const [state] = (0, global_data_instance_js_namespaceObject.useGlobalData)();
143
+ const messageData = state.messageData;
144
+ const classNames = (0, external_react_namespaceObject.useMemo)(()=>external_clsx_default()('fairys_taro-ui-portal-message fairystaro__pointer-events-none fairystaro__position-fixed fairystaro__top-0 fairystaro__right-0 fairystaro__bottom-0 fairystaro__left-0', messageClassName), [
145
+ messageClassName
146
+ ]);
147
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.FairysTaroPortal, {
148
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FairysTaroMessage, {
149
+ ...rest,
150
+ className: classNames,
151
+ children: messageData.map((item)=>{
152
+ const { content, visible, __id, ...rest } = item;
153
+ if (visible) return /*#__PURE__*/ (0, external_react_namespaceObject.createElement)(FairysTaroMessageItem, {
154
+ ...rest,
155
+ key: __id
156
+ }, content);
157
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_namespaceObject.Fragment, {}, `${__id}_hidden`);
158
+ })
159
+ })
160
+ });
161
+ };
162
+ exports.FairysTaroMessage = __webpack_exports__.FairysTaroMessage;
163
+ exports.FairysTaroMessageItem = __webpack_exports__.FairysTaroMessageItem;
164
+ exports.FairysTaroPortalMessage = __webpack_exports__.FairysTaroPortalMessage;
165
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
166
+ "FairysTaroMessage",
167
+ "FairysTaroMessageItem",
168
+ "FairysTaroPortalMessage"
169
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
170
+ Object.defineProperty(exports, '__esModule', {
171
+ value: true
172
+ });
@@ -0,0 +1,8 @@
1
+ export interface FairysTaroPortalProps {
2
+ children: React.ReactNode;
3
+ /**
4
+ * 自定义容器(h5环境)
5
+ */
6
+ domContainer?: HTMLElement;
7
+ }
8
+ export declare const FairysTaroPortal: (props: FairysTaroPortalProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,45 @@
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
+ FairysTaroPortal: ()=>FairysTaroPortal
28
+ });
29
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
30
+ const external_react_dom_namespaceObject = require("react-dom");
31
+ const components_namespaceObject = require("@tarojs/components");
32
+ const FairysTaroPortal = (props)=>{
33
+ const { children, domContainer } = props;
34
+ if ('weapp' === process.env.TARO_ENV) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.RootPortal, {
35
+ children: children
36
+ });
37
+ return /*#__PURE__*/ (0, external_react_dom_namespaceObject.createPortal)(children, domContainer || document.body);
38
+ };
39
+ exports.FairysTaroPortal = __webpack_exports__.FairysTaroPortal;
40
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
41
+ "FairysTaroPortal"
42
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
43
+ Object.defineProperty(exports, '__esModule', {
44
+ value: true
45
+ });
@@ -0,0 +1 @@
1
+ export declare const FairysTaroToast: () => import("react/jsx-runtime").JSX.Element;