@dcl/react-ecs 7.8.5 → 7.8.6-14664638926.commit-7bb4ee2
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/components/Button/index.js +2 -2
- package/dist/components/Dropdown/index.js +5 -2
- package/dist/components/Input/index.js +5 -2
- package/dist/components/Label/index.js +8 -3
- package/dist/components/Label/types.d.ts +4 -0
- package/dist/components/listeners/types.d.ts +6 -0
- package/dist/components/listeners/types.js +4 -1
- package/dist/components/uiBackground/types.d.ts +12 -1
- package/dist/components/uiBackground/utils.js +8 -0
- package/dist/components/uiTransform/index.d.ts +1 -1
- package/dist/components/uiTransform/index.js +9 -4
- package/dist/components/uiTransform/types.d.ts +16 -0
- package/dist/components/uiTransform/utils.js +37 -0
- package/dist/react-ecs.d.ts +5 -11
- package/dist/react-ecs.js +0 -2
- package/dist/reconciler/index.d.ts +4 -3
- package/dist/reconciler/index.js +27 -3
- package/dist/reconciler/utils.js +3 -0
- package/dist/system.d.ts +2 -1
- package/dist/system.js +16 -1
- package/package.json +3 -3
|
@@ -29,7 +29,7 @@ function getButtonProps(props) {
|
|
|
29
29
|
*/
|
|
30
30
|
/* @__PURE__ */
|
|
31
31
|
export function Button(props) {
|
|
32
|
-
const { uiTransform, uiBackground, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, ...otherProps } = props;
|
|
32
|
+
const { uiTransform, uiBackground, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, onMouseDrag, onMouseDragLocked, onMouseDragEnd, ...otherProps } = props;
|
|
33
33
|
const buttonProps = getButtonProps(props);
|
|
34
34
|
const uiBackgroundProps = parseUiBackground({
|
|
35
35
|
...buttonProps.uiBackground,
|
|
@@ -54,5 +54,5 @@ export function Button(props) {
|
|
|
54
54
|
if (uiBackgroundProps && uiBackgroundProps.color)
|
|
55
55
|
uiBackgroundProps.color.a /= 2;
|
|
56
56
|
}
|
|
57
|
-
return (ReactEcs.createElement("entity", { onMouseDown: !!props.disabled ? undefined : onMouseDown, onMouseUp: !!props.disabled ? undefined : onMouseUp, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, uiTransform: uiTransformProps, uiText: textProps, uiBackground: uiBackgroundProps }));
|
|
57
|
+
return (ReactEcs.createElement("entity", { onMouseDown: !!props.disabled ? undefined : onMouseDown, onMouseUp: !!props.disabled ? undefined : onMouseUp, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onMouseDrag: onMouseDrag, onMouseDragLocked: onMouseDragLocked, onMouseDragEnd: onMouseDragEnd, uiTransform: uiTransformProps, uiText: textProps, uiBackground: uiBackgroundProps }));
|
|
58
58
|
}
|
|
@@ -34,7 +34,7 @@ function parseUiDropdown(props) {
|
|
|
34
34
|
*/
|
|
35
35
|
/* @__PURE__ */
|
|
36
36
|
export function Dropdown(props) {
|
|
37
|
-
const { uiTransform, uiBackground, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, ...otherProps } = props;
|
|
37
|
+
const { uiTransform, uiBackground, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, onMouseDrag, onMouseDragLocked, onMouseDragEnd, ...otherProps } = props;
|
|
38
38
|
const dropdownProps = parseUiDropdown(otherProps);
|
|
39
39
|
const commonProps = parseProps({
|
|
40
40
|
uiTransform,
|
|
@@ -42,7 +42,10 @@ export function Dropdown(props) {
|
|
|
42
42
|
onMouseDown,
|
|
43
43
|
onMouseUp,
|
|
44
44
|
onMouseEnter,
|
|
45
|
-
onMouseLeave
|
|
45
|
+
onMouseLeave,
|
|
46
|
+
onMouseDrag,
|
|
47
|
+
onMouseDragLocked,
|
|
48
|
+
onMouseDragEnd
|
|
46
49
|
});
|
|
47
50
|
return ReactEcs.createElement("entity", { ...commonProps, uiDropdown: dropdownProps });
|
|
48
51
|
}
|
|
@@ -35,7 +35,7 @@ function parseUiInput(props) {
|
|
|
35
35
|
* @category Component
|
|
36
36
|
*/ /* @__PURE__ */
|
|
37
37
|
export function Input(props) {
|
|
38
|
-
const { uiTransform, uiBackground, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, ...otherProps } = props;
|
|
38
|
+
const { uiTransform, uiBackground, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, onMouseDrag, onMouseDragLocked, onMouseDragEnd, ...otherProps } = props;
|
|
39
39
|
const inputProps = parseUiInput(otherProps);
|
|
40
40
|
const commonProps = parseProps({
|
|
41
41
|
uiTransform,
|
|
@@ -43,7 +43,10 @@ export function Input(props) {
|
|
|
43
43
|
onMouseDown,
|
|
44
44
|
onMouseUp,
|
|
45
45
|
onMouseEnter,
|
|
46
|
-
onMouseLeave
|
|
46
|
+
onMouseLeave,
|
|
47
|
+
onMouseDrag,
|
|
48
|
+
onMouseDragLocked,
|
|
49
|
+
onMouseDragEnd
|
|
47
50
|
});
|
|
48
51
|
return ReactEcs.createElement("entity", { ...commonProps, uiInput: inputProps });
|
|
49
52
|
}
|
|
@@ -16,14 +16,17 @@ export { scaleFontSize } from './utils';
|
|
|
16
16
|
*/
|
|
17
17
|
/* @__PURE__ */
|
|
18
18
|
export function Label(props) {
|
|
19
|
-
const { uiTransform, uiBackground, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, ...uiTextProps } = props;
|
|
19
|
+
const { uiTransform, uiBackground, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, onMouseDrag, onMouseDragLocked, onMouseDragEnd, ...uiTextProps } = props;
|
|
20
20
|
const commonProps = parseProps({
|
|
21
21
|
uiTransform,
|
|
22
22
|
uiBackground,
|
|
23
23
|
onMouseDown,
|
|
24
24
|
onMouseUp,
|
|
25
25
|
onMouseEnter,
|
|
26
|
-
onMouseLeave
|
|
26
|
+
onMouseLeave,
|
|
27
|
+
onMouseDrag,
|
|
28
|
+
onMouseDragLocked,
|
|
29
|
+
onMouseDragEnd
|
|
27
30
|
});
|
|
28
31
|
const { font, textAlign, fontSize, textWrap, ...textProps } = uiTextProps;
|
|
29
32
|
const uiText = {
|
|
@@ -31,7 +34,9 @@ export function Label(props) {
|
|
|
31
34
|
...getFont(font),
|
|
32
35
|
...getTextAlign(textAlign),
|
|
33
36
|
...getFontSize(fontSize),
|
|
34
|
-
...getTextWrap(textWrap)
|
|
37
|
+
...getTextWrap(textWrap),
|
|
38
|
+
outlineWidth: props.outlineWidth,
|
|
39
|
+
outlineColor: props.outlineColor
|
|
35
40
|
};
|
|
36
41
|
return ReactEcs.createElement("entity", { ...commonProps, uiText: uiText });
|
|
37
42
|
}
|
|
@@ -15,6 +15,10 @@ export interface UiLabelProps {
|
|
|
15
15
|
textAlign?: TextAlignType | undefined;
|
|
16
16
|
/** Label font type. @defaultValue 'sans-serif' */
|
|
17
17
|
font?: UiFontType | undefined;
|
|
18
|
+
/** Outline width of the text. @defaultValue 0 */
|
|
19
|
+
outlineWidth?: number | undefined;
|
|
20
|
+
/** Outline color of the text. @defaultValue `{ r: 0, g: 0, b: 0, a: 1 }` */
|
|
21
|
+
outlineColor?: Color4 | undefined;
|
|
18
22
|
/** Behaviour when text reached. @defaultValue 'wrap' */
|
|
19
23
|
textWrap?: UiTextWrapType | undefined;
|
|
20
24
|
}
|
|
@@ -16,4 +16,10 @@ export type Listeners = {
|
|
|
16
16
|
onMouseEnter?: Callback;
|
|
17
17
|
/** triggered on mouse leave event */
|
|
18
18
|
onMouseLeave?: Callback;
|
|
19
|
+
/** triggered on mouse drag event */
|
|
20
|
+
onMouseDrag?: Callback;
|
|
21
|
+
/** triggered on mouse drag event */
|
|
22
|
+
onMouseDragLocked?: Callback;
|
|
23
|
+
/** triggered on mouse drag event */
|
|
24
|
+
onMouseDragEnd?: Callback;
|
|
19
25
|
};
|
|
@@ -2,7 +2,10 @@ const listeners = {
|
|
|
2
2
|
onMouseDown: undefined,
|
|
3
3
|
onMouseUp: undefined,
|
|
4
4
|
onMouseEnter: undefined,
|
|
5
|
-
onMouseLeave: undefined
|
|
5
|
+
onMouseLeave: undefined,
|
|
6
|
+
onMouseDrag: undefined,
|
|
7
|
+
onMouseDragLocked: undefined,
|
|
8
|
+
onMouseDragEnd: undefined
|
|
6
9
|
};
|
|
7
10
|
const listenersKey = Object.keys(listeners);
|
|
8
11
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BorderRect } from '@dcl/ecs';
|
|
1
|
+
import { BorderRect, Entity } from '@dcl/ecs';
|
|
2
2
|
import { Color4 } from '@dcl/ecs/dist/components/generated/pb/decentraland/common/colors.gen';
|
|
3
3
|
/**
|
|
4
4
|
* @public
|
|
@@ -15,6 +15,8 @@ export interface UiBackgroundProps {
|
|
|
15
15
|
uvs?: number[];
|
|
16
16
|
/** AvatarTexture for the background */
|
|
17
17
|
avatarTexture?: UiAvatarTexture;
|
|
18
|
+
/** VideoTexture for the background */
|
|
19
|
+
videoTexture?: UiVideoTexture;
|
|
18
20
|
/** Texture for the background */
|
|
19
21
|
texture?: UiTexture;
|
|
20
22
|
}
|
|
@@ -27,6 +29,15 @@ export interface UiAvatarTexture {
|
|
|
27
29
|
wrapMode?: TextureWrapType;
|
|
28
30
|
filterMode?: TextureFilterType;
|
|
29
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Texture
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export interface UiVideoTexture {
|
|
37
|
+
videoPlayerEntity: Entity;
|
|
38
|
+
wrapMode?: TextureWrapType;
|
|
39
|
+
filterMode?: TextureFilterType;
|
|
40
|
+
}
|
|
30
41
|
/**
|
|
31
42
|
* Texture
|
|
32
43
|
* @public
|
|
@@ -30,6 +30,14 @@ export function getTexture(props) {
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
+
if (props.videoTexture) {
|
|
34
|
+
return {
|
|
35
|
+
tex: {
|
|
36
|
+
$case: 'videoTexture',
|
|
37
|
+
videoTexture: parseTexture(props.videoTexture)
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
33
41
|
return undefined;
|
|
34
42
|
}
|
|
35
43
|
function parseTexture(texture) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getAlign, getDisplay, getFlexDirection, getFlexWrap, getJustify, getOverflow, getPointerFilter, getPositionType, parseBorderColor, parseBorderRadius, parseBorderWidth, parsePosition, parseSize } from './utils';
|
|
1
|
+
import { getAlign, getDisplay, getFlexDirection, getFlexWrap, getJustify, getOverflow, getPointerFilter, getPositionType, parseBorderColor, parseBorderRadius, parseBorderWidth, getScrollPosition, getScrollVisible, parsePosition, parseSize } from './utils';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
@@ -51,14 +51,16 @@ const defaultUiTransform = {
|
|
|
51
51
|
flexBasisUnit: 0 /* YGUnit.YGU_UNDEFINED */,
|
|
52
52
|
widthUnit: 3 /* YGUnit.YGU_AUTO */,
|
|
53
53
|
heightUnit: 0 /* YGUnit.YGU_UNDEFINED */,
|
|
54
|
-
pointerFilter: 0 /* PointerFilterMode.PFM_NONE
|
|
54
|
+
pointerFilter: 0 /* PointerFilterMode.PFM_NONE */,
|
|
55
|
+
opacity: 1,
|
|
56
|
+
zIndex: 0
|
|
55
57
|
};
|
|
56
58
|
/**
|
|
57
59
|
* @public
|
|
58
60
|
*/
|
|
59
61
|
/* @__PURE__ */
|
|
60
62
|
export function parseUiTransform(props = {}) {
|
|
61
|
-
const { height, minHeight, maxHeight, width, minWidth, maxWidth, alignItems, alignContent, flexWrap, borderRadius, borderWidth, borderColor, ...otherProps } = props;
|
|
63
|
+
const { scrollPosition, scrollVisible, height, minHeight, maxHeight, width, minWidth, maxWidth, alignItems, alignContent, flexWrap, borderRadius, borderWidth, borderColor, zIndex, ...otherProps } = props;
|
|
62
64
|
return {
|
|
63
65
|
...defaultUiTransform,
|
|
64
66
|
...otherProps,
|
|
@@ -84,6 +86,9 @@ export function parseUiTransform(props = {}) {
|
|
|
84
86
|
...(flexWrap && getFlexWrap(flexWrap)),
|
|
85
87
|
...(borderRadius && parseBorderRadius(borderRadius)),
|
|
86
88
|
...(borderWidth && parseBorderWidth(borderWidth)),
|
|
87
|
-
...(borderColor && parseBorderColor(borderColor))
|
|
89
|
+
...(borderColor && parseBorderColor(borderColor)),
|
|
90
|
+
...(scrollPosition && getScrollPosition(scrollPosition)),
|
|
91
|
+
...(scrollVisible && getScrollVisible(scrollVisible)),
|
|
92
|
+
...(zIndex && { zIndex })
|
|
88
93
|
};
|
|
89
94
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Color4 } from '@dcl/ecs/dist/components/generated/pb/decentraland/common/colors.gen';
|
|
2
|
+
import { Vector2 } from '@dcl/ecs/dist/components/generated/pb/decentraland/common/vectors.gen';
|
|
2
3
|
import { ScaleUnit } from '../types';
|
|
3
4
|
/**
|
|
4
5
|
* unit value specified. i.e. 1 || '100%' || '1px' || '10vw'
|
|
@@ -73,6 +74,11 @@ export type PositionType = 'absolute' | 'relative';
|
|
|
73
74
|
* The pointer filter property determines if the ui element blocks the pointer or not (elements with pointer events always block the pointer regardless of this property)
|
|
74
75
|
*/
|
|
75
76
|
export type PointerFilterType = 'none' | 'block';
|
|
77
|
+
/**
|
|
78
|
+
* @public
|
|
79
|
+
* The scroll-visible determines if the scrollbars are shown when the scroll overflow is enabled
|
|
80
|
+
*/
|
|
81
|
+
export type ScrollVisibleType = 'horizontal' | 'vertical' | 'both' | 'hidden';
|
|
76
82
|
/**
|
|
77
83
|
* Layout props to position things in the canvas
|
|
78
84
|
* @public
|
|
@@ -127,4 +133,14 @@ export interface UiTransformProps {
|
|
|
127
133
|
borderColor?: Record<keyof Partial<Position>, Color4> | Color4 | undefined;
|
|
128
134
|
borderRadius?: Partial<BorderRadius> | PositionUnit;
|
|
129
135
|
borderWidth?: Partial<Position> | PositionUnit;
|
|
136
|
+
/** The opacity property sets the opacity level for an element, it's accumulated across children @defaultValue 1 */
|
|
137
|
+
opacity?: number;
|
|
138
|
+
/** A reference value to identify the element, default empty */
|
|
139
|
+
elementId?: string;
|
|
140
|
+
/** default position=(0,0) if it aplies, a vector or a reference-id */
|
|
141
|
+
scrollPosition?: Vector2 | string;
|
|
142
|
+
/** default ShowScrollBar.SSB_BOTH */
|
|
143
|
+
scrollVisible?: ScrollVisibleType;
|
|
144
|
+
/** default 0 */
|
|
145
|
+
zIndex?: number;
|
|
130
146
|
}
|
|
@@ -241,3 +241,40 @@ const parsePointerFilter = {
|
|
|
241
241
|
none: 0 /* PointerFilterMode.PFM_NONE */,
|
|
242
242
|
block: 1 /* PointerFilterMode.PFM_BLOCK */
|
|
243
243
|
};
|
|
244
|
+
/**
|
|
245
|
+
* @internal
|
|
246
|
+
*/
|
|
247
|
+
export function getScrollPosition(scrollPosition) {
|
|
248
|
+
if (typeof scrollPosition === 'string') {
|
|
249
|
+
return {
|
|
250
|
+
scrollPosition: {
|
|
251
|
+
value: {
|
|
252
|
+
$case: 'reference',
|
|
253
|
+
reference: scrollPosition
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
return {
|
|
260
|
+
scrollPosition: {
|
|
261
|
+
value: {
|
|
262
|
+
$case: 'position',
|
|
263
|
+
position: scrollPosition
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
const parseScrollVisible = {
|
|
270
|
+
both: 0 /* ShowScrollBar.SSB_BOTH */,
|
|
271
|
+
hidden: 3 /* ShowScrollBar.SSB_HIDDEN */,
|
|
272
|
+
horizontal: 2 /* ShowScrollBar.SSB_ONLY_HORIZONTAL */,
|
|
273
|
+
vertical: 1 /* ShowScrollBar.SSB_ONLY_VERTICAL */
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* @internal
|
|
277
|
+
*/
|
|
278
|
+
export function getScrollVisible(scrollVisible) {
|
|
279
|
+
return { scrollVisible: parseScrollVisible[scrollVisible] };
|
|
280
|
+
}
|
package/dist/react-ecs.d.ts
CHANGED
|
@@ -22,6 +22,9 @@ export type EntityComponents = {
|
|
|
22
22
|
onMouseUp: Callback;
|
|
23
23
|
onMouseEnter: Callback;
|
|
24
24
|
onMouseLeave: Callback;
|
|
25
|
+
onMouseDrag: Callback;
|
|
26
|
+
onMouseDragLocked: Callback;
|
|
27
|
+
onMouseDragEnd: Callback;
|
|
25
28
|
};
|
|
26
29
|
/**
|
|
27
30
|
* @hidden
|
|
@@ -50,7 +53,7 @@ export interface ReactElement<P = any, T extends string | JSXElementConstructor<
|
|
|
50
53
|
* @public
|
|
51
54
|
*/
|
|
52
55
|
export declare namespace ReactEcs {
|
|
53
|
-
|
|
56
|
+
namespace JSX {
|
|
54
57
|
/**
|
|
55
58
|
* @public
|
|
56
59
|
*/
|
|
@@ -73,14 +76,5 @@ export declare namespace ReactEcs {
|
|
|
73
76
|
interface Component {
|
|
74
77
|
}
|
|
75
78
|
}
|
|
76
|
-
|
|
77
|
-
type SetStateAction<T> = T | ((prevState: T) => T);
|
|
78
|
-
type Dispatch<T> = (action: SetStateAction<T>) => void;
|
|
79
|
-
type StateHook = <T>(initialState: T | (() => T)) => [T, Dispatch<T>];
|
|
80
|
-
type DependencyList = ReadonlyArray<any>;
|
|
81
|
-
type EffectCallback = () => void | (() => void | undefined);
|
|
82
|
-
type EffectHook = (effect: EffectCallback, deps?: DependencyList) => void;
|
|
83
|
-
export const useEffect: EffectHook;
|
|
84
|
-
export const useState: StateHook;
|
|
85
|
-
export {};
|
|
79
|
+
const createElement: any;
|
|
86
80
|
}
|
package/dist/react-ecs.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Entity, IEngine, PointerEventsSystem } from '@dcl/ecs';
|
|
2
2
|
import { ReactEcs } from '../react-ecs';
|
|
3
|
-
export
|
|
4
|
-
update: (component: ReactEcs.JSX.ReactNode) =>
|
|
3
|
+
export interface DclReconciler {
|
|
4
|
+
update: (component: ReactEcs.JSX.ReactNode) => void;
|
|
5
5
|
getEntities: () => Entity[];
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
|
+
export declare function createReconciler(engine: Pick<IEngine, 'getComponent' | 'addEntity' | 'removeEntity' | 'defineComponentFromSchema' | 'getEntitiesWith'>, pointerEvents: PointerEventsSystem, rootEntity: Entity | undefined): DclReconciler;
|
package/dist/reconciler/index.js
CHANGED
|
@@ -8,11 +8,14 @@ function getPointerEnum(pointerKey) {
|
|
|
8
8
|
onMouseDown: 1 /* PointerEventType.PET_DOWN */,
|
|
9
9
|
onMouseUp: 0 /* PointerEventType.PET_UP */,
|
|
10
10
|
onMouseEnter: 2 /* PointerEventType.PET_HOVER_ENTER */,
|
|
11
|
-
onMouseLeave: 3 /* PointerEventType.PET_HOVER_LEAVE
|
|
11
|
+
onMouseLeave: 3 /* PointerEventType.PET_HOVER_LEAVE */,
|
|
12
|
+
onMouseDrag: 5 /* PointerEventType.PET_DRAG */,
|
|
13
|
+
onMouseDragLocked: 4 /* PointerEventType.PET_DRAG_LOCKED */,
|
|
14
|
+
onMouseDragEnd: 6 /* PointerEventType.PET_DRAG_END */
|
|
12
15
|
};
|
|
13
16
|
return pointers[pointerKey];
|
|
14
17
|
}
|
|
15
|
-
export function createReconciler(engine, pointerEvents) {
|
|
18
|
+
export function createReconciler(engine, pointerEvents, rootEntity) {
|
|
16
19
|
// Store all the entities so when we destroy the UI we can also destroy them
|
|
17
20
|
const entities = new Set();
|
|
18
21
|
// Store the onChange callbacks to be runned every time a Result has changed
|
|
@@ -26,6 +29,8 @@ export function createReconciler(engine, pointerEvents) {
|
|
|
26
29
|
const UiInputResult = components.UiInputResult(engine);
|
|
27
30
|
const UiDropdown = components.UiDropdown(engine);
|
|
28
31
|
const UiDropdownResult = components.UiDropdownResult(engine);
|
|
32
|
+
const UiScrollResult = components.UiScrollResult(engine);
|
|
33
|
+
const Transform = components.Transform(engine);
|
|
29
34
|
// Component ID Helper
|
|
30
35
|
const getComponentId = {
|
|
31
36
|
uiTransform: UiTransform.componentId,
|
|
@@ -58,6 +63,15 @@ export function createReconciler(engine, pointerEvents) {
|
|
|
58
63
|
else if (update.component === 'onMouseLeave') {
|
|
59
64
|
pointerEvents.removeOnPointerHoverLeave(instance.entity);
|
|
60
65
|
}
|
|
66
|
+
else if (update.component === 'onMouseDrag') {
|
|
67
|
+
pointerEvents.removeOnPointerDrag(instance.entity);
|
|
68
|
+
}
|
|
69
|
+
else if (update.component === 'onMouseDragLocked') {
|
|
70
|
+
pointerEvents.removeOnPointerDragLocked(instance.entity);
|
|
71
|
+
}
|
|
72
|
+
else if (update.component === 'onMouseDragEnd') {
|
|
73
|
+
pointerEvents.removeOnPointerDragEnd(instance.entity);
|
|
74
|
+
}
|
|
61
75
|
return;
|
|
62
76
|
}
|
|
63
77
|
if (update.props) {
|
|
@@ -73,7 +87,13 @@ export function createReconciler(engine, pointerEvents) {
|
|
|
73
87
|
? pointerEvents.onPointerUp
|
|
74
88
|
: update.component === 'onMouseEnter'
|
|
75
89
|
? pointerEvents.onPointerHoverEnter
|
|
76
|
-
: update.component === 'onMouseLeave'
|
|
90
|
+
: update.component === 'onMouseLeave'
|
|
91
|
+
? pointerEvents.onPointerHoverLeave
|
|
92
|
+
: update.component === 'onMouseDrag'
|
|
93
|
+
? pointerEvents.onPointerDrag
|
|
94
|
+
: update.component === 'onMouseDragLocked'
|
|
95
|
+
? pointerEvents.onPointerDragLocked
|
|
96
|
+
: update.component === 'onMouseDragEnd' && pointerEvents.onPointerDragEnd;
|
|
77
97
|
if (pointerEventSystem) {
|
|
78
98
|
pointerEventSystem({
|
|
79
99
|
entity: instance.entity,
|
|
@@ -193,6 +213,10 @@ export function createReconciler(engine, pointerEvents) {
|
|
|
193
213
|
...noopConfig,
|
|
194
214
|
createInstance(type, props) {
|
|
195
215
|
const entity = engine.addEntity();
|
|
216
|
+
// set root
|
|
217
|
+
if (rootEntity !== undefined) {
|
|
218
|
+
Transform.createOrReplace(entity, { parent: rootEntity });
|
|
219
|
+
}
|
|
196
220
|
entities.add(entity);
|
|
197
221
|
const instance = {
|
|
198
222
|
entity,
|
package/dist/reconciler/utils.js
CHANGED
package/dist/system.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IEngine, PointerEventsSystem } from '@dcl/ecs';
|
|
1
|
+
import type { Entity, IEngine, PointerEventsSystem } from '@dcl/ecs';
|
|
2
2
|
import type { ReactEcs } from './react-ecs';
|
|
3
3
|
/**
|
|
4
4
|
* @public
|
|
@@ -10,6 +10,7 @@ export type UiComponent = () => ReactEcs.JSX.ReactNode;
|
|
|
10
10
|
export interface ReactBasedUiSystem {
|
|
11
11
|
destroy(): void;
|
|
12
12
|
setUiRenderer(ui: UiComponent): void;
|
|
13
|
+
setTextureRenderer(entity: Entity, ui: UiComponent): void;
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
16
|
* @public
|
package/dist/system.js
CHANGED
|
@@ -3,11 +3,15 @@ import { createReconciler } from './reconciler';
|
|
|
3
3
|
* @public
|
|
4
4
|
*/
|
|
5
5
|
export function createReactBasedUiSystem(engine, pointerSystem) {
|
|
6
|
-
const renderer = createReconciler(engine, pointerSystem);
|
|
6
|
+
const renderer = createReconciler(engine, pointerSystem, undefined);
|
|
7
7
|
let uiComponent = undefined;
|
|
8
|
+
const textureRenderersAndUis = [];
|
|
8
9
|
function ReactBasedUiSystem() {
|
|
9
10
|
if (uiComponent)
|
|
10
11
|
renderer.update(uiComponent());
|
|
12
|
+
for (const [textureRenderer, ui] of textureRenderersAndUis) {
|
|
13
|
+
textureRenderer.update(ui());
|
|
14
|
+
}
|
|
11
15
|
}
|
|
12
16
|
engine.addSystem(ReactBasedUiSystem, 100e3, '@dcl/react-ecs');
|
|
13
17
|
return {
|
|
@@ -16,9 +20,20 @@ export function createReactBasedUiSystem(engine, pointerSystem) {
|
|
|
16
20
|
for (const entity of renderer.getEntities()) {
|
|
17
21
|
engine.removeEntity(entity);
|
|
18
22
|
}
|
|
23
|
+
for (const [textureRenderer, _] of textureRenderersAndUis) {
|
|
24
|
+
for (const entity of textureRenderer.getEntities()) {
|
|
25
|
+
engine.removeEntity(entity);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
for (const entity of renderer.getEntities()) {
|
|
29
|
+
engine.removeEntity(entity);
|
|
30
|
+
}
|
|
19
31
|
},
|
|
20
32
|
setUiRenderer(ui) {
|
|
21
33
|
uiComponent = ui;
|
|
34
|
+
},
|
|
35
|
+
setTextureRenderer(entity, ui) {
|
|
36
|
+
textureRenderersAndUis.push([createReconciler(engine, pointerSystem, entity), ui]);
|
|
22
37
|
}
|
|
23
38
|
};
|
|
24
39
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcl/react-ecs",
|
|
3
3
|
"description": "Decentraland ECS",
|
|
4
|
-
"version": "7.8.
|
|
4
|
+
"version": "7.8.6-14664638926.commit-7bb4ee2",
|
|
5
5
|
"author": "DCL",
|
|
6
6
|
"bugs": "https://github.com/decentraland/js-sdk-toolchain/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@dcl/ecs": "7.8.
|
|
8
|
+
"@dcl/ecs": "7.8.6-14664638926.commit-7bb4ee2",
|
|
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": "7bb4ee209754501774c77a7531e049744eb7f4ca"
|
|
44
44
|
}
|