bkui-vue 2.0.2-beta.70 → 2.0.2-beta.72

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/lib/index.js CHANGED
@@ -3,5 +3,5 @@ export * from './hooks';
3
3
  export { default } from './preset';
4
4
  export * from './config-provider';
5
5
  export * from './directives';
6
- export const version = "2.0.2-beta.70";
6
+ export const version = "2.0.2-beta.72";
7
7
  window.__bkui_vue_version__ = version;
@@ -168,7 +168,6 @@ declare const BkPopover: {
168
168
  isRenderModeShow: import("vue").ComputedRef<boolean>;
169
169
  transBoundary: import("vue").ComputedRef<boolean>;
170
170
  handleClickContent: () => void;
171
- handleClickOutside: (_e: MouseEvent, hideIgnoreReference?: boolean) => void;
172
171
  updatePopover: (virtualEl?: any, props?: {}, callFn?: any) => void;
173
172
  resetPopover: () => void;
174
173
  hide: () => void;
@@ -561,7 +560,6 @@ declare const BkPopover: {
561
560
  isRenderModeShow: import("vue").ComputedRef<boolean>;
562
561
  transBoundary: import("vue").ComputedRef<boolean>;
563
562
  handleClickContent: () => void;
564
- handleClickOutside: (_e: MouseEvent, hideIgnoreReference?: boolean) => void;
565
563
  updatePopover: (virtualEl?: any, props?: {}, callFn?: any) => void;
566
564
  resetPopover: () => void;
567
565
  hide: () => void;
@@ -780,7 +778,6 @@ declare const BkPopover: {
780
778
  isRenderModeShow: import("vue").ComputedRef<boolean>;
781
779
  transBoundary: import("vue").ComputedRef<boolean>;
782
780
  handleClickContent: () => void;
783
- handleClickOutside: (_e: MouseEvent, hideIgnoreReference?: boolean) => void;
784
781
  updatePopover: (virtualEl?: any, props?: {}, callFn?: any) => void;
785
782
  resetPopover: () => void;
786
783
  hide: () => void;
@@ -692,7 +692,7 @@ const shared_namespaceObject = x({ ["PlacementEnum"]: () => __WEBPACK_EXTERNAL_M
692
692
  ;// CONCATENATED MODULE: external "vue"
693
693
  var external_vue_x = y => { var x = {}; __webpack_require__.d(x, y); return x; }
694
694
  var external_vue_y = x => () => x
695
- const external_vue_namespaceObject = external_vue_x({ ["Fragment"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.Fragment, ["Teleport"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.Teleport, ["Text"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.Text, ["computed"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.computed, ["createApp"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.createApp, ["createVNode"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.createVNode, ["defineComponent"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.defineComponent, ["h"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.h, ["isVNode"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.isVNode, ["mergeProps"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.mergeProps, ["nextTick"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.nextTick, ["onBeforeUnmount"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.onBeforeUnmount, ["onMounted"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.onMounted, ["reactive"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.reactive, ["ref"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.ref, ["render"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.render, ["resolveDirective"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.resolveDirective, ["toRefs"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.toRefs, ["watch"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.watch, ["withDirectives"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.withDirectives });
695
+ const external_vue_namespaceObject = external_vue_x({ ["Fragment"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.Fragment, ["Teleport"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.Teleport, ["Text"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.Text, ["computed"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.computed, ["createApp"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.createApp, ["createVNode"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.createVNode, ["defineComponent"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.defineComponent, ["h"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.h, ["isVNode"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.isVNode, ["mergeProps"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.mergeProps, ["nextTick"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.nextTick, ["onBeforeUnmount"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.onBeforeUnmount, ["onMounted"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.onMounted, ["reactive"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.reactive, ["ref"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.ref, ["render"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.render, ["toRefs"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.toRefs, ["watch"]: () => __WEBPACK_EXTERNAL_MODULE_vue__.watch });
696
696
  ;// CONCATENATED MODULE: ../../packages/directives/src/clickoutside.ts
697
697
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
698
698
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -1545,7 +1545,7 @@ var EMIT_EVENT_TYPES = _defineProperty(_defineProperty(_defineProperty(_definePr
1545
1545
  var refContent = (0,external_vue_namespaceObject.ref)(null);
1546
1546
  var refTimer = (0,external_vue_namespaceObject.ref)(null);
1547
1547
  var handleClick = function handleClick(evt) {
1548
- evt.stopPropagation();
1548
+ // evt.stopPropagation();
1549
1549
  emit('click', evt);
1550
1550
  };
1551
1551
  var resetPointerEvent = function resetPointerEvent() {
@@ -4440,10 +4440,11 @@ function use_floating_objectSpread(e) { for (var r = 1; r < arguments.length; r+
4440
4440
  */
4441
4441
 
4442
4442
 
4443
- var popContainerId = null;
4444
- var parentNodeReferId = null;
4443
+ var popContainerId = "id_".concat(esm_browser_v4());
4445
4444
  /* harmony default export */ const use_popper_id = (function (props) {
4446
4445
  var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '#';
4446
+ // 为每个 popover 实例生成独立的 parentNodeReferId,避免嵌套时 ID 冲突
4447
+ var parentNodeReferId = "id_".concat(esm_browser_v4());
4447
4448
  var getPrefixId = function getPrefixId(root) {
4448
4449
  var resolvedBoundary = null;
4449
4450
  var resolveBoundary = function resolveBoundary(fn) {
@@ -4452,8 +4453,7 @@ var parentNodeReferId = null;
4452
4453
  }
4453
4454
  };
4454
4455
  var resolveParentBoundary = function resolveParentBoundary() {
4455
- if (/^parent$/i.test(props.boundary)) {
4456
- resolvedBoundary = "".concat(prefix).concat(popContainerId);
4456
+ if (/^parent$/i.test(props.boundary) || !props.boundary) {
4457
4457
  var _ref = root || {},
4458
4458
  parentNode = _ref.parentNode;
4459
4459
  if (parentNode !== null && parentNode !== void 0 && parentNode.parentNode) {
@@ -4463,43 +4463,62 @@ var parentNodeReferId = null;
4463
4463
  }
4464
4464
  };
4465
4465
  var resolveCommonBoundary = function resolveCommonBoundary() {
4466
- if (!/^body$/i.test(props.boundary)) {
4467
- if (typeof props.boundary === 'string') {
4468
- if (!isAvailableId(props.boundary)) {
4469
- // console.error('props.boundary is not available selector');
4470
- resolvedBoundary = 'body';
4471
- return;
4472
- }
4473
- resolvedBoundary = props.boundary;
4474
- return;
4475
- }
4476
- if (utils_isElement(props.boundary)) {
4477
- resolvedBoundary = props.boundary;
4478
- return;
4479
- }
4466
+ // 如果 boundary 是字符串 'body',使用动态创建的 popContainer
4467
+ if (typeof props.boundary === 'string' && /^body$/i.test(props.boundary)) {
4468
+ resolvedBoundary = "".concat(prefix).concat(popContainerId);
4469
+ return;
4470
+ }
4471
+ // 如果 boundary 是 document.body 对象,使用动态创建的 popContainer
4472
+ if (props.boundary === document.body) {
4473
+ resolvedBoundary = "".concat(prefix).concat(popContainerId);
4474
+ return;
4475
+ }
4476
+ // 处理其他字符串选择器,直接使用
4477
+ if (typeof props.boundary === 'string') {
4478
+ resolvedBoundary = props.boundary;
4479
+ return;
4480
+ }
4481
+ // 处理其他 HTMLElement 对象,直接使用
4482
+ if (utils_isElement(props.boundary)) {
4483
+ resolvedBoundary = props.boundary;
4484
+ return;
4480
4485
  }
4481
4486
  };
4482
4487
  resolveBoundary(resolveParentBoundary);
4483
4488
  resolveBoundary(resolveCommonBoundary);
4489
+ // 默认降级逻辑
4484
4490
  resolveBoundary(function () {
4485
- resolvedBoundary = typeof props.boundary === 'string' ? props.boundary : "".concat(prefix).concat(popContainerId);
4491
+ resolvedBoundary = "".concat(prefix).concat(popContainerId);
4486
4492
  });
4487
4493
  return resolvedBoundary;
4488
4494
  };
4489
- if (popContainerId === null || !isAvailableId("#".concat(popContainerId))) {
4490
- popContainerId = "id_".concat(esm_browser_v4());
4495
+ // 确保全局 popContainer 容器存在
4496
+ if (!isAvailableId("#".concat(popContainerId))) {
4491
4497
  var popContainer = document.createElement('div');
4492
4498
  popContainer.setAttribute('id', popContainerId);
4493
4499
  popContainer.setAttribute('data-popper-id', popContainerId);
4494
4500
  document.body.append(popContainer);
4495
4501
  }
4496
- if (parentNodeReferId === null) {
4497
- parentNodeReferId = "id_".concat(esm_browser_v4());
4498
- }
4502
+ // 清理父节点上的 data-pnode-id 属性
4503
+ var clearParentNodeId = function clearParentNodeId(root) {
4504
+ if (/^parent$/i.test(props.boundary)) {
4505
+ var _ref2 = root || {},
4506
+ parentNode = _ref2.parentNode;
4507
+ if (parentNode !== null && parentNode !== void 0 && parentNode.parentNode) {
4508
+ var attr = parentNode.parentNode.getAttribute('data-pnode-id');
4509
+ // 只清理当前实例设置的属性
4510
+ if (attr === parentNodeReferId) {
4511
+ parentNode.parentNode.removeAttribute('data-pnode-id');
4512
+ }
4513
+ }
4514
+ }
4515
+ };
4499
4516
  return {
4500
4517
  popContainerId: popContainerId,
4501
4518
  prefixId: getPrefixId(),
4502
- getPrefixId: getPrefixId
4519
+ getPrefixId: getPrefixId,
4520
+ parentNodeReferId: parentNodeReferId,
4521
+ clearParentNodeId: clearParentNodeId
4503
4522
  };
4504
4523
  });
4505
4524
  ;// CONCATENATED MODULE: ../../packages/popover/src/use-popover-init.ts
@@ -4668,7 +4687,8 @@ var parentNodeReferId = null;
4668
4687
  boundary.value = getPrefixId(root || elReference);
4669
4688
  };
4670
4689
  var _usePopperId = use_popper_id(props, '#'),
4671
- getPrefixId = _usePopperId.getPrefixId;
4690
+ getPrefixId = _usePopperId.getPrefixId,
4691
+ clearParentNodeId = _usePopperId.clearParentNodeId;
4672
4692
  var setFullscreenTag = function setFullscreenTag() {
4673
4693
  var _fullScreenTarget$val2;
4674
4694
  fullScreenTarget === null || fullScreenTarget === void 0 || (_fullScreenTarget$val2 = fullScreenTarget.value) === null || _fullScreenTarget$val2 === void 0 || _fullScreenTarget$val2.setAttribute('data-fllsrn-id', fullscreenReferId);
@@ -4702,25 +4722,49 @@ var parentNodeReferId = null;
4702
4722
  if (props.disabled) {
4703
4723
  return;
4704
4724
  }
4705
- initPopInstance();
4706
4725
  if (isElementFullScreen()) {
4707
4726
  var query = "[data-fllsrn-id=".concat(fullscreenReferId, "]");
4708
4727
  var target = getFullscreenRoot(query);
4709
4728
  updateFullscreen(target);
4710
4729
  }
4730
+ // 先更新 boundary,确保在初始化 popover 实例之前 boundary 已正确设置
4711
4731
  updateBoundary();
4732
+ initPopInstance();
4712
4733
  document.body.addEventListener('fullscreenchange', handleFullscreenChange);
4734
+ document.addEventListener('click', handleClickOutside);
4713
4735
  };
4714
4736
  var onUnmountedFn = function onUnmountedFn() {
4715
4737
  beforeInstanceUnmount();
4738
+ // 清理父节点上的 data-pnode-id 属性
4739
+ var _resolvePopElements4 = resolvePopElements(),
4740
+ root = _resolvePopElements4.root;
4741
+ clearParentNodeId(root);
4716
4742
  document.body.removeEventListener('fullscreenchange', handleFullscreenChange);
4743
+ document.removeEventListener('click', handleClickOutside);
4717
4744
  };
4718
- var handleClickOutside = function handleClickOutside(_e) {
4745
+ var isClickInside = function isClickInside(target) {
4746
+ var _refContent$value$$el, _refContent$value, _refContent$value$con;
4747
+ return (_refContent$value$$el = (_refContent$value = refContent.value) === null || _refContent$value === void 0 || (_refContent$value = _refContent$value.$el) === null || _refContent$value === void 0 || (_refContent$value$con = _refContent$value.contains) === null || _refContent$value$con === void 0 ? void 0 : _refContent$value$con.call(_refContent$value, target)) !== null && _refContent$value$$el !== void 0 ? _refContent$value$$el : false;
4748
+ };
4749
+ /**
4750
+ * 处理点击外部区域的事件
4751
+ * @param e - 事件对象
4752
+ * @param hideIgnoreReference - 是否忽略隐藏参考元素
4753
+ * @returns
4754
+ */
4755
+ var handleClickOutside = function handleClickOutside(e) {
4719
4756
  var hideIgnoreReference = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
4757
+ var target = e.target;
4758
+ if (isClickInside(target)) {
4759
+ e.preventDefault();
4760
+ e.stopPropagation();
4761
+ e.stopImmediatePropagation();
4762
+ return;
4763
+ }
4720
4764
  var commonFunc = function commonFunc() {
4721
4765
  ctx.emit(EMIT_EVENTS.CLICK_OUTSIDE, {
4722
4766
  isShow: localIsShow.value,
4723
- event: _e
4767
+ event: e
4724
4768
  });
4725
4769
  var needExec = props.disableOutsideClick || props.always || props.disabled || props.trigger === 'manual';
4726
4770
  if (!props.forceClickoutside && needExec) {
@@ -4730,6 +4774,11 @@ var parentNodeReferId = null;
4730
4774
  hideFn();
4731
4775
  }
4732
4776
  };
4777
+ /**
4778
+ * 如果需要忽略隐藏参考元素,则设置一个定时器,在定时器结束后检查是否需要隐藏 popover
4779
+ * @param hideIgnoreReference - 是否忽略隐藏参考元素
4780
+ * @returns
4781
+ */
4733
4782
  if (hideIgnoreReference) {
4734
4783
  setTimeout(function () {
4735
4784
  if (ReferenceClickSharedState[uniqKey]) {
@@ -4833,9 +4882,7 @@ function _isSlot(s) {
4833
4882
  }),
4834
4883
  onMountedFn = _usePopoverInit.onMountedFn,
4835
4884
  onUnmountedFn = _usePopoverInit.onUnmountedFn,
4836
- handleClickOutside = _usePopoverInit.handleClickOutside,
4837
4885
  beforeInstanceUnmount = _usePopoverInit.beforeInstanceUnmount,
4838
- updateBoundary = _usePopoverInit.updateBoundary,
4839
4886
  initPopInstance = _usePopoverInit.initPopInstance,
4840
4887
  showFn = _usePopoverInit.showFn,
4841
4888
  hideFn = _usePopoverInit.hideFn,
@@ -4865,7 +4912,6 @@ function _isSlot(s) {
4865
4912
  initPopInstance();
4866
4913
  }
4867
4914
  });
4868
- updateBoundary();
4869
4915
  (0,external_vue_namespaceObject.onMounted)(onMountedFn);
4870
4916
  (0,external_vue_namespaceObject.onBeforeUnmount)(onUnmountedFn);
4871
4917
  var isRenderModeShow = (0,external_vue_namespaceObject.computed)(function () {
@@ -4914,7 +4960,6 @@ function _isSlot(s) {
4914
4960
  isRenderModeShow: isRenderModeShow,
4915
4961
  transBoundary: transBoundary,
4916
4962
  handleClickContent: handleClickContent,
4917
- handleClickOutside: handleClickOutside,
4918
4963
  updatePopover: updatePopover,
4919
4964
  resetPopover: resetPopover,
4920
4965
  hide: hide,
@@ -4970,7 +5015,7 @@ function _isSlot(s) {
4970
5015
  "to": _this.boundary
4971
5016
  }, {
4972
5017
  "default": function _default() {
4973
- return [(0,external_vue_namespaceObject.withDirectives)((0,external_vue_namespaceObject.createVNode)(content, {
5018
+ return [(0,external_vue_namespaceObject.createVNode)(content, {
4974
5019
  "ref": "refContent",
4975
5020
  "width": _this.width,
4976
5021
  "height": _this.height,
@@ -4995,9 +5040,7 @@ function _isSlot(s) {
4995
5040
  }
4996
5041
  }) : '';
4997
5042
  }
4998
- }), [[(0,external_vue_namespaceObject.resolveDirective)("clickoutside"), function (e) {
4999
- return _this.handleClickOutside(e, _this.hideIgnoreReference);
5000
- }]])];
5043
+ })];
5001
5044
  }
5002
5045
  })];
5003
5046
  }
@@ -154,7 +154,6 @@ declare const _default: import("vue").DefineComponent<{
154
154
  isRenderModeShow: import("vue").ComputedRef<boolean>;
155
155
  transBoundary: import("vue").ComputedRef<boolean>;
156
156
  handleClickContent: () => void;
157
- handleClickOutside: (_e: MouseEvent, hideIgnoreReference?: boolean) => void;
158
157
  updatePopover: (virtualEl?: any, props?: {}, callFn?: any) => void;
159
158
  resetPopover: () => void;
160
159
  hide: () => void;
@@ -6,7 +6,7 @@ declare const _default: (props: any, ctx: any, { refReference, refContent, refAr
6
6
  }) => {
7
7
  onMountedFn: () => void;
8
8
  onUnmountedFn: () => void;
9
- handleClickOutside: (_e: MouseEvent, hideIgnoreReference?: boolean) => void;
9
+ handleClickOutside: (e: MouseEvent, hideIgnoreReference?: boolean) => void;
10
10
  beforeInstanceUnmount: () => void;
11
11
  updateBoundary: () => void;
12
12
  initPopInstance: () => void;
@@ -1,6 +1,8 @@
1
1
  declare const _default: (props: any, prefix?: string) => {
2
- popContainerId: any;
2
+ popContainerId: string;
3
3
  prefixId: any;
4
4
  getPrefixId: (root?: any) => any;
5
+ parentNodeReferId: string;
6
+ clearParentNodeId: (root?: any) => void;
5
7
  };
6
8
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkui-vue",
3
- "version": "2.0.2-beta.70",
3
+ "version": "2.0.2-beta.72",
4
4
  "workspaces": [
5
5
  "packages/**",
6
6
  "scripts/cli",