@dcl/react-ecs 7.7.10-14035313559.commit-093b171 → 7.8.0
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,4 +1,4 @@
|
|
|
1
|
-
import { getAlign, getDisplay, getFlexDirection, getFlexWrap, getJustify, getOverflow, getPointerFilter, getPositionType, parsePosition, parseSize } from './utils';
|
|
1
|
+
import { getAlign, getDisplay, getFlexDirection, getFlexWrap, getJustify, getOverflow, getPointerFilter, getPositionType, parseBorderColor, parseBorderRadius, parseBorderWidth, parsePosition, parseSize } from './utils';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
@@ -58,7 +58,7 @@ const defaultUiTransform = {
|
|
|
58
58
|
*/
|
|
59
59
|
/* @__PURE__ */
|
|
60
60
|
export function parseUiTransform(props = {}) {
|
|
61
|
-
const { height, minHeight, maxHeight, width, minWidth, maxWidth, alignItems, alignContent, flexWrap, ...otherProps } = props;
|
|
61
|
+
const { height, minHeight, maxHeight, width, minWidth, maxWidth, alignItems, alignContent, flexWrap, borderRadius, borderWidth, borderColor, ...otherProps } = props;
|
|
62
62
|
return {
|
|
63
63
|
...defaultUiTransform,
|
|
64
64
|
...otherProps,
|
|
@@ -81,6 +81,9 @@ export function parseUiTransform(props = {}) {
|
|
|
81
81
|
// Optional values
|
|
82
82
|
...(alignContent && getAlign('alignContent', alignContent)),
|
|
83
83
|
...(alignItems && getAlign('alignItems', alignItems)),
|
|
84
|
-
...(flexWrap && getFlexWrap(flexWrap))
|
|
84
|
+
...(flexWrap && getFlexWrap(flexWrap)),
|
|
85
|
+
...(borderRadius && parseBorderRadius(borderRadius)),
|
|
86
|
+
...(borderWidth && parseBorderWidth(borderWidth)),
|
|
87
|
+
...(borderColor && parseBorderColor(borderColor))
|
|
85
88
|
};
|
|
86
89
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Color4 } from '@dcl/ecs/dist/components/generated/pb/decentraland/common/colors.gen';
|
|
1
2
|
import { ScaleUnit } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* unit value specified. i.e. 1 || '100%' || '1px' || '10vw'
|
|
@@ -27,6 +28,16 @@ export interface Position {
|
|
|
27
28
|
bottom: PositionUnit;
|
|
28
29
|
left: PositionUnit;
|
|
29
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Type used for defining the border radius of the element
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
export interface BorderRadius {
|
|
36
|
+
topLeft: PositionUnit;
|
|
37
|
+
topRight: PositionUnit;
|
|
38
|
+
bottomLeft: PositionUnit;
|
|
39
|
+
bottomRight: PositionUnit;
|
|
40
|
+
}
|
|
30
41
|
/**
|
|
31
42
|
* @public
|
|
32
43
|
*/
|
|
@@ -113,4 +124,7 @@ export interface UiTransformProps {
|
|
|
113
124
|
overflow?: OverflowType;
|
|
114
125
|
/** 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) **/
|
|
115
126
|
pointerFilter?: PointerFilterType;
|
|
127
|
+
borderColor?: Record<keyof Partial<Position>, Color4> | Color4 | undefined;
|
|
128
|
+
borderRadius?: Partial<BorderRadius> | PositionUnit;
|
|
129
|
+
borderWidth?: Partial<Position> | PositionUnit;
|
|
116
130
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { YGUnit } from '@dcl/ecs';
|
|
2
|
-
import { Position, PositionUnit, PositionShorthand } from './types';
|
|
3
|
-
|
|
2
|
+
import { Position, PositionUnit, PositionShorthand, BorderRadius, UiTransformProps } from './types';
|
|
3
|
+
import { Color4 } from '@dcl/ecs/dist/components/generated/pb/decentraland/common/colors.gen';
|
|
4
|
+
type PropName = 'position' | 'margin' | 'padding' | 'borderWidth';
|
|
4
5
|
type PropKey = `${PropName}${Capitalize<keyof Position>}`;
|
|
5
6
|
type PropKeyUnit = `${PropName}${Capitalize<keyof Position>}Unit`;
|
|
6
7
|
type PositionParsed = {
|
|
@@ -8,6 +9,26 @@ type PositionParsed = {
|
|
|
8
9
|
} & {
|
|
9
10
|
[key in PropKeyUnit]?: YGUnit;
|
|
10
11
|
};
|
|
12
|
+
type BorderProp = `border${Capitalize<keyof BorderRadius>}Radius`;
|
|
13
|
+
type BorderPropUnit = `${BorderProp}Unit`;
|
|
14
|
+
type BorderProps = {
|
|
15
|
+
[key in BorderProp]?: number;
|
|
16
|
+
} & {
|
|
17
|
+
[key in BorderPropUnit]?: YGUnit;
|
|
18
|
+
};
|
|
19
|
+
export declare function parseBorderRadius(radius: Partial<BorderRadius> | PositionUnit): BorderProps | undefined;
|
|
20
|
+
type BorderKey = Record<keyof Position, number>;
|
|
21
|
+
type BorderWidthProp = `border${Capitalize<keyof BorderKey>}Width`;
|
|
22
|
+
type BorderWidthPropUnit = `${BorderWidthProp}Unit`;
|
|
23
|
+
type BorderWidthProps = {
|
|
24
|
+
[key in BorderWidthProp]?: number;
|
|
25
|
+
} & {
|
|
26
|
+
[key in BorderWidthPropUnit]?: YGUnit;
|
|
27
|
+
};
|
|
28
|
+
export declare function parseBorderWidth(borderWidth: Partial<Position> | PositionUnit): BorderWidthProps | undefined;
|
|
29
|
+
type BorderColor = Record<keyof Position, Color4>;
|
|
30
|
+
type BorderColorKey = `border${Capitalize<keyof BorderColor>}Color`;
|
|
31
|
+
export declare function parseBorderColor(borderColor: UiTransformProps['borderColor']): Record<BorderColorKey, Color4> | undefined;
|
|
11
32
|
export declare function parsePosition<T extends PropName>(position: PositionShorthand | Partial<Position> | undefined, prop: T): Partial<PositionParsed>;
|
|
12
33
|
type HeightWidth = 'height' | 'width';
|
|
13
34
|
type SizePropName = HeightWidth | `max${Capitalize<HeightWidth>}` | `min${Capitalize<HeightWidth>}`;
|
|
@@ -38,6 +38,63 @@ function parsePositionUnit(val) {
|
|
|
38
38
|
}
|
|
39
39
|
return [undefined, 0 /* YGUnit.YGU_UNDEFINED */];
|
|
40
40
|
}
|
|
41
|
+
export function parseBorderRadius(radius) {
|
|
42
|
+
if (typeof radius === 'object') {
|
|
43
|
+
const obj = {};
|
|
44
|
+
for (const key in radius) {
|
|
45
|
+
const typedKey = key;
|
|
46
|
+
const propKey = `border${capitalize(typedKey)}Radius`;
|
|
47
|
+
const propKeyUnit = `${propKey}Unit`;
|
|
48
|
+
const [value, unit] = parsePositionUnit(radius[typedKey]);
|
|
49
|
+
if (value === undefined)
|
|
50
|
+
continue;
|
|
51
|
+
obj[propKeyUnit] = unit;
|
|
52
|
+
obj[propKey] = value;
|
|
53
|
+
}
|
|
54
|
+
return obj;
|
|
55
|
+
}
|
|
56
|
+
if (typeof radius === 'number') {
|
|
57
|
+
return parseBorderRadius({ topLeft: radius, topRight: radius, bottomLeft: radius, bottomRight: radius });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export function parseBorderWidth(borderWidth) {
|
|
61
|
+
if (typeof borderWidth === 'object') {
|
|
62
|
+
const obj = {};
|
|
63
|
+
for (const key in borderWidth) {
|
|
64
|
+
const typedKey = key;
|
|
65
|
+
const propKey = `border${capitalize(typedKey)}Width`;
|
|
66
|
+
const propKeyUnit = `${propKey}Unit`;
|
|
67
|
+
const [value, unit] = parsePositionUnit(borderWidth[typedKey]);
|
|
68
|
+
if (value === undefined)
|
|
69
|
+
continue;
|
|
70
|
+
obj[propKeyUnit] = unit;
|
|
71
|
+
obj[propKey] = value;
|
|
72
|
+
}
|
|
73
|
+
return obj;
|
|
74
|
+
}
|
|
75
|
+
if (typeof borderWidth === 'number') {
|
|
76
|
+
return parseBorderWidth({ top: borderWidth, left: borderWidth, right: borderWidth, bottom: borderWidth });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const isColor = (v) => {
|
|
80
|
+
if (v.b !== undefined)
|
|
81
|
+
return true;
|
|
82
|
+
return false;
|
|
83
|
+
};
|
|
84
|
+
export function parseBorderColor(borderColor) {
|
|
85
|
+
if (isColor(borderColor)) {
|
|
86
|
+
return parseBorderColor({ top: borderColor, left: borderColor, right: borderColor, bottom: borderColor });
|
|
87
|
+
}
|
|
88
|
+
if (typeof borderColor === 'object') {
|
|
89
|
+
const obj = {};
|
|
90
|
+
for (const key in borderColor) {
|
|
91
|
+
const typedKey = key;
|
|
92
|
+
const propKey = `border${capitalize(typedKey)}Color`;
|
|
93
|
+
obj[propKey] = borderColor[typedKey];
|
|
94
|
+
}
|
|
95
|
+
return obj;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
41
98
|
export function parsePosition(position = {}, prop) {
|
|
42
99
|
if (typeof position === 'object') {
|
|
43
100
|
const obj = {};
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcl/react-ecs",
|
|
3
3
|
"description": "Decentraland ECS",
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.8.0",
|
|
5
5
|
"author": "DCL",
|
|
6
6
|
"bugs": "https://github.com/decentraland/js-sdk-toolchain/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@dcl/ecs": "7.
|
|
8
|
+
"@dcl/ecs": "7.8.0",
|
|
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": "8d32240be828682a0e97b38c9e8a298d51eb5dcd"
|
|
44
44
|
}
|