@next-core/brick-kit 2.118.7 → 2.120.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,38 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.120.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.119.1...@next-core/brick-kit@2.120.0) (2022-05-26)
7
+
8
+
9
+ ### Features
10
+
11
+ * support lifeCycle.onScrollIntoView ([4e3a4ec](https://github.com/easyops-cn/next-core/commit/4e3a4ec99a78b312c6efe595d82e214a843458d0))
12
+
13
+
14
+
15
+
16
+
17
+ ## [2.119.1](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.119.0...@next-core/brick-kit@2.119.1) (2022-05-13)
18
+
19
+ **Note:** Version bump only for package @next-core/brick-kit
20
+
21
+
22
+
23
+
24
+
25
+ # [2.119.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.118.7...@next-core/brick-kit@2.119.0) (2022-05-11)
26
+
27
+
28
+ ### Features
29
+
30
+ * **mock:** add note ([74c0031](https://github.com/easyops-cn/next-core/commit/74c0031c81ded97014384213d99fedce8ed55d54))
31
+ * **mock:** update mock rule ([c8fe9fc](https://github.com/easyops-cn/next-core/commit/c8fe9fccb46117330e1ff2ef42a18bef8dfff864))
32
+ * **mock:** update mock rule ([5898ecf](https://github.com/easyops-cn/next-core/commit/5898ecfd604ca418feeb954a6091e3b940a1e867))
33
+
34
+
35
+
36
+
37
+
6
38
  ## [2.118.7](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.118.6...@next-core/brick-kit@2.118.7) (2022-05-10)
7
39
 
8
40
  **Note:** Version bump only for package @next-core/brick-kit
@@ -5791,11 +5791,14 @@
5791
5791
  var _useMocks$mockList;
5792
5792
 
5793
5793
  if (useMocks) mocks = _objectSpread__default["default"](_objectSpread__default["default"]({}, useMocks), {}, {
5794
- mockList: (_useMocks$mockList = useMocks.mockList) === null || _useMocks$mockList === void 0 ? void 0 : _useMocks$mockList.map(item => _objectSpread__default["default"](_objectSpread__default["default"]({}, item), {}, {
5795
- uri: item.uri.replace(/(easyops\.api\.)(.+?)\/(.+)/, (_match, p1, p2, p3) => {
5796
- return "(".concat(p1, ")?").concat(p2, "(@\\d+\\.\\d+\\.\\d+)?/").concat(p3, "$");
5797
- }).replace(/:\w+/g, "([^/]+)")
5798
- }))
5794
+ mockList: (_useMocks$mockList = useMocks.mockList) === null || _useMocks$mockList === void 0 ? void 0 : _useMocks$mockList.map(item => {
5795
+ var isFlowAPi = isCustomApiProvider(item.provider);
5796
+ return _objectSpread__default["default"](_objectSpread__default["default"]({}, item), {}, {
5797
+ uri: "".concat(isFlowAPi ? item.uri.replace(/(.+?)\/(.+)/, (_match, p1, p2) => {
5798
+ return "/".concat(p1, "(@\\d+\\.\\d+\\.\\d+)?/").concat(p2, "$");
5799
+ }) : "/".concat(item.uri.split(".").slice(2).join("."), "$")).replace(/:\w+/g, "([^/]+)")
5800
+ });
5801
+ })
5799
5802
  });
5800
5803
  }
5801
5804
  function getMockList() {
@@ -5815,6 +5818,7 @@
5815
5818
  if (item) {
5816
5819
  return {
5817
5820
  url: requestUrl.replace(/(api\/gateway\/.+?)(@\d+\.\d+\.\d+)?\/(.+)/, (_match, p1, _p2, p3) => {
5821
+ // 忽略版本
5818
5822
  return "".concat(p1, "/").concat(p3);
5819
5823
  }).replace(/(api\/gateway)/, "api/gateway/mock_server.proxy.".concat(mocks.mockId)),
5820
5824
  mockId: mocks.mockId
@@ -9072,12 +9076,16 @@
9072
9076
 
9073
9077
  _defineProperty__default["default"](this, "messageHandlers", []);
9074
9078
 
9079
+ _defineProperty__default["default"](this, "scrollIntoViewHandlersMap", new Map());
9080
+
9075
9081
  _defineProperty__default["default"](this, "segues", {});
9076
9082
 
9077
9083
  _defineProperty__default["default"](this, "currentMatch", void 0);
9078
9084
 
9079
9085
  _defineProperty__default["default"](this, "storyboardContextWrapper", new StoryboardContextWrapper());
9080
9086
 
9087
+ _defineProperty__default["default"](this, "observersList", []);
9088
+
9081
9089
  this.kernel = kernel;
9082
9090
  this.location = location;
9083
9091
  this.resolver = new Resolver(kernel);
@@ -9444,7 +9452,7 @@
9444
9452
  _this6 = this;
9445
9453
 
9446
9454
  return _asyncToGenerator__default["default"](function* () {
9447
- var _this6$kernel$nextApp;
9455
+ var _this6$kernel$nextApp, _brickConf$lifeCycle, _brick$lifeCycle;
9448
9456
 
9449
9457
  var tplStack = _arguments.length > 4 && _arguments[4] !== undefined ? _arguments[4] : [];
9450
9458
  var tplContextId = brickConf[symbolForTplContextId];
@@ -9485,7 +9493,7 @@
9485
9493
  yield _this6.storyboardContextWrapper.define(brickConf.context, context, brick);
9486
9494
  yield _this6.preCheckPermissions(brickConf, context);
9487
9495
  var trackingContextList = [];
9488
- Object.assign(brick, {
9496
+ Object.assign(brick, _objectSpread__default["default"]({
9489
9497
  type: tplTagName || brickConf.brick,
9490
9498
  properties: computeRealProperties(brickConf.properties, context, brickConf.injectDeep !== false, trackingContextList),
9491
9499
  events: brickUtils.isObject(brickConf.events) ? brickConf.events : {},
@@ -9495,7 +9503,11 @@
9495
9503
  refForProxy: brickConf[symbolForRefForProxy],
9496
9504
  tplContextId,
9497
9505
  iid: brickConf.iid
9498
- });
9506
+ }, (_brickConf$lifeCycle = brickConf.lifeCycle) !== null && _brickConf$lifeCycle !== void 0 && _brickConf$lifeCycle.onScrollIntoView ? {
9507
+ lifeCycle: {
9508
+ onScrollIntoView: brickConf.lifeCycle.onScrollIntoView
9509
+ }
9510
+ } : {}));
9499
9511
 
9500
9512
  if (brickConf[symbolForComputedPropsFromProxy]) {
9501
9513
  Object.entries(brickConf[symbolForComputedPropsFromProxy]).forEach(_ref2 => {
@@ -9510,7 +9522,11 @@
9510
9522
  brick.refForProxy.brick = brick;
9511
9523
  }
9512
9524
 
9513
- _this6.registerHandlersFromLifeCycle(brickConf.lifeCycle, brick, match, tplContextId); // Then, resolve the brick.
9525
+ _this6.registerHandlersFromLifeCycle(brickConf.lifeCycle, brick, match, tplContextId);
9526
+
9527
+ if ((_brick$lifeCycle = brick.lifeCycle) !== null && _brick$lifeCycle !== void 0 && _brick$lifeCycle.onScrollIntoView) {
9528
+ _this6.brickBindObserver(brick);
9529
+ } // Then, resolve the brick.
9514
9530
 
9515
9531
 
9516
9532
  yield _this6.resolver.resolve(brickConf, brick, context);
@@ -9585,7 +9601,8 @@
9585
9601
  onAnchorUnload,
9586
9602
  onMediaChange,
9587
9603
  onMessage,
9588
- onMessageClose
9604
+ onMessageClose,
9605
+ onScrollIntoView
9589
9606
  } = lifeCycle !== null && lifeCycle !== void 0 ? lifeCycle : {};
9590
9607
 
9591
9608
  if (onBeforePageLoad) {
@@ -9668,6 +9685,15 @@
9668
9685
  handler: onMessageClose
9669
9686
  });
9670
9687
  }
9688
+
9689
+ if (onScrollIntoView) {
9690
+ this.scrollIntoViewHandlersMap.set(brick.iid, {
9691
+ brick,
9692
+ match,
9693
+ tplContextId,
9694
+ handler: onScrollIntoView.handlers
9695
+ });
9696
+ }
9671
9697
  }
9672
9698
 
9673
9699
  handleBeforePageLoad() {
@@ -9722,6 +9748,17 @@
9722
9748
  }), this.messageCloseHandlers);
9723
9749
  }
9724
9750
 
9751
+ handleScrollIntoView(id) {
9752
+ var currentHandlers = this.scrollIntoViewHandlersMap.get(id);
9753
+ this.dispatchLifeCycleEvent(new CustomEvent("scroll.into.view"), [currentHandlers]);
9754
+ }
9755
+
9756
+ handleBrickBindObserver() {
9757
+ this.observersList.forEach(value => {
9758
+ value.$$observe();
9759
+ });
9760
+ }
9761
+
9725
9762
  getCurrentMatch() {
9726
9763
  return this.currentMatch;
9727
9764
  }
@@ -9754,6 +9791,27 @@
9754
9791
  })();
9755
9792
  }
9756
9793
 
9794
+ brickBindObserver(brick) {
9795
+ var _brick$lifeCycle$onSc;
9796
+
9797
+ var threshold = (_brick$lifeCycle$onSc = brick.lifeCycle.onScrollIntoView.threshold) !== null && _brick$lifeCycle$onSc !== void 0 ? _brick$lifeCycle$onSc : 0.1;
9798
+ var observer = new IntersectionObserver((entries, observer) => {
9799
+ entries.forEach(entry => {
9800
+ if (entry.isIntersecting) {
9801
+ if (entry.intersectionRatio >= threshold) {
9802
+ this.handleScrollIntoView(brick.iid);
9803
+ observer.disconnect();
9804
+ }
9805
+ }
9806
+ });
9807
+ }, {
9808
+ threshold
9809
+ });
9810
+ this.observersList.push({
9811
+ $$observe: () => observer.observe(brick.element)
9812
+ });
9813
+ }
9814
+
9757
9815
  }
9758
9816
 
9759
9817
  function unmountTree(mountPoint) {
@@ -10633,6 +10691,8 @@
10633
10691
  window.scrollTo(0, 0);
10634
10692
 
10635
10693
  if (!failed) {
10694
+ _this3.locationContext.handleBrickBindObserver();
10695
+
10636
10696
  _this3.locationContext.handlePageLoad();
10637
10697
 
10638
10698
  _this3.locationContext.handleAnchorLoad();