bkui-vue 0.0.1-beta.70 → 0.0.1-beta.73
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 +24 -24
- package/dist/index.esm.js +115 -25
- package/dist/index.umd.js +22 -22
- 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-node-action.d.ts +1 -0
- package/lib/tree/use-tree-init.d.ts +2 -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
|
}
|
@@ -21575,6 +21595,7 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues) => {
|
|
21575
21595
|
renderTreeNode,
|
21576
21596
|
hanldeTreeNodeClick,
|
21577
21597
|
deepAutoOpen,
|
21598
|
+
asyncNodeClick,
|
21578
21599
|
setNodeAction,
|
21579
21600
|
setNodeOpened,
|
21580
21601
|
setSelect,
|
@@ -21890,10 +21911,26 @@ var useTreeInit = (props) => {
|
|
21890
21911
|
const outputData = [];
|
21891
21912
|
let order2 = 0;
|
21892
21913
|
const schema = /* @__PURE__ */ new Map();
|
21914
|
+
function loopUpdateNodeAttr(uuid2, attrName, attrValue, callFn) {
|
21915
|
+
if (uuid2 === void 0 || uuid2 === null) {
|
21916
|
+
return;
|
21917
|
+
}
|
21918
|
+
if (schema.has(uuid2) && ![NODE_ATTRIBUTES.UUID, NODE_ATTRIBUTES.PARENT_ID].includes(attrName)) {
|
21919
|
+
const target = schema.get(uuid2);
|
21920
|
+
if (Object.prototype.hasOwnProperty.call(target, attrName)) {
|
21921
|
+
if (typeof callFn === "function" && Reflect.apply(callFn, self, [target, attrName, attrValue])) {
|
21922
|
+
Object.assign(target, {
|
21923
|
+
[attrName]: attrValue
|
21924
|
+
});
|
21925
|
+
loopUpdateNodeAttr(target[NODE_ATTRIBUTES.PARENT_ID], attrName, attrValue, callFn);
|
21926
|
+
}
|
21927
|
+
}
|
21928
|
+
}
|
21929
|
+
}
|
21893
21930
|
function getUid(item) {
|
21894
21931
|
let uid = null;
|
21895
21932
|
if (typeof props2.nodeKey === "string") {
|
21896
|
-
uid = item[props2.nodeKey];
|
21933
|
+
uid = item[props2.nodeKey] || uuid_1.v4();
|
21897
21934
|
}
|
21898
21935
|
return uid || item[NODE_ATTRIBUTES.UUID] || uuid_1.v4();
|
21899
21936
|
}
|
@@ -21903,7 +21940,7 @@ var useTreeInit = (props) => {
|
|
21903
21940
|
if (cached) {
|
21904
21941
|
result = cached[cachedAttr];
|
21905
21942
|
} else {
|
21906
|
-
result = node[attr];
|
21943
|
+
result = attr === null ? void 0 : node[attr];
|
21907
21944
|
}
|
21908
21945
|
if (result === void 0) {
|
21909
21946
|
result = defVal;
|
@@ -21920,7 +21957,16 @@ var useTreeInit = (props) => {
|
|
21920
21957
|
return getCachedTreeNodeAttr(uuid2, node, "isMatch", NODE_ATTRIBUTES.IS_MATCH, true);
|
21921
21958
|
}
|
21922
21959
|
function isCachedTreeNodeSelected(uuid2, node) {
|
21923
|
-
return getCachedTreeNodeAttr(uuid2, node,
|
21960
|
+
return getCachedTreeNodeAttr(uuid2, node, null, NODE_ATTRIBUTES.IS_SELECTED, false);
|
21961
|
+
}
|
21962
|
+
function isCachedTreeNodeHasCached(uuid2, node) {
|
21963
|
+
return getCachedTreeNodeAttr(uuid2, node, "cached", NODE_ATTRIBUTES.IS_CACHED, false);
|
21964
|
+
}
|
21965
|
+
function isCachedTreeNodeAsync(uuid2, node) {
|
21966
|
+
return getCachedTreeNodeAttr(uuid2, node, "async", NODE_ATTRIBUTES.IS_ASYNC, false);
|
21967
|
+
}
|
21968
|
+
function validateIsOpenLoopFn(target) {
|
21969
|
+
return !target[NODE_ATTRIBUTES.IS_OPENED];
|
21924
21970
|
}
|
21925
21971
|
function flatten(array, depth = 0, parent = null, path = null) {
|
21926
21972
|
const arrLength = array.length;
|
@@ -21930,7 +21976,7 @@ var useTreeInit = (props) => {
|
|
21930
21976
|
flatten(item, depth, parent, path);
|
21931
21977
|
} else {
|
21932
21978
|
if (typeof item === "object" && item !== null) {
|
21933
|
-
const uuid2 = getUid(item)
|
21979
|
+
const uuid2 = `${getUid(item)}`;
|
21934
21980
|
const currentPath = path !== null ? `${path}-${i}` : `${i}`;
|
21935
21981
|
const hasChildren = !!(item[children] || []).length;
|
21936
21982
|
const attrs = {
|
@@ -21946,6 +21992,8 @@ var useTreeInit = (props) => {
|
|
21946
21992
|
[NODE_ATTRIBUTES.IS_MATCH]: isCachedTreeNodeMatch(uuid2, item),
|
21947
21993
|
[NODE_ATTRIBUTES.IS_OPENED]: isCachedTreeNodeOpened(uuid2, item),
|
21948
21994
|
[NODE_ATTRIBUTES.IS_CHECKED]: isCachedTreeNodeChecked(uuid2, item),
|
21995
|
+
[NODE_ATTRIBUTES.IS_CACHED]: isCachedTreeNodeHasCached(uuid2, item),
|
21996
|
+
[NODE_ATTRIBUTES.IS_ASYNC]: isCachedTreeNodeAsync(uuid2, item),
|
21949
21997
|
[children]: null
|
21950
21998
|
};
|
21951
21999
|
Object.assign(item, {
|
@@ -21956,6 +22004,9 @@ var useTreeInit = (props) => {
|
|
21956
22004
|
outputData.push(__spreadProps(__spreadValues({}, item), {
|
21957
22005
|
[children]: null
|
21958
22006
|
}));
|
22007
|
+
if (attrs[NODE_ATTRIBUTES.IS_OPENED] || attrs[NODE_ATTRIBUTES.IS_SELECTED]) {
|
22008
|
+
loopUpdateNodeAttr(parent, NODE_ATTRIBUTES.IS_OPENED, true, validateIsOpenLoopFn);
|
22009
|
+
}
|
21959
22010
|
if (Object.prototype.hasOwnProperty.call(item, children)) {
|
21960
22011
|
flatten(item[children] || [], depth + 1, uuid2, currentPath);
|
21961
22012
|
}
|
@@ -21967,6 +22018,9 @@ var useTreeInit = (props) => {
|
|
21967
22018
|
return [outputData, schema];
|
21968
22019
|
};
|
21969
22020
|
const formatData = getFlatdata(props);
|
22021
|
+
const nextLoopEvents = /* @__PURE__ */ new Map();
|
22022
|
+
const afterSelectEvents = [];
|
22023
|
+
const afterSelectWatch = [];
|
21970
22024
|
const flatData = reactive({
|
21971
22025
|
data: formatData[0],
|
21972
22026
|
schema: formatData[1],
|
@@ -21977,6 +22031,25 @@ var useTreeInit = (props) => {
|
|
21977
22031
|
asyncNodeClick,
|
21978
22032
|
deepAutoOpen
|
21979
22033
|
} = useNodeAsync(props, flatData);
|
22034
|
+
const onSelected = (event) => {
|
22035
|
+
afterSelectEvents.push(event);
|
22036
|
+
};
|
22037
|
+
const registerNextLoop = (key, event, reset2 = true) => {
|
22038
|
+
if (reset2 && nextLoopEvents.has(key)) {
|
22039
|
+
nextLoopEvents.delete(key);
|
22040
|
+
}
|
22041
|
+
nextLoopEvents.set(key, event);
|
22042
|
+
};
|
22043
|
+
const executeNextEvent = () => {
|
22044
|
+
Array.from(nextLoopEvents.keys()).forEach((key) => {
|
22045
|
+
const target = nextLoopEvents.get(key);
|
22046
|
+
if (Array.isArray(target)) {
|
22047
|
+
target.forEach((event) => Reflect.apply(event, globalThis, []));
|
22048
|
+
} else {
|
22049
|
+
Reflect.apply(target, globalThis, []);
|
22050
|
+
}
|
22051
|
+
});
|
22052
|
+
};
|
21980
22053
|
watch(() => [props.data], (newData) => {
|
21981
22054
|
var _a2, _b;
|
21982
22055
|
const formatData2 = getFlatdata(props, newData, schemaValues.value);
|
@@ -21985,9 +22058,25 @@ var useTreeInit = (props) => {
|
|
21985
22058
|
if (((_a2 = props.async) == null ? void 0 : _a2.callback) && ((_b = props.async) == null ? void 0 : _b.deepAutoOpen) === "every") {
|
21986
22059
|
deepAutoOpen();
|
21987
22060
|
}
|
22061
|
+
executeNextEvent();
|
21988
22062
|
}, {
|
21989
22063
|
deep: true
|
21990
22064
|
});
|
22065
|
+
if (props.selectable) {
|
22066
|
+
watch(() => props.selected, (newData) => {
|
22067
|
+
afterSelectWatch.length = 0;
|
22068
|
+
afterSelectEvents.forEach((event) => {
|
22069
|
+
Reflect.apply(event, globalThis, [newData]);
|
22070
|
+
afterSelectWatch.push(() => Reflect.apply(event, globalThis, [newData]));
|
22071
|
+
});
|
22072
|
+
registerNextLoop("afterSelectWatch", afterSelectWatch);
|
22073
|
+
}, {
|
22074
|
+
immediate: true
|
22075
|
+
});
|
22076
|
+
}
|
22077
|
+
const afterDataUpdate = (callFn) => {
|
22078
|
+
registerNextLoop("afterDataUpdate", callFn);
|
22079
|
+
};
|
21991
22080
|
if ((_a = props.async) == null ? void 0 : _a.callback) {
|
21992
22081
|
deepAutoOpen();
|
21993
22082
|
}
|
@@ -21995,7 +22084,9 @@ var useTreeInit = (props) => {
|
|
21995
22084
|
flatData,
|
21996
22085
|
schemaValues,
|
21997
22086
|
asyncNodeClick,
|
21998
|
-
deepAutoOpen
|
22087
|
+
deepAutoOpen,
|
22088
|
+
afterDataUpdate,
|
22089
|
+
onSelected
|
21999
22090
|
};
|
22000
22091
|
};
|
22001
22092
|
var Component$2 = defineComponent({
|
@@ -22005,7 +22096,8 @@ var Component$2 = defineComponent({
|
|
22005
22096
|
setup(props, ctx) {
|
22006
22097
|
const {
|
22007
22098
|
flatData,
|
22008
|
-
schemaValues
|
22099
|
+
schemaValues,
|
22100
|
+
onSelected
|
22009
22101
|
} = useTreeInit(props);
|
22010
22102
|
const {
|
22011
22103
|
setNodeAttr,
|
@@ -22051,18 +22143,15 @@ var Component$2 = defineComponent({
|
|
22051
22143
|
setNodeOpened,
|
22052
22144
|
setOpen,
|
22053
22145
|
setNodeAction,
|
22054
|
-
setSelect
|
22146
|
+
setSelect,
|
22147
|
+
asyncNodeClick
|
22055
22148
|
} = useNodeAction(props, ctx, flatData, renderData, schemaValues);
|
22056
22149
|
const setChecked = (item, checked = true) => {
|
22057
22150
|
setNodeAction(resolveNodeItem(item), NODE_ATTRIBUTES.IS_CHECKED, checked);
|
22058
22151
|
};
|
22059
|
-
|
22060
|
-
|
22061
|
-
|
22062
|
-
}, {
|
22063
|
-
immediate: true
|
22064
|
-
});
|
22065
|
-
}
|
22152
|
+
onSelected((newData) => {
|
22153
|
+
setSelect(newData, true, true);
|
22154
|
+
});
|
22066
22155
|
const getData = () => flatData;
|
22067
22156
|
ctx.expose({
|
22068
22157
|
hanldeTreeNodeClick,
|
@@ -22076,6 +22165,7 @@ var Component$2 = defineComponent({
|
|
22076
22165
|
setNodeAction,
|
22077
22166
|
setNodeOpened,
|
22078
22167
|
setSelect,
|
22168
|
+
asyncNodeClick,
|
22079
22169
|
getData
|
22080
22170
|
});
|
22081
22171
|
const root = ref();
|