@cloudbase/weda-ui-mp 3.15.8 → 3.17.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.
Files changed (29) hide show
  1. package/components/chart/ec-canvas/ec-canvas.js +1 -25
  2. package/components/form/select/dropdown-select/index.js +8 -0
  3. package/components/form/select/dropdown-select/index.wxml +1 -1
  4. package/components/form/selectMultiple/dropdown-select/index.js +15 -17
  5. package/components/form/selectMultiple/dropdown-select/index.wxml +1 -1
  6. package/components/form/selectMultiple/index.js +29 -7
  7. package/components/form/selectMultiple/index.wxml +2 -1
  8. package/components/form/uploaderFile/index.js +23 -220
  9. package/components/form/uploaderFile/upload.js +283 -0
  10. package/components/richText/copy/index.wxss +45 -48
  11. package/components/wd-ad/index.js +101 -5
  12. package/components/wd-ad/index.wxml +2 -0
  13. package/components/wd-select/index.js +18 -14
  14. package/components/wd-select/index.wxml +7 -3
  15. package/components/wd-select/select/dropdown-select/index.js +192 -0
  16. package/components/wd-select/select/dropdown-select/index.json +4 -0
  17. package/components/wd-select/select/dropdown-select/index.wxml +37 -0
  18. package/components/wd-select/select/dropdown-select/index.wxss +329 -0
  19. package/components/wd-select/select/formats-util.js +12 -1
  20. package/components/wd-select/select/index.js +208 -344
  21. package/components/wd-select/select/index.json +1 -1
  22. package/components/wd-select/select/index.wxml +16 -16
  23. package/components/wd-select-multiple/index.js +16 -8
  24. package/components/wd-select-multiple/index.json +1 -1
  25. package/components/wd-select-multiple/index.wxml +6 -2
  26. package/components/wd-upload-image/index.js +148 -4
  27. package/components/wd-upload-image/index.wxml +5 -0
  28. package/package.json +1 -1
  29. package/utils/platform.js +27 -8
@@ -1,25 +1,25 @@
1
1
  <wd-form-item-read-only version="{{version}}" readOnly="{{readOnly}}" readValue="{{displayValue}}">
2
2
  <view class="wd-select">
3
- <view class="wd-select-input-group" bindchange="onChange" bindtap="onSelectPicker" data-show="true">
3
+ <view class="wd-select-input-group" bindchange="onChange" bindtap="onOpenPicker" data-show="true">
4
4
  <label class="wd-select-input {{displayValue ? '' : 'weui-input__placeholder'}}">{{displayValue || placeholder}}</label>
5
5
  </view>
6
6
  <block wx:if="{{allPickerShow}}">
7
7
  <dropdownSelect
8
- ignoreCase="{{ignoreCase}}"
9
- staticSearchable="{{staticSearchable}}"
10
- class="weui-picker__group weui-input"
11
- bindchange="onChange"
12
- bind:_childFetchData="_childFetchData"
13
- bind:onSelectPicker="onSelectPicker"
14
- option="{{option}}"
15
- loadStatus="{{loadStatus}}"
16
- searchOption="{{searchOption}}"
17
- searchStatus="{{searchStatus}}"
18
- chooseIndexValue="{{chooseIndexValue}}"
19
- isTurnPages="{{isTurnPages}}"
20
- pageNo="{{pageNo}}"
21
- _needFetch="{{formatNeedFetch}}"
22
- bind:search="onSearch"
8
+ multiple="{{multiple}}"
9
+ searchable="{{searchable}}"
10
+ filterable="{{_filterable}}"
11
+ currentPageNo="{{currentPageNo}}"
12
+ class="weui-picker__group weui-input"
13
+ bindchange="onChange"
14
+ bind:_childFetchData="_childFetchData"
15
+ bind:onSelectPicker="onSelectPicker"
16
+ bind:onClosePicker="onClosePicker"
17
+ option="{{option}}"
18
+ loadStatus="{{loadStatus}}"
19
+ searchStatus="{{searchStatus}}"
20
+ selectedValue="{{value}}"
21
+ ignoreCase="{{ignoreCase}}"
22
+ bind:search="onSearch"
23
23
  />
24
24
  </block>
25
25
  </view>
@@ -25,9 +25,16 @@ Component({
25
25
  type: Array,
26
26
  value: [],
27
27
  },
28
+ searchable: {
29
+ type: Boolean,
30
+ value: true,
31
+ },
32
+ filterable: {
33
+ type: Boolean,
34
+ value: false,
35
+ },
28
36
  },
29
37
  data: {
30
- options: [],
31
38
  itemMap: {},
32
39
  selectedLabel: null,
33
40
  selectedItem: null,
@@ -55,6 +62,12 @@ Component({
55
62
  debouncedTriggerSearchEvent: debounce(function (value) {
56
63
  this.triggerEvent('search', { value });
57
64
  }),
65
+ updateSelect: function (e) {
66
+ const { value, option } = e.detail;
67
+ const itemMap = arrayToMap(option, 'value');
68
+ const { selectedLabel, selectedItem } = getSelected(itemMap, value, true);
69
+ this.setData({ selectedLabel, selectedItem });
70
+ },
58
71
  },
59
72
  observers: {
60
73
  'name, value, label, required, visible, disabled, readOnly, before, after, primaryField, selectedLabel, selectedItem':
@@ -65,13 +78,8 @@ Component({
65
78
  const [_suffixType, _suffixIcon] = convertFixedIcon(suffixType, suffixIcon, SELECT_ICON_H5);
66
79
  this.setData({ _suffixType, _suffixIcon });
67
80
  },
68
- options: function (options) {
69
- const itemMap = arrayToMap(options, 'value');
70
- this.setData({ itemMap });
71
- },
72
- 'itemMap, value': function (itemMap, value) {
73
- const { selectedLabel, selectedItem } = getSelected(itemMap, value, true);
74
- this.setData({ selectedLabel, selectedItem });
81
+ range: function (range) {
82
+ this.updateSelect({ detail: { value: this.data.value, option: range } });
75
83
  },
76
84
  },
77
85
  lifetimes: {
@@ -5,6 +5,6 @@
5
5
  "wd-form-item": "../wd-form-item/index",
6
6
  "wd-input-group": "../wd-input-group/index",
7
7
  "wd-input-wrap": "../wd-input-wrap/index",
8
- "old-select": "../form/selectMultiple"
8
+ "old-select": "../wd-select/select/index"
9
9
  }
10
10
  }
@@ -22,6 +22,9 @@
22
22
  <wd-input-group before="{{before}}" after="{{after}}" block="{{true}}" size="{{_size}}" classRoot="{{classRoot}}" readOnly="{{readOnly}}">
23
23
  <wd-input-wrap block="{{block}}" classRoot="{{classRoot}}" before="{{before}}" after="{{after}}" disabled="{{disabled}}" prefixType="{{prefixType}}" prefixIcon="{{prefixIcon}}" prefixSrc="{{prefixSrc}}" suffixType="{{_suffixType}}" suffixIcon="{{_suffixIcon}}" suffixSrc="{{suffixSrc}}" hasClearIcon="{{hasClearIcon}}" bind:onClear="handleClear" readOnly="{{readOnly}}">
24
24
  <old-select
25
+ multiple="{{true}}"
26
+ searchable="{{searchable}}"
27
+ filterable="{{filterable}}"
25
28
  supportManyRelated="{{supportManyRelated}}"
26
29
  queryCondition="{{queryCondition}}"
27
30
  sorter="{{sorter}}"
@@ -43,11 +46,12 @@
43
46
  mode="selector"
44
47
  version="wd"
45
48
  ignoreCase="{{ignoreCase}}"
46
- staticSearchable="{{staticSearchable}}"
47
49
  bind:change="handleChange"
48
- bind:changeOptions="changeOptions"
50
+ bind:updateSelect="updateSelect"
49
51
  bind:changeLabel="changeLabel"
50
52
  bind:search="search"
53
+ bind:focus="handleEvent"
54
+ bind:blur="handleEvent"
51
55
  />
52
56
  </wd-input-wrap>
53
57
  </wd-input-group>
@@ -3,6 +3,7 @@ import formFieldBehavior from '../form-field-behavior/form-field-behavior';
3
3
  import itemBehavior from '../form-field-behavior/item-behavior';
4
4
  import isEqual from '../../utils/deepEqual';
5
5
  import { convertSingleValue } from '../../utils/platform';
6
+ import { upload } from '../form/uploaderFile/upload';
6
7
 
7
8
  Component({
8
9
  options: {
@@ -39,6 +40,15 @@ Component({
39
40
  type: Object,
40
41
  value: null,
41
42
  },
43
+ template: {
44
+ type: String,
45
+ value: 'normal',
46
+ },
47
+ },
48
+ data: {
49
+ files: [],
50
+ uploadInstance: {},
51
+ config: { count: 9, maxDuration: 60 },
42
52
  },
43
53
  methods: {
44
54
  initValue: function () {
@@ -48,17 +58,151 @@ Component({
48
58
  this.setData({ value: v });
49
59
  }
50
60
  },
61
+ mapPreviewFile: function (files) {
62
+ return files.map((i) => ({
63
+ ...i,
64
+ progress: i.percent,
65
+ loading: i.status !== 'success',
66
+ cloudId: i.cloudId || i.cloudPath,
67
+ tempUrl: i.tempFilePath,
68
+ }));
69
+ },
70
+ initUploadInstance: function ({ action, config }) {
71
+ const { files } = this.data;
72
+ const _this = this;
73
+ let uploadInstance = {
74
+ action,
75
+ config: { ...config },
76
+ previewFile: files,
77
+ updatePreviewFile(files) {
78
+ _this.setData({ files: _this.mapPreviewFile(files) });
79
+ },
80
+ getPreviewFile() {
81
+ const { files } = _this.data;
82
+ return files;
83
+ },
84
+ onComplete(result) {
85
+ const files = _this.mapPreviewFile(result);
86
+ _this.setData({
87
+ files,
88
+ });
89
+ const cloudPathList = files.map((i) => i.cloudId).filter((j) => !!j);
90
+ let _value = cloudPathList;
91
+ if (_this.data.single) {
92
+ _value = cloudPathList[0] ?? '';
93
+ }
94
+ _this.handleChange({ detail: { value: _value } });
95
+ },
96
+ onSuccess(res) {
97
+ _this.triggerEvent('success', {
98
+ value: res.cloudPath,
99
+ file: res,
100
+ });
101
+ },
102
+ onFail(e) {
103
+ _this.triggerEvent('error', e);
104
+ },
105
+ beforeUpload: _this.data.callbacks?.beforeUpload,
106
+ };
107
+
108
+ return uploadInstance;
109
+ },
110
+ setConfig: function (_config) {
111
+ const { single, maxUploadCount, config } = this.data;
112
+ const _maxUploadCount = _config.maxUploadCount ?? maxUploadCount;
113
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
114
+ const maxCount = single ? 1 : _maxUploadCount;
115
+ const res = { ...config, count: maxCount, ..._config };
116
+ this.setData({ config: res });
117
+ },
118
+ deleteHandle: function ({ cloudId }) {
119
+ const { files, single } = this.data;
120
+ const fileList = files.filter((d) => d.cloudId !== cloudId);
121
+ this.setData({ files: fileList });
122
+
123
+ let value = fileList.map((i) => i?.cloudId).filter((j) => !!j);
124
+
125
+ value = single ? value[0] || '' : value;
126
+
127
+ this.handleChange({ detail: { value: value } });
128
+ },
129
+ setConfigHandle: function ({ config }) {
130
+ this.setConfig(config);
131
+ },
132
+ init: function () {
133
+ const { config } = this.data;
134
+ const uploadInstance = this.initUploadInstance({ action: 'CHOOSE_MEDIA', config });
135
+ this.setData({ uploadInstance });
136
+
137
+ this.setReadonlyAttributes &&
138
+ this.setReadonlyAttributes({
139
+ upload: (_uploadInstance = uploadInstance) => {
140
+ upload(_uploadInstance);
141
+ },
142
+ delete: this.deleteHandle.bind(this),
143
+ uploadInstance,
144
+ setConfig: this.setConfigHandle.bind(this),
145
+ });
146
+ },
147
+ updatePreviewFile: function () {
148
+ const { files } = this.data;
149
+ this.setReadonlyAttributes &&
150
+ this.setReadonlyAttributes({
151
+ previewFile: files,
152
+ });
153
+ },
51
154
  },
52
155
  observers: {
53
- 'name, value, label, required, visible, disabled, readOnly, sourceType':
54
- function () {
55
- this.updateWidgetAPI();
56
- },
156
+ 'name, value, label, required, visible, disabled, readOnly, sourceType': function () {
157
+ this.updateWidgetAPI();
158
+ },
159
+ 'disabled,sourceType,maxUploadCount,sizeType,single': function (disabled, sourceType, maxUploadCount, sizeType) {
160
+ const config = {
161
+ disabled,
162
+ sourceType,
163
+ maxUploadCount,
164
+ sizeType,
165
+ };
166
+ this.setConfig(config);
167
+ },
168
+ config: function () {
169
+ this.init();
170
+ },
171
+ files: function () {
172
+ this.updatePreviewFile();
173
+ },
174
+ value: function (value) {
175
+ const _value = [].concat(value).filter((d) => typeof d === 'string' && d !== '');
176
+
177
+ const previewFileMap = this.data.files.reduce((acc, obj) => {
178
+ acc[obj?.cloudId] = obj; // 使用 cloudId 作为新对象的 key
179
+ return acc;
180
+ }, {});
181
+ if (_value.some((i) => !previewFileMap[i])) {
182
+ const previewFile = _value?.length
183
+ ? _value.map((i) => ({
184
+ progress: 100,
185
+ loading: false,
186
+ cloudId: i,
187
+ tempUrl: '',
188
+ }))
189
+ : [];
190
+ this.setData({ files: previewFile });
191
+ }
192
+ },
57
193
  },
58
194
  lifetimes: {
59
195
  attached: function () {
60
196
  this.initValue();
197
+ const { disabled, sourceType, sizeType } = this.data;
198
+ this.setConfig({ disabled, maxDuration: 60, sourceType, sizeType });
199
+
61
200
  this.updateWidgetAPI();
62
201
  },
202
+ ready: function () {
203
+ this.triggerEvent('onReady', {
204
+ uploadInstance: this.data.uploadInstance,
205
+ });
206
+ },
63
207
  },
64
208
  });
@@ -19,6 +19,10 @@
19
19
  size="{{size}}"
20
20
  borderedH5="{{borderedH5}}"
21
21
  >
22
+ <block wx:if="{{template==='custom'}}">
23
+ <slot></slot>
24
+ </block>
25
+ <block wx:else>
22
26
  <old-image-uploader
23
27
  labelVisible="{{false}}"
24
28
  acceptTypes="{{acceptTypes}}"
@@ -41,5 +45,6 @@
41
45
  bind:success="handleEvent"
42
46
  bind:error="handleEvent"
43
47
  />
48
+ </block>
44
49
  </wd-form-item>
45
50
  </block>
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.8",
6
+ "version": "3.17.0",
7
7
  "main": "./",
8
8
  "publishConfig": {
9
9
  "access": "public"
package/utils/platform.js CHANGED
@@ -58,11 +58,7 @@ export const getWhereList = (where) => {
58
58
  }
59
59
  let [rel, val] = [REL_DICT[item2?.rel] || item2?.rel, item2?.value];
60
60
  // 去掉空字符串、undefined(接口不支持)、对象类型(接口不支持)
61
- if (
62
- val === '' ||
63
- val === undefined ||
64
- Object.prototype.toString.call(val) === '[object Object]'
65
- ) {
61
+ if (val === '' || val === undefined || Object.prototype.toString.call(val) === '[object Object]') {
66
62
  return;
67
63
  }
68
64
  if ('_begin_with' === rel) {
@@ -115,9 +111,7 @@ export const randomStr = (len = 32) => {
115
111
  * 转换枚举值
116
112
  */
117
113
  export const convertLegacyEnum = (prop, enumObj, defaultValue) => {
118
- const enumValue = enumObj.map((i) => i.value).includes(prop)
119
- ? prop
120
- : enumObj[0].value;
114
+ const enumValue = enumObj.map((i) => i.value).includes(prop) ? prop : enumObj[0].value;
121
115
  if (defaultValue !== undefined) return enumValue || defaultValue;
122
116
  return enumValue;
123
117
  };
@@ -160,3 +154,28 @@ export const convertSingleValue = (value, single) => {
160
154
  }
161
155
  return v;
162
156
  };
157
+
158
+ export const compareVersion = (v1, v2) => {
159
+ v1 = v1.split('.');
160
+ v2 = v2.split('.');
161
+ const len = Math.max(v1.length, v2.length);
162
+
163
+ while (v1.length < len) {
164
+ v1.push('0');
165
+ }
166
+ while (v2.length < len) {
167
+ v2.push('0');
168
+ }
169
+
170
+ for (let i = 0; i < len; i++) {
171
+ const num1 = parseInt(v1[i]);
172
+ const num2 = parseInt(v2[i]);
173
+
174
+ if (num1 > num2) {
175
+ return 1;
176
+ } else if (num1 < num2) {
177
+ return -1;
178
+ }
179
+ }
180
+ return 0;
181
+ };