@fairys/taro-tools-react 0.0.1

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 (62) hide show
  1. package/README.md +1 -0
  2. package/esm/components/EnterLoading/index.d.ts +14 -0
  3. package/esm/components/EnterLoading/index.js +65 -0
  4. package/esm/components/MainPage/index.d.ts +10 -0
  5. package/esm/components/MainPage/index.js +49 -0
  6. package/esm/components/Mesage/index.d.ts +48 -0
  7. package/esm/components/Mesage/index.js +122 -0
  8. package/esm/components/Portal/index.d.ts +8 -0
  9. package/esm/components/Portal/index.js +11 -0
  10. package/esm/components/Toast/index.d.ts +1 -0
  11. package/esm/components/Toast/index.js +20 -0
  12. package/esm/components/connectToastMessage/index.d.ts +10 -0
  13. package/esm/components/connectToastMessage/index.js +28 -0
  14. package/esm/components/index.d.ts +6 -0
  15. package/esm/components/index.js +6 -0
  16. package/esm/context/global.data.instance.d.ts +5411 -0
  17. package/esm/context/global.data.instance.js +66 -0
  18. package/esm/context/global.setting.data.instance.d.ts +28 -0
  19. package/esm/context/global.setting.data.instance.js +20 -0
  20. package/esm/context/index.d.ts +4 -0
  21. package/esm/context/index.js +4 -0
  22. package/esm/context/page.data.instance.d.ts +71 -0
  23. package/esm/context/page.data.instance.js +139 -0
  24. package/esm/context/page.info.data.instance.d.ts +72 -0
  25. package/esm/context/page.info.data.instance.js +107 -0
  26. package/esm/index.d.ts +3 -0
  27. package/esm/index.js +3 -0
  28. package/esm/styles/index.css +711 -0
  29. package/esm/utils/index.d.ts +4 -0
  30. package/esm/utils/index.js +4 -0
  31. package/esm/utils/navigate.d.ts +109 -0
  32. package/esm/utils/navigate.js +45 -0
  33. package/esm/utils/request.d.ts +112 -0
  34. package/esm/utils/request.js +212 -0
  35. package/esm/utils/useId.d.ts +2 -0
  36. package/esm/utils/useId.js +13 -0
  37. package/esm/utils/valtio/index.d.ts +9 -0
  38. package/esm/utils/valtio/index.js +23 -0
  39. package/esm/utils/valtio/instance.d.ts +15 -0
  40. package/esm/utils/valtio/instance.js +34 -0
  41. package/lib/index.js +78 -0
  42. package/package.json +40 -0
  43. package/src/components/EnterLoading/index.tsx +57 -0
  44. package/src/components/MainPage/index.tsx +72 -0
  45. package/src/components/Mesage/index.tsx +217 -0
  46. package/src/components/Portal/index.tsx +18 -0
  47. package/src/components/Toast/index.tsx +22 -0
  48. package/src/components/connectToastMessage/index.tsx +41 -0
  49. package/src/components/index.ts +6 -0
  50. package/src/context/global.data.instance.ts +106 -0
  51. package/src/context/global.setting.data.instance.ts +36 -0
  52. package/src/context/index.ts +4 -0
  53. package/src/context/page.data.instance.ts +215 -0
  54. package/src/context/page.info.data.instance.ts +182 -0
  55. package/src/index.ts +3 -0
  56. package/src/styles/index.css +515 -0
  57. package/src/utils/index.ts +4 -0
  58. package/src/utils/navigate.ts +159 -0
  59. package/src/utils/request.ts +319 -0
  60. package/src/utils/useId.ts +14 -0
  61. package/src/utils/valtio/index.ts +23 -0
  62. package/src/utils/valtio/instance.ts +59 -0
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # 框架 ui 组件库
@@ -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,65 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import clsx from "clsx";
3
+ import { Text, View } from "@tarojs/components";
4
+ import { Fragment, forwardRef, useMemo } from "react";
5
+ import { FairysTaroPortal } from "../Portal/index.js";
6
+ const FairysTaroLoadingMain = /*#__PURE__*/ forwardRef((props, ref)=>{
7
+ const { title = '', tips = "\u8F7D\u5165\u4E2D", className, ...rest } = props;
8
+ const classNames = useMemo(()=>clsx('fairys_taro_loading fairystaro__bg-white_xg_90', className), [
9
+ className
10
+ ]);
11
+ return /*#__PURE__*/ jsx(Fragment, {
12
+ children: /*#__PURE__*/ jsxs(View, {
13
+ ...rest,
14
+ ref: ref,
15
+ className: classNames,
16
+ children: [
17
+ /*#__PURE__*/ jsxs(View, {
18
+ className: "fairys_taro_loading-main",
19
+ children: [
20
+ /*#__PURE__*/ jsx(View, {
21
+ className: "square"
22
+ }),
23
+ /*#__PURE__*/ jsx(View, {
24
+ className: "square"
25
+ }),
26
+ /*#__PURE__*/ jsx(View, {
27
+ className: "square"
28
+ }),
29
+ /*#__PURE__*/ jsx(View, {
30
+ className: "square"
31
+ })
32
+ ]
33
+ }),
34
+ title ? /*#__PURE__*/ jsx(View, {
35
+ className: "name",
36
+ children: title
37
+ }) : /*#__PURE__*/ jsx(Fragment, {}),
38
+ /*#__PURE__*/ jsxs(View, {
39
+ className: "tips",
40
+ children: [
41
+ /*#__PURE__*/ jsx(Text, {
42
+ children: tips
43
+ }),
44
+ /*#__PURE__*/ jsx(Text, {
45
+ className: "loading-dots"
46
+ })
47
+ ]
48
+ })
49
+ ]
50
+ })
51
+ });
52
+ });
53
+ const FairysTaroLoading = /*#__PURE__*/ forwardRef((props, ref)=>{
54
+ const { loading = false, isPortal = true, ...rest } = props;
55
+ return loading ? isPortal ? /*#__PURE__*/ jsx(FairysTaroPortal, {
56
+ children: /*#__PURE__*/ jsx(FairysTaroLoadingMain, {
57
+ ...rest,
58
+ ref: ref
59
+ })
60
+ }) : /*#__PURE__*/ jsx(FairysTaroLoadingMain, {
61
+ ...rest,
62
+ ref: ref
63
+ }) : /*#__PURE__*/ jsx(Fragment, {});
64
+ });
65
+ export { FairysTaroLoading, FairysTaroLoadingMain };
@@ -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,49 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { View } from "@tarojs/components";
3
+ import clsx from "clsx";
4
+ import { useMemo } from "react";
5
+ const FairysTaroMainPage = (props)=>{
6
+ const { className: itemClassName, children, ...rest } = props;
7
+ const cls = useMemo(()=>clsx('fairys_taro-ui-main-page fairystaro__box-border fairystaro__w-full fairystaro__h-full fairystaro__flex fairystaro__flex-col fairystaro__overflow-auto', itemClassName), [
8
+ itemClassName
9
+ ]);
10
+ return /*#__PURE__*/ jsx(View, {
11
+ className: cls,
12
+ ...rest,
13
+ children: children
14
+ });
15
+ };
16
+ const FairysTaroMainPageSearch = (props)=>{
17
+ const { className: itemClassName, children, ...rest } = props;
18
+ const cls = useMemo(()=>clsx('fairys_taro-ui-main-page-search fairystaro__box-border fairystaro__w-full', itemClassName), [
19
+ itemClassName
20
+ ]);
21
+ return /*#__PURE__*/ jsx(View, {
22
+ className: cls,
23
+ ...rest,
24
+ children: children
25
+ });
26
+ };
27
+ const FairysTaroMainPageBody = (props)=>{
28
+ const { className: itemClassName, children, ...rest } = props;
29
+ const cls = useMemo(()=>clsx('fairys_taro-ui-main-page-body fairystaro__box-border fairystaro__w-full fairystaro__flex-1 fairystaro__overflow-auto', itemClassName), [
30
+ itemClassName
31
+ ]);
32
+ return /*#__PURE__*/ jsx(View, {
33
+ className: cls,
34
+ ...rest,
35
+ children: children
36
+ });
37
+ };
38
+ const FairysTaroMainPageFooter = (props)=>{
39
+ const { className: itemClassName, children, ...rest } = props;
40
+ const cls = useMemo(()=>clsx('fairys_taro-ui-main-page-footer fairystaro__box-border fairystaro__w-full', itemClassName), [
41
+ itemClassName
42
+ ]);
43
+ return /*#__PURE__*/ jsx(View, {
44
+ className: cls,
45
+ ...rest,
46
+ children: children
47
+ });
48
+ };
49
+ export { FairysTaroMainPage, FairysTaroMainPageBody, FairysTaroMainPageFooter, FairysTaroMainPageSearch };
@@ -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,122 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Fragment, createElement, useMemo } from "react";
3
+ import { View } from "@tarojs/components";
4
+ import { useGlobalData } from "../../context/global.data.instance.js";
5
+ import { FairysTaroPortal } from "../Portal/index.js";
6
+ import clsx from "clsx";
7
+ const FairysTaroMessageItem = (props)=>{
8
+ 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;
9
+ const isIcon = !!icon;
10
+ const isIconString = 'string' == typeof icon;
11
+ const className = useMemo(()=>clsx('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_', {
12
+ 'fairystaro__border fairystaro__border-solid': bordered
13
+ }, itemClassName), [
14
+ type,
15
+ itemClassName,
16
+ bordered
17
+ ]);
18
+ const classIconName = useMemo(()=>clsx('fairys_taro-ui-message-icon fairystaro__box-border ', iconClassName, {
19
+ 'ant-design--close-circle-outlined': 'error' === type && !isIcon,
20
+ 'ant-design--exclamation-circle-outlined': 'warning' === type && !isIcon,
21
+ 'ant-design--check-circle-outlined': 'success' === type && !isIcon,
22
+ 'ant-design--info-circle-outlined': 'info' === type && !isIcon,
23
+ 'fairystaro__text-color-_zkh1_red_zhk2_': 'error' === type,
24
+ 'fairystaro__text-color-_zkh1_orange_zhk2_': 'warning' === type,
25
+ 'fairystaro__text-color-_zkh1_green_zhk2_': 'success' === type,
26
+ 'fairystaro__text-color-_zkh1_blue_zhk2_': 'info' === type
27
+ }), [
28
+ type,
29
+ iconClassName,
30
+ isIcon
31
+ ]);
32
+ const lastIconClassName = useMemo(()=>clsx(classIconName, isIconString ? icon : ''), [
33
+ classIconName,
34
+ isIconString,
35
+ icon
36
+ ]);
37
+ const titleClassNames = useMemo(()=>clsx('fairys_taro-ui-message-item-title fairystaro__font-bold', titleClassName), [
38
+ titleClassName
39
+ ]);
40
+ const _iconStyle = {
41
+ ...iconStyle
42
+ };
43
+ if (iconColor) _iconStyle.color = iconColor;
44
+ const _style = {
45
+ ...style
46
+ };
47
+ if (borderColor) _style.borderColor = borderColor;
48
+ if (backgroundColor) _style.backgroundColor = backgroundColor;
49
+ if (color) _style.color = color;
50
+ return /*#__PURE__*/ jsxs(View, {
51
+ className: className,
52
+ ...rest,
53
+ style: _style,
54
+ children: [
55
+ showIcon ? /*#__PURE__*/ jsxs(View, {
56
+ className: "fairystaro__flex fairystaro__flex-row fairystaro__justify-center fairystaro__p-t-_zkh1_0_dl_15rem_zhk2_",
57
+ children: [
58
+ isIcon ? /*#__PURE__*/ jsx(Fragment, {}) : /*#__PURE__*/ jsx(View, {
59
+ className: classIconName,
60
+ style: _iconStyle
61
+ }),
62
+ isIcon && !isIconString ? /*#__PURE__*/ jsx(View, {
63
+ className: classIconName,
64
+ style: _iconStyle,
65
+ children: icon
66
+ }) : /*#__PURE__*/ jsx(Fragment, {}),
67
+ isIcon && isIconString ? /*#__PURE__*/ jsx(View, {
68
+ className: lastIconClassName,
69
+ style: _iconStyle
70
+ }) : /*#__PURE__*/ jsx(Fragment, {})
71
+ ]
72
+ }) : /*#__PURE__*/ jsx(Fragment, {}),
73
+ /*#__PURE__*/ jsxs(View, {
74
+ children: [
75
+ title ? /*#__PURE__*/ jsx(View, {
76
+ className: titleClassNames,
77
+ style: titleStyle,
78
+ children: title
79
+ }) : /*#__PURE__*/ jsx(Fragment, {}),
80
+ children ? /*#__PURE__*/ jsx(View, {
81
+ className: clsx('fairys_taro-ui-message-item-body', bodyClassName),
82
+ style: bodyStyle,
83
+ children: children
84
+ }) : /*#__PURE__*/ jsx(Fragment, {})
85
+ ]
86
+ })
87
+ ]
88
+ });
89
+ };
90
+ const FairysTaroMessage = (props)=>{
91
+ const { className: messageClassName, ...rest } = props;
92
+ const classNames = useMemo(()=>clsx('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), [
93
+ messageClassName
94
+ ]);
95
+ return /*#__PURE__*/ jsx(View, {
96
+ ...rest,
97
+ className: classNames
98
+ });
99
+ };
100
+ const FairysTaroPortalMessage = (props)=>{
101
+ const { className: messageClassName, ...rest } = props;
102
+ const [state] = useGlobalData();
103
+ const messageData = state.messageData;
104
+ const classNames = useMemo(()=>clsx('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), [
105
+ messageClassName
106
+ ]);
107
+ return /*#__PURE__*/ jsx(FairysTaroPortal, {
108
+ children: /*#__PURE__*/ jsx(FairysTaroMessage, {
109
+ ...rest,
110
+ className: classNames,
111
+ children: messageData.map((item)=>{
112
+ const { content, visible, __id, ...rest } = item;
113
+ if (visible) return /*#__PURE__*/ createElement(FairysTaroMessageItem, {
114
+ ...rest,
115
+ key: __id
116
+ }, content);
117
+ return /*#__PURE__*/ jsx(Fragment, {}, `${__id}_hidden`);
118
+ })
119
+ })
120
+ });
121
+ };
122
+ export { FairysTaroMessage, FairysTaroMessageItem, FairysTaroPortalMessage };
@@ -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,11 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { createPortal } from "react-dom";
3
+ import { RootPortal } from "@tarojs/components";
4
+ const FairysTaroPortal = (props)=>{
5
+ const { children, domContainer } = props;
6
+ if ('weapp' === process.env.TARO_ENV) return /*#__PURE__*/ jsx(RootPortal, {
7
+ children: children
8
+ });
9
+ return /*#__PURE__*/ createPortal(children, domContainer || document.body);
10
+ };
11
+ export { FairysTaroPortal };
@@ -0,0 +1 @@
1
+ export declare const FairysTaroToast: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,20 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Toast } from "@nutui/nutui-react-taro";
3
+ import { FairysTaroPortal } from "../Portal/index.js";
4
+ import { useGlobalData } from "../../context/global.data.instance.js";
5
+ const FairysTaroToast = ()=>{
6
+ const [state, proxyInstance] = useGlobalData();
7
+ const toastConfig = state.toastData;
8
+ return /*#__PURE__*/ jsx(FairysTaroPortal, {
9
+ children: /*#__PURE__*/ jsx(Toast, {
10
+ type: "text",
11
+ ...toastConfig,
12
+ visible: toastConfig?.visible || false,
13
+ onClose: ()=>{
14
+ toastConfig?.onClose?.();
15
+ proxyInstance.hideToast();
16
+ }
17
+ })
18
+ });
19
+ };
20
+ export { FairysTaroToast };
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ export interface ConnectToastMessageOptions {
3
+ /**
4
+ * 是否是根页面,
5
+ * 在 h5 中,只有入口文件才需要展示 message 组件 和 toast 组件
6
+ * 在微信中,所有页面都需要展示 message 组件 和 toast 组件, 入口文件不展示
7
+ */
8
+ isRoot?: boolean;
9
+ }
10
+ export declare const connectToastMessage: (Component: React.FC, options?: ConnectToastMessageOptions) => (props: any) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,28 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { FairysTaroPortalMessage } from "../Mesage/index.js";
3
+ import { FairysTaroToast } from "../Toast/index.js";
4
+ import { Fragment } from "react";
5
+ const connectToastMessage = (Component, options = {})=>{
6
+ const { isRoot = false } = options;
7
+ return (props)=>{
8
+ if ('weapp' === process.env.TARO_ENV) return /*#__PURE__*/ jsxs(Fragment, {
9
+ children: [
10
+ /*#__PURE__*/ jsx(Component, {
11
+ ...props
12
+ }),
13
+ isRoot ? /*#__PURE__*/ jsx(Fragment, {}) : /*#__PURE__*/ jsx(FairysTaroToast, {}),
14
+ isRoot ? /*#__PURE__*/ jsx(Fragment, {}) : /*#__PURE__*/ jsx(FairysTaroPortalMessage, {})
15
+ ]
16
+ });
17
+ return /*#__PURE__*/ jsxs(Fragment, {
18
+ children: [
19
+ /*#__PURE__*/ jsx(Component, {
20
+ ...props
21
+ }),
22
+ isRoot ? /*#__PURE__*/ jsx(FairysTaroToast, {}) : /*#__PURE__*/ jsx(Fragment, {}),
23
+ isRoot ? /*#__PURE__*/ jsx(FairysTaroPortalMessage, {}) : /*#__PURE__*/ jsx(Fragment, {})
24
+ ]
25
+ });
26
+ };
27
+ };
28
+ export { connectToastMessage };
@@ -0,0 +1,6 @@
1
+ export * from './EnterLoading';
2
+ export * from './Portal';
3
+ export * from './Mesage';
4
+ export * from './Toast';
5
+ export * from './connectToastMessage';
6
+ export * from './MainPage';
@@ -0,0 +1,6 @@
1
+ export * from "./EnterLoading/index.js";
2
+ export * from "./Portal/index.js";
3
+ export * from "./Mesage/index.js";
4
+ export * from "./Toast/index.js";
5
+ export * from "./connectToastMessage/index.js";
6
+ export * from "./MainPage/index.js";