@cloudbase/weda-ui 3.1.3 → 3.1.4
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/components/carousel.json +2 -2
- package/dist/configs/components/form/checkbox.json +1 -0
- package/dist/configs/components/form/form.json +39 -15
- package/dist/configs/components/form/select.json +1 -0
- package/dist/web/components/chart/common/core/eChartBar.js +3 -1
- package/dist/web/components/chart/common/core/eChartLine.js +3 -1
- package/dist/web/components/form/checkbox/index.js +1 -1
- package/dist/web/components/form/form/index.css +4 -0
- package/dist/web/components/form/form/index.d.ts +21 -2
- package/dist/web/components/form/form/index.js +90 -16
- package/dist/web/components/form/location/common/mapChoose.js +93 -35
- package/dist/web/components/form/select/dropdown-select/ui.d.ts +15 -0
- package/dist/web/components/form/select/dropdown-select/ui.js +55 -0
- package/dist/web/components/form/select/h5.d.ts +1 -1
- package/dist/web/components/form/select/h5.js +54 -152
- package/dist/web/components/form/select/index.d.ts +1 -1
- package/dist/web/components/form/select/index.js +33 -96
- package/dist/web/components/form/select/use-options.d.ts +26 -0
- package/dist/web/components/form/select/use-options.js +103 -0
- package/dist/web/components/form/uploader/index.css +10 -3
- package/dist/web/components/form/uploader/uploader.h5.d.ts +1 -1
- package/dist/web/components/form/uploader/uploader.h5.js +18 -19
- package/dist/web/components/form/uploader/uploader.pc.js +6 -3
- package/dist/web/components/richText/index.js +14 -14
- package/dist/web/utils/tcb.d.ts +5 -1
- package/dist/web/utils/tcb.js +26 -3
- package/package.json +39 -36
|
@@ -10,7 +10,7 @@ const uploadPath = 'weda-uploader';
|
|
|
10
10
|
/**
|
|
11
11
|
* H5端
|
|
12
12
|
*/
|
|
13
|
-
export function ImageUploaderH5({ title, maxUploadCount, maxSize = 10, acceptTypes, className, id, events, layout, defaultValue, single = false, requiredFlag = false, onChange, style, }) {
|
|
13
|
+
export function ImageUploaderH5({ title, maxUploadCount, maxSize = 10, acceptTypes, className, id, events, layout, defaultValue, single = false, disabled = false, requiredFlag = false, onChange, style, }) {
|
|
14
14
|
const cls = classNames({
|
|
15
15
|
'weda-ui': true,
|
|
16
16
|
'weui-cells': true,
|
|
@@ -123,24 +123,23 @@ export function ImageUploaderH5({ title, maxUploadCount, maxSize = 10, acceptTyp
|
|
|
123
123
|
React.createElement("div", { className: "weui-uploader__file-content" },
|
|
124
124
|
progress,
|
|
125
125
|
"%")))),
|
|
126
|
-
showAdd && (React.createElement("div", { className: "weui-uploader__input-box" },
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
} })))))));
|
|
126
|
+
showAdd && (React.createElement("div", { className: "weui-uploader__input-box" }, !disabled && (React.createElement("input", { id: "uploaderInput", className: "weui-uploader__input", type: "file", accept: accepts.join(','), multiple: true, onChange: (e) => {
|
|
127
|
+
const files = [...e.target.files];
|
|
128
|
+
if (files.some((f) => f.size > maxSize * 1024 * 1024)) {
|
|
129
|
+
weui.alert('请上传不超过10M的图片');
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
if (files.length > finalMaxImgCount) {
|
|
133
|
+
// 防止一下子选择过多文件
|
|
134
|
+
weui.alert(`最多只能上传${finalMaxImgCount}张图片,请重新选择`);
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
if (fileIdList.length + files.length > finalMaxImgCount) {
|
|
138
|
+
weui.alert(`最多只能上传${finalMaxImgCount}张图片`);
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
files.forEach((f) => uploadToTcb(f));
|
|
142
|
+
} }))))))));
|
|
144
143
|
}
|
|
145
144
|
function SingleImage({ src, deleteBySrc }) {
|
|
146
145
|
const [error, setError] = React.useState(false);
|
|
@@ -36,7 +36,7 @@ export function UploaderPC({ layout, className, id, style, title, tips, ...props
|
|
|
36
36
|
}
|
|
37
37
|
export function UploaderPCInner(props) {
|
|
38
38
|
const { tips = '', btnTitle = '上传图片', maxUploadCount = 9, maxSize = 10, value: defaultValue, // 需要兼容 cloud:和https: 协议,需要兼容 字符串和字符串数组
|
|
39
|
-
acceptTypes = IMAGE_TYPES, uploadPath = 'weda-uploader', events = emptyObject, single = false, onChange, } = props;
|
|
39
|
+
acceptTypes = IMAGE_TYPES, uploadPath = 'weda-uploader', events = emptyObject, single = false, disabled = false, onChange, } = props;
|
|
40
40
|
// 上传中
|
|
41
41
|
const [uploading, setUploading] = React.useState(false);
|
|
42
42
|
//上传进度
|
|
@@ -146,13 +146,16 @@ export function UploaderPCInner(props) {
|
|
|
146
146
|
"\u4E0A\u4F20",
|
|
147
147
|
progress,
|
|
148
148
|
"%..."))))),
|
|
149
|
-
React.createElement("div", { className: `${CLASS_PREFIX}__input-box` }, ((
|
|
149
|
+
React.createElement("div", { className: `${CLASS_PREFIX}__input-box` }, disabled ? (React.createElement("li", { className: "_weda-fn-upload-result__item wedatea2td-disabled" },
|
|
150
|
+
React.createElement("div", { className: "_weda-fn-upload-result__status" },
|
|
151
|
+
React.createElement("i", { className: "wedatea2td-icon wedatea2td-icon-plus", role: "img", "aria-label": "plus" }),
|
|
152
|
+
React.createElement("span", { className: "wedatea2td-mt-1n wedatea2td-text-label wedatea2td-fz-reset" }, btnTitle)))) : (((!single && fileIDList.length < maxUploadCount) ||
|
|
150
153
|
(single && fileIDList.length < 1)) && ( // single 模式时,仅当数组为空时显示
|
|
151
154
|
React.createElement(Upload, { ...extraProps, beforeUpload: beforeHandle },
|
|
152
155
|
React.createElement("li", { className: "_weda-fn-upload-result__item _weda-fn-upload-result__item--upload" },
|
|
153
156
|
React.createElement("div", { className: "_weda-fn-upload-result__status" },
|
|
154
157
|
React.createElement("i", { className: "wedatea2td-icon wedatea2td-icon-plus", role: "img", "aria-label": "plus" }),
|
|
155
|
-
React.createElement("span", { className: "wedatea2td-mt-1n wedatea2td-text-label wedatea2td-fz-reset" }, btnTitle)))))))));
|
|
158
|
+
React.createElement("span", { className: "wedatea2td-mt-1n wedatea2td-text-label wedatea2td-fz-reset" }, btnTitle))))))))));
|
|
156
159
|
}
|
|
157
160
|
export const TcbImage = (props) => {
|
|
158
161
|
const { fileID, isZoom, ...rest } = props;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import { useSetState } from '../../utils/useSetState';
|
|
3
3
|
import classNames from '../../utils/classnames';
|
|
4
4
|
import Editor, { convertEditorStateToHTML } from 'kedao';
|
|
@@ -56,18 +56,18 @@ label, labelVisible, value: initialValue, readOnly, layout, requiredFlag, onChan
|
|
|
56
56
|
const state = createStateFromContent(initialValue, {});
|
|
57
57
|
setEditorState(state);
|
|
58
58
|
}, []);
|
|
59
|
-
const extendControls =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
{ type: 'IMAGE', url }
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
];
|
|
59
|
+
const extendControls = useMemo(() => {
|
|
60
|
+
return [
|
|
61
|
+
{
|
|
62
|
+
key: 'richtext-uploader',
|
|
63
|
+
type: 'component',
|
|
64
|
+
component: (React.createElement(CustomUploader, { acceptTypes: acceptTypes, maxSize: maxSize, cloudPath: cloudPath, onChange: (url) => {
|
|
65
|
+
const state = ContentUtils.insertMedias(latestEditorState.current, [{ type: 'IMAGE', url }]);
|
|
66
|
+
setEditorState(state);
|
|
67
|
+
} })),
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
}, [setEditorState, acceptTypes, maxSize, cloudPath, ContentUtils]);
|
|
71
71
|
// 修改img显示逻辑
|
|
72
72
|
const blockRenderFn = (contentBlock, { editor, editorState }) => {
|
|
73
73
|
var _a;
|
|
@@ -263,7 +263,7 @@ export const RichTextImg = ({ contentState, block }) => {
|
|
|
263
263
|
React.createElement("div", { className: "bf-media" },
|
|
264
264
|
React.createElement("div", { draggable: "true", className: "bf-image", style: { float: 'left' } },
|
|
265
265
|
React.createElement("div", { style: { position: 'relative', display: 'inline-block' } },
|
|
266
|
-
React.createElement("img", { src: src,
|
|
266
|
+
React.createElement("img", { src: src, style: { maxWidth: '100%', width }, onError: () => {
|
|
267
267
|
setSrc(defaultBase64);
|
|
268
268
|
setWidth('80px');
|
|
269
269
|
} }),
|
package/dist/web/utils/tcb.d.ts
CHANGED
|
@@ -11,7 +11,11 @@ export function getTempFileURL(data: any): Promise<any>;
|
|
|
11
11
|
/**
|
|
12
12
|
* 云函数获取数据
|
|
13
13
|
*/
|
|
14
|
-
export function callDataSource(param: any): Promise<any>;
|
|
14
|
+
export function callDataSource(param: any, throwError?: boolean): Promise<any>;
|
|
15
|
+
/**
|
|
16
|
+
* 云函数获取连接器数据
|
|
17
|
+
*/
|
|
18
|
+
export function callConnector(param: any, throwError?: boolean): Promise<any>;
|
|
15
19
|
/**
|
|
16
20
|
* 云API:获取用户自定义导航内容
|
|
17
21
|
* param
|
package/dist/web/utils/tcb.js
CHANGED
|
@@ -34,19 +34,42 @@ export async function getTempFileURL(data) {
|
|
|
34
34
|
/**
|
|
35
35
|
* 云函数获取数据
|
|
36
36
|
*/
|
|
37
|
-
export async function callDataSource(param) {
|
|
37
|
+
export async function callDataSource(param, throwError = false) {
|
|
38
38
|
var _a, _b, _c;
|
|
39
|
-
const {
|
|
39
|
+
const { dataSourceName, methodName, params } = param;
|
|
40
40
|
try {
|
|
41
41
|
const res = await ((_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.app) === null || _a === void 0 ? void 0 : _a.cloud) === null || _b === void 0 ? void 0 : _b.callDataSource) === null || _c === void 0 ? void 0 : _c.call(_b, {
|
|
42
|
+
dataSourceName,
|
|
43
|
+
methodName,
|
|
42
44
|
params,
|
|
45
|
+
}));
|
|
46
|
+
return res;
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.error('callDataSource: ', error);
|
|
50
|
+
if (throwError)
|
|
51
|
+
throw error;
|
|
52
|
+
return {};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 云函数获取连接器数据
|
|
57
|
+
*/
|
|
58
|
+
export async function callConnector(param, throwError = false) {
|
|
59
|
+
var _a, _b, _c;
|
|
60
|
+
const { dataSourceName, methodName, params } = param;
|
|
61
|
+
try {
|
|
62
|
+
const res = await ((_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.app) === null || _a === void 0 ? void 0 : _a.cloud) === null || _b === void 0 ? void 0 : _b.callConnector) === null || _c === void 0 ? void 0 : _c.call(_b, {
|
|
43
63
|
dataSourceName,
|
|
44
64
|
methodName,
|
|
65
|
+
params,
|
|
45
66
|
}));
|
|
46
67
|
return res;
|
|
47
68
|
}
|
|
48
69
|
catch (error) {
|
|
49
|
-
console.error('
|
|
70
|
+
console.error('callConnector: ', error);
|
|
71
|
+
if (throwError)
|
|
72
|
+
throw error;
|
|
50
73
|
return {};
|
|
51
74
|
}
|
|
52
75
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/weda-ui",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.4",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index",
|
|
6
6
|
"miniprogram": "mpdist",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"test": "npm run test:jest",
|
|
23
23
|
"test:jest": "jest test --env=jsdom",
|
|
24
24
|
"test:watch": "jest test --env=jsdom --watch",
|
|
25
|
-
"test:e2e": "npx cypress run
|
|
25
|
+
"test:e2e": "npx cypress run --component",
|
|
26
26
|
"test:all": "npm run test && npm run test:e2e",
|
|
27
|
-
"e2e": "npx cypress open
|
|
27
|
+
"e2e": "npx cypress open --component",
|
|
28
28
|
"pretest:all": "rimraf .nyc_output || true",
|
|
29
29
|
"posttest:all": "npm run report:combined",
|
|
30
30
|
"mkdir:reports": "mkdir reports || true",
|
|
@@ -81,69 +81,72 @@
|
|
|
81
81
|
"react": ">=16.8.0"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@babel/preset-env": "^7.
|
|
85
|
-
"@babel/preset-react": "^7.
|
|
86
|
-
"@babel/preset-typescript": "^7.
|
|
87
|
-
"@cloudbase/lowcode-cli": "^0.14.
|
|
84
|
+
"@babel/preset-env": "^7.18.6",
|
|
85
|
+
"@babel/preset-react": "^7.18.6",
|
|
86
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
87
|
+
"@cloudbase/lowcode-cli": "^0.14.4",
|
|
88
88
|
"@commitlint/cli": "^16.0.2",
|
|
89
89
|
"@commitlint/config-conventional": "^17.0.0",
|
|
90
|
-
"@craco/craco": "^
|
|
91
|
-
"@cypress/code-coverage": "^3.
|
|
92
|
-
"@cypress/react": "^
|
|
93
|
-
"@cypress/webpack-dev-server": "~
|
|
90
|
+
"@craco/craco": "^7.0.0-alpha.7",
|
|
91
|
+
"@cypress/code-coverage": "^3.10.0",
|
|
92
|
+
"@cypress/react": "^6.0.0",
|
|
93
|
+
"@cypress/webpack-dev-server": "~2.0.0",
|
|
94
94
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
95
95
|
"@size-limit/preset-big-lib": "^7.0.8",
|
|
96
|
-
"@storybook/addon-actions": "^6.
|
|
97
|
-
"@storybook/addon-essentials": "^6.
|
|
98
|
-
"@storybook/addon-links": "^6.
|
|
99
|
-
"@storybook/addon-storyshots": "^6.
|
|
100
|
-
"@storybook/
|
|
96
|
+
"@storybook/addon-actions": "^6.5.9",
|
|
97
|
+
"@storybook/addon-essentials": "^6.5.9",
|
|
98
|
+
"@storybook/addon-links": "^6.5.9",
|
|
99
|
+
"@storybook/addon-storyshots": "^6.5.9",
|
|
100
|
+
"@storybook/builder-webpack5": "^6.5.9",
|
|
101
|
+
"@storybook/manager-webpack5": "^6.5.9",
|
|
102
|
+
"@storybook/react": "^6.5.9",
|
|
101
103
|
"@swc-node/jest": "^1.5.2",
|
|
102
|
-
"@testing-library/jest-dom": "^5.16.
|
|
103
|
-
"@testing-library/react": "^12.1.
|
|
104
|
-
"@testing-library/react-hooks": "^
|
|
104
|
+
"@testing-library/jest-dom": "^5.16.4",
|
|
105
|
+
"@testing-library/react": "^12.1.5",
|
|
106
|
+
"@testing-library/react-hooks": "^8.0.1",
|
|
105
107
|
"@types/jest": "^27.5.1",
|
|
106
108
|
"@types/resize-observer-browser": "^0.1.7",
|
|
107
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
108
|
-
"@typescript-eslint/parser": "^5.
|
|
109
|
+
"@typescript-eslint/eslint-plugin": "^5.30.5",
|
|
110
|
+
"@typescript-eslint/parser": "^5.30.5",
|
|
109
111
|
"babel-loader": "^8.2.5",
|
|
110
112
|
"babel-plugin-istanbul": "^6.1.1",
|
|
111
113
|
"cross-env": "^7.0.3",
|
|
112
|
-
"cypress": "~
|
|
113
|
-
"eslint": "^8.
|
|
114
|
+
"cypress": "~10.3.0",
|
|
115
|
+
"eslint": "^8.19.0",
|
|
114
116
|
"eslint-config-prettier": "^8.5.0",
|
|
115
117
|
"eslint-config-tencent": "^1.0.4",
|
|
116
|
-
"eslint-import-resolver-typescript": "^2.
|
|
118
|
+
"eslint-import-resolver-typescript": "^3.2.4",
|
|
117
119
|
"eslint-plugin-cypress": "^2.12.1",
|
|
118
120
|
"eslint-plugin-import": "^2.26.0",
|
|
119
|
-
"eslint-plugin-jest": "^26.
|
|
120
|
-
"eslint-plugin-prettier": "^4.
|
|
121
|
-
"eslint-plugin-react": "^7.30.
|
|
121
|
+
"eslint-plugin-jest": "^26.5.3",
|
|
122
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
123
|
+
"eslint-plugin-react": "^7.30.1",
|
|
122
124
|
"eslint-plugin-rulesdir": "^0.2.1",
|
|
125
|
+
"eslint-plugin-storybook": "^0.5.13",
|
|
123
126
|
"husky": "^8.0.1",
|
|
124
127
|
"identity-obj-proxy": "^3.0.0",
|
|
125
128
|
"jest": "^27.5.1",
|
|
126
129
|
"jest-canvas-mock": "^2.4.0",
|
|
127
130
|
"jest-environment-jsdom": "^27",
|
|
128
|
-
"jest-preview": "^0.2.
|
|
131
|
+
"jest-preview": "^0.2.6",
|
|
129
132
|
"miniprogram-simulate": "^1.5.7",
|
|
130
133
|
"nano-staged": "^0.8.0",
|
|
131
134
|
"pinst": "^3.0.0",
|
|
132
|
-
"prettier": "^2.
|
|
135
|
+
"prettier": "^2.7.1",
|
|
133
136
|
"react": "^16",
|
|
134
137
|
"react-dom": "^16",
|
|
135
|
-
"react-scripts": "^
|
|
138
|
+
"react-scripts": "^5.0.1",
|
|
136
139
|
"react-test-renderer": "^16",
|
|
137
140
|
"regenerator-runtime": "^0.13.9",
|
|
138
141
|
"rimraf": "^3.0.2",
|
|
139
142
|
"size-limit": "^7.0.8",
|
|
140
|
-
"swc-loader": "0.
|
|
141
|
-
"swc-plugin-coverage-instrument": "^0.0.
|
|
142
|
-
"ts-loader": "^
|
|
143
|
-
"typescript": "^4.
|
|
143
|
+
"swc-loader": "0.2.3",
|
|
144
|
+
"swc-plugin-coverage-instrument": "^0.0.7",
|
|
145
|
+
"ts-loader": "^9.3.1",
|
|
146
|
+
"typescript": "^4.7.4",
|
|
144
147
|
"webpack": "^5.73.0",
|
|
145
|
-
"webpack-cli": "^4.
|
|
146
|
-
"webpack-dev-server": "^4.9.
|
|
148
|
+
"webpack-cli": "^4.10.0",
|
|
149
|
+
"webpack-dev-server": "^4.9.3",
|
|
147
150
|
"zx": "^5.2.0"
|
|
148
151
|
},
|
|
149
152
|
"nano-staged": {
|