@next-core/brick-kit 2.104.3 → 2.104.4

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.esm.js CHANGED
@@ -1904,12 +1904,12 @@ function _checkIf(rawIf, ctx, fn) {
1904
1904
  }
1905
1905
 
1906
1906
  class StoryboardContextWrapper {
1907
- constructor(isTemplateState) {
1907
+ constructor(tplContextId) {
1908
1908
  _defineProperty$1(this, "data", new Map());
1909
1909
 
1910
- _defineProperty$1(this, "isTemplateState", void 0);
1910
+ _defineProperty$1(this, "tplContextId", void 0);
1911
1911
 
1912
- this.isTemplateState = isTemplateState;
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.isTemplateState) {
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.isTemplateState ? "state.change" : "context.change", {
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,7 +1980,7 @@ class StoryboardContextWrapper {
1980
1980
 
1981
1981
  return _asyncToGenerator$4(function* () {
1982
1982
  if (Array.isArray(contextConfs)) {
1983
- yield resolveContextConcurrently(contextConfs, contextConf => resolveStoryboardContext(_this.isTemplateState, contextConf, coreContext, _this, brick));
1983
+ yield resolveContextConcurrently(contextConfs, contextConf => resolveStoryboardContext(contextConf, coreContext, _this, brick));
1984
1984
  }
1985
1985
  })();
1986
1986
  }
@@ -1993,14 +1993,14 @@ class StoryboardContextWrapper {
1993
1993
 
1994
1994
  }
1995
1995
 
1996
- function resolveStoryboardContext(_x, _x2, _x3, _x4, _x5) {
1996
+ function resolveStoryboardContext(_x, _x2, _x3, _x4) {
1997
1997
  return _resolveStoryboardContext.apply(this, arguments);
1998
1998
  }
1999
1999
 
2000
2000
  function _resolveStoryboardContext() {
2001
- _resolveStoryboardContext = _asyncToGenerator$4(function* (isTemplateState, contextConf, coreContext, storyboardContextWrapper, brick) {
2001
+ _resolveStoryboardContext = _asyncToGenerator$4(function* (contextConf, coreContext, storyboardContextWrapper, brick) {
2002
2002
  if (contextConf.property) {
2003
- if (isTemplateState) {
2003
+ if (storyboardContextWrapper.tplContextId) {
2004
2004
  throw new Error("Setting `property` is not allowed in template scoped context");
2005
2005
  }
2006
2006
 
@@ -2020,7 +2020,7 @@ function _resolveStoryboardContext() {
2020
2020
  return _resolveStoryboardContext.apply(this, arguments);
2021
2021
  }
2022
2022
 
2023
- function resolveNormalStoryboardContext(_x6, _x7, _x8, _x9) {
2023
+ function resolveNormalStoryboardContext(_x5, _x6, _x7, _x8) {
2024
2024
  return _resolveNormalStoryboardContext.apply(this, arguments);
2025
2025
  }
2026
2026
 
@@ -2079,7 +2079,7 @@ function syncResolveStoryboardContext(contextConf, coreContext, storyboardContex
2079
2079
  }
2080
2080
 
2081
2081
  function getDefinedTemplateState(contextConf, storyboardContextWrapper, brick) {
2082
- if (storyboardContextWrapper.isTemplateState && brick.properties && hasOwnProperty(brick.properties, contextConf.name)) {
2082
+ if (storyboardContextWrapper.tplContextId && brick.properties && hasOwnProperty(brick.properties, contextConf.name)) {
2083
2083
  return brick.properties[contextConf.name];
2084
2084
  }
2085
2085
  }
@@ -2094,7 +2094,13 @@ function resolveFreeVariableValue(value, contextConf, coreContext, storyboardCon
2094
2094
 
2095
2095
  if (contextConf.onChange) {
2096
2096
  for (var handler of [].concat(contextConf.onChange)) {
2097
- newContext.eventTarget.addEventListener(storyboardContextWrapper.isTemplateState ? "state.change" : "context.change", listenerFactory(handler, coreContext, brick));
2097
+ if (storyboardContextWrapper.tplContextId) {
2098
+ newContext.eventTarget.addEventListener("state.change", listenerFactory(handler, _objectSpread(_objectSpread({}, coreContext), {}, {
2099
+ tplContextId: storyboardContextWrapper.tplContextId
2100
+ }), brick));
2101
+ } else {
2102
+ newContext.eventTarget.addEventListener("context.change", listenerFactory(handler, coreContext, brick));
2103
+ }
2098
2104
  }
2099
2105
  }
2100
2106
 
@@ -2106,12 +2112,13 @@ class CustomTemplateContext {
2106
2112
  constructor(brick) {
2107
2113
  _defineProperty$1(this, "variables", void 0);
2108
2114
 
2109
- _defineProperty$1(this, "state", new StoryboardContextWrapper(true));
2115
+ _defineProperty$1(this, "state", void 0);
2110
2116
 
2111
2117
  _defineProperty$1(this, "id", uniqueId("tpl-ctx-"));
2112
2118
 
2113
2119
  this.brick = brick;
2114
2120
  tplContextMap.set(this.id, this);
2121
+ this.state = new StoryboardContextWrapper(this.id);
2115
2122
  brick.tplContextId = this.id;
2116
2123
  }
2117
2124