@next-core/brick-kit 2.136.1 → 2.136.2
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 +8 -0
- package/dist/index.bundle.js +113 -54
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +113 -54
- package/dist/index.esm.js.map +1 -1
- package/dist/types/core/BrickNode.d.ts +1 -0
- package/dist/types/core/BrickNode.d.ts.map +1 -1
- package/dist/types/core/CustomForms/CustomFormContext.d.ts +8 -0
- package/dist/types/core/CustomForms/CustomFormContext.d.ts.map +1 -0
- 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/CustomForms/constants.d.ts +4 -0
- package/dist/types/core/CustomForms/constants.d.ts.map +1 -1
- package/dist/types/core/LocationContext.d.ts.map +1 -1
- package/dist/types/internal/evaluate.d.ts +1 -0
- package/dist/types/internal/evaluate.d.ts.map +1 -1
- package/dist/types/internal/setProperties.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/index.esm.js
CHANGED
|
@@ -2344,6 +2344,22 @@ mediaBreakpointMinWidthMap.forEach((minWidth, breakpoint) => {
|
|
|
2344
2344
|
});
|
|
2345
2345
|
var getMedia = () => MEDIA;
|
|
2346
2346
|
|
|
2347
|
+
var FormContextMap = new Map();
|
|
2348
|
+
class CustomFormContext {
|
|
2349
|
+
constructor() {
|
|
2350
|
+
_defineProperty$1(this, "formState", void 0);
|
|
2351
|
+
|
|
2352
|
+
_defineProperty$1(this, "id", uniqueId("form-ctx-"));
|
|
2353
|
+
|
|
2354
|
+
FormContextMap.set(this.id, this);
|
|
2355
|
+
this.formState = new StoryboardContextWrapper();
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2358
|
+
}
|
|
2359
|
+
function getCustomFormContext(formContextId) {
|
|
2360
|
+
return FormContextMap.get(formContextId);
|
|
2361
|
+
}
|
|
2362
|
+
|
|
2347
2363
|
var symbolForRaw = Symbol.for("pre.evaluated.raw");
|
|
2348
2364
|
var symbolForContext = Symbol.for("pre.evaluated.context");
|
|
2349
2365
|
function isPreEvaluated(raw) {
|
|
@@ -2416,6 +2432,7 @@ function evaluate(raw) {
|
|
|
2416
2432
|
var attemptToVisitData = attemptToVisitGlobals.has("DATA");
|
|
2417
2433
|
var attemptToVisitTpl = attemptToVisitGlobals.has("TPL");
|
|
2418
2434
|
var attemptToVisitState = attemptToVisitGlobals.has("STATE");
|
|
2435
|
+
var attemptToVisitFormState = attemptToVisitGlobals.has("FORM_STATE");
|
|
2419
2436
|
var attemptToVisitTplOrState = attemptToVisitTpl || attemptToVisitState; // Ignore evaluating if `event` is missing in context.
|
|
2420
2437
|
// Since it should be evaluated during events handling.
|
|
2421
2438
|
|
|
@@ -2467,6 +2484,20 @@ function evaluate(raw) {
|
|
|
2467
2484
|
}
|
|
2468
2485
|
}
|
|
2469
2486
|
|
|
2487
|
+
if (attemptToVisitFormState && runtimeContext.formContextId) {
|
|
2488
|
+
var formContext = getCustomFormContext(runtimeContext.formContextId);
|
|
2489
|
+
globalVariables.FORM_STATE = getDynamicReadOnlyProxy({
|
|
2490
|
+
get(target, key) {
|
|
2491
|
+
return formContext.formState.getValue(key);
|
|
2492
|
+
},
|
|
2493
|
+
|
|
2494
|
+
ownKeys() {
|
|
2495
|
+
return Array.from(formContext.formState.get().keys());
|
|
2496
|
+
}
|
|
2497
|
+
|
|
2498
|
+
});
|
|
2499
|
+
}
|
|
2500
|
+
|
|
2470
2501
|
var {
|
|
2471
2502
|
app: currentApp,
|
|
2472
2503
|
query,
|
|
@@ -2920,7 +2951,7 @@ var computeRealValue = (value, context, injectDeep, internalOptions) => {
|
|
|
2920
2951
|
|
|
2921
2952
|
if (preEvaluated || isEvaluable(value)) {
|
|
2922
2953
|
var runtimeContext = {};
|
|
2923
|
-
var keys = ["event", "tplContextId", "overrideApp", "appendI18nNamespace"];
|
|
2954
|
+
var keys = ["event", "tplContextId", "overrideApp", "appendI18nNamespace", "formContextId"];
|
|
2924
2955
|
|
|
2925
2956
|
for (var key of keys) {
|
|
2926
2957
|
if (context !== null && context !== void 0 && context[key]) {
|
|
@@ -8276,6 +8307,7 @@ function applyColorTheme(options) {
|
|
|
8276
8307
|
|
|
8277
8308
|
var formRenderer = "form-renderer.form-renderer";
|
|
8278
8309
|
var filterProperties = ["instanceId", "brick", "slots", "properties", "events", "if", "context", "bricks", "mountPoint"];
|
|
8310
|
+
var symbolForFormContextId = Symbol.for("form.contextId");
|
|
8279
8311
|
|
|
8280
8312
|
function collectRefsInTemplate(template) {
|
|
8281
8313
|
var refMap = new Map();
|
|
@@ -9957,58 +9989,73 @@ function listenOnTrackingContext(brick, trackingContextList, context) {
|
|
|
9957
9989
|
}
|
|
9958
9990
|
}
|
|
9959
9991
|
|
|
9960
|
-
function ExpandCustomForm(
|
|
9961
|
-
|
|
9962
|
-
|
|
9963
|
-
|
|
9964
|
-
|
|
9965
|
-
|
|
9966
|
-
|
|
9967
|
-
|
|
9968
|
-
|
|
9969
|
-
|
|
9992
|
+
function ExpandCustomForm(_x, _x2, _x3, _x4) {
|
|
9993
|
+
return _ExpandCustomForm.apply(this, arguments);
|
|
9994
|
+
}
|
|
9995
|
+
|
|
9996
|
+
function _ExpandCustomForm() {
|
|
9997
|
+
_ExpandCustomForm = _asyncToGenerator$3(function* (formData, brickConf, isPreview, context) {
|
|
9998
|
+
var errorBrick = {
|
|
9999
|
+
brick: "presentational-bricks.brick-illustration",
|
|
10000
|
+
properties: {
|
|
10001
|
+
category: "default",
|
|
10002
|
+
header: {
|
|
10003
|
+
title: "参数错误"
|
|
10004
|
+
},
|
|
10005
|
+
mode: "guide",
|
|
10006
|
+
name: "search-empty"
|
|
10007
|
+
}
|
|
10008
|
+
};
|
|
10009
|
+
var formContext = new CustomFormContext();
|
|
10010
|
+
|
|
10011
|
+
if (Array.isArray(formData.context)) {
|
|
10012
|
+
yield formContext.formState.define(formData.context, _objectSpread(_objectSpread({}, context), {}, {
|
|
10013
|
+
formContextId: formContext.id
|
|
10014
|
+
}), {});
|
|
9970
10015
|
}
|
|
9971
|
-
};
|
|
9972
10016
|
|
|
9973
|
-
|
|
9974
|
-
|
|
9975
|
-
|
|
9976
|
-
|
|
9977
|
-
|
|
9978
|
-
|
|
9979
|
-
|
|
9980
|
-
|
|
9981
|
-
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
|
|
10017
|
+
try {
|
|
10018
|
+
var formStoryboard = getStoryboard([formData.formSchema], [], formData.fields, isPreview, formContext.id);
|
|
10019
|
+
formStoryboard[0] = _.isEmpty(formStoryboard[0]) ? errorBrick : formStoryboard[0];
|
|
10020
|
+
return _objectSpread(_objectSpread({}, brickConf), {}, {
|
|
10021
|
+
brick: "div",
|
|
10022
|
+
slots: {
|
|
10023
|
+
"": {
|
|
10024
|
+
bricks: [{
|
|
10025
|
+
brick: "basic-bricks.micro-view",
|
|
10026
|
+
properties: {
|
|
10027
|
+
style: {
|
|
10028
|
+
padding: "12px"
|
|
10029
|
+
}
|
|
10030
|
+
},
|
|
10031
|
+
slots: {
|
|
10032
|
+
content: {
|
|
10033
|
+
bricks: formStoryboard,
|
|
10034
|
+
type: "bricks"
|
|
10035
|
+
}
|
|
9991
10036
|
}
|
|
9992
|
-
}
|
|
9993
|
-
|
|
9994
|
-
|
|
10037
|
+
}],
|
|
10038
|
+
type: "bricks"
|
|
10039
|
+
}
|
|
9995
10040
|
}
|
|
9996
|
-
}
|
|
9997
|
-
})
|
|
9998
|
-
|
|
9999
|
-
|
|
10000
|
-
|
|
10001
|
-
|
|
10002
|
-
|
|
10003
|
-
|
|
10004
|
-
|
|
10005
|
-
|
|
10006
|
-
|
|
10041
|
+
});
|
|
10042
|
+
} catch (error) {
|
|
10043
|
+
// eslint-disable-next-line no-console
|
|
10044
|
+
console.warn(error.message);
|
|
10045
|
+
return {
|
|
10046
|
+
brick: "div",
|
|
10047
|
+
slots: {
|
|
10048
|
+
"": {
|
|
10049
|
+
bricks: [errorBrick],
|
|
10050
|
+
type: "bricks"
|
|
10051
|
+
}
|
|
10007
10052
|
}
|
|
10008
|
-
}
|
|
10009
|
-
}
|
|
10010
|
-
}
|
|
10053
|
+
};
|
|
10054
|
+
}
|
|
10055
|
+
});
|
|
10056
|
+
return _ExpandCustomForm.apply(this, arguments);
|
|
10011
10057
|
}
|
|
10058
|
+
|
|
10012
10059
|
function getDefaultProperties(_name, fields) {
|
|
10013
10060
|
var field = fields.filter(item => item.fieldId === _name)[0];
|
|
10014
10061
|
|
|
@@ -10241,7 +10288,7 @@ function getDefaultProperties(_name, fields) {
|
|
|
10241
10288
|
return defaultValue;
|
|
10242
10289
|
} else return {};
|
|
10243
10290
|
}
|
|
10244
|
-
function getStoryboard(datasource, result, fields, isPreview) {
|
|
10291
|
+
function getStoryboard(datasource, result, fields, isPreview, formContextId) {
|
|
10245
10292
|
var _loop = function (i) {
|
|
10246
10293
|
var dataItem = datasource[i];
|
|
10247
10294
|
var resultItem = {}; //数据初始化:根据id,字段类型获取默认属性
|
|
@@ -10283,7 +10330,7 @@ function getStoryboard(datasource, result, fields, isPreview) {
|
|
|
10283
10330
|
if (Array.isArray(dataItem.bricks)) {
|
|
10284
10331
|
var _Object$keys;
|
|
10285
10332
|
|
|
10286
|
-
resultItem["slots"] = _.groupBy(getStoryboard(dataItem.bricks, [], fields, isPreview), "mountPoint");
|
|
10333
|
+
resultItem["slots"] = _.groupBy(getStoryboard(dataItem.bricks, [], fields, isPreview, formContextId), "mountPoint");
|
|
10287
10334
|
(_Object$keys = Object.keys(resultItem["slots"])) === null || _Object$keys === void 0 ? void 0 : _Object$keys.forEach(item => {
|
|
10288
10335
|
resultItem.slots[item] = {
|
|
10289
10336
|
bricks: resultItem.slots[item],
|
|
@@ -10292,6 +10339,9 @@ function getStoryboard(datasource, result, fields, isPreview) {
|
|
|
10292
10339
|
});
|
|
10293
10340
|
}
|
|
10294
10341
|
|
|
10342
|
+
resultItem = _objectSpread(_objectSpread({}, resultItem), {}, {
|
|
10343
|
+
[symbolForFormContextId]: formContextId
|
|
10344
|
+
});
|
|
10295
10345
|
result[i] = resultItem;
|
|
10296
10346
|
};
|
|
10297
10347
|
|
|
@@ -10348,7 +10398,8 @@ class LocationContext {
|
|
|
10348
10398
|
getContext(_ref) {
|
|
10349
10399
|
var {
|
|
10350
10400
|
match,
|
|
10351
|
-
tplContextId
|
|
10401
|
+
tplContextId,
|
|
10402
|
+
formContextId
|
|
10352
10403
|
} = _ref;
|
|
10353
10404
|
var auth = getAuth();
|
|
10354
10405
|
var context = {
|
|
@@ -10368,7 +10419,8 @@ class LocationContext {
|
|
|
10368
10419
|
flags: this.kernel.getFeatureFlags(),
|
|
10369
10420
|
segues: this.segues,
|
|
10370
10421
|
storyboardContext: this.storyboardContextWrapper.get(),
|
|
10371
|
-
tplContextId
|
|
10422
|
+
tplContextId,
|
|
10423
|
+
formContextId
|
|
10372
10424
|
};
|
|
10373
10425
|
return context;
|
|
10374
10426
|
}
|
|
@@ -10708,10 +10760,12 @@ class LocationContext {
|
|
|
10708
10760
|
|
|
10709
10761
|
var tplStack = _arguments.length > 4 && _arguments[4] !== undefined ? _arguments[4] : [];
|
|
10710
10762
|
var tplContextId = brickConf[symbolForTplContextId];
|
|
10763
|
+
var formContextId = brickConf[symbolForFormContextId];
|
|
10711
10764
|
|
|
10712
10765
|
var context = _this6.getContext({
|
|
10713
10766
|
match,
|
|
10714
|
-
tplContextId
|
|
10767
|
+
tplContextId,
|
|
10768
|
+
formContextId
|
|
10715
10769
|
}); // First, check whether the brick should be rendered.
|
|
10716
10770
|
|
|
10717
10771
|
|
|
@@ -10741,6 +10795,10 @@ class LocationContext {
|
|
|
10741
10795
|
tplStack.push(tplTagName);
|
|
10742
10796
|
}
|
|
10743
10797
|
|
|
10798
|
+
if (brickConf.brick === formRenderer) {
|
|
10799
|
+
brickConf.properties.formData = JSON.stringify(brickConf.properties.formData);
|
|
10800
|
+
}
|
|
10801
|
+
|
|
10744
10802
|
var brick = {};
|
|
10745
10803
|
yield _this6.storyboardContextWrapper.define(brickConf.context, context, brick);
|
|
10746
10804
|
yield _this6.preCheckPermissions(brickConf, context);
|
|
@@ -10754,6 +10812,7 @@ class LocationContext {
|
|
|
10754
10812
|
slotId,
|
|
10755
10813
|
refForProxy: brickConf[symbolForRefForProxy],
|
|
10756
10814
|
tplContextId,
|
|
10815
|
+
formContextId,
|
|
10757
10816
|
iid: brickConf.iid
|
|
10758
10817
|
}, (_brickConf$lifeCycle = brickConf.lifeCycle) !== null && _brickConf$lifeCycle !== void 0 && _brickConf$lifeCycle.onScrollIntoView ? {
|
|
10759
10818
|
lifeCycle: {
|
|
@@ -10799,8 +10858,8 @@ class LocationContext {
|
|
|
10799
10858
|
}
|
|
10800
10859
|
|
|
10801
10860
|
if (brick.type === formRenderer) {
|
|
10802
|
-
var formData = brick.properties.formData;
|
|
10803
|
-
expandedBrickConf = ExpandCustomForm(formData, brickConf, brick.properties.isPreview);
|
|
10861
|
+
var formData = JSON.parse(brick.properties.formData);
|
|
10862
|
+
expandedBrickConf = yield ExpandCustomForm(formData, brickConf, brick.properties.isPreview, context);
|
|
10804
10863
|
yield _this6.kernel.loadDynamicBricksInBrickConf(expandedBrickConf);
|
|
10805
10864
|
}
|
|
10806
10865
|
|