@sheinx/hooks 3.5.7-beta.6 → 3.5.7-fix.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"use-Input-able.d.ts","sourceRoot":"","sources":["use-Input-able.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;;;;EA2E3F"}
1
+ {"version":3,"file":"use-Input-able.d.ts","sourceRoot":"","sources":["use-Input-able.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;;;;EA0E3F"}
@@ -46,19 +46,18 @@ function useInputAble(props) {
46
46
  var render = (0, _useRender.useRender)(syncValue);
47
47
  var shouldUseState = delay || !control;
48
48
  var value = shouldUseState ? stateValue : valuePo;
49
- (0, _react.useEffect)(function () {
50
- if (context.timer) {
51
- clearTimeout(context.timer);
52
- context.timer = null;
53
- }
49
+ (0, _react.useLayoutEffect)(function () {
54
50
  if (delay && control && props.value !== stateValue) {
55
51
  changeStateValue(props.value);
52
+ } else if (context.timer) {
53
+ clearTimeout(context.timer);
54
+ context.timer = null;
56
55
  }
57
56
  }, [props.value, delay, control]);
58
57
  var forceDelayChange = (0, _usePersistFn.default)(function () {
59
- if (context.timer && context.delayChange) {
58
+ if (context.delayChange) context.delayChange();
59
+ if (context.timer) {
60
60
  clearTimeout(context.timer);
61
- context.delayChange();
62
61
  context.timer = null;
63
62
  context.delayChange = null;
64
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"use-input-format.d.ts","sourceRoot":"","sources":["use-input-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAM3D,QAAA,MAAM,cAAc,UAAW,gBAAgB;kBAsBP,MAAM,GAAG,SAAS;gBA4BpB,gBAAgB;iBAgDd,gBAAgB;;;CAyBvD,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"use-input-format.d.ts","sourceRoot":"","sources":["use-input-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAM3D,QAAA,MAAM,cAAc,UAAW,gBAAgB;kBAsBP,MAAM,GAAG,SAAS;gBAoCpB,gBAAgB;iBAgDd,gBAAgB;;;CAyBvD,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -28,7 +28,7 @@ var useInputFormat = function useInputFormat(props) {
28
28
  autoFix = props.autoFix,
29
29
  coin = props.coin,
30
30
  cancelBlurChange = props.cancelBlurChange;
31
- var _React$useState = _react.default.useState(false),
31
+ var _React$useState = _react.default.useState(coin),
32
32
  _React$useState2 = _slicedToArray(_React$useState, 2),
33
33
  showCoin = _React$useState2[0],
34
34
  setShowCoin = _React$useState2[1];
@@ -55,6 +55,13 @@ var useInputFormat = function useInputFormat(props) {
55
55
  var noNeg = numType === 'non-negative' || numType === 'positive';
56
56
  var regExp = new RegExp("^(".concat(noNeg ? '' : '-', ")?(\\d").concat(regLength(integerLimit), ")(").concat(digits !== 0 ? "\\.\\d".concat(regLength(digits)) : '', ")?.*$"), 'g');
57
57
  value = value.replace(regExp, '$1$2$3');
58
+
59
+ // 修正小数位数
60
+ var _value = v.split('.');
61
+ var __value = value.split('.');
62
+ if (_value[1] !== undefined && __value[1] === undefined) {
63
+ value = "".concat(value, ".").concat(_value[1]);
64
+ }
58
65
  }
59
66
  onChange(value);
60
67
  });
@@ -1 +1 @@
1
- {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["object.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,UAGvC;AASD,UAAU,WAAW;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAGD,eAAO,MAAM,YAAY,QAAS,UAAU,UAG3C,CAAC;AAGF,eAAO,MAAM,SAAS,2CAEZ,UAAU,YACT,WAAW,eAwBrB,CAAC;AAEF,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,+DA4BxC;AAED,UAAU,cAAc;IACtB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,OAAO,WACV,UAAU,QACZ,MAAM,SACL,GAAG,YACD,cAAc,eAiDxB,CAAC;AAEF,eAAO,MAAM,OAAO,WAAY,UAAU,QAAQ,MAAM,YAAW,WAAW,YAyB7E,CAAC;AAEF,eAAO,MAAM,UAAU,WAAY,UAAU,QAAQ,MAAM,eA0B1D,CAAC;AAEF,eAAO,MAAM,OAAO,WAAY,UAAU,QAAQ,MAAM,YAavD,CAAC;AAEF,eAAO,MAAM,OAAO,QAAS,UAAU,YAItC,CAAC;AAEF,eAAO,MAAM,WAAW,wFAQvB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,QAAS,UAAU,cAAa,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;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,QAAS,UAAU,cAAa,MAAM,KAAQ,MAAM,EAoB9E,CAAC;AAGF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,WAAY,MAAM,GAAG,MAAM,EAAE,aAAa,MAAM,EAAE,KAAG,MAAM,EAkB3F,CAAA"}
@@ -320,6 +320,9 @@ var getCompleteFieldKeys = exports.getCompleteFieldKeys = function getCompleteFi
320
320
  var completeFields = [];
321
321
  fieldsArray.forEach(function (field) {
322
322
  var na = "".concat(field, "[");
323
+ if (field.endsWith(']')) {
324
+ na = field;
325
+ }
323
326
  var no = "".concat(field, ".");
324
327
  completeFields.push(field);
325
328
  var childFields = allFields.filter(function (f) {
@@ -1 +1 @@
1
- {"version":3,"file":"use-Input-able.d.ts","sourceRoot":"","sources":["use-Input-able.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;;;;EA2E3F"}
1
+ {"version":3,"file":"use-Input-able.d.ts","sourceRoot":"","sources":["use-Input-able.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;;;;EA0E3F"}
@@ -4,7 +4,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
4
4
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
5
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import { useEffect, useRef, useState } from 'react';
7
+ import { useLayoutEffect, useRef, useState } from 'react';
8
8
  import { isFunc } from "../../utils/is";
9
9
  import { shallowEqual } from "../../utils/shallow-equal";
10
10
  import usePersistFn from "../use-persist-fn";
@@ -39,19 +39,18 @@ export default function useInputAble(props) {
39
39
  var render = useRender(syncValue);
40
40
  var shouldUseState = delay || !control;
41
41
  var value = shouldUseState ? stateValue : valuePo;
42
- useEffect(function () {
43
- if (context.timer) {
44
- clearTimeout(context.timer);
45
- context.timer = null;
46
- }
42
+ useLayoutEffect(function () {
47
43
  if (delay && control && props.value !== stateValue) {
48
44
  changeStateValue(props.value);
45
+ } else if (context.timer) {
46
+ clearTimeout(context.timer);
47
+ context.timer = null;
49
48
  }
50
49
  }, [props.value, delay, control]);
51
50
  var forceDelayChange = usePersistFn(function () {
52
- if (context.timer && context.delayChange) {
51
+ if (context.delayChange) context.delayChange();
52
+ if (context.timer) {
53
53
  clearTimeout(context.timer);
54
- context.delayChange();
55
54
  context.timer = null;
56
55
  context.delayChange = null;
57
56
  }
@@ -1 +1 @@
1
- {"version":3,"file":"use-input-format.d.ts","sourceRoot":"","sources":["use-input-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAM3D,QAAA,MAAM,cAAc,UAAW,gBAAgB;kBAsBP,MAAM,GAAG,SAAS;gBA4BpB,gBAAgB;iBAgDd,gBAAgB;;;CAyBvD,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"use-input-format.d.ts","sourceRoot":"","sources":["use-input-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAM3D,QAAA,MAAM,cAAc,UAAW,gBAAgB;kBAsBP,MAAM,GAAG,SAAS;gBAoCpB,gBAAgB;iBAgDd,gBAAgB;;;CAyBvD,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -21,7 +21,7 @@ var useInputFormat = function useInputFormat(props) {
21
21
  autoFix = props.autoFix,
22
22
  coin = props.coin,
23
23
  cancelBlurChange = props.cancelBlurChange;
24
- var _React$useState = React.useState(false),
24
+ var _React$useState = React.useState(coin),
25
25
  _React$useState2 = _slicedToArray(_React$useState, 2),
26
26
  showCoin = _React$useState2[0],
27
27
  setShowCoin = _React$useState2[1];
@@ -48,6 +48,13 @@ var useInputFormat = function useInputFormat(props) {
48
48
  var noNeg = numType === 'non-negative' || numType === 'positive';
49
49
  var regExp = new RegExp("^(".concat(noNeg ? '' : '-', ")?(\\d").concat(regLength(integerLimit), ")(").concat(digits !== 0 ? "\\.\\d".concat(regLength(digits)) : '', ")?.*$"), 'g');
50
50
  value = value.replace(regExp, '$1$2$3');
51
+
52
+ // 修正小数位数
53
+ var _value = v.split('.');
54
+ var __value = value.split('.');
55
+ if (_value[1] !== undefined && __value[1] === undefined) {
56
+ value = "".concat(value, ".").concat(_value[1]);
57
+ }
51
58
  }
52
59
  onChange(value);
53
60
  });
@@ -1 +1 @@
1
- {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["object.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,UAGvC;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getCompleteFieldKeys(fields, allField
310
310
  var completeFields = [];
311
311
  fieldsArray.forEach(function (field) {
312
312
  var na = "".concat(field, "[");
313
+ if (field.endsWith(']')) {
314
+ na = field;
315
+ }
313
316
  var no = "".concat(field, ".");
314
317
  completeFields.push(field);
315
318
  var childFields = allFields.filter(function (f) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/hooks",
3
- "version": "3.5.7-beta.6",
3
+ "version": "3.5.7-fix.1",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",