@tuya-miniapp/smart-ui 2.3.0-beta-4 → 2.3.0-beta-6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README-zh_CN.md +66 -0
- package/dist/calendar/index.js +1 -0
- package/dist/calendar/index.json +1 -2
- package/dist/calendar/index.wxml +0 -2
- package/dist/common/appLog.d.ts +10 -0
- package/dist/common/appLog.js +105 -0
- package/dist/dialog/dialog.js +9 -0
- package/dist/dialog/index.js +5 -0
- package/dist/mixins/transition.js +13 -2
- package/dist/popover/index.js +2 -2
- package/dist/toast/index.js +4 -0
- package/dist/toast/toast.js +7 -1
- package/lib/calendar/index.js +1 -0
- package/lib/calendar/index.json +1 -2
- package/lib/calendar/index.wxml +0 -2
- package/lib/common/appLog.d.ts +10 -0
- package/lib/common/appLog.js +112 -0
- package/lib/dialog/dialog.js +12 -0
- package/lib/dialog/index.js +5 -0
- package/lib/mixins/transition.js +16 -2
- package/lib/popover/index.js +2 -2
- package/lib/toast/index.js +7 -0
- package/lib/toast/toast.js +10 -1
- package/package.json +6 -2
- package/lib/action-sheet/demo/index.d.ts +0 -1
- package/lib/action-sheet/demo/index.js +0 -124
- package/lib/area/demo/index.d.ts +0 -1
- package/lib/area/demo/index.js +0 -47
- package/lib/battery/demo/index.d.ts +0 -1
- package/lib/battery/demo/index.js +0 -4
- package/lib/bottom-sheet/demo/index.d.ts +0 -1
- package/lib/bottom-sheet/demo/index.js +0 -27
- package/lib/button/demo/index.d.ts +0 -1
- package/lib/button/demo/index.js +0 -14
- package/lib/calendar/demo/index.d.ts +0 -1
- package/lib/calendar/demo/index.js +0 -110
- package/lib/cascader/demo/index.d.ts +0 -1
- package/lib/cascader/demo/index.js +0 -197
- package/lib/cell/demo/index.d.ts +0 -1
- package/lib/cell/demo/index.js +0 -20
- package/lib/checkbox/demo/index.d.ts +0 -1
- package/lib/checkbox/demo/index.js +0 -38
- package/lib/circle/demo/index.d.ts +0 -1
- package/lib/circle/demo/index.js +0 -21
- package/lib/col/demo/index.d.ts +0 -1
- package/lib/col/demo/index.js +0 -6
- package/lib/collapse/demo/index.d.ts +0 -1
- package/lib/collapse/demo/index.js +0 -42
- package/lib/config-provider/demo/index.d.ts +0 -1
- package/lib/config-provider/demo/index.js +0 -24
- package/lib/count-down/demo/index.d.ts +0 -1
- package/lib/count-down/demo/index.js +0 -38
- package/lib/custom-keyboard/demo/index.d.ts +0 -1
- package/lib/custom-keyboard/demo/index.js +0 -19
- package/lib/datetime-picker/demo/index.d.ts +0 -1
- package/lib/datetime-picker/demo/index.js +0 -99
- package/lib/dialog/demo/index.d.ts +0 -1
- package/lib/dialog/demo/index.js +0 -144
- package/lib/divider/demo/index.d.ts +0 -1
- package/lib/divider/demo/index.js +0 -6
- package/lib/dropdown-menu/demo/index.d.ts +0 -1
- package/lib/dropdown-menu/demo/index.js +0 -52
- package/lib/empty/demo/index.d.ts +0 -1
- package/lib/empty/demo/index.js +0 -15
- package/lib/field/demo/index.d.ts +0 -1
- package/lib/field/demo/index.js +0 -25
- package/lib/goods-action/demo/index.d.ts +0 -1
- package/lib/goods-action/demo/index.js +0 -17
- package/lib/grid/demo/index.d.ts +0 -1
- package/lib/grid/demo/index.js +0 -11
- package/lib/icon/demo/index.d.ts +0 -1
- package/lib/icon/demo/index.js +0 -54
- package/lib/image/demo/index.d.ts +0 -1
- package/lib/image/demo/index.js +0 -17
- package/lib/index-bar/demo/index.d.ts +0 -1
- package/lib/index-bar/demo/index.js +0 -23
- package/lib/loading/demo/index.d.ts +0 -1
- package/lib/loading/demo/index.js +0 -6
- package/lib/nav-bar/demo/index.d.ts +0 -1
- package/lib/nav-bar/demo/index.js +0 -31
- package/lib/normal-slider/demo/index.d.ts +0 -1
- package/lib/normal-slider/demo/index.js +0 -21
- package/lib/notice-bar/demo/index.d.ts +0 -1
- package/lib/notice-bar/demo/index.js +0 -16
- package/lib/notify/demo/index.d.ts +0 -1
- package/lib/notify/demo/index.js +0 -50
- package/lib/overlay/demo/index.d.ts +0 -1
- package/lib/overlay/demo/index.js +0 -24
- package/lib/picker/demo/index.d.ts +0 -1
- package/lib/picker/demo/index.js +0 -99
- package/lib/popover/demo/index.d.ts +0 -1
- package/lib/popover/demo/index.js +0 -27
- package/lib/popup/demo/index.d.ts +0 -1
- package/lib/popup/demo/index.js +0 -85
- package/lib/progress/demo/index.d.ts +0 -1
- package/lib/progress/demo/index.js +0 -6
- package/lib/radio/demo/index.d.ts +0 -1
- package/lib/radio/demo/index.js +0 -34
- package/lib/rate/demo/index.d.ts +0 -1
- package/lib/rate/demo/index.js +0 -30
- package/lib/search/demo/index.d.ts +0 -1
- package/lib/search/demo/index.js +0 -48
- package/lib/sidebar/demo/index.d.ts +0 -1
- package/lib/sidebar/demo/index.js +0 -14
- package/lib/skeleton/demo/index.d.ts +0 -1
- package/lib/skeleton/demo/index.js +0 -14
- package/lib/slider/demo/index.d.ts +0 -1
- package/lib/slider/demo/index.js +0 -21
- package/lib/stepper/demo/index.d.ts +0 -1
- package/lib/stepper/demo/index.js +0 -25
- package/lib/steps/demo/index.d.ts +0 -1
- package/lib/steps/demo/index.js +0 -48
- package/lib/sticky/demo/index.d.ts +0 -1
- package/lib/sticky/demo/index.js +0 -30
- package/lib/swipe-cell/demo/index.d.ts +0 -1
- package/lib/swipe-cell/demo/index.js +0 -50
- package/lib/switch/demo/index.d.ts +0 -1
- package/lib/switch/demo/index.js +0 -37
- package/lib/tab/demo/index.d.ts +0 -1
- package/lib/tab/demo/index.js +0 -57
- package/lib/tabbar/demo/index.d.ts +0 -1
- package/lib/tabbar/demo/index.js +0 -41
- package/lib/tag/demo/index.d.ts +0 -1
- package/lib/tag/demo/index.js +0 -19
- package/lib/toast/demo/index.d.ts +0 -1
- package/lib/toast/demo/index.js +0 -74
- package/lib/transition/demo/index.d.ts +0 -1
- package/lib/transition/demo/index.js +0 -71
- package/lib/tree-select/demo/index.d.ts +0 -1
- package/lib/tree-select/demo/index.js +0 -130
package/README-zh_CN.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
[English](./README.md) | 简体中文
|
2
|
+
|
3
|
+
# @tuya-miniapp/smart-ui
|
4
|
+
|
5
|
+
## 介绍
|
6
|
+
|
7
|
+
`@tuya-miniapp/smart-ui` 是一个**轻量、可靠的智能小程序组件库**,其基于 `vant-weapp` 实现,提供了一整套符合智能小程序移动端设计规范的 UI 组件。
|
8
|
+
|
9
|
+
## 预览
|
10
|
+
|
11
|
+
扫描下方智能小程序二维码,体验组件库示例。
|
12
|
+
|
13
|
+
<img src="https://images.tuyacn.com/rms-static/8bcfe810-a187-11ef-9773-6b86083026a3-1731478901009.png?tyName=v2.0.0miniapp-SmartUI.png" width="200" height="200">
|
14
|
+
|
15
|
+
## 使用之前
|
16
|
+
|
17
|
+
使用 Smart UI 前,请确保你已经学习过智能小程序官方的 [智能小程序快速开始](https://developer.tuya.com/cn/miniapp/develop/miniapp/guide/start/smart) 和 [小程序组件介绍](https://developer.tuya.com/cn/miniapp/develop/miniapp/framework/component/intro)。
|
18
|
+
|
19
|
+
## 安装
|
20
|
+
|
21
|
+
```bash
|
22
|
+
# 通过 yarn 安装(推荐)
|
23
|
+
yarn add @tuya-miniapp/smart-ui
|
24
|
+
|
25
|
+
# 通过 npm 安装
|
26
|
+
npm i @tuya-miniapp/smart-ui
|
27
|
+
```
|
28
|
+
|
29
|
+
## 使用组件
|
30
|
+
|
31
|
+
以按钮组件为例,只需要在 json 文件中引入按钮对应的自定义组件即可
|
32
|
+
|
33
|
+
```json
|
34
|
+
{
|
35
|
+
"usingComponents": {
|
36
|
+
"smart-button": "@tuya-miniapp/smart-ui/lib/button/index"
|
37
|
+
}
|
38
|
+
}
|
39
|
+
```
|
40
|
+
|
41
|
+
接着就可以在 tyml 中直接使用组件
|
42
|
+
|
43
|
+
```html
|
44
|
+
<smart-button type="primary">按钮</smart-button>
|
45
|
+
```
|
46
|
+
|
47
|
+
## 在开发者工具中预览
|
48
|
+
|
49
|
+
```bash
|
50
|
+
# 安装项目依赖
|
51
|
+
yarn
|
52
|
+
|
53
|
+
# 执行组件编译
|
54
|
+
yarn dev
|
55
|
+
```
|
56
|
+
|
57
|
+
打开 [Tuya MiniApp Tools](https://developer.tuya.com/cn/miniapp/devtools/tools),把`smart-ui/example`目录添加进去就可以预览示例了。
|
58
|
+
|
59
|
+
## 基础库版本
|
60
|
+
|
61
|
+
`@tuya-miniapp/smart-ui` 从智能小程序基础库 `2.19.0` 版本开始提供稳定的支持。
|
62
|
+
|
63
|
+
## 开源协议
|
64
|
+
|
65
|
+
本项目基于 [MIT](https://zh.wikipedia.org/wiki/MIT%E8%A8%B1%E5%8F%AF%E8%AD%89) 协议,请自由地享受和参与开源。
|
66
|
+
|
package/dist/calendar/index.js
CHANGED
package/dist/calendar/index.json
CHANGED
package/dist/calendar/index.wxml
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
export declare const init: (tag: string) => any;
|
2
|
+
export declare const info: (data: any, devId?: string) => void;
|
3
|
+
export declare const warn: (data: any, devId?: string) => void;
|
4
|
+
export declare const error: (data: any, devId?: string) => void;
|
5
|
+
declare const _default: {
|
6
|
+
info: (data: any, devId?: string | undefined) => void;
|
7
|
+
warn: (data: any, devId?: string | undefined) => void;
|
8
|
+
error: (data: any, devId?: string | undefined) => void;
|
9
|
+
};
|
10
|
+
export default _default;
|
@@ -0,0 +1,105 @@
|
|
1
|
+
/* eslint-disable no-console */
|
2
|
+
const defaultTag = 'smart-ui-info';
|
3
|
+
let Log = null;
|
4
|
+
function isErrorMessage(obj) {
|
5
|
+
return obj instanceof Error;
|
6
|
+
}
|
7
|
+
export const init = (tag) => {
|
8
|
+
if (tag !== defaultTag && tag) {
|
9
|
+
Log = null;
|
10
|
+
}
|
11
|
+
if (Log) {
|
12
|
+
return Log;
|
13
|
+
}
|
14
|
+
// @ts-ignore
|
15
|
+
if (!ty.getLogManager) {
|
16
|
+
console.warn('不支持ty.getLogManager');
|
17
|
+
return null;
|
18
|
+
}
|
19
|
+
// @ts-ignore
|
20
|
+
Log = ty.getLogManager({
|
21
|
+
tag: tag || defaultTag,
|
22
|
+
});
|
23
|
+
return Log;
|
24
|
+
};
|
25
|
+
export const info = (data, devId) => {
|
26
|
+
if (!Log) {
|
27
|
+
const _log = init(devId || defaultTag);
|
28
|
+
if (!_log) {
|
29
|
+
return;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
if (typeof data !== 'string') {
|
33
|
+
// eslint-disable-next-line no-param-reassign
|
34
|
+
data = JSON.stringify(data);
|
35
|
+
}
|
36
|
+
Log.log({
|
37
|
+
message: data,
|
38
|
+
success(res) {
|
39
|
+
// console.log('success ty.Log', res);
|
40
|
+
},
|
41
|
+
failure(err) {
|
42
|
+
console.log('fail ty.Log', err);
|
43
|
+
},
|
44
|
+
});
|
45
|
+
};
|
46
|
+
export const warn = (data, devId) => {
|
47
|
+
if (!Log) {
|
48
|
+
const _log = init(devId || defaultTag);
|
49
|
+
if (!_log) {
|
50
|
+
return;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
if (typeof data !== 'string') {
|
54
|
+
// eslint-disable-next-line no-param-reassign
|
55
|
+
data = JSON.stringify(data);
|
56
|
+
}
|
57
|
+
Log.debug({
|
58
|
+
message: data,
|
59
|
+
success(res) {
|
60
|
+
console.log('success ty.debug', res);
|
61
|
+
},
|
62
|
+
failure(err) {
|
63
|
+
console.log('fail ty.debug', err);
|
64
|
+
},
|
65
|
+
});
|
66
|
+
};
|
67
|
+
export const error = (data, devId) => {
|
68
|
+
var _a, _b;
|
69
|
+
if (!Log) {
|
70
|
+
const _log = init(devId || defaultTag);
|
71
|
+
if (!_log) {
|
72
|
+
return;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
let _data = null;
|
76
|
+
const isError = isErrorMessage(data);
|
77
|
+
if (isError) {
|
78
|
+
_data = {
|
79
|
+
message: data.message,
|
80
|
+
stack: (_b = (_a = data.stack) === null || _a === void 0 ? void 0 : _a.slice(0, 200)) !== null && _b !== void 0 ? _b : [],
|
81
|
+
};
|
82
|
+
}
|
83
|
+
else {
|
84
|
+
try {
|
85
|
+
_data = JSON.stringify(data);
|
86
|
+
}
|
87
|
+
catch (e) {
|
88
|
+
_data = e === null || e === void 0 ? void 0 : e.toString();
|
89
|
+
}
|
90
|
+
}
|
91
|
+
Log.error({
|
92
|
+
message: _data,
|
93
|
+
success(res) {
|
94
|
+
console.log('success ty.error', res);
|
95
|
+
},
|
96
|
+
failure(err) {
|
97
|
+
console.log('fail ty.error', err);
|
98
|
+
},
|
99
|
+
});
|
100
|
+
};
|
101
|
+
export default {
|
102
|
+
info,
|
103
|
+
warn,
|
104
|
+
error,
|
105
|
+
};
|
package/dist/dialog/dialog.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import appLog from '../common/appLog';
|
1
2
|
import { getCurrentPage } from '../common/utils';
|
2
3
|
const queueRef = {
|
3
4
|
value: [],
|
@@ -36,15 +37,20 @@ export const contextRef = {
|
|
36
37
|
const Dialog = (options) => {
|
37
38
|
options = Object.assign(Object.assign({}, currentOptions), options);
|
38
39
|
return new Promise((resolve, reject) => {
|
40
|
+
appLog.info('start open dialog');
|
39
41
|
const context = (typeof options.context === 'function' ? options.context() : options.context) ||
|
40
42
|
contextRef.value[options.selector] ||
|
41
43
|
getCurrentPage();
|
42
44
|
const selector = options.selector;
|
45
|
+
appLog.info(`dialog selector: ${selector}`);
|
46
|
+
appLog.info(`queue : ${JSON.stringify(queueRef.value)}`);
|
43
47
|
const dialog = context.selectComponent(options.selector);
|
48
|
+
appLog.info(`dialog component ${dialog ? 'success' : 'fail'}`);
|
44
49
|
if (!options.ignoreQueue &&
|
45
50
|
queueRef.value.length > 0 &&
|
46
51
|
queueRef.value.find(item => dialog && item && item.id === dialog.id)) {
|
47
52
|
console.warn(`相同选择器的 Dialog 调用过于频繁,${dialog.id} 已忽略重复调用`);
|
53
|
+
appLog.info(`相同选择器的 Dialog 调用过于频繁,${dialog.id} 已忽略重复调用`);
|
48
54
|
return;
|
49
55
|
}
|
50
56
|
delete options.context;
|
@@ -60,14 +66,17 @@ const Dialog = (options) => {
|
|
60
66
|
*/
|
61
67
|
queueRef.value = queueRef.value.filter(item => item.id !== dialog.id);
|
62
68
|
action === 'confirm' ? resolve(instance) : reject(instance);
|
69
|
+
appLog.info(`dialog ${dialog.id} callback`);
|
63
70
|
} }, optionsWithInputValue));
|
64
71
|
wx.nextTick(() => {
|
72
|
+
appLog.info(`start open dialog ${dialog.id}`);
|
65
73
|
dialog.setData({ show: true });
|
66
74
|
});
|
67
75
|
queueRef.value.push(dialog);
|
68
76
|
}
|
69
77
|
else {
|
70
78
|
console.warn(`未找到 ${(selector !== null && selector !== void 0 ? selector : '#smart-dialog').replace('#', '')} 节点,请确认 selector 及 context 是否正确`);
|
79
|
+
appLog.info(`未找到 ${(selector !== null && selector !== void 0 ? selector : '#smart-dialog').replace('#', '')} 节点,请确认 selector 及 context 是否正确`);
|
71
80
|
}
|
72
81
|
});
|
73
82
|
};
|
package/dist/dialog/index.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import warningIcon from '@tuya-miniapp/icons/dist/svg/Warning';
|
2
2
|
import { SmartComponent } from '../common/component';
|
3
3
|
import { button } from '../mixins/button';
|
4
|
+
import appLog from '../common/appLog';
|
4
5
|
import { getCurrentPage, toPromise } from '../common/utils';
|
5
6
|
import { contextRef } from './dialog';
|
6
7
|
SmartComponent({
|
@@ -97,13 +98,16 @@ SmartComponent({
|
|
97
98
|
return;
|
98
99
|
if (contextRef.value[`#${this.id}`]) {
|
99
100
|
console.error(`Dialog component #${this.id} repeated!`);
|
101
|
+
appLog.info(`Dialog component #${this.id} repeated!`);
|
100
102
|
}
|
101
103
|
contextRef.value[`#${this.id}`] = getCurrentPage();
|
104
|
+
appLog.info(`Dialog #${this.id} mounted`);
|
102
105
|
},
|
103
106
|
destroyed: function () {
|
104
107
|
if (!this.id)
|
105
108
|
return;
|
106
109
|
contextRef.value[`#${this.id}`] = null;
|
110
|
+
appLog.info(`dialog #${this.id} destroyed`);
|
107
111
|
},
|
108
112
|
methods: {
|
109
113
|
onConfirm() {
|
@@ -181,6 +185,7 @@ SmartComponent({
|
|
181
185
|
},
|
182
186
|
onAfterLeave() {
|
183
187
|
this.$emit('after-leave');
|
188
|
+
appLog.info(`dialog #${this.id} after-leave`);
|
184
189
|
const { callback, actionType } = this.data;
|
185
190
|
if (callback) {
|
186
191
|
callback(actionType, this);
|
@@ -1,4 +1,5 @@
|
|
1
1
|
// @ts-nocheck
|
2
|
+
import appLog from '../common/appLog';
|
2
3
|
import { requestAnimationFrame } from '../common/utils';
|
3
4
|
import { isObj } from '../common/validator';
|
4
5
|
const getClassNames = (name) => ({
|
@@ -39,6 +40,7 @@ export function transition(showDefaultValue) {
|
|
39
40
|
},
|
40
41
|
methods: {
|
41
42
|
observeShow(value, old) {
|
43
|
+
appLog.info(`transition component observeShow value: ${value};old: ${value}`);
|
42
44
|
if (value === old) {
|
43
45
|
return;
|
44
46
|
}
|
@@ -47,6 +49,7 @@ export function transition(showDefaultValue) {
|
|
47
49
|
enter() {
|
48
50
|
if (this.enterFinishedPromise)
|
49
51
|
return;
|
52
|
+
appLog.info(`transition component enter success`);
|
50
53
|
this.enterFinishedPromise = new Promise(resolve => {
|
51
54
|
const { duration, name } = this.data;
|
52
55
|
const classNames = getClassNames(name);
|
@@ -72,6 +75,7 @@ export function transition(showDefaultValue) {
|
|
72
75
|
return;
|
73
76
|
}
|
74
77
|
this.transitionEnded = false;
|
78
|
+
appLog.info(`transition component enter transitionEnded false`);
|
75
79
|
this.setData({ classes: classNames['enter-to'] });
|
76
80
|
resolve();
|
77
81
|
});
|
@@ -79,12 +83,14 @@ export function transition(showDefaultValue) {
|
|
79
83
|
});
|
80
84
|
this.enterFinishedPromise.catch(err => {
|
81
85
|
this.enterFinishedPromise = null;
|
82
|
-
|
86
|
+
appLog.info(err);
|
87
|
+
console.log(err, '---error-enter');
|
83
88
|
});
|
84
89
|
},
|
85
90
|
leave() {
|
86
91
|
if (!this.enterFinishedPromise)
|
87
92
|
return;
|
93
|
+
appLog.info(`transition component leave success`);
|
88
94
|
this.enterFinishedPromise
|
89
95
|
.then(() => {
|
90
96
|
if (!this.data.display) {
|
@@ -109,8 +115,10 @@ export function transition(showDefaultValue) {
|
|
109
115
|
return;
|
110
116
|
}
|
111
117
|
this.transitionEnded = false;
|
118
|
+
appLog.info(`transition component leave transitionEnded false`);
|
112
119
|
setTimeout(() => {
|
113
120
|
this.enterFinishedPromise = null;
|
121
|
+
appLog.info(`transition component enterFinishedPromise cleared`);
|
114
122
|
this.onTransitionEnd();
|
115
123
|
}, currentDuration);
|
116
124
|
this.setData({ classes: classNames['leave-to'] });
|
@@ -119,15 +127,18 @@ export function transition(showDefaultValue) {
|
|
119
127
|
})
|
120
128
|
.catch(err => {
|
121
129
|
this.enterFinishedPromise = null;
|
122
|
-
console.log(err, '---error');
|
130
|
+
console.log(err, '---error-leave');
|
123
131
|
});
|
124
132
|
},
|
125
133
|
onTransitionEnd() {
|
134
|
+
appLog.info(`transition component in transitionEnded ${this.transitionEnded}`);
|
126
135
|
if (this.transitionEnded) {
|
127
136
|
return;
|
128
137
|
}
|
129
138
|
this.transitionEnded = true;
|
139
|
+
appLog.info(`transition component in transitionEnded true`);
|
130
140
|
this.$emit(`after-${this.status}`);
|
141
|
+
appLog.info(`transition component onTransitionEnd ${this.status} success`);
|
131
142
|
const { show, display } = this.data;
|
132
143
|
if (!show && display) {
|
133
144
|
this.setData({ display: false });
|
package/dist/popover/index.js
CHANGED
@@ -161,7 +161,7 @@ SmartComponent({
|
|
161
161
|
this.setData({
|
162
162
|
currentShow: true,
|
163
163
|
});
|
164
|
-
this.$emit('
|
164
|
+
this.$emit('show-change', true);
|
165
165
|
if (this.data.duration) {
|
166
166
|
setTimeout(() => {
|
167
167
|
this.onClose();
|
@@ -172,7 +172,7 @@ SmartComponent({
|
|
172
172
|
this.setData({
|
173
173
|
currentShow: false,
|
174
174
|
});
|
175
|
-
this.$emit('
|
175
|
+
this.$emit('show-change', false);
|
176
176
|
this.$emit('close', false);
|
177
177
|
},
|
178
178
|
},
|
package/dist/toast/index.js
CHANGED
@@ -2,6 +2,7 @@ import { Success, Alarm, Error } from './icons';
|
|
2
2
|
import { SmartComponent } from '../common/component';
|
3
3
|
import { contextRef } from './toast';
|
4
4
|
import { getCurrentPage } from '../common/utils';
|
5
|
+
import appLog from '../common/appLog';
|
5
6
|
SmartComponent({
|
6
7
|
props: {
|
7
8
|
show: Boolean,
|
@@ -38,13 +39,16 @@ SmartComponent({
|
|
38
39
|
return;
|
39
40
|
if (contextRef.value[`#${this.id}`]) {
|
40
41
|
console.error(`Toast component #${this.id} repeated!`);
|
42
|
+
appLog.info(`Toast component #${this.id} repeated!`);
|
41
43
|
}
|
42
44
|
contextRef.value[`#${this.id}`] = getCurrentPage();
|
45
|
+
appLog.info(`Toast #${this.id} mounted`);
|
43
46
|
},
|
44
47
|
destroyed: function () {
|
45
48
|
if (!this.id)
|
46
49
|
return;
|
47
50
|
contextRef.value[`#${this.id}`] = null;
|
51
|
+
appLog.info(`Toast #${this.id} destroyed`);
|
48
52
|
},
|
49
53
|
methods: {
|
50
54
|
// for prevent touchmove
|
package/dist/toast/toast.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import appLog from '../common/appLog';
|
1
2
|
import { getCurrentPage } from '../common/utils';
|
2
3
|
import { isObj } from '../common/validator';
|
3
4
|
const defaultOptions = {
|
@@ -27,12 +28,16 @@ export const contextRef = {
|
|
27
28
|
};
|
28
29
|
function Toast(toastOptions) {
|
29
30
|
const options = Object.assign(Object.assign({}, currentOptions), parseOptions(toastOptions));
|
31
|
+
appLog.info('start open Toast');
|
30
32
|
const context = (typeof options.context === 'function' ? options.context() : options.context) ||
|
31
33
|
contextRef.value[options.selector] ||
|
32
34
|
getCurrentPage();
|
33
35
|
const toast = context.selectComponent(options.selector);
|
36
|
+
appLog.info(`toast selector: ${options.selector}`);
|
37
|
+
appLog.info(`toast component ${toast ? 'success' : 'fail'}`);
|
34
38
|
if (!toast) {
|
35
|
-
console.warn('
|
39
|
+
console.warn(`未找到 ${options.selector || '#smart-toast'} 节点,请确认 selector 及 context 是否正确`);
|
40
|
+
appLog.info(`未找到 ${options.selector || '#smart-toast'} 节点,请确认 selector 及 context 是否正确`);
|
36
41
|
return;
|
37
42
|
}
|
38
43
|
delete options.context;
|
@@ -50,6 +55,7 @@ function Toast(toastOptions) {
|
|
50
55
|
toast.timer = setTimeout(() => {
|
51
56
|
toast.clear();
|
52
57
|
queueRef.value = queueRef.value.filter(item => item !== toast);
|
58
|
+
appLog.info(`toast ${options.selector} cleared`);
|
53
59
|
}, options.duration);
|
54
60
|
}
|
55
61
|
return toast;
|
package/lib/calendar/index.js
CHANGED
@@ -434,6 +434,7 @@ var getTime = function (date) { return (date instanceof Date ? date.getTime() :
|
|
434
434
|
if (maxRange && (0, utils_1.calcDateNum)(date) > maxRange) {
|
435
435
|
if (showRangePrompt) {
|
436
436
|
(0, toast_1.default)({
|
437
|
+
selector: '#smart-toast-calendar',
|
437
438
|
context: this,
|
438
439
|
message: rangePrompt || "\u9009\u62E9\u5929\u6570\u4E0D\u80FD\u8D85\u8FC7 ".concat(maxRange, " \u5929"),
|
439
440
|
});
|
package/lib/calendar/index.json
CHANGED
package/lib/calendar/index.wxml
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
export declare const init: (tag: string) => any;
|
2
|
+
export declare const info: (data: any, devId?: string) => void;
|
3
|
+
export declare const warn: (data: any, devId?: string) => void;
|
4
|
+
export declare const error: (data: any, devId?: string) => void;
|
5
|
+
declare const _default: {
|
6
|
+
info: (data: any, devId?: string | undefined) => void;
|
7
|
+
warn: (data: any, devId?: string | undefined) => void;
|
8
|
+
error: (data: any, devId?: string | undefined) => void;
|
9
|
+
};
|
10
|
+
export default _default;
|
@@ -0,0 +1,112 @@
|
|
1
|
+
"use strict";
|
2
|
+
/* eslint-disable no-console */
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.error = exports.warn = exports.info = exports.init = void 0;
|
5
|
+
var defaultTag = 'smart-ui-info';
|
6
|
+
var Log = null;
|
7
|
+
function isErrorMessage(obj) {
|
8
|
+
return obj instanceof Error;
|
9
|
+
}
|
10
|
+
var init = function (tag) {
|
11
|
+
if (tag !== defaultTag && tag) {
|
12
|
+
Log = null;
|
13
|
+
}
|
14
|
+
if (Log) {
|
15
|
+
return Log;
|
16
|
+
}
|
17
|
+
// @ts-ignore
|
18
|
+
if (!ty.getLogManager) {
|
19
|
+
console.warn('不支持ty.getLogManager');
|
20
|
+
return null;
|
21
|
+
}
|
22
|
+
// @ts-ignore
|
23
|
+
Log = ty.getLogManager({
|
24
|
+
tag: tag || defaultTag,
|
25
|
+
});
|
26
|
+
return Log;
|
27
|
+
};
|
28
|
+
exports.init = init;
|
29
|
+
var info = function (data, devId) {
|
30
|
+
if (!Log) {
|
31
|
+
var _log = (0, exports.init)(devId || defaultTag);
|
32
|
+
if (!_log) {
|
33
|
+
return;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
if (typeof data !== 'string') {
|
37
|
+
// eslint-disable-next-line no-param-reassign
|
38
|
+
data = JSON.stringify(data);
|
39
|
+
}
|
40
|
+
Log.log({
|
41
|
+
message: data,
|
42
|
+
success: function (res) {
|
43
|
+
// console.log('success ty.Log', res);
|
44
|
+
},
|
45
|
+
failure: function (err) {
|
46
|
+
console.log('fail ty.Log', err);
|
47
|
+
},
|
48
|
+
});
|
49
|
+
};
|
50
|
+
exports.info = info;
|
51
|
+
var warn = function (data, devId) {
|
52
|
+
if (!Log) {
|
53
|
+
var _log = (0, exports.init)(devId || defaultTag);
|
54
|
+
if (!_log) {
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
if (typeof data !== 'string') {
|
59
|
+
// eslint-disable-next-line no-param-reassign
|
60
|
+
data = JSON.stringify(data);
|
61
|
+
}
|
62
|
+
Log.debug({
|
63
|
+
message: data,
|
64
|
+
success: function (res) {
|
65
|
+
console.log('success ty.debug', res);
|
66
|
+
},
|
67
|
+
failure: function (err) {
|
68
|
+
console.log('fail ty.debug', err);
|
69
|
+
},
|
70
|
+
});
|
71
|
+
};
|
72
|
+
exports.warn = warn;
|
73
|
+
var error = function (data, devId) {
|
74
|
+
var _a, _b;
|
75
|
+
if (!Log) {
|
76
|
+
var _log = (0, exports.init)(devId || defaultTag);
|
77
|
+
if (!_log) {
|
78
|
+
return;
|
79
|
+
}
|
80
|
+
}
|
81
|
+
var _data = null;
|
82
|
+
var isError = isErrorMessage(data);
|
83
|
+
if (isError) {
|
84
|
+
_data = {
|
85
|
+
message: data.message,
|
86
|
+
stack: (_b = (_a = data.stack) === null || _a === void 0 ? void 0 : _a.slice(0, 200)) !== null && _b !== void 0 ? _b : [],
|
87
|
+
};
|
88
|
+
}
|
89
|
+
else {
|
90
|
+
try {
|
91
|
+
_data = JSON.stringify(data);
|
92
|
+
}
|
93
|
+
catch (e) {
|
94
|
+
_data = e === null || e === void 0 ? void 0 : e.toString();
|
95
|
+
}
|
96
|
+
}
|
97
|
+
Log.error({
|
98
|
+
message: _data,
|
99
|
+
success: function (res) {
|
100
|
+
console.log('success ty.error', res);
|
101
|
+
},
|
102
|
+
failure: function (err) {
|
103
|
+
console.log('fail ty.error', err);
|
104
|
+
},
|
105
|
+
});
|
106
|
+
};
|
107
|
+
exports.error = error;
|
108
|
+
exports.default = {
|
109
|
+
info: exports.info,
|
110
|
+
warn: exports.warn,
|
111
|
+
error: exports.error,
|
112
|
+
};
|
package/lib/dialog/dialog.js
CHANGED
@@ -10,8 +10,12 @@ var __assign = (this && this.__assign) || function () {
|
|
10
10
|
};
|
11
11
|
return __assign.apply(this, arguments);
|
12
12
|
};
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
15
|
+
};
|
13
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
14
17
|
exports.contextRef = void 0;
|
18
|
+
var appLog_1 = __importDefault(require("../common/appLog"));
|
15
19
|
var utils_1 = require("../common/utils");
|
16
20
|
var queueRef = {
|
17
21
|
value: [],
|
@@ -50,15 +54,20 @@ exports.contextRef = {
|
|
50
54
|
var Dialog = function (options) {
|
51
55
|
options = __assign(__assign({}, currentOptions), options);
|
52
56
|
return new Promise(function (resolve, reject) {
|
57
|
+
appLog_1.default.info('start open dialog');
|
53
58
|
var context = (typeof options.context === 'function' ? options.context() : options.context) ||
|
54
59
|
exports.contextRef.value[options.selector] ||
|
55
60
|
(0, utils_1.getCurrentPage)();
|
56
61
|
var selector = options.selector;
|
62
|
+
appLog_1.default.info("dialog selector: ".concat(selector));
|
63
|
+
appLog_1.default.info("queue : ".concat(JSON.stringify(queueRef.value)));
|
57
64
|
var dialog = context.selectComponent(options.selector);
|
65
|
+
appLog_1.default.info("dialog component ".concat(dialog ? 'success' : 'fail'));
|
58
66
|
if (!options.ignoreQueue &&
|
59
67
|
queueRef.value.length > 0 &&
|
60
68
|
queueRef.value.find(function (item) { return dialog && item && item.id === dialog.id; })) {
|
61
69
|
console.warn("\u76F8\u540C\u9009\u62E9\u5668\u7684 Dialog \u8C03\u7528\u8FC7\u4E8E\u9891\u7E41\uFF0C".concat(dialog.id, " \u5DF2\u5FFD\u7565\u91CD\u590D\u8C03\u7528"));
|
70
|
+
appLog_1.default.info("\u76F8\u540C\u9009\u62E9\u5668\u7684 Dialog \u8C03\u7528\u8FC7\u4E8E\u9891\u7E41\uFF0C".concat(dialog.id, " \u5DF2\u5FFD\u7565\u91CD\u590D\u8C03\u7528"));
|
62
71
|
return;
|
63
72
|
}
|
64
73
|
delete options.context;
|
@@ -74,14 +83,17 @@ var Dialog = function (options) {
|
|
74
83
|
*/
|
75
84
|
queueRef.value = queueRef.value.filter(function (item) { return item.id !== dialog.id; });
|
76
85
|
action === 'confirm' ? resolve(instance) : reject(instance);
|
86
|
+
appLog_1.default.info("dialog ".concat(dialog.id, " callback"));
|
77
87
|
} }, optionsWithInputValue));
|
78
88
|
wx.nextTick(function () {
|
89
|
+
appLog_1.default.info("start open dialog ".concat(dialog.id));
|
79
90
|
dialog.setData({ show: true });
|
80
91
|
});
|
81
92
|
queueRef.value.push(dialog);
|
82
93
|
}
|
83
94
|
else {
|
84
95
|
console.warn("\u672A\u627E\u5230 ".concat((selector !== null && selector !== void 0 ? selector : '#smart-dialog').replace('#', ''), " \u8282\u70B9\uFF0C\u8BF7\u786E\u8BA4 selector \u53CA context \u662F\u5426\u6B63\u786E"));
|
96
|
+
appLog_1.default.info("\u672A\u627E\u5230 ".concat((selector !== null && selector !== void 0 ? selector : '#smart-dialog').replace('#', ''), " \u8282\u70B9\uFF0C\u8BF7\u786E\u8BA4 selector \u53CA context \u662F\u5426\u6B63\u786E"));
|
85
97
|
}
|
86
98
|
});
|
87
99
|
};
|
package/lib/dialog/index.js
CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var Warning_1 = __importDefault(require("@tuya-miniapp/icons/dist/svg/Warning"));
|
7
7
|
var component_1 = require("../common/component");
|
8
8
|
var button_1 = require("../mixins/button");
|
9
|
+
var appLog_1 = __importDefault(require("../common/appLog"));
|
9
10
|
var utils_1 = require("../common/utils");
|
10
11
|
var dialog_1 = require("./dialog");
|
11
12
|
(0, component_1.SmartComponent)({
|
@@ -102,13 +103,16 @@ var dialog_1 = require("./dialog");
|
|
102
103
|
return;
|
103
104
|
if (dialog_1.contextRef.value["#".concat(this.id)]) {
|
104
105
|
console.error("Dialog component #".concat(this.id, " repeated!"));
|
106
|
+
appLog_1.default.info("Dialog component #".concat(this.id, " repeated!"));
|
105
107
|
}
|
106
108
|
dialog_1.contextRef.value["#".concat(this.id)] = (0, utils_1.getCurrentPage)();
|
109
|
+
appLog_1.default.info("Dialog #".concat(this.id, " mounted"));
|
107
110
|
},
|
108
111
|
destroyed: function () {
|
109
112
|
if (!this.id)
|
110
113
|
return;
|
111
114
|
dialog_1.contextRef.value["#".concat(this.id)] = null;
|
115
|
+
appLog_1.default.info("dialog #".concat(this.id, " destroyed"));
|
112
116
|
},
|
113
117
|
methods: {
|
114
118
|
onConfirm: function () {
|
@@ -189,6 +193,7 @@ var dialog_1 = require("./dialog");
|
|
189
193
|
},
|
190
194
|
onAfterLeave: function () {
|
191
195
|
this.$emit('after-leave');
|
196
|
+
appLog_1.default.info("dialog #".concat(this.id, " after-leave"));
|
192
197
|
var _a = this.data, callback = _a.callback, actionType = _a.actionType;
|
193
198
|
if (callback) {
|
194
199
|
callback(actionType, this);
|