ydb-components-material 0.1.200 → 0.1.201

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.
@@ -200,6 +200,18 @@ var FileList = function FileList(_ref) {
200
200
  handleChange(value, 0, curMerge.index, curMerge.subIndex);
201
201
  setShowMerge(false);
202
202
  };
203
+
204
+ // 删除之后调用:只要没到 10 个上限,就保证末尾是一个空槽(渲染成「上传材料」按钮)。
205
+ // 末尾已经是空槽或列表为空(空列表也要补一个)时按需处理,已达上限则不动。
206
+ var ensureEmptySlot = function ensureEmptySlot(list) {
207
+ if (list.length >= 10) return list;
208
+ var last = list[list.length - 1];
209
+ if (last && !last.fileId) return list;
210
+ list.push({
211
+ fileId: ''
212
+ });
213
+ return list;
214
+ };
203
215
  var handleChange = function handleChange(value, fileIndex, index, subIndex) {
204
216
  console.log('handleChange', value, fileIndex, index, subIndex);
205
217
  // 先找到一级目录
@@ -210,14 +222,9 @@ var FileList = function FileList(_ref) {
210
222
  if (!value) {
211
223
  oneLevelItem.subMaterials[subIndex].isSmart = false;
212
224
  oneLevelItem.subMaterials[subIndex].isShareFile = false;
213
- // 如果当前文件list中只有一个文件,还得补个空的
214
- if (oneLevelItem.subMaterials[subIndex].fileList.length === 1) {
215
- oneLevelItem.subMaterials[subIndex].fileList = [{
216
- fileId: ''
217
- }];
218
- } else {
219
- oneLevelItem.subMaterials[subIndex].fileList.splice(fileIndex, 1);
220
- }
225
+ oneLevelItem.subMaterials[subIndex].fileList.splice(fileIndex, 1);
226
+ // 删完保证末尾还有「上传材料」按钮
227
+ ensureEmptySlot(oneLevelItem.subMaterials[subIndex].fileList);
221
228
  } else {
222
229
  // 如果当前这个位置的fileId是空的。说明这次修改是新增
223
230
  var isAdd = !oneLevelItem.subMaterials[subIndex].fileList[fileIndex].fileId;
@@ -233,11 +240,8 @@ var FileList = function FileList(_ref) {
233
240
  oneLevelItem.isSmart = false;
234
241
  oneLevelItem.isShareFile = false;
235
242
  oneLevelItem.fileList.splice(fileIndex, 1);
236
- if (oneLevelItem.fileList.length === 0) {
237
- oneLevelItem.fileList.push({
238
- fileId: ''
239
- });
240
- }
243
+ // 删完保证末尾还有「上传材料」按钮
244
+ ensureEmptySlot(oneLevelItem.fileList);
241
245
  } else {
242
246
  // 如果当前这个位置的fileId是空的。说明这次修改是新增
243
247
  var _isAdd = !oneLevelItem.fileList[fileIndex].fileId;
@@ -206,6 +206,18 @@ var FileList = function FileList(_ref) {
206
206
  handleChange(value, 0, curMerge.index, curMerge.subIndex);
207
207
  setShowMerge(false);
208
208
  };
209
+
210
+ // 删除之后调用:只要没到 10 个上限,就保证末尾是一个空槽(渲染成「上传材料」按钮)。
211
+ // 末尾已经是空槽或列表为空(空列表也要补一个)时按需处理,已达上限则不动。
212
+ var ensureEmptySlot = function ensureEmptySlot(list) {
213
+ if (list.length >= 10) return list;
214
+ var last = list[list.length - 1];
215
+ if (last && !last.fileId) return list;
216
+ list.push({
217
+ fileId: ''
218
+ });
219
+ return list;
220
+ };
209
221
  var handleChange = function handleChange(value, fileIndex, index, subIndex) {
210
222
  console.log('handleChange', value, fileIndex, index, subIndex);
211
223
  // 先找到一级目录
@@ -216,14 +228,9 @@ var FileList = function FileList(_ref) {
216
228
  if (!value) {
217
229
  oneLevelItem.subMaterials[subIndex].isSmart = false;
218
230
  oneLevelItem.subMaterials[subIndex].isShareFile = false;
219
- // 如果当前文件list中只有一个文件,还得补个空的
220
- if (oneLevelItem.subMaterials[subIndex].fileList.length === 1) {
221
- oneLevelItem.subMaterials[subIndex].fileList = [{
222
- fileId: ''
223
- }];
224
- } else {
225
- oneLevelItem.subMaterials[subIndex].fileList.splice(fileIndex, 1);
226
- }
231
+ oneLevelItem.subMaterials[subIndex].fileList.splice(fileIndex, 1);
232
+ // 删完保证末尾还有「上传材料」按钮
233
+ ensureEmptySlot(oneLevelItem.subMaterials[subIndex].fileList);
227
234
  } else {
228
235
  // 如果当前这个位置的fileId是空的。说明这次修改是新增
229
236
  var isAdd = !oneLevelItem.subMaterials[subIndex].fileList[fileIndex].fileId;
@@ -239,11 +246,8 @@ var FileList = function FileList(_ref) {
239
246
  oneLevelItem.isSmart = false;
240
247
  oneLevelItem.isShareFile = false;
241
248
  oneLevelItem.fileList.splice(fileIndex, 1);
242
- if (oneLevelItem.fileList.length === 0) {
243
- oneLevelItem.fileList.push({
244
- fileId: ''
245
- });
246
- }
249
+ // 删完保证末尾还有「上传材料」按钮
250
+ ensureEmptySlot(oneLevelItem.fileList);
247
251
  } else {
248
252
  // 如果当前这个位置的fileId是空的。说明这次修改是新增
249
253
  var _isAdd = !oneLevelItem.fileList[fileIndex].fileId;
@@ -99,7 +99,7 @@ function fillRealVersion(meta, packageName, version, basicLibraryVersion) {
99
99
  packageName = 'ydb-components-material';
100
100
  }
101
101
  if (version === void 0) {
102
- version = '0.1.200';
102
+ version = '0.1.201';
103
103
  }
104
104
  if (basicLibraryVersion === void 0) {
105
105
  basicLibraryVersion = {
@@ -104,7 +104,7 @@ function fillRealVersion(meta, packageName, version, basicLibraryVersion) {
104
104
  packageName = 'ydb-components-material';
105
105
  }
106
106
  if (version === void 0) {
107
- version = '0.1.200';
107
+ version = '0.1.201';
108
108
  }
109
109
  if (basicLibraryVersion === void 0) {
110
110
  basicLibraryVersion = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ydb-components-material",
3
- "version": "0.1.200",
3
+ "version": "0.1.201",
4
4
  "description": "ydb-components-material",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -102,10 +102,10 @@
102
102
  },
103
103
  "componentConfig": {
104
104
  "isComponentLibrary": true,
105
- "materialSchema": "https://unpkg.com/ydb-components-material@0.1.200/build/lowcode/assets-prod.json"
105
+ "materialSchema": "https://unpkg.com/ydb-components-material@0.1.201/build/lowcode/assets-prod.json"
106
106
  },
107
107
  "lcMeta": {
108
108
  "type": "component"
109
109
  },
110
- "homepage": "https://unpkg.com/ydb-components-material@0.1.200/build/index.html"
110
+ "homepage": "https://unpkg.com/ydb-components-material@0.1.201/build/index.html"
111
111
  }