@tarojs/components 3.5.0-beta.0 → 3.5.0-beta.3
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.
- package/dist/cjs/taro-rich-text-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-swiper-core_2.cjs.entry.js +8 -3
- package/dist/cjs/taro-tabbar.cjs.entry.js +1 -1
- package/dist/cjs/taro-video-control_3.cjs.entry.js +19 -13
- package/dist/collection/components/rich-text/rich-text.js +1 -1
- package/dist/collection/components/swiper/swiper.js +8 -3
- package/dist/collection/components/tabbar/tabbar.js +1 -1
- package/dist/collection/components/video/style/index.css +0 -1
- package/dist/collection/components/video/utils.js +6 -7
- package/dist/collection/components/video/video-control.js +3 -3
- package/dist/collection/components/video/video.js +10 -3
- package/dist/esm/taro-rich-text-core.entry.js +1 -1
- package/dist/esm/taro-swiper-core_2.entry.js +8 -3
- package/dist/esm/taro-tabbar.entry.js +1 -1
- package/dist/esm/taro-video-control_3.entry.js +19 -13
- package/dist/esm-es5/taro-swiper-core_2.entry.js +1 -1
- package/dist/esm-es5/taro-tabbar.entry.js +1 -1
- package/dist/esm-es5/taro-video-control_3.entry.js +2 -2
- package/dist/taro-components/{p-64f6f87c.system.entry.js → p-12615394.system.entry.js} +2 -2
- package/dist/taro-components/p-1b11a8d4.system.entry.js +1 -0
- package/dist/taro-components/p-1d5fa0f3.entry.js +1 -0
- package/dist/taro-components/{p-bb3d337d.entry.js → p-9eb01395.entry.js} +2 -2
- package/dist/taro-components/p-a2fd3c03.system.js +1 -1
- package/dist/taro-components/{p-49df1b65.system.entry.js → p-c59f3780.system.entry.js} +1 -1
- package/dist/taro-components/{p-7419e765.entry.js → p-f980e090.entry.js} +1 -1
- package/dist/taro-components/taro-components.esm.js +1 -1
- package/dist/types/components/video/utils.d.ts +1 -3
- package/dist/types/components/video/video-control.d.ts +1 -1
- package/dist-h5/react/utils/reactify-wc.js +5 -2
- package/package.json +7 -3
- package/types/Ad.d.ts +6 -6
- package/types/Button.d.ts +12 -12
- package/types/Camera.d.ts +10 -10
- package/types/Canvas.d.ts +1 -1
- package/types/Checkbox.d.ts +4 -4
- package/types/CheckboxGroup.d.ts +3 -3
- package/types/Form.d.ts +2 -2
- package/types/Input.d.ts +19 -19
- package/types/LivePlayer.d.ts +8 -8
- package/types/Map.d.ts +28 -28
- package/types/MovableArea.d.ts +1 -1
- package/types/MovableView.d.ts +18 -18
- package/types/OpenData.d.ts +6 -6
- package/types/PageContainer.d.ts +14 -14
- package/types/Radio.d.ts +5 -5
- package/types/RadioGroup.d.ts +2 -2
- package/types/RichText.d.ts +6 -1
- package/types/ScrollView.d.ts +3 -3
- package/types/Swiper.d.ts +5 -5
- package/types/Switch.d.ts +2 -2
- package/types/Textarea.d.ts +21 -21
- package/types/Video.d.ts +13 -13
- package/types/WebView.d.ts +5 -5
- package/dist/taro-components/p-97af3986.system.entry.js +0 -1
- package/dist/taro-components/p-fc28dbdd.entry.js +0 -1
package/types/Textarea.d.ts
CHANGED
|
@@ -3,35 +3,35 @@ import { StandardProps, CommonEventFunction, FormItemProps } from './common'
|
|
|
3
3
|
|
|
4
4
|
interface TextareaProps extends StandardProps, FormItemProps {
|
|
5
5
|
/** 输入框的内容
|
|
6
|
-
* @supported weapp, h5, rn
|
|
6
|
+
* @supported weapp, h5, rn, tt
|
|
7
7
|
*/
|
|
8
8
|
value?: string
|
|
9
9
|
|
|
10
10
|
/** 输入框为空时占位符
|
|
11
|
-
* @supported weapp, h5, rn
|
|
11
|
+
* @supported weapp, h5, rn, tt
|
|
12
12
|
*/
|
|
13
13
|
placeholder?: string
|
|
14
14
|
|
|
15
15
|
/** 指定 placeholder 的样式
|
|
16
|
-
* @supported weapp
|
|
16
|
+
* @supported weapp, tt
|
|
17
17
|
*/
|
|
18
18
|
placeholderStyle?: string
|
|
19
19
|
|
|
20
20
|
/** 指定 placeholder 的样式类
|
|
21
21
|
* @default "textarea-placeholder"
|
|
22
|
-
* @supported weapp
|
|
22
|
+
* @supported weapp, tt
|
|
23
23
|
*/
|
|
24
24
|
placeholderClass?: string
|
|
25
25
|
|
|
26
26
|
/** 是否禁用
|
|
27
27
|
* @default false
|
|
28
|
-
* @supported weapp, h5, rn
|
|
28
|
+
* @supported weapp, h5, rn, tt
|
|
29
29
|
*/
|
|
30
30
|
disabled?: boolean
|
|
31
31
|
|
|
32
32
|
/** 最大输入长度,设置为 -1 的时候不限制最大长度
|
|
33
33
|
* @default 140
|
|
34
|
-
* @supported weapp, h5, rn
|
|
34
|
+
* @supported weapp, h5, rn, tt
|
|
35
35
|
*/
|
|
36
36
|
maxlength?: number
|
|
37
37
|
|
|
@@ -43,13 +43,13 @@ interface TextareaProps extends StandardProps, FormItemProps {
|
|
|
43
43
|
|
|
44
44
|
/** 获取焦点
|
|
45
45
|
* @default false
|
|
46
|
-
* @supported weapp, rn
|
|
46
|
+
* @supported weapp, rn, tt
|
|
47
47
|
*/
|
|
48
48
|
focus?: boolean
|
|
49
49
|
|
|
50
50
|
/** 是否自动增高,设置 autoHeight 时,style.height不生效
|
|
51
51
|
* @default false
|
|
52
|
-
* @supported weapp, rn
|
|
52
|
+
* @supported weapp, rn, tt
|
|
53
53
|
*/
|
|
54
54
|
autoHeight?: boolean
|
|
55
55
|
|
|
@@ -61,76 +61,76 @@ interface TextareaProps extends StandardProps, FormItemProps {
|
|
|
61
61
|
|
|
62
62
|
/** 指定光标与键盘的距离,单位 px 。取 Textarea 距离底部的距离和 cursorSpacing 指定的距离的最小值作为光标与键盘的距离
|
|
63
63
|
* @default 0
|
|
64
|
-
* @supported weapp
|
|
64
|
+
* @supported weapp, tt
|
|
65
65
|
*/
|
|
66
66
|
cursorSpacing?: number
|
|
67
67
|
|
|
68
68
|
/** 指定 focus 时的光标位置
|
|
69
69
|
* @default -1
|
|
70
|
-
* @supported weapp
|
|
70
|
+
* @supported weapp, tt
|
|
71
71
|
*/
|
|
72
72
|
cursor?: number
|
|
73
73
|
|
|
74
74
|
/** 是否显示键盘上方带有”完成“按钮那一栏
|
|
75
75
|
* @default true
|
|
76
|
-
* @supported weapp
|
|
76
|
+
* @supported weapp, tt
|
|
77
77
|
*/
|
|
78
78
|
showConfirmBar?: boolean
|
|
79
79
|
|
|
80
80
|
/** 光标起始位置,自动聚集时有效,需与 selectionEnd 搭配使用
|
|
81
81
|
* @default -1
|
|
82
|
-
* @supported weapp, rn
|
|
82
|
+
* @supported weapp, rn, tt
|
|
83
83
|
*/
|
|
84
84
|
selectionStart?: number
|
|
85
85
|
|
|
86
86
|
/** 光标结束位置,自动聚集时有效,需与 selectionStart 搭配使用
|
|
87
87
|
* @default -1
|
|
88
|
-
* @supported weapp, rn
|
|
88
|
+
* @supported weapp, rn, tt
|
|
89
89
|
*/
|
|
90
90
|
selectionEnd?: number
|
|
91
91
|
|
|
92
92
|
/** 键盘弹起时,是否自动上推页面
|
|
93
93
|
* @default true
|
|
94
|
-
* @supported weapp
|
|
94
|
+
* @supported weapp, tt
|
|
95
95
|
*/
|
|
96
96
|
adjustPosition?: boolean
|
|
97
97
|
|
|
98
98
|
/** focus 时,点击页面的时候不收起键盘
|
|
99
99
|
* @default false
|
|
100
|
-
* @supported weapp
|
|
100
|
+
* @supported weapp, tt
|
|
101
101
|
*/
|
|
102
102
|
holdKeyboard?: boolean
|
|
103
103
|
|
|
104
104
|
/** 是否去掉 iOS 下的默认内边距
|
|
105
105
|
* @default false
|
|
106
|
-
* @supported weapp
|
|
106
|
+
* @supported weapp, tt
|
|
107
107
|
*/
|
|
108
108
|
disableDefaultPadding?: boolean
|
|
109
109
|
|
|
110
110
|
/** 输入框聚焦时触发
|
|
111
|
-
* @supported weapp, h5, rn
|
|
111
|
+
* @supported weapp, h5, rn, tt
|
|
112
112
|
*/
|
|
113
113
|
onFocus?: CommonEventFunction<TextareaProps.onFocusEventDetail>
|
|
114
114
|
|
|
115
115
|
/** 输入框失去焦点时触发
|
|
116
|
-
* @supported weapp, h5, rn
|
|
116
|
+
* @supported weapp, h5, rn, tt
|
|
117
117
|
*/
|
|
118
118
|
onBlur?: CommonEventFunction<TextareaProps.onBlurEventDetail>
|
|
119
119
|
|
|
120
120
|
/** 输入框行数变化时调用,event.detail = {height: 0, heightRpx: 0, lineCount: 0}
|
|
121
|
-
* @supported weapp, rn
|
|
121
|
+
* @supported weapp, rn, tt
|
|
122
122
|
*/
|
|
123
123
|
onLineChange?: CommonEventFunction<TextareaProps.onLineChangeEventDetail>
|
|
124
124
|
|
|
125
125
|
/** 当键盘输入时,触发 input 事件,event.detail = {value, cursor, keyCode}
|
|
126
126
|
*
|
|
127
127
|
* **onInput 处理函数的返回值并不会反映到 textarea 上**
|
|
128
|
-
* @supported weapp, h5, rn
|
|
128
|
+
* @supported weapp, h5, rn, tt
|
|
129
129
|
*/
|
|
130
130
|
onInput?: CommonEventFunction<TextareaProps.onInputEventDetail>
|
|
131
131
|
|
|
132
132
|
/** 点击完成时, 触发 confirm 事件,event.detail = {value: value}
|
|
133
|
-
* @supported weapp, rn
|
|
133
|
+
* @supported weapp, rn, tt
|
|
134
134
|
*/
|
|
135
135
|
onConfirm?: CommonEventFunction<TextareaProps.onConfirmEventDetail>
|
|
136
136
|
|
package/types/Video.d.ts
CHANGED
|
@@ -76,21 +76,21 @@ interface VideoProps extends StandardProps {
|
|
|
76
76
|
|
|
77
77
|
/** 若不设置,宽度大于240时才会显示
|
|
78
78
|
* @default true
|
|
79
|
-
* @supported weapp, swan
|
|
79
|
+
* @supported weapp, swan, tt
|
|
80
80
|
* @h5 待定
|
|
81
81
|
*/
|
|
82
82
|
showProgress?: boolean
|
|
83
83
|
|
|
84
84
|
/** 是否显示全屏按钮
|
|
85
85
|
* @default true
|
|
86
|
-
* @supported weapp, swan, alipay
|
|
86
|
+
* @supported weapp, swan, alipay, tt
|
|
87
87
|
* @h5 待定
|
|
88
88
|
*/
|
|
89
89
|
showFullscreenBtn?: boolean
|
|
90
90
|
|
|
91
91
|
/** 是否显示视频底部控制栏的播放按钮
|
|
92
92
|
* @default true
|
|
93
|
-
* @supported weapp, swan, alipay
|
|
93
|
+
* @supported weapp, swan, alipay, tt
|
|
94
94
|
* @h5 待定
|
|
95
95
|
*/
|
|
96
96
|
showPlayBtn?: boolean
|
|
@@ -104,14 +104,14 @@ interface VideoProps extends StandardProps {
|
|
|
104
104
|
|
|
105
105
|
/** 是否开启控制进度的手势
|
|
106
106
|
* @default true
|
|
107
|
-
* @supported weapp, swan, alipay
|
|
107
|
+
* @supported weapp, swan, alipay, tt
|
|
108
108
|
* @h5 待定
|
|
109
109
|
*/
|
|
110
110
|
enableProgressGesture?: boolean
|
|
111
111
|
|
|
112
112
|
/** 当视频大小与 video 容器大小不一致时,视频的表现形式
|
|
113
113
|
* @default "contain"
|
|
114
|
-
* @supported weapp, swan, alipay
|
|
114
|
+
* @supported weapp, swan, alipay, tt
|
|
115
115
|
* @h5 待定
|
|
116
116
|
*/
|
|
117
117
|
objectFit?: keyof VideoProps.ObjectFit
|
|
@@ -123,7 +123,7 @@ interface VideoProps extends StandardProps {
|
|
|
123
123
|
|
|
124
124
|
/** 是否显示静音按钮
|
|
125
125
|
* @default false
|
|
126
|
-
* @supported weapp
|
|
126
|
+
* @supported weapp, tt
|
|
127
127
|
* @h5 待定
|
|
128
128
|
*/
|
|
129
129
|
showMuteBtn?: boolean
|
|
@@ -139,14 +139,14 @@ interface VideoProps extends StandardProps {
|
|
|
139
139
|
* - `center`: 视频中间
|
|
140
140
|
*
|
|
141
141
|
* @default 'bottom'
|
|
142
|
-
* @supported weapp
|
|
142
|
+
* @supported weapp, tt
|
|
143
143
|
* @h5 待定
|
|
144
144
|
*/
|
|
145
145
|
playBtnPosition?: keyof VideoProps.PlayBtnPosition
|
|
146
146
|
|
|
147
147
|
/** 是否开启播放手势,即双击切换播放/暂停
|
|
148
148
|
* @default false
|
|
149
|
-
* @supported weapp
|
|
149
|
+
* @supported weapp, tt
|
|
150
150
|
* @h5 待定
|
|
151
151
|
*/
|
|
152
152
|
enablePlayGesture?: boolean
|
|
@@ -167,14 +167,14 @@ interface VideoProps extends StandardProps {
|
|
|
167
167
|
|
|
168
168
|
/** 在非全屏模式下,是否开启亮度与音量调节手势(同 `page-gesture`)
|
|
169
169
|
* @default false
|
|
170
|
-
* @supported weapp, swan
|
|
170
|
+
* @supported weapp, swan, tt
|
|
171
171
|
* @h5 待定
|
|
172
172
|
*/
|
|
173
173
|
vslideGesture?: boolean
|
|
174
174
|
|
|
175
175
|
/** 在全屏模式下,是否开启亮度与音量调节手势
|
|
176
176
|
* @default true
|
|
177
|
-
* @supported weapp
|
|
177
|
+
* @supported weapp, tt
|
|
178
178
|
* @h5 待定
|
|
179
179
|
*/
|
|
180
180
|
vslideGestureInFullscreen?: boolean
|
|
@@ -249,7 +249,7 @@ interface VideoProps extends StandardProps {
|
|
|
249
249
|
/** 当视频进入和退出全屏时触发
|
|
250
250
|
*
|
|
251
251
|
* event.detail = {fullScreen, direction},direction取为 vertical 或 horizontal
|
|
252
|
-
* @supported weapp, swan, alipay, rn
|
|
252
|
+
* @supported weapp, swan, alipay, rn, tt
|
|
253
253
|
* @h5 待定
|
|
254
254
|
*/
|
|
255
255
|
onFullscreenChange?: CommonEventFunction<VideoProps.onFullscreenChangeEventDetail>
|
|
@@ -257,7 +257,7 @@ interface VideoProps extends StandardProps {
|
|
|
257
257
|
/** 当视频进入和退出全屏时触发
|
|
258
258
|
*
|
|
259
259
|
* event.detail = {fullScreen, direction},direction 取为 vertical 或 horizontal
|
|
260
|
-
* @supported weapp, swan
|
|
260
|
+
* @supported weapp, swan, tt
|
|
261
261
|
* @h5 待定
|
|
262
262
|
*/
|
|
263
263
|
onWaiting?: CommonEventFunction<VideoProps.onWaitingEventDetail>
|
|
@@ -273,7 +273,7 @@ interface VideoProps extends StandardProps {
|
|
|
273
273
|
onProgress?: CommonEventFunction<VideoProps.onProgressEventDetail>
|
|
274
274
|
|
|
275
275
|
/** 视频元数据加载完成时触发。event.detail = {width, height, duration}
|
|
276
|
-
* @supported weapp, rn
|
|
276
|
+
* @supported weapp, rn, tt
|
|
277
277
|
*/
|
|
278
278
|
onLoadedMetaData?: CommonEventFunction
|
|
279
279
|
|
package/types/WebView.d.ts
CHANGED
|
@@ -3,22 +3,22 @@ import { StandardProps, CommonEventFunction } from './common'
|
|
|
3
3
|
|
|
4
4
|
interface WebViewProps extends StandardProps {
|
|
5
5
|
/** webview 指向网页的链接。可打开关联的公众号的文章,其它网页需登录小程序管理后台配置业务域名。
|
|
6
|
-
* @supported weapp, h5
|
|
6
|
+
* @supported weapp, h5, rn, tt
|
|
7
7
|
*/
|
|
8
8
|
src: string
|
|
9
9
|
|
|
10
10
|
/** 网页向小程序 postMessage 时,会在特定时机(小程序后退、组件销毁、分享)触发并收到消息。e.detail = { data }
|
|
11
|
-
* @supported weapp
|
|
11
|
+
* @supported weapp, tt
|
|
12
12
|
*/
|
|
13
13
|
onMessage?: CommonEventFunction<WebViewProps.onMessageEventDetail>
|
|
14
14
|
|
|
15
15
|
/** 网页加载成功时候触发此事件。e.detail = { src }
|
|
16
|
-
* @supported weapp, h5
|
|
16
|
+
* @supported weapp, h5, rn, tt
|
|
17
17
|
*/
|
|
18
18
|
onLoad?: CommonEventFunction<WebViewProps.onLoadEventDetail>
|
|
19
19
|
|
|
20
20
|
/** 网页加载失败的时候触发此事件。e.detail = { src }
|
|
21
|
-
* @supported weapp, h5
|
|
21
|
+
* @supported weapp, h5, rn, tt
|
|
22
22
|
*/
|
|
23
23
|
onError?: CommonEventFunction<WebViewProps.onErrorEventDetail>
|
|
24
24
|
}
|
|
@@ -40,7 +40,7 @@ declare namespace WebViewProps {
|
|
|
40
40
|
|
|
41
41
|
/** web-view 组件是一个可以用来承载网页的容器,会自动铺满整个小程序页面。个人类型与海外类型的小程序暂不支持使用。
|
|
42
42
|
* @classification open
|
|
43
|
-
* @supported weapp, h5, rn
|
|
43
|
+
* @supported weapp, h5, rn, tt
|
|
44
44
|
* @example_react
|
|
45
45
|
* ```tsx
|
|
46
46
|
* class App extends Component {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var __spreadArray=this&&this.__spreadArray||function(e,t){for(var r=0,a=t.length,o=e.length;r<a;r++,o++)e[o]=t[r];return e};System.register(["./p-44996bd6.system.js","@tarojs/taro","./p-5f4d0d5b.system.js"],(function(e){"use strict";var t,r,a,o,n,i,s;return{setters:[function(e){t=e.h;r=e.r;a=e.c;o=e.H;n=e.g},function(e){i=e.default},function(e){s=e.c}],execute:function(){var l=function(e){var t=e||"";var r;var a={path:null,query:null,fragment:null};r=t.indexOf("#");if(r>-1){a.fragment=t.substring(r+1);t=t.substring(0,r)}r=t.indexOf("?");if(r>-1){a.query=t.substring(r+1);t=t.substring(0,r)}a.path=t;return a};function d(e){return e.charAt(0)==="/"}function b(e,t){for(var r=t,a=r+1,o=e.length;a<o;r+=1,a+=1){e[r]=e[a]}e.pop()}function h(e,t){if(t===undefined)t="";var r=e&&e.split("/")||[];var a=t&&t.split("/")||[];var o=e&&d(e);var n=t&&d(t);var i=o||n;if(e&&d(e)){a=r}else if(r.length){a.pop();a=a.concat(r)}if(!a.length)return"/";var s;if(a.length){var l=a[a.length-1];s=l==="."||l===".."||l===""}else{s=false}var h=0;for(var f=a.length;f>=0;f--){var c=a[f];if(c==="."){b(a,f)}else if(c===".."){b(a,f);h++}else if(h){b(a,f);h--}}if(!i)for(;h--;h)a.unshift("..");if(i&&a[0]!==""&&(!a[0]||!d(a[0])))a.unshift("");var u=a.join("/");if(s&&u.substr(-1)!=="/")u+="/";return u}var f=function(e){var r=e.index,a=e.isSelected,o=a===void 0?false:a,n=e.textColor,i=e.iconPath,l=e.badgeText,d=e.showRedDot,b=d===void 0?false:d,h=e.text,f=e.onSelect;var c=s("weui-tabbar__item",{"weui-bar__item_on":o});var u={position:"absolute",top:"-2px",right:"-13px"};var v={position:"absolute",top:"0",right:"-6px"};function g(){f(r)}return t("a",{key:r,href:"javascript:;",class:c,onClick:g},t("span",{style:{display:"inline-block",position:"relative"}},t("img",{src:i,alt:"",class:"weui-tabbar__icon"}),!!l&&t("span",{class:"weui-badge taro-tabbar-badge",style:u},l),b&&t("span",{class:"weui-badge weui-badge_dot",style:v})),t("p",{class:"weui-tabbar__label",style:{color:n}},h))};var c="html,body{height:100%}#app{height:100%}.taro-tabbar__border-white::before{border-top-color:#fff !important}.taro-tabbar__container{display:-ms-flexbox;display:flex;overflow:hidden;-ms-flex-direction:column;flex-direction:column;height:100%}.taro-tabbar__panel{overflow:auto;position:relative;-ms-flex:1;flex:1;-webkit-overflow-scrolling:auto}.taro-tabbar__tabbar{position:relative;width:100%;height:50px;-webkit-transition:bottom 0.2s, top 0.2s;transition:bottom 0.2s, top 0.2s}.taro-tabbar__tabbar-top{top:0}.taro-tabbar__tabbar-bottom{bottom:0;margin-bottom:constant(safe-area-inset-bottom);margin-bottom:env(safe-area-inset-bottom)}.taro-tabbar__tabbar-hide{display:none}.taro-tabbar__tabbar-slideout{top:-52px;-ms-flex:0 0;flex:0 0}.taro-tabbar__panel+.taro-tabbar__tabbar-slideout{top:auto;bottom:-52px}";var u=function(e){if(e===void 0){e=""}return e[0]==="/"?e:"/"+e};var v=function(e,t){if(e===void 0){e=""}if(t===void 0){t=""}return new RegExp("^"+t+"(\\/|\\?|#|$)","i").test(e)};var g=function(e,t){if(e===void 0){e=""}if(t===void 0){t=""}return v(e,t)?e.substr(t.length):e};var _=function(e,t){if(e===void 0){e=""}if(t===void 0){t=""}return e.includes(t)?e.substring(0,e.length-t.length):e};var p=0;var m=1;var T=2;var B="taro-tabbar__tabbar";var H="taro-tabbar__tabbar-hide";var x="taro-tabbar__tabbar-slideout";var w=e("taro_tabbar",function(){function e(e){var t=this;r(this,e);this.onLongPress=a(this,"longpress",7);this.homePage="";this.customRoutes=[];this.tabbarPos="bottom";this.selectedIndex=-1;this.status=p;this.getOriginUrl=function(e){var r=t.customRoutes.filter((function(t){var r=t[1];var a=l(r).path;var o=l(e).path;return a===o}));return _(r.length?r[0][0]:e,".html")};this.getSelectedIndex=function(e){var r=-1;t.list.forEach((function(t,a){var o=t.pagePath;var n=l(e).path;var i=l(o).path;if(n===i){r=a}}));return r};this.switchTab=function(e){t.selectedIndex=e;i.switchTab({url:t.list[e].pagePath})};this.switchTabHandler=function(e){var r=e.url,a=e.successHandler,o=e.errorHandler;var n=t.getOriginUrl(t.getCurrentUrl()||t.homePage);var i=h(r,n);var s=t.getSelectedIndex(i);if(s>-1){t.switchTab(s);a({errMsg:"switchTab:ok"})}else{o({errMsg:'switchTab:fail page "'+i+'" is not found'})}};this.routerChangeHandler=function(e){var r;var a=(r=e===null||e===void 0?void 0:e.toLocation)===null||r===void 0?void 0:r.path;var o;if(typeof a==="string"){var n=t.conf.basename||"/";o=g(u(a||t.homePage),n)}else{o=t.getCurrentUrl()}t.selectedIndex=t.getSelectedIndex(t.getOriginUrl(o))};this.setTabBarBadgeHandler=function(e){var r=e.index,a=e.text,o=e.successHandler,n=e.errorHandler;var i=__spreadArray([],t.list);if(r in i){i[r].showRedDot=false;i[r].badgeText=a;o({errMsg:"setTabBarBadge:ok"})}else{n({errMsg:"setTabBarBadge:fail tabbar item not found"})}t.list=i};this.removeTabBarBadgeHandler=function(e){var r=e.index,a=e.successHandler,o=e.errorHandler;var n=__spreadArray([],t.list);if(r in n){n[r].badgeText=null;n[r].badgeText=null;a({errMsg:"removeTabBarBadge:ok"})}else{o({errMsg:"removeTabBarBadge:fail tabbar item not found"})}t.list=n};this.showTabBarRedDotHandler=function(e){var r=e.index,a=e.successHandler,o=e.errorHandler;var n=__spreadArray([],t.list);if(r in n){n[r].badgeText=null;n[r].showRedDot=true;a({errMsg:"showTabBarRedDot:ok"})}else{o({errMsg:"showTabBarRedDot:fail tabbar item not found"})}t.list=n};this.hideTabBarRedDotHandler=function(e){var r=e.index,a=e.successHandler,o=e.errorHandler;var n=__spreadArray([],t.list);if(r in n){n[r].showRedDot=false;a({errMsg:"hideTabBarRedDot:ok"})}else{o({errMsg:"hideTabBarRedDot:fail tabbar item not found"})}t.list=n};this.showTabBarHandler=function(e){var r=e.successHandler;t.status=p;r({errMsg:"showTabBar:ok"})};this.hideTabBarHandler=function(e){var r=e.animation,a=e.successHandler;t.status=r?T:m;a({errMsg:"hideTabBar:ok"})};this.setTabBarStyleHandler=function(e){var r=e.color,a=e.selectedColor,o=e.backgroundColor,n=e.borderStyle,i=e.successHandler;if(o)t.backgroundColor=o;if(n)t.borderStyle=n;if(r)t.color=r;if(a)t.selectedColor=a;i({errMsg:"setTabBarStyle:ok"})};this.setTabBarItemHandler=function(e){var r=e.index,a=e.iconPath,o=e.selectedIconPath,n=e.text,i=e.successHandler,s=e.errorHandler;var l=__spreadArray([],t.list);if(r in l){if(a)l[r].iconPath=a;if(o)l[r].selectedIconPath=o;if(n)l[r].text=n;i({errMsg:"setTabBarItem:ok"})}else{s({errMsg:"setTabBarItem:fail tabbar item not found"})}t.list=l};var o=this.conf.list;var n=this.conf.customRoutes;if(Object.prototype.toString.call(o)!=="[object Array]"||o.length<2||o.length>5){throw new Error("tabBar 配置错误")}this.homePage=u(this.conf.homePage);var s=function(e){var t;var r=n[e];e=u(e);if(typeof r==="string"){d.customRoutes.push([e,u(r)])}else if((r===null||r===void 0?void 0:r.length)>0){(t=d.customRoutes).push.apply(t,r.map((function(t){return[e,u(t)]})))}};var d=this;for(var b in n){s(b)}o.forEach((function(e){if(e.pagePath.indexOf("/")!==0){e.pagePath="/"+e.pagePath}}));this.list=o;this.borderStyle=this.conf.borderStyle;this.backgroundColor=this.conf.backgroundColor;this.color=this.conf.color;this.selectedColor=this.conf.selectedColor}e.prototype.getCurrentUrl=function(){var e=this.conf.mode;var t=this.conf.basename||"/";var r;if(e==="hash"){var a=window.location.href;var o=a.indexOf("#");r=o===-1?"":a.substring(o+1)}else{r=location.pathname}var n=u(g(r,t));return decodeURI(n==="/"?this.homePage:n)};e.prototype.bindEvent=function(){i.eventCenter.on("__taroRouterChange",this.routerChangeHandler);i.eventCenter.on("__taroSwitchTab",this.switchTabHandler);i.eventCenter.on("__taroSetTabBarBadge",this.setTabBarBadgeHandler);i.eventCenter.on("__taroRemoveTabBarBadge",this.removeTabBarBadgeHandler);i.eventCenter.on("__taroShowTabBarRedDotHandler",this.showTabBarRedDotHandler);i.eventCenter.on("__taroHideTabBarRedDotHandler",this.hideTabBarRedDotHandler);i.eventCenter.on("__taroShowTabBar",this.showTabBarHandler);i.eventCenter.on("__taroHideTabBar",this.hideTabBarHandler);i.eventCenter.on("__taroSetTabBarStyle",this.setTabBarStyleHandler);i.eventCenter.on("__taroSetTabBarItem",this.setTabBarItemHandler)};e.prototype.removeEvent=function(){i.eventCenter.off("__taroRouterChange",this.routerChangeHandler);i.eventCenter.off("__taroSwitchTab",this.switchTabHandler);i.eventCenter.off("__taroSetTabBarBadge",this.setTabBarBadgeHandler);i.eventCenter.off("__taroRemoveTabBarBadge",this.removeTabBarBadgeHandler);i.eventCenter.off("__taroShowTabBarRedDotHandler",this.showTabBarRedDotHandler);i.eventCenter.off("__taroHideTabBarRedDotHandler",this.hideTabBarRedDotHandler);i.eventCenter.off("__taroShowTabBar",this.showTabBarHandler);i.eventCenter.off("__taroHideTabBar",this.hideTabBarHandler);i.eventCenter.off("__taroSetTabBarStyle",this.setTabBarStyleHandler);i.eventCenter.off("__taroSetTabBarItem",this.setTabBarItemHandler)};e.prototype.componentDidLoad=function(){this.tabbarPos=this.tabbar.nextElementSibling?"top":"bottom";this.bindEvent();this.routerChangeHandler()};e.prototype.disconnectedCallback=function(){this.removeEvent()};e.prototype.render=function(){var e,r;var a=this;var n=this.tabbarPos,i=n===void 0?"bottom":n;var l=this.status;var d=s("weui-tabbar",(e={},e["taro-tabbar__border-"+(this.borderStyle||"black")]=true,e));var b=this.selectedIndex===-1||l===m;var h=l===T;return t(o,{class:s(B,B+"-"+i,(r={},r[H]=b,r[x]=h,r))},t("div",{class:d,style:{backgroundColor:this.backgroundColor||"",height:"inherit"}},this.list.map((function(e,r){var o=a.selectedIndex===r;var n;var i;if(o){n=a.selectedColor||"";i=e.selectedIconPath}else{n=a.color||"";i=e.iconPath}return t(f,{index:r,onSelect:a.switchTab.bind(a),isSelected:o,textColor:n,iconPath:i,text:e.text,badgeText:e.badgeText,showRedDot:e.showRedDot})}))))};Object.defineProperty(e.prototype,"tabbar",{get:function(){return n(this)},enumerable:false,configurable:true});return e}());w.style=c}}}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as t,r as a,c as r,H as e,g as s}from"./p-8c7cf814.js";import o from"@tarojs/taro";import{c as i}from"./p-7e5d2d7a.js";const n=t=>{let a,r=t||"";const e={path:null,query:null,fragment:null};return a=r.indexOf("#"),a>-1&&(e.fragment=r.substring(a+1),r=r.substring(0,a)),a=r.indexOf("?"),a>-1&&(e.query=r.substring(a+1),r=r.substring(0,a)),e.path=r,e};function h(t){return"/"===t.charAt(0)}function b(t,a){for(var r=a,e=r+1,s=t.length;e<s;r+=1,e+=1)t[r]=t[e];t.pop()}const l=({index:a,isSelected:r=!1,textColor:e,iconPath:s,badgeText:o,showRedDot:n=!1,text:h,onSelect:b})=>{const l=i("weui-tabbar__item",{"weui-bar__item_on":r});return t("a",{key:a,href:"javascript:;",class:l,onClick:function(){b(a)}},t("span",{style:{display:"inline-block",position:"relative"}},t("img",{src:s,alt:"",class:"weui-tabbar__icon"}),!!o&&t("span",{class:"weui-badge taro-tabbar-badge",style:{position:"absolute",top:"-2px",right:"-13px"}},o),n&&t("span",{class:"weui-badge weui-badge_dot",style:{position:"absolute",top:"0",right:"-6px"}})),t("p",{class:"weui-tabbar__label",style:{color:e}},h))},d=(t="")=>"/"===t[0]?t:`/${t}`,c=(t="",a="")=>((t="",a="")=>new RegExp("^"+a+"(\\/|\\?|#|$)","i").test(t))(t,a)?t.substr(a.length):t;let _=class{constructor(t){a(this,t),this.onLongPress=r(this,"longpress",7),this.homePage="",this.customRoutes=[],this.tabbarPos="bottom",this.selectedIndex=-1,this.status=0,this.getOriginUrl=t=>{const a=this.customRoutes.filter((([,a])=>n(a).path===n(t).path));return((t="",a="")=>t.includes(a)?t.substring(0,t.length-a.length):t)(a.length?a[0][0]:t,".html")},this.getSelectedIndex=t=>{let a=-1;return this.list.forEach((({pagePath:r},e)=>{n(t).path===n(r).path&&(a=e)})),a},this.switchTab=t=>{this.selectedIndex=t,o.switchTab({url:this.list[t].pagePath})},this.switchTabHandler=({url:t,successHandler:a,errorHandler:r})=>{const e=function(t,a){void 0===a&&(a="");var r,e=t&&t.split("/")||[],s=a&&a.split("/")||[],o=t&&h(t),i=a&&h(a),n=o||i;if(t&&h(t)?s=e:e.length&&(s.pop(),s=s.concat(e)),!s.length)return"/";if(s.length){var l=s[s.length-1];r="."===l||".."===l||""===l}else r=!1;for(var d=0,c=s.length;c>=0;c--){var _=s[c];"."===_?b(s,c):".."===_?(b(s,c),d++):d&&(b(s,c),d--)}if(!n)for(;d--;d)s.unshift("..");!n||""===s[0]||s[0]&&h(s[0])||s.unshift("");var u=s.join("/");return r&&"/"!==u.substr(-1)&&(u+="/"),u}(t,this.getOriginUrl(this.getCurrentUrl()||this.homePage)),s=this.getSelectedIndex(e);s>-1?(this.switchTab(s),a({errMsg:"switchTab:ok"})):r({errMsg:`switchTab:fail page "${e}" is not found`})},this.routerChangeHandler=t=>{var a;const r=null===(a=null==t?void 0:t.toLocation)||void 0===a?void 0:a.path;let e;if("string"==typeof r){const t=this.conf.basename||"/";e=c(d(r||this.homePage),t)}else e=this.getCurrentUrl();this.selectedIndex=this.getSelectedIndex(this.getOriginUrl(e))},this.setTabBarBadgeHandler=({index:t,text:a,successHandler:r,errorHandler:e})=>{const s=[...this.list];t in s?(s[t].showRedDot=!1,s[t].badgeText=a,r({errMsg:"setTabBarBadge:ok"})):e({errMsg:"setTabBarBadge:fail tabbar item not found"}),this.list=s},this.removeTabBarBadgeHandler=({index:t,successHandler:a,errorHandler:r})=>{const e=[...this.list];t in e?(e[t].badgeText=null,e[t].badgeText=null,a({errMsg:"removeTabBarBadge:ok"})):r({errMsg:"removeTabBarBadge:fail tabbar item not found"}),this.list=e},this.showTabBarRedDotHandler=({index:t,successHandler:a,errorHandler:r})=>{const e=[...this.list];t in e?(e[t].badgeText=null,e[t].showRedDot=!0,a({errMsg:"showTabBarRedDot:ok"})):r({errMsg:"showTabBarRedDot:fail tabbar item not found"}),this.list=e},this.hideTabBarRedDotHandler=({index:t,successHandler:a,errorHandler:r})=>{const e=[...this.list];t in e?(e[t].showRedDot=!1,a({errMsg:"hideTabBarRedDot:ok"})):r({errMsg:"hideTabBarRedDot:fail tabbar item not found"}),this.list=e},this.showTabBarHandler=({successHandler:t})=>{this.status=0,t({errMsg:"showTabBar:ok"})},this.hideTabBarHandler=({animation:t,successHandler:a})=>{this.status=t?2:1,a({errMsg:"hideTabBar:ok"})},this.setTabBarStyleHandler=({color:t,selectedColor:a,backgroundColor:r,borderStyle:e,successHandler:s})=>{r&&(this.backgroundColor=r),e&&(this.borderStyle=e),t&&(this.color=t),a&&(this.selectedColor=a),s({errMsg:"setTabBarStyle:ok"})},this.setTabBarItemHandler=({index:t,iconPath:a,selectedIconPath:r,text:e,successHandler:s,errorHandler:o})=>{const i=[...this.list];t in i?(a&&(i[t].iconPath=a),r&&(i[t].selectedIconPath=r),e&&(i[t].text=e),s({errMsg:"setTabBarItem:ok"})):o({errMsg:"setTabBarItem:fail tabbar item not found"}),this.list=i};const e=this.conf.list,s=this.conf.customRoutes;if("[object Array]"!==Object.prototype.toString.call(e)||e.length<2||e.length>5)throw new Error("tabBar 配置错误");this.homePage=d(this.conf.homePage);for(let t in s){const a=s[t];t=d(t),"string"==typeof a?this.customRoutes.push([t,d(a)]):(null==a?void 0:a.length)>0&&this.customRoutes.push(...a.map((a=>[t,d(a)])))}e.forEach((t=>{0!==t.pagePath.indexOf("/")&&(t.pagePath="/"+t.pagePath)})),this.list=e,this.borderStyle=this.conf.borderStyle,this.backgroundColor=this.conf.backgroundColor,this.color=this.conf.color,this.selectedColor=this.conf.selectedColor}getCurrentUrl(){const t=this.conf.basename||"/";let a;if("hash"===this.conf.mode){const t=window.location.href,r=t.indexOf("#");a=-1===r?"":t.substring(r+1)}else a=location.pathname;const r=d(c(a,t));return decodeURI("/"===r?this.homePage:r)}bindEvent(){o.eventCenter.on("__taroRouterChange",this.routerChangeHandler),o.eventCenter.on("__taroSwitchTab",this.switchTabHandler),o.eventCenter.on("__taroSetTabBarBadge",this.setTabBarBadgeHandler),o.eventCenter.on("__taroRemoveTabBarBadge",this.removeTabBarBadgeHandler),o.eventCenter.on("__taroShowTabBarRedDotHandler",this.showTabBarRedDotHandler),o.eventCenter.on("__taroHideTabBarRedDotHandler",this.hideTabBarRedDotHandler),o.eventCenter.on("__taroShowTabBar",this.showTabBarHandler),o.eventCenter.on("__taroHideTabBar",this.hideTabBarHandler),o.eventCenter.on("__taroSetTabBarStyle",this.setTabBarStyleHandler),o.eventCenter.on("__taroSetTabBarItem",this.setTabBarItemHandler)}removeEvent(){o.eventCenter.off("__taroRouterChange",this.routerChangeHandler),o.eventCenter.off("__taroSwitchTab",this.switchTabHandler),o.eventCenter.off("__taroSetTabBarBadge",this.setTabBarBadgeHandler),o.eventCenter.off("__taroRemoveTabBarBadge",this.removeTabBarBadgeHandler),o.eventCenter.off("__taroShowTabBarRedDotHandler",this.showTabBarRedDotHandler),o.eventCenter.off("__taroHideTabBarRedDotHandler",this.hideTabBarRedDotHandler),o.eventCenter.off("__taroShowTabBar",this.showTabBarHandler),o.eventCenter.off("__taroHideTabBar",this.hideTabBarHandler),o.eventCenter.off("__taroSetTabBarStyle",this.setTabBarStyleHandler),o.eventCenter.off("__taroSetTabBarItem",this.setTabBarItemHandler)}componentDidLoad(){this.tabbarPos=this.tabbar.nextElementSibling?"top":"bottom",this.bindEvent(),this.routerChangeHandler()}disconnectedCallback(){this.removeEvent()}render(){const{tabbarPos:a="bottom"}=this,r=this.status,s=i("weui-tabbar",{[`taro-tabbar__border-${this.borderStyle||"black"}`]:!0});return t(e,{class:i("taro-tabbar__tabbar",`taro-tabbar__tabbar-${a}`,{"taro-tabbar__tabbar-hide":-1===this.selectedIndex||1===r,"taro-tabbar__tabbar-slideout":2===r})},t("div",{class:s,style:{backgroundColor:this.backgroundColor||"",height:"inherit"}},this.list.map(((a,r)=>{const e=this.selectedIndex===r;let s,o;return e?(s=this.selectedColor||"",o=a.selectedIconPath):(s=this.color||"",o=a.iconPath),t(l,{index:r,onSelect:this.switchTab.bind(this),isSelected:e,textColor:s,iconPath:o,text:a.text,badgeText:a.badgeText,showRedDot:a.showRedDot})}))))}get tabbar(){return s(this)}};_.style="html,body{height:100%}#app{height:100%}.taro-tabbar__border-white::before{border-top-color:#fff !important}.taro-tabbar__container{display:-ms-flexbox;display:flex;overflow:hidden;-ms-flex-direction:column;flex-direction:column;height:100%}.taro-tabbar__panel{overflow:auto;position:relative;-ms-flex:1;flex:1;-webkit-overflow-scrolling:auto}.taro-tabbar__tabbar{position:relative;width:100%;height:50px;-webkit-transition:bottom 0.2s, top 0.2s;transition:bottom 0.2s, top 0.2s}.taro-tabbar__tabbar-top{top:0}.taro-tabbar__tabbar-bottom{bottom:0;margin-bottom:constant(safe-area-inset-bottom);margin-bottom:env(safe-area-inset-bottom)}.taro-tabbar__tabbar-hide{display:none}.taro-tabbar__tabbar-slideout{top:-52px;-ms-flex:0 0;flex:0 0}.taro-tabbar__panel+.taro-tabbar__tabbar-slideout{top:auto;bottom:-52px}";export{_ as taro_tabbar}
|