@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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
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.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)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * fix targetRef on working in state.onChange ([bac0003](https://github.com/easyops-cn/next-core/commit/bac000367d82ebd428a2aa08d05193b129718eb7))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [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
18
 
8
19
 
@@ -1903,12 +1903,12 @@
1903
1903
  }
1904
1904
 
1905
1905
  class StoryboardContextWrapper {
1906
- constructor(isTemplateState) {
1906
+ constructor(tplContextId) {
1907
1907
  _defineProperty__default["default"](this, "data", new Map());
1908
1908
 
1909
- _defineProperty__default["default"](this, "isTemplateState", void 0);
1909
+ _defineProperty__default["default"](this, "tplContextId", void 0);
1910
1910
 
1911
- this.isTemplateState = isTemplateState;
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.isTemplateState) {
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.isTemplateState ? "state.change" : "context.change", {
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,7 +1979,7 @@
1979
1979
 
1980
1980
  return _asyncToGenerator__default["default"](function* () {
1981
1981
  if (Array.isArray(contextConfs)) {
1982
- yield brickUtils.resolveContextConcurrently(contextConfs, contextConf => resolveStoryboardContext(_this.isTemplateState, contextConf, coreContext, _this, brick));
1982
+ yield brickUtils.resolveContextConcurrently(contextConfs, contextConf => resolveStoryboardContext(contextConf, coreContext, _this, brick));
1983
1983
  }
1984
1984
  })();
1985
1985
  }
@@ -1992,14 +1992,14 @@
1992
1992
 
1993
1993
  }
1994
1994
 
1995
- function resolveStoryboardContext(_x, _x2, _x3, _x4, _x5) {
1995
+ function resolveStoryboardContext(_x, _x2, _x3, _x4) {
1996
1996
  return _resolveStoryboardContext.apply(this, arguments);
1997
1997
  }
1998
1998
 
1999
1999
  function _resolveStoryboardContext() {
2000
- _resolveStoryboardContext = _asyncToGenerator__default["default"](function* (isTemplateState, contextConf, coreContext, storyboardContextWrapper, brick) {
2000
+ _resolveStoryboardContext = _asyncToGenerator__default["default"](function* (contextConf, coreContext, storyboardContextWrapper, brick) {
2001
2001
  if (contextConf.property) {
2002
- if (isTemplateState) {
2002
+ if (storyboardContextWrapper.tplContextId) {
2003
2003
  throw new Error("Setting `property` is not allowed in template scoped context");
2004
2004
  }
2005
2005
 
@@ -2019,7 +2019,7 @@
2019
2019
  return _resolveStoryboardContext.apply(this, arguments);
2020
2020
  }
2021
2021
 
2022
- function resolveNormalStoryboardContext(_x6, _x7, _x8, _x9) {
2022
+ function resolveNormalStoryboardContext(_x5, _x6, _x7, _x8) {
2023
2023
  return _resolveNormalStoryboardContext.apply(this, arguments);
2024
2024
  }
2025
2025
 
@@ -2078,7 +2078,7 @@
2078
2078
  }
2079
2079
 
2080
2080
  function getDefinedTemplateState(contextConf, storyboardContextWrapper, brick) {
2081
- if (storyboardContextWrapper.isTemplateState && brick.properties && brickUtils.hasOwnProperty(brick.properties, contextConf.name)) {
2081
+ if (storyboardContextWrapper.tplContextId && brick.properties && brickUtils.hasOwnProperty(brick.properties, contextConf.name)) {
2082
2082
  return brick.properties[contextConf.name];
2083
2083
  }
2084
2084
  }
@@ -2093,7 +2093,13 @@
2093
2093
 
2094
2094
  if (contextConf.onChange) {
2095
2095
  for (var handler of [].concat(contextConf.onChange)) {
2096
- newContext.eventTarget.addEventListener(storyboardContextWrapper.isTemplateState ? "state.change" : "context.change", listenerFactory(handler, coreContext, brick));
2096
+ if (storyboardContextWrapper.tplContextId) {
2097
+ newContext.eventTarget.addEventListener("state.change", listenerFactory(handler, _objectSpread__default["default"](_objectSpread__default["default"]({}, coreContext), {}, {
2098
+ tplContextId: storyboardContextWrapper.tplContextId
2099
+ }), brick));
2100
+ } else {
2101
+ newContext.eventTarget.addEventListener("context.change", listenerFactory(handler, coreContext, brick));
2102
+ }
2097
2103
  }
2098
2104
  }
2099
2105
 
@@ -2105,12 +2111,13 @@
2105
2111
  constructor(brick) {
2106
2112
  _defineProperty__default["default"](this, "variables", void 0);
2107
2113
 
2108
- _defineProperty__default["default"](this, "state", new StoryboardContextWrapper(true));
2114
+ _defineProperty__default["default"](this, "state", void 0);
2109
2115
 
2110
2116
  _defineProperty__default["default"](this, "id", lodash.uniqueId("tpl-ctx-"));
2111
2117
 
2112
2118
  this.brick = brick;
2113
2119
  tplContextMap.set(this.id, this);
2120
+ this.state = new StoryboardContextWrapper(this.id);
2114
2121
  brick.tplContextId = this.id;
2115
2122
  }
2116
2123