@sheinx/hooks 3.1.25 → 3.1.27

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";AAuBA,OAAO,EAAe,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAsJ8B;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;aAAE;8BARzB,MAAM;oCA6CD,OAAO;;6BALb,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;;;;;;oBAmDnD;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE;0BARzB,MAAM;gCA6CD,OAAO;;yBALb,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;;CAwT7F,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";AAuBA,OAAO,EAAe,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAsJ8B;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;aAAE;8BARzB,MAAM;oCA6CD,OAAO;;6BALb,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;;;;;;oBAmDnD;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE;0BARzB,MAAM;gCA6CD,OAAO;;yBALb,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;;CAiU7F,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -384,6 +384,13 @@ var useForm = function useForm(props) {
384
384
  size: size
385
385
  };
386
386
  }, [labelWidth, labelAlign, labelVerticalAlign, keepErrorHeight, inline, disabled, size]);
387
+ var updateValue = function updateValue() {
388
+ if (props.value !== context.lastValue && props.value !== context.value) {
389
+ context.value = (0, _utils.deepClone)(props.value) || emptyObj;
390
+ context.lastValue = props.value;
391
+ }
392
+ };
393
+ updateValue();
387
394
  React.useEffect(function () {
388
395
  // 服务端错误更新
389
396
  if (!props.error) context.serverErrors = {};else {
@@ -400,8 +407,8 @@ var useForm = function useForm(props) {
400
407
  // 默认值更新
401
408
  React.useEffect(function () {
402
409
  context.removeLock = false;
403
- if (props.value === context.lastValue) return;
404
- context.value = (0, _utils.deepClone)(props.value) || emptyObj;
410
+ // 内部 onChange 改的 value, 不需要更新
411
+ if (props.value === context.value) return;
405
412
  if (initValidate && !context.resetTime) {
406
413
  var keys = Object.keys(context.validateMap).filter(function (key) {
407
414
  var oldValue = (0, _utils.deepGet)(context.lastValue || emptyObj, key);
@@ -1 +1 @@
1
- {"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";AAuBA,OAAO,EAAe,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAsJ8B;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;aAAE;8BARzB,MAAM;oCA6CD,OAAO;;6BALb,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;;;;;;oBAmDnD;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE;0BARzB,MAAM;gCA6CD,OAAO;;yBALb,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;;CAwT7F,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";AAuBA,OAAO,EAAe,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAsJ8B;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;aAAE;8BARzB,MAAM;oCA6CD,OAAO;;6BALb,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;;;;;;oBAmDnD;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE;0BARzB,MAAM;gCA6CD,OAAO;;yBALb,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;;CAiU7F,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -375,6 +375,13 @@ var useForm = function useForm(props) {
375
375
  size: size
376
376
  };
377
377
  }, [labelWidth, labelAlign, labelVerticalAlign, keepErrorHeight, inline, disabled, size]);
378
+ var updateValue = function updateValue() {
379
+ if (props.value !== context.lastValue && props.value !== context.value) {
380
+ context.value = deepClone(props.value) || emptyObj;
381
+ context.lastValue = props.value;
382
+ }
383
+ };
384
+ updateValue();
378
385
  React.useEffect(function () {
379
386
  // 服务端错误更新
380
387
  if (!props.error) context.serverErrors = {};else {
@@ -391,8 +398,8 @@ var useForm = function useForm(props) {
391
398
  // 默认值更新
392
399
  React.useEffect(function () {
393
400
  context.removeLock = false;
394
- if (props.value === context.lastValue) return;
395
- context.value = deepClone(props.value) || emptyObj;
401
+ // 内部 onChange 改的 value, 不需要更新
402
+ if (props.value === context.value) return;
396
403
  if (initValidate && !context.resetTime) {
397
404
  var keys = Object.keys(context.validateMap).filter(function (key) {
398
405
  var oldValue = deepGet(context.lastValue || emptyObj, key);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/hooks",
3
- "version": "3.1.25",
3
+ "version": "3.1.27",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",