@cloudbase/weda-ui 0.2.15 → 0.2.16

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.
Files changed (112) hide show
  1. package/package.json +10 -7
  2. package/src/configs/components/calendar.json +75 -0
  3. package/src/configs/components/carousel.json +273 -0
  4. package/src/configs/components/chart/statisticsCard.json +331 -0
  5. package/src/configs/components/dataView.json +139 -0
  6. package/src/configs/components/form/location.json +152 -0
  7. package/src/configs/components/form/uploaderFile.json +2 -1
  8. package/src/configs/components/graphicCard.json +399 -0
  9. package/src/configs/components/link.json +2 -2
  10. package/src/configs/components/listView.json +230 -0
  11. package/src/configs/components/navLayout.json +350 -0
  12. package/src/configs/components/swiper.json +3 -3
  13. package/src/configs/index.js +16 -0
  14. package/src/mp/components/button/index.js +12 -13
  15. package/src/mp/components/button/index.wxml +1 -1
  16. package/src/mp/components/calendar/arrowright--line.svg +11 -0
  17. package/src/mp/components/calendar/index.js +238 -0
  18. package/src/mp/components/calendar/index.json +4 -0
  19. package/src/mp/components/calendar/index.wxml +37 -0
  20. package/src/mp/components/calendar/index.wxss +178 -0
  21. package/src/mp/components/carousel/index.js +88 -0
  22. package/src/mp/components/carousel/index.json +7 -0
  23. package/src/mp/components/carousel/index.wxml +6 -0
  24. package/src/mp/components/chart/statisticsCard/index.js +226 -0
  25. package/src/mp/components/chart/statisticsCard/index.json +4 -0
  26. package/src/mp/components/chart/statisticsCard/index.wxml +9 -0
  27. package/src/mp/components/chart/statisticsCard/index.wxss +45 -0
  28. package/src/mp/components/dataView/index.js +34 -0
  29. package/src/mp/components/dataView/index.json +7 -0
  30. package/src/mp/components/dataView/index.wxml +15 -0
  31. package/src/mp/components/dataView/index.wxss +0 -0
  32. package/src/mp/components/form/location/components/mapChoose/index.js +201 -0
  33. package/src/mp/components/form/location/components/mapChoose/index.json +4 -0
  34. package/src/mp/components/form/location/components/mapChoose/index.wxml +42 -0
  35. package/src/mp/components/form/location/components/mapChoose/index.wxss +188 -0
  36. package/src/mp/components/form/location/index.js +341 -0
  37. package/src/mp/components/form/location/index.json +6 -0
  38. package/src/mp/components/form/location/index.wxml +25 -0
  39. package/src/mp/components/form/location/index.wxss +91 -0
  40. package/src/mp/components/form/uploader/index.js +39 -35
  41. package/src/mp/components/form/uploaderFile/index.js +61 -14
  42. package/src/mp/components/graphicCard/chevron-right.svg +3 -0
  43. package/src/mp/components/graphicCard/index.js +205 -0
  44. package/src/mp/components/graphicCard/index.json +4 -0
  45. package/src/mp/components/graphicCard/index.wxml +29 -0
  46. package/src/mp/components/graphicCard/index.wxss +157 -0
  47. package/src/mp/components/image/index.js +0 -1
  48. package/src/mp/components/listView/arrow-right-line.svg +3 -0
  49. package/src/mp/components/listView/index.js +286 -0
  50. package/src/mp/components/listView/index.json +4 -0
  51. package/src/mp/components/listView/index.wxml +40 -0
  52. package/src/mp/components/listView/index.wxss +150 -0
  53. package/src/mp/components/listView/more-line.svg +3 -0
  54. package/src/mp/components/navLayout/index.js +123 -0
  55. package/src/mp/components/navLayout/index.json +7 -0
  56. package/src/mp/components/navLayout/index.wxml +25 -0
  57. package/src/mp/components/navLayout/index.wxss +1193 -0
  58. package/src/mp/components/swiper/index.wxml +2 -0
  59. package/src/mp/index.json +9 -1
  60. package/src/mp/utils/debounce.js +133 -0
  61. package/src/mp/utils/dr_square_point.js +25 -0
  62. package/src/mp/utils/qqmap-wx-jssdk1.2/qqmap-wx-jssdk.js +1336 -0
  63. package/src/mp/utils/spark-md5.js +776 -0
  64. package/src/mp/utils/tcb.js +18 -0
  65. package/src/web/components/calendar/index.css +382 -0
  66. package/src/web/components/calendar/index.jsx +312 -0
  67. package/src/web/components/calendar/util.js +90 -0
  68. package/src/web/components/carousel/index.css +119 -0
  69. package/src/web/components/carousel/index.tsx +417 -0
  70. package/src/web/components/chart/statisticsCard/index.css +62 -0
  71. package/src/web/components/chart/statisticsCard/index.tsx +286 -0
  72. package/src/web/components/chart/statisticsCard/interface.ts +14 -0
  73. package/src/web/components/dataView/index.tsx +20 -0
  74. package/src/web/components/dataView/interface.ts +6 -0
  75. package/src/web/components/form/location/common/mapChoose.css +178 -0
  76. package/src/web/components/form/location/common/mapChoose.jsx +343 -0
  77. package/src/web/components/form/location/common/mapView.jsx +190 -0
  78. package/src/web/components/form/location/common/propsConfig.js +54 -0
  79. package/src/web/components/form/location/common/selectModal.css +44 -0
  80. package/src/web/components/form/location/common/selectModal.jsx +82 -0
  81. package/src/web/components/form/location/common/useLocationInfo.js +100 -0
  82. package/src/web/components/form/location/components/LocationH5/index.css +243 -0
  83. package/src/web/components/form/location/components/LocationH5/location.h5.jsx +403 -0
  84. package/src/web/components/form/location/components/LocationPC/Header.jsx +109 -0
  85. package/src/web/components/form/location/components/LocationPC/index.css +44 -0
  86. package/src/web/components/form/location/components/LocationPC/location.PC.jsx +323 -0
  87. package/src/web/components/form/location/constants.js +4 -0
  88. package/src/web/components/form/location/index.css +0 -0
  89. package/src/web/components/form/location/index.jsx +25 -0
  90. package/src/web/components/form/uploader/uploader.h5.tsx +16 -10
  91. package/src/web/components/form/uploader/uploader.pc.tsx +15 -11
  92. package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +122 -107
  93. package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +22 -19
  94. package/src/web/components/graphicCard/index.css +163 -0
  95. package/src/web/components/graphicCard/index.tsx +309 -0
  96. package/src/web/components/image/image.tsx +0 -1
  97. package/src/web/components/index.js +12 -0
  98. package/src/web/components/listView/arrow-right-line.svg +3 -0
  99. package/src/web/components/listView/index.css +139 -0
  100. package/src/web/components/listView/index.tsx +354 -0
  101. package/src/web/components/listView/interface.ts +98 -0
  102. package/src/web/components/navLayout/index.css +332 -0
  103. package/src/web/components/navLayout/index.tsx +247 -0
  104. package/src/web/components/tabs/index.tsx +2 -2
  105. package/src/web/components/tabs/tabs.h5.tsx +7 -4
  106. package/src/web/components/uploaderFileView/index.css +9 -9
  107. package/src/web/components/uploaderFileView/index.jsx +32 -23
  108. package/src/web/types.d.ts +15 -14
  109. package/src/web/utils/debounce.js +98 -0
  110. package/src/web/utils/platform.js +31 -0
  111. package/src/web/utils/tcb.js +35 -0
  112. package/src/web/utils/tmap.js +4 -0
@@ -0,0 +1,286 @@
1
+ import React, { useState, useRef, useEffect } from 'react';
2
+ import { CommonPropsType } from '../../../types';
3
+ import './index.css';
4
+ import classNames from '../../../utils/classnames';
5
+ import { ConfigProvider } from 'tea-component';
6
+ import { usePlatform } from '../../../utils/platform';
7
+ import { IDataSource, IField } from './interface';
8
+ import { useDeepCompareEffect, useIsMounted } from '@react-hookz/web';
9
+ import { callDataSource, callWedaApi } from '../../../utils/tcb';
10
+
11
+ interface PropsType extends CommonPropsType {
12
+ /**
13
+ * 数据源
14
+ */
15
+ dataSource?: IDataSource;
16
+ /**
17
+ * 数据筛选
18
+ */
19
+ filterData?: any;
20
+ /**
21
+ * 字段
22
+ */
23
+ field?: IField;
24
+ /**
25
+ * 统计方式
26
+ */
27
+ operationType?: string;
28
+ /**
29
+ * 字段展示名称
30
+ */
31
+ label?: string;
32
+ /**
33
+ * 是否统计空值
34
+ */
35
+ isCountEmpty?: boolean;
36
+ /**
37
+ * 是否显示单位
38
+ */
39
+ isShowUnit?: boolean;
40
+ /**
41
+ * 单位
42
+ */
43
+ unit?: number;
44
+ /**
45
+ * 小数位数
46
+ */
47
+ decimalDigits?: number;
48
+ /**
49
+ * 后缀
50
+ */
51
+ suffix?: number;
52
+ /**
53
+ * app.cloud 对象依赖,默认会从 window.app 取值
54
+ */
55
+ appCloud?: { callDataSource?: any; callWedaApi?: any };
56
+ /**
57
+ * 其他属性
58
+ */
59
+ [key: string]: any;
60
+ }
61
+
62
+ const CLASS_PREFIX = 'weda-statistics-card';
63
+ // 默认显示值
64
+ const defaultVal = 1000;
65
+
66
+ /**
67
+ * 修复科学计数法问题
68
+ * @param num 小数
69
+ * @returns {string}
70
+ */
71
+ export function scientificToNumber(num) {
72
+ const str = num;
73
+ const reg = /^([-]?\d+\.?\d*)(e)([-|+]?\d+)$/;
74
+ let zero = '';
75
+ if (!reg.test(str)) {
76
+ return num;
77
+ }
78
+ const arr = reg.exec(str);
79
+ const len = Math.abs(+arr[3]) - 1;
80
+ for (let i = 0; i < len; i += 1) {
81
+ zero += '0';
82
+ }
83
+ if (arr[1].indexOf('-') === 0) {
84
+ return `-0.${zero}${arr[1].replace('-', '').replace('.', '')}`;
85
+ }
86
+ return `0.${zero}${arr[1].replace('.', '')}`;
87
+ }
88
+
89
+ /**
90
+ * 补齐小数位数0
91
+ * @param source 源字符串
92
+ * @param targetLength 目标长度
93
+ * @returns {string}
94
+ */
95
+ export function padEnd(source, targetLength) {
96
+ targetLength = Math.floor(targetLength); //floor if number or convert non-number to 0;
97
+ if (source.length > targetLength) {
98
+ return source;
99
+ } else {
100
+ targetLength = targetLength - source.length;
101
+ return source + '0'.repeat(targetLength);
102
+ }
103
+ }
104
+
105
+ /**
106
+ * 修复toFixed四舍五入不准确问题
107
+ * @param num
108
+ * @param digit 小数位数
109
+ * @returns {string}
110
+ */
111
+ export function customToFixed(num, digit = 0) {
112
+ const pow = Math.pow(10, digit);
113
+ let value = `${num}`;
114
+ // 如果是小数,四舍五入进行转化处理确保精度正确
115
+ if (!Number.isInteger(num)) {
116
+ if (num > 0) {
117
+ value = (Math.round((num + Number.EPSILON) * pow) / pow).toString();
118
+ } else if (num < 0) {
119
+ value = (Math.round((num - Number.EPSILON) * pow) / pow).toString();
120
+ }
121
+ }
122
+ value = scientificToNumber(value);
123
+ const [integer, decimal = ''] = value.split('.');
124
+ if (digit > 0) {
125
+ return `${integer}.${padEnd(decimal, digit)}`;
126
+ }
127
+ return integer;
128
+ }
129
+
130
+ /**
131
+ * 格式化:添加千分符,四舍五入
132
+ * @param val
133
+ * @param digits
134
+ */
135
+ const formatNumber = (val, digits = 0) => {
136
+ return isNaN(val)
137
+ ? val
138
+ : Intl
139
+ ? Intl.NumberFormat('en-US', {
140
+ maximumFractionDigits: 10,
141
+ minimumFractionDigits: digits,
142
+ }).format(+customToFixed(val, digits))
143
+ : val;
144
+ };
145
+
146
+ export default function StatisticsCard({
147
+ dataSource,
148
+ filterData,
149
+ field,
150
+ operationType,
151
+ label,
152
+ isCountEmpty,
153
+ isShowUnit,
154
+ unit,
155
+ decimalDigits,
156
+ suffix,
157
+ className,
158
+ style,
159
+ events,
160
+ id,
161
+ role,
162
+ appCloud = { callDataSource, callWedaApi },
163
+ }: PropsType) {
164
+ const [val, setVal] = useState(defaultVal);
165
+ const isMounted = useIsMounted();
166
+
167
+ async function getSourceData(
168
+ dataSource,
169
+ filterData,
170
+ field,
171
+ operationType,
172
+ isCountEmpty
173
+ ) {
174
+ const where = filterData?.map
175
+ ? filterData.map((val) => {
176
+ let arrLogicData = val.logicData;
177
+ if (val.logicData && val.logicData.length > 0) {
178
+ arrLogicData = val.logicData.map((mval) => {
179
+ return {
180
+ Key: mval.key,
181
+ Rel: mval.rel,
182
+ Value: mval.value,
183
+ Logic: mval.logic,
184
+ };
185
+ });
186
+ }
187
+ return {
188
+ GroupLogic: val.groupLogic,
189
+ LogicData: arrLogicData,
190
+ };
191
+ })
192
+ : [];
193
+ const params = {
194
+ dataSourceName: dataSource?.name,
195
+ where,
196
+ value: [
197
+ {
198
+ Key: field?.name,
199
+ OperationType: operationType,
200
+ IsCountEmpty: isCountEmpty,
201
+ },
202
+ ],
203
+ };
204
+ try {
205
+ if (dataSource?.type === 'database') {
206
+ return await appCloud?.callWedaApi({
207
+ action: 'DescribeChartCardData',
208
+ data: params,
209
+ });
210
+ }
211
+ return await appCloud?.callDataSource({
212
+ dataSourceName: dataSource?.name,
213
+ methodName: dataSource?.methodName,
214
+ });
215
+ } catch {
216
+ return [];
217
+ }
218
+ }
219
+
220
+ const initCard = async () => {
221
+ // 内部数据源需要字段和统计方式,外部数据源不需要
222
+ if (
223
+ (dataSource?.type === 'database' && field && operationType) ||
224
+ (dataSource && dataSource?.type !== 'database')
225
+ ) {
226
+ let data = await getSourceData(
227
+ dataSource,
228
+ filterData,
229
+ field,
230
+ operationType,
231
+ isCountEmpty
232
+ );
233
+ // 自定义连接器 返回处理
234
+ if (dataSource?.type !== 'database' && data?.result) {
235
+ data = data?.result;
236
+ }
237
+ if (data?.length) {
238
+ const val = isNaN(data[0]?.Value) ? 0 : data[0]?.Value;
239
+ isMounted && setVal(val);
240
+ } else {
241
+ // 返回数据为空 使用 0
242
+ isMounted && setVal(0);
243
+ }
244
+ } else {
245
+ // 没有配置数据使用默认数据
246
+ isMounted && setVal(defaultVal);
247
+ }
248
+ };
249
+
250
+ useDeepCompareEffect(() => {
251
+ initCard();
252
+ }, [dataSource, filterData, field, operationType, isCountEmpty]);
253
+
254
+ const platform = usePlatform();
255
+ const cls = classNames({
256
+ 'weda-ui': true,
257
+ [CLASS_PREFIX]: true,
258
+ [className]: className,
259
+ [`${CLASS_PREFIX}-mobile`]: platform === 'h5',
260
+ [`${CLASS_PREFIX}-pc`]: platform !== 'h5',
261
+ });
262
+
263
+ return (
264
+ <ConfigProvider classPrefix="wedatea2td">
265
+ <div
266
+ id={id}
267
+ role={role}
268
+ className={cls}
269
+ style={style}
270
+ onClick={(e) => events.tap({}, { originEvent: e })}
271
+ >
272
+ <div className={`${CLASS_PREFIX}__wrapper`}>
273
+ <div className={`${CLASS_PREFIX}__title`}>{label}</div>
274
+ <div className={`${CLASS_PREFIX}__detail`}>
275
+ <div className={`${CLASS_PREFIX}__count`}>
276
+ {isShowUnit ? formatNumber(val / unit, decimalDigits) : val}
277
+ {isShowUnit && (
278
+ <label className={`${CLASS_PREFIX}__unit`}>{suffix}</label>
279
+ )}
280
+ </div>
281
+ </div>
282
+ </div>
283
+ </div>
284
+ </ConfigProvider>
285
+ );
286
+ }
@@ -0,0 +1,14 @@
1
+ export interface IDataSource {
2
+ name: string; // 数据源名
3
+ type: string; // 数据源类型
4
+ subType: string; // 数据源子类型
5
+ provider?: string; // 内置连接器类型
6
+ methodName: string; // 数据源方法名
7
+ }
8
+
9
+ export interface IField {
10
+ format: string;
11
+ type: string;
12
+ title: string;
13
+ name: string;
14
+ }
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { IDataView } from './interface';
3
+ import ListView from '../listView';
4
+
5
+ /**
6
+ * 数据容器-列表视图
7
+ */
8
+ export default function DataView(props: IDataView) {
9
+ return (
10
+ <ListView
11
+ {...props}
12
+ orderBy={undefined}
13
+ orderType={undefined}
14
+ template="none"
15
+ pageSize={1}
16
+ pagination="none"
17
+ beforeDataChange={(values) => values?.[0]}
18
+ />
19
+ );
20
+ }
@@ -0,0 +1,6 @@
1
+ import { IDataContainer } from '../listView/interface';
2
+
3
+ /**
4
+ * 数据容器-数据视图
5
+ */
6
+ export interface IDataView extends IDataContainer {}
@@ -0,0 +1,178 @@
1
+ /* mapChoose组件 */
2
+ .weda-ui_map-choose {
3
+ width: 100%;
4
+ height: 100%;
5
+ }
6
+ .map-choose-pc {
7
+ display: flex;
8
+ }
9
+ .map-choose-pc-left {
10
+ width: 45%;
11
+ position: relative;
12
+ }
13
+ .map-choose-pc-right {
14
+ width: 55%;
15
+ }
16
+ .map-choose-header {
17
+ width: 100%;
18
+ padding: 8px 15px;
19
+ position: relative;
20
+ border-bottom: 1px solid #d3d3d3;
21
+ }
22
+ .map-choose-header_focus {
23
+ padding-right: 60px;
24
+ }
25
+ .map-choose-header_focus .map-choose-header_search_cancel {
26
+ display: block;
27
+ }
28
+ .map-choose-header_focus .map-choose-header_search_place {
29
+ left: 10px;
30
+ transform: translate(0, 0);
31
+ }
32
+ .map-choose-header_search {
33
+ height: 30px;
34
+ background-color: #ebebeb;
35
+ padding-left: 10px;
36
+ padding-right: 10px;
37
+ color: #b4b4b4;
38
+ font-size: 15px;
39
+ line-height: 31px;
40
+ border-radius: 5px;
41
+ overflow: hidden;
42
+ white-space: nowrap;
43
+ text-overflow: ellipsis;
44
+ position: relative;
45
+ }
46
+ .map-choose-header_search_place {
47
+ position: absolute;
48
+ top: 0;
49
+ left: 50%;
50
+ display: flex;
51
+ align-items: center;
52
+ transform: translate(-50%, 0);
53
+ }
54
+ .map-choose-header_search_cancel {
55
+ position: absolute;
56
+ top: 0;
57
+ right: 0;
58
+ width: 55px;
59
+ height: 46px;
60
+ line-height: 46px;
61
+ text-align: center;
62
+ font-size: 16px;
63
+ color: #0079ff;
64
+ background-color: #fff;
65
+ cursor: pointer;
66
+ display: none;
67
+ }
68
+ .map-choose-header_search img {
69
+ width: 16px;
70
+ height: 16px;
71
+ margin-right: 4px;
72
+ }
73
+ .map-choose-header_search input {
74
+ display: block;
75
+ width: 100%;
76
+ padding-top: 6px;
77
+ padding-bottom: 6px;
78
+ border: 0;
79
+ font-size: 14px;
80
+ line-height: 18px;
81
+ background: 0 0;
82
+ position: relative;
83
+ z-index: 1;
84
+ }
85
+
86
+ .map-choose-con {
87
+ width: 100%;
88
+ height: calc(100% - 50px);
89
+ position: relative;
90
+ }
91
+ .map-choose-warp,
92
+ .map-choose-explore {
93
+ width: 100%;
94
+ height: 100%;
95
+ }
96
+ .map-choose-explore-pc {
97
+ height: calc(100% - 47px);
98
+ }
99
+ .map-choose-explore {
100
+ display: none;
101
+ }
102
+ .map-choose-explore_show {
103
+ display: block;
104
+ position: absolute;
105
+ z-index: 1000;
106
+ top: 0;
107
+ left: 0;
108
+ background-color: #fff;
109
+ overflow: hidden;
110
+ }
111
+ .map-choose-explore_show-pc {
112
+ top: 47px;
113
+ }
114
+
115
+ .map-choose-warp_sugges {
116
+ height: 55%;
117
+ width: 100%;
118
+ }
119
+ .map-choose-warp_sugges-pc {
120
+ height: calc(100% - 47px);
121
+ width: 100%;
122
+ }
123
+ .map-choose-warp_sugges ul,
124
+ .map-choose-explore_show ul {
125
+ width: 100%;
126
+ height: 100%;
127
+ padding: 0;
128
+ overflow: scroll;
129
+ overflow-x: hidden;
130
+ }
131
+ .map-choose-warp_sugges li,
132
+ .map-choose-explore_show li {
133
+ width: 100%;
134
+ height: 59px;
135
+ padding-top: 6px;
136
+ position: relative;
137
+ border-bottom: 1px solid #d3d3d3;
138
+ cursor: pointer;
139
+ position: relative;
140
+ }
141
+ .map-choose-warp_sugges li span {
142
+ display: none;
143
+ }
144
+ .map-choose-warp_sugges_choosed span {
145
+ position: absolute;
146
+ right: 20px;
147
+ top: 50%;
148
+ transform: translate(0, -50%);
149
+ width: 16px;
150
+ height: 16px;
151
+ display: block !important;
152
+ background-image: url('https://qcloudimg.tencent-cloud.cn/raw/354c15c0cb845120ac3e9c474e6737b3.png');
153
+ background-size: 100% 100%;
154
+ background-repeat: no-repeat;
155
+ }
156
+ .map-choose-warp_sugges li div,
157
+ .map-choose-explore_show li div {
158
+ text-overflow: ellipsis;
159
+ white-space: nowrap;
160
+ overflow: hidden;
161
+ width: 98%;
162
+ }
163
+ .map-choose-warp_sugges_title,
164
+ .map-choose-explore_title {
165
+ font-size: 14px;
166
+ line-height: 27px;
167
+ color: #333;
168
+ font-weight: 400;
169
+ display: block;
170
+ }
171
+
172
+ .map-choose-explore_show_inSearch {
173
+ display: none;
174
+ }
175
+ .map-choose-explore_show-h5 {
176
+ height: auto;
177
+ min-height: 75vh;
178
+ }