@next-core/brick-kit 2.73.0 → 2.74.1

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.esm.js CHANGED
@@ -10,12 +10,11 @@ import React__default, { useState, useEffect, forwardRef, useRef, useImperativeH
10
10
  import { HttpResponseError, HttpFetchError, http } from '@next-core/brick-http';
11
11
  import { ExclamationCircleOutlined } from '@ant-design/icons';
12
12
  import i18next from 'i18next';
13
- import lodash, { set, get, sortBy, isEmpty, difference, cloneDeep, merge, clamp, uniqueId, orderBy, omit } from 'lodash';
13
+ import lodash, { set, get, isNil, sortBy, isEmpty, difference, cloneDeep, merge, clamp, uniqueId, orderBy, omit } from 'lodash';
14
14
  import moment from 'moment';
15
15
  import { pipes } from '@next-core/pipes';
16
16
  import yaml from 'js-yaml';
17
17
  import { apiAnalyzer } from '@next-core/easyops-analytics';
18
- import require$$0 from 'path';
19
18
  import { withTranslation } from 'react-i18next';
20
19
  import _extends$2 from '@babel/runtime/helpers/esm/extends';
21
20
  import { getIllustration } from '@next-core/illustrations';
@@ -1349,7 +1348,16 @@ function _constructMenu() {
1349
1348
  var hasSubMenu = !!menuBar.subMenuId;
1350
1349
 
1351
1350
  if (menuBar.menuId) {
1352
- menuBar.menu = yield processMenu(menuBar.menuId, context, kernel, hasSubMenu);
1351
+ var _menuBar$menu;
1352
+
1353
+ var defaultCollapsed = (_menuBar$menu = menuBar.menu) === null || _menuBar$menu === void 0 ? void 0 : _menuBar$menu.defaultCollapsed;
1354
+ var menu = yield processMenu(menuBar.menuId, context, kernel, hasSubMenu);
1355
+
1356
+ if (!isNil(defaultCollapsed)) {
1357
+ menu.defaultCollapsed = defaultCollapsed;
1358
+ }
1359
+
1360
+ menuBar.menu = menu;
1353
1361
  }
1354
1362
 
1355
1363
  if (hasSubMenu) {
@@ -2331,7 +2339,7 @@ function StoryboardFunctionRegistryFactory({
2331
2339
  }
2332
2340
 
2333
2341
  function getStoryboardFunction(name) {
2334
- var _collector, _collector2, _collector3;
2342
+ var _collector, _collector2, _collector3, _collector4;
2335
2343
 
2336
2344
  var fn = registeredFunctions.get(name);
2337
2345
 
@@ -2365,7 +2373,8 @@ function StoryboardFunctionRegistryFactory({
2365
2373
  }),
2366
2374
  hooks: {
2367
2375
  beforeEvaluate: (_collector2 = collector) === null || _collector2 === void 0 ? void 0 : _collector2.beforeEvaluate,
2368
- beforeBranch: (_collector3 = collector) === null || _collector3 === void 0 ? void 0 : _collector3.beforeBranch
2376
+ beforeCall: (_collector3 = collector) === null || _collector3 === void 0 ? void 0 : _collector3.beforeCall,
2377
+ beforeBranch: (_collector4 = collector) === null || _collector4 === void 0 ? void 0 : _collector4.beforeBranch
2369
2378
  }
2370
2379
  });
2371
2380
  fn.processed = true;
@@ -3285,7 +3294,7 @@ var path = {
3285
3294
  };
3286
3295
 
3287
3296
  try {
3288
- path = require$$0;
3297
+ path = require('path');
3289
3298
  } catch (er) {}
3290
3299
 
3291
3300
  var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {};
@@ -5655,6 +5664,14 @@ class Kernel {
5655
5664
 
5656
5665
  _defineProperty$2(this, "loadingBar", void 0);
5657
5666
 
5667
+ _defineProperty$2(this, "navBar", void 0);
5668
+
5669
+ _defineProperty$2(this, "sideBar", void 0);
5670
+
5671
+ _defineProperty$2(this, "footer", void 0);
5672
+
5673
+ _defineProperty$2(this, "breadcrumb", void 0);
5674
+
5658
5675
  _defineProperty$2(this, "router", void 0);
5659
5676
 
5660
5677
  _defineProperty$2(this, "currentApp", void 0);
@@ -5669,6 +5686,8 @@ class Kernel {
5669
5686
 
5670
5687
  _defineProperty$2(this, "currentLayout", void 0);
5671
5688
 
5689
+ _defineProperty$2(this, "enableUiV8", false);
5690
+
5672
5691
  _defineProperty$2(this, "allUserMapPromise", Promise.resolve(new Map()));
5673
5692
 
5674
5693
  _defineProperty$2(this, "allMagicBrickConfigMapPromise", Promise.resolve(new Map()));
@@ -5697,13 +5716,20 @@ class Kernel {
5697
5716
  throw new Error("No storyboard were found.");
5698
5717
  }
5699
5718
 
5719
+ _this.setUiVersion();
5720
+
5700
5721
  if (isLoggedIn()) {
5701
5722
  _this.loadSharedData();
5702
5723
  }
5703
5724
 
5704
5725
  _this.menuBar = new MenuBar(_this, "menuBar");
5705
5726
  _this.appBar = new AppBar(_this, "appBar");
5706
- _this.loadingBar = new BaseBar(_this, "loadingBar");
5727
+ _this.loadingBar = new BaseBar(_this, "loadingBar"); // Todo(nlicro): 这里需要新写对应的NavBar...
5728
+
5729
+ _this.navBar = new BaseBar(_this, "navBar");
5730
+ _this.sideBar = new BaseBar(_this, "sideBar");
5731
+ _this.breadcrumb = new BaseBar(_this, "breadcrumb");
5732
+ _this.footer = new BaseBar(_this, "footer");
5707
5733
  _this.router = new Router(_this);
5708
5734
  yield _this.router.bootstrap();
5709
5735
 
@@ -5728,7 +5754,13 @@ class Kernel {
5728
5754
  loadingBar: "business-website.loading-bar",
5729
5755
  pageNotFound: "business-website.page-not-found",
5730
5756
  pageError: "business-website.page-error"
5731
- } : _objectSpread(_objectSpread({}, _this2.bootstrapData.navbar), {}, {
5757
+ } : _objectSpread(_objectSpread({}, _this2.enableUiV8 ? {
5758
+ loadingBar: _this2.bootstrapData.navbar.loadingBar,
5759
+ navBar: "frame-bricks.nav-bar",
5760
+ sideBar: "frame-bricks.side-bar",
5761
+ breadcrumb: null,
5762
+ footer: null
5763
+ } : _this2.bootstrapData.navbar), {}, {
5732
5764
  pageNotFound: "basic-bricks.page-not-found",
5733
5765
  pageError: "basic-bricks.page-error"
5734
5766
  });
@@ -5743,7 +5775,7 @@ class Kernel {
5743
5775
 
5744
5776
  yield Promise.all([_this2.menuBar.bootstrap(_this2.presetBricks.menuBar, {
5745
5777
  testid: "brick-next-menu-bar"
5746
- }), _this2.appBar.bootstrap(_this2.presetBricks.appBar), _this2.loadingBar.bootstrap(_this2.presetBricks.loadingBar)]);
5778
+ }), _this2.appBar.bootstrap(_this2.presetBricks.appBar), _this2.navBar.bootstrap(_this2.presetBricks.navBar), _this2.sideBar.bootstrap(_this2.presetBricks.sideBar), _this2.footer.bootstrap(_this2.presetBricks.footer), _this2.breadcrumb.bootstrap(_this2.presetBricks.breadcrumb), _this2.loadingBar.bootstrap(_this2.presetBricks.loadingBar)]);
5747
5779
  })();
5748
5780
  }
5749
5781
 
@@ -6002,7 +6034,7 @@ class Kernel {
6002
6034
  this.appBar.setBreadcrumb(null);
6003
6035
  }
6004
6036
 
6005
- this.appBar.setPageTitle(null);
6037
+ getRuntime().applyPageTitle(null);
6006
6038
  }
6007
6039
 
6008
6040
  toggleLegacyIframe(visible) {
@@ -6261,6 +6293,16 @@ class Kernel {
6261
6293
  })();
6262
6294
  }
6263
6295
 
6296
+ setUiVersion() {
6297
+ // get from localStorage fot test
6298
+ // this.enableUiV8 = this.getFeatureFlags()["ui-v8"];
6299
+ this.enableUiV8 = !!localStorage.getItem("test-ui-v8");
6300
+
6301
+ if (this.enableUiV8) {
6302
+ document.documentElement.dataset.ui = "v8";
6303
+ }
6304
+ }
6305
+
6264
6306
  } // Since `@next-dll/editor-bricks-helper` depends on `@next-dll/react-dnd`,
6265
6307
  // always load react-dnd before loading editor-bricks-helper.
6266
6308
 
@@ -7551,7 +7593,7 @@ class LocationContext {
7551
7593
 
7552
7594
  if (menuId) {
7553
7595
  mountRoutesResult.menuBar.menuId = menuId;
7554
- mountRoutesResult.menuBar.menu = null;
7596
+ mountRoutesResult.menuBar.menu = sidebarMenu;
7555
7597
  } else if (sidebarMenu) {
7556
7598
  mountRoutesResult.menuBar.menu = sidebarMenu;
7557
7599
  mountRoutesResult.menuBar.menuId = null;
@@ -8518,7 +8560,10 @@ class Router {
8518
8560
  }; // Omit the "key" when checking whether locations are equal in certain situations.
8519
8561
 
8520
8562
  if ( // When current location is triggered by browser action of hash link.
8521
- location.key === undefined || action === "POP" && (_this.prevLocation.key === undefined || // or the previous location specified notify false.
8563
+ location.key === undefined || // When current location is triggered by browser action of non-push-or-replace,
8564
+ // such as goBack or goForward,
8565
+ action === "POP" && ( // and the previous location was triggered by hash link,
8566
+ _this.prevLocation.key === undefined || // or the previous location specified notify false.
8522
8567
  ((_this$prevLocation$st = _this.prevLocation.state) === null || _this$prevLocation$st === void 0 ? void 0 : _this$prevLocation$st.notify) === false)) {
8523
8568
  omittedLocationProps.key = null;
8524
8569
  }
@@ -8754,30 +8799,33 @@ class Router {
8754
8799
  if (barsHidden || getRuntimeMisc().isInIframeOfLegacyConsole) {
8755
8800
  _this3.kernel.toggleBars(false);
8756
8801
  } else if (_this3.kernel.currentLayout === "console") {
8757
- var _menuBar$menu, _menuBar$menu2;
8802
+ /* istanbul ignore next */
8803
+ if (!_this3.kernel.enableUiV8) {
8804
+ var _menuBar$menu, _menuBar$menu2;
8758
8805
 
8759
- yield constructMenu(menuBar, _this3.locationContext.getCurrentContext(), _this3.kernel);
8806
+ yield constructMenu(menuBar, _this3.locationContext.getCurrentContext(), _this3.kernel);
8760
8807
 
8761
- if (shouldBeDefaultCollapsed((_menuBar$menu = menuBar.menu) === null || _menuBar$menu === void 0 ? void 0 : _menuBar$menu.defaultCollapsed, (_menuBar$menu2 = menuBar.menu) === null || _menuBar$menu2 === void 0 ? void 0 : _menuBar$menu2.defaultCollapsedBreakpoint)) {
8762
- _this3.kernel.menuBar.collapse(true);
8808
+ if (shouldBeDefaultCollapsed((_menuBar$menu = menuBar.menu) === null || _menuBar$menu === void 0 ? void 0 : _menuBar$menu.defaultCollapsed, (_menuBar$menu2 = menuBar.menu) === null || _menuBar$menu2 === void 0 ? void 0 : _menuBar$menu2.defaultCollapsedBreakpoint)) {
8809
+ _this3.kernel.menuBar.collapse(true);
8763
8810
 
8764
- _this3.defaultCollapsed = true;
8765
- } else {
8766
- if (_this3.defaultCollapsed) {
8767
- _this3.kernel.menuBar.collapse(false);
8811
+ _this3.defaultCollapsed = true;
8812
+ } else {
8813
+ if (_this3.defaultCollapsed) {
8814
+ _this3.kernel.menuBar.collapse(false);
8815
+ }
8816
+
8817
+ _this3.defaultCollapsed = false;
8768
8818
  }
8769
8819
 
8770
- _this3.defaultCollapsed = false;
8771
- }
8820
+ if (actualLegacy === "iframe") {
8821
+ // Do not modify breadcrumb in iframe mode,
8822
+ // it will be *popped* from iframe automatically.
8823
+ delete appBar.breadcrumb;
8824
+ }
8772
8825
 
8773
- if (actualLegacy === "iframe") {
8774
- // Do not modify breadcrumb in iframe mode,
8775
- // it will be *popped* from iframe automatically.
8776
- delete appBar.breadcrumb;
8826
+ mountStaticNode(_this3.kernel.menuBar.element, menuBar);
8827
+ mountStaticNode(_this3.kernel.appBar.element, appBar);
8777
8828
  }
8778
-
8779
- mountStaticNode(_this3.kernel.menuBar.element, menuBar);
8780
- mountStaticNode(_this3.kernel.appBar.element, appBar);
8781
8829
  }
8782
8830
 
8783
8831
  _this3.kernel.toggleLegacyIframe(actualLegacy === "iframe");