@dcl/react-ecs 7.7.6-13418365922.commit-c459a2f → 7.7.6-13579862299.commit-06e2154
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/reconciler/index.js +15 -28
- package/package.json +3 -3
package/dist/reconciler/index.js
CHANGED
|
@@ -124,6 +124,7 @@ export function createReconciler(engine, pointerEvents) {
|
|
|
124
124
|
}
|
|
125
125
|
function removeChildEntity(instance) {
|
|
126
126
|
changeEvents.delete(instance.entity);
|
|
127
|
+
clickEvents.delete(instance.entity);
|
|
127
128
|
engine.removeEntity(instance.entity);
|
|
128
129
|
for (const child of instance._child) {
|
|
129
130
|
removeChildEntity(child);
|
|
@@ -170,13 +171,23 @@ export function createReconciler(engine, pointerEvents) {
|
|
|
170
171
|
removeChildEntity(child);
|
|
171
172
|
}
|
|
172
173
|
function updateOnChange(entity, componentId, state) {
|
|
174
|
+
const hasEvent = changeEvents.has(entity);
|
|
173
175
|
const event = changeEvents.get(entity) || changeEvents.set(entity, new Map()).get(entity);
|
|
174
|
-
const oldState = event.get(componentId);
|
|
175
176
|
const onChangeCallback = state?.onChangeCallback;
|
|
176
177
|
const onSubmitCallback = state?.onSubmitCallback;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
event.set(componentId, { onChangeCallback, onSubmitCallback });
|
|
179
|
+
// Create onChange callback if its the first callback event for this entity
|
|
180
|
+
if (!hasEvent) {
|
|
181
|
+
const resultComponentId = componentId === UiDropdown.componentId ? UiDropdownResult.componentId : UiInputResult.componentId;
|
|
182
|
+
engine.getComponent(resultComponentId).onChange(entity, (value) => {
|
|
183
|
+
if (value?.isSubmit) {
|
|
184
|
+
const onSubmit = changeEvents.get(entity)?.get(componentId)?.onSubmitCallback;
|
|
185
|
+
onSubmit && onSubmit(value?.value);
|
|
186
|
+
}
|
|
187
|
+
const onChange = changeEvents.get(entity)?.get(componentId)?.onChangeCallback;
|
|
188
|
+
onChange && onChange(value?.value);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
180
191
|
}
|
|
181
192
|
const hostConfig = {
|
|
182
193
|
...noopConfig,
|
|
@@ -251,32 +262,8 @@ export function createReconciler(engine, pointerEvents) {
|
|
|
251
262
|
const root = reconciler.createContainer({}, 0, null, false, null, '',
|
|
252
263
|
/* istanbul ignore next */
|
|
253
264
|
function () { }, null);
|
|
254
|
-
// Maybe this could be something similar to Input system, but since we
|
|
255
|
-
// are going to use this only here, i prefer to scope it here.
|
|
256
|
-
function handleOnChange(componentId, resultComponent) {
|
|
257
|
-
for (const [entity, Result] of engine.getEntitiesWith(resultComponent)) {
|
|
258
|
-
const entityState = changeEvents.get(entity)?.get(componentId);
|
|
259
|
-
const isSubmit = !!Result.isSubmit;
|
|
260
|
-
if (entityState?.onChangeCallback && Result.value !== entityState.value) {
|
|
261
|
-
entityState.onChangeCallback(Result.value);
|
|
262
|
-
}
|
|
263
|
-
if (entityState?.onSubmitCallback && isSubmit && !entityState.isSubmit) {
|
|
264
|
-
entityState.onSubmitCallback(Result.value);
|
|
265
|
-
}
|
|
266
|
-
updateOnChange(entity, componentId, {
|
|
267
|
-
onChangeCallback: entityState?.onChangeCallback,
|
|
268
|
-
onSubmitCallback: entityState?.onSubmitCallback,
|
|
269
|
-
value: Result.value,
|
|
270
|
-
isSubmit
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
265
|
return {
|
|
275
266
|
update: function (component) {
|
|
276
|
-
if (changeEvents.size) {
|
|
277
|
-
handleOnChange(UiInput.componentId, UiInputResult);
|
|
278
|
-
handleOnChange(UiDropdown.componentId, UiDropdownResult);
|
|
279
|
-
}
|
|
280
267
|
return reconciler.updateContainer(component, root, null);
|
|
281
268
|
},
|
|
282
269
|
getEntities: () => Array.from(entities)
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcl/react-ecs",
|
|
3
3
|
"description": "Decentraland ECS",
|
|
4
|
-
"version": "7.7.6-
|
|
4
|
+
"version": "7.7.6-13579862299.commit-06e2154",
|
|
5
5
|
"author": "DCL",
|
|
6
6
|
"bugs": "https://github.com/decentraland/js-sdk-toolchain/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@dcl/ecs": "7.7.6-
|
|
8
|
+
"@dcl/ecs": "7.7.6-13579862299.commit-06e2154",
|
|
9
9
|
"react": "^18.2.0",
|
|
10
10
|
"react-reconciler": "^0.29.0"
|
|
11
11
|
},
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"tsconfig": "./tsconfig.json"
|
|
41
41
|
},
|
|
42
42
|
"types": "./dist/index.d.ts",
|
|
43
|
-
"commit": "
|
|
43
|
+
"commit": "06e21544861e59ce4851a5a31fa1aa7c70a48181"
|
|
44
44
|
}
|