@sheinx/hooks 3.1.15 → 3.1.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"use-upload.d.ts","sourceRoot":"","sources":["use-upload.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAa,MAAM,mBAAmB,CAAC;AAgC1E,QAAA,MAAM,SAAS;;;;;;0BAyLkB,IAAI,EAAE;yBAqEb,MAAM;6BAqBF,MAAM;8BAqBL,MAAM;;CA2BpC,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"use-upload.d.ts","sourceRoot":"","sources":["use-upload.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAa,MAAM,mBAAmB,CAAC;AAgC1E,QAAA,MAAM,SAAS;;;;;;0BAuL+B,IAAI,EAAE;yBAqEb,MAAM;6BAqBF,MAAM;8BAqBL,MAAM;;CA2BjD,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -172,10 +172,9 @@ var useUpload = function useUpload(props) {
172
172
  });
173
173
  });
174
174
  };
175
- var getCurrent = (0, _usePersistFn.default)(function () {
176
- return {
177
- filesState: filesState
178
- };
175
+ var latestState = (0, _useLatestObj.default)({
176
+ filesState: filesState,
177
+ value: value
179
178
  });
180
179
  var uploadFile = function uploadFile(id, file, data) {
181
180
  var request = props.request || _xhr.default;
@@ -196,8 +195,7 @@ var useUpload = function useUpload(props) {
196
195
  throttle = false;
197
196
  }, 16);
198
197
  var percent = typeof e.percent === 'number' ? e.percent : e.loaded / e.total * 100;
199
- var _getCurrent = getCurrent(),
200
- filesState = _getCurrent.filesState;
198
+ var filesState = latestState.filesState;
201
199
  var newFiles = _objectSpread({}, filesState);
202
200
  if (!newFiles[id]) return;
203
201
  newFiles[id].process = percent;
@@ -234,7 +232,7 @@ var useUpload = function useUpload(props) {
234
232
  });
235
233
  });
236
234
  // add value
237
- var values = (0, _immer.produce)(value, function (draft) {
235
+ var values = (0, _immer.produce)(latestState.value, function (draft) {
238
236
  draft.push(result);
239
237
  });
240
238
  props.onChange(values);
@@ -287,7 +285,7 @@ var useUpload = function useUpload(props) {
287
285
  reader.readAsDataURL(blob);
288
286
  });
289
287
  };
290
- var addFiles = /*#__PURE__*/function () {
288
+ var addFiles = (0, _usePersistFn.default)( /*#__PURE__*/function () {
291
289
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(files) {
292
290
  var fileList, newFiles, resetLength, list, _loop, _ret, i;
293
291
  return _regeneratorRuntime().wrap(function _callee2$(_context3) {
@@ -426,11 +424,11 @@ var useUpload = function useUpload(props) {
426
424
  }
427
425
  }, _callee2);
428
426
  }));
429
- return function addFiles(_x3) {
427
+ return function (_x3) {
430
428
  return _ref2.apply(this, arguments);
431
429
  };
432
- }();
433
- var removeFile = function removeFile(id) {
430
+ }());
431
+ var removeFile = (0, _usePersistFn.default)(function (id) {
434
432
  var beforeCancel = props.beforeCancel,
435
433
  onErrorRemove = props.onErrorRemove;
436
434
  var file = filesState[id];
@@ -448,8 +446,8 @@ var useUpload = function useUpload(props) {
448
446
  onErrorRemove(file.xhr, file.blob, file);
449
447
  }
450
448
  }
451
- };
452
- var removeValue = function removeValue(index) {
449
+ });
450
+ var removeValue = (0, _usePersistFn.default)(function (index) {
453
451
  if (props.disabled) return;
454
452
  var recoverAble = props.recoverAble,
455
453
  beforeRemove = props.beforeRemove;
@@ -461,15 +459,15 @@ var useUpload = function useUpload(props) {
461
459
  newRecycle.push(value[index]);
462
460
  }
463
461
  setRecycleValues(newRecycle);
464
- var newValue = (0, _immer.produce)(props.value, function (draft) {
462
+ var newValue = (0, _immer.produce)(latestState.value, function (draft) {
465
463
  draft.splice(index, 1);
466
464
  });
467
465
  props.onChange(newValue);
468
466
  }).catch(function () {});
469
- };
470
- var recoverValue = function recoverValue(index) {
467
+ });
468
+ var recoverValue = (0, _usePersistFn.default)(function (index) {
471
469
  if (props.disabled) return;
472
- props.onChange((0, _immer.produce)(props.value, function (draft) {
470
+ props.onChange((0, _immer.produce)(latestState.value, function (draft) {
473
471
  draft.push(recycleValues[index]);
474
472
  }));
475
473
  setRecycleValues(function (pre) {
@@ -477,7 +475,7 @@ var useUpload = function useUpload(props) {
477
475
  newRecycle.splice(index, 1);
478
476
  return newRecycle;
479
477
  });
480
- };
478
+ });
481
479
  var func = (0, _useLatestObj.default)({
482
480
  addFiles: addFiles,
483
481
  removeFile: removeFile,
@@ -105,7 +105,7 @@ export interface RuleFuncResult {
105
105
  export type RuleResult = {
106
106
  [key: string]: RuleFuncResult;
107
107
  } | RuleCommonResult;
108
- export type RuleResultValue = ValueOf<RuleResult>;
108
+ export type RuleResultValue = RuleFuncResult | ValueOf<RuleCommonResult>;
109
109
  export type FormItemObjectRule = Type & RegExpParams & Range & Min & Max & Required & {
110
110
  func?: ValidFunc;
111
111
  args?: any;
@@ -1 +1 @@
1
- {"version":3,"file":"rule.type.d.ts","sourceRoot":"","sources":["rule.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAEpC,MAAM,WAAW,SAAS,CAAC,CAAC,GAAG,GAAG;IAChC,CACE,KAAK,EAAE,CAAC,GAAG,SAAS,EACpB,SAAS,EAAE,UAAU,EACrB,EAAE,EAAE,CAAC,MAAM,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,EAClC,KAAK,EAAE,GAAG,GACT,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CACxB;AAED,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;AACpG,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,MAAM,CAAC,CA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B,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,MAAM,CAAC,EAAE,YAAY,CAAC;IAEtB,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,CAAC,QAAQ,EAAE,MAAM,GACb;QACE,IAAI,CAAC,EAAE,SAAS,CAAC;QACjB,OAAO,CAAC,EAAE,WAAW,CAAC;KACvB,GACD,SAAS,GACT,SAAS,CAAC;CACf;AAGD,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,gBAAgB,EAAE,IAAI,CAAA;CAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-upload.d.ts","sourceRoot":"","sources":["use-upload.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAa,MAAM,mBAAmB,CAAC;AAgC1E,QAAA,MAAM,SAAS;;;;;;0BAyLkB,IAAI,EAAE;yBAqEb,MAAM;6BAqBF,MAAM;8BAqBL,MAAM;;CA2BpC,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"use-upload.d.ts","sourceRoot":"","sources":["use-upload.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAa,MAAM,mBAAmB,CAAC;AAgC1E,QAAA,MAAM,SAAS;;;;;;0BAuL+B,IAAI,EAAE;yBAqEb,MAAM;6BAqBF,MAAM;8BAqBL,MAAM;;CA2BjD,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -165,10 +165,9 @@ var useUpload = function useUpload(props) {
165
165
  });
166
166
  });
167
167
  };
168
- var getCurrent = usePersistFn(function () {
169
- return {
170
- filesState: filesState
171
- };
168
+ var latestState = useLatestObj({
169
+ filesState: filesState,
170
+ value: value
172
171
  });
173
172
  var uploadFile = function uploadFile(id, file, data) {
174
173
  var request = props.request || xhrUpload;
@@ -189,8 +188,7 @@ var useUpload = function useUpload(props) {
189
188
  throttle = false;
190
189
  }, 16);
191
190
  var percent = typeof e.percent === 'number' ? e.percent : e.loaded / e.total * 100;
192
- var _getCurrent = getCurrent(),
193
- filesState = _getCurrent.filesState;
191
+ var filesState = latestState.filesState;
194
192
  var newFiles = _objectSpread({}, filesState);
195
193
  if (!newFiles[id]) return;
196
194
  newFiles[id].process = percent;
@@ -227,7 +225,7 @@ var useUpload = function useUpload(props) {
227
225
  });
228
226
  });
229
227
  // add value
230
- var values = produce(value, function (draft) {
228
+ var values = produce(latestState.value, function (draft) {
231
229
  draft.push(result);
232
230
  });
233
231
  props.onChange(values);
@@ -280,7 +278,7 @@ var useUpload = function useUpload(props) {
280
278
  reader.readAsDataURL(blob);
281
279
  });
282
280
  };
283
- var addFiles = /*#__PURE__*/function () {
281
+ var addFiles = usePersistFn( /*#__PURE__*/function () {
284
282
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(files) {
285
283
  var fileList, newFiles, resetLength, list, _loop, _ret, i;
286
284
  return _regeneratorRuntime().wrap(function _callee2$(_context3) {
@@ -419,11 +417,11 @@ var useUpload = function useUpload(props) {
419
417
  }
420
418
  }, _callee2);
421
419
  }));
422
- return function addFiles(_x3) {
420
+ return function (_x3) {
423
421
  return _ref2.apply(this, arguments);
424
422
  };
425
- }();
426
- var removeFile = function removeFile(id) {
423
+ }());
424
+ var removeFile = usePersistFn(function (id) {
427
425
  var beforeCancel = props.beforeCancel,
428
426
  onErrorRemove = props.onErrorRemove;
429
427
  var file = filesState[id];
@@ -441,8 +439,8 @@ var useUpload = function useUpload(props) {
441
439
  onErrorRemove(file.xhr, file.blob, file);
442
440
  }
443
441
  }
444
- };
445
- var removeValue = function removeValue(index) {
442
+ });
443
+ var removeValue = usePersistFn(function (index) {
446
444
  if (props.disabled) return;
447
445
  var recoverAble = props.recoverAble,
448
446
  beforeRemove = props.beforeRemove;
@@ -454,15 +452,15 @@ var useUpload = function useUpload(props) {
454
452
  newRecycle.push(value[index]);
455
453
  }
456
454
  setRecycleValues(newRecycle);
457
- var newValue = produce(props.value, function (draft) {
455
+ var newValue = produce(latestState.value, function (draft) {
458
456
  draft.splice(index, 1);
459
457
  });
460
458
  props.onChange(newValue);
461
459
  }).catch(function () {});
462
- };
463
- var recoverValue = function recoverValue(index) {
460
+ });
461
+ var recoverValue = usePersistFn(function (index) {
464
462
  if (props.disabled) return;
465
- props.onChange(produce(props.value, function (draft) {
463
+ props.onChange(produce(latestState.value, function (draft) {
466
464
  draft.push(recycleValues[index]);
467
465
  }));
468
466
  setRecycleValues(function (pre) {
@@ -470,7 +468,7 @@ var useUpload = function useUpload(props) {
470
468
  newRecycle.splice(index, 1);
471
469
  return newRecycle;
472
470
  });
473
- };
471
+ });
474
472
  var func = useLatestObj({
475
473
  addFiles: addFiles,
476
474
  removeFile: removeFile,
@@ -105,7 +105,7 @@ export interface RuleFuncResult {
105
105
  export type RuleResult = {
106
106
  [key: string]: RuleFuncResult;
107
107
  } | RuleCommonResult;
108
- export type RuleResultValue = ValueOf<RuleResult>;
108
+ export type RuleResultValue = RuleFuncResult | ValueOf<RuleCommonResult>;
109
109
  export type FormItemObjectRule = Type & RegExpParams & Range & Min & Max & Required & {
110
110
  func?: ValidFunc;
111
111
  args?: any;
@@ -1 +1 @@
1
- {"version":3,"file":"rule.type.d.ts","sourceRoot":"","sources":["rule.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC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