bkui-vue 2.1.0-dev-beta.14 → 2.1.0-dev-beta.16
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 +46 -46
- package/dist/index.esm.js +6762 -6779
- package/dist/index.umd.js +48 -48
- package/lib/index.js +1 -1
- package/lib/popover/index.js +50 -63
- package/lib/popover/props.d.ts +1 -1
- package/lib/tree/index.js +97 -67
- package/lib/tree/use-search.d.ts +3 -3
- package/package.json +1 -1
package/lib/index.js
CHANGED
package/lib/popover/index.js
CHANGED
|
@@ -3191,7 +3191,7 @@ var PopoverProps = {
|
|
|
3191
3191
|
*/
|
|
3192
3192
|
referenceCls: shared_namespaceObject.PropTypes.string.def(''),
|
|
3193
3193
|
/**
|
|
3194
|
-
* 是否渲染默认插槽最外层 reference span
|
|
3194
|
+
* 是否渲染默认插槽最外层 reference span;仅 true 时主动追加 span
|
|
3195
3195
|
*/
|
|
3196
3196
|
renderReferenceWrapper: shared_namespaceObject.PropTypes.bool.def(undefined),
|
|
3197
3197
|
/**
|
|
@@ -3363,15 +3363,9 @@ var EMIT_EVENTS = {
|
|
|
3363
3363
|
target = _toRefs.target,
|
|
3364
3364
|
floatingReference = _toRefs.floatingReference,
|
|
3365
3365
|
renderReferenceWrapper = _toRefs.renderReferenceWrapper;
|
|
3366
|
-
var
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
}
|
|
3370
|
-
var globalValue = globalConfig.value.popoverRenderReferenceWrapper;
|
|
3371
|
-
if (globalValue !== undefined) {
|
|
3372
|
-
return globalValue === false;
|
|
3373
|
-
}
|
|
3374
|
-
return false;
|
|
3366
|
+
var shouldRenderReferenceWrapper = (0,external_vue_namespaceObject.computed)(function () {
|
|
3367
|
+
var _renderReferenceWrapp;
|
|
3368
|
+
return ((_renderReferenceWrapp = renderReferenceWrapper.value) !== null && _renderReferenceWrapp !== void 0 ? _renderReferenceWrapp : globalConfig.value.popoverRenderReferenceWrapper) === true;
|
|
3375
3369
|
});
|
|
3376
3370
|
var setReferenceRef = function setReferenceRef(refValue) {
|
|
3377
3371
|
referenceWrapperRef.value = refValue;
|
|
@@ -3484,33 +3478,11 @@ var EMIT_EVENTS = {
|
|
|
3484
3478
|
/**
|
|
3485
3479
|
* 解析默认 slot reference 元素
|
|
3486
3480
|
*
|
|
3487
|
-
* referenceWrapperRef
|
|
3488
|
-
*
|
|
3489
|
-
*
|
|
3490
|
-
* 策略:优先使用第一个元素子节点作为 reference;否则向下寻找第一个具有可见尺寸的 HTMLElement。
|
|
3481
|
+
* referenceWrapperRef 在 wrapper 开启时指向外层 span,
|
|
3482
|
+
* wrapper 关闭时指向默认 slot 的实际元素。
|
|
3491
3483
|
*/
|
|
3492
3484
|
var resolveDefaultReferenceElement = function resolveDefaultReferenceElement() {
|
|
3493
|
-
|
|
3494
|
-
if (!wrapper) return null;
|
|
3495
|
-
if (isReferenceWrapperDisabled.value) {
|
|
3496
|
-
return wrapper;
|
|
3497
|
-
}
|
|
3498
|
-
// display: contents 的元素自身尺寸为 0,直接查找子元素
|
|
3499
|
-
var firstChild = wrapper.firstElementChild;
|
|
3500
|
-
if (firstChild instanceof HTMLElement) {
|
|
3501
|
-
return firstChild;
|
|
3502
|
-
}
|
|
3503
|
-
var descendants = wrapper.querySelectorAll('*');
|
|
3504
|
-
for (var _i = 0, _Array$from = Array.from(descendants); _i < _Array$from.length; _i++) {
|
|
3505
|
-
var node = _Array$from[_i];
|
|
3506
|
-
if (!(node instanceof HTMLElement)) continue;
|
|
3507
|
-
var rect = node.getBoundingClientRect();
|
|
3508
|
-
if (rect.width > 0 || rect.height > 0) {
|
|
3509
|
-
return node;
|
|
3510
|
-
}
|
|
3511
|
-
}
|
|
3512
|
-
// 兜底仍返回 wrapper,保证类型与行为一致
|
|
3513
|
-
return wrapper;
|
|
3485
|
+
return resolveReferenceRefElement(referenceWrapperRef.value);
|
|
3514
3486
|
};
|
|
3515
3487
|
// 延迟控制
|
|
3516
3488
|
var delayOptions = (0,external_vue_namespaceObject.computed)(function () {
|
|
@@ -3601,7 +3573,7 @@ var EMIT_EVENTS = {
|
|
|
3601
3573
|
return target.value;
|
|
3602
3574
|
}, function () {
|
|
3603
3575
|
return floatingReference.value;
|
|
3604
|
-
}], function () {
|
|
3576
|
+
}, shouldRenderReferenceWrapper], function () {
|
|
3605
3577
|
(0,external_vue_namespaceObject.nextTick)(updateFloatingReference);
|
|
3606
3578
|
});
|
|
3607
3579
|
(0,external_vue_namespaceObject.watch)(isOpen, function (val) {
|
|
@@ -3655,7 +3627,7 @@ var EMIT_EVENTS = {
|
|
|
3655
3627
|
};
|
|
3656
3628
|
var bindNoWrapperReferenceEvents = function bindNoWrapperReferenceEvents() {
|
|
3657
3629
|
clearNoWrapperReferenceEvents();
|
|
3658
|
-
if (
|
|
3630
|
+
if (shouldRenderReferenceWrapper.value) return;
|
|
3659
3631
|
var referenceEl = resolveReferenceRefElement(referenceWrapperRef.value);
|
|
3660
3632
|
if (!referenceEl) return;
|
|
3661
3633
|
Object.keys(referenceListeners.value).forEach(function (eventName) {
|
|
@@ -3667,7 +3639,7 @@ var EMIT_EVENTS = {
|
|
|
3667
3639
|
});
|
|
3668
3640
|
});
|
|
3669
3641
|
};
|
|
3670
|
-
(0,external_vue_namespaceObject.watch)([
|
|
3642
|
+
(0,external_vue_namespaceObject.watch)([shouldRenderReferenceWrapper, referenceWrapperRef, function () {
|
|
3671
3643
|
return referenceListeners.value;
|
|
3672
3644
|
}], function () {
|
|
3673
3645
|
(0,external_vue_namespaceObject.nextTick)(bindNoWrapperReferenceEvents);
|
|
@@ -3684,7 +3656,7 @@ var EMIT_EVENTS = {
|
|
|
3684
3656
|
var isTargetInSelfOrChildren = function isTargetInSelfOrChildren(targetEl) {
|
|
3685
3657
|
var _floatingRef$value;
|
|
3686
3658
|
var actualRef = floatingReferenceRef.value;
|
|
3687
|
-
var referenceWrapperEl =
|
|
3659
|
+
var referenceWrapperEl = shouldRenderReferenceWrapper.value ? resolveReferenceRefElement(referenceWrapperRef.value) : null;
|
|
3688
3660
|
if (actualRef instanceof HTMLElement && actualRef.contains(targetEl) || referenceWrapperEl instanceof HTMLElement && referenceWrapperEl.contains(targetEl)) {
|
|
3689
3661
|
return true;
|
|
3690
3662
|
}
|
|
@@ -3797,6 +3769,17 @@ var EMIT_EVENTS = {
|
|
|
3797
3769
|
var dataTheme = (0,external_vue_namespaceObject.computed)(function () {
|
|
3798
3770
|
return theme.value;
|
|
3799
3771
|
});
|
|
3772
|
+
// 兼容旧版自定义 theme 标记:theme="light bk-table-settings"
|
|
3773
|
+
// 除了追加 bk-table-settings class 外,还需要生成 data-bk-table-settings-theme="true",
|
|
3774
|
+
// table settings 等组件的弹层样式依赖该属性选择器。
|
|
3775
|
+
var extraThemeAttrs = (0,external_vue_namespaceObject.computed)(function () {
|
|
3776
|
+
var _parseTheme2 = parseTheme(theme.value),
|
|
3777
|
+
extraClasses = _parseTheme2.extraClasses;
|
|
3778
|
+
return extraClasses.reduce(function (attrs, className) {
|
|
3779
|
+
attrs["data-".concat(className, "-theme")] = 'true';
|
|
3780
|
+
return attrs;
|
|
3781
|
+
}, {});
|
|
3782
|
+
});
|
|
3800
3783
|
var _filterEmptyNodes = function filterEmptyNodes() {
|
|
3801
3784
|
var children = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
3802
3785
|
var nodes = [];
|
|
@@ -3819,11 +3802,6 @@ var EMIT_EVENTS = {
|
|
|
3819
3802
|
return !(child && (child.type === external_vue_namespaceObject.Comment || child.type === external_vue_namespaceObject.Fragment && Array.isArray(child.children) && child.children.length === 0 || child.type === external_vue_namespaceObject.Text && "".concat((_child$children = child.children) !== null && _child$children !== void 0 ? _child$children : '').trim() === ''));
|
|
3820
3803
|
});
|
|
3821
3804
|
};
|
|
3822
|
-
var hasElementNode = function hasElementNode(nodes) {
|
|
3823
|
-
return nodes.some(function (node) {
|
|
3824
|
-
return node.type !== external_vue_namespaceObject.Text && node.type !== external_vue_namespaceObject.Comment;
|
|
3825
|
-
});
|
|
3826
|
-
};
|
|
3827
3805
|
// 处理 clickoutside
|
|
3828
3806
|
var handleClickOutside = function handleClickOutside(event) {
|
|
3829
3807
|
var _floatingRef$value2;
|
|
@@ -3837,7 +3815,7 @@ var EMIT_EVENTS = {
|
|
|
3837
3815
|
var target = event.target;
|
|
3838
3816
|
// 点击在 reference 内(包括自定义 reference 和默认 reference)
|
|
3839
3817
|
var actualRef = floatingReferenceRef.value;
|
|
3840
|
-
var referenceWrapperEl =
|
|
3818
|
+
var referenceWrapperEl = shouldRenderReferenceWrapper.value ? resolveReferenceRefElement(referenceWrapperRef.value) : null;
|
|
3841
3819
|
var isInReference = actualRef instanceof HTMLElement && actualRef.contains(target) || referenceWrapperEl instanceof HTMLElement && referenceWrapperEl.contains(target);
|
|
3842
3820
|
if (isInReference) {
|
|
3843
3821
|
// 对于 click 和 hover 模式,点击 reference 的行为由 referenceListeners 处理
|
|
@@ -3973,7 +3951,7 @@ var EMIT_EVENTS = {
|
|
|
3973
3951
|
id: popoverId,
|
|
3974
3952
|
floatingEl: floatingRef.value,
|
|
3975
3953
|
referenceEl: referenceEl,
|
|
3976
|
-
referenceWrapperEl:
|
|
3954
|
+
referenceWrapperEl: shouldRenderReferenceWrapper.value ? resolveReferenceRefElement(referenceWrapperRef.value) : null
|
|
3977
3955
|
});
|
|
3978
3956
|
};
|
|
3979
3957
|
(0,external_vue_namespaceObject.watch)([floatingRef, floatingReferenceRef, referenceWrapperRef], function () {
|
|
@@ -4035,7 +4013,8 @@ var EMIT_EVENTS = {
|
|
|
4035
4013
|
"class": contentClass.value,
|
|
4036
4014
|
"data-arrow": arrowSide.value,
|
|
4037
4015
|
"data-bk-popover-id": popoverId,
|
|
4038
|
-
"data-theme": dataTheme.value
|
|
4016
|
+
"data-theme": dataTheme.value
|
|
4017
|
+
}, extraThemeAttrs.value, {
|
|
4039
4018
|
"onClick": handleClickContent
|
|
4040
4019
|
}, guardedFloatingListeners.value), [arrow.value && (0,external_vue_namespaceObject.createVNode)("div", {
|
|
4041
4020
|
"ref": arrowRef,
|
|
@@ -4059,13 +4038,10 @@ var EMIT_EVENTS = {
|
|
|
4059
4038
|
}
|
|
4060
4039
|
var defaultSlotNodes = (_slots$default = (_slots$default2 = slots["default"]) === null || _slots$default2 === void 0 ? void 0 : _slots$default2.call(slots)) !== null && _slots$default !== void 0 ? _slots$default : [];
|
|
4061
4040
|
var referenceNodes = _filterEmptyNodes(defaultSlotNodes);
|
|
4062
|
-
|
|
4063
|
-
if (!isReferenceWrapperDisabled.value) {
|
|
4041
|
+
if (shouldRenderReferenceWrapper.value) {
|
|
4064
4042
|
return (0,external_vue_namespaceObject.createVNode)(external_vue_namespaceObject.Fragment, null, [(0,external_vue_namespaceObject.createVNode)("span", (0,external_vue_namespaceObject.mergeProps)({
|
|
4065
4043
|
"ref": referenceWrapperRef,
|
|
4066
|
-
"style":
|
|
4067
|
-
display: 'contents'
|
|
4068
|
-
} : {
|
|
4044
|
+
"style": {
|
|
4069
4045
|
display: 'inline-block'
|
|
4070
4046
|
},
|
|
4071
4047
|
"class": [referenceCls.value, attrs["class"]]
|
|
@@ -4075,25 +4051,36 @@ var EMIT_EVENTS = {
|
|
|
4075
4051
|
if (!referenceNodes.length) {
|
|
4076
4052
|
return null;
|
|
4077
4053
|
}
|
|
4078
|
-
//
|
|
4079
|
-
//
|
|
4080
|
-
|
|
4054
|
+
// 默认无包裹模式:保持 Fragment 根结构,不主动追加任何具体 DOM。
|
|
4055
|
+
// 为了兼容定位与触发事件,尽可能把 ref/class 透传到第一个非文本 reference 节点。
|
|
4056
|
+
// 但纯文本 slot 没有可承载 ref 和监听器的 DOM 节点,需要生成一个 span 作为触发元素。
|
|
4057
|
+
var isTextReference = referenceNodes.every(function (node) {
|
|
4058
|
+
return (0,external_vue_namespaceObject.isVNode)(node) && node.type === external_vue_namespaceObject.Text;
|
|
4059
|
+
});
|
|
4060
|
+
if (isTextReference) {
|
|
4081
4061
|
return (0,external_vue_namespaceObject.createVNode)("span", {
|
|
4082
|
-
"ref":
|
|
4062
|
+
"ref": referenceWrapperRef,
|
|
4083
4063
|
"style": {
|
|
4084
4064
|
display: 'inline-block'
|
|
4085
4065
|
},
|
|
4086
4066
|
"class": [referenceCls.value, attrs["class"]]
|
|
4087
4067
|
}, [referenceNodes]);
|
|
4088
4068
|
}
|
|
4089
|
-
var
|
|
4090
|
-
|
|
4091
|
-
|
|
4069
|
+
var referenceNodeIndex = referenceNodes.findIndex(function (node) {
|
|
4070
|
+
return (0,external_vue_namespaceObject.isVNode)(node) && node.type !== external_vue_namespaceObject.Text && node.type !== external_vue_namespaceObject.Comment;
|
|
4071
|
+
});
|
|
4072
|
+
if (referenceNodeIndex < 0) {
|
|
4073
|
+
return referenceNodes;
|
|
4092
4074
|
}
|
|
4093
|
-
return
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4075
|
+
return referenceNodes.map(function (node, index) {
|
|
4076
|
+
if (index !== referenceNodeIndex || !(0,external_vue_namespaceObject.isVNode)(node)) {
|
|
4077
|
+
return node;
|
|
4078
|
+
}
|
|
4079
|
+
return (0,external_vue_namespaceObject.cloneVNode)(node, {
|
|
4080
|
+
ref: setReferenceRef,
|
|
4081
|
+
"class": [referenceCls.value, attrs["class"]]
|
|
4082
|
+
}, true);
|
|
4083
|
+
});
|
|
4097
4084
|
};
|
|
4098
4085
|
// 默认情况:渲染 reference 和 floating content
|
|
4099
4086
|
return (0,external_vue_namespaceObject.createVNode)(external_vue_namespaceObject.Fragment, null, [renderReferenceNode(), renderTeleport()]);
|
package/lib/popover/props.d.ts
CHANGED
|
@@ -181,7 +181,7 @@ export declare const PopoverProps: {
|
|
|
181
181
|
default: string;
|
|
182
182
|
};
|
|
183
183
|
/**
|
|
184
|
-
* 是否渲染默认插槽最外层 reference span
|
|
184
|
+
* 是否渲染默认插槽最外层 reference span;仅 true 时主动追加 span
|
|
185
185
|
*/
|
|
186
186
|
renderReferenceWrapper: import("vue-types").VueTypeValidableDef<boolean> & {
|
|
187
187
|
default: boolean;
|
package/lib/tree/index.js
CHANGED
|
@@ -19871,64 +19871,75 @@ var use_search_this = undefined;
|
|
|
19871
19871
|
*/
|
|
19872
19872
|
|
|
19873
19873
|
/* harmony default export */ const use_search = (function (props) {
|
|
19874
|
-
var _props$search;
|
|
19875
19874
|
var refSearch = (0,external_vue_namespaceObject.toRef)(props, 'search');
|
|
19876
|
-
var _ref = (_props$search = props.search) !== null && _props$search !== void 0 ? _props$search : {},
|
|
19877
|
-
_ref$resultType = _ref.resultType,
|
|
19878
|
-
resultType = _ref$resultType === void 0 ? 'tree' : _ref$resultType,
|
|
19879
|
-
_ref$showChildNodes = _ref.showChildNodes,
|
|
19880
|
-
showChildNodes = _ref$showChildNodes === void 0 ? true : _ref$showChildNodes;
|
|
19881
19875
|
var isCommonType = function isCommonType(val) {
|
|
19882
19876
|
return ['string', 'number', 'boolean'].includes(_typeof(val));
|
|
19883
19877
|
};
|
|
19884
|
-
var
|
|
19878
|
+
var exactMatch = function exactMatch(matchValue, itemValue) {
|
|
19885
19879
|
return matchValue === itemValue;
|
|
19886
19880
|
};
|
|
19887
|
-
var
|
|
19888
|
-
|
|
19881
|
+
var fuzzyMatch = function fuzzyMatch(matchValue, itemValue) {
|
|
19882
|
+
try {
|
|
19883
|
+
return new RegExp("".concat(matchValue), 'i').test("".concat(itemValue));
|
|
19884
|
+
} catch (_unused) {
|
|
19885
|
+
return "".concat(itemValue).toLowerCase().includes("".concat(matchValue).toLowerCase());
|
|
19886
|
+
}
|
|
19889
19887
|
};
|
|
19890
19888
|
var matchFn = function matchFn(match, args) {
|
|
19891
19889
|
return Reflect.apply(match, use_search_this, args);
|
|
19892
19890
|
};
|
|
19893
|
-
var isSearchDisabled =
|
|
19894
|
-
|
|
19895
|
-
|
|
19896
|
-
|
|
19891
|
+
var isSearchDisabled = (0,external_vue_namespaceObject.computed)(function () {
|
|
19892
|
+
return refSearch.value === undefined || refSearch.value === false;
|
|
19893
|
+
});
|
|
19894
|
+
var searchOption = (0,external_vue_namespaceObject.computed)(function () {
|
|
19895
|
+
if (refSearch.value && _typeof(refSearch.value) === 'object') {
|
|
19896
|
+
return refSearch.value;
|
|
19897
19897
|
}
|
|
19898
|
+
var emptyOption = {
|
|
19899
|
+
value: ''
|
|
19900
|
+
};
|
|
19901
|
+
return emptyOption;
|
|
19902
|
+
});
|
|
19903
|
+
var resultType = (0,external_vue_namespaceObject.computed)(function () {
|
|
19904
|
+
var _searchOption$value$r;
|
|
19905
|
+
return (_searchOption$value$r = searchOption.value.resultType) !== null && _searchOption$value$r !== void 0 ? _searchOption$value$r : 'tree';
|
|
19906
|
+
});
|
|
19907
|
+
var showChildNodes = (0,external_vue_namespaceObject.computed)(function () {
|
|
19908
|
+
var _searchOption$value$s;
|
|
19909
|
+
return (_searchOption$value$s = searchOption.value.showChildNodes) !== null && _searchOption$value$s !== void 0 ? _searchOption$value$s : false;
|
|
19910
|
+
});
|
|
19911
|
+
var getSearchValue = function getSearchValue() {
|
|
19912
|
+
var _searchOption$value$v;
|
|
19898
19913
|
if (isCommonType(refSearch.value)) {
|
|
19899
|
-
|
|
19900
|
-
return false;
|
|
19901
|
-
}
|
|
19902
|
-
return matchFn(regMatch, [refSearch.value, itemValue, item]);
|
|
19914
|
+
return refSearch.value;
|
|
19903
19915
|
}
|
|
19904
|
-
|
|
19905
|
-
|
|
19906
|
-
|
|
19907
|
-
|
|
19908
|
-
|
|
19909
|
-
|
|
19910
|
-
var
|
|
19916
|
+
return (_searchOption$value$v = searchOption.value.value) !== null && _searchOption$value$v !== void 0 ? _searchOption$value$v : '';
|
|
19917
|
+
};
|
|
19918
|
+
var searchFn = function searchFn(itemValue, item) {
|
|
19919
|
+
if (isSearchDisabled.value) {
|
|
19920
|
+
return true;
|
|
19921
|
+
}
|
|
19922
|
+
var value = getSearchValue();
|
|
19911
19923
|
if ("".concat(value).length === 0) {
|
|
19912
19924
|
return false;
|
|
19913
19925
|
}
|
|
19926
|
+
if (isCommonType(refSearch.value)) {
|
|
19927
|
+
return matchFn(fuzzyMatch, [value, itemValue, item]);
|
|
19928
|
+
}
|
|
19929
|
+
var _searchOption$value$m = searchOption.value.match,
|
|
19930
|
+
match = _searchOption$value$m === void 0 ? 'fuzzy' : _searchOption$value$m;
|
|
19931
|
+
var defaultMatch = match === 'fuzzy' ? fuzzyMatch : exactMatch;
|
|
19932
|
+
var matchCallback = typeof match === 'function' ? match : defaultMatch;
|
|
19914
19933
|
return matchFn(matchCallback, [value, itemValue, item]);
|
|
19915
19934
|
};
|
|
19916
19935
|
var isSearchActive = (0,external_vue_namespaceObject.computed)(function () {
|
|
19917
|
-
if (
|
|
19936
|
+
if (isSearchDisabled.value) {
|
|
19918
19937
|
return false;
|
|
19919
19938
|
}
|
|
19920
|
-
|
|
19921
|
-
return "".concat(refSearch.value).length > 0;
|
|
19922
|
-
}
|
|
19923
|
-
var _refSearch$value$valu2 = refSearch.value.value,
|
|
19924
|
-
value = _refSearch$value$valu2 === void 0 ? '' : _refSearch$value$valu2;
|
|
19925
|
-
return "".concat(value).length > 0;
|
|
19939
|
+
return "".concat(getSearchValue()).length > 0;
|
|
19926
19940
|
});
|
|
19927
|
-
/**
|
|
19928
|
-
* 索索结果展示为Tree
|
|
19929
|
-
*/
|
|
19930
19941
|
var isTreeUI = (0,external_vue_namespaceObject.computed)(function () {
|
|
19931
|
-
return resultType === 'tree';
|
|
19942
|
+
return resultType.value === 'tree';
|
|
19932
19943
|
});
|
|
19933
19944
|
return {
|
|
19934
19945
|
searchFn: searchFn,
|
|
@@ -20491,7 +20502,6 @@ var use_tree_init_this = undefined;
|
|
|
20491
20502
|
isNodeChecked = _useNodeAttribute.isNodeChecked,
|
|
20492
20503
|
isNodeMatched = _useNodeAttribute.isNodeMatched,
|
|
20493
20504
|
hasChildNode = _useNodeAttribute.hasChildNode,
|
|
20494
|
-
getNodePath = _useNodeAttribute.getNodePath,
|
|
20495
20505
|
getNodeId = _useNodeAttribute.getNodeId,
|
|
20496
20506
|
getNodeAttr = _useNodeAttribute.getNodeAttr,
|
|
20497
20507
|
getNodeById = _useNodeAttribute.getNodeById,
|
|
@@ -20504,28 +20514,31 @@ var use_tree_init_this = undefined;
|
|
|
20504
20514
|
refSearch = _useSearch.refSearch,
|
|
20505
20515
|
isSearchDisabled = _useSearch.isSearchDisabled,
|
|
20506
20516
|
isTreeUI = _useSearch.isTreeUI,
|
|
20517
|
+
resultType = _useSearch.resultType,
|
|
20507
20518
|
showChildNodes = _useSearch.showChildNodes;
|
|
20508
|
-
var
|
|
20519
|
+
var matchedNodeIds = (0,external_vue_namespaceObject.reactive)(new Set());
|
|
20520
|
+
var visibleNodeIds = (0,external_vue_namespaceObject.reactive)(new Set());
|
|
20521
|
+
var getRenderNodeId = function getRenderNodeId(node) {
|
|
20522
|
+
return "".concat(getNodeId(node));
|
|
20523
|
+
};
|
|
20524
|
+
var addAncestorNodes = function addAncestorNodes(node) {
|
|
20525
|
+
var parent = getParentNode(node);
|
|
20526
|
+
while (parent) {
|
|
20527
|
+
visibleNodeIds.add(getRenderNodeId(parent));
|
|
20528
|
+
parent = getParentNode(parent);
|
|
20529
|
+
}
|
|
20530
|
+
};
|
|
20531
|
+
var _addDescendantNodes = function addDescendantNodes(node) {
|
|
20532
|
+
var _flatData$childMap$ge, _flatData$childMap;
|
|
20533
|
+
var children = (_flatData$childMap$ge = (_flatData$childMap = flatData.childMap) === null || _flatData$childMap === void 0 ? void 0 : _flatData$childMap.get(node)) !== null && _flatData$childMap$ge !== void 0 ? _flatData$childMap$ge : [];
|
|
20534
|
+
children.forEach(function (child) {
|
|
20535
|
+
visibleNodeIds.add(getRenderNodeId(child));
|
|
20536
|
+
_addDescendantNodes(child);
|
|
20537
|
+
});
|
|
20538
|
+
};
|
|
20509
20539
|
var filterFn = function filterFn(item) {
|
|
20510
20540
|
if (isSearchActive.value) {
|
|
20511
|
-
|
|
20512
|
-
var _getNodePath;
|
|
20513
|
-
var itemPath = (_getNodePath = getNodePath(item)) !== null && _getNodePath !== void 0 ? _getNodePath : '';
|
|
20514
|
-
var asParentPath = "".concat(itemPath, "-");
|
|
20515
|
-
var isNodeOpen = checkNodeIsOpen(item);
|
|
20516
|
-
var isNodeMatch = isNodeMatched(item);
|
|
20517
|
-
var isNodeRoot = isRootNode(item);
|
|
20518
|
-
if (isNodeOpen) {
|
|
20519
|
-
if (isNodeRoot) {
|
|
20520
|
-
return isNodeMatch;
|
|
20521
|
-
}
|
|
20522
|
-
return isNodeMatch || matchedNodePath.some(function (path) {
|
|
20523
|
-
return asParentPath.indexOf("".concat(path, "-")) === 0;
|
|
20524
|
-
});
|
|
20525
|
-
}
|
|
20526
|
-
return false;
|
|
20527
|
-
}
|
|
20528
|
-
return checkNodeIsOpen(item) && isNodeMatched(item);
|
|
20541
|
+
return visibleNodeIds.has(getRenderNodeId(item));
|
|
20529
20542
|
}
|
|
20530
20543
|
return checkNodeIsOpen(item);
|
|
20531
20544
|
};
|
|
@@ -20619,23 +20632,40 @@ var use_tree_init_this = undefined;
|
|
|
20619
20632
|
deepUpdateChildNode = _useNodeAction.deepUpdateChildNode,
|
|
20620
20633
|
updateParentChecked = _useNodeAction.updateParentChecked;
|
|
20621
20634
|
var handleSearch = (0,shared_namespaceObject.debounce)(120, function () {
|
|
20622
|
-
|
|
20635
|
+
matchedNodeIds.clear();
|
|
20636
|
+
visibleNodeIds.clear();
|
|
20623
20637
|
flatData.data.forEach(function (item) {
|
|
20624
|
-
var isMatch = searchFn(getLabel(item, props), item);
|
|
20638
|
+
var isMatch = !isSearchDisabled.value && searchFn(getLabel(item, props), item);
|
|
20639
|
+
var nodeId = getRenderNodeId(item);
|
|
20625
20640
|
if (isMatch) {
|
|
20626
|
-
|
|
20641
|
+
matchedNodeIds.add(nodeId);
|
|
20642
|
+
visibleNodeIds.add(nodeId);
|
|
20627
20643
|
}
|
|
20628
|
-
setNodeAttribute(item, [NODE_ATTRIBUTES.IS_MATCH], [isMatch],
|
|
20644
|
+
setNodeAttribute(item, [NODE_ATTRIBUTES.IS_MATCH], [isMatch], false);
|
|
20629
20645
|
});
|
|
20630
|
-
|
|
20631
|
-
|
|
20632
|
-
|
|
20633
|
-
|
|
20634
|
-
|
|
20635
|
-
|
|
20636
|
-
|
|
20646
|
+
if (!isSearchActive.value) {
|
|
20647
|
+
return;
|
|
20648
|
+
}
|
|
20649
|
+
flatData.data.forEach(function (item) {
|
|
20650
|
+
if (!matchedNodeIds.has(getRenderNodeId(item))) {
|
|
20651
|
+
return;
|
|
20652
|
+
}
|
|
20653
|
+
if (resultType.value === 'tree') {
|
|
20654
|
+
addAncestorNodes(item);
|
|
20655
|
+
}
|
|
20656
|
+
if (showChildNodes.value) {
|
|
20657
|
+
_addDescendantNodes(item);
|
|
20658
|
+
}
|
|
20637
20659
|
});
|
|
20638
|
-
}
|
|
20660
|
+
});
|
|
20661
|
+
(0,external_vue_namespaceObject.watch)([refSearch, function () {
|
|
20662
|
+
return flatData.data;
|
|
20663
|
+
}, resultType, showChildNodes], function () {
|
|
20664
|
+
handleSearch();
|
|
20665
|
+
}, {
|
|
20666
|
+
deep: true,
|
|
20667
|
+
immediate: true
|
|
20668
|
+
});
|
|
20639
20669
|
(0,external_vue_namespaceObject.onMounted)(function () {
|
|
20640
20670
|
if (props.virtualRender) {
|
|
20641
20671
|
(0,external_vue_namespaceObject.nextTick)(function () {
|
package/lib/tree/use-search.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ declare const _default: (props: TreePropTypes) => {
|
|
|
3
3
|
searchFn: (itemValue: unknown, item: unknown) => boolean;
|
|
4
4
|
refSearch: import("vue").Ref<string | number | boolean | SearchOption, string | number | boolean | SearchOption>;
|
|
5
5
|
isSearchActive: import("vue").ComputedRef<boolean>;
|
|
6
|
-
isSearchDisabled: boolean
|
|
7
|
-
resultType: "list" | "tree"
|
|
6
|
+
isSearchDisabled: import("vue").ComputedRef<boolean>;
|
|
7
|
+
resultType: import("vue").ComputedRef<"list" | "tree">;
|
|
8
8
|
isTreeUI: import("vue").ComputedRef<boolean>;
|
|
9
|
-
showChildNodes: boolean
|
|
9
|
+
showChildNodes: import("vue").ComputedRef<boolean>;
|
|
10
10
|
};
|
|
11
11
|
export default _default;
|