bkui-vue 2.0.2-beta.77 → 2.0.2-beta.78
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 +21 -21
- package/dist/index.esm.js +2738 -2702
- package/dist/index.umd.js +21 -21
- package/lib/index.js +1 -1
- package/lib/popover/index.d.ts +3 -3
- package/lib/popover/index.js +110 -13
- package/lib/popover/popover.d.ts +1 -1
- package/lib/popover/use-floating.d.ts +2 -2
- package/lib/popover/use-popover-init.d.ts +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
package/lib/popover/index.d.ts
CHANGED
|
@@ -160,7 +160,7 @@ declare const BkPopover: {
|
|
|
160
160
|
onContentMouseenter?: (e: MouseEvent) => any;
|
|
161
161
|
onContentMouseleave?: (e: MouseEvent) => any;
|
|
162
162
|
}, {
|
|
163
|
-
boundary: import("vue").Ref<
|
|
163
|
+
boundary: import("vue").Ref<string>;
|
|
164
164
|
arrow: boolean;
|
|
165
165
|
refDefaultReference: import("vue").Ref<any>;
|
|
166
166
|
refContent: import("vue").Ref<any>;
|
|
@@ -557,7 +557,7 @@ declare const BkPopover: {
|
|
|
557
557
|
onContentMouseenter?: (e: MouseEvent) => any;
|
|
558
558
|
onContentMouseleave?: (e: MouseEvent) => any;
|
|
559
559
|
}, {
|
|
560
|
-
boundary: import("vue").Ref<
|
|
560
|
+
boundary: import("vue").Ref<string>;
|
|
561
561
|
arrow: boolean;
|
|
562
562
|
refDefaultReference: import("vue").Ref<any>;
|
|
563
563
|
refContent: import("vue").Ref<any>;
|
|
@@ -778,7 +778,7 @@ declare const BkPopover: {
|
|
|
778
778
|
onContentMouseenter?: (e: MouseEvent) => any;
|
|
779
779
|
onContentMouseleave?: (e: MouseEvent) => any;
|
|
780
780
|
}, {
|
|
781
|
-
boundary: import("vue").Ref<
|
|
781
|
+
boundary: import("vue").Ref<string>;
|
|
782
782
|
arrow: boolean;
|
|
783
783
|
refDefaultReference: import("vue").Ref<any>;
|
|
784
784
|
refContent: import("vue").Ref<any>;
|
package/lib/popover/index.js
CHANGED
|
@@ -4176,6 +4176,25 @@ function use_floating_objectSpread(e) { for (var r = 1; r < arguments.length; r+
|
|
|
4176
4176
|
}, {});
|
|
4177
4177
|
var contentClass = "".concat(customThemeCls);
|
|
4178
4178
|
var cleanup = null;
|
|
4179
|
+
// 清理所有定时器的函数
|
|
4180
|
+
var clearAllTimers = function clearAllTimers() {
|
|
4181
|
+
if (popHideTimerId) {
|
|
4182
|
+
clearTimeout(popHideTimerId);
|
|
4183
|
+
popHideTimerId = undefined;
|
|
4184
|
+
}
|
|
4185
|
+
if (popShowTimerId) {
|
|
4186
|
+
clearTimeout(popShowTimerId);
|
|
4187
|
+
popShowTimerId = undefined;
|
|
4188
|
+
}
|
|
4189
|
+
};
|
|
4190
|
+
// 包装 cleanup 函数,确保在清理时也清理定时器
|
|
4191
|
+
var wrappedCleanup = function wrappedCleanup() {
|
|
4192
|
+
clearAllTimers();
|
|
4193
|
+
if (cleanup) {
|
|
4194
|
+
cleanup();
|
|
4195
|
+
cleanup = null;
|
|
4196
|
+
}
|
|
4197
|
+
};
|
|
4179
4198
|
var getRoundPixelVal = function getRoundPixelVal(val) {
|
|
4180
4199
|
var dpr = window.devicePixelRatio || 1;
|
|
4181
4200
|
return Math.round(val * dpr) / dpr || 0;
|
|
@@ -4226,9 +4245,35 @@ function use_floating_objectSpread(e) { for (var r = 1; r < arguments.length; r+
|
|
|
4226
4245
|
}
|
|
4227
4246
|
};
|
|
4228
4247
|
var createPopInstance = function createPopInstance() {
|
|
4248
|
+
var retryCount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
4229
4249
|
var _resolvePopElements = resolvePopElements(),
|
|
4230
4250
|
elReference = _resolvePopElements.elReference,
|
|
4231
4251
|
elContent = _resolvePopElements.elContent;
|
|
4252
|
+
// 检查元素是否存在,如果不存在则延迟创建实例
|
|
4253
|
+
// 这通常发生在 renderDirective = 'show' 时,Content 通过 Teleport 渲染,可能还未完全挂载
|
|
4254
|
+
if (!elReference || !elContent) {
|
|
4255
|
+
// 限制重试次数,避免无限循环
|
|
4256
|
+
if (retryCount >= 10) {
|
|
4257
|
+
console.warn('[Popover] Failed to create popover instance: elements not found after retries');
|
|
4258
|
+
return;
|
|
4259
|
+
}
|
|
4260
|
+
// 使用 nextTick 等待 DOM 更新完成,特别是等待 Teleport 完成
|
|
4261
|
+
(0,external_vue_namespaceObject.nextTick)(function () {
|
|
4262
|
+
createPopInstance(retryCount + 1);
|
|
4263
|
+
});
|
|
4264
|
+
return;
|
|
4265
|
+
}
|
|
4266
|
+
// 确保元素已经挂载到 DOM 中(对于 Teleport 渲染的元素很重要)
|
|
4267
|
+
if (!elReference.isConnected || !elContent.isConnected) {
|
|
4268
|
+
if (retryCount >= 10) {
|
|
4269
|
+
console.warn('[Popover] Failed to create popover instance: elements not connected to DOM after retries');
|
|
4270
|
+
return;
|
|
4271
|
+
}
|
|
4272
|
+
(0,external_vue_namespaceObject.nextTick)(function () {
|
|
4273
|
+
createPopInstance(retryCount + 1);
|
|
4274
|
+
});
|
|
4275
|
+
return;
|
|
4276
|
+
}
|
|
4232
4277
|
cleanup = autoUpdate(elReference, elContent, function () {
|
|
4233
4278
|
if (localIsShow.value) {
|
|
4234
4279
|
updatePopover(null, props);
|
|
@@ -4281,6 +4326,10 @@ function use_floating_objectSpread(e) { for (var r = 1; r < arguments.length; r+
|
|
|
4281
4326
|
var delay = resolvePopoverDelay()[0];
|
|
4282
4327
|
// 设置settimeout避免hidePopover导致显示问题
|
|
4283
4328
|
popShowTimerId = setTimeout(function () {
|
|
4329
|
+
// 检查组件是否仍然存在,避免在组件卸载后更新状态
|
|
4330
|
+
if (!refContent.value) {
|
|
4331
|
+
return;
|
|
4332
|
+
}
|
|
4284
4333
|
// if (popHideTimerId) {
|
|
4285
4334
|
// clearTimeout(popHideTimerId);
|
|
4286
4335
|
// }
|
|
@@ -4292,6 +4341,10 @@ function use_floating_objectSpread(e) { for (var r = 1; r < arguments.length; r+
|
|
|
4292
4341
|
var hidePopover = function hidePopover() {
|
|
4293
4342
|
var delay = resolvePopoverDelay()[1];
|
|
4294
4343
|
popHideTimerId = setTimeout(function () {
|
|
4344
|
+
// 检查组件是否仍然存在,避免在组件卸载后更新状态
|
|
4345
|
+
if (!refContent.value) {
|
|
4346
|
+
return;
|
|
4347
|
+
}
|
|
4295
4348
|
popShowTimerId && clearTimeout(popShowTimerId);
|
|
4296
4349
|
isMouseenter = false;
|
|
4297
4350
|
localIsShow.value = false;
|
|
@@ -4300,20 +4353,34 @@ function use_floating_objectSpread(e) { for (var r = 1; r < arguments.length; r+
|
|
|
4300
4353
|
var handlePopoverShow = function handlePopoverShow() {
|
|
4301
4354
|
var _refContent$value2;
|
|
4302
4355
|
var elContent = resolveTargetElement((_refContent$value2 = refContent.value) === null || _refContent$value2 === void 0 ? void 0 : _refContent$value2.$el);
|
|
4356
|
+
// 检查元素是否存在,避免在 null 上访问 style 属性
|
|
4357
|
+
if (!elContent) {
|
|
4358
|
+
return;
|
|
4359
|
+
}
|
|
4303
4360
|
elContent.style.setProperty('display', 'block');
|
|
4304
4361
|
elContent.style.setProperty('z-index', "".concat(props.zIndex ? props.zIndex : shared_namespaceObject.bkZIndexManager.getPopperIndex()));
|
|
4305
4362
|
updatePopover();
|
|
4306
|
-
ctx
|
|
4307
|
-
|
|
4308
|
-
|
|
4363
|
+
// 检查 ctx 是否存在,避免在 null 上调用 emit
|
|
4364
|
+
if (ctx !== null && ctx !== void 0 && ctx.emit) {
|
|
4365
|
+
ctx.emit(EMIT_EVENTS.CONTENT_AfterShow, {
|
|
4366
|
+
isShow: true
|
|
4367
|
+
});
|
|
4368
|
+
}
|
|
4309
4369
|
};
|
|
4310
4370
|
var handlePopoverHide = function handlePopoverHide() {
|
|
4311
4371
|
var _refContent$value3;
|
|
4312
4372
|
var elContent = resolveTargetElement((_refContent$value3 = refContent.value) === null || _refContent$value3 === void 0 ? void 0 : _refContent$value3.$el);
|
|
4373
|
+
// 检查元素是否存在,避免在 null 上访问 style 属性
|
|
4374
|
+
if (!elContent) {
|
|
4375
|
+
return;
|
|
4376
|
+
}
|
|
4313
4377
|
elContent.style.setProperty('display', 'none');
|
|
4314
|
-
ctx
|
|
4315
|
-
|
|
4316
|
-
|
|
4378
|
+
// 检查 ctx 是否存在,避免在 null 上调用 emit
|
|
4379
|
+
if (ctx !== null && ctx !== void 0 && ctx.emit) {
|
|
4380
|
+
ctx.emit(EMIT_EVENTS.CONTENT_AfterHidden, {
|
|
4381
|
+
isShow: false
|
|
4382
|
+
});
|
|
4383
|
+
}
|
|
4317
4384
|
};
|
|
4318
4385
|
var triggerPopover = function triggerPopover() {
|
|
4319
4386
|
if (!localIsShow.value) {
|
|
@@ -4352,13 +4419,17 @@ function use_floating_objectSpread(e) { for (var r = 1; r < arguments.length; r+
|
|
|
4352
4419
|
* 例如:鼠标移入内容区域,则取消弹出内容隐藏操作
|
|
4353
4420
|
*/
|
|
4354
4421
|
var emitPopContentMouseEnter = function emitPopContentMouseEnter(e) {
|
|
4355
|
-
ctx.emit
|
|
4422
|
+
if (ctx !== null && ctx !== void 0 && ctx.emit) {
|
|
4423
|
+
ctx.emit(EMIT_EVENTS.CONTENT_MOUSEENTER, e);
|
|
4424
|
+
}
|
|
4356
4425
|
};
|
|
4357
4426
|
/**
|
|
4358
4427
|
* 弹出内容鼠标移出事件
|
|
4359
4428
|
*/
|
|
4360
4429
|
var emitPopContentMouseLeave = function emitPopContentMouseLeave(e) {
|
|
4361
|
-
ctx.emit
|
|
4430
|
+
if (ctx !== null && ctx !== void 0 && ctx.emit) {
|
|
4431
|
+
ctx.emit(EMIT_EVENTS.CONTENT_MOUSELEAVE, e);
|
|
4432
|
+
}
|
|
4362
4433
|
};
|
|
4363
4434
|
var resolveTriggerEvents = function resolveTriggerEvents() {
|
|
4364
4435
|
var _triggerEvents$props$;
|
|
@@ -4411,7 +4482,7 @@ function use_floating_objectSpread(e) { for (var r = 1; r < arguments.length; r+
|
|
|
4411
4482
|
getFullscreenRoot: getFullscreenRoot,
|
|
4412
4483
|
stopHide: stopHide,
|
|
4413
4484
|
localIsShow: localIsShow,
|
|
4414
|
-
cleanup:
|
|
4485
|
+
cleanup: wrappedCleanup
|
|
4415
4486
|
};
|
|
4416
4487
|
});
|
|
4417
4488
|
;// CONCATENATED MODULE: ../../packages/popover/src/use-popper-id.ts
|
|
@@ -4602,9 +4673,23 @@ var popContainerId = "id_".concat(esm_browser_v4());
|
|
|
4602
4673
|
}
|
|
4603
4674
|
};
|
|
4604
4675
|
var addEventToPopTargetEl = function addEventToPopTargetEl() {
|
|
4676
|
+
var retryCount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
4605
4677
|
var _resolvePopElements = resolvePopElements(),
|
|
4606
4678
|
elReference = _resolvePopElements.elReference,
|
|
4607
4679
|
elContent = _resolvePopElements.elContent;
|
|
4680
|
+
// 检查元素是否存在,如果不存在则延迟执行
|
|
4681
|
+
// 这通常发生在 renderDirective = 'show' 时,Content 通过 Teleport 渲染,可能还未完全挂载
|
|
4682
|
+
if (!elReference) {
|
|
4683
|
+
if (retryCount >= 10) {
|
|
4684
|
+
console.warn('[Popover] Failed to add events: reference element not found after retries');
|
|
4685
|
+
return;
|
|
4686
|
+
}
|
|
4687
|
+
// 使用 nextTick 等待 DOM 更新完成
|
|
4688
|
+
(0,external_vue_namespaceObject.nextTick)(function () {
|
|
4689
|
+
addEventToPopTargetEl(retryCount + 1);
|
|
4690
|
+
});
|
|
4691
|
+
return;
|
|
4692
|
+
}
|
|
4608
4693
|
storeEvents = resolveTriggerEvents();
|
|
4609
4694
|
storeEvents.forEach(function (storeEvent) {
|
|
4610
4695
|
if (Array.isArray(storeEvent)) {
|
|
@@ -4613,11 +4698,18 @@ var popContainerId = "id_".concat(esm_browser_v4());
|
|
|
4613
4698
|
var content = storeEvent.content,
|
|
4614
4699
|
reference = storeEvent.reference;
|
|
4615
4700
|
addEventToTargetEl(elReference, reference);
|
|
4616
|
-
|
|
4701
|
+
// elContent 可能为 null(当 renderDirective = 'show' 且 Content 还未挂载时)
|
|
4702
|
+
if (elContent) {
|
|
4703
|
+
addEventToTargetEl(elContent, content);
|
|
4704
|
+
}
|
|
4617
4705
|
}
|
|
4618
4706
|
});
|
|
4619
4707
|
};
|
|
4620
4708
|
var addEventToTargetEl = function addEventToTargetEl(target, evets) {
|
|
4709
|
+
// 检查 target 是否存在,避免在 null 上调用 addEventListener
|
|
4710
|
+
if (!target) {
|
|
4711
|
+
return;
|
|
4712
|
+
}
|
|
4621
4713
|
evets.forEach(function (_ref2) {
|
|
4622
4714
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
4623
4715
|
event = _ref3[0],
|
|
@@ -4683,10 +4775,14 @@ var popContainerId = "id_".concat(esm_browser_v4());
|
|
|
4683
4775
|
var _fullScreenTarget$val;
|
|
4684
4776
|
var _ref10 = elReference || root || {},
|
|
4685
4777
|
parentNode = _ref10.parentNode;
|
|
4686
|
-
|
|
4778
|
+
var fullscreenBoundary = (_fullScreenTarget$val = fullScreenTarget === null || fullScreenTarget === void 0 ? void 0 : fullScreenTarget.value) !== null && _fullScreenTarget$val !== void 0 ? _fullScreenTarget$val : getClosestFullscreenElement(parentNode);
|
|
4779
|
+
// 确保 boundary 始终有一个有效值,避免 Teleport 的 to 属性为 undefined
|
|
4780
|
+
boundary.value = fullscreenBoundary || 'body';
|
|
4687
4781
|
return;
|
|
4688
4782
|
}
|
|
4689
|
-
|
|
4783
|
+
var resolvedBoundary = getPrefixId(root || elReference);
|
|
4784
|
+
// 确保 boundary 始终有一个有效值,避免 Teleport 的 to 属性为 undefined
|
|
4785
|
+
boundary.value = resolvedBoundary || 'body';
|
|
4690
4786
|
};
|
|
4691
4787
|
var _usePopperId = use_popper_id(props, '#'),
|
|
4692
4788
|
getPrefixId = _usePopperId.getPrefixId,
|
|
@@ -4702,7 +4798,8 @@ var popContainerId = "id_".concat(esm_browser_v4());
|
|
|
4702
4798
|
element === null || element === void 0 || element.removeAttribute('data-fllsrn-id');
|
|
4703
4799
|
});
|
|
4704
4800
|
};
|
|
4705
|
-
|
|
4801
|
+
// 初始化 boundary 为 'body',避免 Teleport 的 to 属性为 undefined
|
|
4802
|
+
var boundary = (0,external_vue_namespaceObject.ref)('body');
|
|
4706
4803
|
var beforeInstanceUnmount = function beforeInstanceUnmount() {
|
|
4707
4804
|
removeEventListener();
|
|
4708
4805
|
};
|
package/lib/popover/popover.d.ts
CHANGED
|
@@ -146,7 +146,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
146
146
|
default: boolean;
|
|
147
147
|
};
|
|
148
148
|
}, {
|
|
149
|
-
boundary: import("vue").Ref<
|
|
149
|
+
boundary: import("vue").Ref<string>;
|
|
150
150
|
arrow: boolean;
|
|
151
151
|
refDefaultReference: import("vue").Ref<any>;
|
|
152
152
|
refContent: import("vue").Ref<any>;
|
|
@@ -24,11 +24,11 @@ declare const _default: (props: PopoverPropTypes, ctx: any, { refReference, refC
|
|
|
24
24
|
};
|
|
25
25
|
isElementFullScreen: () => boolean;
|
|
26
26
|
resolveTargetElement: (target: any) => any;
|
|
27
|
-
createPopInstance: () => void;
|
|
27
|
+
createPopInstance: (retryCount?: number) => void;
|
|
28
28
|
updateFullscreenTarget: (val?: HTMLElement) => void;
|
|
29
29
|
getFullscreenRoot: (selector: any) => any;
|
|
30
30
|
stopHide: () => void;
|
|
31
31
|
localIsShow: import("vue").Ref<boolean>;
|
|
32
|
-
cleanup:
|
|
32
|
+
cleanup: () => void;
|
|
33
33
|
};
|
|
34
34
|
export default _default;
|
|
@@ -18,7 +18,7 @@ declare const _default: (props: any, ctx: any, { refReference, refContent, refAr
|
|
|
18
18
|
hideFn: () => void;
|
|
19
19
|
stopHide: () => void;
|
|
20
20
|
isFullscreen: import("vue").Ref<boolean>;
|
|
21
|
-
boundary: import("vue").Ref<
|
|
21
|
+
boundary: import("vue").Ref<string>;
|
|
22
22
|
localIsShow: import("vue").Ref<boolean>;
|
|
23
23
|
uniqKey: string;
|
|
24
24
|
};
|