@next-core/brick-kit 2.122.2 → 2.122.5

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,7 +10,7 @@ import i18next, { getFixedT } from 'i18next';
10
10
  import { parsePath, createBrowserHistory, locationsAreEqual, createPath } from 'history';
11
11
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
12
12
  import { JsonStorage, toPath, computeRealRoutePath, hasOwnProperty, isObject, isEvaluable, transformAndInject, transform, trackContext, trackState, scanPermissionActionsInStoryboard, precookFunction, cook, resolveContextConcurrently, syncResolveContextConcurrently, shouldAllowRecursiveEvaluations, preevaluate, inject, deepFreeze, createProviderClass, loadScript, getTemplateDepsOfStoryboard, getDllAndDepsOfStoryboard, asyncProcessStoryboard, getDllAndDepsByResource, scanRouteAliasInStoryboard, prefetchScript, scanBricksInBrickConf, scanProcessorsInAny, matchPath, scanAppGetMenuInAny, asyncProcessBrick, restoreDynamicTemplates, scanStoryboard, mapCustomApisToNameAndNamespace } from '@next-core/brick-utils';
13
- import lodash, { set, get, difference, identity, uniqueId, cloneDeep, clamp, isNil, sortBy, merge, pick, orderBy, omit, findLastIndex, noop, isObject as isObject$1, isString } from 'lodash';
13
+ import _, { set, get, difference, identity, uniqueId, cloneDeep, clamp, isNil, sortBy, merge, pick, orderBy, omit, findLastIndex, noop, isObject as isObject$1, isString } from 'lodash';
14
14
  import moment from 'moment';
15
15
  import { pipes } from '@next-core/pipes';
16
16
  import yaml from 'js-yaml';
@@ -564,24 +564,6 @@ var InstanceApi_postSearch = /*#__PURE__*/function () {
564
564
  return _ref.apply(this, arguments);
565
565
  };
566
566
  }();
567
- /**
568
- * @description 搜索实例V3 (支持多属性排序)
569
- * @endpoint POST /v3/object/:objectId/instance/_search
570
- */
571
-
572
-
573
- var InstanceApi_postSearchV3 = /*#__PURE__*/function () {
574
- var _ref = _asyncToGenerator$3(function* (objectId, data, options) {
575
- return (
576
- /**! @contract easyops.api.cmdb.instance.PostSearchV3 */
577
- (yield http.post("api/gateway/cmdb.instance.PostSearchV3/v3/object/".concat(objectId, "/instance/_search"), data, options)).data
578
- );
579
- });
580
-
581
- return function InstanceApi_postSearchV3(_x, _x2, _x3) {
582
- return _ref.apply(this, arguments);
583
- };
584
- }();
585
567
 
586
568
  function supply(attemptToVisitGlobals, providedGlobalVariables, mock) {
587
569
  var globalVariables = _objectSpread({}, providedGlobalVariables); // Allow limited browser builtin values.
@@ -626,7 +608,7 @@ function supplyIndividual(variableName, mock) {
626
608
  return delegateMethods(Object, ["entries", "fromEntries", "keys", "values"]);
627
609
 
628
610
  case "_":
629
- return Object.fromEntries(Object.entries(lodash).filter(entry => !shouldOmitInLodash.has(entry[0])).concat(mock ? [["uniqueId", prefix => "".concat(prefix !== null && prefix !== void 0 ? prefix : "", "42")]] : []));
611
+ return Object.fromEntries(Object.entries(_).filter(entry => !shouldOmitInLodash.has(entry[0])).concat(mock ? [["uniqueId", prefix => "".concat(prefix !== null && prefix !== void 0 ? prefix : "", "42")]] : []));
630
612
 
631
613
  case "moment":
632
614
  return Object.assign(function () {
@@ -3402,6 +3384,11 @@ function _dev_only_updateTemplatePreviewSettings(appId, templateId, settings) {
3402
3384
  function _dev_only_updateSnippetPreviewSettings(appId, snippetData) {
3403
3385
  kernel._dev_only_updateSnippetPreviewSettings(appId, snippetData);
3404
3386
  }
3387
+ /* istanbul ignore next */
3388
+
3389
+ function _dev_only_updateFormPreviewSettings(appId, formId, settings) {
3390
+ kernel._dev_only_updateFormPreviewSettings(appId, formId, settings);
3391
+ }
3405
3392
  class Runtime {
3406
3393
  constructor() {
3407
3394
  _defineProperty$1(this, "registerBrickTemplate", registerBrickTemplate);
@@ -5842,51 +5829,6 @@ var ContractApi_searchSingleContract = /*#__PURE__*/function () {
5842
5829
  };
5843
5830
  }();
5844
5831
 
5845
- var mocks = {
5846
- mockId: null,
5847
- mockList: []
5848
- };
5849
- function registerMock(useMocks) {
5850
- var _useMocks$mockList;
5851
-
5852
- if (useMocks) mocks = _objectSpread(_objectSpread({}, useMocks), {}, {
5853
- mockList: (_useMocks$mockList = useMocks.mockList) === null || _useMocks$mockList === void 0 ? void 0 : _useMocks$mockList.map(item => {
5854
- var isFlowAPi = isCustomApiProvider(item.provider);
5855
- return _objectSpread(_objectSpread({}, item), {}, {
5856
- uri: "".concat(isFlowAPi ? item.uri.replace(/(.+?)\/(.+)/, (_match, p1, p2) => {
5857
- return "/".concat(p1, "(@\\d+\\.\\d+\\.\\d+)?/").concat(p2, "$");
5858
- }) : "/".concat(item.uri.split(".").slice(2).join("."), "$")).replace(/:\w+/g, "([^/]+)")
5859
- });
5860
- })
5861
- });
5862
- }
5863
- function getMockList() {
5864
- return mocks.mockList;
5865
- }
5866
- var getMockInfo = (requestUrl, method) => {
5867
- var transformGetMethod = method => {
5868
- if (method.toUpperCase() === "LIST") {
5869
- return "GET";
5870
- }
5871
-
5872
- return method === null || method === void 0 ? void 0 : method.toUpperCase();
5873
- };
5874
-
5875
- var item = mocks.mockList.find(item => new RegExp(item.uri).test(requestUrl) && transformGetMethod(item.method) === (method === null || method === void 0 ? void 0 : method.toUpperCase()));
5876
-
5877
- if (item) {
5878
- return {
5879
- url: requestUrl.replace(/(api\/gateway\/.+?)(@\d+\.\d+\.\d+)?\/(.+)/, (_match, p1, _p2, p3) => {
5880
- // 忽略版本
5881
- return "".concat(p1, "/").concat(p3);
5882
- }).replace(/(api\/gateway)/, "api/gateway/mock_server.proxy.".concat(mocks.mockId)),
5883
- mockId: mocks.mockId
5884
- };
5885
- }
5886
-
5887
- return;
5888
- };
5889
-
5890
5832
  var contractsMap = new Map();
5891
5833
  function collectContract(contracts) {
5892
5834
  contracts === null || contracts === void 0 ? void 0 : contracts.forEach(contract => {
@@ -6023,75 +5965,40 @@ function _fetchFlowApiDefinition2() {
6023
5965
  _fetchFlowApiDefinition2 = _asyncToGenerator$4(function* (provider) {
6024
5966
  var [namespaceName, nameWithVersion] = provider.split("@");
6025
5967
  var [name, version] = nameWithVersion.split(":");
6026
- var isUseMock = getMockList().find(item => item.provider === "".concat(namespaceName, "@").concat(name));
6027
-
6028
- if (isUseMock) {
6029
- var _list$;
5968
+ var contract;
6030
5969
 
6031
- var {
6032
- list
6033
- } = yield InstanceApi_postSearchV3("FLOW_BUILDER_API_CONTRACT@EASYOPS", {
6034
- fields: ["name", "namespaceId", "endpoint", "response", "version", "serviceName"],
6035
- query: {
6036
- namespaceId: {
6037
- $eq: namespaceName
6038
- },
6039
- name: {
6040
- $eq: name
6041
- }
5970
+ if (contract = getContract("".concat(namespaceName, ".").concat(name))) {
5971
+ return {
5972
+ name: contract.name,
5973
+ namespace: contract.namespaceId,
5974
+ serviceName: contract.serviceName,
5975
+ version: contract.version,
5976
+ contract: {
5977
+ endpoint: contract.endpoint,
5978
+ response: contract.response
6042
5979
  }
6043
- });
6044
-
6045
- if ((_list$ = list[0]) !== null && _list$ !== void 0 && _list$.instanceId) {
6046
- var _list$2, _list$3;
6047
-
6048
- return {
6049
- name: list[0].name,
6050
- namespace: (_list$2 = list[0]) === null || _list$2 === void 0 ? void 0 : _list$2.namespaceId,
6051
- serviceName: (_list$3 = list[0]) === null || _list$3 === void 0 ? void 0 : _list$3.serviceName,
6052
- version: list[0].version,
6053
- contract: {
6054
- endpoint: list[0].endpoint,
6055
- response: list[0].response
6056
- }
6057
- };
6058
- }
5980
+ };
6059
5981
  } else {
6060
- var contract;
5982
+ var {
5983
+ contractData
5984
+ } = yield ContractApi_searchSingleContract({
5985
+ contractName: "".concat(namespaceName, ".").concat(name),
5986
+ version
5987
+ }); // return undefined if don't found contract
5988
+
5989
+ if (contractData) {
5990
+ var _contractData$namespa, _contractData$namespa2;
6061
5991
 
6062
- if (contract = getContract("".concat(namespaceName, ".").concat(name))) {
6063
5992
  return {
6064
- name: contract.name,
6065
- namespace: contract.namespaceId,
6066
- serviceName: contract.serviceName,
6067
- version: contract.version,
5993
+ name: contractData.name,
5994
+ namespace: (_contractData$namespa = contractData.namespace) === null || _contractData$namespa === void 0 ? void 0 : (_contractData$namespa2 = _contractData$namespa[0]) === null || _contractData$namespa2 === void 0 ? void 0 : _contractData$namespa2.name,
5995
+ serviceName: contractData.serviceName,
5996
+ version: contractData.version,
6068
5997
  contract: {
6069
- endpoint: contract.endpoint,
6070
- response: contract.response
5998
+ endpoint: contractData.endpoint,
5999
+ response: contractData.response
6071
6000
  }
6072
6001
  };
6073
- } else {
6074
- var {
6075
- contractData
6076
- } = yield ContractApi_searchSingleContract({
6077
- contractName: "".concat(namespaceName, ".").concat(name),
6078
- version
6079
- }); // return undefined if don't found contract
6080
-
6081
- if (contractData) {
6082
- var _contractData$namespa, _contractData$namespa2;
6083
-
6084
- return {
6085
- name: contractData.name,
6086
- namespace: (_contractData$namespa = contractData.namespace) === null || _contractData$namespa === void 0 ? void 0 : (_contractData$namespa2 = _contractData$namespa[0]) === null || _contractData$namespa2 === void 0 ? void 0 : _contractData$namespa2.name,
6087
- serviceName: contractData.serviceName,
6088
- version: contractData.version,
6089
- contract: {
6090
- endpoint: contractData.endpoint,
6091
- response: contractData.response
6092
- }
6093
- };
6094
- }
6095
6002
  }
6096
6003
  }
6097
6004
  });
@@ -7910,6 +7817,19 @@ Object.keys(presetPrimaryColors).forEach(function (key) {
7910
7817
  });
7911
7818
  presetDarkPalettes[key].primary = presetDarkPalettes[key][5];
7912
7819
  });
7820
+ presetPalettes.red;
7821
+ presetPalettes.volcano;
7822
+ presetPalettes.gold;
7823
+ presetPalettes.orange;
7824
+ presetPalettes.yellow;
7825
+ presetPalettes.lime;
7826
+ presetPalettes.green;
7827
+ presetPalettes.cyan;
7828
+ presetPalettes.blue;
7829
+ presetPalettes.geekblue;
7830
+ presetPalettes.purple;
7831
+ presetPalettes.magenta;
7832
+ presetPalettes.grey;
7913
7833
 
7914
7834
  function getStyleByBaseColors(theme, baseColors, backgroundColor) {
7915
7835
  return (theme === "dark" ? getDarkStyle : getLightStyle)("".concat(getCssVariableDefinitionsByPalettes(generatePalettes(baseColors, theme, backgroundColor), theme), "\n").concat(getMigratedCssVariableDefinitions(theme, baseColors, backgroundColor)));
@@ -8034,6 +7954,9 @@ function applyColorTheme(options) {
8034
7954
  }
8035
7955
  }
8036
7956
 
7957
+ var formRenderer = "form-renderer.form-renderer";
7958
+ var filterProperties = ["brick", "slots", "properties", "events", "if", "context", "bricks", "mountPoint"];
7959
+
8037
7960
  class Kernel {
8038
7961
  constructor() {
8039
7962
  var _this = this;
@@ -8402,6 +8325,31 @@ class Kernel {
8402
8325
  }
8403
8326
  }
8404
8327
 
8328
+ _dev_only_updateFormPreviewSettings(appId, formId, formData) {
8329
+ var {
8330
+ routes
8331
+ } = this.bootstrapData.storyboards.find(item => item.app.id === appId);
8332
+ var previewPath = "${APP.homepage}/_dev_only_/form-preview/".concat(formId);
8333
+ var previewRouteIndex = routes.findIndex(route => route.path === previewPath);
8334
+ var newPreviewRoute = {
8335
+ path: previewPath,
8336
+ bricks: [{
8337
+ brick: formRenderer,
8338
+ properties: {
8339
+ formData: formData
8340
+ }
8341
+ }],
8342
+ menu: false,
8343
+ exact: true
8344
+ };
8345
+
8346
+ if (previewRouteIndex === -1) {
8347
+ routes.unshift(newPreviewRoute);
8348
+ } else {
8349
+ routes.splice(previewRouteIndex, 1, newPreviewRoute);
8350
+ }
8351
+ }
8352
+
8405
8353
  loadDepsOfStoryboard(storyboard) {
8406
8354
  return this.gracefullyLoadDeps(this._loadDepsOfStoryboard, storyboard);
8407
8355
  }
@@ -9102,6 +9050,299 @@ function listenOnTrackingContext(brick, trackingContextList, context) {
9102
9050
  }
9103
9051
  }
9104
9052
 
9053
+ function ExpandCustomForm(formData, brickConf) {
9054
+ var errorBrick = {
9055
+ brick: "presentational-bricks.brick-illustration",
9056
+ properties: {
9057
+ category: "default",
9058
+ header: {
9059
+ title: "参数错误"
9060
+ },
9061
+ mode: "guide",
9062
+ name: "search-empty"
9063
+ }
9064
+ };
9065
+
9066
+ try {
9067
+ var formStoryboard = getStoryboard([formData.formSchema], [], formData.fields);
9068
+ formStoryboard[0] = _.isEmpty(formStoryboard[0]) ? errorBrick : formStoryboard[0];
9069
+ return _objectSpread(_objectSpread({}, brickConf), {}, {
9070
+ brick: "div",
9071
+ slots: {
9072
+ "": {
9073
+ bricks: formStoryboard,
9074
+ type: "bricks"
9075
+ }
9076
+ }
9077
+ });
9078
+ } catch (error) {
9079
+ // eslint-disable-next-line no-console
9080
+ console.warn(error.message);
9081
+ return {
9082
+ brick: "div",
9083
+ slots: {
9084
+ "": {
9085
+ bricks: [errorBrick],
9086
+ type: "bricks"
9087
+ }
9088
+ }
9089
+ };
9090
+ }
9091
+ }
9092
+ function getDefaultProperties(_name, fields) {
9093
+ var field = fields.filter(item => item.id === _name)[0];
9094
+ var defaultValue = {};
9095
+
9096
+ if (field) {
9097
+ switch (field.type) {
9098
+ case "STRING":
9099
+ defaultValue = {
9100
+ brick: "forms.general-input",
9101
+ properties: {
9102
+ id: field.id,
9103
+ name: field.id,
9104
+ label: field.name,
9105
+ readOnly: field.limit.includes("readOnly"),
9106
+ required: field.limit.includes("required"),
9107
+ placeholder: field.description
9108
+ }
9109
+ };
9110
+ break;
9111
+
9112
+ case "INT":
9113
+ defaultValue = {
9114
+ brick: "forms.general-input-number",
9115
+ properties: {
9116
+ id: field.id,
9117
+ name: field.id,
9118
+ label: field.name,
9119
+ readOnly: field.limit.includes("readOnly"),
9120
+ required: field.limit.includes("required"),
9121
+ placeholder: field.description,
9122
+ precision: 0,
9123
+ inputBoxStyle: {
9124
+ width: "100%"
9125
+ }
9126
+ }
9127
+ };
9128
+ break;
9129
+
9130
+ case "BOOLEAN":
9131
+ defaultValue = {
9132
+ brick: "forms.general-switch",
9133
+ properties: {
9134
+ id: field.id,
9135
+ name: field.id,
9136
+ label: field.name,
9137
+ readOnly: field.limit.includes("readOnly"),
9138
+ required: field.limit.includes("required")
9139
+ }
9140
+ };
9141
+ break;
9142
+
9143
+ case "FLOAT":
9144
+ defaultValue = {
9145
+ brick: "forms.general-input-number",
9146
+ properties: {
9147
+ id: field.id,
9148
+ name: field.id,
9149
+ label: field.name,
9150
+ readOnly: field.limit.includes("readOnly"),
9151
+ required: field.limit.includes("required"),
9152
+ placeholder: field.description,
9153
+ inputBoxStyle: {
9154
+ width: "100%"
9155
+ }
9156
+ }
9157
+ };
9158
+ break;
9159
+
9160
+ case "ENUMERATED_SINGLE_OPTION":
9161
+ defaultValue = {
9162
+ brick: "forms.general-select",
9163
+ properties: {
9164
+ id: field.id,
9165
+ name: field.id,
9166
+ label: field.name,
9167
+ readOnly: field.limit.includes("readOnly"),
9168
+ required: field.limit.includes("required"),
9169
+ options: [{
9170
+ label: "选项一",
9171
+ value: 1
9172
+ }, {
9173
+ label: "选项二",
9174
+ value: 2
9175
+ }],
9176
+ placeholder: field.description,
9177
+ inputBoxStyle: {
9178
+ width: "100%"
9179
+ }
9180
+ }
9181
+ };
9182
+ break;
9183
+
9184
+ case "SELECT_MULTIPLE_ENUMERATED_TYPE":
9185
+ defaultValue = {
9186
+ brick: "forms.general-select",
9187
+ properties: {
9188
+ id: field.id,
9189
+ name: field.id,
9190
+ label: field.name,
9191
+ readOnly: field.limit.includes("readOnly"),
9192
+ required: field.limit.includes("required"),
9193
+ mode: "multiple",
9194
+ options: [{
9195
+ label: "选项一",
9196
+ value: 1
9197
+ }, {
9198
+ label: "选项二",
9199
+ value: 2
9200
+ }],
9201
+ placeholder: field.description,
9202
+ inputBoxStyle: {
9203
+ width: "100%"
9204
+ }
9205
+ }
9206
+ };
9207
+ break;
9208
+
9209
+ case "DATE":
9210
+ defaultValue = {
9211
+ brick: "forms.general-date-picker",
9212
+ properties: {
9213
+ id: field.id,
9214
+ name: field.id,
9215
+ label: field.name,
9216
+ readOnly: field.limit.includes("readOnly"),
9217
+ required: field.limit.includes("required"),
9218
+ placeholder: field.description
9219
+ }
9220
+ };
9221
+ break;
9222
+
9223
+ case "TIME":
9224
+ defaultValue = {
9225
+ brick: "forms.general-date-picker",
9226
+ properties: {
9227
+ id: field.id,
9228
+ name: field.id,
9229
+ label: field.name,
9230
+ readOnly: field.limit.includes("readOnly"),
9231
+ required: field.limit.includes("required"),
9232
+ placeholder: field.description
9233
+ }
9234
+ };
9235
+ break;
9236
+
9237
+ case "IP":
9238
+ defaultValue = {
9239
+ brick: "forms.general-input",
9240
+ properties: {
9241
+ id: field.id,
9242
+ name: field.id,
9243
+ label: field.name,
9244
+ readOnly: field.limit.includes("readOnly"),
9245
+ required: field.limit.includes("required"),
9246
+ placeholder: field.description,
9247
+ pattern: /((^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$)|(^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$))/
9248
+ }
9249
+ };
9250
+ break;
9251
+
9252
+ case "JSON":
9253
+ defaultValue = {};
9254
+ break;
9255
+
9256
+ case "ARRAY":
9257
+ defaultValue = {};
9258
+ break;
9259
+
9260
+ case "STRUCTURE":
9261
+ defaultValue = {
9262
+ brick: "forms.cmdb-instance-select-panel",
9263
+ properties: {
9264
+ id: field.id,
9265
+ name: field.id,
9266
+ label: field.name,
9267
+ readOnly: field.limit.includes("readOnly"),
9268
+ required: field.limit.includes("required")
9269
+ }
9270
+ };
9271
+ break;
9272
+
9273
+ case "STRUCTURE_ARRAY":
9274
+ defaultValue = {
9275
+ brick: "forms.cmdb-instance-select-panel",
9276
+ properties: {
9277
+ id: field.id,
9278
+ name: field.id,
9279
+ label: field.name,
9280
+ readOnly: field.limit.includes("readOnly"),
9281
+ required: field.limit.includes("required")
9282
+ }
9283
+ };
9284
+ break;
9285
+
9286
+ default:
9287
+ defaultValue = {
9288
+ brick: "forms.general-input",
9289
+ properties: {
9290
+ id: field.id,
9291
+ name: field.id,
9292
+ label: field.name,
9293
+ readOnly: field.limit.includes("readOnly"),
9294
+ required: field.limit.includes("required"),
9295
+ placeholder: field.description
9296
+ }
9297
+ };
9298
+ break;
9299
+ }
9300
+ }
9301
+
9302
+ return defaultValue;
9303
+ }
9304
+ function getStoryboard(datasource, result, fields) {
9305
+ var _loop = function (i) {
9306
+ var dataItem = datasource[i];
9307
+ var resultItem = {}; //数据初始化:根据id,字段类型获取默认属性
9308
+
9309
+ var defaultProperties = getDefaultProperties(dataItem.id, fields); //数据初始化:与默认属性进行合并
9310
+
9311
+ Object.keys(defaultProperties).forEach(item => {
9312
+ if (!dataItem[item]) {
9313
+ dataItem[item] = defaultProperties[item];
9314
+ } else if (dataItem[item] && typeof dataItem[item] === "object") {
9315
+ dataItem[item] = _objectSpread(_objectSpread({}, defaultProperties[item]), dataItem[item]);
9316
+ }
9317
+ });
9318
+ Object.keys(dataItem).forEach(item => {
9319
+ if (filterProperties.includes(item)) {
9320
+ resultItem[item] = dataItem[item];
9321
+ }
9322
+ });
9323
+
9324
+ if (Array.isArray(dataItem.bricks)) {
9325
+ var _Object$keys;
9326
+
9327
+ resultItem["slots"] = _.groupBy(getStoryboard(dataItem.bricks, [], fields), "mountPoint");
9328
+ (_Object$keys = Object.keys(resultItem["slots"])) === null || _Object$keys === void 0 ? void 0 : _Object$keys.forEach(item => {
9329
+ resultItem.slots[item] = {
9330
+ bricks: resultItem.slots[item],
9331
+ type: "bricks"
9332
+ };
9333
+ });
9334
+ }
9335
+
9336
+ result[i] = resultItem;
9337
+ };
9338
+
9339
+ for (var i = 0; i < datasource.length; i++) {
9340
+ _loop(i);
9341
+ }
9342
+
9343
+ return result;
9344
+ }
9345
+
9105
9346
  class LocationContext {
9106
9347
  constructor(kernel, location) {
9107
9348
  _defineProperty$1(this, "query", void 0);
@@ -9598,6 +9839,12 @@ class LocationContext {
9598
9839
  yield _this6.kernel.loadDynamicBricksInBrickConf(expandedBrickConf);
9599
9840
  }
9600
9841
 
9842
+ if (brick.type === formRenderer) {
9843
+ var formData = brick.properties.formData;
9844
+ expandedBrickConf = ExpandCustomForm(formData, brickConf);
9845
+ yield _this6.kernel.loadDynamicBricksInBrickConf(expandedBrickConf);
9846
+ }
9847
+
9601
9848
  if (expandedBrickConf.exports) {
9602
9849
  for (var [prop, ctxName] of Object.entries(expandedBrickConf.exports)) {
9603
9850
  if (typeof ctxName === "string" && ctxName.startsWith("CTX.")) {
@@ -10326,6 +10573,57 @@ function shouldBeDefaultCollapsed(defaultCollapsed, defaultCollapsedBreakpoint)
10326
10573
  return defaultCollapsed || defaultCollapsedBreakpoint && document.documentElement.clientWidth < defaultCollapsedBreakpoint;
10327
10574
  }
10328
10575
 
10576
+ var mocks = {
10577
+ mockId: null,
10578
+ mockList: []
10579
+ };
10580
+ function registerMock(useMocks) {
10581
+ var _useMocks$mockList;
10582
+
10583
+ if (useMocks) mocks = _objectSpread(_objectSpread({}, useMocks), {}, {
10584
+ mockList: (_useMocks$mockList = useMocks.mockList) === null || _useMocks$mockList === void 0 ? void 0 : _useMocks$mockList.map(item => {
10585
+ var isFlowAPi = isCustomApiProvider(item.provider);
10586
+ return _objectSpread(_objectSpread({}, item), {}, {
10587
+ uri: "".concat(isFlowAPi ? item.uri.replace(/(.+?)\/(.+)/, (_match, p1, p2) => {
10588
+ return "/".concat(p1, "(@\\d+\\.\\d+\\.\\d+)?/").concat(p2, "$");
10589
+ }) : "/".concat(item.uri.split(".").slice(2).join("."), "$")).replace(/:\w+/g, "([^/]+)")
10590
+ });
10591
+ })
10592
+ });
10593
+ }
10594
+ var getMockInfo = (requestUrl, method) => {
10595
+ var transformGetMethod = method => {
10596
+ if (method.toUpperCase() === "LIST") {
10597
+ return "GET";
10598
+ }
10599
+
10600
+ return method === null || method === void 0 ? void 0 : method.toUpperCase();
10601
+ };
10602
+
10603
+ var item = mocks.mockList.find(item => new RegExp(item.uri).test(requestUrl) && transformGetMethod(item.method) === (method === null || method === void 0 ? void 0 : method.toUpperCase()));
10604
+
10605
+ if (item) {
10606
+ return {
10607
+ url: requestUrl.replace(/(api\/gateway\/.+?)(@\d+\.\d+\.\d+)?\/(.+)/, (_match, p1, _p2, p3) => {
10608
+ // 忽略版本
10609
+ return "".concat(p1, "/").concat(p3);
10610
+ }).replace(/(api\/gateway)/, "api/gateway/mock_server.proxy.".concat(mocks.mockId)),
10611
+ mockId: mocks.mockId
10612
+ };
10613
+ }
10614
+
10615
+ return;
10616
+ };
10617
+
10618
+ function registerFormRenderer() {
10619
+ customElements.get(formRenderer) || customElements.define(formRenderer, class FormElement extends HTMLElement {
10620
+ get $$typeof() {
10621
+ return "formRenderer";
10622
+ }
10623
+
10624
+ });
10625
+ }
10626
+
10329
10627
  class Router {
10330
10628
  constructor(kernel) {
10331
10629
  _defineProperty$1(this, "defaultCollapsed", false);
@@ -10534,6 +10832,7 @@ class Router {
10534
10832
 
10535
10833
  registerStoryboardFunctions((_storyboard$meta = storyboard.meta) === null || _storyboard$meta === void 0 ? void 0 : _storyboard$meta.functions, storyboard.app);
10536
10834
  registerMock((_storyboard$meta2 = storyboard.meta) === null || _storyboard$meta2 === void 0 ? void 0 : _storyboard$meta2.mocks);
10835
+ registerFormRenderer();
10537
10836
  collectContract((_storyboard$meta3 = storyboard.meta) === null || _storyboard$meta3 === void 0 ? void 0 : _storyboard$meta3.contracts);
10538
10837
  }
10539
10838
 
@@ -10593,23 +10892,8 @@ class Router {
10593
10892
  };
10594
10893
 
10595
10894
  try {
10596
- var specificTemplatePreviewIndex = findLastIndex(storyboard.routes, route => route.path.startsWith("${APP.homepage}/_dev_only_/template-preview/"));
10597
- var specificSnippetPreviewIndex = findLastIndex(storyboard.routes, route => route.path.startsWith("${APP.homepage}/_dev_only_/snippet-preview/"));
10598
- var mergedRoutes = [...storyboard.routes.slice(0, specificTemplatePreviewIndex + 1), ...storyboard.routes.slice(0, specificSnippetPreviewIndex + 1), {
10599
- path: "${APP.homepage}/_dev_only_/template-preview/:templateId",
10600
- bricks: [{
10601
- brick: "span"
10602
- }],
10603
- menu: false,
10604
- exact: true
10605
- }, {
10606
- path: "${APP.homepage}/_dev_only_/snippet-preview/:snippetId",
10607
- bricks: [{
10608
- brick: "span"
10609
- }],
10610
- menu: false,
10611
- exact: true
10612
- }, ...storyboard.routes.slice(specificTemplatePreviewIndex + 1)];
10895
+ var mergedRoutes = _this3.MergePreviewRouter(storyboard.routes);
10896
+
10613
10897
  yield locationContext.mountRoutes(mergedRoutes, undefined, mountRoutesResult);
10614
10898
  } catch (error) {
10615
10899
  // eslint-disable-next-line no-console
@@ -10819,6 +11103,50 @@ class Router {
10819
11103
  subMenu: mountResult.menuBar.subMenu
10820
11104
  };
10821
11105
  }
11106
+
11107
+ MergePreviewRouter(router) {
11108
+ var mergedRoutes = router;
11109
+ var specificTemplatePreviewIndex = findLastIndex(mergedRoutes, route => route.path.startsWith("${APP.homepage}/_dev_only_/template-preview/"));
11110
+
11111
+ if (specificTemplatePreviewIndex > -1) {
11112
+ mergedRoutes = [...mergedRoutes.slice(0, specificTemplatePreviewIndex + 1), {
11113
+ path: "${APP.homepage}/_dev_only_/template-preview/:templateId",
11114
+ bricks: [{
11115
+ brick: "span"
11116
+ }],
11117
+ menu: false,
11118
+ exact: true
11119
+ }, ...mergedRoutes.slice(specificTemplatePreviewIndex + 1)];
11120
+ }
11121
+
11122
+ var specificSnippetPreviewIndex = findLastIndex(mergedRoutes, route => route.path.startsWith("${APP.homepage}/_dev_only_/snippet-preview/"));
11123
+
11124
+ if (specificSnippetPreviewIndex > -1) {
11125
+ mergedRoutes = [...mergedRoutes.slice(0, specificSnippetPreviewIndex + 1), {
11126
+ path: "${APP.homepage}/_dev_only_/snippet-preview/:snippetId",
11127
+ bricks: [{
11128
+ brick: "span"
11129
+ }],
11130
+ menu: false,
11131
+ exact: true
11132
+ }, ...mergedRoutes.slice(specificSnippetPreviewIndex + 1)];
11133
+ }
11134
+
11135
+ var specificFormPreviewIndex = findLastIndex(mergedRoutes, route => route.path.startsWith("${APP.homepage}/_dev_only_/form-preview/"));
11136
+
11137
+ if (specificFormPreviewIndex > -1) {
11138
+ mergedRoutes = [...mergedRoutes.slice(0, specificFormPreviewIndex + 1), {
11139
+ path: "${APP.homepage}/_dev_only_/form-preview/:FormId",
11140
+ bricks: [{
11141
+ brick: "span"
11142
+ }],
11143
+ menu: false,
11144
+ exact: true
11145
+ }, ...mergedRoutes.slice(specificFormPreviewIndex + 1)];
11146
+ }
11147
+
11148
+ return mergedRoutes;
11149
+ }
10822
11150
  /* istanbul ignore next */
10823
11151
 
10824
11152
 
@@ -13239,7 +13567,8 @@ var developHelper = {
13239
13567
  checkoutTplContext: noop,
13240
13568
  updateStoryboard: _dev_only_updateStoryboard,
13241
13569
  updateTemplatePreviewSettings: _dev_only_updateTemplatePreviewSettings,
13242
- updateSnippetPreviewSettings: _dev_only_updateSnippetPreviewSettings
13570
+ updateSnippetPreviewSettings: _dev_only_updateSnippetPreviewSettings,
13571
+ updateFormPreviewSettings: _dev_only_updateFormPreviewSettings
13243
13572
  };
13244
13573
 
13245
13574
  var _excluded$2 = ["type"];