@cloudbase/weda-ui 3.4.0 → 3.4.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.
- package/dist/configs/actions/showMessage.json +45 -0
- package/dist/configs/components/carousel.json +75 -65
- package/dist/configs/components/chart/bar.json +37 -1
- package/dist/configs/components/chart/line.json +3 -0
- package/dist/configs/components/chart/pie.json +3 -0
- package/dist/configs/components/container.json +15 -1
- package/dist/configs/components/dataView.json +45 -2
- package/dist/configs/components/form/location.json +1 -1
- package/dist/configs/components/form/richText.json +1 -1
- package/dist/configs/components/form/uploaderFile.json +3 -2
- package/dist/configs/components/formdetail.json +5 -0
- package/dist/configs/components/image.json +5 -2
- package/dist/configs/components/link.json +4 -1
- package/dist/configs/components/listView.json +109 -34
- package/dist/configs/components/richtextview.json +4 -1
- package/dist/configs/components/scrollVeiw.json +16 -1
- package/dist/configs/components/swiper.json +46 -37
- package/dist/configs/components/text.json +11 -5
- package/dist/configs/components/wxOpenApi/phone.json +1 -1
- package/dist/configs/components/wxOpenApi/phoneCode.json +1 -1
- package/dist/configs/components/wxOpenApi/userInfo.json +13 -1
- package/dist/configs/index.d.ts +2 -0
- package/dist/configs/index.js +2 -0
- package/dist/web/actions/index.d.ts +1 -0
- package/dist/web/actions/index.js +1 -0
- package/dist/web/actions/showMessage/index.css +6 -0
- package/dist/web/actions/showMessage/index.d.ts +17 -0
- package/dist/web/actions/showMessage/index.js +39 -0
- package/dist/web/components/button/index.d.ts +3 -2
- package/dist/web/components/button/index.js +14 -3
- package/dist/web/components/common/use-loop-render-detect.js +7 -6
- package/dist/web/components/form/form/index.js +13 -53
- package/dist/web/components/form/uploader/uploader.h5.js +1 -1
- package/dist/web/components/form/uploader/uploader.pc.js +2 -0
- package/dist/web/components/form/uploaderFile/uploadFile.h5.js +12 -10
- package/dist/web/components/form/uploaderFile/uploadFile.pc.d.ts +11 -0
- package/dist/web/components/form/uploaderFile/uploadFile.pc.js +10 -8
- package/dist/web/components/form/userOrgSelect/comTool.js +6 -3
- package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.pc.js +4 -4
- package/dist/web/components/form/userOrgSelect/getUserService.js +2 -1
- package/dist/web/components/form/userOrgSelect/userOrgSelect.css +10 -12
- package/dist/web/components/form/userOrgSelect/userTreeSelect.pc.js +36 -17
- package/dist/web/components/form/userOrgSelect/utils.d.ts +1 -0
- package/dist/web/components/form/userOrgSelect/utils.js +15 -0
- package/dist/web/components/formdetail/index.css +40 -27
- package/dist/web/components/formdetail/index.js +22 -19
- package/dist/web/components/link/index.js +2 -1
- package/dist/web/components/listView/index.css +5 -1
- package/dist/web/components/listView/index.js +22 -2
- package/dist/web/components/navigationBar/index.js +8 -3
- package/dist/web/components/phone/index.js +4 -1
- package/dist/web/components/phoneCode/index.js +4 -1
- package/dist/web/components/richText/index.d.ts +1 -1
- package/dist/web/components/richText/index.js +6 -6
- package/dist/web/components/share/index.js +4 -1
- package/dist/web/components/text/index.js +2 -1
- package/dist/web/components/userInfo/index.js +4 -1
- package/dist/web/utils/console.js +1 -1
- package/dist/web/utils/platform.d.ts +11 -1
- package/dist/web/utils/platform.js +61 -12
- package/package.json +2 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useMediaQuery } from '@react-hookz/web';
|
|
2
2
|
import { REL_DICT } from './constant';
|
|
3
|
+
import { message as TeaMessage } from 'tea-component';
|
|
3
4
|
/**
|
|
4
5
|
* 当前环境是否为 H5 端
|
|
5
6
|
*/
|
|
@@ -34,9 +35,9 @@ export const isHttpFileID = (url) => {
|
|
|
34
35
|
};
|
|
35
36
|
export function usePlatform() {
|
|
36
37
|
var _a, _b;
|
|
37
|
-
const smallScreen = (_a = useMediaQuery('(max-width:
|
|
38
|
+
const smallScreen = (_a = useMediaQuery('(max-width: 1024px)')) !== null && _a !== void 0 ? _a : isH5Platform();
|
|
38
39
|
const touchDevice = (_b = useMediaQuery('(pointer:coarse)')) !== null && _b !== void 0 ? _b : smallScreen;
|
|
39
|
-
// 非高精度指针(鼠标)就直接 h5, 否则当屏幕小于
|
|
40
|
+
// 非高精度指针(鼠标)就直接 h5, 否则当屏幕小于1024 时用h5
|
|
40
41
|
return touchDevice || smallScreen ? 'h5' : 'pc';
|
|
41
42
|
}
|
|
42
43
|
/**
|
|
@@ -84,19 +85,40 @@ export const transSize = (size) => {
|
|
|
84
85
|
/**
|
|
85
86
|
* 链接转换为下载
|
|
86
87
|
*/
|
|
87
|
-
export const downloadFile = (url) => {
|
|
88
|
+
export const downloadFile = (url, name) => {
|
|
88
89
|
if (!url) {
|
|
89
90
|
return;
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
92
|
+
var xhr = new XMLHttpRequest();
|
|
93
|
+
xhr.open('GET', url, true);
|
|
94
|
+
xhr.setRequestHeader('Content-type', 'application/octet-stream');
|
|
95
|
+
xhr.setRequestHeader('Content-Disposition', 'attachment');
|
|
96
|
+
xhr.responseType = 'blob';
|
|
97
|
+
xhr.onload = function () {
|
|
98
|
+
if (xhr.readyState === 4) {
|
|
99
|
+
if (xhr.status === 200) {
|
|
100
|
+
// data为blob格式
|
|
101
|
+
var blob = new Blob([xhr.response]);
|
|
102
|
+
var downloadElement = document.createElement('a');
|
|
103
|
+
var href = window.URL.createObjectURL(blob);
|
|
104
|
+
downloadElement.href = href;
|
|
105
|
+
downloadElement.download = name;
|
|
106
|
+
document.body.appendChild(downloadElement);
|
|
107
|
+
downloadElement.click();
|
|
108
|
+
document.body.removeChild(downloadElement);
|
|
109
|
+
window.URL.revokeObjectURL(href);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
console.error(xhr.statusText);
|
|
113
|
+
alertErrorMessage({ message: `下载失败 ${xhr.statusText}` });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
xhr.onerror = function () {
|
|
118
|
+
console.error(xhr.statusText);
|
|
119
|
+
alertErrorMessage({ message: `下载失败 ${xhr.statusText}` });
|
|
120
|
+
};
|
|
121
|
+
xhr.send();
|
|
100
122
|
};
|
|
101
123
|
/**
|
|
102
124
|
* 文件名截取,保留后缀类型
|
|
@@ -191,3 +213,30 @@ export const getWhereList = (where) => {
|
|
|
191
213
|
});
|
|
192
214
|
return result;
|
|
193
215
|
};
|
|
216
|
+
export const textToString = (text) => {
|
|
217
|
+
let str = String(text);
|
|
218
|
+
if (['undefined', 'null', 'Infinity', 'NaN'].includes(str)) {
|
|
219
|
+
return '';
|
|
220
|
+
}
|
|
221
|
+
return str;
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* 统一错误提示
|
|
225
|
+
*
|
|
226
|
+
*/
|
|
227
|
+
export function alertErrorMessage({ message, duration = 1500, icon = 'none' }) {
|
|
228
|
+
var _a, _b, _c, _d, _e;
|
|
229
|
+
const smallScreen = (_b = (_a = window === null || window === void 0 ? void 0 : window.matchMedia('(max-width: 1024px)')) === null || _a === void 0 ? void 0 : _a.matches) !== null && _b !== void 0 ? _b : isH5Platform();
|
|
230
|
+
const touchDevice = (_d = (_c = window === null || window === void 0 ? void 0 : window.matchMedia('(pointer:coarse)')) === null || _c === void 0 ? void 0 : _c.matches) !== null && _d !== void 0 ? _d : smallScreen;
|
|
231
|
+
const platform = touchDevice || smallScreen ? 'h5' : 'pc';
|
|
232
|
+
if (platform === 'h5') {
|
|
233
|
+
(_e = window === null || window === void 0 ? void 0 : window.app) === null || _e === void 0 ? void 0 : _e.showToast({
|
|
234
|
+
title: message,
|
|
235
|
+
icon,
|
|
236
|
+
duration,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
TeaMessage.error({ content: message, duration });
|
|
241
|
+
}
|
|
242
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/weda-ui",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index",
|
|
6
6
|
"miniprogram": "mpdist",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"pree2e:report": "npx mkdirp cypress/report && npx mochawesome-merge 'cypress/results/*.json' > cypress/report/mochawesome_full.json",
|
|
32
32
|
"e2e:report": "npx marge -o storybook-static/e2e-report cypress/report/mochawesome_full.json",
|
|
33
33
|
"test:all": "node tools/test-ci.mjs",
|
|
34
|
+
"test:coverage": "node tools/test-coverage.mjs",
|
|
34
35
|
"e2e": "npx cypress open --component",
|
|
35
36
|
"pretest:all": "rimraf .nyc_output || true",
|
|
36
37
|
"storybook": "start-storybook -p 6006",
|