@sheinx/hooks 3.1.18 → 3.1.19
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;
|
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
|
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":"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;
|
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
|
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
|
};
|