@next-core/brick-kit 2.157.1 → 2.157.3
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.bundle.js +45 -10
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +46 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/types/core/CustomForms/ExpandCustomForm.d.ts.map +1 -1
- package/dist/types/core/StoryboardContext.d.ts +2 -1
- package/dist/types/core/StoryboardContext.d.ts.map +1 -1
- package/dist/types/internal/bindListeners.d.ts.map +1 -1
- package/dist/types/internal/listenOnTrackingContext.d.ts +1 -0
- package/dist/types/internal/listenOnTrackingContext.d.ts.map +1 -1
- package/dist/types/internal/setProperties.d.ts.map +1 -1
- package/dist/types/transformProperties.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/index.esm.js
CHANGED
|
@@ -4,7 +4,7 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
|
|
|
4
4
|
import _asyncToGenerator$3 from '@babel/runtime/helpers/asyncToGenerator';
|
|
5
5
|
import _defineProperty$1 from '@babel/runtime/helpers/defineProperty';
|
|
6
6
|
import React, { useState, useEffect, useRef, useCallback, useMemo, forwardRef, useImperativeHandle, useContext, createContext, useReducer } from 'react';
|
|
7
|
-
import { JsonStorage, toPath, computeRealRoutePath, hasOwnProperty, isObject, isEvaluable, transformAndInject, transform, trackContext, trackState, scanPermissionActionsInStoryboard, precookFunction, cook, resolveContextConcurrently, syncResolveContextConcurrently, trackUsedState, trackUsedContext, shouldAllowRecursiveEvaluations, preevaluate, inject, matchPath, deepFreeze, createProviderClass, removeDeadConditionsInTpl, getTemplateDepsOfStoryboard, getDllAndDepsOfStoryboard, asyncProcessStoryboard, getDllAndDepsByResource, scanRouteAliasInStoryboard, prefetchScript, scanBricksInBrickConf, scanProcessorsInAny, loadScript, scanAppGetMenuInAny, asyncProcessBrick, scanInstalledAppsInStoryboard, removeDeadConditions, restoreDynamicTemplates, scanStoryboard, mapCustomApisToNameAndNamespace } from '@next-core/brick-utils';
|
|
7
|
+
import { JsonStorage, toPath, computeRealRoutePath, hasOwnProperty, isObject, isEvaluable, transformAndInject, transform, trackContext, trackState, trackFormState, scanPermissionActionsInStoryboard, precookFunction, cook, resolveContextConcurrently, syncResolveContextConcurrently, trackUsedState, trackUsedContext, shouldAllowRecursiveEvaluations, preevaluate, inject, matchPath, deepFreeze, createProviderClass, removeDeadConditionsInTpl, getTemplateDepsOfStoryboard, getDllAndDepsOfStoryboard, asyncProcessStoryboard, getDllAndDepsByResource, scanRouteAliasInStoryboard, prefetchScript, scanBricksInBrickConf, scanProcessorsInAny, loadScript, scanAppGetMenuInAny, asyncProcessBrick, scanInstalledAppsInStoryboard, removeDeadConditions, restoreDynamicTemplates, scanStoryboard, mapCustomApisToNameAndNamespace } from '@next-core/brick-utils';
|
|
8
8
|
import _, { set, get, difference, identity, uniqueId, cloneDeep, clamp, isNil, isEmpty, sortBy, orderBy, merge, isObject as isObject$1, uniq, pick, omit, findLastIndex, noop, isString as isString$1 } from 'lodash';
|
|
9
9
|
import { http, HttpResponseError, HttpAbortError, HttpFetchError } from '@next-core/brick-http';
|
|
10
10
|
import moment from 'moment';
|
|
@@ -870,10 +870,12 @@ function doTransform(data, to, options) {
|
|
|
870
870
|
}
|
|
871
871
|
var contextNames = trackContext(raw);
|
|
872
872
|
var stateNames = trackState(raw);
|
|
873
|
-
|
|
873
|
+
var formStateNames = trackFormState(raw);
|
|
874
|
+
if (contextNames || stateNames || formStateNames) {
|
|
874
875
|
options.trackingContextList.push({
|
|
875
876
|
contextNames,
|
|
876
877
|
stateNames,
|
|
878
|
+
formStateNames,
|
|
877
879
|
propName: k,
|
|
878
880
|
propValue: v
|
|
879
881
|
});
|
|
@@ -1718,10 +1720,12 @@ function _checkIf(rawIf, ctx, fn) {
|
|
|
1718
1720
|
}
|
|
1719
1721
|
|
|
1720
1722
|
class StoryboardContextWrapper {
|
|
1721
|
-
constructor(tplContextId) {
|
|
1723
|
+
constructor(tplContextId, formContextId) {
|
|
1722
1724
|
_defineProperty$1(this, "data", new Map());
|
|
1723
1725
|
_defineProperty$1(this, "tplContextId", void 0);
|
|
1726
|
+
_defineProperty$1(this, "formContextId", void 0);
|
|
1724
1727
|
this.tplContextId = tplContextId;
|
|
1728
|
+
this.formContextId = formContextId;
|
|
1725
1729
|
}
|
|
1726
1730
|
set(name, item) {
|
|
1727
1731
|
if (this.data.has(name)) {
|
|
@@ -1782,7 +1786,7 @@ class StoryboardContextWrapper {
|
|
|
1782
1786
|
var _item$eventTarget;
|
|
1783
1787
|
item.loaded = true;
|
|
1784
1788
|
item.value = val;
|
|
1785
|
-
(_item$eventTarget = item.eventTarget) === null || _item$eventTarget === void 0 ? void 0 : _item$eventTarget.dispatchEvent(new CustomEvent(this.tplContextId ? "state.change" : "context.change", {
|
|
1789
|
+
(_item$eventTarget = item.eventTarget) === null || _item$eventTarget === void 0 ? void 0 : _item$eventTarget.dispatchEvent(new CustomEvent(this.formContextId ? "formstate.change" : this.tplContextId ? "state.change" : "context.change", {
|
|
1786
1790
|
detail: item.value
|
|
1787
1791
|
}));
|
|
1788
1792
|
}, err => {
|
|
@@ -1817,7 +1821,7 @@ class StoryboardContextWrapper {
|
|
|
1817
1821
|
item.value = value;
|
|
1818
1822
|
}
|
|
1819
1823
|
}
|
|
1820
|
-
(_item$eventTarget2 = item.eventTarget) === null || _item$eventTarget2 === void 0 ? void 0 : _item$eventTarget2.dispatchEvent(new CustomEvent(this.tplContextId ? "state.change" : "context.change", {
|
|
1824
|
+
(_item$eventTarget2 = item.eventTarget) === null || _item$eventTarget2 === void 0 ? void 0 : _item$eventTarget2.dispatchEvent(new CustomEvent(this.formContextId ? "formstate.change" : this.tplContextId ? "state.change" : "context.change", {
|
|
1821
1825
|
detail: item.value
|
|
1822
1826
|
}));
|
|
1823
1827
|
}
|
|
@@ -1953,7 +1957,7 @@ function resolveFreeVariableValue(value, contextConf, mergedContext, storyboardC
|
|
|
1953
1957
|
};
|
|
1954
1958
|
if (contextConf.onChange) {
|
|
1955
1959
|
for (var handler of [].concat(contextConf.onChange)) {
|
|
1956
|
-
newContext.eventTarget.addEventListener(storyboardContextWrapper.tplContextId ? "state.change" : "context.change", listenerFactory(handler, mergedContext, brick));
|
|
1960
|
+
newContext.eventTarget.addEventListener(storyboardContextWrapper.formContextId ? "formstate.change" : storyboardContextWrapper.tplContextId ? "state.change" : "context.change", listenerFactory(handler, mergedContext, brick));
|
|
1957
1961
|
}
|
|
1958
1962
|
}
|
|
1959
1963
|
if (contextConf.track) {
|
|
@@ -1963,7 +1967,7 @@ function resolveFreeVariableValue(value, contextConf, mergedContext, storyboardC
|
|
|
1963
1967
|
for (var dep of deps) {
|
|
1964
1968
|
var _eventTarget;
|
|
1965
1969
|
var ctx = storyboardContextWrapper.get().get(dep);
|
|
1966
|
-
ctx === null || ctx === void 0 ? void 0 : (_eventTarget = ctx.eventTarget) === null || _eventTarget === void 0 ? void 0 : _eventTarget.addEventListener(isTemplateState ? "state.change" : "context.change", () => {
|
|
1970
|
+
ctx === null || ctx === void 0 ? void 0 : (_eventTarget = ctx.eventTarget) === null || _eventTarget === void 0 ? void 0 : _eventTarget.addEventListener(storyboardContextWrapper.formContextId ? "formstate.change" : isTemplateState ? "state.change" : "context.change", () => {
|
|
1967
1971
|
if (load) {
|
|
1968
1972
|
storyboardContextWrapper.updateValue(contextConf.name, {
|
|
1969
1973
|
cache: "default"
|
|
@@ -2058,7 +2062,7 @@ class CustomFormContext {
|
|
|
2058
2062
|
_defineProperty$1(this, "formState", void 0);
|
|
2059
2063
|
_defineProperty$1(this, "id", uniqueId("form-ctx-"));
|
|
2060
2064
|
FormContextMap.set(this.id, this);
|
|
2061
|
-
this.formState = new StoryboardContextWrapper();
|
|
2065
|
+
this.formState = new StoryboardContextWrapper("", this.id);
|
|
2062
2066
|
}
|
|
2063
2067
|
}
|
|
2064
2068
|
function getCustomFormContext(formContextId) {
|
|
@@ -2678,10 +2682,12 @@ function computeRealProperties(properties, context, injectDeep, trackingContextL
|
|
|
2678
2682
|
var raw = typeof propValue === "string" ? propValue : getPreEvaluatedRaw(propValue);
|
|
2679
2683
|
var contextNames = trackContext(raw);
|
|
2680
2684
|
var stateNames = trackState(raw);
|
|
2681
|
-
|
|
2685
|
+
var formStateNames = trackFormState(raw);
|
|
2686
|
+
if (contextNames || stateNames || formStateNames) {
|
|
2682
2687
|
trackingContextList.push({
|
|
2683
2688
|
contextNames,
|
|
2684
2689
|
stateNames,
|
|
2690
|
+
formStateNames,
|
|
2685
2691
|
propName,
|
|
2686
2692
|
propValue
|
|
2687
2693
|
});
|
|
@@ -5684,6 +5690,8 @@ function listenerFactory(handler, context, runtimeBrick) {
|
|
|
5684
5690
|
case "state.refresh":
|
|
5685
5691
|
case "state.load":
|
|
5686
5692
|
return builtinStateListenerFactory(method, handler.args, handler, handler.callback, context);
|
|
5693
|
+
case "formstate.update":
|
|
5694
|
+
return builtinFormStateListenerFactory(method, handler.args, handler, handler.callback, context);
|
|
5687
5695
|
case "tpl.dispatchEvent":
|
|
5688
5696
|
return builtinTplDispatchEventFactory(handler.args, handler, context);
|
|
5689
5697
|
case "message.subscribe":
|
|
@@ -5776,6 +5784,13 @@ function getTplContext(tplContextId) {
|
|
|
5776
5784
|
}
|
|
5777
5785
|
return getCustomTemplateContext(tplContextId);
|
|
5778
5786
|
}
|
|
5787
|
+
function getFormContext(formContextId) {
|
|
5788
|
+
// istanbul ignore if
|
|
5789
|
+
if (!formContextId) {
|
|
5790
|
+
throw new Error("Calling tpl but no formContextId was found in context!");
|
|
5791
|
+
}
|
|
5792
|
+
return getCustomFormContext(formContextId);
|
|
5793
|
+
}
|
|
5779
5794
|
function builtinTplDispatchEventFactory(args, ifContainer, context) {
|
|
5780
5795
|
return function (event) {
|
|
5781
5796
|
if (!looseCheckIf(ifContainer, _objectSpread(_objectSpread({}, context), {}, {
|
|
@@ -5812,6 +5827,18 @@ function builtinStateListenerFactory(method, args, ifContainer, callback, contex
|
|
|
5812
5827
|
tplContext.state.updateValue(name, value, method === "update" ? "replace" : method, callback);
|
|
5813
5828
|
};
|
|
5814
5829
|
}
|
|
5830
|
+
function builtinFormStateListenerFactory(method, args, ifContainer, callback, context) {
|
|
5831
|
+
return function (event) {
|
|
5832
|
+
if (!looseCheckIf(ifContainer, _objectSpread(_objectSpread({}, context), {}, {
|
|
5833
|
+
event
|
|
5834
|
+
}))) {
|
|
5835
|
+
return;
|
|
5836
|
+
}
|
|
5837
|
+
var formContext = getFormContext(context.formContextId);
|
|
5838
|
+
var [name, value] = argsFactory(args, context, event);
|
|
5839
|
+
formContext.formState.updateValue(name, value, method === "update" ? "replace" : method, callback);
|
|
5840
|
+
};
|
|
5841
|
+
}
|
|
5815
5842
|
function builtinLocationListenerFactory(method, args, ifContainer, context) {
|
|
5816
5843
|
return function (event) {
|
|
5817
5844
|
if (!looseCheckIf(ifContainer, _objectSpread(_objectSpread({}, context), {}, {
|
|
@@ -9010,6 +9037,14 @@ function listenOnTrackingContext(brick, trackingContextList, context) {
|
|
|
9010
9037
|
_ctx === null || _ctx === void 0 ? void 0 : (_eventTarget2 = _ctx.eventTarget) === null || _eventTarget2 === void 0 ? void 0 : _eventTarget2.addEventListener("state.change", listener);
|
|
9011
9038
|
}
|
|
9012
9039
|
}
|
|
9040
|
+
if (track.formStateNames) {
|
|
9041
|
+
var formContext = getCustomFormContext(context.formContextId);
|
|
9042
|
+
for (var _stateName of track.formStateNames) {
|
|
9043
|
+
var _eventTarget3;
|
|
9044
|
+
var _ctx2 = formContext.formState.get().get(_stateName);
|
|
9045
|
+
_ctx2 === null || _ctx2 === void 0 ? void 0 : (_eventTarget3 = _ctx2.eventTarget) === null || _eventTarget3 === void 0 ? void 0 : _eventTarget3.addEventListener("formstate.change", listener);
|
|
9046
|
+
}
|
|
9047
|
+
}
|
|
9013
9048
|
};
|
|
9014
9049
|
for (var track of trackingContextList) {
|
|
9015
9050
|
_loop(track);
|
|
@@ -9268,7 +9303,7 @@ function getStoryboard(datasource, result, fields, isPreview, formContextId) {
|
|
|
9268
9303
|
dataItem.properties = _objectSpread(_objectSpread({}, dataItem.properties), {}, {
|
|
9269
9304
|
className: "form-preview"
|
|
9270
9305
|
});
|
|
9271
|
-
dataItem.events = {
|
|
9306
|
+
dataItem.events = _objectSpread(_objectSpread({}, dataItem.events), {}, {
|
|
9272
9307
|
"validate.error": [{
|
|
9273
9308
|
action: "preview.debug",
|
|
9274
9309
|
args: ["validate.error", "<% EVENT.detail %>"]
|
|
@@ -9277,7 +9312,7 @@ function getStoryboard(datasource, result, fields, isPreview, formContextId) {
|
|
|
9277
9312
|
action: "preview.debug",
|
|
9278
9313
|
args: ["validate.success", "<% EVENT.detail %>"]
|
|
9279
9314
|
}]
|
|
9280
|
-
};
|
|
9315
|
+
});
|
|
9281
9316
|
}
|
|
9282
9317
|
//数据初始化:与默认属性进行合并
|
|
9283
9318
|
Object.keys(defaultProperties).forEach(item => {
|