@applicaster/zapp-react-native-ui-components 16.0.0-alpha.1042942411 → 16.0.0-alpha.1052711356
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/Components/MasterCell/DefaultComponents/ActionButton.tsx +59 -27
- package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +46 -217
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +109 -46
- package/Components/MasterCell/DefaultComponents/Button.tsx +43 -50
- package/Components/MasterCell/DefaultComponents/CellBadge/index.tsx +14 -13
- package/Components/MasterCell/DefaultComponents/Image/hoc/utils/__tests__/withDimensions.test.ts +420 -125
- package/Components/MasterCell/DefaultComponents/Image/hoc/utils/index.ts +114 -19
- package/Components/MasterCell/DefaultComponents/Image/hoc/withDimensions.tsx +19 -8
- package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +50 -46
- package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +39 -47
- package/Components/MasterCell/DefaultComponents/SecondaryImage/utils.ts +6 -19
- package/Components/MasterCell/DefaultComponents/Text/index.tsx +15 -45
- package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +67 -196
- package/Components/MasterCell/DefaultComponents/index.ts +0 -4
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +6 -4
- package/Components/MasterCell/elementMapper.tsx +0 -2
- package/Components/ModalComponent/AudioPlayer/Components/Header.tsx +1 -1
- package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +53 -54
- package/Components/ModalComponent/AudioPlayer/Components/NowPlayingHeaderSection.tsx +86 -0
- package/Components/ModalComponent/AudioPlayer/Components/index.ts +3 -1
- package/Components/ModalComponent/BottomSheetModalContent.tsx +290 -55
- package/Components/ModalComponent/Button/index.tsx +5 -3
- package/Components/ModalComponent/Header/utils.ts +1 -1
- package/Components/ModalComponent/SortableList.tsx +142 -0
- package/Components/ModalComponent/TextInputContent.tsx +100 -0
- package/Components/ModalComponent/__tests__/BottomSheetModalContent.test.tsx +183 -0
- package/Components/ModalComponent/__tests__/TextInputContent.test.tsx +128 -0
- package/Components/ModalComponent/__tests__/showTextInput.test.ts +95 -0
- package/Components/ModalComponent/index.tsx +11 -0
- package/Components/ModalComponent/presets/__tests__/getCell.test.ts +66 -0
- package/Components/ModalComponent/presets/dynamicCollectionCell.tsx +74 -0
- package/Components/ModalComponent/presets/index.ts +27 -0
- package/Components/ModalComponent/presets/selectableCell.tsx +27 -0
- package/Components/ModalComponent/presets/standardCell.tsx +41 -0
- package/Components/ModalComponent/presets/types.ts +35 -0
- package/Components/ModalComponent/showTextInput.ts +43 -0
- package/package.json +6 -5
- package/Components/MasterCell/DefaultComponents/CellBadge/__tests__/__snapshots__/index.test.tsx.snap +0 -18
- package/Components/MasterCell/DefaultComponents/CellBadge/__tests__/index.test.tsx +0 -90
- package/Components/MasterCell/DefaultComponents/UIKitAdapters/Badge.tsx +0 -49
- package/Components/MasterCell/DefaultComponents/__tests__/ActionButton.test.tsx +0 -122
- package/Components/MasterCell/DefaultComponents/__tests__/Button.test.tsx +0 -186
- package/Components/MasterCell/DefaultComponents/__tests__/DynamicBadge.test.tsx +0 -156
- package/Components/MasterCell/DefaultComponents/__tests__/__snapshots__/ActionButton.test.tsx.snap +0 -60
- /package/Decorators/ZappPipesDataConnector/__tests__/{Hero.js → Hero.tsx} +0 -0
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import React, { useCallback, useEffect } from "react";
|
|
2
|
-
import { ViewStyle } from "react-native";
|
|
3
|
-
import {
|
|
4
|
-
ActionButton as UIKitActionButton,
|
|
5
|
-
ActionButtonProps,
|
|
6
|
-
} from "@applicaster/uikit/lib/components/uikit/action-button";
|
|
2
|
+
import { TouchableOpacity, ViewStyle } from "react-native";
|
|
7
3
|
|
|
8
4
|
import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
|
|
9
|
-
import Image from "./Image";
|
|
10
5
|
|
|
6
|
+
import Image from "./Image";
|
|
11
7
|
type Props = {
|
|
12
8
|
item: ZappEntry | ZappFeed;
|
|
13
9
|
flavour?: "flavour_1" | "flavour_2";
|
|
@@ -32,6 +28,30 @@ type Props = {
|
|
|
32
28
|
extraProps?: Record<string, any>;
|
|
33
29
|
};
|
|
34
30
|
|
|
31
|
+
function isStringAsset(asset) {
|
|
32
|
+
return typeof asset === "string" || Array.isArray(asset);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function getAssetValue(asset, flavour, fallbackAsset = null) {
|
|
36
|
+
if (!asset) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (typeof asset === "string") return fallbackAsset || asset;
|
|
41
|
+
|
|
42
|
+
if (Array.isArray(asset)) {
|
|
43
|
+
const flavourIndex = Number(flavour.replace("flavour_", ""));
|
|
44
|
+
|
|
45
|
+
if (flavour && flavourIndex > -1) {
|
|
46
|
+
return fallbackAsset || asset[flavourIndex - 1];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return fallbackAsset || asset[0];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return asset.src || fallbackAsset;
|
|
53
|
+
}
|
|
54
|
+
|
|
35
55
|
export const ActionButton = React.memo(function ActionButtonComponent(
|
|
36
56
|
props: Props
|
|
37
57
|
) {
|
|
@@ -73,32 +93,44 @@ export const ActionButton = React.memo(function ActionButtonComponent(
|
|
|
73
93
|
}, [item?.id, setActionState, actionContext]);
|
|
74
94
|
|
|
75
95
|
if (actionDisabled || !actionContext) return null;
|
|
76
|
-
|
|
77
|
-
const resolvedAssetComponent = actionState?.asset;
|
|
96
|
+
const AssetComponent = actionState?.asset;
|
|
78
97
|
|
|
79
98
|
// Default state is not yet ready
|
|
80
|
-
if (!
|
|
99
|
+
if (!AssetComponent) return null;
|
|
81
100
|
|
|
82
101
|
return (
|
|
83
|
-
<
|
|
84
|
-
|
|
85
|
-
item={item}
|
|
86
|
-
action={action}
|
|
87
|
-
asset={asset}
|
|
88
|
-
flavour={flavour}
|
|
89
|
-
cellUUID={cellUUID}
|
|
90
|
-
extraProps={props?.extraProps}
|
|
91
|
-
show={!!resolvedAssetComponent}
|
|
92
|
-
AssetComponent={resolvedAssetComponent}
|
|
93
|
-
ImageComponent={Image}
|
|
102
|
+
<TouchableOpacity
|
|
103
|
+
activeOpacity={1}
|
|
94
104
|
onPress={onPress}
|
|
95
|
-
testID={props?.testID}
|
|
96
|
-
accessibilityLabel={props?.accessibilityLabel}
|
|
105
|
+
testID={props?.testID || `${item?.id}`}
|
|
106
|
+
accessibilityLabel={props?.accessibilityLabel || `${item?.id}`}
|
|
97
107
|
accessibilityHint={props?.accessibilityHint}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
108
|
+
accessible={!!(props?.testID || props?.accessibilityLabel)}
|
|
109
|
+
style={props?.style}
|
|
110
|
+
>
|
|
111
|
+
{isStringAsset(actionState.asset) ? (
|
|
112
|
+
<Image
|
|
113
|
+
fadeDuration={0}
|
|
114
|
+
style={asset?.style || props?.style}
|
|
115
|
+
uri={getAssetValue(
|
|
116
|
+
actionState.asset,
|
|
117
|
+
flavour,
|
|
118
|
+
actionState.state === 1 ? asset?.src.active : asset?.src.inactive
|
|
119
|
+
)}
|
|
120
|
+
{...asset?.props}
|
|
121
|
+
/>
|
|
122
|
+
) : (
|
|
123
|
+
<AssetComponent
|
|
124
|
+
flavour={flavour}
|
|
125
|
+
asset={getAssetValue(
|
|
126
|
+
asset,
|
|
127
|
+
flavour,
|
|
128
|
+
actionState.state === 1 ? asset?.src.active : asset?.src.inactive
|
|
129
|
+
)}
|
|
130
|
+
cellUUID={cellUUID}
|
|
131
|
+
{...(props?.extraProps ?? {})}
|
|
132
|
+
/>
|
|
133
|
+
)}
|
|
134
|
+
</TouchableOpacity>
|
|
103
135
|
);
|
|
104
136
|
});
|
package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx
CHANGED
|
@@ -1,85 +1,26 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import {
|
|
3
|
+
BorderContainerView,
|
|
4
|
+
getBorderPadding, // Export for testing (using a double underscore prefix is a common convention)
|
|
5
|
+
} from "../index";
|
|
6
|
+
import { render } from "@testing-library/react-native";
|
|
7
|
+
import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
8
|
+
import { View } from "react-native";
|
|
9
|
+
|
|
10
|
+
jest.mock("@applicaster/zapp-react-native-utils/numberUtils", () => ({
|
|
11
|
+
toNumberWithDefaultZero: jest.fn((value) => Number(value) || 0),
|
|
12
|
+
}));
|
|
10
13
|
|
|
11
14
|
jest.mock(
|
|
12
15
|
"@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks",
|
|
13
16
|
() => ({
|
|
14
17
|
useAccessibilityManager: jest.fn(() => ({
|
|
15
|
-
addHeading:
|
|
18
|
+
addHeading: jest.fn(),
|
|
16
19
|
})),
|
|
17
20
|
})
|
|
18
21
|
);
|
|
19
22
|
|
|
20
|
-
const createMockValue = () => {
|
|
21
|
-
const values = {
|
|
22
|
-
cell_padding_top: 1,
|
|
23
|
-
cell_padding_left: 2,
|
|
24
|
-
cell_padding_right: 3,
|
|
25
|
-
cell_padding_bottom: 4,
|
|
26
|
-
image_border_size: 5,
|
|
27
|
-
image_focused_border_color: "red",
|
|
28
|
-
image_selected_border_color: "blue",
|
|
29
|
-
image_focused_selected_border_color: "green",
|
|
30
|
-
image_border_color: "black",
|
|
31
|
-
image_corner_radius: 10,
|
|
32
|
-
image_border_position: "outside",
|
|
33
|
-
image_border_padding_top: 6,
|
|
34
|
-
image_border_padding_right: 7,
|
|
35
|
-
image_border_padding_bottom: 8,
|
|
36
|
-
image_border_padding_left: 9,
|
|
37
|
-
image_margin_top: 11,
|
|
38
|
-
image_margin_left: 12,
|
|
39
|
-
image_margin_right: 13,
|
|
40
|
-
image_margin_bottom: 14,
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
return (key) => values[key] || 0;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const renderBorderContainer = (
|
|
47
|
-
overrideProps: Partial<any> = {},
|
|
48
|
-
measurementValue: React.ContextType<typeof MeasurementPortalContext> = null
|
|
49
|
-
) => {
|
|
50
|
-
const props = {
|
|
51
|
-
style: {
|
|
52
|
-
borderWidth: 4,
|
|
53
|
-
borderColor: "red",
|
|
54
|
-
borderRadius: 8,
|
|
55
|
-
backgroundColor: "navy",
|
|
56
|
-
},
|
|
57
|
-
testID: "border-container",
|
|
58
|
-
borderPosition: "outside" as const,
|
|
59
|
-
borderPaddingTop: 1,
|
|
60
|
-
borderPaddingRight: 2,
|
|
61
|
-
borderPaddingBottom: 3,
|
|
62
|
-
borderPaddingLeft: 4,
|
|
63
|
-
hasFocusableInside: jest.fn(() => false),
|
|
64
|
-
entry: { id: "test-entry", title: "Test title" } as ZappEntry,
|
|
65
|
-
state: "focused" as CellState,
|
|
66
|
-
hasTextLabels: false,
|
|
67
|
-
children: <View testID="child" />,
|
|
68
|
-
...overrideProps,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
return render(
|
|
72
|
-
<MeasurementPortalContext.Provider value={measurementValue}>
|
|
73
|
-
<BorderContainerView {...props} />
|
|
74
|
-
</MeasurementPortalContext.Provider>
|
|
75
|
-
);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
23
|
describe("BorderContainerView", () => {
|
|
79
|
-
beforeEach(() => {
|
|
80
|
-
jest.clearAllMocks();
|
|
81
|
-
});
|
|
82
|
-
|
|
83
24
|
describe("getBorderPadding", () => {
|
|
84
25
|
it("returns 0 for inside", () => {
|
|
85
26
|
expect(getBorderPadding("inside", 10)).toBe(0);
|
|
@@ -94,159 +35,47 @@ describe("BorderContainerView", () => {
|
|
|
94
35
|
});
|
|
95
36
|
|
|
96
37
|
it("returns borderWidth for invalid position", () => {
|
|
97
|
-
// @ts-ignore
|
|
38
|
+
// @ts-ignore
|
|
98
39
|
expect(getBorderPadding("other_value", 10)).toBe(10);
|
|
99
40
|
});
|
|
100
41
|
});
|
|
101
42
|
|
|
102
|
-
it("
|
|
103
|
-
const style =
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const flattenedOverlayStyle = StyleSheet.flatten(overlayHost.props.style);
|
|
133
|
-
expect(flattenedOverlayStyle.borderWidth).toBe(6);
|
|
134
|
-
expect(flattenedOverlayStyle.borderColor).toBe("orange");
|
|
135
|
-
expect(flattenedOverlayStyle.top).toBe(-7);
|
|
136
|
-
expect(flattenedOverlayStyle.right).toBe(-8);
|
|
137
|
-
expect(flattenedOverlayStyle.bottom).toBe(-9);
|
|
138
|
-
expect(flattenedOverlayStyle.left).toBe(-10);
|
|
139
|
-
expect(flattenedOverlayStyle.borderTopLeftRadius).toBe(19);
|
|
140
|
-
expect(flattenedOverlayStyle.borderTopRightRadius).toBe(19);
|
|
141
|
-
expect(flattenedOverlayStyle.borderBottomLeftRadius).toBe(21);
|
|
142
|
-
expect(flattenedOverlayStyle.borderBottomRightRadius).toBe(20);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it("renders no overlay when borderPosition is missing", () => {
|
|
146
|
-
const { getByTestId } = renderBorderContainer({
|
|
147
|
-
borderPosition: null,
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
const root = getByTestId("border-container");
|
|
151
|
-
|
|
152
|
-
expect(root.children).toHaveLength(2);
|
|
153
|
-
expect((root.children[0] as any).children).toHaveLength(0);
|
|
154
|
-
expect((root.children[1] as any).props.testID).toBe("child");
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it("preserves root pointerEvents defaults and caller overrides", () => {
|
|
158
|
-
const defaultRender = renderBorderContainer();
|
|
159
|
-
|
|
160
|
-
expect(
|
|
161
|
-
defaultRender.getByTestId("border-container").props.pointerEvents
|
|
162
|
-
).toBe("box-none");
|
|
163
|
-
|
|
164
|
-
const overrideRender = renderBorderContainer({
|
|
165
|
-
pointerEvents: "none",
|
|
166
|
-
testID: "override-border-container",
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
expect(
|
|
170
|
-
overrideRender.getByTestId("override-border-container").props
|
|
171
|
-
.pointerEvents
|
|
172
|
-
).toBe("none");
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
it("keeps the heading announcement logic in the QuickBrick wrapper", async () => {
|
|
176
|
-
renderBorderContainer({
|
|
177
|
-
entry: { id: "entry-1", title: "Hero title" } as ZappEntry,
|
|
178
|
-
state: "focused",
|
|
179
|
-
hasTextLabels: false,
|
|
180
|
-
hasFocusableInside: jest.fn(() => false),
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
await waitFor(() => {
|
|
184
|
-
expect(mockAddHeading).toHaveBeenCalledWith("Hero title");
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it("suppresses the heading announcement while measurement is in progress", async () => {
|
|
189
|
-
renderBorderContainer(
|
|
190
|
-
{
|
|
191
|
-
entry: { id: "entry-1", title: "Hero title" } as ZappEntry,
|
|
192
|
-
},
|
|
193
|
-
{ measuringInProgress: true }
|
|
43
|
+
it("Border component renders null if no borderPosition", () => {
|
|
44
|
+
const style = { borderWidth: 5, borderRadius: 10, borderColor: "red" };
|
|
45
|
+
|
|
46
|
+
const padding = {
|
|
47
|
+
paddingTop: 2,
|
|
48
|
+
paddingRight: 3,
|
|
49
|
+
paddingBottom: 4,
|
|
50
|
+
paddingLeft: 5,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const borderPosition = null;
|
|
54
|
+
const mockEntry = { id: "test-entry" } as ZappEntry;
|
|
55
|
+
const mockHasFocusableInside = jest.fn(() => false);
|
|
56
|
+
|
|
57
|
+
const { queryByTestId } = render(
|
|
58
|
+
<BorderContainerView
|
|
59
|
+
style={style}
|
|
60
|
+
testID="border-container"
|
|
61
|
+
borderPosition={borderPosition}
|
|
62
|
+
borderPaddingTop={toNumberWithDefaultZero(padding.paddingTop)}
|
|
63
|
+
borderPaddingRight={toNumberWithDefaultZero(padding.paddingRight)}
|
|
64
|
+
borderPaddingBottom={toNumberWithDefaultZero(padding.paddingBottom)}
|
|
65
|
+
borderPaddingLeft={toNumberWithDefaultZero(padding.paddingLeft)}
|
|
66
|
+
hasFocusableInside={mockHasFocusableInside}
|
|
67
|
+
entry={mockEntry}
|
|
68
|
+
state="focused"
|
|
69
|
+
hasTextLabels={false}
|
|
70
|
+
>
|
|
71
|
+
<View testID="child" />
|
|
72
|
+
</BorderContainerView>
|
|
194
73
|
);
|
|
195
74
|
|
|
196
|
-
|
|
197
|
-
expect(mockAddHeading).not.toHaveBeenCalled();
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
it("stays compatible with the ImageBorderContainer caller path", () => {
|
|
202
|
-
const imageBorderConfig = ImageBorderContainer({
|
|
203
|
-
value: createMockValue(),
|
|
204
|
-
state: "default",
|
|
205
|
-
imageStyles: {
|
|
206
|
-
width: 100,
|
|
207
|
-
height: 60,
|
|
208
|
-
},
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
const { getByTestId } = renderBorderContainer({
|
|
212
|
-
style: imageBorderConfig.style,
|
|
213
|
-
pointerEvents: imageBorderConfig.additionalProps.pointerEvents,
|
|
214
|
-
borderPosition: imageBorderConfig.additionalProps.borderPosition,
|
|
215
|
-
borderPaddingTop: imageBorderConfig.additionalProps.borderPaddingTop,
|
|
216
|
-
borderPaddingRight: imageBorderConfig.additionalProps.borderPaddingRight,
|
|
217
|
-
borderPaddingBottom:
|
|
218
|
-
imageBorderConfig.additionalProps.borderPaddingBottom,
|
|
219
|
-
borderPaddingLeft: imageBorderConfig.additionalProps.borderPaddingLeft,
|
|
220
|
-
children: <View testID="image-border-child" />,
|
|
221
|
-
state: null,
|
|
222
|
-
hasTextLabels: true,
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
const root = getByTestId("border-container");
|
|
226
|
-
const overlay = root.children[0] as any;
|
|
227
|
-
const overlayHost = overlay.children[0] as any;
|
|
228
|
-
const child = root.children[1] as any;
|
|
229
|
-
|
|
230
|
-
expect(root.props.pointerEvents).toBe("none");
|
|
231
|
-
expect(child.props.testID).toBe("image-border-child");
|
|
232
|
-
|
|
233
|
-
const flattenedRootStyle = StyleSheet.flatten(root.props.style);
|
|
234
|
-
expect(flattenedRootStyle.borderRadius).toBe(10);
|
|
235
|
-
expect(flattenedRootStyle.marginTop).toBe(12);
|
|
236
|
-
expect(flattenedRootStyle.marginLeft).toBe(14);
|
|
237
|
-
expect(flattenedRootStyle.marginRight).toBe(16);
|
|
238
|
-
expect(flattenedRootStyle.marginBottom).toBe(18);
|
|
75
|
+
const children = queryByTestId("border-container").children;
|
|
239
76
|
|
|
240
|
-
expect(
|
|
241
|
-
expect(overlay.props.borderColor).toBe("black");
|
|
242
|
-
expect(overlay.props.borderRadius).toBe(10);
|
|
77
|
+
expect(children[1].props.testID).toBe("child");
|
|
243
78
|
|
|
244
|
-
|
|
245
|
-
expect(flattenedOverlayStyle.borderWidth).toBe(5);
|
|
246
|
-
expect(flattenedOverlayStyle.borderColor).toBe("black");
|
|
247
|
-
expect(flattenedOverlayStyle.borderTopLeftRadius).toBe(21);
|
|
248
|
-
expect(flattenedOverlayStyle.borderTopRightRadius).toBe(21);
|
|
249
|
-
expect(flattenedOverlayStyle.borderBottomLeftRadius).toBe(23);
|
|
250
|
-
expect(flattenedOverlayStyle.borderBottomRightRadius).toBe(22);
|
|
79
|
+
expect(children[0].children.length).toBe(0);
|
|
251
80
|
});
|
|
252
81
|
});
|
|
@@ -1,27 +1,18 @@
|
|
|
1
1
|
import React, { useMemo, useContext, useEffect } from "react";
|
|
2
|
-
import {
|
|
3
|
-
ImageStyle,
|
|
4
|
-
StyleProp,
|
|
5
|
-
StyleSheet,
|
|
6
|
-
ViewProps,
|
|
7
|
-
ViewStyle,
|
|
8
|
-
} from "react-native";
|
|
9
|
-
import {
|
|
10
|
-
BorderContainer as UIKitBorderContainer,
|
|
11
|
-
getBorderPadding,
|
|
12
|
-
type BorderPosition,
|
|
13
|
-
type UIKitBorderContainerProps,
|
|
14
|
-
} from "@applicaster/uikit/lib/components/uikit/border-container";
|
|
2
|
+
import { ImageStyle, StyleSheet, View, ViewStyle } from "react-native";
|
|
15
3
|
import { useAccessibilityManager } from "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks";
|
|
4
|
+
import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
16
5
|
import { MeasurementPortalContext } from "../../../MeasurmentsPortal/MeasurementsPortal";
|
|
17
6
|
|
|
18
|
-
|
|
7
|
+
type BorderPosition = "inside" | "outside" | "center";
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
19
10
|
hasFocusableInside: (entry: ZappEntry) => boolean;
|
|
20
11
|
entry: ZappEntry;
|
|
21
12
|
state: CellState;
|
|
22
13
|
hasTextLabels: boolean;
|
|
23
|
-
style:
|
|
24
|
-
borderPosition
|
|
14
|
+
style: ImageStyle | ViewStyle;
|
|
15
|
+
borderPosition: BorderPosition;
|
|
25
16
|
borderPaddingTop: number;
|
|
26
17
|
borderPaddingRight: number;
|
|
27
18
|
borderPaddingBottom: number;
|
|
@@ -29,23 +20,100 @@ interface Props extends ViewProps {
|
|
|
29
20
|
children: React.ReactNode;
|
|
30
21
|
}
|
|
31
22
|
|
|
32
|
-
const
|
|
33
|
-
|
|
23
|
+
const COLOR_TRANSPARENT = "transparent";
|
|
24
|
+
|
|
25
|
+
const styles = StyleSheet.create({
|
|
26
|
+
container: {
|
|
27
|
+
overflow: "visible",
|
|
28
|
+
borderWidth: 0,
|
|
29
|
+
borderColor: COLOR_TRANSPARENT,
|
|
30
|
+
},
|
|
31
|
+
border: {
|
|
32
|
+
...StyleSheet.absoluteFillObject,
|
|
33
|
+
zIndex: 1,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
export const getBorderPadding = (
|
|
38
|
+
borderPosition: BorderPosition,
|
|
39
|
+
borderWidth: number
|
|
40
|
+
) => {
|
|
41
|
+
switch (borderPosition) {
|
|
42
|
+
case "inside":
|
|
43
|
+
return 0;
|
|
44
|
+
case "center":
|
|
45
|
+
return borderWidth / 2;
|
|
46
|
+
case "outside":
|
|
47
|
+
return borderWidth;
|
|
48
|
+
default:
|
|
49
|
+
return borderWidth;
|
|
50
|
+
}
|
|
36
51
|
};
|
|
37
52
|
|
|
38
|
-
const
|
|
39
|
-
|
|
53
|
+
const Border = ({
|
|
54
|
+
style,
|
|
55
|
+
padding,
|
|
56
|
+
borderPosition,
|
|
57
|
+
}: {
|
|
58
|
+
style: ViewStyle;
|
|
59
|
+
padding: ViewStyle;
|
|
60
|
+
borderPosition: BorderPosition;
|
|
61
|
+
}) => {
|
|
62
|
+
if (!borderPosition) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
40
65
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
66
|
+
const borderWidth = toNumberWithDefaultZero(style.borderWidth);
|
|
67
|
+
const containerPadding = getBorderPadding(borderPosition, borderWidth);
|
|
68
|
+
|
|
69
|
+
const initialBorderRadius = toNumberWithDefaultZero(style.borderRadius);
|
|
70
|
+
const paddingTop = toNumberWithDefaultZero(padding.paddingTop);
|
|
71
|
+
const paddingRight = toNumberWithDefaultZero(padding.paddingRight);
|
|
72
|
+
const paddingBottom = toNumberWithDefaultZero(padding.paddingBottom);
|
|
73
|
+
const paddingLeft = toNumberWithDefaultZero(padding.paddingLeft);
|
|
74
|
+
|
|
75
|
+
const borderRadiusStyle = initialBorderRadius
|
|
76
|
+
? {
|
|
77
|
+
borderTopLeftRadius:
|
|
78
|
+
initialBorderRadius +
|
|
79
|
+
containerPadding +
|
|
80
|
+
Math.min(paddingTop, paddingLeft),
|
|
81
|
+
borderTopRightRadius:
|
|
82
|
+
initialBorderRadius +
|
|
83
|
+
containerPadding +
|
|
84
|
+
Math.min(paddingTop, paddingRight),
|
|
85
|
+
borderBottomLeftRadius:
|
|
86
|
+
initialBorderRadius +
|
|
87
|
+
containerPadding +
|
|
88
|
+
Math.min(paddingBottom, paddingLeft),
|
|
89
|
+
borderBottomRightRadius:
|
|
90
|
+
initialBorderRadius +
|
|
91
|
+
containerPadding +
|
|
92
|
+
Math.min(paddingBottom, paddingRight),
|
|
93
|
+
}
|
|
94
|
+
: {
|
|
95
|
+
borderTopLeftRadius: 0,
|
|
96
|
+
borderTopRightRadius: 0,
|
|
97
|
+
borderBottomLeftRadius: 0,
|
|
98
|
+
borderBottomRightRadius: 0,
|
|
99
|
+
};
|
|
47
100
|
|
|
48
|
-
|
|
101
|
+
return (
|
|
102
|
+
<View
|
|
103
|
+
pointerEvents="none"
|
|
104
|
+
style={{
|
|
105
|
+
...styles.border,
|
|
106
|
+
right: -containerPadding - paddingRight,
|
|
107
|
+
bottom: -containerPadding - paddingBottom,
|
|
108
|
+
left: -containerPadding - paddingLeft,
|
|
109
|
+
top: -containerPadding - paddingTop,
|
|
110
|
+
borderWidth,
|
|
111
|
+
borderColor: style.borderColor,
|
|
112
|
+
...borderRadiusStyle,
|
|
113
|
+
}}
|
|
114
|
+
/>
|
|
115
|
+
);
|
|
116
|
+
};
|
|
49
117
|
|
|
50
118
|
export const BorderContainerView = (props: Props) => {
|
|
51
119
|
const {
|
|
@@ -60,15 +128,11 @@ export const BorderContainerView = (props: Props) => {
|
|
|
60
128
|
entry,
|
|
61
129
|
state,
|
|
62
130
|
hasTextLabels,
|
|
63
|
-
...viewProps
|
|
64
131
|
} = props;
|
|
65
132
|
|
|
66
133
|
const accessibilityManager = useAccessibilityManager();
|
|
67
134
|
const isMeasurement = useContext(MeasurementPortalContext);
|
|
68
135
|
|
|
69
|
-
const { borderWidth, borderColor, borderRadius } =
|
|
70
|
-
getBorderPropsFromStyle(style);
|
|
71
|
-
|
|
72
136
|
const isImageOnlyCell = useMemo(
|
|
73
137
|
() =>
|
|
74
138
|
state === "focused" &&
|
|
@@ -84,21 +148,20 @@ export const BorderContainerView = (props: Props) => {
|
|
|
84
148
|
}
|
|
85
149
|
}, [isImageOnlyCell, entry?.title]);
|
|
86
150
|
|
|
151
|
+
const padding =
|
|
152
|
+
borderPosition === "outside"
|
|
153
|
+
? {
|
|
154
|
+
paddingTop: borderPaddingTop,
|
|
155
|
+
paddingRight: borderPaddingRight,
|
|
156
|
+
paddingBottom: borderPaddingBottom,
|
|
157
|
+
paddingLeft: borderPaddingLeft,
|
|
158
|
+
}
|
|
159
|
+
: {};
|
|
160
|
+
|
|
87
161
|
return (
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
{...viewProps}
|
|
91
|
-
style={style as UIKitBorderContainerProps["style"]}
|
|
92
|
-
borderPosition={borderPosition}
|
|
93
|
-
borderWidth={borderWidth}
|
|
94
|
-
borderColor={borderColor}
|
|
95
|
-
borderRadius={borderRadius}
|
|
96
|
-
borderPaddingTop={borderPaddingTop}
|
|
97
|
-
borderPaddingRight={borderPaddingRight}
|
|
98
|
-
borderPaddingBottom={borderPaddingBottom}
|
|
99
|
-
borderPaddingLeft={borderPaddingLeft}
|
|
100
|
-
>
|
|
162
|
+
<View pointerEvents="box-none" {...props} style={[style, styles.container]}>
|
|
163
|
+
<Border style={style} padding={padding} borderPosition={borderPosition} />
|
|
101
164
|
{children}
|
|
102
|
-
</
|
|
165
|
+
</View>
|
|
103
166
|
);
|
|
104
167
|
};
|