@applicaster/zapp-react-native-ui-components 12.0.0-alpha.5061452310 → 12.0.0-alpha.5085420612
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.
|
@@ -7,50 +7,24 @@ type BorderPosition = "inside" | "outside" | "center";
|
|
|
7
7
|
interface Props {
|
|
8
8
|
style: ImageStyle | ViewStyle;
|
|
9
9
|
borderPosition: BorderPosition;
|
|
10
|
+
borderPaddingTop: number;
|
|
11
|
+
borderPaddingRight: number;
|
|
12
|
+
borderPaddingBottom: number;
|
|
13
|
+
borderPaddingLeft: number;
|
|
10
14
|
children: React.ReactNode;
|
|
11
15
|
}
|
|
12
16
|
|
|
13
|
-
const
|
|
14
|
-
"marginTop",
|
|
15
|
-
"marginBottom",
|
|
16
|
-
"marginLeft",
|
|
17
|
-
"marginRight",
|
|
18
|
-
] as const;
|
|
17
|
+
const COLOR_TRANSPARENT = "transparent";
|
|
19
18
|
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
const styles = StyleSheet.create({
|
|
20
|
+
container: {
|
|
21
|
+
overflow: "visible",
|
|
22
|
+
borderWidth: 0,
|
|
23
|
+
borderColor: COLOR_TRANSPARENT,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
26
|
|
|
27
|
-
const
|
|
28
|
-
if (typeof value === "string" && value.endsWith("%")) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return false;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const calculateContainerSpacing = ({
|
|
36
|
-
spacingKey,
|
|
37
|
-
style,
|
|
38
|
-
additionalSpacing,
|
|
39
|
-
}: {
|
|
40
|
-
spacingKey: typeof MARGINS[number] | typeof PADDINGS[number];
|
|
41
|
-
style: ImageStyle | ViewStyle;
|
|
42
|
-
additionalSpacing: number;
|
|
43
|
-
}) => {
|
|
44
|
-
return {
|
|
45
|
-
[spacingKey]:
|
|
46
|
-
toNumberWithDefaultZero(style[spacingKey]) + additionalSpacing,
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const getContainerBorderWidth = (
|
|
51
|
-
borderPosition: BorderPosition,
|
|
52
|
-
borderWidth
|
|
53
|
-
) => {
|
|
27
|
+
const getBorderPadding = (borderPosition: BorderPosition, borderWidth) => {
|
|
54
28
|
switch (borderPosition) {
|
|
55
29
|
case "inside":
|
|
56
30
|
return 0;
|
|
@@ -63,19 +37,6 @@ const getContainerBorderWidth = (
|
|
|
63
37
|
}
|
|
64
38
|
};
|
|
65
39
|
|
|
66
|
-
const getContainerPadding = (borderPosition: BorderPosition, borderWidth) => {
|
|
67
|
-
switch (borderPosition) {
|
|
68
|
-
case "inside":
|
|
69
|
-
return borderWidth;
|
|
70
|
-
case "center":
|
|
71
|
-
return borderWidth / 2;
|
|
72
|
-
case "outside":
|
|
73
|
-
return 0;
|
|
74
|
-
default:
|
|
75
|
-
return 0;
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
|
|
79
40
|
const InsideBorder = ({
|
|
80
41
|
style,
|
|
81
42
|
borderPosition,
|
|
@@ -83,82 +44,93 @@ const InsideBorder = ({
|
|
|
83
44
|
style: ViewStyle;
|
|
84
45
|
borderPosition: BorderPosition;
|
|
85
46
|
}) => {
|
|
86
|
-
if (borderPosition
|
|
47
|
+
if (!borderPosition) {
|
|
87
48
|
return null;
|
|
88
49
|
}
|
|
89
50
|
|
|
90
|
-
const
|
|
91
|
-
|
|
51
|
+
const borderWidth = toNumberWithDefaultZero(style.borderWidth);
|
|
52
|
+
const containerPadding = getBorderPadding(borderPosition, borderWidth);
|
|
53
|
+
|
|
54
|
+
const initialBorderRadius = toNumberWithDefaultZero(style.borderRadius);
|
|
55
|
+
const paddingTop = toNumberWithDefaultZero(style.paddingTop);
|
|
56
|
+
const paddingRight = toNumberWithDefaultZero(style.paddingRight);
|
|
57
|
+
const paddingBottom = toNumberWithDefaultZero(style.paddingBottom);
|
|
58
|
+
const paddingLeft = toNumberWithDefaultZero(style.paddingLeft);
|
|
59
|
+
|
|
60
|
+
const borderRadiusStyle = initialBorderRadius
|
|
61
|
+
? {
|
|
62
|
+
borderTopLeftRadius:
|
|
63
|
+
initialBorderRadius +
|
|
64
|
+
containerPadding +
|
|
65
|
+
Math.min(paddingTop, paddingLeft),
|
|
66
|
+
borderTopRightRadius:
|
|
67
|
+
initialBorderRadius +
|
|
68
|
+
containerPadding +
|
|
69
|
+
Math.min(paddingTop, paddingRight),
|
|
70
|
+
borderBottomLeftRadius:
|
|
71
|
+
initialBorderRadius +
|
|
72
|
+
containerPadding +
|
|
73
|
+
Math.min(paddingBottom, paddingLeft),
|
|
74
|
+
borderBottomRightRadius:
|
|
75
|
+
initialBorderRadius +
|
|
76
|
+
containerPadding +
|
|
77
|
+
Math.min(paddingBottom, paddingRight),
|
|
78
|
+
}
|
|
79
|
+
: {
|
|
80
|
+
borderTopLeftRadius: 0,
|
|
81
|
+
borderTopRightRadius: 0,
|
|
82
|
+
borderBottomLeftRadius: 0,
|
|
83
|
+
borderBottomRightRadius: 0,
|
|
84
|
+
};
|
|
92
85
|
|
|
93
86
|
return (
|
|
94
87
|
<View
|
|
95
88
|
style={{
|
|
96
89
|
...StyleSheet.absoluteFillObject,
|
|
97
|
-
|
|
90
|
+
right: -containerPadding - paddingRight,
|
|
91
|
+
bottom: -containerPadding - paddingBottom,
|
|
92
|
+
left: -containerPadding - paddingLeft,
|
|
93
|
+
top: -containerPadding - paddingTop,
|
|
94
|
+
borderWidth,
|
|
98
95
|
borderColor: style.borderColor,
|
|
99
|
-
|
|
96
|
+
...borderRadiusStyle,
|
|
100
97
|
}}
|
|
101
98
|
/>
|
|
102
99
|
);
|
|
103
100
|
};
|
|
104
101
|
|
|
105
102
|
export const BorderContainerView = (props: Props) => {
|
|
106
|
-
const {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
103
|
+
const {
|
|
104
|
+
borderPosition,
|
|
105
|
+
borderPaddingTop,
|
|
106
|
+
borderPaddingRight,
|
|
107
|
+
borderPaddingBottom,
|
|
108
|
+
borderPaddingLeft,
|
|
109
|
+
style,
|
|
110
|
+
children,
|
|
111
|
+
} = props;
|
|
112
112
|
|
|
113
113
|
const borderStyleForMissingBorder =
|
|
114
114
|
style?.borderWidth === 0 || !style?.borderColor ? { borderRadius: 0 } : {};
|
|
115
115
|
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const updatedPaddings = PADDINGS.reduce((acc, padding) => {
|
|
127
|
-
const paddingValue = calculateContainerSpacing({
|
|
128
|
-
spacingKey: padding,
|
|
129
|
-
style,
|
|
130
|
-
additionalSpacing: spacing,
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
return { ...acc, ...paddingValue };
|
|
134
|
-
}, {});
|
|
135
|
-
|
|
136
|
-
const updatedWidth = style.width
|
|
137
|
-
? isPercentageValue(style.width)
|
|
138
|
-
? style.width
|
|
139
|
-
: toNumberWithDefaultZero(style.width) - spacing * 2
|
|
140
|
-
: undefined;
|
|
141
|
-
|
|
142
|
-
const updatedHeight = style.height
|
|
143
|
-
? isPercentageValue(style.height)
|
|
144
|
-
? style.height
|
|
145
|
-
: toNumberWithDefaultZero(style.height) - spacing * 2
|
|
146
|
-
: undefined;
|
|
147
|
-
|
|
148
|
-
const containerStyle = {
|
|
149
|
-
borderWidth: getContainerBorderWidth(borderPosition, borderWidth),
|
|
150
|
-
padding: spacing,
|
|
151
|
-
...updatedMargins,
|
|
152
|
-
...updatedPaddings,
|
|
153
|
-
width: updatedWidth,
|
|
154
|
-
height: updatedHeight,
|
|
155
|
-
};
|
|
116
|
+
const padding =
|
|
117
|
+
borderPosition === "outside"
|
|
118
|
+
? {
|
|
119
|
+
paddingTop: borderPaddingTop,
|
|
120
|
+
paddingRight: borderPaddingRight,
|
|
121
|
+
paddingBottom: borderPaddingBottom,
|
|
122
|
+
paddingLeft: borderPaddingLeft,
|
|
123
|
+
}
|
|
124
|
+
: {};
|
|
156
125
|
|
|
157
126
|
return (
|
|
158
|
-
<View
|
|
127
|
+
<View
|
|
128
|
+
{...props}
|
|
129
|
+
style={[style, styles.container, borderStyleForMissingBorder]}
|
|
130
|
+
>
|
|
159
131
|
{children}
|
|
160
132
|
<InsideBorder
|
|
161
|
-
style={{ ...style, ...
|
|
133
|
+
style={{ ...style, ...padding }}
|
|
162
134
|
borderPosition={borderPosition}
|
|
163
135
|
/>
|
|
164
136
|
</View>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "12.0.0-alpha.
|
|
3
|
+
"version": "12.0.0-alpha.5085420612",
|
|
4
4
|
"description": "Applicaster Zapp React Native ui components for the Quick Brick App",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"redux-mock-store": "^1.5.3"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@applicaster/applicaster-types": "12.0.0-alpha.
|
|
38
|
-
"@applicaster/zapp-react-native-bridge": "12.0.0-alpha.
|
|
39
|
-
"@applicaster/zapp-react-native-redux": "12.0.0-alpha.
|
|
40
|
-
"@applicaster/zapp-react-native-utils": "12.0.0-alpha.
|
|
37
|
+
"@applicaster/applicaster-types": "12.0.0-alpha.5085420612",
|
|
38
|
+
"@applicaster/zapp-react-native-bridge": "12.0.0-alpha.5085420612",
|
|
39
|
+
"@applicaster/zapp-react-native-redux": "12.0.0-alpha.5085420612",
|
|
40
|
+
"@applicaster/zapp-react-native-utils": "12.0.0-alpha.5085420612",
|
|
41
41
|
"promise": "^8.3.0",
|
|
42
42
|
"react-router-native": "^5.1.2",
|
|
43
43
|
"url": "^0.11.0",
|