@dcl/react-ecs 7.3.26 → 7.3.27-6730660340.commit-f58fd69
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.
|
@@ -6,6 +6,8 @@ import { TextAlignType, UiFontType } from '../Label/types';
|
|
|
6
6
|
export interface UiInputProps extends Omit<PBUiInput, 'font' | 'textAlign'> {
|
|
7
7
|
/** function to be called on value change */
|
|
8
8
|
onChange?(value: string): void;
|
|
9
|
+
/** function to be called on text field submit */
|
|
10
|
+
onSubmit?(value: string): void;
|
|
9
11
|
font?: UiFontType;
|
|
10
12
|
textAlign?: TextAlignType;
|
|
11
13
|
}
|
package/dist/reconciler/index.js
CHANGED
|
@@ -75,10 +75,22 @@ export function createReconciler(engine, pointerEvents) {
|
|
|
75
75
|
}
|
|
76
76
|
function upsertComponent(instance, props = {}, componentName) {
|
|
77
77
|
const componentId = getComponentId[componentName];
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
const onChangeExists = 'onChange' in props;
|
|
79
|
+
const onSubmitExists = 'onSubmit' in props;
|
|
80
|
+
const entityState = changeEvents.get(instance.entity)?.get(componentId);
|
|
81
|
+
const onChange = onChangeExists
|
|
82
|
+
? props['onChange']
|
|
83
|
+
: entityState?.onChangeCallback;
|
|
84
|
+
const onSubmit = onSubmitExists
|
|
85
|
+
? props['onSubmit']
|
|
86
|
+
: entityState?.onSubmitCallback;
|
|
87
|
+
if (onChangeExists || onSubmitExists) {
|
|
88
|
+
updateOnChange(instance.entity, componentId, {
|
|
89
|
+
onChangeCallback: onChange,
|
|
90
|
+
onSubmitCallback: onSubmit
|
|
91
|
+
});
|
|
92
|
+
delete props.onChange;
|
|
93
|
+
delete props.onSubmit;
|
|
82
94
|
}
|
|
83
95
|
// We check if there is any key pending to be changed to avoid updating the existing component
|
|
84
96
|
if (!Object.keys(props).length) {
|
|
@@ -141,9 +153,11 @@ export function createReconciler(engine, pointerEvents) {
|
|
|
141
153
|
function updateOnChange(entity, componentId, state) {
|
|
142
154
|
const event = changeEvents.get(entity) || changeEvents.set(entity, new Map()).get(entity);
|
|
143
155
|
const oldState = event.get(componentId);
|
|
144
|
-
const
|
|
156
|
+
const onChangeCallback = state?.onChangeCallback;
|
|
157
|
+
const onSubmitCallback = state?.onSubmitCallback;
|
|
145
158
|
const value = state?.value ?? oldState?.value;
|
|
146
|
-
|
|
159
|
+
const isSubmit = state?.isSubmit ?? oldState?.isSubmit;
|
|
160
|
+
event.set(componentId, { onChangeCallback, onSubmitCallback, value, isSubmit });
|
|
147
161
|
}
|
|
148
162
|
const hostConfig = {
|
|
149
163
|
...noopConfig,
|
|
@@ -223,14 +237,19 @@ export function createReconciler(engine, pointerEvents) {
|
|
|
223
237
|
function handleOnChange(componentId, resultComponent) {
|
|
224
238
|
for (const [entity, Result] of engine.getEntitiesWith(resultComponent)) {
|
|
225
239
|
const entityState = changeEvents.get(entity)?.get(componentId);
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
entityState.
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
});
|
|
240
|
+
const isSubmit = !!Result.isSubmit;
|
|
241
|
+
if (entityState?.onChangeCallback && Result.value !== entityState.value) {
|
|
242
|
+
entityState.onChangeCallback(Result.value);
|
|
243
|
+
}
|
|
244
|
+
if (entityState?.onSubmitCallback && isSubmit && !entityState.isSubmit) {
|
|
245
|
+
entityState.onSubmitCallback(Result.value);
|
|
233
246
|
}
|
|
247
|
+
updateOnChange(entity, componentId, {
|
|
248
|
+
onChangeCallback: entityState?.onChangeCallback,
|
|
249
|
+
onSubmitCallback: entityState?.onSubmitCallback,
|
|
250
|
+
value: Result.value,
|
|
251
|
+
isSubmit
|
|
252
|
+
});
|
|
234
253
|
}
|
|
235
254
|
}
|
|
236
255
|
return {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcl/react-ecs",
|
|
3
3
|
"description": "Decentraland ECS",
|
|
4
|
-
"version": "7.3.
|
|
4
|
+
"version": "7.3.27-6730660340.commit-f58fd69",
|
|
5
5
|
"author": "DCL",
|
|
6
6
|
"bugs": "https://github.com/decentraland/js-sdk-toolchain/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@dcl/ecs": "7.3.
|
|
8
|
+
"@dcl/ecs": "7.3.27-6730660340.commit-f58fd69",
|
|
9
9
|
"react": "^18.2.0",
|
|
10
10
|
"react-reconciler": "^0.29.0"
|
|
11
11
|
},
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"tsconfig": "./tsconfig.json"
|
|
40
40
|
},
|
|
41
41
|
"types": "./dist/index.d.ts",
|
|
42
|
-
"commit": "
|
|
42
|
+
"commit": "f58fd69f1dc7178d6d26b86cf6fe6243f1e9328b"
|
|
43
43
|
}
|