@dcl/react-ecs 7.5.3-9489898545.commit-df2f989 → 7.5.4-9583175884.commit-4a0210f

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.
@@ -1,5 +1,5 @@
1
1
  import { ReactEcs } from '../../react-ecs';
2
- import { getFont, getFontSize, getTextAlign } from '../Label/utils';
2
+ import { getFont, getFontSize, getTextAlign, getTextWrap } from '../Label/utils';
3
3
  import { parseUiBackground } from '../uiBackground';
4
4
  import { parseUiTransform } from '../uiTransform';
5
5
  function getButtonProps(props) {
@@ -35,13 +35,14 @@ export function Button(props) {
35
35
  ...buttonProps.uiBackground,
36
36
  ...uiBackground
37
37
  });
38
- const { font, textAlign, fontSize, ...uiTexProps } = otherProps;
38
+ const { font, textAlign, fontSize, textWrap, ...uiTexProps } = otherProps;
39
39
  const textProps = {
40
40
  ...buttonProps.uiText,
41
41
  ...uiTexProps,
42
42
  ...getFont(font),
43
43
  ...getTextAlign(textAlign),
44
- ...getFontSize(fontSize)
44
+ ...getFontSize(fontSize),
45
+ ...getTextWrap(textWrap)
45
46
  };
46
47
  const uiTransformProps = parseUiTransform({
47
48
  height: 36,
@@ -1,6 +1,6 @@
1
1
  import { parseProps } from '../utils';
2
2
  import { ReactEcs } from '../../react-ecs';
3
- import { getFont, getFontSize, getTextAlign } from './utils';
3
+ import { getFont, getFontSize, getTextAlign, getTextWrap } from './utils';
4
4
  export { scaleFontSize } from './utils';
5
5
  /**
6
6
  *
@@ -23,12 +23,13 @@ export function Label(props) {
23
23
  onMouseDown,
24
24
  onMouseUp
25
25
  });
26
- const { font, textAlign, fontSize, ...textProps } = uiTextProps;
26
+ const { font, textAlign, fontSize, textWrap, ...textProps } = uiTextProps;
27
27
  const uiText = {
28
28
  ...textProps,
29
29
  ...getFont(font),
30
30
  ...getTextAlign(textAlign),
31
- ...getFontSize(fontSize)
31
+ ...getFontSize(fontSize),
32
+ ...getTextWrap(textWrap)
32
33
  };
33
34
  return ReactEcs.createElement("entity", { ...commonProps, uiText: uiText });
34
35
  }
@@ -15,11 +15,17 @@ export interface UiLabelProps {
15
15
  textAlign?: TextAlignType | undefined;
16
16
  /** Label font type. @defaultValue 'sans-serif' */
17
17
  font?: UiFontType | undefined;
18
+ /** Behaviour when text reached. @defaultValue 'wrap' */
19
+ textWrap?: UiTextWrapType | undefined;
18
20
  }
19
21
  /**
20
22
  * @public
21
23
  */
22
24
  export type UiFontType = 'sans-serif' | 'serif' | 'monospace';
25
+ /**
26
+ * @public
27
+ */
28
+ export type UiTextWrapType = 'wrap' | 'nowrap';
23
29
  /**
24
30
  * @public
25
31
  */
@@ -55,3 +55,15 @@ export function scaleFontSize(fontSize, scaleUnit = 0.39, ctx = getScaleCtx()) {
55
55
  return fontSize;
56
56
  return fontSize + calcOnViewport(scaleUnit, ctx);
57
57
  }
58
+ const parseTextWrap = {
59
+ wrap: 0 /* TextWrap.TW_WRAP */,
60
+ nowrap: 1 /* TextWrap.TW_NO_WRAP */
61
+ };
62
+ /**
63
+ * @internal
64
+ */
65
+ export function getTextWrap(textWrap) {
66
+ if (!textWrap)
67
+ return undefined;
68
+ return { textWrap: parseTextWrap[textWrap] };
69
+ }
@@ -1,5 +1,5 @@
1
1
  import { ReactEcs } from '../react-ecs';
2
- import { getFont, getFontSize, getTextAlign } from './Label/utils';
2
+ import { getFont, getFontSize, getTextAlign, getTextWrap } from './Label/utils';
3
3
  import { parseProps } from './utils';
4
4
  export * from './types';
5
5
  export * from './uiTransform/types';
@@ -24,7 +24,8 @@ export function UiEntity(props) {
24
24
  ...props.uiText,
25
25
  ...getFont(props.uiText.font),
26
26
  ...getTextAlign(props.uiText.textAlign),
27
- ...getFontSize(props.uiText.fontSize)
27
+ ...getFontSize(props.uiText.fontSize),
28
+ ...getTextWrap(props.uiText.textWrap)
28
29
  }
29
30
  };
30
31
  return ReactEcs.createElement("entity", { ...parseProps(props), ...uiText });
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@dcl/react-ecs",
3
3
  "description": "Decentraland ECS",
4
- "version": "7.5.3-9489898545.commit-df2f989",
4
+ "version": "7.5.4-9583175884.commit-4a0210f",
5
5
  "author": "DCL",
6
6
  "bugs": "https://github.com/decentraland/js-sdk-toolchain/issues",
7
7
  "dependencies": {
8
- "@dcl/ecs": "7.5.3-9489898545.commit-df2f989",
8
+ "@dcl/ecs": "7.5.4-9583175884.commit-4a0210f",
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": "df2f989c1b9c05a767dc1de628ab1318f4cdadec"
43
+ "commit": "4a0210f3621fb67a74dd10a2576bee25f30b3c73"
44
44
  }