@sheinx/hooks 3.1.18 → 3.1.20

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"use-tree.d.ts","sourceRoot":"","sources":["use-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAKb,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,eAAO,MAAM,IAAI;IACf;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEJ,CAAC;AAEF,QAAA,MAAM,OAAO;;;;CA6aZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"use-tree.d.ts","sourceRoot":"","sources":["use-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAKb,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AASjD,eAAO,MAAM,IAAI;IACf;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEJ,CAAC;AAEF,QAAA,MAAM,OAAO;;;;CA6aZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -16,6 +16,11 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
16
16
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
17
17
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
18
18
  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; }
19
+ function toArray(value) {
20
+ if (!value) return [];
21
+ if (!Array.isArray(value)) return [value];
22
+ return value;
23
+ }
19
24
  var MODE = exports.MODE = {
20
25
  /**
21
26
  * 返回全选数据,包含父节点和子节点
@@ -303,8 +308,8 @@ var useTree = function useTree(props) {
303
308
  return checked;
304
309
  };
305
310
  var setValue = function setValue(value) {
306
- context.value = value;
307
- if (value && value !== context.cachedValue) {
311
+ context.value = toArray(value);
312
+ if (value !== context.cachedValue) {
308
313
  initValue();
309
314
  }
310
315
  setUnmatedValue();
@@ -333,9 +338,9 @@ var useTree = function useTree(props) {
333
338
  context.valueMap = new Map();
334
339
  context.unmatchedValueMap = new Map();
335
340
  context.disabled = getDisabled();
336
- context.data = data;
341
+ context.data = toArray(data);
337
342
  if (!data) return;
338
- initData(data, []);
343
+ initData(context.data, []);
339
344
  initValue();
340
345
  setValue(prevValue);
341
346
  };
@@ -1 +1 @@
1
- {"version":3,"file":"get-rule.d.ts","sourceRoot":"","sources":["get-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAmB,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAM/C,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,KAAK,EACnC,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,EACjC,KAAK,EAAE,UAAU,GAChB,SAAS,CAAC,KAAK,CAAC,CAuGlB"}
1
+ {"version":3,"file":"get-rule.d.ts","sourceRoot":"","sources":["get-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAmB,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAO/C,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,KAAK,EACnC,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,EACjC,KAAK,EAAE,UAAU,GAChB,SAAS,CAAC,KAAK,CAAC,CAuGlB"}
@@ -8,6 +8,7 @@ var _nullable = _interopRequireDefault(require("./nullable"));
8
8
  var _is = require("../is");
9
9
  var _type = _interopRequireDefault(require("./type"));
10
10
  var _error = require("./error");
11
+ var _string = require("../string");
11
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
13
  function getRule(rule, props) {
13
14
  var po = props;
@@ -30,7 +31,7 @@ function getRule(rule, props) {
30
31
  max: max,
31
32
  args: args
32
33
  });
33
- po.message = typeof message === 'function' ? message(po) : message;
34
+ po.message = typeof message === 'function' ? message(po) : (0, _string.substitute)(message, po);
34
35
  var cb = function cb() {};
35
36
  if (func) {
36
37
  cb = function cb(value, formData, callback) {
@@ -1 +1 @@
1
- {"version":3,"file":"use-tree.d.ts","sourceRoot":"","sources":["use-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAKb,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,eAAO,MAAM,IAAI;IACf;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEJ,CAAC;AAEF,QAAA,MAAM,OAAO;;;;CA6aZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"use-tree.d.ts","sourceRoot":"","sources":["use-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAKb,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AASjD,eAAO,MAAM,IAAI;IACf;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEJ,CAAC;AAEF,QAAA,MAAM,OAAO;;;;CA6aZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -9,6 +9,11 @@ import useLatestObj from "../../common/use-latest-obj";
9
9
  import { useInputAble } from "../../common/use-input-able";
10
10
  import { usePersistFn } from "../../common/use-persist-fn";
11
11
  import { isFunc, isString, isNumber, isArray, isUnMatchedData } from "../../utils/is";
12
+ function toArray(value) {
13
+ if (!value) return [];
14
+ if (!Array.isArray(value)) return [value];
15
+ return value;
16
+ }
12
17
  export var MODE = {
13
18
  /**
14
19
  * 返回全选数据,包含父节点和子节点
@@ -296,8 +301,8 @@ var useTree = function useTree(props) {
296
301
  return checked;
297
302
  };
298
303
  var setValue = function setValue(value) {
299
- context.value = value;
300
- if (value && value !== context.cachedValue) {
304
+ context.value = toArray(value);
305
+ if (value !== context.cachedValue) {
301
306
  initValue();
302
307
  }
303
308
  setUnmatedValue();
@@ -326,9 +331,9 @@ var useTree = function useTree(props) {
326
331
  context.valueMap = new Map();
327
332
  context.unmatchedValueMap = new Map();
328
333
  context.disabled = getDisabled();
329
- context.data = data;
334
+ context.data = toArray(data);
330
335
  if (!data) return;
331
- initData(data, []);
336
+ initData(context.data, []);
332
337
  initValue();
333
338
  setValue(prevValue);
334
339
  };
@@ -1 +1 @@
1
- {"version":3,"file":"get-rule.d.ts","sourceRoot":"","sources":["get-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAmB,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAM/C,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,KAAK,EACnC,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,EACjC,KAAK,EAAE,UAAU,GAChB,SAAS,CAAC,KAAK,CAAC,CAuGlB"}
1
+ {"version":3,"file":"get-rule.d.ts","sourceRoot":"","sources":["get-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAmB,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAO/C,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,KAAK,EACnC,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,EACjC,KAAK,EAAE,UAAU,GAChB,SAAS,CAAC,KAAK,CAAC,CAuGlB"}
@@ -2,6 +2,7 @@ import nullable from "./nullable";
2
2
  import { isEmpty } from "../is";
3
3
  import typeOf from "./type";
4
4
  import { FormError } from "./error";
5
+ import { substitute } from "../string";
5
6
  export default function getRule(rule, props) {
6
7
  var po = props;
7
8
  var rulePo = rule;
@@ -23,7 +24,7 @@ export default function getRule(rule, props) {
23
24
  max: max,
24
25
  args: args
25
26
  });
26
- po.message = typeof message === 'function' ? message(po) : message;
27
+ po.message = typeof message === 'function' ? message(po) : substitute(message, po);
27
28
  var cb = function cb() {};
28
29
  if (func) {
29
30
  cb = function cb(value, formData, callback) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/hooks",
3
- "version": "3.1.18",
3
+ "version": "3.1.20",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",