@next-core/brick-kit 2.104.3 → 2.104.7
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 +41 -0
- package/dist/index.bundle.js +60 -35
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +60 -35
- package/dist/index.esm.js.map +1 -1
- package/dist/types/BrickAsComponent.d.ts.map +1 -1
- package/dist/types/core/CustomTemplates/CustomTemplateContext.d.ts.map +1 -1
- package/dist/types/core/CustomTemplates/handleProxyOfCustomTemplate.d.ts +1 -1
- package/dist/types/core/CustomTemplates/handleProxyOfCustomTemplate.d.ts.map +1 -1
- package/dist/types/core/StoryboardContext.d.ts +3 -2
- package/dist/types/core/StoryboardContext.d.ts.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,47 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.104.7](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.104.6...@next-core/brick-kit@2.104.7) (2022-02-17)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* mark lazy useBrick for tpl property merge ([5794719](https://github.com/easyops-cn/next-core/commit/579471913e569856772e24ccdf024519b6680aaa))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [2.104.6](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.104.5...@next-core/brick-kit@2.104.6) (2022-02-15)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @next-core/brick-kit
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [2.104.5](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.104.4...@next-core/brick-kit@2.104.5) (2022-02-15)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* fix re-render of useBrick of tpl ([7cbd0d8](https://github.com/easyops-cn/next-core/commit/7cbd0d83517afdb1eef9fafb5e803655f3e698b9))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## [2.104.4](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.104.3...@next-core/brick-kit@2.104.4) (2022-02-15)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Bug Fixes
|
|
40
|
+
|
|
41
|
+
* fix targetRef on working in state.onChange ([bac0003](https://github.com/easyops-cn/next-core/commit/bac000367d82ebd428a2aa08d05193b129718eb7))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
6
47
|
## [2.104.3](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.104.2...@next-core/brick-kit@2.104.3) (2022-02-15)
|
|
7
48
|
|
|
8
49
|
|
package/dist/index.bundle.js
CHANGED
|
@@ -1903,12 +1903,12 @@
|
|
|
1903
1903
|
}
|
|
1904
1904
|
|
|
1905
1905
|
class StoryboardContextWrapper {
|
|
1906
|
-
constructor(
|
|
1906
|
+
constructor(tplContextId) {
|
|
1907
1907
|
_defineProperty__default["default"](this, "data", new Map());
|
|
1908
1908
|
|
|
1909
|
-
_defineProperty__default["default"](this, "
|
|
1909
|
+
_defineProperty__default["default"](this, "tplContextId", void 0);
|
|
1910
1910
|
|
|
1911
|
-
this.
|
|
1911
|
+
this.tplContextId = tplContextId;
|
|
1912
1912
|
}
|
|
1913
1913
|
|
|
1914
1914
|
set(name, item) {
|
|
@@ -1936,7 +1936,7 @@
|
|
|
1936
1936
|
var _item$eventTarget;
|
|
1937
1937
|
|
|
1938
1938
|
if (!this.data.has(name)) {
|
|
1939
|
-
if (this.
|
|
1939
|
+
if (this.tplContextId) {
|
|
1940
1940
|
throw new Error("State not found: ".concat(name));
|
|
1941
1941
|
} else {
|
|
1942
1942
|
// eslint-disable-next-line no-console
|
|
@@ -1969,7 +1969,7 @@
|
|
|
1969
1969
|
}
|
|
1970
1970
|
}
|
|
1971
1971
|
|
|
1972
|
-
(_item$eventTarget = item.eventTarget) === null || _item$eventTarget === void 0 ? void 0 : _item$eventTarget.dispatchEvent(new CustomEvent(this.
|
|
1972
|
+
(_item$eventTarget = item.eventTarget) === null || _item$eventTarget === void 0 ? void 0 : _item$eventTarget.dispatchEvent(new CustomEvent(this.tplContextId ? "state.change" : "context.change", {
|
|
1973
1973
|
detail: item.value
|
|
1974
1974
|
}));
|
|
1975
1975
|
}
|
|
@@ -1979,27 +1979,48 @@
|
|
|
1979
1979
|
|
|
1980
1980
|
return _asyncToGenerator__default["default"](function* () {
|
|
1981
1981
|
if (Array.isArray(contextConfs)) {
|
|
1982
|
-
|
|
1982
|
+
var {
|
|
1983
|
+
mergedContext,
|
|
1984
|
+
keyword
|
|
1985
|
+
} = _this.getResolveOptions(coreContext);
|
|
1986
|
+
|
|
1987
|
+
yield brickUtils.resolveContextConcurrently(contextConfs, contextConf => resolveStoryboardContext(contextConf, mergedContext, _this, brick), keyword);
|
|
1983
1988
|
}
|
|
1984
1989
|
})();
|
|
1985
1990
|
}
|
|
1986
1991
|
|
|
1987
1992
|
syncDefine(contextConfs, coreContext, brick) {
|
|
1988
1993
|
if (Array.isArray(contextConfs)) {
|
|
1989
|
-
|
|
1994
|
+
var {
|
|
1995
|
+
mergedContext,
|
|
1996
|
+
keyword
|
|
1997
|
+
} = this.getResolveOptions(coreContext);
|
|
1998
|
+
brickUtils.syncResolveContextConcurrently(contextConfs, contextConf => syncResolveStoryboardContext(contextConf, mergedContext, this, brick), keyword);
|
|
1990
1999
|
}
|
|
1991
2000
|
}
|
|
1992
2001
|
|
|
2002
|
+
getResolveOptions(coreContext) {
|
|
2003
|
+
return this.tplContextId ? {
|
|
2004
|
+
mergedContext: _objectSpread__default["default"](_objectSpread__default["default"]({}, coreContext), {}, {
|
|
2005
|
+
tplContextId: this.tplContextId
|
|
2006
|
+
}),
|
|
2007
|
+
keyword: "STATE"
|
|
2008
|
+
} : {
|
|
2009
|
+
mergedContext: coreContext,
|
|
2010
|
+
keyword: "CTX"
|
|
2011
|
+
};
|
|
2012
|
+
}
|
|
2013
|
+
|
|
1993
2014
|
}
|
|
1994
2015
|
|
|
1995
|
-
function resolveStoryboardContext(_x, _x2, _x3, _x4
|
|
2016
|
+
function resolveStoryboardContext(_x, _x2, _x3, _x4) {
|
|
1996
2017
|
return _resolveStoryboardContext.apply(this, arguments);
|
|
1997
2018
|
}
|
|
1998
2019
|
|
|
1999
2020
|
function _resolveStoryboardContext() {
|
|
2000
|
-
_resolveStoryboardContext = _asyncToGenerator__default["default"](function* (
|
|
2021
|
+
_resolveStoryboardContext = _asyncToGenerator__default["default"](function* (contextConf, coreContext, storyboardContextWrapper, brick) {
|
|
2001
2022
|
if (contextConf.property) {
|
|
2002
|
-
if (
|
|
2023
|
+
if (storyboardContextWrapper.tplContextId) {
|
|
2003
2024
|
throw new Error("Setting `property` is not allowed in template scoped context");
|
|
2004
2025
|
}
|
|
2005
2026
|
|
|
@@ -2019,28 +2040,28 @@
|
|
|
2019
2040
|
return _resolveStoryboardContext.apply(this, arguments);
|
|
2020
2041
|
}
|
|
2021
2042
|
|
|
2022
|
-
function resolveNormalStoryboardContext(_x6, _x7, _x8
|
|
2043
|
+
function resolveNormalStoryboardContext(_x5, _x6, _x7, _x8) {
|
|
2023
2044
|
return _resolveNormalStoryboardContext.apply(this, arguments);
|
|
2024
2045
|
}
|
|
2025
2046
|
|
|
2026
2047
|
function _resolveNormalStoryboardContext() {
|
|
2027
|
-
_resolveNormalStoryboardContext = _asyncToGenerator__default["default"](function* (contextConf,
|
|
2028
|
-
if (!looseCheckIf(contextConf,
|
|
2048
|
+
_resolveNormalStoryboardContext = _asyncToGenerator__default["default"](function* (contextConf, mergedContext, storyboardContextWrapper, brick) {
|
|
2049
|
+
if (!looseCheckIf(contextConf, mergedContext)) {
|
|
2029
2050
|
return false;
|
|
2030
2051
|
}
|
|
2031
2052
|
|
|
2032
2053
|
var isResolve = false;
|
|
2033
|
-
var value = getDefinedTemplateState(
|
|
2054
|
+
var value = getDefinedTemplateState(!!storyboardContextWrapper.tplContextId, contextConf, brick);
|
|
2034
2055
|
|
|
2035
2056
|
if (value === undefined) {
|
|
2036
2057
|
if (contextConf.resolve) {
|
|
2037
|
-
if (looseCheckIf(contextConf.resolve,
|
|
2058
|
+
if (looseCheckIf(contextConf.resolve, mergedContext)) {
|
|
2038
2059
|
isResolve = true;
|
|
2039
2060
|
var valueConf = {};
|
|
2040
2061
|
yield _internalApiGetResolver().resolveOne("reference", _objectSpread__default["default"]({
|
|
2041
2062
|
transform: "value",
|
|
2042
2063
|
transformMapArray: false
|
|
2043
|
-
}, contextConf.resolve), valueConf, null,
|
|
2064
|
+
}, contextConf.resolve), valueConf, null, mergedContext);
|
|
2044
2065
|
value = valueConf.value;
|
|
2045
2066
|
} else if (!brickUtils.hasOwnProperty(contextConf, "value")) {
|
|
2046
2067
|
return false;
|
|
@@ -2048,18 +2069,18 @@
|
|
|
2048
2069
|
}
|
|
2049
2070
|
|
|
2050
2071
|
if (!isResolve && contextConf.value !== undefined) {
|
|
2051
|
-
value = computeRealValue(contextConf.value,
|
|
2072
|
+
value = computeRealValue(contextConf.value, mergedContext, true);
|
|
2052
2073
|
}
|
|
2053
2074
|
}
|
|
2054
2075
|
|
|
2055
|
-
resolveFreeVariableValue(value, contextConf,
|
|
2076
|
+
resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick);
|
|
2056
2077
|
return true;
|
|
2057
2078
|
});
|
|
2058
2079
|
return _resolveNormalStoryboardContext.apply(this, arguments);
|
|
2059
2080
|
}
|
|
2060
2081
|
|
|
2061
|
-
function syncResolveStoryboardContext(contextConf,
|
|
2062
|
-
if (!looseCheckIf(contextConf,
|
|
2082
|
+
function syncResolveStoryboardContext(contextConf, mergedContext, storyboardContextWrapper, brick) {
|
|
2083
|
+
if (!looseCheckIf(contextConf, mergedContext)) {
|
|
2063
2084
|
return false;
|
|
2064
2085
|
}
|
|
2065
2086
|
|
|
@@ -2067,23 +2088,23 @@
|
|
|
2067
2088
|
throw new Error("resolve is not allowed here");
|
|
2068
2089
|
}
|
|
2069
2090
|
|
|
2070
|
-
var value = getDefinedTemplateState(
|
|
2091
|
+
var value = getDefinedTemplateState(!!storyboardContextWrapper.tplContextId, contextConf, brick);
|
|
2071
2092
|
|
|
2072
2093
|
if (value === undefined) {
|
|
2073
|
-
value = computeRealValue(contextConf.value,
|
|
2094
|
+
value = computeRealValue(contextConf.value, mergedContext, true);
|
|
2074
2095
|
}
|
|
2075
2096
|
|
|
2076
|
-
resolveFreeVariableValue(value, contextConf,
|
|
2097
|
+
resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick);
|
|
2077
2098
|
return true;
|
|
2078
2099
|
}
|
|
2079
2100
|
|
|
2080
|
-
function getDefinedTemplateState(
|
|
2081
|
-
if (
|
|
2101
|
+
function getDefinedTemplateState(isTemplateState, contextConf, brick) {
|
|
2102
|
+
if (isTemplateState && brick.properties && brickUtils.hasOwnProperty(brick.properties, contextConf.name)) {
|
|
2082
2103
|
return brick.properties[contextConf.name];
|
|
2083
2104
|
}
|
|
2084
2105
|
}
|
|
2085
2106
|
|
|
2086
|
-
function resolveFreeVariableValue(value, contextConf,
|
|
2107
|
+
function resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick) {
|
|
2087
2108
|
var newContext = {
|
|
2088
2109
|
type: "free-variable",
|
|
2089
2110
|
value,
|
|
@@ -2093,7 +2114,7 @@
|
|
|
2093
2114
|
|
|
2094
2115
|
if (contextConf.onChange) {
|
|
2095
2116
|
for (var handler of [].concat(contextConf.onChange)) {
|
|
2096
|
-
newContext.eventTarget.addEventListener(storyboardContextWrapper.
|
|
2117
|
+
newContext.eventTarget.addEventListener(storyboardContextWrapper.tplContextId ? "state.change" : "context.change", listenerFactory(handler, mergedContext, brick));
|
|
2097
2118
|
}
|
|
2098
2119
|
}
|
|
2099
2120
|
|
|
@@ -2105,12 +2126,13 @@
|
|
|
2105
2126
|
constructor(brick) {
|
|
2106
2127
|
_defineProperty__default["default"](this, "variables", void 0);
|
|
2107
2128
|
|
|
2108
|
-
_defineProperty__default["default"](this, "state",
|
|
2129
|
+
_defineProperty__default["default"](this, "state", void 0);
|
|
2109
2130
|
|
|
2110
2131
|
_defineProperty__default["default"](this, "id", lodash.uniqueId("tpl-ctx-"));
|
|
2111
2132
|
|
|
2112
2133
|
this.brick = brick;
|
|
2113
2134
|
tplContextMap.set(this.id, this);
|
|
2135
|
+
this.state = new StoryboardContextWrapper(this.id);
|
|
2114
2136
|
brick.tplContextId = this.id;
|
|
2115
2137
|
}
|
|
2116
2138
|
|
|
@@ -10122,7 +10144,9 @@
|
|
|
10122
10144
|
// Use an approach like template-literal's quasis:
|
|
10123
10145
|
// `quasi0${0}quais1${1}quasi2...`
|
|
10124
10146
|
// Every quasi can be merged with multiple items.
|
|
10125
|
-
var computedBaseValue = Array.isArray(baseValue) ? computeRealValue(baseValue, context, true
|
|
10147
|
+
var computedBaseValue = Array.isArray(baseValue) ? computeRealValue(baseValue, context, true, {
|
|
10148
|
+
$$lazyForUseBrick: true
|
|
10149
|
+
}) : [];
|
|
10126
10150
|
var quasis = [];
|
|
10127
10151
|
var size = computedBaseValue.length + 1;
|
|
10128
10152
|
|
|
@@ -10512,7 +10536,7 @@
|
|
|
10512
10536
|
return false;
|
|
10513
10537
|
}
|
|
10514
10538
|
|
|
10515
|
-
function handleProxyOfCustomTemplate(brick
|
|
10539
|
+
function handleProxyOfCustomTemplate(brick) {
|
|
10516
10540
|
// Ignore non-tpl bricks.
|
|
10517
10541
|
if (!brick.proxyRefs) {
|
|
10518
10542
|
return;
|
|
@@ -10526,17 +10550,18 @@
|
|
|
10526
10550
|
|
|
10527
10551
|
return (_brick$proxyRefs$get$ = brick.proxyRefs.get(ref).brick) === null || _brick$proxyRefs$get$ === void 0 ? void 0 : _brick$proxyRefs$get$.element;
|
|
10528
10552
|
}
|
|
10529
|
-
}
|
|
10530
|
-
// `tpl.$$getElementByRef(ref)` will return the ref element inside a custom template.
|
|
10553
|
+
}
|
|
10531
10554
|
|
|
10555
|
+
var firstRun = !node.$$getElementByRef; // For usages of `targetRef: "..."`.
|
|
10556
|
+
// `tpl.$$getElementByRef(ref)` will return the ref element inside a custom template.
|
|
10532
10557
|
|
|
10533
|
-
if (
|
|
10558
|
+
if (firstRun) {
|
|
10534
10559
|
Object.defineProperty(node, "$$getElementByRef", {
|
|
10535
10560
|
value: getElementByRef
|
|
10536
10561
|
});
|
|
10537
10562
|
}
|
|
10538
10563
|
|
|
10539
|
-
if (
|
|
10564
|
+
if (firstRun && brick.stateNames) {
|
|
10540
10565
|
(function () {
|
|
10541
10566
|
// Define properties from state for tpl.
|
|
10542
10567
|
var getState = () => getCustomTemplateContext(brick.tplContextId).state;
|
|
@@ -11196,7 +11221,7 @@
|
|
|
11196
11221
|
handleProxyOfCustomTemplate(_objectSpread__default["default"](_objectSpread__default["default"]({}, tplBrick), {}, {
|
|
11197
11222
|
proxyRefs: singleRefBrickProxyMap,
|
|
11198
11223
|
proxy: getFilterProxy(tplBrick.proxy, brick.ref)
|
|
11199
|
-
})
|
|
11224
|
+
}));
|
|
11200
11225
|
setRealProperties(tplBrick.element, tplBrick.properties || {});
|
|
11201
11226
|
}
|
|
11202
11227
|
}
|