bkui-vue 0.0.1-beta.70 → 0.0.1-beta.71
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.
- package/dist/index.cjs.js +22 -22
- package/dist/index.esm.js +78 -17
- package/dist/index.umd.js +20 -20
- package/lib/table/index.js +1 -1
- package/lib/tree/constant.d.ts +3 -1
- package/lib/tree/index.d.ts +33 -11
- package/lib/tree/index.js +1 -1
- package/lib/tree/props.d.ts +6 -2
- package/lib/tree/tree.d.ts +15 -5
- package/lib/tree/use-tree-init.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
@@ -14343,7 +14343,7 @@ const useClass = (props, root, reactiveProp) => {
|
|
14343
14343
|
const resolveFooterHeight = props.pagination && props.data.length ? 40 : 0;
|
14344
14344
|
const contentHeight = resolveHeight - resolveHeadHeight - resolveFooterHeight;
|
14345
14345
|
const height = props.height !== "auto" ? `${contentHeight}px` : false;
|
14346
|
-
const maxHeight =
|
14346
|
+
const maxHeight = resolveMaxHeight - resolveHeadHeight - resolveFooterHeight;
|
14347
14347
|
const minHeight = resolveMinHeight - resolveHeadHeight - resolveFooterHeight;
|
14348
14348
|
Object.assign(contentStyle, {
|
14349
14349
|
display: "block",
|
@@ -21073,6 +21073,8 @@ var NODE_ATTRIBUTES = /* @__PURE__ */ ((NODE_ATTRIBUTES2) => {
|
|
21073
21073
|
NODE_ATTRIBUTES2["IS_ASYNC_INIT"] = "__is_async_init";
|
21074
21074
|
NODE_ATTRIBUTES2["IS_MATCH"] = "__is_match";
|
21075
21075
|
NODE_ATTRIBUTES2["IS_NULL"] = "__IS_NULL";
|
21076
|
+
NODE_ATTRIBUTES2["IS_CACHED"] = "__is_cached";
|
21077
|
+
NODE_ATTRIBUTES2["IS_ASYNC"] = "__is_async";
|
21076
21078
|
return NODE_ATTRIBUTES2;
|
21077
21079
|
})(NODE_ATTRIBUTES || {});
|
21078
21080
|
const treeProps = {
|
@@ -21121,7 +21123,7 @@ const treeProps = {
|
|
21121
21123
|
draggable: PropTypes.bool.def(false),
|
21122
21124
|
dragSort: PropTypes.bool.def(false),
|
21123
21125
|
selectable: PropTypes.bool.def(true),
|
21124
|
-
selected: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.
|
21126
|
+
selected: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).def(null)
|
21125
21127
|
};
|
21126
21128
|
var useEmpty = (props, {
|
21127
21129
|
slots
|
@@ -21297,7 +21299,7 @@ const resolveNodeItem = (node) => {
|
|
21297
21299
|
if (node === void 0 || node === null) {
|
21298
21300
|
return { __IS_NULL: true };
|
21299
21301
|
}
|
21300
|
-
if (typeof node === "string") {
|
21302
|
+
if (typeof node === "string" || typeof node === "number" || typeof node === "symbol") {
|
21301
21303
|
return { [NODE_ATTRIBUTES.UUID]: node };
|
21302
21304
|
}
|
21303
21305
|
if (Object.prototype.hasOwnProperty.call(node, NODE_ATTRIBUTES.UUID)) {
|
@@ -21317,17 +21319,20 @@ var useNodeAsync = (props, flatData) => {
|
|
21317
21319
|
setNodeAttr(item, NODE_ATTRIBUTES.IS_OPENED, true);
|
21318
21320
|
const nodeValue = Array.isArray(resp) ? resp : [resp];
|
21319
21321
|
updateTreeNode(getNodePath(item), props.data, props.children, props.children, nodeValue);
|
21322
|
+
return Promise.resolve(resp);
|
21320
21323
|
}
|
21324
|
+
return Promise.reject(resp);
|
21321
21325
|
};
|
21322
21326
|
const asyncNodeClick = (item) => {
|
21323
|
-
if (item.
|
21327
|
+
if (getNodeAttr2(item, NODE_ATTRIBUTES.IS_ASYNC)) {
|
21324
21328
|
const {
|
21325
21329
|
callback = null,
|
21326
21330
|
cache = true
|
21327
21331
|
} = props.async || {};
|
21328
21332
|
setNodeAttr(item, NODE_ATTRIBUTES.IS_ASYNC_INIT, true);
|
21329
21333
|
if (typeof callback === "function") {
|
21330
|
-
if (!item.
|
21334
|
+
if (!getNodeAttr2(item, NODE_ATTRIBUTES.IS_CACHED)) {
|
21335
|
+
setNodeAttr(item, NODE_ATTRIBUTES.IS_CACHED, cache);
|
21331
21336
|
Object.assign(item, {
|
21332
21337
|
loading: true
|
21333
21338
|
});
|
@@ -21343,6 +21348,7 @@ var useNodeAsync = (props, flatData) => {
|
|
21343
21348
|
}
|
21344
21349
|
return Promise.reject("async need to set prop: asyncLoad with function wich will return promise object");
|
21345
21350
|
}
|
21351
|
+
return Promise.resolve(true);
|
21346
21352
|
};
|
21347
21353
|
const deepAutoOpen = () => {
|
21348
21354
|
const autoOpenNodes = flatData.data.filter((item) => item.async && item.isOpen && !getNodeAttr2(item, NODE_ATTRIBUTES.IS_ASYNC_INIT));
|
@@ -21493,25 +21499,39 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
|
|
21493
21499
|
hanldeTreeNodeClick(node, e);
|
21494
21500
|
};
|
21495
21501
|
const setSelect = (uuid2, selected = true, autoOpen = true) => {
|
21496
|
-
const
|
21502
|
+
const nodeList2 = Array.isArray(uuid2) ? uuid2 : [uuid2];
|
21503
|
+
if (!nodeList2.length) {
|
21504
|
+
return;
|
21505
|
+
}
|
21506
|
+
const resolvedItem = resolveNodeItem(nodeList2[0]);
|
21497
21507
|
if (resolvedItem[NODE_ATTRIBUTES.IS_NULL]) {
|
21498
21508
|
return;
|
21499
21509
|
}
|
21500
21510
|
if (props.selectable) {
|
21501
|
-
if (selectedNodeId !== null) {
|
21511
|
+
if (selectedNodeId !== null && selectedNodeId !== void 0) {
|
21502
21512
|
setNodeAttr({
|
21503
21513
|
[NODE_ATTRIBUTES.UUID]: selectedNodeId
|
21504
21514
|
}, NODE_ATTRIBUTES.IS_SELECTED, !selected);
|
21505
21515
|
}
|
21506
21516
|
setNodeAttr(resolvedItem, NODE_ATTRIBUTES.IS_SELECTED, selected);
|
21507
21517
|
selectedNodeId = getNodeId(resolvedItem);
|
21508
|
-
|
21509
|
-
|
21510
|
-
|
21518
|
+
if (autoOpen && nodeList2.length === 1) {
|
21519
|
+
setOpen(resolvedItem, true, true);
|
21520
|
+
}
|
21521
|
+
if (getNodeAttr2(resolvedItem, NODE_ATTRIBUTES.IS_ASYNC)) {
|
21522
|
+
asyncNodeClick(resolvedItem).then(() => {
|
21523
|
+
nextTick(() => {
|
21524
|
+
nodeList2.shift();
|
21525
|
+
setSelect(nodeList2, selected, autoOpen);
|
21526
|
+
});
|
21527
|
+
});
|
21528
|
+
}
|
21529
|
+
} else {
|
21530
|
+
console.warn("props.selectable is false or undefined, please set selectable with true");
|
21511
21531
|
}
|
21512
21532
|
};
|
21513
21533
|
const handleNodeContentClick = (item, e) => {
|
21514
|
-
setSelect(item);
|
21534
|
+
setSelect(item, true, false);
|
21515
21535
|
if (!isNodeOpened(item)) {
|
21516
21536
|
hanldeTreeNodeClick(item, e);
|
21517
21537
|
}
|
@@ -21890,10 +21910,26 @@ var useTreeInit = (props) => {
|
|
21890
21910
|
const outputData = [];
|
21891
21911
|
let order2 = 0;
|
21892
21912
|
const schema = /* @__PURE__ */ new Map();
|
21913
|
+
function loopUpdateNodeAttr(uuid2, attrName, attrValue, callFn) {
|
21914
|
+
if (uuid2 === void 0 || uuid2 === null) {
|
21915
|
+
return;
|
21916
|
+
}
|
21917
|
+
if (schema.has(uuid2) && ![NODE_ATTRIBUTES.UUID, NODE_ATTRIBUTES.PARENT_ID].includes(attrName)) {
|
21918
|
+
const target = schema.get(uuid2);
|
21919
|
+
if (Object.prototype.hasOwnProperty.call(target, attrName)) {
|
21920
|
+
if (typeof callFn === "function" && Reflect.apply(callFn, self, [target, attrName, attrValue])) {
|
21921
|
+
Object.assign(target, {
|
21922
|
+
[attrName]: attrValue
|
21923
|
+
});
|
21924
|
+
loopUpdateNodeAttr(target[NODE_ATTRIBUTES.PARENT_ID], attrName, attrValue, callFn);
|
21925
|
+
}
|
21926
|
+
}
|
21927
|
+
}
|
21928
|
+
}
|
21893
21929
|
function getUid(item) {
|
21894
21930
|
let uid = null;
|
21895
21931
|
if (typeof props2.nodeKey === "string") {
|
21896
|
-
uid = item[props2.nodeKey];
|
21932
|
+
uid = item[props2.nodeKey] || uuid_1.v4();
|
21897
21933
|
}
|
21898
21934
|
return uid || item[NODE_ATTRIBUTES.UUID] || uuid_1.v4();
|
21899
21935
|
}
|
@@ -21903,7 +21939,7 @@ var useTreeInit = (props) => {
|
|
21903
21939
|
if (cached) {
|
21904
21940
|
result = cached[cachedAttr];
|
21905
21941
|
} else {
|
21906
|
-
result = node[attr];
|
21942
|
+
result = attr === null ? void 0 : node[attr];
|
21907
21943
|
}
|
21908
21944
|
if (result === void 0) {
|
21909
21945
|
result = defVal;
|
@@ -21920,7 +21956,16 @@ var useTreeInit = (props) => {
|
|
21920
21956
|
return getCachedTreeNodeAttr(uuid2, node, "isMatch", NODE_ATTRIBUTES.IS_MATCH, true);
|
21921
21957
|
}
|
21922
21958
|
function isCachedTreeNodeSelected(uuid2, node) {
|
21923
|
-
return getCachedTreeNodeAttr(uuid2, node,
|
21959
|
+
return getCachedTreeNodeAttr(uuid2, node, null, NODE_ATTRIBUTES.IS_SELECTED, false);
|
21960
|
+
}
|
21961
|
+
function isCachedTreeNodeHasCached(uuid2, node) {
|
21962
|
+
return getCachedTreeNodeAttr(uuid2, node, "cached", NODE_ATTRIBUTES.IS_CACHED, false);
|
21963
|
+
}
|
21964
|
+
function isCachedTreeNodeAsync(uuid2, node) {
|
21965
|
+
return getCachedTreeNodeAttr(uuid2, node, "async", NODE_ATTRIBUTES.IS_ASYNC, false);
|
21966
|
+
}
|
21967
|
+
function validateIsOpenLoopFn(target) {
|
21968
|
+
return !target[NODE_ATTRIBUTES.IS_OPENED];
|
21924
21969
|
}
|
21925
21970
|
function flatten(array, depth = 0, parent = null, path = null) {
|
21926
21971
|
const arrLength = array.length;
|
@@ -21946,6 +21991,8 @@ var useTreeInit = (props) => {
|
|
21946
21991
|
[NODE_ATTRIBUTES.IS_MATCH]: isCachedTreeNodeMatch(uuid2, item),
|
21947
21992
|
[NODE_ATTRIBUTES.IS_OPENED]: isCachedTreeNodeOpened(uuid2, item),
|
21948
21993
|
[NODE_ATTRIBUTES.IS_CHECKED]: isCachedTreeNodeChecked(uuid2, item),
|
21994
|
+
[NODE_ATTRIBUTES.IS_CACHED]: isCachedTreeNodeHasCached(uuid2, item),
|
21995
|
+
[NODE_ATTRIBUTES.IS_ASYNC]: isCachedTreeNodeAsync(uuid2, item),
|
21949
21996
|
[children]: null
|
21950
21997
|
};
|
21951
21998
|
Object.assign(item, {
|
@@ -21956,6 +22003,9 @@ var useTreeInit = (props) => {
|
|
21956
22003
|
outputData.push(__spreadProps(__spreadValues({}, item), {
|
21957
22004
|
[children]: null
|
21958
22005
|
}));
|
22006
|
+
if (attrs[NODE_ATTRIBUTES.IS_OPENED] || attrs[NODE_ATTRIBUTES.IS_SELECTED]) {
|
22007
|
+
loopUpdateNodeAttr(parent, NODE_ATTRIBUTES.IS_OPENED, true, validateIsOpenLoopFn);
|
22008
|
+
}
|
21959
22009
|
if (Object.prototype.hasOwnProperty.call(item, children)) {
|
21960
22010
|
flatten(item[children] || [], depth + 1, uuid2, currentPath);
|
21961
22011
|
}
|
@@ -21967,6 +22017,7 @@ var useTreeInit = (props) => {
|
|
21967
22017
|
return [outputData, schema];
|
21968
22018
|
};
|
21969
22019
|
const formatData = getFlatdata(props);
|
22020
|
+
const loopEvents = [];
|
21970
22021
|
const flatData = reactive({
|
21971
22022
|
data: formatData[0],
|
21972
22023
|
schema: formatData[1],
|
@@ -21985,9 +22036,17 @@ var useTreeInit = (props) => {
|
|
21985
22036
|
if (((_a2 = props.async) == null ? void 0 : _a2.callback) && ((_b = props.async) == null ? void 0 : _b.deepAutoOpen) === "every") {
|
21986
22037
|
deepAutoOpen();
|
21987
22038
|
}
|
22039
|
+
nextTick(() => {
|
22040
|
+
loopEvents.forEach((event) => {
|
22041
|
+
Reflect.apply(event, globalThis, []);
|
22042
|
+
});
|
22043
|
+
});
|
21988
22044
|
}, {
|
21989
22045
|
deep: true
|
21990
22046
|
});
|
22047
|
+
const afterDataUpdate = (callFn) => {
|
22048
|
+
loopEvents.push(callFn);
|
22049
|
+
};
|
21991
22050
|
if ((_a = props.async) == null ? void 0 : _a.callback) {
|
21992
22051
|
deepAutoOpen();
|
21993
22052
|
}
|
@@ -21995,7 +22054,8 @@ var useTreeInit = (props) => {
|
|
21995
22054
|
flatData,
|
21996
22055
|
schemaValues,
|
21997
22056
|
asyncNodeClick,
|
21998
|
-
deepAutoOpen
|
22057
|
+
deepAutoOpen,
|
22058
|
+
afterDataUpdate
|
21999
22059
|
};
|
22000
22060
|
};
|
22001
22061
|
var Component$2 = defineComponent({
|
@@ -22005,7 +22065,8 @@ var Component$2 = defineComponent({
|
|
22005
22065
|
setup(props, ctx) {
|
22006
22066
|
const {
|
22007
22067
|
flatData,
|
22008
|
-
schemaValues
|
22068
|
+
schemaValues,
|
22069
|
+
afterDataUpdate
|
22009
22070
|
} = useTreeInit(props);
|
22010
22071
|
const {
|
22011
22072
|
setNodeAttr,
|
@@ -22058,7 +22119,7 @@ var Component$2 = defineComponent({
|
|
22058
22119
|
};
|
22059
22120
|
if (props.selectable) {
|
22060
22121
|
watch(() => props.selected, (newData) => {
|
22061
|
-
setSelect(newData, true, true);
|
22122
|
+
afterDataUpdate(() => setSelect(newData, true, true));
|
22062
22123
|
}, {
|
22063
22124
|
immediate: true
|
22064
22125
|
});
|