@fairys/taro-tools-react 1.0.33 → 1.0.34

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 (34) hide show
  1. package/esm/components/custom-tab-bar/index.css +39 -0
  2. package/esm/components/custom-tab-bar/index.d.ts +57 -0
  3. package/esm/components/custom-tab-bar/index.js +114 -0
  4. package/esm/components/index.d.ts +1 -0
  5. package/esm/components/index.js +1 -0
  6. package/esm/context/global.data.instance.d.ts +27 -0
  7. package/esm/context/global.data.instance.js +40 -0
  8. package/esm/context/global.message.data.instance.d.ts +0 -7
  9. package/esm/context/global.message.data.instance.js +0 -25
  10. package/esm/context/index.d.ts +1 -0
  11. package/esm/context/index.js +1 -0
  12. package/esm/styles/index.css +18 -0
  13. package/esm/utils/request.js +3 -2
  14. package/lib/components/custom-tab-bar/index.css +39 -0
  15. package/lib/components/custom-tab-bar/index.d.ts +57 -0
  16. package/lib/components/custom-tab-bar/index.js +165 -0
  17. package/lib/components/index.d.ts +1 -0
  18. package/lib/components/index.js +9 -0
  19. package/lib/context/global.data.instance.d.ts +27 -0
  20. package/lib/context/global.data.instance.js +91 -0
  21. package/lib/context/global.message.data.instance.d.ts +0 -7
  22. package/lib/context/global.message.data.instance.js +0 -36
  23. package/lib/context/index.d.ts +1 -0
  24. package/lib/context/index.js +9 -0
  25. package/lib/styles/index.css +18 -0
  26. package/lib/utils/request.js +3 -2
  27. package/package.json +1 -1
  28. package/src/components/custom-tab-bar/index.css +38 -0
  29. package/src/components/custom-tab-bar/index.tsx +169 -0
  30. package/src/components/index.ts +1 -0
  31. package/src/context/global.data.instance.ts +69 -0
  32. package/src/context/global.message.data.instance.ts +0 -37
  33. package/src/context/index.ts +1 -0
  34. package/src/utils/request.ts +3 -2
@@ -0,0 +1,39 @@
1
+ .fairys_taro_custom_tab_bar {
2
+ height: 60px;
3
+ padding-bottom: env(safe-area-inset-bottom);
4
+ background: #fff;
5
+ display: flex;
6
+ position: fixed;
7
+ bottom: 0;
8
+ left: 0;
9
+ right: 0;
10
+ }
11
+
12
+ .fairys_taro_custom_tab_bar-border {
13
+ background-color: #00000054;
14
+ width: 100%;
15
+ height: 1px;
16
+ position: absolute;
17
+ top: 0;
18
+ left: 0;
19
+ transform: scaleY(.5);
20
+ }
21
+
22
+ .fairys_taro_custom_tab_bar_item {
23
+ text-align: center;
24
+ flex-direction: column;
25
+ flex: 1;
26
+ justify-content: center;
27
+ align-items: center;
28
+ display: flex;
29
+ }
30
+
31
+ .fairys_taro_custom_tab_bar_item cover-image {
32
+ width: 54px;
33
+ height: 54px;
34
+ }
35
+
36
+ .fairys_taro_custom_tab_bar_item cover-view {
37
+ font-size: 14px;
38
+ }
39
+
@@ -0,0 +1,57 @@
1
+ /**自定义底部导航栏状态管理*/
2
+ export declare const fairysTaroCustomTabBarState: {
3
+ /**当前选中的项*/
4
+ selected: string;
5
+ items: FairysTaroCustomTabBarItemItem[];
6
+ isUpdatedItems: boolean;
7
+ /**未选中颜色*/
8
+ color: string;
9
+ /**选中颜色*/
10
+ selectedColor: string;
11
+ /**切换标签*/
12
+ onSwitchTab: (url: string) => void;
13
+ /**更新自定义底部导航栏项*/
14
+ onUpdatedItems: (items: FairysTaroCustomTabBarItemItem[]) => void;
15
+ /**设置自定义底部导航栏渲染*/
16
+ onSetTabBarRender: (_tabBarRender: React.ReactNode) => void;
17
+ };
18
+ export interface FairysTaroCustomTabBarItemItem {
19
+ /**自定义底部导航栏项文本*/
20
+ text: string;
21
+ /**自定义底部导航栏项 URL*/
22
+ url: string;
23
+ /**自定义底部导航栏项图标*/
24
+ icon?: string;
25
+ /**自定义底部导航栏项样式*/
26
+ style?: React.CSSProperties;
27
+ /**自定义底部导航栏项类名*/
28
+ className?: string;
29
+ /**自定义底部导航栏项选中图标*/
30
+ selectedIcon?: string;
31
+ /**自定义底部导航栏项选中图标样式*/
32
+ selectedIconStyle?: React.CSSProperties;
33
+ /**自定义底部导航栏项图标样式*/
34
+ iconStyle?: React.CSSProperties;
35
+ /**自定义底部导航栏项选中图标类名*/
36
+ selectedIconClassName?: string;
37
+ /**自定义底部导航栏项选中文本样式*/
38
+ selectedTextStyle?: React.CSSProperties;
39
+ /**自定义底部导航栏项文本样式*/
40
+ textStyle?: React.CSSProperties;
41
+ /**自定义底部导航栏项选中文本类名*/
42
+ selectedTextClassName?: string;
43
+ }
44
+ export interface FairysTaroCustomTabBarProps {
45
+ }
46
+ export interface FairysTaroCustomTabBarItemProps {
47
+ /**自定义底部导航栏项*/
48
+ item: FairysTaroCustomTabBarItemItem;
49
+ }
50
+ export declare const FairysTaroCustomTabBar: import("react").MemoExoticComponent<() => import("react/jsx-runtime").JSX.Element>;
51
+ /**
52
+ * 页面高度问题
53
+ */
54
+ export declare const useFairysTaroCustomTabBarPageStyle: () => {
55
+ height: number;
56
+ overflowY: string;
57
+ };
@@ -0,0 +1,114 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { proxy, ref, useSnapshot } from "valtio";
3
+ import { CoverImage, CoverView } from "@tarojs/components";
4
+ import taro from "@tarojs/taro";
5
+ import { Fragment, memo, useMemo } from "react";
6
+ import clsx from "clsx";
7
+ let fairysTaroCustomTabBarRender;
8
+ const fairysTaroCustomTabBarState = proxy({
9
+ selected: '',
10
+ items: ref([]),
11
+ isUpdatedItems: false,
12
+ color: 'rgb(156 163 175)',
13
+ selectedColor: '#000',
14
+ onSwitchTab: (url)=>{
15
+ fairysTaroCustomTabBarState.selected = url;
16
+ taro.switchTab({
17
+ url
18
+ });
19
+ },
20
+ onUpdatedItems: (items)=>{
21
+ fairysTaroCustomTabBarState.items = ref(items);
22
+ fairysTaroCustomTabBarState.isUpdatedItems = true;
23
+ },
24
+ onSetTabBarRender: (_tabBarRender)=>{
25
+ fairysTaroCustomTabBarRender = _tabBarRender;
26
+ fairysTaroCustomTabBarState.isUpdatedItems = false;
27
+ }
28
+ });
29
+ const FairysTaroCustomTabBarItemBase = (props)=>{
30
+ const { item } = props;
31
+ const { selected, color, selectedColor } = useSnapshot(fairysTaroCustomTabBarState);
32
+ const isSelected = selected === item.url;
33
+ const className = useMemo(()=>clsx('fairys_taro_custom_tab_bar_item', item.className), [
34
+ item.className
35
+ ]);
36
+ const imgClassName = useMemo(()=>clsx('fairys_taro_custom_tab_bar_item_img', item.selectedIconClassName, {
37
+ fairys_taro_custom_tab_bar_item_img_selected: isSelected
38
+ }), [
39
+ item.selectedIconClassName,
40
+ isSelected
41
+ ]);
42
+ const imgStyle = useMemo(()=>({
43
+ opacity: isSelected ? 1 : 0.6
44
+ }), [
45
+ isSelected
46
+ ]);
47
+ const textClassName = useMemo(()=>clsx('fairys_taro_custom_tab_bar_item_text', item.selectedTextClassName, {
48
+ fairys_taro_custom_tab_bar_item_text_selected: isSelected
49
+ }), [
50
+ item.selectedTextClassName,
51
+ isSelected
52
+ ]);
53
+ const textStyle = useMemo(()=>({
54
+ color: isSelected ? selectedColor : color
55
+ }), [
56
+ isSelected,
57
+ color,
58
+ selectedColor
59
+ ]);
60
+ return /*#__PURE__*/ jsxs(CoverView, {
61
+ onClick: ()=>fairysTaroCustomTabBarState.onSwitchTab(item.url),
62
+ style: item.style,
63
+ className: className,
64
+ children: [
65
+ item.icon ? /*#__PURE__*/ jsx(CoverImage, {
66
+ src: isSelected ? item.selectedIcon || item.icon : item.icon,
67
+ className: imgClassName,
68
+ style: {
69
+ ...imgStyle,
70
+ ...(isSelected ? item.selectedIconStyle : item.iconStyle) || {}
71
+ }
72
+ }) : /*#__PURE__*/ jsx(Fragment, {}),
73
+ /*#__PURE__*/ jsx(CoverView, {
74
+ className: textClassName,
75
+ style: {
76
+ ...(isSelected ? item.selectedTextStyle : item.textStyle) || {},
77
+ ...textStyle
78
+ },
79
+ children: item.text
80
+ })
81
+ ]
82
+ }, item.url);
83
+ };
84
+ const FairysTaroCustomTabBarBase = ()=>{
85
+ const { items } = useSnapshot(fairysTaroCustomTabBarState);
86
+ const _itemsRender = useMemo(()=>{
87
+ if (false === fairysTaroCustomTabBarState.isUpdatedItems && fairysTaroCustomTabBarRender) return fairysTaroCustomTabBarRender;
88
+ const render = items.map((item)=>/*#__PURE__*/ jsx(FairysTaroCustomTabBarItemBase, {
89
+ item: item
90
+ }, item.url));
91
+ fairysTaroCustomTabBarState.onSetTabBarRender(render);
92
+ return render;
93
+ }, [
94
+ items
95
+ ]);
96
+ return /*#__PURE__*/ jsxs(CoverView, {
97
+ className: "fairys_taro_custom_tab_bar",
98
+ children: [
99
+ /*#__PURE__*/ jsx(CoverView, {
100
+ className: "fairys_taro_custom_tab_bar-border"
101
+ }),
102
+ _itemsRender
103
+ ]
104
+ });
105
+ };
106
+ const FairysTaroCustomTabBar = /*#__PURE__*/ memo(()=>useMemo(()=>/*#__PURE__*/ jsx(FairysTaroCustomTabBarBase, {}), []));
107
+ const useFairysTaroCustomTabBarPageStyle = ()=>useMemo(()=>{
108
+ const height = taro.getSystemInfoSync().windowHeight;
109
+ return {
110
+ height: height - 60,
111
+ overflowY: 'auto'
112
+ };
113
+ }, []);
114
+ export { FairysTaroCustomTabBar, fairysTaroCustomTabBarState, useFairysTaroCustomTabBarPageStyle };
@@ -4,3 +4,4 @@ export * from './Mesage';
4
4
  export * from './Toast';
5
5
  export * from './connectToastMessage';
6
6
  export * from './MainPage';
7
+ export * from './custom-tab-bar';
@@ -4,3 +4,4 @@ export * from "./Mesage/index.js";
4
4
  export * from "./Toast/index.js";
5
5
  export * from "./connectToastMessage/index.js";
6
6
  export * from "./MainPage/index.js";
7
+ export * from "./custom-tab-bar/index.js";
@@ -0,0 +1,27 @@
1
+ import { ProxyInstanceObjectBase } from '../utils/valtio/instance';
2
+ export interface GlobalDataInstanceState {
3
+ /**数据默认值不使用*/
4
+ __defaultValue?: string;
5
+ }
6
+ /**
7
+ * 全局数据实例
8
+ */
9
+ export declare class GlobalDataInstance extends ProxyInstanceObjectBase<GlobalDataInstanceState> {
10
+ store: GlobalDataInstanceState;
11
+ /**
12
+ * 跳转登录页面前执行
13
+ */
14
+ onBeforetToLoginPage?: () => boolean | void;
15
+ /**跳转 redirect 路由*/
16
+ toRedirect: () => void;
17
+ /**跳转登录页面*/
18
+ toLoginPage: () => void;
19
+ }
20
+ /**
21
+ * 全局数据实例
22
+ */
23
+ export declare const globalDataInstance: GlobalDataInstance;
24
+ /**
25
+ * 全局数据状态管理
26
+ */
27
+ export declare const useGlobalData: () => [GlobalDataInstanceState, GlobalDataInstance, string | undefined];
@@ -0,0 +1,40 @@
1
+ import { proxy, useSnapshot } from "valtio";
2
+ import utils_navigate from "../utils/navigate.js";
3
+ import { ProxyInstanceObjectBase } from "../utils/valtio/instance.js";
4
+ import { globalSettingDataInstance } from "./global.setting.data.instance.js";
5
+ import taro from "@tarojs/taro";
6
+ import { authDataInstance } from "./auth.data.instance.js";
7
+ class GlobalDataInstance extends ProxyInstanceObjectBase {
8
+ store = proxy({});
9
+ onBeforetToLoginPage;
10
+ toRedirect = ()=>{
11
+ const currentPath = taro.getCurrentInstance().router?.params?.redirect || '';
12
+ if (currentPath) utils_navigate.navigateTo({
13
+ url: currentPath
14
+ });
15
+ };
16
+ toLoginPage = ()=>{
17
+ authDataInstance.clear();
18
+ if (this.onBeforetToLoginPage) {
19
+ const f = this.onBeforetToLoginPage();
20
+ if (false === f) return;
21
+ }
22
+ const loginPageRoute = globalSettingDataInstance.store.loginPageRoute || '';
23
+ const isLoginPage = utils_navigate.isCurrentPage(loginPageRoute || '');
24
+ const _loginPageRoute = `${loginPageRoute || ''}`.replace(/^\//, '');
25
+ if (isLoginPage) return;
26
+ taro.navigateTo({
27
+ url: `/${_loginPageRoute}`
28
+ });
29
+ };
30
+ }
31
+ const globalDataInstance = new GlobalDataInstance();
32
+ const useGlobalData = ()=>{
33
+ const store = useSnapshot(globalDataInstance.store);
34
+ return [
35
+ store,
36
+ globalDataInstance,
37
+ store.__defaultValue
38
+ ];
39
+ };
40
+ export { GlobalDataInstance, globalDataInstance, useGlobalData };
@@ -40,13 +40,6 @@ export declare class GlobalMessageDataInstance extends ProxyInstanceObjectBase<G
40
40
  showToast: (config?: Partial<ToastDataType>) => void;
41
41
  /**隐藏Toast */
42
42
  hideToast: () => void;
43
- /**
44
- * 跳转登录页面前执行
45
- */
46
- onBeforetToLoginPage?: () => boolean | void;
47
- toRedirect: () => void;
48
- /**跳转登录页面*/
49
- toLoginPage: () => void;
50
43
  }
51
44
  /**
52
45
  * 全局消息数据实例
@@ -1,10 +1,6 @@
1
1
  import { proxy, ref, useSnapshot } from "valtio";
2
- import utils_navigate from "../utils/navigate.js";
3
2
  import { createUseId } from "../utils/useId.js";
4
3
  import { ProxyInstanceObjectBase } from "../utils/valtio/instance.js";
5
- import { globalSettingDataInstance } from "./global.setting.data.instance.js";
6
- import taro from "@tarojs/taro";
7
- import { authDataInstance } from "./auth.data.instance.js";
8
4
  class GlobalMessageDataInstance extends ProxyInstanceObjectBase {
9
5
  store = proxy({
10
6
  messageData: ref([]),
@@ -47,27 +43,6 @@ class GlobalMessageDataInstance extends ProxyInstanceObjectBase {
47
43
  visible: false
48
44
  });
49
45
  };
50
- onBeforetToLoginPage;
51
- toRedirect = ()=>{
52
- const currentPath = taro.getCurrentInstance().router?.params?.redirect || '';
53
- if (currentPath) utils_navigate.navigateTo({
54
- url: currentPath
55
- });
56
- };
57
- toLoginPage = ()=>{
58
- authDataInstance.clear();
59
- if (this.onBeforetToLoginPage) {
60
- const f = this.onBeforetToLoginPage();
61
- if (false === f) return;
62
- }
63
- const loginPageRoute = globalSettingDataInstance.store.loginPageRoute || '';
64
- const isLoginPage = utils_navigate.isCurrentPage(loginPageRoute || '');
65
- const _loginPageRoute = `${loginPageRoute || ''}`.replace(/^\//, '');
66
- if (isLoginPage) return;
67
- taro.navigateTo({
68
- url: `/${_loginPageRoute}`
69
- });
70
- };
71
46
  }
72
47
  const globalMessageDataInstance = new GlobalMessageDataInstance();
73
48
  const useGlobalMessageData = ()=>{
@@ -3,3 +3,4 @@ export * from './page.data.instance';
3
3
  export * from './page.info.data.instance';
4
4
  export * from './auth.data.instance';
5
5
  export * from './global.setting.data.instance';
6
+ export * from './global.data.instance';
@@ -3,3 +3,4 @@ export * from "./page.data.instance.js";
3
3
  export * from "./page.info.data.instance.js";
4
4
  export * from "./auth.data.instance.js";
5
5
  export * from "./global.setting.data.instance.js";
6
+ export * from "./global.data.instance.js";
@@ -181,6 +181,11 @@
181
181
  font-size: 12.8px;
182
182
  }
183
183
 
184
+ .fairystaro__text-black {
185
+ --un-text-opacity: 1;
186
+ color: rgb(0 0 0 / var(--un-text-opacity));
187
+ }
188
+
184
189
  .fairystaro__text-color-_zkh1_blue_zhk2_ {
185
190
  color: #00f;
186
191
  }
@@ -197,10 +202,23 @@
197
202
  color: red;
198
203
  }
199
204
 
205
+ .fairystaro__text-gray-400 {
206
+ --un-text-opacity: 1;
207
+ color: rgb(156 163 175 / var(--un-text-opacity));
208
+ }
209
+
200
210
  .fairystaro__font-bold {
201
211
  font-weight: 700;
202
212
  }
203
213
 
214
+ .fairystaro__opacity-100 {
215
+ opacity: 1;
216
+ }
217
+
218
+ .fairystaro__opacity-60 {
219
+ opacity: .6;
220
+ }
221
+
204
222
  @keyframes fairys_taro_loading_transform {
205
223
  0% {
206
224
  --fairys-enter-loading-transform-color: #00a98e;
@@ -1,6 +1,7 @@
1
1
  import taro from "@tarojs/taro";
2
2
  import { globalSettingDataInstance } from "../context/global.setting.data.instance.js";
3
3
  import { globalMessageDataInstance } from "../context/global.message.data.instance.js";
4
+ import { globalDataInstance } from "../context/global.data.instance.js";
4
5
  const codeMessage = {
5
6
  400: "\u53D1\u51FA\u7684\u8BF7\u6C42\u9519\u8BEF",
6
7
  401: "\u7528\u6237\u6CA1\u6709\u6743\u9650",
@@ -22,7 +23,7 @@ const requestResponseHandle = (result, options)=>{
22
23
  const code = result?.data?.code;
23
24
  if (401 === statusCode || 401 === code || code === globalSettingDataInstance.store.tokenExpiredCode) {
24
25
  msg = "\u8BF7\u91CD\u65B0\u767B\u5F55";
25
- globalMessageDataInstance.toLoginPage();
26
+ globalDataInstance.toLoginPage();
26
27
  } else msg = [
27
28
  globalSettingDataInstance.store.requestSuccessCode,
28
29
  requestSuccessCode,
@@ -134,7 +135,7 @@ class RequestInstance {
134
135
  options?.fail?.({
135
136
  errMsg: "\u672A\u767B\u5F55"
136
137
  });
137
- globalMessageDataInstance.toLoginPage();
138
+ globalDataInstance.toLoginPage();
138
139
  return;
139
140
  }
140
141
  return {
@@ -0,0 +1,39 @@
1
+ .fairys_taro_custom_tab_bar {
2
+ height: 60px;
3
+ padding-bottom: env(safe-area-inset-bottom);
4
+ background: #fff;
5
+ display: flex;
6
+ position: fixed;
7
+ bottom: 0;
8
+ left: 0;
9
+ right: 0;
10
+ }
11
+
12
+ .fairys_taro_custom_tab_bar-border {
13
+ background-color: #00000054;
14
+ width: 100%;
15
+ height: 1px;
16
+ position: absolute;
17
+ top: 0;
18
+ left: 0;
19
+ transform: scaleY(.5);
20
+ }
21
+
22
+ .fairys_taro_custom_tab_bar_item {
23
+ text-align: center;
24
+ flex-direction: column;
25
+ flex: 1;
26
+ justify-content: center;
27
+ align-items: center;
28
+ display: flex;
29
+ }
30
+
31
+ .fairys_taro_custom_tab_bar_item cover-image {
32
+ width: 54px;
33
+ height: 54px;
34
+ }
35
+
36
+ .fairys_taro_custom_tab_bar_item cover-view {
37
+ font-size: 14px;
38
+ }
39
+
@@ -0,0 +1,57 @@
1
+ /**自定义底部导航栏状态管理*/
2
+ export declare const fairysTaroCustomTabBarState: {
3
+ /**当前选中的项*/
4
+ selected: string;
5
+ items: FairysTaroCustomTabBarItemItem[];
6
+ isUpdatedItems: boolean;
7
+ /**未选中颜色*/
8
+ color: string;
9
+ /**选中颜色*/
10
+ selectedColor: string;
11
+ /**切换标签*/
12
+ onSwitchTab: (url: string) => void;
13
+ /**更新自定义底部导航栏项*/
14
+ onUpdatedItems: (items: FairysTaroCustomTabBarItemItem[]) => void;
15
+ /**设置自定义底部导航栏渲染*/
16
+ onSetTabBarRender: (_tabBarRender: React.ReactNode) => void;
17
+ };
18
+ export interface FairysTaroCustomTabBarItemItem {
19
+ /**自定义底部导航栏项文本*/
20
+ text: string;
21
+ /**自定义底部导航栏项 URL*/
22
+ url: string;
23
+ /**自定义底部导航栏项图标*/
24
+ icon?: string;
25
+ /**自定义底部导航栏项样式*/
26
+ style?: React.CSSProperties;
27
+ /**自定义底部导航栏项类名*/
28
+ className?: string;
29
+ /**自定义底部导航栏项选中图标*/
30
+ selectedIcon?: string;
31
+ /**自定义底部导航栏项选中图标样式*/
32
+ selectedIconStyle?: React.CSSProperties;
33
+ /**自定义底部导航栏项图标样式*/
34
+ iconStyle?: React.CSSProperties;
35
+ /**自定义底部导航栏项选中图标类名*/
36
+ selectedIconClassName?: string;
37
+ /**自定义底部导航栏项选中文本样式*/
38
+ selectedTextStyle?: React.CSSProperties;
39
+ /**自定义底部导航栏项文本样式*/
40
+ textStyle?: React.CSSProperties;
41
+ /**自定义底部导航栏项选中文本类名*/
42
+ selectedTextClassName?: string;
43
+ }
44
+ export interface FairysTaroCustomTabBarProps {
45
+ }
46
+ export interface FairysTaroCustomTabBarItemProps {
47
+ /**自定义底部导航栏项*/
48
+ item: FairysTaroCustomTabBarItemItem;
49
+ }
50
+ export declare const FairysTaroCustomTabBar: import("react").MemoExoticComponent<() => import("react/jsx-runtime").JSX.Element>;
51
+ /**
52
+ * 页面高度问题
53
+ */
54
+ export declare const useFairysTaroCustomTabBarPageStyle: () => {
55
+ height: number;
56
+ overflowY: string;
57
+ };
@@ -0,0 +1,165 @@
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
+ fairysTaroCustomTabBarState: ()=>fairysTaroCustomTabBarState,
37
+ useFairysTaroCustomTabBarPageStyle: ()=>useFairysTaroCustomTabBarPageStyle,
38
+ FairysTaroCustomTabBar: ()=>FairysTaroCustomTabBar
39
+ });
40
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
41
+ const external_valtio_namespaceObject = require("valtio");
42
+ const components_namespaceObject = require("@tarojs/components");
43
+ const taro_namespaceObject = require("@tarojs/taro");
44
+ var taro_default = /*#__PURE__*/ __webpack_require__.n(taro_namespaceObject);
45
+ const external_react_namespaceObject = require("react");
46
+ const external_clsx_namespaceObject = require("clsx");
47
+ var external_clsx_default = /*#__PURE__*/ __webpack_require__.n(external_clsx_namespaceObject);
48
+ let fairysTaroCustomTabBarRender;
49
+ const fairysTaroCustomTabBarState = (0, external_valtio_namespaceObject.proxy)({
50
+ selected: '',
51
+ items: (0, external_valtio_namespaceObject.ref)([]),
52
+ isUpdatedItems: false,
53
+ color: 'rgb(156 163 175)',
54
+ selectedColor: '#000',
55
+ onSwitchTab: (url)=>{
56
+ fairysTaroCustomTabBarState.selected = url;
57
+ taro_default().switchTab({
58
+ url
59
+ });
60
+ },
61
+ onUpdatedItems: (items)=>{
62
+ fairysTaroCustomTabBarState.items = (0, external_valtio_namespaceObject.ref)(items);
63
+ fairysTaroCustomTabBarState.isUpdatedItems = true;
64
+ },
65
+ onSetTabBarRender: (_tabBarRender)=>{
66
+ fairysTaroCustomTabBarRender = _tabBarRender;
67
+ fairysTaroCustomTabBarState.isUpdatedItems = false;
68
+ }
69
+ });
70
+ const FairysTaroCustomTabBarItemBase = (props)=>{
71
+ const { item } = props;
72
+ const { selected, color, selectedColor } = (0, external_valtio_namespaceObject.useSnapshot)(fairysTaroCustomTabBarState);
73
+ const isSelected = selected === item.url;
74
+ const className = (0, external_react_namespaceObject.useMemo)(()=>external_clsx_default()('fairys_taro_custom_tab_bar_item', item.className), [
75
+ item.className
76
+ ]);
77
+ const imgClassName = (0, external_react_namespaceObject.useMemo)(()=>external_clsx_default()('fairys_taro_custom_tab_bar_item_img', item.selectedIconClassName, {
78
+ fairys_taro_custom_tab_bar_item_img_selected: isSelected
79
+ }), [
80
+ item.selectedIconClassName,
81
+ isSelected
82
+ ]);
83
+ const imgStyle = (0, external_react_namespaceObject.useMemo)(()=>({
84
+ opacity: isSelected ? 1 : 0.6
85
+ }), [
86
+ isSelected
87
+ ]);
88
+ const textClassName = (0, external_react_namespaceObject.useMemo)(()=>external_clsx_default()('fairys_taro_custom_tab_bar_item_text', item.selectedTextClassName, {
89
+ fairys_taro_custom_tab_bar_item_text_selected: isSelected
90
+ }), [
91
+ item.selectedTextClassName,
92
+ isSelected
93
+ ]);
94
+ const textStyle = (0, external_react_namespaceObject.useMemo)(()=>({
95
+ color: isSelected ? selectedColor : color
96
+ }), [
97
+ isSelected,
98
+ color,
99
+ selectedColor
100
+ ]);
101
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(components_namespaceObject.CoverView, {
102
+ onClick: ()=>fairysTaroCustomTabBarState.onSwitchTab(item.url),
103
+ style: item.style,
104
+ className: className,
105
+ children: [
106
+ item.icon ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.CoverImage, {
107
+ src: isSelected ? item.selectedIcon || item.icon : item.icon,
108
+ className: imgClassName,
109
+ style: {
110
+ ...imgStyle,
111
+ ...(isSelected ? item.selectedIconStyle : item.iconStyle) || {}
112
+ }
113
+ }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_namespaceObject.Fragment, {}),
114
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.CoverView, {
115
+ className: textClassName,
116
+ style: {
117
+ ...(isSelected ? item.selectedTextStyle : item.textStyle) || {},
118
+ ...textStyle
119
+ },
120
+ children: item.text
121
+ })
122
+ ]
123
+ }, item.url);
124
+ };
125
+ const FairysTaroCustomTabBarBase = ()=>{
126
+ const { items } = (0, external_valtio_namespaceObject.useSnapshot)(fairysTaroCustomTabBarState);
127
+ const _itemsRender = (0, external_react_namespaceObject.useMemo)(()=>{
128
+ if (false === fairysTaroCustomTabBarState.isUpdatedItems && fairysTaroCustomTabBarRender) return fairysTaroCustomTabBarRender;
129
+ const render = items.map((item)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FairysTaroCustomTabBarItemBase, {
130
+ item: item
131
+ }, item.url));
132
+ fairysTaroCustomTabBarState.onSetTabBarRender(render);
133
+ return render;
134
+ }, [
135
+ items
136
+ ]);
137
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(components_namespaceObject.CoverView, {
138
+ className: "fairys_taro_custom_tab_bar",
139
+ children: [
140
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.CoverView, {
141
+ className: "fairys_taro_custom_tab_bar-border"
142
+ }),
143
+ _itemsRender
144
+ ]
145
+ });
146
+ };
147
+ const FairysTaroCustomTabBar = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(()=>(0, external_react_namespaceObject.useMemo)(()=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FairysTaroCustomTabBarBase, {}), []));
148
+ const useFairysTaroCustomTabBarPageStyle = ()=>(0, external_react_namespaceObject.useMemo)(()=>{
149
+ const height = taro_default().getSystemInfoSync().windowHeight;
150
+ return {
151
+ height: height - 60,
152
+ overflowY: 'auto'
153
+ };
154
+ }, []);
155
+ exports.FairysTaroCustomTabBar = __webpack_exports__.FairysTaroCustomTabBar;
156
+ exports.fairysTaroCustomTabBarState = __webpack_exports__.fairysTaroCustomTabBarState;
157
+ exports.useFairysTaroCustomTabBarPageStyle = __webpack_exports__.useFairysTaroCustomTabBarPageStyle;
158
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
159
+ "FairysTaroCustomTabBar",
160
+ "fairysTaroCustomTabBarState",
161
+ "useFairysTaroCustomTabBarPageStyle"
162
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
163
+ Object.defineProperty(exports, '__esModule', {
164
+ value: true
165
+ });