@next-core/brick-kit 2.122.12 → 2.123.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 +27 -0
- package/dist/index.bundle.js +104 -20
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +105 -21
- package/dist/index.esm.js.map +1 -1
- package/dist/types/core/CustomForms/ExpandCustomForm.d.ts +2 -2
- package/dist/types/core/CustomForms/ExpandCustomForm.d.ts.map +1 -1
- package/dist/types/core/Kernel.d.ts.map +1 -1
- package/dist/types/core/LocationContext.d.ts.map +1 -1
- package/dist/types/core/interfaces.d.ts +4 -5
- package/dist/types/core/interfaces.d.ts.map +1 -1
- package/dist/types/internal/bindListeners.d.ts.map +1 -1
- package/dist/types/providers/CustomApi.d.ts +5 -2
- package/dist/types/providers/CustomApi.d.ts.map +1 -1
- package/package.json +6 -6
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 _, { 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, isEmpty, 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';
|
|
@@ -5882,7 +5882,8 @@ function getApiArgsFromApiProfile(_ref, originalArgs) {
|
|
|
5882
5882
|
serviceName,
|
|
5883
5883
|
responseWrapper,
|
|
5884
5884
|
version,
|
|
5885
|
-
isFileType
|
|
5885
|
+
isFileType,
|
|
5886
|
+
request
|
|
5886
5887
|
} = _ref;
|
|
5887
5888
|
var fileName;
|
|
5888
5889
|
|
|
@@ -5898,14 +5899,16 @@ function getApiArgsFromApiProfile(_ref, originalArgs) {
|
|
|
5898
5899
|
url,
|
|
5899
5900
|
method,
|
|
5900
5901
|
ext_fields,
|
|
5901
|
-
responseWrapper: false
|
|
5902
|
+
responseWrapper: false,
|
|
5903
|
+
request
|
|
5902
5904
|
}, ...args, {
|
|
5903
5905
|
responseType: "blob"
|
|
5904
5906
|
}] : [{
|
|
5905
5907
|
url,
|
|
5906
5908
|
method,
|
|
5907
5909
|
ext_fields,
|
|
5908
|
-
responseWrapper
|
|
5910
|
+
responseWrapper,
|
|
5911
|
+
request
|
|
5909
5912
|
}, ...args];
|
|
5910
5913
|
}
|
|
5911
5914
|
|
|
@@ -5946,7 +5949,8 @@ function getApiProfileFromApiDefinition(provider, api) {
|
|
|
5946
5949
|
serviceName: api.serviceName,
|
|
5947
5950
|
version: api.version,
|
|
5948
5951
|
isFileType: (contract === null || contract === void 0 ? void 0 : (_contract$response = contract.response) === null || _contract$response === void 0 ? void 0 : _contract$response.type) === "file",
|
|
5949
|
-
responseWrapper
|
|
5952
|
+
responseWrapper,
|
|
5953
|
+
request: contract.request
|
|
5950
5954
|
};
|
|
5951
5955
|
}
|
|
5952
5956
|
|
|
@@ -5979,7 +5983,8 @@ function _fetchFlowApiDefinition2() {
|
|
|
5979
5983
|
version: contract.version,
|
|
5980
5984
|
contract: {
|
|
5981
5985
|
endpoint: contract.endpoint,
|
|
5982
|
-
response: contract.response
|
|
5986
|
+
response: contract.response,
|
|
5987
|
+
request: contract.request
|
|
5983
5988
|
}
|
|
5984
5989
|
};
|
|
5985
5990
|
} else {
|
|
@@ -6000,7 +6005,8 @@ function _fetchFlowApiDefinition2() {
|
|
|
6000
6005
|
version: contractData.version,
|
|
6001
6006
|
contract: {
|
|
6002
6007
|
endpoint: contractData.endpoint,
|
|
6003
|
-
response: contractData.response
|
|
6008
|
+
response: contractData.response,
|
|
6009
|
+
request: contractData.request
|
|
6004
6010
|
}
|
|
6005
6011
|
};
|
|
6006
6012
|
}
|
|
@@ -6199,6 +6205,9 @@ function listenerFactory(handler, context, runtimeBrick) {
|
|
|
6199
6205
|
case "analytics.event":
|
|
6200
6206
|
return builtinAnalyticsListenerFactory(handler.args, handler, context);
|
|
6201
6207
|
|
|
6208
|
+
case "preview.debug":
|
|
6209
|
+
return builtinFormDebugListenerFactory(handler.args, handler, context);
|
|
6210
|
+
|
|
6202
6211
|
default:
|
|
6203
6212
|
return () => {
|
|
6204
6213
|
// eslint-disable-next-line no-console
|
|
@@ -6669,6 +6678,22 @@ function builtinWebStorageListenerFactory(storageType, method, args, ifContainer
|
|
|
6669
6678
|
};
|
|
6670
6679
|
}
|
|
6671
6680
|
|
|
6681
|
+
function builtinFormDebugListenerFactory(args, ifContainer, context) {
|
|
6682
|
+
return function (event) {
|
|
6683
|
+
if (!looseCheckIf(ifContainer, _objectSpread(_objectSpread({}, context), {}, {
|
|
6684
|
+
event
|
|
6685
|
+
}))) {
|
|
6686
|
+
return;
|
|
6687
|
+
}
|
|
6688
|
+
|
|
6689
|
+
window.parent.postMessage({
|
|
6690
|
+
sender: "previewer",
|
|
6691
|
+
type: "preview.debug",
|
|
6692
|
+
res: argsFactory(args, context, event)
|
|
6693
|
+
});
|
|
6694
|
+
};
|
|
6695
|
+
}
|
|
6696
|
+
|
|
6672
6697
|
function argsFactory(args, context, event) {
|
|
6673
6698
|
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
6674
6699
|
return Array.isArray(args) ? computeRealValue(args, _objectSpread(_objectSpread({}, context), {}, {
|
|
@@ -6924,6 +6949,46 @@ function processExtFields(ext_fields) {
|
|
|
6924
6949
|
options
|
|
6925
6950
|
};
|
|
6926
6951
|
}
|
|
6952
|
+
function hasFileType(request) {
|
|
6953
|
+
var flag = false;
|
|
6954
|
+
if (!request) return flag;
|
|
6955
|
+
|
|
6956
|
+
var processFields = fields => {
|
|
6957
|
+
return fields.some(field => {
|
|
6958
|
+
if (["file", "file[]"].includes(field.type)) {
|
|
6959
|
+
return true;
|
|
6960
|
+
}
|
|
6961
|
+
|
|
6962
|
+
if (!isEmpty(field.fields)) {
|
|
6963
|
+
return processFields(field.fields);
|
|
6964
|
+
}
|
|
6965
|
+
});
|
|
6966
|
+
};
|
|
6967
|
+
|
|
6968
|
+
if (request.type === "object" && !isEmpty(request.fields)) {
|
|
6969
|
+
flag = processFields(request.fields);
|
|
6970
|
+
}
|
|
6971
|
+
|
|
6972
|
+
return flag;
|
|
6973
|
+
}
|
|
6974
|
+
function transformFormData(data) {
|
|
6975
|
+
var formData = new FormData();
|
|
6976
|
+
|
|
6977
|
+
for (var [key, value] of Object.entries(data)) {
|
|
6978
|
+
if (Array.isArray(value)) {
|
|
6979
|
+
(function () {
|
|
6980
|
+
var k = "".concat(key, "[]");
|
|
6981
|
+
value.forEach(v => {
|
|
6982
|
+
formData.append(k, v);
|
|
6983
|
+
});
|
|
6984
|
+
})();
|
|
6985
|
+
} else {
|
|
6986
|
+
formData.append(key, value);
|
|
6987
|
+
}
|
|
6988
|
+
}
|
|
6989
|
+
|
|
6990
|
+
return formData;
|
|
6991
|
+
}
|
|
6927
6992
|
function CustomApi(_x) {
|
|
6928
6993
|
return _CustomApi.apply(this, arguments);
|
|
6929
6994
|
}
|
|
@@ -6934,9 +6999,11 @@ function _CustomApi() {
|
|
|
6934
6999
|
url,
|
|
6935
7000
|
method = "GET",
|
|
6936
7001
|
responseWrapper = true,
|
|
6937
|
-
ext_fields = []
|
|
7002
|
+
ext_fields = [],
|
|
7003
|
+
request
|
|
6938
7004
|
} = _ref;
|
|
6939
7005
|
var isSimpleRequest = ["get", "delete", "head"].includes(method.toLowerCase());
|
|
7006
|
+
var response;
|
|
6940
7007
|
|
|
6941
7008
|
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
6942
7009
|
args[_key2 - 1] = arguments[_key2];
|
|
@@ -6944,17 +7011,16 @@ function _CustomApi() {
|
|
|
6944
7011
|
|
|
6945
7012
|
if (isSimpleRequest) {
|
|
6946
7013
|
var [data, options] = args;
|
|
6947
|
-
|
|
7014
|
+
response = yield http.simpleRequest(method, url, _objectSpread({
|
|
6948
7015
|
params: data
|
|
6949
7016
|
}, options));
|
|
6950
|
-
return responseWrapper ? response.data : response;
|
|
6951
7017
|
} else {
|
|
7018
|
+
var isUploadType = hasFileType(request);
|
|
6952
7019
|
var result = processExtFields(ext_fields, ...args);
|
|
6953
|
-
|
|
6954
|
-
var _response = yield http.requestWithBody(method, url, result.data, result.options);
|
|
6955
|
-
|
|
6956
|
-
return responseWrapper ? _response.data : _response;
|
|
7020
|
+
response = yield http.requestWithBody(method, url, isUploadType ? transformFormData(result.data) : result.data, result.options);
|
|
6957
7021
|
}
|
|
7022
|
+
|
|
7023
|
+
return responseWrapper ? response.data : response;
|
|
6958
7024
|
});
|
|
6959
7025
|
return _CustomApi.apply(this, arguments);
|
|
6960
7026
|
}
|
|
@@ -8340,7 +8406,8 @@ class Kernel {
|
|
|
8340
8406
|
bricks: [{
|
|
8341
8407
|
brick: formRenderer,
|
|
8342
8408
|
properties: {
|
|
8343
|
-
formData: formData
|
|
8409
|
+
formData: formData,
|
|
8410
|
+
isPreview: true
|
|
8344
8411
|
}
|
|
8345
8412
|
}],
|
|
8346
8413
|
menu: false,
|
|
@@ -9054,7 +9121,7 @@ function listenOnTrackingContext(brick, trackingContextList, context) {
|
|
|
9054
9121
|
}
|
|
9055
9122
|
}
|
|
9056
9123
|
|
|
9057
|
-
function ExpandCustomForm(formData, brickConf) {
|
|
9124
|
+
function ExpandCustomForm(formData, brickConf, isPreview) {
|
|
9058
9125
|
var errorBrick = {
|
|
9059
9126
|
brick: "presentational-bricks.brick-illustration",
|
|
9060
9127
|
properties: {
|
|
@@ -9068,7 +9135,7 @@ function ExpandCustomForm(formData, brickConf) {
|
|
|
9068
9135
|
};
|
|
9069
9136
|
|
|
9070
9137
|
try {
|
|
9071
|
-
var formStoryboard = getStoryboard([formData.formSchema], [], formData.fields);
|
|
9138
|
+
var formStoryboard = getStoryboard([formData.formSchema], [], formData.fields, isPreview);
|
|
9072
9139
|
formStoryboard[0] = _.isEmpty(formStoryboard[0]) ? errorBrick : formStoryboard[0];
|
|
9073
9140
|
return _objectSpread(_objectSpread({}, brickConf), {}, {
|
|
9074
9141
|
brick: "div",
|
|
@@ -9332,12 +9399,29 @@ function getDefaultProperties(_name, fields) {
|
|
|
9332
9399
|
return defaultValue;
|
|
9333
9400
|
} else return {};
|
|
9334
9401
|
}
|
|
9335
|
-
function getStoryboard(datasource, result, fields) {
|
|
9402
|
+
function getStoryboard(datasource, result, fields, isPreview) {
|
|
9336
9403
|
var _loop = function (i) {
|
|
9337
9404
|
var dataItem = datasource[i];
|
|
9338
9405
|
var resultItem = {}; //数据初始化:根据id,字段类型获取默认属性
|
|
9339
9406
|
|
|
9340
|
-
var defaultProperties = getDefaultProperties(dataItem.id, fields);
|
|
9407
|
+
var defaultProperties = getDefaultProperties(dataItem.id, fields);
|
|
9408
|
+
|
|
9409
|
+
if (dataItem.brick === "forms.general-form" && isPreview) {
|
|
9410
|
+
dataItem.properties = _objectSpread(_objectSpread({}, dataItem.properties), {}, {
|
|
9411
|
+
className: "form-preview"
|
|
9412
|
+
});
|
|
9413
|
+
dataItem.events = {
|
|
9414
|
+
"validate.error": [{
|
|
9415
|
+
action: "preview.debug",
|
|
9416
|
+
args: ["validate.error", "<% EVENT.detail %>"]
|
|
9417
|
+
}],
|
|
9418
|
+
"validate.success": [{
|
|
9419
|
+
action: "preview.debug",
|
|
9420
|
+
args: ["validate.success", "<% EVENT.detail %>"]
|
|
9421
|
+
}]
|
|
9422
|
+
};
|
|
9423
|
+
} //数据初始化:与默认属性进行合并
|
|
9424
|
+
|
|
9341
9425
|
|
|
9342
9426
|
Object.keys(defaultProperties).forEach(item => {
|
|
9343
9427
|
if (!dataItem[item]) {
|
|
@@ -9357,7 +9441,7 @@ function getStoryboard(datasource, result, fields) {
|
|
|
9357
9441
|
if (Array.isArray(dataItem.bricks)) {
|
|
9358
9442
|
var _Object$keys;
|
|
9359
9443
|
|
|
9360
|
-
resultItem["slots"] = _.groupBy(getStoryboard(dataItem.bricks, [], fields), "mountPoint");
|
|
9444
|
+
resultItem["slots"] = _.groupBy(getStoryboard(dataItem.bricks, [], fields, isPreview), "mountPoint");
|
|
9361
9445
|
(_Object$keys = Object.keys(resultItem["slots"])) === null || _Object$keys === void 0 ? void 0 : _Object$keys.forEach(item => {
|
|
9362
9446
|
resultItem.slots[item] = {
|
|
9363
9447
|
bricks: resultItem.slots[item],
|
|
@@ -9874,7 +9958,7 @@ class LocationContext {
|
|
|
9874
9958
|
|
|
9875
9959
|
if (brick.type === formRenderer) {
|
|
9876
9960
|
var formData = brick.properties.formData;
|
|
9877
|
-
expandedBrickConf = ExpandCustomForm(formData, brickConf);
|
|
9961
|
+
expandedBrickConf = ExpandCustomForm(formData, brickConf, brick.properties.isPreview);
|
|
9878
9962
|
yield _this6.kernel.loadDynamicBricksInBrickConf(expandedBrickConf);
|
|
9879
9963
|
}
|
|
9880
9964
|
|