@cloudbase/weda-ui-mp 3.15.1 → 3.15.2

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.
@@ -143,34 +143,36 @@ Component({
143
143
  .select(`#${this.data.canvasId}`)
144
144
  .fields({ node: true, size: true })
145
145
  .exec(async (res) => {
146
- const canvasNode = res[0].node;
147
- this.canvasNode = canvasNode;
146
+ const canvasNode = res[0]?.node;
147
+ if (canvasNode) {
148
+ this.canvasNode = canvasNode;
148
149
 
149
- const canvasDpr = wx.getSystemInfoSync().pixelRatio;
150
- const canvasWidth = res[0].width;
151
- const canvasHeight = res[0].height;
150
+ const canvasDpr = wx.getSystemInfoSync().pixelRatio;
151
+ const canvasWidth = res[0].width;
152
+ const canvasHeight = res[0].height;
152
153
 
153
- const ctx = canvasNode.getContext('2d');
154
+ const ctx = canvasNode.getContext('2d');
154
155
 
155
- const canvas = new WxCanvas(ctx, this.data.canvasId, true, canvasNode);
156
- echarts.setCanvasCreator(() => {
157
- return canvas;
158
- });
159
-
160
- if (typeof callback === 'function') {
161
- this.chart = callback(canvas, canvasWidth, canvasHeight, canvasDpr);
162
- } else if (this.data.ec && typeof this.data.ec.onInit === 'function') {
163
- this.chart = await this.data.ec.onInit(canvas, canvasWidth, canvasHeight, canvasDpr);
164
- } else {
165
- this.triggerEvent('init', {
166
- canvas: canvas,
167
- width: canvasWidth,
168
- height: canvasHeight,
169
- dpr: canvasDpr,
156
+ const canvas = new WxCanvas(ctx, this.data.canvasId, true, canvasNode);
157
+ echarts.setCanvasCreator(() => {
158
+ return canvas;
170
159
  });
171
- }
172
160
 
173
- this.domObserver && this.domObserver.disconnect();
161
+ if (typeof callback === 'function') {
162
+ this.chart = callback(canvas, canvasWidth, canvasHeight, canvasDpr);
163
+ } else if (this.data.ec && typeof this.data.ec.onInit === 'function') {
164
+ this.chart = await this.data.ec.onInit(canvas, canvasWidth, canvasHeight, canvasDpr);
165
+ } else {
166
+ this.triggerEvent('init', {
167
+ canvas: canvas,
168
+ width: canvasWidth,
169
+ height: canvasHeight,
170
+ dpr: canvasDpr,
171
+ });
172
+ }
173
+
174
+ this.domObserver && this.domObserver.disconnect();
175
+ }
174
176
  });
175
177
  },
176
178
  canvasToTempFilePath(opt) {
@@ -127,7 +127,7 @@ Component({
127
127
  });
128
128
  }
129
129
  this.triggerEvent('search', { value });
130
- }, 1000);
130
+ }, 300);
131
131
  this.setData({
132
132
  timeId,
133
133
  });
@@ -181,12 +181,7 @@ Component({
181
181
  observers: {
182
182
  'option,searchValue,staticSearchable': function (option, searchValue, staticSearchable) {
183
183
  const { ignoreCase } = this.properties;
184
- if (searchValue === '') {
185
- this.setData({
186
- showOption: option,
187
- status: option.length > 0 ? 0 : 3,
188
- });
189
- } else if (staticSearchable) {
184
+ if (staticSearchable) {
190
185
  const searchRange = option.filter((item) => {
191
186
  if (ignoreCase) {
192
187
  return String(item.label).toLowerCase().indexOf(searchValue.toLowerCase()) !== -1;
@@ -94,10 +94,6 @@ Component({
94
94
  type: Boolean,
95
95
  value: true,
96
96
  },
97
- staticSearchable: {
98
- type: Boolean,
99
- value: true,
100
- },
101
97
  where: {
102
98
  type: Array,
103
99
  value: [],
@@ -120,6 +116,7 @@ Component({
120
116
  whereEffected: [], // 每次请求都加上
121
117
  fetchTimed: null, // 防抖
122
118
  queryParam: { select: { $master: true } },
119
+ staticSearchable: true,
123
120
  },
124
121
  lifetimes: {
125
122
  attached() {
@@ -143,7 +140,6 @@ Component({
143
140
  // 默认
144
141
  this.setData({
145
142
  option: range,
146
- loadStatus: range.length > 0 ? 0 : -1,
147
143
  value: this.properties.defaultValue,
148
144
  cls,
149
145
  subCls,
@@ -175,6 +171,11 @@ Component({
175
171
  value: this.properties.defaultValue,
176
172
  });
177
173
  },
174
+ format: function (format) {
175
+ this.setData({
176
+ staticSearchable: !['many-many', 'one-many'].includes(format),
177
+ });
178
+ },
178
179
  'value,range': function () {
179
180
  const { range, format } = this.properties;
180
181
  if (format !== 'one-many' && format !== 'many-many') {
@@ -187,6 +188,7 @@ Component({
187
188
  this.setData({
188
189
  option: checkRange,
189
190
  displayLabel: label,
191
+ loadStatus: range.length > 0 ? 0 : -1,
190
192
  });
191
193
  },
192
194
  dataSourceName: function () {
@@ -259,7 +261,7 @@ Component({
259
261
  // eslint-disable-next-line rulesdir/no-timer
260
262
  this.data.fetchTimed = setTimeout(() => {
261
263
  const { format, dataSourceName, primaryField } = this.properties;
262
- if (['many-many', 'one-many'].concat(format) && dataSourceName && primaryField) {
264
+ if (['many-many', 'one-many'].includes(format) && dataSourceName && primaryField) {
263
265
  this.setData({ records: [], option: [], pageNo: 1 });
264
266
  this._fetchData({ searchValue, _init: true });
265
267
  }
@@ -270,6 +272,7 @@ Component({
270
272
  _fetchData: async function ({ queryParam = this.data.queryParam, searchValue = '', pageNo = 1, _init = false }) {
271
273
  const { dataSourceName, primaryField } = this.properties;
272
274
  if (!dataSourceName) return;
275
+ this.setData({ loadStatus: 1 });
273
276
  // 默认筛选条件
274
277
  let _filter = destr(this.data.queryParam.filter) ?? {};
275
278
  // 根据搜索值查询
@@ -304,9 +307,9 @@ Component({
304
307
  finalRecords = this.getUniqueOption(finalRecords);
305
308
  const { value } = this.data;
306
309
 
307
- const unchecked = value.filter((i) => !finalRecords.find((j) => i === j.value));
310
+ const unchecked = value?.filter((i) => !finalRecords.find((j) => i === j.value));
308
311
  // 跨页勾选回显示
309
- if (unchecked.length) {
312
+ if (unchecked?.length) {
310
313
  const uncheckedItem = await this.fetchItem(unchecked);
311
314
  uncheckedItem?.forEach((i) => {
312
315
  if (i) {
@@ -251,7 +251,8 @@ Component({
251
251
  };
252
252
  const uploadPath = 'weda-uploader';
253
253
  const _uploadPath = await getDefaultUploadPath(uploadPath);
254
- const cloudPath = `${_uploadPath}/${randomStr()}-${tempFile.name}`;
254
+ const filenameRegex = /[^a-zA-Z0-9\u4e00-\u9fff-*!_.]/g;
255
+ const cloudPath = `${_uploadPath}/${randomStr()}-${tempFile.name?.replace(filenameRegex, '-')}`;
255
256
  try {
256
257
  const tcb = await getCloudInstance();
257
258
  const uploadTask = await tcb.uploadFile({
@@ -5,6 +5,7 @@ import { commonCompBehavior } from '../../utils/common-behavior';
5
5
  import { callDataSource } from '../../utils/tcb';
6
6
  import isEqual from '../../utils/deepEqual';
7
7
  import { textToString } from '../../utils/platform';
8
+ import { deepClone } from '../../utils/lodash';
8
9
 
9
10
  import { WdCompError } from '../../utils/error';
10
11
  const LISTVIEW_MESSAGE = {
@@ -175,6 +176,7 @@ Component({
175
176
  },
176
177
  },
177
178
  paramRef: [],
179
+ preDataSourceCache: [],
178
180
  },
179
181
  methods: {
180
182
  // 数据列表设置表达式: 区分前后端分页
@@ -185,7 +187,7 @@ Component({
185
187
  let total = 0;
186
188
  if (Array.isArray(dataSourceData)) {
187
189
  if (enableTotal) {
188
- records = dataSourceData;
190
+ records = deepClone(dataSourceData);
189
191
  total = !isNaN(parseInt(`${_total}`)) ? _total : 0;
190
192
  } else {
191
193
  const count = pageSize * pageNo;
@@ -603,7 +605,10 @@ Component({
603
605
  });
604
606
  }, 500);
605
607
  },
606
- 'dataSourceType,dataSourceData,total,enableTotal': function () {
608
+ 'dataSourceType,dataSourceData,total,enableTotal': function (...rest) {
609
+ if (isEqual(this.data.preDataSourceCache, rest)) return;
610
+
611
+ this.setData({ preDataSourceCache: rest });
607
612
  if (this.properties.dataSourceType === 'expression') {
608
613
  // console.log('====dataSourceData====', this.data.dataSourceData);
609
614
  this.setExpression();
@@ -25,6 +25,7 @@ Component({
25
25
  counter: 0,
26
26
  placeholderCls: `${WD_PREFIX}-form-input-wrap__placeholder weui-input__placeholder`,
27
27
  _size: 'md',
28
+ _focus: false,
28
29
  },
29
30
  methods: {
30
31
  handleChange: function (e) {
@@ -32,17 +33,18 @@ Component({
32
33
  this.triggerEvent('change', e.detail);
33
34
  },
34
35
  handleFocus: function (e) {
36
+ this.setData({ _focus: true });
35
37
  this.triggerEvent('focus', e.detail);
36
38
  },
37
39
  handleBlur: function (e) {
40
+ this.setData({ _focus: false });
38
41
  this.triggerEvent('blur', e.detail);
39
42
  },
40
43
  handleConfirm: function (e) {
41
44
  this.triggerEvent('confirm', e.detail);
42
45
  },
43
46
  updateWidgetAPI: function () {
44
- const { name, value, label, required, visible, disabled, readOnly } =
45
- this.data;
47
+ const { name, value, label, required, visible, disabled, readOnly } = this.data;
46
48
  this.setReadonlyAttributes?.({
47
49
  name,
48
50
  value,
@@ -54,7 +56,7 @@ Component({
54
56
  });
55
57
  },
56
58
  init() {
57
- const { disabled, size, classRoot } = this.data;
59
+ const { disabled, size, classRoot, _focus } = this.data;
58
60
  const { classPrefix } = this.data;
59
61
  const _size = convertSize(size);
60
62
  const root = `${classPrefix}-${classRoot}`;
@@ -70,14 +72,15 @@ Component({
70
72
  'size-width-hundred': true,
71
73
  'is-disabled': disabled,
72
74
  'textarea-restriction': true,
73
- }
75
+ 'is-focused': _focus,
76
+ },
74
77
  );
75
78
  const countCls = `${textareaWrap}__label ${root}-${classRoot}__count-text`;
76
79
  this.setData({ cls, countCls, _size });
77
80
  },
78
81
  },
79
82
  observers: {
80
- 'disabled,counterVisible,size,classRoot': function () {
83
+ 'disabled,counterVisible,size,classRoot,_focus': function () {
81
84
  this.init();
82
85
  },
83
86
  value: function (value) {
@@ -87,6 +90,9 @@ Component({
87
90
  'name, value, label, required, visible, disabled, readOnly': function () {
88
91
  this.updateWidgetAPI();
89
92
  },
93
+ focus: function (focus) {
94
+ this.setData({ _focus: focus });
95
+ },
90
96
  },
91
97
  lifetimes: {
92
98
  attached: function () {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "miniprogram": "./",
4
4
  "packageManager": "yarn@3.0.2",
5
5
  "dependencies": {},
6
- "version": "3.15.1",
6
+ "version": "3.15.2",
7
7
  "main": "./",
8
8
  "publishConfig": {
9
9
  "access": "public"