@next-core/brick-kit 2.104.2 → 2.104.6
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 +104 -77
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +104 -77
- 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/dist/types/internal/setProperties.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -1904,12 +1904,12 @@ function _checkIf(rawIf, ctx, fn) {
|
|
|
1904
1904
|
}
|
|
1905
1905
|
|
|
1906
1906
|
class StoryboardContextWrapper {
|
|
1907
|
-
constructor(
|
|
1907
|
+
constructor(tplContextId) {
|
|
1908
1908
|
_defineProperty$1(this, "data", new Map());
|
|
1909
1909
|
|
|
1910
|
-
_defineProperty$1(this, "
|
|
1910
|
+
_defineProperty$1(this, "tplContextId", void 0);
|
|
1911
1911
|
|
|
1912
|
-
this.
|
|
1912
|
+
this.tplContextId = tplContextId;
|
|
1913
1913
|
}
|
|
1914
1914
|
|
|
1915
1915
|
set(name, item) {
|
|
@@ -1937,7 +1937,7 @@ class StoryboardContextWrapper {
|
|
|
1937
1937
|
var _item$eventTarget;
|
|
1938
1938
|
|
|
1939
1939
|
if (!this.data.has(name)) {
|
|
1940
|
-
if (this.
|
|
1940
|
+
if (this.tplContextId) {
|
|
1941
1941
|
throw new Error("State not found: ".concat(name));
|
|
1942
1942
|
} else {
|
|
1943
1943
|
// eslint-disable-next-line no-console
|
|
@@ -1970,7 +1970,7 @@ class StoryboardContextWrapper {
|
|
|
1970
1970
|
}
|
|
1971
1971
|
}
|
|
1972
1972
|
|
|
1973
|
-
(_item$eventTarget = item.eventTarget) === null || _item$eventTarget === void 0 ? void 0 : _item$eventTarget.dispatchEvent(new CustomEvent(this.
|
|
1973
|
+
(_item$eventTarget = item.eventTarget) === null || _item$eventTarget === void 0 ? void 0 : _item$eventTarget.dispatchEvent(new CustomEvent(this.tplContextId ? "state.change" : "context.change", {
|
|
1974
1974
|
detail: item.value
|
|
1975
1975
|
}));
|
|
1976
1976
|
}
|
|
@@ -1980,27 +1980,48 @@ class StoryboardContextWrapper {
|
|
|
1980
1980
|
|
|
1981
1981
|
return _asyncToGenerator$4(function* () {
|
|
1982
1982
|
if (Array.isArray(contextConfs)) {
|
|
1983
|
-
|
|
1983
|
+
var {
|
|
1984
|
+
mergedContext,
|
|
1985
|
+
keyword
|
|
1986
|
+
} = _this.getResolveOptions(coreContext);
|
|
1987
|
+
|
|
1988
|
+
yield resolveContextConcurrently(contextConfs, contextConf => resolveStoryboardContext(contextConf, mergedContext, _this, brick), keyword);
|
|
1984
1989
|
}
|
|
1985
1990
|
})();
|
|
1986
1991
|
}
|
|
1987
1992
|
|
|
1988
1993
|
syncDefine(contextConfs, coreContext, brick) {
|
|
1989
1994
|
if (Array.isArray(contextConfs)) {
|
|
1990
|
-
|
|
1995
|
+
var {
|
|
1996
|
+
mergedContext,
|
|
1997
|
+
keyword
|
|
1998
|
+
} = this.getResolveOptions(coreContext);
|
|
1999
|
+
syncResolveContextConcurrently(contextConfs, contextConf => syncResolveStoryboardContext(contextConf, mergedContext, this, brick), keyword);
|
|
1991
2000
|
}
|
|
1992
2001
|
}
|
|
1993
2002
|
|
|
2003
|
+
getResolveOptions(coreContext) {
|
|
2004
|
+
return this.tplContextId ? {
|
|
2005
|
+
mergedContext: _objectSpread(_objectSpread({}, coreContext), {}, {
|
|
2006
|
+
tplContextId: this.tplContextId
|
|
2007
|
+
}),
|
|
2008
|
+
keyword: "STATE"
|
|
2009
|
+
} : {
|
|
2010
|
+
mergedContext: coreContext,
|
|
2011
|
+
keyword: "CTX"
|
|
2012
|
+
};
|
|
2013
|
+
}
|
|
2014
|
+
|
|
1994
2015
|
}
|
|
1995
2016
|
|
|
1996
|
-
function resolveStoryboardContext(_x, _x2, _x3, _x4
|
|
2017
|
+
function resolveStoryboardContext(_x, _x2, _x3, _x4) {
|
|
1997
2018
|
return _resolveStoryboardContext.apply(this, arguments);
|
|
1998
2019
|
}
|
|
1999
2020
|
|
|
2000
2021
|
function _resolveStoryboardContext() {
|
|
2001
|
-
_resolveStoryboardContext = _asyncToGenerator$4(function* (
|
|
2022
|
+
_resolveStoryboardContext = _asyncToGenerator$4(function* (contextConf, coreContext, storyboardContextWrapper, brick) {
|
|
2002
2023
|
if (contextConf.property) {
|
|
2003
|
-
if (
|
|
2024
|
+
if (storyboardContextWrapper.tplContextId) {
|
|
2004
2025
|
throw new Error("Setting `property` is not allowed in template scoped context");
|
|
2005
2026
|
}
|
|
2006
2027
|
|
|
@@ -2020,28 +2041,28 @@ function _resolveStoryboardContext() {
|
|
|
2020
2041
|
return _resolveStoryboardContext.apply(this, arguments);
|
|
2021
2042
|
}
|
|
2022
2043
|
|
|
2023
|
-
function resolveNormalStoryboardContext(_x6, _x7, _x8
|
|
2044
|
+
function resolveNormalStoryboardContext(_x5, _x6, _x7, _x8) {
|
|
2024
2045
|
return _resolveNormalStoryboardContext.apply(this, arguments);
|
|
2025
2046
|
}
|
|
2026
2047
|
|
|
2027
2048
|
function _resolveNormalStoryboardContext() {
|
|
2028
|
-
_resolveNormalStoryboardContext = _asyncToGenerator$4(function* (contextConf,
|
|
2029
|
-
if (!looseCheckIf(contextConf,
|
|
2049
|
+
_resolveNormalStoryboardContext = _asyncToGenerator$4(function* (contextConf, mergedContext, storyboardContextWrapper, brick) {
|
|
2050
|
+
if (!looseCheckIf(contextConf, mergedContext)) {
|
|
2030
2051
|
return false;
|
|
2031
2052
|
}
|
|
2032
2053
|
|
|
2033
2054
|
var isResolve = false;
|
|
2034
|
-
var value = getDefinedTemplateState(
|
|
2055
|
+
var value = getDefinedTemplateState(!!storyboardContextWrapper.tplContextId, contextConf, brick);
|
|
2035
2056
|
|
|
2036
2057
|
if (value === undefined) {
|
|
2037
2058
|
if (contextConf.resolve) {
|
|
2038
|
-
if (looseCheckIf(contextConf.resolve,
|
|
2059
|
+
if (looseCheckIf(contextConf.resolve, mergedContext)) {
|
|
2039
2060
|
isResolve = true;
|
|
2040
2061
|
var valueConf = {};
|
|
2041
2062
|
yield _internalApiGetResolver().resolveOne("reference", _objectSpread({
|
|
2042
2063
|
transform: "value",
|
|
2043
2064
|
transformMapArray: false
|
|
2044
|
-
}, contextConf.resolve), valueConf, null,
|
|
2065
|
+
}, contextConf.resolve), valueConf, null, mergedContext);
|
|
2045
2066
|
value = valueConf.value;
|
|
2046
2067
|
} else if (!hasOwnProperty(contextConf, "value")) {
|
|
2047
2068
|
return false;
|
|
@@ -2049,18 +2070,18 @@ function _resolveNormalStoryboardContext() {
|
|
|
2049
2070
|
}
|
|
2050
2071
|
|
|
2051
2072
|
if (!isResolve && contextConf.value !== undefined) {
|
|
2052
|
-
value = computeRealValue(contextConf.value,
|
|
2073
|
+
value = computeRealValue(contextConf.value, mergedContext, true);
|
|
2053
2074
|
}
|
|
2054
2075
|
}
|
|
2055
2076
|
|
|
2056
|
-
resolveFreeVariableValue(value, contextConf,
|
|
2077
|
+
resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick);
|
|
2057
2078
|
return true;
|
|
2058
2079
|
});
|
|
2059
2080
|
return _resolveNormalStoryboardContext.apply(this, arguments);
|
|
2060
2081
|
}
|
|
2061
2082
|
|
|
2062
|
-
function syncResolveStoryboardContext(contextConf,
|
|
2063
|
-
if (!looseCheckIf(contextConf,
|
|
2083
|
+
function syncResolveStoryboardContext(contextConf, mergedContext, storyboardContextWrapper, brick) {
|
|
2084
|
+
if (!looseCheckIf(contextConf, mergedContext)) {
|
|
2064
2085
|
return false;
|
|
2065
2086
|
}
|
|
2066
2087
|
|
|
@@ -2068,23 +2089,23 @@ function syncResolveStoryboardContext(contextConf, coreContext, storyboardContex
|
|
|
2068
2089
|
throw new Error("resolve is not allowed here");
|
|
2069
2090
|
}
|
|
2070
2091
|
|
|
2071
|
-
var value = getDefinedTemplateState(
|
|
2092
|
+
var value = getDefinedTemplateState(!!storyboardContextWrapper.tplContextId, contextConf, brick);
|
|
2072
2093
|
|
|
2073
2094
|
if (value === undefined) {
|
|
2074
|
-
value = computeRealValue(contextConf.value,
|
|
2095
|
+
value = computeRealValue(contextConf.value, mergedContext, true);
|
|
2075
2096
|
}
|
|
2076
2097
|
|
|
2077
|
-
resolveFreeVariableValue(value, contextConf,
|
|
2098
|
+
resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick);
|
|
2078
2099
|
return true;
|
|
2079
2100
|
}
|
|
2080
2101
|
|
|
2081
|
-
function getDefinedTemplateState(
|
|
2082
|
-
if (
|
|
2102
|
+
function getDefinedTemplateState(isTemplateState, contextConf, brick) {
|
|
2103
|
+
if (isTemplateState && brick.properties && hasOwnProperty(brick.properties, contextConf.name)) {
|
|
2083
2104
|
return brick.properties[contextConf.name];
|
|
2084
2105
|
}
|
|
2085
2106
|
}
|
|
2086
2107
|
|
|
2087
|
-
function resolveFreeVariableValue(value, contextConf,
|
|
2108
|
+
function resolveFreeVariableValue(value, contextConf, mergedContext, storyboardContextWrapper, brick) {
|
|
2088
2109
|
var newContext = {
|
|
2089
2110
|
type: "free-variable",
|
|
2090
2111
|
value,
|
|
@@ -2094,7 +2115,7 @@ function resolveFreeVariableValue(value, contextConf, coreContext, storyboardCon
|
|
|
2094
2115
|
|
|
2095
2116
|
if (contextConf.onChange) {
|
|
2096
2117
|
for (var handler of [].concat(contextConf.onChange)) {
|
|
2097
|
-
newContext.eventTarget.addEventListener(storyboardContextWrapper.
|
|
2118
|
+
newContext.eventTarget.addEventListener(storyboardContextWrapper.tplContextId ? "state.change" : "context.change", listenerFactory(handler, mergedContext, brick));
|
|
2098
2119
|
}
|
|
2099
2120
|
}
|
|
2100
2121
|
|
|
@@ -2106,12 +2127,13 @@ class CustomTemplateContext {
|
|
|
2106
2127
|
constructor(brick) {
|
|
2107
2128
|
_defineProperty$1(this, "variables", void 0);
|
|
2108
2129
|
|
|
2109
|
-
_defineProperty$1(this, "state",
|
|
2130
|
+
_defineProperty$1(this, "state", void 0);
|
|
2110
2131
|
|
|
2111
2132
|
_defineProperty$1(this, "id", uniqueId("tpl-ctx-"));
|
|
2112
2133
|
|
|
2113
2134
|
this.brick = brick;
|
|
2114
2135
|
tplContextMap.set(this.id, this);
|
|
2136
|
+
this.state = new StoryboardContextWrapper(this.id);
|
|
2115
2137
|
brick.tplContextId = this.id;
|
|
2116
2138
|
}
|
|
2117
2139
|
|
|
@@ -2435,6 +2457,49 @@ function evaluate(raw) {
|
|
|
2435
2457
|
}
|
|
2436
2458
|
}
|
|
2437
2459
|
|
|
2460
|
+
var customTemplateRegistry = new Map();
|
|
2461
|
+
var appRegistered = new Set();
|
|
2462
|
+
var symbolForComputedPropsFromProxy = Symbol.for("tpl.computedPropsFromProxy");
|
|
2463
|
+
var symbolForRefForProxy = Symbol.for("tpl.refForProxy");
|
|
2464
|
+
var symbolForTplContextId = Symbol.for("tpl.contextId");
|
|
2465
|
+
|
|
2466
|
+
function setupUseBrickInTemplate(props, tplContextId) {
|
|
2467
|
+
function walk(props) {
|
|
2468
|
+
if (!props) {
|
|
2469
|
+
return;
|
|
2470
|
+
}
|
|
2471
|
+
|
|
2472
|
+
for (var [key, value] of Object.entries(props)) {
|
|
2473
|
+
if (isObject(value)) {
|
|
2474
|
+
if (key === "useBrick") {
|
|
2475
|
+
if (Array.isArray(value)) {
|
|
2476
|
+
value.forEach(setup);
|
|
2477
|
+
} else {
|
|
2478
|
+
setup(value);
|
|
2479
|
+
}
|
|
2480
|
+
} else {
|
|
2481
|
+
walk(value);
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
|
|
2487
|
+
function setup(item) {
|
|
2488
|
+
item[symbolForTplContextId] = tplContextId;
|
|
2489
|
+
walk(item.properties);
|
|
2490
|
+
|
|
2491
|
+
if (item.slots) {
|
|
2492
|
+
Object.values(item.slots).forEach(slot => {
|
|
2493
|
+
if (Array.isArray(slot.bricks)) {
|
|
2494
|
+
slot.bricks.forEach(setup);
|
|
2495
|
+
}
|
|
2496
|
+
});
|
|
2497
|
+
}
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2500
|
+
walk(props);
|
|
2501
|
+
}
|
|
2502
|
+
|
|
2438
2503
|
var computeRealValue = (value, context, injectDeep, internalOptions) => {
|
|
2439
2504
|
var preEvaluated = isPreEvaluated(value);
|
|
2440
2505
|
|
|
@@ -2488,6 +2553,10 @@ var computeRealValue = (value, context, injectDeep, internalOptions) => {
|
|
|
2488
2553
|
function setProperties(bricks, properties, context, injectDeep) {
|
|
2489
2554
|
var realProps = computeRealProperties(properties, context, injectDeep);
|
|
2490
2555
|
|
|
2556
|
+
if (context.tplContextId) {
|
|
2557
|
+
setupUseBrickInTemplate(realProps, context.tplContextId);
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2491
2560
|
if (!Array.isArray(bricks)) {
|
|
2492
2561
|
bricks = [bricks];
|
|
2493
2562
|
}
|
|
@@ -10002,12 +10071,6 @@ class Router {
|
|
|
10002
10071
|
|
|
10003
10072
|
}
|
|
10004
10073
|
|
|
10005
|
-
var customTemplateRegistry = new Map();
|
|
10006
|
-
var appRegistered = new Set();
|
|
10007
|
-
var symbolForComputedPropsFromProxy = Symbol.for("tpl.computedPropsFromProxy");
|
|
10008
|
-
var symbolForRefForProxy = Symbol.for("tpl.refForProxy");
|
|
10009
|
-
var symbolForTplContextId = Symbol.for("tpl.contextId");
|
|
10010
|
-
|
|
10011
10074
|
function isBasicProperty(propRef) {
|
|
10012
10075
|
return !!propRef.refProperty;
|
|
10013
10076
|
}
|
|
@@ -10182,43 +10245,6 @@ function collectMergeBases(conf, mergeBases, contextInTemplate, refToBrickConf)
|
|
|
10182
10245
|
}
|
|
10183
10246
|
}
|
|
10184
10247
|
|
|
10185
|
-
function setupUseBrickInTemplate(props, tplContextId) {
|
|
10186
|
-
function walk(props) {
|
|
10187
|
-
if (!props) {
|
|
10188
|
-
return;
|
|
10189
|
-
}
|
|
10190
|
-
|
|
10191
|
-
for (var [key, value] of Object.entries(props)) {
|
|
10192
|
-
if (isObject(value)) {
|
|
10193
|
-
if (key === "useBrick") {
|
|
10194
|
-
if (Array.isArray(value)) {
|
|
10195
|
-
value.forEach(setup);
|
|
10196
|
-
} else {
|
|
10197
|
-
setup(value);
|
|
10198
|
-
}
|
|
10199
|
-
} else {
|
|
10200
|
-
walk(value);
|
|
10201
|
-
}
|
|
10202
|
-
}
|
|
10203
|
-
}
|
|
10204
|
-
}
|
|
10205
|
-
|
|
10206
|
-
function setup(item) {
|
|
10207
|
-
item[symbolForTplContextId] = tplContextId;
|
|
10208
|
-
walk(item.properties);
|
|
10209
|
-
|
|
10210
|
-
if (item.slots) {
|
|
10211
|
-
Object.values(item.slots).forEach(slot => {
|
|
10212
|
-
if (Array.isArray(slot.bricks)) {
|
|
10213
|
-
slot.bricks.forEach(setup);
|
|
10214
|
-
}
|
|
10215
|
-
});
|
|
10216
|
-
}
|
|
10217
|
-
}
|
|
10218
|
-
|
|
10219
|
-
walk(props);
|
|
10220
|
-
}
|
|
10221
|
-
|
|
10222
10248
|
var _excluded$1 = ["properties", "slots"],
|
|
10223
10249
|
_excluded2 = ["ref", "slots"];
|
|
10224
10250
|
function expandCustomTemplate(brickConf, proxyBrick, context) {
|
|
@@ -10509,7 +10535,7 @@ function getTagNameOfCustomTemplate(brick, appId) {
|
|
|
10509
10535
|
return false;
|
|
10510
10536
|
}
|
|
10511
10537
|
|
|
10512
|
-
function handleProxyOfCustomTemplate(brick
|
|
10538
|
+
function handleProxyOfCustomTemplate(brick) {
|
|
10513
10539
|
// Ignore non-tpl bricks.
|
|
10514
10540
|
if (!brick.proxyRefs) {
|
|
10515
10541
|
return;
|
|
@@ -10523,17 +10549,18 @@ function handleProxyOfCustomTemplate(brick, reRun) {
|
|
|
10523
10549
|
|
|
10524
10550
|
return (_brick$proxyRefs$get$ = brick.proxyRefs.get(ref).brick) === null || _brick$proxyRefs$get$ === void 0 ? void 0 : _brick$proxyRefs$get$.element;
|
|
10525
10551
|
}
|
|
10526
|
-
}
|
|
10527
|
-
// `tpl.$$getElementByRef(ref)` will return the ref element inside a custom template.
|
|
10552
|
+
}
|
|
10528
10553
|
|
|
10554
|
+
var firstRun = !node.$$getElementByRef; // For usages of `targetRef: "..."`.
|
|
10555
|
+
// `tpl.$$getElementByRef(ref)` will return the ref element inside a custom template.
|
|
10529
10556
|
|
|
10530
|
-
if (
|
|
10557
|
+
if (firstRun) {
|
|
10531
10558
|
Object.defineProperty(node, "$$getElementByRef", {
|
|
10532
10559
|
value: getElementByRef
|
|
10533
10560
|
});
|
|
10534
10561
|
}
|
|
10535
10562
|
|
|
10536
|
-
if (
|
|
10563
|
+
if (firstRun && brick.stateNames) {
|
|
10537
10564
|
(function () {
|
|
10538
10565
|
// Define properties from state for tpl.
|
|
10539
10566
|
var getState = () => getCustomTemplateContext(brick.tplContextId).state;
|
|
@@ -11193,7 +11220,7 @@ var handleProxyOfParentTemplate = (brick, tplContextId) => {
|
|
|
11193
11220
|
handleProxyOfCustomTemplate(_objectSpread(_objectSpread({}, tplBrick), {}, {
|
|
11194
11221
|
proxyRefs: singleRefBrickProxyMap,
|
|
11195
11222
|
proxy: getFilterProxy(tplBrick.proxy, brick.ref)
|
|
11196
|
-
})
|
|
11223
|
+
}));
|
|
11197
11224
|
setRealProperties(tplBrick.element, tplBrick.properties || {});
|
|
11198
11225
|
}
|
|
11199
11226
|
}
|