@next-core/brick-kit 2.137.1 → 2.139.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/dist/index.esm.js CHANGED
@@ -3925,15 +3925,33 @@ function _internalApiLoadDynamicBricksInBrickConf(brickConf) {
3925
3925
  }
3926
3926
 
3927
3927
  var _excluded$5 = ["extraQuery", "clear", "keepHash"];
3928
+ var blocked = false;
3929
+ function getUserConfirmation(message, callback) {
3930
+ blocked = !confirm(message);
3931
+ callback(!blocked);
3932
+ }
3928
3933
  function historyExtended(browserHistory) {
3929
3934
  var {
3930
3935
  push: originalPush,
3931
3936
  replace: originalReplace
3932
3937
  } = browserHistory;
3933
3938
 
3939
+ function push(location, state, callback) {
3940
+ blocked = false;
3941
+ originalPush(location, state);
3942
+ callback === null || callback === void 0 ? void 0 : callback(blocked);
3943
+ }
3944
+
3945
+ function replace(location, state, callback) {
3946
+ blocked = false;
3947
+ originalReplace(location, state);
3948
+ callback === null || callback === void 0 ? void 0 : callback(blocked);
3949
+ }
3950
+
3934
3951
  function updateQueryFactory(method) {
3935
3952
  return function updateQuery(query) {
3936
3953
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3954
+ var callback = arguments.length > 2 ? arguments[2] : undefined;
3937
3955
 
3938
3956
  var {
3939
3957
  extraQuery,
@@ -3960,30 +3978,28 @@ function historyExtended(browserHistory) {
3960
3978
  }
3961
3979
  }
3962
3980
 
3963
- (method === "push" ? originalPush : originalReplace)("?".concat(urlSearchParams.toString()).concat(keepHash ? browserHistory.location.hash : ""), state);
3981
+ (method === "push" ? push : replace)("?".concat(urlSearchParams.toString()).concat(keepHash ? browserHistory.location.hash : ""), state, callback);
3964
3982
  };
3965
3983
  }
3966
3984
 
3967
- function updateAnchorFactory(method) {
3968
- return function updateAnchor(hash, state) {
3969
- (method === "push" ? originalPush : originalReplace)(_objectSpread(_objectSpread({}, browserHistory.location), {}, {
3970
- key: undefined,
3971
- hash,
3972
- state: _objectSpread({
3973
- // The default notify is false
3974
- notify: false
3975
- }, state)
3976
- }));
3977
- };
3985
+ function pushAnchor(hash, state, callback) {
3986
+ push(_objectSpread(_objectSpread({}, browserHistory.location), {}, {
3987
+ key: undefined,
3988
+ hash,
3989
+ state: _objectSpread({
3990
+ // The default notify is false
3991
+ notify: false
3992
+ }, state)
3993
+ }), undefined, callback);
3978
3994
  }
3979
3995
 
3980
- function reload() {
3981
- originalReplace(_objectSpread(_objectSpread({}, browserHistory.location), {}, {
3996
+ function reload(callback) {
3997
+ replace(_objectSpread(_objectSpread({}, browserHistory.location), {}, {
3982
3998
  state: _objectSpread(_objectSpread({}, browserHistory.location.state), {}, {
3983
3999
  // Always notify
3984
4000
  notify: true
3985
4001
  })
3986
- }));
4002
+ }), undefined, callback);
3987
4003
  }
3988
4004
 
3989
4005
  var blockMessage;
@@ -4003,13 +4019,17 @@ function historyExtended(browserHistory) {
4003
4019
  return _objectSpread({
4004
4020
  pushQuery: updateQueryFactory("push"),
4005
4021
  replaceQuery: updateQueryFactory("replace"),
4006
- pushAnchor: updateAnchorFactory("push"),
4007
- // replaceAnchor: updateAnchorFactory("replace"),
4022
+ pushAnchor: pushAnchor,
4008
4023
  reload,
4009
4024
  setBlockMessage,
4010
4025
  getBlockMessage,
4011
- unblock
4012
- }, window.STANDALONE_MICRO_APPS ? standaloneHistoryOverridden(browserHistory) : null);
4026
+ unblock,
4027
+ push,
4028
+ replace
4029
+ }, window.STANDALONE_MICRO_APPS ? standaloneHistoryOverridden(_objectSpread(_objectSpread({}, browserHistory), {}, {
4030
+ push,
4031
+ replace
4032
+ })) : {});
4013
4033
  }
4014
4034
  /**
4015
4035
  * Override history for standalone micro apps.
@@ -4024,7 +4044,7 @@ function standaloneHistoryOverridden(browserHistory) {
4024
4044
  } = browserHistory;
4025
4045
 
4026
4046
  function updateFactory(method) {
4027
- return function update(path, state) {
4047
+ return function update(path, state, callback) {
4028
4048
  var pathname;
4029
4049
  var pathIsString = typeof path === "string";
4030
4050
 
@@ -4035,7 +4055,7 @@ function standaloneHistoryOverridden(browserHistory) {
4035
4055
  }
4036
4056
 
4037
4057
  if (pathname === "" || _internalApiHasMatchedApp(pathname)) {
4038
- return (method === "push" ? originalPush : originalReplace)(path, state);
4058
+ return (method === "push" ? originalPush : originalReplace)(path, state, callback);
4039
4059
  } // Going to outside apps.
4040
4060
 
4041
4061
 
@@ -4054,7 +4074,8 @@ var history;
4054
4074
 
4055
4075
  function createHistory() {
4056
4076
  var browserHistory = createBrowserHistory({
4057
- basename: getBasePath().replace(/\/$/, "")
4077
+ basename: getBasePath().replace(/\/$/, ""),
4078
+ getUserConfirmation
4058
4079
  });
4059
4080
  Object.assign(browserHistory, historyExtended(browserHistory));
4060
4081
  history = browserHistory;
@@ -6304,17 +6325,15 @@ function listenerFactory(handler, context, runtimeBrick) {
6304
6325
  case "history.replaceQuery":
6305
6326
  case "history.pushAnchor":
6306
6327
  case "history.block":
6307
- return builtinHistoryListenerFactory(method, handler.args, handler, context);
6308
-
6309
6328
  case "history.goBack":
6310
6329
  case "history.goForward":
6311
6330
  case "history.reload":
6312
6331
  case "history.unblock":
6313
- return builtinHistoryWithoutArgsListenerFactory(method, handler, context);
6332
+ return builtinHistoryListenerFactory(method, handler.args, handler, handler.callback, context);
6314
6333
 
6315
6334
  case "segue.push":
6316
6335
  case "segue.replace":
6317
- return builtinSegueListenerFactory(method, handler.args, handler, context);
6336
+ return builtinSegueListenerFactory(method, handler.args, handler, handler.callback, context);
6318
6337
 
6319
6338
  case "alias.push":
6320
6339
  case "alias.replace":
@@ -6556,7 +6575,7 @@ function builtinLocationListenerFactory(method, args, ifContainer, context) {
6556
6575
  };
6557
6576
  }
6558
6577
 
6559
- function builtinSegueListenerFactory(method, args, ifContainer, context) {
6578
+ function builtinSegueListenerFactory(method, args, ifContainer, callback, context) {
6560
6579
  return function (event) {
6561
6580
  if (!looseCheckIf(ifContainer, _objectSpread(_objectSpread({}, context), {}, {
6562
6581
  event
@@ -6569,7 +6588,15 @@ function builtinSegueListenerFactory(method, args, ifContainer, context) {
6569
6588
  segues
6570
6589
  } = _internalApiGetCurrentContext();
6571
6590
 
6572
- getHistory()[method](getUrlBySegueFactory(app, segues)(...argsFactory(args, context, event)));
6591
+ getHistory()[method](getUrlBySegueFactory(app, segues)(...argsFactory(args, context, event)), undefined, callback ? blocked => {
6592
+ var callbackFactory = eventCallbackFactory(callback, () => context, null);
6593
+ callbackFactory(blocked ? "error" : "success")({
6594
+ blocked
6595
+ });
6596
+ callbackFactory("finally")({
6597
+ blocked
6598
+ });
6599
+ } : undefined);
6573
6600
  };
6574
6601
  }
6575
6602
 
@@ -6832,7 +6859,7 @@ function _brickCallback() {
6832
6859
  return _brickCallback.apply(this, arguments);
6833
6860
  }
6834
6861
 
6835
- function builtinHistoryListenerFactory(method, args, ifContainer, context) {
6862
+ function builtinHistoryListenerFactory(method, args, ifContainer, callback, context) {
6836
6863
  return function (event) {
6837
6864
  if (!looseCheckIf(ifContainer, _objectSpread(_objectSpread({}, context), {}, {
6838
6865
  event
@@ -6840,21 +6867,52 @@ function builtinHistoryListenerFactory(method, args, ifContainer, context) {
6840
6867
  return;
6841
6868
  }
6842
6869
 
6843
- getHistory()[method === "block" ? "setBlockMessage" : method](...argsFactory(args, context, event, {
6844
- useEventDetailAsDefault: true
6845
- }));
6846
- };
6847
- }
6870
+ var baseArgsLength = 0;
6871
+ var hasCallback = false;
6872
+ var overrideMethod = method;
6848
6873
 
6849
- function builtinHistoryWithoutArgsListenerFactory(method, ifContainer, context) {
6850
- return function (event) {
6851
- if (!looseCheckIf(ifContainer, _objectSpread(_objectSpread({}, context), {}, {
6852
- event
6853
- }))) {
6854
- return;
6874
+ switch (method) {
6875
+ case "push":
6876
+ case "replace":
6877
+ case "pushQuery":
6878
+ case "replaceQuery":
6879
+ case "pushAnchor":
6880
+ baseArgsLength = 2;
6881
+ hasCallback = true;
6882
+ break;
6883
+
6884
+ case "reload":
6885
+ hasCallback = true;
6886
+ break;
6887
+
6888
+ case "block":
6889
+ baseArgsLength = 1;
6890
+ overrideMethod = "setBlockMessage";
6891
+ break;
6892
+ }
6893
+
6894
+ var computedArgs = [];
6895
+
6896
+ if (baseArgsLength > 0) {
6897
+ computedArgs = argsFactory(args, context, event, {
6898
+ useEventDetailAsDefault: true
6899
+ });
6900
+ computedArgs.length = baseArgsLength;
6901
+ }
6902
+
6903
+ if (hasCallback && callback) {
6904
+ var callbackFactory = eventCallbackFactory(callback, () => context, null);
6905
+ computedArgs.push(blocked => {
6906
+ callbackFactory(blocked ? "error" : "success")({
6907
+ blocked
6908
+ });
6909
+ callbackFactory("finally")({
6910
+ blocked
6911
+ });
6912
+ });
6855
6913
  }
6856
6914
 
6857
- getHistory()[method]();
6915
+ getHistory()[overrideMethod](...computedArgs);
6858
6916
  };
6859
6917
  }
6860
6918
 
@@ -8390,6 +8448,10 @@ function expandCustomTemplate(brickConf, proxyBrick, context) {
8390
8448
  var tplContext = new CustomTemplateContext(proxyBrick);
8391
8449
  var template = customTemplateRegistry.get(brickConf.brick);
8392
8450
 
8451
+ if (template.contracts) {
8452
+ collectWidgetContract(template.contracts);
8453
+ }
8454
+
8393
8455
  if (Array.isArray(template.state)) {
8394
8456
  tplContext.state.syncDefine(template.state, context, proxyBrick);
8395
8457
  }
@@ -8405,6 +8467,10 @@ function _asyncExpandCustomTemplate() {
8405
8467
  var tplContext = new CustomTemplateContext(proxyBrick);
8406
8468
  var template = customTemplateRegistry.get(brickConf.brick);
8407
8469
 
8470
+ if (template.contracts) {
8471
+ collectWidgetContract(template.contracts);
8472
+ }
8473
+
8408
8474
  if (Array.isArray(template.state)) {
8409
8475
  yield tplContext.state.define(template.state, context, proxyBrick);
8410
8476
  }
@@ -8418,8 +8484,7 @@ function lowLevelExpandCustomTemplate(template, brickConf, proxyBrick, context,
8418
8484
  var {
8419
8485
  bricks,
8420
8486
  proxy,
8421
- state,
8422
- contracts
8487
+ state
8423
8488
  } = template;
8424
8489
 
8425
8490
  var {
@@ -8435,11 +8500,6 @@ function lowLevelExpandCustomTemplate(template, brickConf, proxyBrick, context,
8435
8500
  proxyBrick.proxy = proxyCopy;
8436
8501
  proxyBrick.proxyRefs = new Map();
8437
8502
  proxyBrick.stateNames = state === null || state === void 0 ? void 0 : state.map(item => item.name);
8438
-
8439
- if (contracts) {
8440
- collectWidgetContract(contracts);
8441
- }
8442
-
8443
8503
  var refToBrickConf = collectRefsInTemplate(template); // Reversed proxies are used for expand storyboard before rendering page.
8444
8504
 
8445
8505
  var reversedProxies = {
@@ -12022,7 +12082,7 @@ class Router {
12022
12082
  };
12023
12083
 
12024
12084
  if (storyboard) {
12025
- var _currentApp$breadcrum, _currentApp$breadcrum2;
12085
+ var _currentApp$breadcrum, _currentApp$breadcrum2, _currentApp$breadcrum3, _currentApp$breadcrum4;
12026
12086
 
12027
12087
  var {
12028
12088
  bricks,
@@ -12046,7 +12106,7 @@ class Router {
12046
12106
  appBar: {
12047
12107
  breadcrumb: [],
12048
12108
  documentId: null,
12049
- noCurrentApp: (_currentApp$breadcrum = (_currentApp$breadcrum2 = currentApp.breadcrumb) === null || _currentApp$breadcrum2 === void 0 ? void 0 : _currentApp$breadcrum2.noCurrentApp) !== null && _currentApp$breadcrum !== void 0 ? _currentApp$breadcrum : false
12109
+ noCurrentApp: typeof ((_currentApp$breadcrum = currentApp.breadcrumb) === null || _currentApp$breadcrum === void 0 ? void 0 : _currentApp$breadcrum.noCurrentApp) === "string" ? computeRealValue((_currentApp$breadcrum2 = currentApp.breadcrumb) === null || _currentApp$breadcrum2 === void 0 ? void 0 : _currentApp$breadcrum2.noCurrentApp, _this3.locationContext.getCurrentContext()) : (_currentApp$breadcrum3 = (_currentApp$breadcrum4 = currentApp.breadcrumb) === null || _currentApp$breadcrum4 === void 0 ? void 0 : _currentApp$breadcrum4.noCurrentApp) !== null && _currentApp$breadcrum3 !== void 0 ? _currentApp$breadcrum3 : false
12050
12110
  },
12051
12111
  flags: {
12052
12112
  redirect: undefined,