@dcl/react-ecs 7.6.7 → 7.6.8-12354882097.commit-0c727b8

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.
@@ -29,7 +29,7 @@ function getButtonProps(props) {
29
29
  */
30
30
  /* @__PURE__ */
31
31
  export function Button(props) {
32
- const { uiTransform, uiBackground, onMouseDown, onMouseUp, ...otherProps } = props;
32
+ const { uiTransform, uiBackground, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, ...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, 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, uiTransform: uiTransformProps, uiText: textProps, uiBackground: uiBackgroundProps }));
58
58
  }
@@ -34,13 +34,15 @@ function parseUiDropdown(props) {
34
34
  */
35
35
  /* @__PURE__ */
36
36
  export function Dropdown(props) {
37
- const { uiTransform, uiBackground, onMouseDown, onMouseUp, ...otherProps } = props;
37
+ const { uiTransform, uiBackground, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, ...otherProps } = props;
38
38
  const dropdownProps = parseUiDropdown(otherProps);
39
39
  const commonProps = parseProps({
40
40
  uiTransform,
41
41
  uiBackground,
42
42
  onMouseDown,
43
- onMouseUp
43
+ onMouseUp,
44
+ onMouseEnter,
45
+ onMouseLeave
44
46
  });
45
47
  return ReactEcs.createElement("entity", { ...commonProps, uiDropdown: dropdownProps });
46
48
  }
@@ -35,13 +35,15 @@ function parseUiInput(props) {
35
35
  * @category Component
36
36
  */ /* @__PURE__ */
37
37
  export function Input(props) {
38
- const { uiTransform, uiBackground, onMouseDown, onMouseUp, ...otherProps } = props;
38
+ const { uiTransform, uiBackground, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, ...otherProps } = props;
39
39
  const inputProps = parseUiInput(otherProps);
40
40
  const commonProps = parseProps({
41
41
  uiTransform,
42
42
  uiBackground,
43
43
  onMouseDown,
44
- onMouseUp
44
+ onMouseUp,
45
+ onMouseEnter,
46
+ onMouseLeave
45
47
  });
46
48
  return ReactEcs.createElement("entity", { ...commonProps, uiInput: inputProps });
47
49
  }
@@ -16,12 +16,14 @@ export { scaleFontSize } from './utils';
16
16
  */
17
17
  /* @__PURE__ */
18
18
  export function Label(props) {
19
- const { uiTransform, uiBackground, onMouseDown, onMouseUp, ...uiTextProps } = props;
19
+ const { uiTransform, uiBackground, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, ...uiTextProps } = props;
20
20
  const commonProps = parseProps({
21
21
  uiTransform,
22
22
  uiBackground,
23
23
  onMouseDown,
24
- onMouseUp
24
+ onMouseUp,
25
+ onMouseEnter,
26
+ onMouseLeave
25
27
  });
26
28
  const { font, textAlign, fontSize, textWrap, ...textProps } = uiTextProps;
27
29
  const uiText = {
@@ -12,4 +12,8 @@ export type Listeners = {
12
12
  onMouseDown?: Callback;
13
13
  /** triggered on mouse up event */
14
14
  onMouseUp?: Callback;
15
+ /** triggered on mouse hover event */
16
+ onMouseEnter?: Callback;
17
+ /** triggered on mouse leave event */
18
+ onMouseLeave?: Callback;
15
19
  };
@@ -1,6 +1,8 @@
1
1
  const listeners = {
2
2
  onMouseDown: undefined,
3
- onMouseUp: undefined
3
+ onMouseUp: undefined,
4
+ onMouseEnter: undefined,
5
+ onMouseLeave: undefined
4
6
  };
5
7
  const listenersKey = Object.keys(listeners);
6
8
  /**
@@ -20,6 +20,8 @@ export type EntityComponents = {
20
20
  uiDropdown: PBUiDropdown;
21
21
  onMouseDown: Callback;
22
22
  onMouseUp: Callback;
23
+ onMouseEnter: Callback;
24
+ onMouseLeave: Callback;
23
25
  };
24
26
  /**
25
27
  * @hidden
@@ -6,7 +6,9 @@ import { componentKeys, isNotUndefined, noopConfig, propsChanged } from './utils
6
6
  function getPointerEnum(pointerKey) {
7
7
  const pointers = {
8
8
  onMouseDown: 1 /* PointerEventType.PET_DOWN */,
9
- onMouseUp: 0 /* PointerEventType.PET_UP */
9
+ onMouseUp: 0 /* PointerEventType.PET_UP */,
10
+ onMouseEnter: 2 /* PointerEventType.PET_HOVER_ENTER */,
11
+ onMouseLeave: 3 /* PointerEventType.PET_HOVER_LEAVE */
10
12
  };
11
13
  return pointers[pointerKey];
12
14
  }
@@ -50,6 +52,12 @@ export function createReconciler(engine, pointerEvents) {
50
52
  else if (update.component === 'onMouseUp') {
51
53
  pointerEvents.removeOnPointerUp(instance.entity);
52
54
  }
55
+ else if (update.component === 'onMouseEnter') {
56
+ pointerEvents.removeOnPointerHoverEnter(instance.entity);
57
+ }
58
+ else if (update.component === 'onMouseLeave') {
59
+ pointerEvents.removeOnPointerHoverLeave(instance.entity);
60
+ }
53
61
  return;
54
62
  }
55
63
  if (update.props) {
@@ -59,13 +67,24 @@ export function createReconciler(engine, pointerEvents) {
59
67
  entityEvent.set(pointerEvent, update.props);
60
68
  if (alreadyHasPointerEvent)
61
69
  return;
62
- const pointerEventSystem = update.component === 'onMouseDown' ? pointerEvents.onPointerDown : pointerEvents.onPointerUp;
63
- pointerEventSystem(instance.entity, () => pointerEventCallback(instance.entity, pointerEvent), {
64
- button: 0 /* InputAction.IA_POINTER */,
65
- // We add this showFeedBack so the pointerEventSystem creates a PointerEvent component with our entity
66
- // This is needed for the renderer to know which entities are clickeables
67
- showFeedback: true
68
- });
70
+ const pointerEventSystem = update.component === 'onMouseDown'
71
+ ? pointerEvents.onPointerDown
72
+ : update.component === 'onMouseUp'
73
+ ? pointerEvents.onPointerUp
74
+ : update.component === 'onMouseEnter'
75
+ ? pointerEvents.onPointerHoverEnter
76
+ : update.component === 'onMouseLeave' && pointerEvents.onPointerHoverLeave;
77
+ if (pointerEventSystem) {
78
+ pointerEventSystem({
79
+ entity: instance.entity,
80
+ opts: {
81
+ button: 0 /* InputAction.IA_POINTER */,
82
+ // We add this showFeedBack so the pointerEventSystem creates a PointerEvent component with our entity
83
+ // This is needed for the renderer to know which entities are clickeables
84
+ showFeedback: true
85
+ }
86
+ }, () => pointerEventCallback(instance.entity, pointerEvent));
87
+ }
69
88
  }
70
89
  }
71
90
  function removeComponent(instance, component) {
@@ -33,6 +33,8 @@ const entityComponent = {
33
33
  uiTransform: undefined,
34
34
  onMouseDown: undefined,
35
35
  onMouseUp: undefined,
36
+ onMouseEnter: undefined,
37
+ onMouseLeave: undefined,
36
38
  uiInput: undefined,
37
39
  uiDropdown: undefined
38
40
  };
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@dcl/react-ecs",
3
3
  "description": "Decentraland ECS",
4
- "version": "7.6.7",
4
+ "version": "7.6.8-12354882097.commit-0c727b8",
5
5
  "author": "DCL",
6
6
  "bugs": "https://github.com/decentraland/js-sdk-toolchain/issues",
7
7
  "dependencies": {
8
- "@dcl/ecs": "7.6.7",
8
+ "@dcl/ecs": "7.6.8-12354882097.commit-0c727b8",
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": "085da37eac19a1ee4794076a6acf221cf8b796fe"
43
+ "commit": "0c727b82d18c849bc14e34108ef9ce7e3531ca64"
44
44
  }