@player-ui/data-change-listener-plugin 0.7.0 → 0.7.1-next.0

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.cjs.js CHANGED
@@ -77,20 +77,16 @@ function extractDataChangeListeners(view, bindingParser) {
77
77
  }
78
78
  const listenerRawBinding = listenerKey.slice(LISTENER_TYPES.dataChange.length);
79
79
  if (listenerKey.match(WILDCARD_REGEX)) {
80
- return [
81
- ...allListeners,
82
- createWildcardHandler(listenerRawBinding, listenerExp, bindingParser)
83
- ];
80
+ allListeners.push(createWildcardHandler(listenerRawBinding, listenerExp, bindingParser));
81
+ return allListeners;
84
82
  }
85
83
  const parsedOriginalBinding = bindingParser.parse(listenerRawBinding);
86
- return [
87
- ...allListeners,
88
- (context, binding) => {
89
- if (parsedOriginalBinding.contains(binding)) {
90
- context.expressionEvaluator.evaluate(listenerExp);
91
- }
84
+ allListeners.push((context, binding) => {
85
+ if (parsedOriginalBinding.contains(binding)) {
86
+ context.expressionEvaluator.evaluate(listenerExp);
92
87
  }
93
- ];
88
+ });
89
+ return allListeners;
94
90
  }, []);
95
91
  }
96
92
  class DataChangeListenerPlugin {
@@ -100,6 +96,7 @@ class DataChangeListenerPlugin {
100
96
  apply(player) {
101
97
  let expressionEvaluator;
102
98
  let dataChangeListeners = [];
99
+ let validationController;
103
100
  player.hooks.expressionEvaluator.tap(this.name, (expEvaluator) => {
104
101
  expressionEvaluator = expEvaluator;
105
102
  });
@@ -121,8 +118,7 @@ class DataChangeListenerPlugin {
121
118
  return;
122
119
  const validUpdates = updates.filter((update) => {
123
120
  var _a;
124
- const committedVal = (_a = options == null ? void 0 : options.context) == null ? void 0 : _a.model.get(update.binding);
125
- return committedVal === update.newValue;
121
+ return !((_a = validationController.getValidationForBinding(update.binding)) == null ? void 0 : _a.getAll().length);
126
122
  });
127
123
  onFieldUpdateHandler(validUpdates.map((t) => t.binding));
128
124
  }));
@@ -142,6 +138,9 @@ class DataChangeListenerPlugin {
142
138
  return withoutListeners;
143
139
  });
144
140
  });
141
+ player.hooks.validationController.tap(this.name, (vc) => {
142
+ validationController = vc;
143
+ });
145
144
  player.hooks.flowController.tap(this.name, (flowController) => {
146
145
  flowController.hooks.flow.tap(this.name, (flow) => {
147
146
  flow.hooks.transition.tap(this.name, (from, to) => {
package/dist/index.esm.js CHANGED
@@ -73,20 +73,16 @@ function extractDataChangeListeners(view, bindingParser) {
73
73
  }
74
74
  const listenerRawBinding = listenerKey.slice(LISTENER_TYPES.dataChange.length);
75
75
  if (listenerKey.match(WILDCARD_REGEX)) {
76
- return [
77
- ...allListeners,
78
- createWildcardHandler(listenerRawBinding, listenerExp, bindingParser)
79
- ];
76
+ allListeners.push(createWildcardHandler(listenerRawBinding, listenerExp, bindingParser));
77
+ return allListeners;
80
78
  }
81
79
  const parsedOriginalBinding = bindingParser.parse(listenerRawBinding);
82
- return [
83
- ...allListeners,
84
- (context, binding) => {
85
- if (parsedOriginalBinding.contains(binding)) {
86
- context.expressionEvaluator.evaluate(listenerExp);
87
- }
80
+ allListeners.push((context, binding) => {
81
+ if (parsedOriginalBinding.contains(binding)) {
82
+ context.expressionEvaluator.evaluate(listenerExp);
88
83
  }
89
- ];
84
+ });
85
+ return allListeners;
90
86
  }, []);
91
87
  }
92
88
  class DataChangeListenerPlugin {
@@ -96,6 +92,7 @@ class DataChangeListenerPlugin {
96
92
  apply(player) {
97
93
  let expressionEvaluator;
98
94
  let dataChangeListeners = [];
95
+ let validationController;
99
96
  player.hooks.expressionEvaluator.tap(this.name, (expEvaluator) => {
100
97
  expressionEvaluator = expEvaluator;
101
98
  });
@@ -117,8 +114,7 @@ class DataChangeListenerPlugin {
117
114
  return;
118
115
  const validUpdates = updates.filter((update) => {
119
116
  var _a;
120
- const committedVal = (_a = options == null ? void 0 : options.context) == null ? void 0 : _a.model.get(update.binding);
121
- return committedVal === update.newValue;
117
+ return !((_a = validationController.getValidationForBinding(update.binding)) == null ? void 0 : _a.getAll().length);
122
118
  });
123
119
  onFieldUpdateHandler(validUpdates.map((t) => t.binding));
124
120
  }));
@@ -138,6 +134,9 @@ class DataChangeListenerPlugin {
138
134
  return withoutListeners;
139
135
  });
140
136
  });
137
+ player.hooks.validationController.tap(this.name, (vc) => {
138
+ validationController = vc;
139
+ });
141
140
  player.hooks.flowController.tap(this.name, (flowController) => {
142
141
  flowController.hooks.flow.tap(this.name, (flow) => {
143
142
  flow.hooks.transition.tap(this.name, (from, to) => {
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@player-ui/data-change-listener-plugin",
3
- "version": "0.7.0",
3
+ "version": "0.7.1-next.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org"
7
7
  },
8
8
  "peerDependencies": {
9
- "@player-ui/player": "0.7.0"
9
+ "@player-ui/player": "0.7.1-next.0"
10
10
  },
11
11
  "dependencies": {
12
12
  "@babel/runtime": "7.15.4"
package/src/index.ts CHANGED
@@ -8,6 +8,7 @@ import type {
8
8
  ExpressionEvaluator,
9
9
  BindingInstance,
10
10
  BindingParser,
11
+ ValidationController,
11
12
  } from '@player-ui/player';
12
13
  import { isExpressionNode } from '@player-ui/player';
13
14
 
@@ -166,22 +167,20 @@ function extractDataChangeListeners(
166
167
  );
167
168
 
168
169
  if (listenerKey.match(WILDCARD_REGEX)) {
169
- return [
170
- ...allListeners,
171
- createWildcardHandler(listenerRawBinding, listenerExp, bindingParser),
172
- ];
170
+ allListeners.push(
171
+ createWildcardHandler(listenerRawBinding, listenerExp, bindingParser)
172
+ );
173
+ return allListeners;
173
174
  }
174
175
 
175
176
  const parsedOriginalBinding = bindingParser.parse(listenerRawBinding);
176
177
 
177
- return [
178
- ...allListeners,
179
- (context, binding) => {
180
- if (parsedOriginalBinding.contains(binding)) {
181
- context.expressionEvaluator.evaluate(listenerExp);
182
- }
183
- },
184
- ];
178
+ allListeners.push((context, binding) => {
179
+ if (parsedOriginalBinding.contains(binding)) {
180
+ context.expressionEvaluator.evaluate(listenerExp);
181
+ }
182
+ });
183
+ return allListeners;
185
184
  },
186
185
  []
187
186
  );
@@ -196,6 +195,7 @@ export class DataChangeListenerPlugin implements PlayerPlugin {
196
195
  apply(player: Player) {
197
196
  let expressionEvaluator: ExpressionEvaluator;
198
197
  let dataChangeListeners: Array<ViewListenerHandler> = [];
198
+ let validationController: ValidationController;
199
199
 
200
200
  player.hooks.expressionEvaluator.tap(
201
201
  this.name,
@@ -236,8 +236,9 @@ export class DataChangeListenerPlugin implements PlayerPlugin {
236
236
  const { silent = false } = options || {};
237
237
  if (silent) return;
238
238
  const validUpdates = updates.filter((update) => {
239
- const committedVal = options?.context?.model.get(update.binding);
240
- return committedVal === update.newValue;
239
+ return !validationController
240
+ .getValidationForBinding(update.binding)
241
+ ?.getAll().length;
241
242
  });
242
243
  onFieldUpdateHandler(validUpdates.map((t) => t.binding));
243
244
  })
@@ -279,6 +280,10 @@ export class DataChangeListenerPlugin implements PlayerPlugin {
279
280
  }
280
281
  );
281
282
 
283
+ player.hooks.validationController.tap(this.name, (vc) => {
284
+ validationController = vc;
285
+ });
286
+
282
287
  player.hooks.flowController.tap(this.name, (flowController) => {
283
288
  flowController.hooks.flow.tap(this.name, (flow) => {
284
289
  flow.hooks.transition.tap(this.name, (from, to) => {