@cloudbase/weda-ui 3.26.1 → 3.27.0
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/chart/statisticsCard.d.ts +83 -0
- package/dist/configs/components/chart/statisticsCard.js +365 -0
- package/dist/configs/components/slot.json +2 -6
- package/dist/configs/components/wd-drawer.d.ts +1 -1
- package/dist/configs/components/wd-drawer.js +1 -1
- package/dist/configs/components/wd-modal.d.ts +1 -1
- package/dist/configs/components/wd-modal.js +1 -1
- package/dist/configs/components/wd-tabbar.d.ts +1 -1
- package/dist/configs/components/wd-tabbar.js +1 -1
- package/dist/configs/components/wd-table.js +5 -1
- package/dist/configs/index.d.ts +159 -629
- package/dist/configs/index.js +1 -1
- package/dist/configs/type-utils/type-form.js +1 -1
- package/dist/style/weda-ui.min.css +3 -3
- package/dist/web/components/chart/common/core/eChartBar.js +1 -1
- package/dist/web/components/chart/common/core/eChartLine.js +1 -1
- package/dist/web/components/chart/common/data-transform.js +9 -18
- package/dist/web/components/chart/statisticsCard/index.d.ts +3 -3
- package/dist/web/components/chart/statisticsCard/index.js +9 -4
- package/dist/web/components/form/uploader/index.d.ts +1 -0
- package/dist/web/components/wd-modal/wd-modal.js +2 -4
- package/dist/web/components/wd-upload-image/wd-upload-image.d.ts +1 -0
- package/dist/web/components/wd-upload-image/wd-upload-image.js +2 -2
- package/i18n/source/en.json +2947 -0
- package/i18n/source/zh.json +2947 -0
- package/package.json +9 -5
- package/dist/configs/components/chart/statisticsCard.json +0 -473
|
@@ -115,7 +115,7 @@ class EchartBar extends EchartBase {
|
|
|
115
115
|
if (this.config.series.length > 0 && setColor && setColor.length > 0) {
|
|
116
116
|
let i = 0;
|
|
117
117
|
this.config.series.forEach((itemSeries) => {
|
|
118
|
-
itemSeries.itemStyle.color = setColor[i %
|
|
118
|
+
itemSeries.itemStyle.color = setColor[i % ((setColor === null || setColor === void 0 ? void 0 : setColor.length) || 1)];
|
|
119
119
|
i = i + 1;
|
|
120
120
|
});
|
|
121
121
|
}
|
|
@@ -114,7 +114,7 @@ class EchartLine extends EchartBase {
|
|
|
114
114
|
if (this.config.series.length > 0 && setColor && setColor.length > 0) {
|
|
115
115
|
let i = 0;
|
|
116
116
|
this.config.series.forEach((itemSeries) => {
|
|
117
|
-
lodashSet(itemSeries, 'itemStyle.color', setColor[i %
|
|
117
|
+
lodashSet(itemSeries, 'itemStyle.color', setColor[i % ((setColor === null || setColor === void 0 ? void 0 : setColor.length) || 1)]);
|
|
118
118
|
i = i + 1;
|
|
119
119
|
});
|
|
120
120
|
}
|
|
@@ -4,8 +4,7 @@ import lodashSet from 'lodash.set';
|
|
|
4
4
|
import { isNil } from '../../../utils/lodash';
|
|
5
5
|
export const checkIsNewData = (props) => {
|
|
6
6
|
var _a, _b;
|
|
7
|
-
return
|
|
8
|
-
Object.keys((_b = props['dataModel']) !== null && _b !== void 0 ? _b : {}).length > 0);
|
|
7
|
+
return Object.keys((_a = props.dataSource) !== null && _a !== void 0 ? _a : {}).length === 0 && Object.keys((_b = props['dataModel']) !== null && _b !== void 0 ? _b : {}).length > 0;
|
|
9
8
|
};
|
|
10
9
|
const logger = debug('chart:transform');
|
|
11
10
|
export function transform(chartType, dataInput, chartInput) {
|
|
@@ -53,7 +52,7 @@ export function transform(chartType, dataInput, chartInput) {
|
|
|
53
52
|
// 是否显示空值
|
|
54
53
|
const finalDataInput = (_a = (dataInput !== null && dataInput !== void 0 ? dataInput : [])) === null || _a === void 0 ? void 0 : _a.filter((item) => {
|
|
55
54
|
if (!chartInput.xIsCountEmpty) {
|
|
56
|
-
return
|
|
55
|
+
return item.XLabel['Value'] !== undefined && item.XLabel['Value'] !== null;
|
|
57
56
|
}
|
|
58
57
|
return true;
|
|
59
58
|
});
|
|
@@ -86,13 +85,11 @@ export function transform(chartType, dataInput, chartInput) {
|
|
|
86
85
|
if (groups.length <= 0) {
|
|
87
86
|
finalDataInput.forEach((item) => {
|
|
88
87
|
item.YLabels.forEach((eachYaxis, idx) => {
|
|
89
|
-
var _a, _b, _c;
|
|
88
|
+
var _a, _b, _c, _d;
|
|
90
89
|
if (!series[idx]) {
|
|
91
90
|
series[idx] = {
|
|
92
91
|
type: chartType,
|
|
93
|
-
name: chartType === 'pie'
|
|
94
|
-
? undefined
|
|
95
|
-
: (_a = eachYaxis.Cn_Name) !== null && _a !== void 0 ? _a : eachYaxis.Name,
|
|
92
|
+
name: chartType === 'pie' ? undefined : (_a = eachYaxis.Cn_Name) !== null && _a !== void 0 ? _a : eachYaxis.Name,
|
|
96
93
|
stack: chartInput.isPile ? 'pile' : undefined,
|
|
97
94
|
showSymbol: chartType === 'pie' ? undefined : chartInput.isSeriesShowSymbol,
|
|
98
95
|
label: {
|
|
@@ -101,7 +98,7 @@ export function transform(chartType, dataInput, chartInput) {
|
|
|
101
98
|
itemStyle: chartType === 'pie'
|
|
102
99
|
? undefined
|
|
103
100
|
: {
|
|
104
|
-
color: (
|
|
101
|
+
color: (_d = (_b = chartInput === null || chartInput === void 0 ? void 0 : chartInput.setColor) === null || _b === void 0 ? void 0 : _b[idx % (((_c = chartInput === null || chartInput === void 0 ? void 0 : chartInput.setColor) === null || _c === void 0 ? void 0 : _c.length) || 1)]) !== null && _d !== void 0 ? _d : null,
|
|
105
102
|
},
|
|
106
103
|
data: chartType === 'pie'
|
|
107
104
|
? [
|
|
@@ -111,10 +108,7 @@ export function transform(chartType, dataInput, chartInput) {
|
|
|
111
108
|
},
|
|
112
109
|
]
|
|
113
110
|
: [eachYaxis.Value],
|
|
114
|
-
...(chartType === 'line' &&
|
|
115
|
-
(chartInput === null || chartInput === void 0 ? void 0 : chartInput.chartType) === 'bight'
|
|
116
|
-
? { smooth: true }
|
|
117
|
-
: {}),
|
|
111
|
+
...(chartType === 'line' && (chartInput === null || chartInput === void 0 ? void 0 : chartInput.chartType) === 'bight' ? { smooth: true } : {}),
|
|
118
112
|
};
|
|
119
113
|
if (chartInput.isUnit || chartInput.isPercent) {
|
|
120
114
|
series[idx].label.formatter = formatter;
|
|
@@ -153,7 +147,7 @@ export function transform(chartType, dataInput, chartInput) {
|
|
|
153
147
|
else {
|
|
154
148
|
// 先给每个分组留位置
|
|
155
149
|
groups.forEach((groupName, idx) => {
|
|
156
|
-
var _a, _b;
|
|
150
|
+
var _a, _b, _c;
|
|
157
151
|
series.push({
|
|
158
152
|
type: chartType,
|
|
159
153
|
name: groupName,
|
|
@@ -165,13 +159,10 @@ export function transform(chartType, dataInput, chartInput) {
|
|
|
165
159
|
itemStyle: chartType === 'pie'
|
|
166
160
|
? undefined
|
|
167
161
|
: {
|
|
168
|
-
color: (
|
|
162
|
+
color: (_c = (_a = chartInput === null || chartInput === void 0 ? void 0 : chartInput.setColor) === null || _a === void 0 ? void 0 : _a[idx % (((_b = chartInput === null || chartInput === void 0 ? void 0 : chartInput.setColor) === null || _b === void 0 ? void 0 : _b.length) || 1)]) !== null && _c !== void 0 ? _c : null,
|
|
169
163
|
},
|
|
170
164
|
data: [],
|
|
171
|
-
...(chartType === 'line' &&
|
|
172
|
-
(chartInput === null || chartInput === void 0 ? void 0 : chartInput.chartType) === 'bight'
|
|
173
|
-
? { smooth: true }
|
|
174
|
-
: {}),
|
|
165
|
+
...(chartType === 'line' && (chartInput === null || chartInput === void 0 ? void 0 : chartInput.chartType) === 'bight' ? { smooth: true } : {}),
|
|
175
166
|
});
|
|
176
167
|
});
|
|
177
168
|
// 然后再往data里放东西
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import type { CommonPropsType } from '../../../types';
|
|
3
3
|
import { IDataSource, IField } from './interface';
|
|
4
4
|
import './style';
|
|
@@ -81,5 +81,5 @@ export declare function customToFixed(num: any, digit?: number): string;
|
|
|
81
81
|
* @param digit
|
|
82
82
|
*/
|
|
83
83
|
export declare function addDelimiter(fixedString: any, digit: any): string;
|
|
84
|
-
|
|
85
|
-
export
|
|
84
|
+
declare const _default: React.ForwardRefExoticComponent<Pick<PropsType, keyof PropsType> & React.RefAttributes<unknown>>;
|
|
85
|
+
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useRef } from 'react';
|
|
2
|
+
import { useState, useRef, forwardRef, useMemo } from 'react';
|
|
3
3
|
import classNames from '../../../utils/classnames';
|
|
4
4
|
import { ConfigProvider } from 'tea-component';
|
|
5
5
|
import { usePlatform } from '../../../utils/platform';
|
|
@@ -7,6 +7,7 @@ import { useDeepCompareEffect, useIsMounted } from '@react-hookz/web';
|
|
|
7
7
|
import { callDataSource, callWedaApi } from '../../../utils/tcb';
|
|
8
8
|
import { getUuid } from '../../../utils/tool';
|
|
9
9
|
import { errorHandler } from '../../../utils/error';
|
|
10
|
+
import { useSetWidgetApi } from '../../../utils/widget-api/use-set-widget-api';
|
|
10
11
|
import './style';
|
|
11
12
|
const CLASS_PREFIX = 'weda-statistics-card';
|
|
12
13
|
// 默认显示值
|
|
@@ -110,7 +111,7 @@ const formatNumber = (val, digits = 0) => {
|
|
|
110
111
|
return isNaN(val) ? val : addDelimiter(customToFixed(val, digits), digits);
|
|
111
112
|
};
|
|
112
113
|
const defaultAppCloud = { callDataSource, callWedaApi };
|
|
113
|
-
export default function StatisticsCard({ dataSource, filterData, field, operationType, label, isCountEmpty, isShowUnit, unit, decimalDigits, suffix, className, style, events, id, role, appCloud = defaultAppCloud, }) {
|
|
114
|
+
export default forwardRef(function StatisticsCard({ dataSource, filterData, field, operationType, label, isCountEmpty, isShowUnit, unit, decimalDigits, suffix, className, style, events, id, role, appCloud = defaultAppCloud, }, ref) {
|
|
114
115
|
const [val, setVal] = useState(defaultVal);
|
|
115
116
|
const delayRef = useRef({ version: null });
|
|
116
117
|
const isMounted = useIsMounted();
|
|
@@ -208,5 +209,9 @@ export default function StatisticsCard({ dataSource, filterData, field, operatio
|
|
|
208
209
|
[`${CLASS_PREFIX}-mobile`]: platform === 'h5',
|
|
209
210
|
[`${CLASS_PREFIX}-pc`]: platform !== 'h5',
|
|
210
211
|
});
|
|
211
|
-
|
|
212
|
-
|
|
212
|
+
const calculatedValue = useMemo(() => {
|
|
213
|
+
return formatNumber(val / unit, decimalDigits);
|
|
214
|
+
}, [val, unit, decimalDigits]);
|
|
215
|
+
useSetWidgetApi(() => ({ calculatedValue, value: val, unit, label }), [calculatedValue, val, unit, label], ref);
|
|
216
|
+
return (_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: _jsx("div", { id: id, role: role, className: cls, style: style, onClick: (e) => events.tap({}, { originEvent: e }), children: _jsxs("div", { className: `${CLASS_PREFIX}__wrapper`, children: [_jsx("div", { className: `${CLASS_PREFIX}__title`, children: label }), _jsx("div", { className: `${CLASS_PREFIX}__detail`, children: _jsxs("div", { className: `${CLASS_PREFIX}__count`, children: [isShowUnit ? calculatedValue : val, isShowUnit && _jsx("label", { className: `${CLASS_PREFIX}__unit`, children: suffix })] }) })] }) }) }));
|
|
217
|
+
});
|
|
@@ -6,6 +6,7 @@ type UploaderProps = (H5UploaderProps | PcUploaderProps) & {
|
|
|
6
6
|
showShape?: string;
|
|
7
7
|
showType?: string;
|
|
8
8
|
setUploadHandle?: (uploadHandle?: any) => void;
|
|
9
|
+
popupContainer?: HTMLElement;
|
|
9
10
|
};
|
|
10
11
|
export default function Uploader(props: UploaderProps): JSX.Element;
|
|
11
12
|
export {};
|
|
@@ -138,11 +138,9 @@ export const WdModal = forwardRef(function WdModal(props, ref) {
|
|
|
138
138
|
}
|
|
139
139
|
}, children: _jsxs("div", { style: { ...styleList, ...style }, className: classNames(modalBdClasses), onClick: (e) => {
|
|
140
140
|
e.stopPropagation();
|
|
141
|
-
}, children: [
|
|
141
|
+
}, children: [_jsx("div", { className: `${classPrefix}-modal-bd__hd`, style: headerFooterStlye, children: props.headerSlot }), _jsx("div", { className: `${classPrefix}-modal-bd__main`, children: props.contentSlot }), _jsx("div", { className: `${classPrefix}-modal-bd__ft ${['confirm', 'notice'].includes(props.template) && platform === 'h5'
|
|
142
142
|
? `${classPrefix}-modal-bd__ft-text-btn`
|
|
143
|
-
: ''} ${props.template === 'notice' && platform === 'h5'
|
|
144
|
-
? `${classPrefix}-modal-bd__ft-text-btn--vertical`
|
|
145
|
-
: ''}`, style: headerFooterStlye, children: props.footerSlot }))] }) })] }));
|
|
143
|
+
: ''} ${props.template === 'notice' && platform === 'h5' ? `${classPrefix}-modal-bd__ft-text-btn--vertical` : ''}`, style: headerFooterStlye, children: props.footerSlot })] }) })] }));
|
|
146
144
|
};
|
|
147
145
|
return (_jsx("div", { id: id, className: classNames(classes, className), style: { display: (style === null || style === void 0 ? void 0 : style.display) || 'block' }, "data-testid": "wd-modal-test", children: maskPreToShow && renderNode() }));
|
|
148
146
|
});
|
|
@@ -15,7 +15,7 @@ import { Upload } from '../form/uploader/upload/index';
|
|
|
15
15
|
export const WdUploadImage = forwardRef(function WdUploadImage(props, ref) {
|
|
16
16
|
const { classRoot = 'upload-image', showShape = X_RUNTIME_DEFAULT.showShape, acceptTypes = X_RUNTIME_DEFAULT.acceptTypes, maxSize = X_RUNTIME_DEFAULT.maxSize, single = X_RUNTIME_DEFAULT.single, maxUploadCount = X_RUNTIME_DEFAULT.maxUploadCount, events = emptyObject, isCompressBeforeUpload = false,
|
|
17
17
|
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
18
|
-
compressQuality = 70, compressedHeight = 0, compressedWidth = 0, sourceType = 'both', tips, callbacks, template = 'normal', children, storageType = 'cloudID', } = props;
|
|
18
|
+
compressQuality = 70, compressedHeight = 0, compressedWidth = 0, sourceType = 'both', tips, callbacks, template = 'normal', children, storageType = 'cloudID', popupContainer, } = props;
|
|
19
19
|
// 强制转换初始值
|
|
20
20
|
const initRef = useRef(false);
|
|
21
21
|
const uploadRef = useRef(null);
|
|
@@ -44,5 +44,5 @@ export const WdUploadImage = forwardRef(function WdUploadImage(props, ref) {
|
|
|
44
44
|
const multiple = !single;
|
|
45
45
|
if (!visible)
|
|
46
46
|
return null;
|
|
47
|
-
return (_jsx(WdFormItem, { ...formItemProps, children: template === 'custom' ? (_jsx(Upload, { events: events, acceptTypes: acceptTypes, maxSize: maxSize, maxUploadCount: maxUploadCount, readOnly: readOnly, disabled: disabled, isCompressBeforeUpload: isCompressBeforeUpload, compressQuality: compressQuality, compressedHeight: compressedHeight, compressedWidth: compressedWidth, callbacks: callbacks, value: value, multiple: multiple, sourceType: sourceType, onChange: onChange, ref: uploadRef, setUploadHandle: setUploadHandle, storageType: storageType, children: children })) : (_jsx(Uploader, { events: events, labelVisible: false, acceptTypes: acceptTypes, defaultValue: value, maxSize: maxSize, maxUploadCount: maxUploadCount, single: single, tips: tips, showShape: showShape, readOnly: readOnly, disabled: disabled, decorator: null, onChange: onChange, isCompressBeforeUpload: isCompressBeforeUpload, compressQuality: compressQuality, compressedHeight: compressedHeight, compressedWidth: compressedWidth, sourceType: sourceType, callbacks: callbacks, setUploadHandle: setUploadHandle, storageType: storageType })) }));
|
|
47
|
+
return (_jsx(WdFormItem, { ...formItemProps, children: template === 'custom' ? (_jsx(Upload, { events: events, acceptTypes: acceptTypes, maxSize: maxSize, maxUploadCount: maxUploadCount, readOnly: readOnly, disabled: disabled, isCompressBeforeUpload: isCompressBeforeUpload, compressQuality: compressQuality, compressedHeight: compressedHeight, compressedWidth: compressedWidth, callbacks: callbacks, value: value, multiple: multiple, sourceType: sourceType, onChange: onChange, ref: uploadRef, setUploadHandle: setUploadHandle, storageType: storageType, children: children })) : (_jsx(Uploader, { events: events, labelVisible: false, acceptTypes: acceptTypes, defaultValue: value, maxSize: maxSize, maxUploadCount: maxUploadCount, single: single, tips: tips, showShape: showShape, readOnly: readOnly, disabled: disabled, decorator: null, onChange: onChange, isCompressBeforeUpload: isCompressBeforeUpload, compressQuality: compressQuality, compressedHeight: compressedHeight, compressedWidth: compressedWidth, sourceType: sourceType, callbacks: callbacks, setUploadHandle: setUploadHandle, storageType: storageType, popupContainer: popupContainer })) }));
|
|
48
48
|
});
|