eoss 0.1.0-alpha.32 → 0.1.0-alpha.34

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.
Files changed (56) hide show
  1. package/lib/account-login.js +1 -1
  2. package/lib/audit-trajectory.js +1 -1
  3. package/lib/autocomplete.js +109 -70
  4. package/lib/cascader.js +109 -70
  5. package/lib/checkbox-group.js +1 -1
  6. package/lib/color-picker.js +109 -70
  7. package/lib/config/api.js +1 -1
  8. package/lib/data-table.js +1 -1
  9. package/lib/date-picker.js +109 -70
  10. package/lib/dropdown-menu.js +109 -70
  11. package/lib/email-login.js +1 -1
  12. package/lib/eoss.common.js +320 -147
  13. package/lib/flow.js +1 -1
  14. package/lib/flows.js +1 -1
  15. package/lib/form.js +1 -1
  16. package/lib/icon.js +1 -1
  17. package/lib/index.js +1 -1
  18. package/lib/login.js +1 -1
  19. package/lib/lowcode-view.js +94 -35
  20. package/lib/lowcode.js +98 -24
  21. package/lib/main.js +3 -2
  22. package/lib/menu.js +109 -70
  23. package/lib/phone-login.js +1 -1
  24. package/lib/popover.js +109 -70
  25. package/lib/process-config.js +1 -1
  26. package/lib/process-module.js +1 -1
  27. package/lib/process-rule.js +1 -1
  28. package/lib/qrcode-login.js +1 -1
  29. package/lib/radio-group.js +1 -1
  30. package/lib/select.js +110 -71
  31. package/lib/selector-panel.js +1 -1
  32. package/lib/selector.js +1 -1
  33. package/lib/submenu.js +109 -70
  34. package/lib/table.js +110 -71
  35. package/lib/theme-chalk/base.css +1 -1
  36. package/lib/theme-chalk/index.css +1 -1
  37. package/lib/theme-chalk/main.css +1 -1
  38. package/lib/time-picker.js +109 -70
  39. package/lib/time-select.js +109 -70
  40. package/lib/tips.js +1 -1
  41. package/lib/tooltip.js +109 -70
  42. package/lib/tree-group.js +1 -1
  43. package/lib/tree.js +1 -1
  44. package/lib/update-history.js +1 -1
  45. package/lib/upload.js +1 -1
  46. package/lib/utils/popper.js +97 -48
  47. package/package.json +1 -1
  48. package/packages/lowcode/src/lowcode.vue +43 -2
  49. package/packages/lowcode/src/render.vue +47 -12
  50. package/packages/lowcode-view/src/render.vue +66 -26
  51. package/packages/lowcode-view/src/view.vue +13 -2
  52. package/packages/main/src/minxs.js +2 -1
  53. package/packages/theme-chalk/src/base.scss +2 -1
  54. package/src/config/api.js +1 -1
  55. package/src/index.js +1 -1
  56. package/src/utils/popper.js +109 -70
@@ -2196,7 +2196,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
2196
2196
  //
2197
2197
  var referenceOffsets = getOffsetRectRelativeToCustomParent(
2198
2198
  reference,
2199
- getOffsetParent(popper),
2199
+ popper,
2200
2200
  isParentFixed
2201
2201
  );
2202
2202
 
@@ -2251,17 +2251,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
2251
2251
  Popper.prototype._setupEventListeners = function () {
2252
2252
  // NOTE: 1 DOM access here
2253
2253
  this.state.updateBound = this.update.bind(this);
2254
- root.addEventListener('resize', this.state.updateBound);
2254
+ // 无界等微前端场景下沙箱 window 不会触发 resize,需监听真实 window
2255
+ this.state.realWindow = getRealWindow(this._popper);
2256
+ this.state.realWindow.addEventListener('resize', this.state.updateBound);
2255
2257
  // if the boundariesElement is window we don't need to listen for the scroll event
2256
2258
  if (this._options.boundariesElement !== 'window') {
2257
2259
  var target = getScrollParent(this._reference);
2258
- // here it could be both `body` or `documentElement` thanks to Firefox, we then check both
2259
- if (
2260
- target === root.document.body ||
2261
- target === root.document.documentElement
2262
- ) {
2263
- target = root;
2264
- }
2265
2260
  target.addEventListener('scroll', this.state.updateBound);
2266
2261
  this.state.scrollTarget = target;
2267
2262
  }
@@ -2275,7 +2270,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
2275
2270
  */
2276
2271
  Popper.prototype._removeEventListeners = function () {
2277
2272
  // NOTE: 1 DOM access here
2278
- root.removeEventListener('resize', this.state.updateBound);
2273
+ (this.state.realWindow || root).removeEventListener(
2274
+ 'resize',
2275
+ this.state.updateBound
2276
+ );
2279
2277
  if (
2280
2278
  this._options.boundariesElement !== 'window' &&
2281
2279
  this.state.scrollTarget
@@ -2329,47 +2327,24 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
2329
2327
  left: 0
2330
2328
  };
2331
2329
  } else if (boundariesElement === 'viewport') {
2332
- var offsetParent = getOffsetParent(this._popper);
2333
- var scrollParent = getScrollParent(this._popper);
2334
- var offsetParentRect = getOffsetRect(offsetParent);
2335
-
2336
- // Thanks the fucking native API, `document.body.scrollTop` & `document.documentElement.scrollTop`
2337
- var getScrollTopValue = function (element) {
2338
- return element == document.body
2339
- ? Math.max(
2340
- document.documentElement.scrollTop,
2341
- document.body.scrollTop
2342
- )
2343
- : element.scrollTop;
2344
- };
2345
- var getScrollLeftValue = function (element) {
2346
- return element == document.body
2347
- ? Math.max(
2348
- document.documentElement.scrollLeft,
2349
- document.body.scrollLeft
2350
- )
2351
- : element.scrollLeft;
2352
- };
2353
-
2354
- // if the popper is fixed we don't have to substract scrolling from the boundaries
2355
- var scrollTop =
2356
- data.offsets.popper.position === 'fixed'
2357
- ? 0
2358
- : getScrollTopValue(scrollParent);
2359
- var scrollLeft =
2330
+ // 将真实 window 的视口换算到 popper 所在包含块的坐标系。
2331
+ // 无界等场景下沙箱 window 的尺寸、shadowRoot 内元素的 scrollTop 均不可靠,
2332
+ // 统一从元素自身的 view 与真实包含块获取
2333
+ var realWindow = getRealWindow(this._popper);
2334
+ var containingBlockRect = getContainingBlockRect(
2335
+ this._popper,
2360
2336
  data.offsets.popper.position === 'fixed'
2361
- ? 0
2362
- : getScrollLeftValue(scrollParent);
2337
+ );
2363
2338
 
2364
2339
  boundaries = {
2365
- top: 0 - (offsetParentRect.top - scrollTop),
2340
+ top: 0 - containingBlockRect.top,
2366
2341
  right:
2367
- root.document.documentElement.clientWidth -
2368
- (offsetParentRect.left - scrollLeft),
2342
+ realWindow.document.documentElement.clientWidth -
2343
+ containingBlockRect.left,
2369
2344
  bottom:
2370
- root.document.documentElement.clientHeight -
2371
- (offsetParentRect.top - scrollTop),
2372
- left: 0 - (offsetParentRect.left - scrollLeft)
2345
+ realWindow.document.documentElement.clientHeight -
2346
+ containingBlockRect.top,
2347
+ left: 0 - containingBlockRect.left
2373
2348
  };
2374
2349
  } else {
2375
2350
  if (getOffsetParent(this._popper) === boundariesElement) {
@@ -2837,7 +2812,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
2837
2812
  element.style.visibility = 'hidden';
2838
2813
  var calcWidthToForceRepaint = element.offsetWidth;
2839
2814
  // original method
2840
- var styles = root.getComputedStyle(element);
2815
+ var styles = getRealWindow(element).getComputedStyle(element);
2841
2816
  var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
2842
2817
  var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
2843
2818
  var result = {
@@ -2908,9 +2883,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
2908
2883
  */
2909
2884
  function getStyleComputedProperty(element, property) {
2910
2885
  // NOTE: 1 DOM access here
2911
- var css = root.getComputedStyle(element, null);
2886
+ // 无界等微前端场景下沙箱 window 与元素实际渲染所在 window 可能不一致,
2887
+ // 需使用元素自身的 view 读取计算样式,避免跨 document 读取到空值
2888
+ var css = getRealWindow(element).getComputedStyle(element, null);
2912
2889
  return css[property];
2913
2890
  }
2891
+
2914
2892
  /**
2915
2893
  * Returns the offset parent of the given element
2916
2894
  * @function
@@ -2925,6 +2903,68 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
2925
2903
  : offsetParent;
2926
2904
  }
2927
2905
 
2906
+ /**
2907
+ * Returns the window the given element actually renders in.
2908
+ * 无界等微前端场景下组件代码运行在沙箱 window 中,而 DOM 实际渲染在
2909
+ * 主应用的 window(shadowRoot 内),滚动量、视口尺寸等必须取自元素自身的 view
2910
+ * @function
2911
+ * @ignore
2912
+ * @argument {Element} element
2913
+ * @returns {Window} window
2914
+ */
2915
+ function getRealWindow(element) {
2916
+ return (
2917
+ (element &&
2918
+ element.ownerDocument &&
2919
+ element.ownerDocument.defaultView) ||
2920
+ root
2921
+ );
2922
+ }
2923
+
2924
+ /**
2925
+ * Returns the viewport rect of the containing block actually used to position the popper.
2926
+ * 无界微前端等场景下 popper 被挂载进子应用的 shadowRoot,offsetParent 的兜底值
2927
+ * (documentElement)与浏览器真实的包含块不再重合,导致下拉框/提示框整体偏移
2928
+ * (偏移量恰为子应用容器在主应用中的位置),因此需要沿 composed tree 查找:
2929
+ * - fixed 定位:包含块为视口;
2930
+ * - absolute 定位:最近的 positioned 祖先元素(跨 shadowRoot 边界查找);
2931
+ * - 无 positioned 祖先:初始包含块,其视口原点为真实 window 滚动量的负值。
2932
+ * @function
2933
+ * @ignore
2934
+ * @argument {Element} element - popper element
2935
+ * @argument {Boolean} fixed - whether the popper is fixed positioned
2936
+ * @returns {Object} rect
2937
+ */
2938
+ function getContainingBlockRect(element, fixed) {
2939
+ if (fixed) {
2940
+ return { top: 0, left: 0, right: 0, bottom: 0 };
2941
+ }
2942
+
2943
+ var node = element.parentNode;
2944
+ while (node) {
2945
+ if (node.nodeType === 1) {
2946
+ if (getStyleComputedProperty(node, 'position') !== 'static') {
2947
+ return getBoundingClientRect(node);
2948
+ }
2949
+ } else if (node.nodeType === 11) {
2950
+ // 遇到 shadowRoot,跨边界从宿主元素继续向上查找
2951
+ node = node.host;
2952
+ continue;
2953
+ } else {
2954
+ break;
2955
+ }
2956
+ node = node.parentNode;
2957
+ }
2958
+
2959
+ var win = getRealWindow(element);
2960
+ return {
2961
+ top: -(win.pageYOffset || 0),
2962
+ left: -(win.pageXOffset || 0),
2963
+ right: 0,
2964
+ bottom: 0
2965
+ };
2966
+ }
2967
+
2928
2968
  /**
2929
2969
  * Returns the scrolling parent of the given element
2930
2970
  * @function
@@ -2934,18 +2974,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
2934
2974
  */
2935
2975
  function getScrollParent(element) {
2936
2976
  var parent = element.parentNode;
2937
- if (!parent || parent.nodeType !== 1) {
2977
+ if (!parent) {
2938
2978
  return element;
2939
2979
  }
2940
2980
 
2941
- if (parent === root.document) {
2942
- // Firefox puts the scrollTOp value on `documentElement` instead of `body`, we then check which of them is
2943
- // greater than 0 and return the proper element
2944
- if (root.document.body.scrollTop || root.document.body.scrollLeft) {
2945
- return root.document.body;
2946
- } else {
2947
- return root.document.documentElement;
2948
- }
2981
+ if (parent.nodeType === 11) {
2982
+ // 无界等微前端场景 DOM 位于 shadowRoot 内,需跨边界从宿主元素继续向上查找,
2983
+ // 否则查找到 shadowRoot 即终止,滚动事件无法被监听
2984
+ return getScrollParent(parent.host);
2985
+ }
2986
+
2987
+ if (parent.nodeType !== 1) {
2988
+ // 到达 document,返回元素实际渲染所在的真实 window,
2989
+ // 保证 window 滚动时能触发位置更新
2990
+ return getRealWindow(element);
2949
2991
  }
2950
2992
 
2951
2993
  // Firefox want us to check `-x` and `-y` variations as well
@@ -2965,7 +3007,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
2965
3007
  // fixes issue #65
2966
3008
  return parent;
2967
3009
  }
2968
- return getScrollParent(element.parentNode);
3010
+ return getScrollParent(parent);
2969
3011
  }
2970
3012
 
2971
3013
  /**
@@ -2983,9 +3025,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
2983
3025
  if (getStyleComputedProperty(element, 'position') === 'fixed') {
2984
3026
  return true;
2985
3027
  }
2986
- return element.parentNode && element.parentNode.nodeType === 1
2987
- ? isFixed(element.parentNode)
2988
- : element;
3028
+ var parent = element.parentNode;
3029
+ if (parent && parent.nodeType === 11) {
3030
+ // 跨 shadowRoot 边界,从宿主元素继续向上判断
3031
+ parent = parent.host;
3032
+ }
3033
+ return parent && parent.nodeType === 1 ? isFixed(parent) : false;
2989
3034
  }
2990
3035
 
2991
3036
  /**
@@ -3101,15 +3146,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
3101
3146
  */
3102
3147
  function getOffsetRectRelativeToCustomParent(element, parent, fixed) {
3103
3148
  var elementRect = getBoundingClientRect(element);
3104
- var parentRect = getBoundingClientRect(parent);
3105
-
3106
- if (fixed) {
3107
- var scrollParent = getScrollParent(parent);
3108
- parentRect.top += scrollParent.scrollTop;
3109
- parentRect.bottom += scrollParent.scrollTop;
3110
- parentRect.left += scrollParent.scrollLeft;
3111
- parentRect.right += scrollParent.scrollLeft;
3112
- }
3149
+ // parent 为 popper 元素:取其真实包含块的视口 rect,
3150
+ // 避免无界 shadowRoot 等场景下包含块假设错误导致的整体偏移
3151
+ var parentRect = getContainingBlockRect(parent, fixed);
3113
3152
 
3114
3153
  var rect = {
3115
3154
  top: elementRect.top - parentRect.top,
@@ -4830,7 +4830,7 @@ var publishedLists = '/main2/pageComponentConfig/listPublished';
4830
4830
  // 获取自定义配置详情
4831
4831
  var pageInfo = '/main2/pageComponentConfig/info';
4832
4832
  // 获取自定义配置授权列表
4833
- var pageGroup = 'main2/pageComponentTarget/listByConfigIdAndTypeGroup';
4833
+ var pageGroup = '/main2/pageComponentTarget/listByConfigIdAndTypeGroup';
4834
4834
 
4835
4835
  // 保存自定义配置,发布也调这个接口但要加上字段status=1
4836
4836
  var pageSave = '/main2/pageComponentConfig/save';