@sheinx/hooks 3.2.0-rc.5 → 3.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAI7C,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AAElD,MAAM,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;AACnD,wBAAgB,YAAY,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,EAAE,MAAM,EAAE;IAE5D,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAE9B,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;CAC/B,QAkCA;AAED,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAI7C,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AAElD,MAAM,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;AACnD,wBAAgB,YAAY,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,EAAE,MAAM,EAAE;IAE5D,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAE9B,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;CAC/B,QAqCA;AAED,eAAe,YAAY,CAAC"}
@@ -45,7 +45,10 @@ function useClickAway(params) {
45
45
  }
46
46
  return function () {
47
47
  // @ts-ignore
48
- document.removeEventListener(event, handleClickAway);
48
+ document.removeEventListener(event, handleClickAway, {
49
+ // 解决 点击后立刻删除dom导致获取不到元素; contains(target) 为 false 的问题
50
+ capture: true
51
+ });
49
52
  };
50
53
  }, [effect]);
51
54
  }
@@ -59,7 +59,7 @@ var useButton = function useButton() {
59
59
  return mergedEventHandlers;
60
60
  };
61
61
  return {
62
- disabled: disabled,
62
+ disabled: disabled || loading,
63
63
  getAnchorProps: getAnchorProps,
64
64
  getButtonProps: getButtonProps,
65
65
  getSpaceChildren: getSpaceChildren
@@ -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":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAI7C,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AAElD,MAAM,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;AACnD,wBAAgB,YAAY,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,EAAE,MAAM,EAAE;IAE5D,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAE9B,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;CAC/B,QAkCA;AAED,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAI7C,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AAElD,MAAM,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;AACnD,wBAAgB,YAAY,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,EAAE,MAAM,EAAE;IAE5D,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAE9B,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;CAC/B,QAqCA;AAED,eAAe,YAAY,CAAC"}
@@ -37,7 +37,10 @@ export function useClickAway(params) {
37
37
  }
38
38
  return function () {
39
39
  // @ts-ignore
40
- document.removeEventListener(event, handleClickAway);
40
+ document.removeEventListener(event, handleClickAway, {
41
+ // 解决 点击后立刻删除dom导致获取不到元素; contains(target) 为 false 的问题
42
+ capture: true
43
+ });
41
44
  };
42
45
  }, [effect]);
43
46
  }
@@ -53,7 +53,7 @@ var useButton = function useButton() {
53
53
  return mergedEventHandlers;
54
54
  };
55
55
  return {
56
- disabled: disabled,
56
+ disabled: disabled || loading,
57
57
  getAnchorProps: getAnchorProps,
58
58
  getButtonProps: getButtonProps,
59
59
  getSpaceChildren: getSpaceChildren
@@ -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.2.0-rc.5",
3
+ "version": "3.2.1",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",