@applicaster/zapp-react-native-ui-components 16.0.0-alpha.2024822855 → 16.0.0-alpha.2105365027
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/Cell/Cell.tsx +3 -6
- package/Components/Cell/TvOSCellComponent.tsx +0 -1
- package/Components/FocusableList/index.tsx +7 -0
- package/Components/GeneralContentScreen/GeneralContentScreen.tsx +7 -0
- package/Components/GeneralContentScreen/GeneralContentScreenHookAdapter.tsx +15 -0
- package/Components/GeneralContentScreen/hookAdapter/__tests__/skipExpression.test.ts +294 -0
- package/Components/GeneralContentScreen/hookAdapter/__tests__/validationHelper.test.ts +64 -0
- package/Components/GeneralContentScreen/hookAdapter/skipExpression.ts +252 -0
- package/Components/GeneralContentScreen/hookAdapter/validationHelper.ts +18 -0
- package/Components/LinkHandler/LinkHandler.tsx +2 -7
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +5 -1
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/ActionButtonController.tsx +19 -4
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/__tests__/ActionButtonController.test.tsx +43 -1
- package/Components/MasterCell/DefaultComponents/Button.tsx +1 -0
- package/Components/MasterCell/DefaultComponents/LiveImage/executePreloadHooks.ts +2 -4
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +14 -6
- package/Components/MasterCell/DefaultComponents/Toggle.tsx +1 -8
- package/Components/MasterCell/DefaultComponents/__tests__/Toggle.test.tsx +10 -6
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +1 -1
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +4 -2
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/factory.test.ts +32 -0
- package/Components/MasterCell/__tests__/masterCell.test.js +60 -0
- package/Components/MasterCell/index.tsx +60 -11
- package/Components/MasterCell/utils/__tests__/withoutFocusedState.test.js +20 -0
- package/Components/MasterCell/utils/index.ts +18 -0
- package/Components/ModalComponent/ActionsBottomSheet/ActionButton.tsx +56 -0
- package/Components/ModalComponent/ActionsBottomSheet/__tests__/openActionsBottomSheet.test.ts +38 -0
- package/Components/ModalComponent/ActionsBottomSheet/boundActionButton.tsx +24 -0
- package/Components/ModalComponent/ActionsBottomSheet/index.ts +9 -0
- package/Components/ModalComponent/ActionsBottomSheet/openActionsBottomSheet.ts +61 -0
- package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +70 -73
- package/Components/ModalComponent/AudioPlayer/Components/Header.tsx +65 -56
- package/Components/ModalComponent/AudioPlayer/Components/Input.tsx +140 -65
- package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +202 -48
- package/Components/ModalComponent/AudioPlayer/Components/NowPlayingHeaderSection.tsx +148 -32
- package/Components/ModalComponent/AudioPlayer/Components/__tests__/Item.test.tsx +164 -0
- package/Components/ModalComponent/AudioPlayer/Components/__tests__/NowPlayingHeaderSection.test.tsx +36 -0
- package/Components/ModalComponent/AudioPlayer/Components/index.ts +0 -2
- package/Components/ModalComponent/AudioPlayer/utils/__tests__/mergeStyles.test.ts +433 -0
- package/Components/ModalComponent/AudioPlayer/utils/mergeStyles.ts +389 -25
- package/Components/ModalComponent/BottomSheetModalContent.tsx +126 -77
- package/Components/ModalComponent/Header/CloseButton.tsx +12 -0
- package/Components/ModalComponent/Header/__tests__/CloseButton.test.tsx +72 -0
- package/Components/ModalComponent/SortableList.tsx +36 -22
- package/Components/ModalComponent/SortableList.web.tsx +2 -70
- package/Components/ModalComponent/TextInputContent.tsx +42 -7
- package/Components/ModalComponent/__tests__/BottomSheetModalContent.test.tsx +111 -6
- package/Components/ModalComponent/__tests__/SortableList.web.test.tsx +16 -0
- package/Components/ModalComponent/__tests__/TextInputContent.test.tsx +50 -1
- package/Components/ModalComponent/__tests__/showTextInput.test.ts +25 -0
- package/Components/ModalComponent/index.tsx +7 -9
- package/Components/ModalComponent/presets/__tests__/getCell.test.ts +24 -0
- package/Components/ModalComponent/presets/dynamicCollectionCell.tsx +1 -1
- package/Components/ModalComponent/presets/selectableCell.tsx +1 -1
- package/Components/ModalComponent/showTextInput.ts +13 -2
- package/Components/ModalComponent/utils.ts +6 -1
- package/Components/OfflineHandler/__tests__/index.test.tsx +109 -0
- package/Components/OfflineHandler/hooks.ts +0 -12
- package/Components/OfflineHandler/index.tsx +42 -4
- package/Components/PlayerContainer/PlayerContainer.tsx +8 -1
- package/Components/River/ComponentsMap/ComponentsMap.tsx +89 -60
- package/Components/River/River.tsx +4 -0
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +140 -75
- package/Components/River/__tests__/componentsMap.test.js +8 -3
- package/Components/River/__tests__/resultCallback.test.tsx +47 -0
- package/Components/Screen/__tests__/Screen.test.tsx +24 -0
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +2 -0
- package/Components/Screen/index.tsx +5 -0
- package/Components/Screen/navigationHandler.ts +8 -8
- package/Components/ScreenRevealManager/ScreenRevealManager.ts +18 -2
- package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +36 -0
- package/Components/ScreenRevealManager/__tests__/withScreenRevealManager.test.tsx +56 -0
- package/Components/ScreenRevealManager/withScreenRevealManager.tsx +21 -4
- package/Components/Transitioner/AnimationManager.js +1 -1
- package/Components/Transitioner/Scene.tsx +4 -3
- package/Components/Transitioner/Transitioner.tsx +71 -33
- package/Components/Transitioner/__tests__/transitioner.test.js +372 -3
- package/Components/VideoLive/LiveImageManager.ts +8 -2
- package/Components/VideoLive/__tests__/LiveImageManager.test.ts +59 -0
- package/Components/VideoModal/PlayerWrapper.tsx +4 -1
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
- package/Components/VideoModal/__tests__/playerWrapperStyle.test.ts +58 -0
- package/Components/VideoModal/__tests__/playerWrapperUtils.test.ts +16 -0
- package/Components/VideoModal/playerWrapperStyle.ts +21 -3
- package/Components/VideoModal/playerWrapperUtils.ts +7 -1
- package/Contexts/ModalNavigationContext/__tests__/index.test.tsx +15 -0
- package/Contexts/ModalNavigationContext/index.tsx +2 -2
- package/Decorators/ZappPipesDataConnector/__tests__/screenToolbox.test.ts +347 -0
- package/Decorators/ZappPipesDataConnector/__tests__/screenToolboxUnavailable.test.ts +53 -0
- package/Decorators/ZappPipesDataConnector/index.tsx +19 -4
- package/Decorators/ZappPipesDataConnector/screenToolbox.ts +384 -0
- package/Hooks/useEntryActionsExpander.ts +63 -0
- package/assets/empty-Info.png +0 -0
- package/package.json +5 -5
- package/Components/ModalComponent/AudioPlayer/Components/Action.tsx +0 -314
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { getNamespaceAndKey } from "@applicaster/zapp-react-native-utils/appUtils/contextKeysManager/utils";
|
|
2
|
+
import { log_error, log_info } from "./logger";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Boolean expressions over storage keys, used by the General Content Screen
|
|
6
|
+
* hook adapter to decide whether a hook should be skipped.
|
|
7
|
+
*
|
|
8
|
+
* The `skip_hook_storage_key` rule normally holds a comma-separated list of
|
|
9
|
+
* keys, meaning "skip when any of these exists". That covers presence only, so
|
|
10
|
+
* a condition such as "the user is logged in but has not picked a profile yet"
|
|
11
|
+
* cannot be expressed. To keep the manifest field untouched, an expression may
|
|
12
|
+
* be packed into the very same string as JSON: anything starting with `{` is
|
|
13
|
+
* parsed as an expression, anything else keeps the legacy behaviour.
|
|
14
|
+
*
|
|
15
|
+
* The expression evaluates to the SKIP condition — true means "do not present
|
|
16
|
+
* the hook" — matching the name of the rule it is configured in.
|
|
17
|
+
*
|
|
18
|
+
* Keys are written as `namespace.key` and resolved exactly like the legacy
|
|
19
|
+
* format: everything before the LAST dot is the namespace, so
|
|
20
|
+
* `com.applicaster.feature.someKey` reads `someKey` from `com.applicaster.feature`.
|
|
21
|
+
* A key with no dot falls back to the default namespace.
|
|
22
|
+
*
|
|
23
|
+
* Operators:
|
|
24
|
+
*
|
|
25
|
+
* "ns.key" shorthand for { "exists": "ns.key" }
|
|
26
|
+
* { "exists": "ns.key" } the key holds a truthy value
|
|
27
|
+
* { "missing": "ns.key" } the key holds no value
|
|
28
|
+
* { "equals": { "key": "ns.key", "value": "kids" } }
|
|
29
|
+
* { "all": [ …operands ] } AND, short-circuits on the first false
|
|
30
|
+
* { "any": [ …operands ] } OR, short-circuits on the first true
|
|
31
|
+
* { "not": operand } negation
|
|
32
|
+
*
|
|
33
|
+
* @example Show the profile selector to a logged-in user who has no profile yet
|
|
34
|
+
* ```json
|
|
35
|
+
* {
|
|
36
|
+
* "any": [
|
|
37
|
+
* { "missing": "quick-brick-login-flow.access_token" },
|
|
38
|
+
* { "exists": "user_account.profile" }
|
|
39
|
+
* ]
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
* As it is stored in the `skip_hook_storage_key` string field:
|
|
43
|
+
* ```json
|
|
44
|
+
* "skip_hook_storage_key": "{\"any\":[{\"missing\":\"quick-brick-login-flow.access_token\"},{\"exists\":\"user_account.profile\"}]}"
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example Skip an onboarding hook once it has been seen on a subscribed device
|
|
48
|
+
* ```json
|
|
49
|
+
* {
|
|
50
|
+
* "all": [
|
|
51
|
+
* "onboarding.completed",
|
|
52
|
+
* { "equals": { "key": "user_account.plan", "value": "premium" } }
|
|
53
|
+
* ]
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* Every failure mode — malformed JSON, an unknown operator, an operand of the
|
|
58
|
+
* wrong type, a storage read that throws — evaluates to false, so a broken
|
|
59
|
+
* configuration presents the hook rather than silently hiding a screen.
|
|
60
|
+
*/
|
|
61
|
+
export type SkipExpression =
|
|
62
|
+
| string
|
|
63
|
+
| { exists: string }
|
|
64
|
+
| { missing: string }
|
|
65
|
+
| { equals: { key: string; value: string } }
|
|
66
|
+
| { all: SkipExpression[] }
|
|
67
|
+
| { any: SkipExpression[] }
|
|
68
|
+
| { not: SkipExpression };
|
|
69
|
+
|
|
70
|
+
/** Reads a single storage key. Injected so evaluation stays storage-agnostic. */
|
|
71
|
+
export type ReadKey = (key: string, namespace?: string) => Promise<unknown>;
|
|
72
|
+
|
|
73
|
+
const isPlainObject = (value: unknown): value is Record<string, unknown> =>
|
|
74
|
+
typeof value === "object" && value !== null && !Array.isArray(value);
|
|
75
|
+
|
|
76
|
+
const hasOperator = (node: Record<string, unknown>, operator: string) =>
|
|
77
|
+
Object.prototype.hasOwnProperty.call(node, operator);
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Whether a `skip_hook_storage_key` value is meant as an expression at all.
|
|
81
|
+
*
|
|
82
|
+
* Deliberately a shape check rather than a successful parse: a value that opens
|
|
83
|
+
* with `{` was written as an expression even when its JSON is broken, and must
|
|
84
|
+
* never fall back to being read as a list of storage keys.
|
|
85
|
+
*/
|
|
86
|
+
export const looksLikeSkipExpression = (input: unknown): boolean =>
|
|
87
|
+
isPlainObject(input) ||
|
|
88
|
+
(typeof input === "string" && input.trim().startsWith("{"));
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Reads a `skip_hook_storage_key` value as an expression, or returns null when
|
|
92
|
+
* it is not one — an empty value, a legacy comma-separated key list, or an
|
|
93
|
+
* expression whose JSON is malformed.
|
|
94
|
+
*/
|
|
95
|
+
export const parseSkipExpression = (input: unknown): SkipExpression | null => {
|
|
96
|
+
if (isPlainObject(input)) {
|
|
97
|
+
return input as SkipExpression;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (!looksLikeSkipExpression(input)) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const trimmed = (input as string).trim();
|
|
105
|
+
|
|
106
|
+
try {
|
|
107
|
+
const parsed = JSON.parse(trimmed);
|
|
108
|
+
|
|
109
|
+
if (!isPlainObject(parsed)) {
|
|
110
|
+
log_error(
|
|
111
|
+
`parseSkipExpression: Expression must be an object, got: ${trimmed}`
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return parsed as SkipExpression;
|
|
118
|
+
} catch (error) {
|
|
119
|
+
log_error(
|
|
120
|
+
`parseSkipExpression: Malformed expression: ${trimmed}. Error: ${error.message}`,
|
|
121
|
+
{ error }
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const keyIsTruthy = async (key: string, readKey: ReadKey): Promise<boolean> => {
|
|
129
|
+
const { namespace, key: name } = getNamespaceAndKey(key);
|
|
130
|
+
|
|
131
|
+
return Boolean(await readKey(name, namespace));
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const evaluateEquals = async (
|
|
135
|
+
operand: { key: string; value: string },
|
|
136
|
+
readKey: ReadKey
|
|
137
|
+
): Promise<boolean> => {
|
|
138
|
+
const { namespace, key: name } = getNamespaceAndKey(operand.key);
|
|
139
|
+
const value = await readKey(name, namespace);
|
|
140
|
+
|
|
141
|
+
return value == null ? false : String(value) === String(operand.value);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const evaluateNode = async (
|
|
145
|
+
node: SkipExpression,
|
|
146
|
+
readKey: ReadKey
|
|
147
|
+
): Promise<boolean> => {
|
|
148
|
+
try {
|
|
149
|
+
if (typeof node === "string") {
|
|
150
|
+
return await keyIsTruthy(node, readKey);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (!isPlainObject(node)) {
|
|
154
|
+
log_error(
|
|
155
|
+
`evaluateSkipExpression: Not an operator: ${JSON.stringify(node)}`
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// The node came from configuration JSON, so every operand is read back as
|
|
162
|
+
// unknown and type-checked here rather than trusted from the union.
|
|
163
|
+
const operator = node as Record<string, unknown>;
|
|
164
|
+
|
|
165
|
+
if (
|
|
166
|
+
hasOperator(operator, "exists") &&
|
|
167
|
+
typeof operator.exists === "string"
|
|
168
|
+
) {
|
|
169
|
+
return await keyIsTruthy(operator.exists, readKey);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (
|
|
173
|
+
hasOperator(operator, "missing") &&
|
|
174
|
+
typeof operator.missing === "string"
|
|
175
|
+
) {
|
|
176
|
+
return !(await keyIsTruthy(operator.missing, readKey));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (hasOperator(operator, "equals") && isPlainObject(operator.equals)) {
|
|
180
|
+
return await evaluateEquals(
|
|
181
|
+
operator.equals as { key: string; value: string },
|
|
182
|
+
readKey
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (hasOperator(operator, "all") && Array.isArray(operator.all)) {
|
|
187
|
+
for (const operand of operator.all) {
|
|
188
|
+
if (!(await evaluateNode(operand, readKey))) {
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// An empty operand list carries no condition, so it stays false rather
|
|
194
|
+
// than skipping the hook on the vacuous truth of an empty AND.
|
|
195
|
+
return operator.all.length > 0;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (hasOperator(operator, "any") && Array.isArray(operator.any)) {
|
|
199
|
+
for (const operand of operator.any) {
|
|
200
|
+
if (await evaluateNode(operand, readKey)) {
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (hasOperator(operator, "not")) {
|
|
209
|
+
return !(await evaluateNode(operator.not as SkipExpression, readKey));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
log_error(
|
|
213
|
+
`evaluateSkipExpression: Unknown or malformed operator: ${JSON.stringify(
|
|
214
|
+
node
|
|
215
|
+
)}`
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
return false;
|
|
219
|
+
} catch (error) {
|
|
220
|
+
log_error(
|
|
221
|
+
`evaluateSkipExpression: Error: ${error.message} evaluating: ${JSON.stringify(
|
|
222
|
+
node
|
|
223
|
+
)}`,
|
|
224
|
+
{ error }
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Evaluates a parsed expression to the skip decision. A null expression — the
|
|
233
|
+
* field held no expression — is not a condition, so nothing is skipped.
|
|
234
|
+
*/
|
|
235
|
+
export const evaluateSkipExpression = async (
|
|
236
|
+
expression: SkipExpression | null,
|
|
237
|
+
readKey: ReadKey
|
|
238
|
+
): Promise<boolean> => {
|
|
239
|
+
if (!expression) {
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const shouldSkip = await evaluateNode(expression, readKey);
|
|
244
|
+
|
|
245
|
+
log_info(
|
|
246
|
+
`evaluateSkipExpression: Expression evaluated to ${shouldSkip}, ${
|
|
247
|
+
shouldSkip ? "skipping hook" : "proceeding with hook"
|
|
248
|
+
}`
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
return shouldSkip;
|
|
252
|
+
};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { getNamespaceAndKey } from "@applicaster/zapp-react-native-utils/appUtils/contextKeysManager/utils";
|
|
2
2
|
import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
|
|
3
3
|
import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
|
|
4
|
+
import {
|
|
5
|
+
looksLikeSkipExpression,
|
|
6
|
+
parseSkipExpression,
|
|
7
|
+
evaluateSkipExpression,
|
|
8
|
+
} from "./skipExpression";
|
|
4
9
|
import { log_error, log_info } from "./logger";
|
|
5
10
|
|
|
6
11
|
type ParseKey = { key: string; namespace?: string };
|
|
@@ -23,6 +28,12 @@ export const getKeyToSkipHook = async (key: string, namespace?: string) => {
|
|
|
23
28
|
return await localStorage.getItem(key, namespace);
|
|
24
29
|
};
|
|
25
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Decides whether the hook should be skipped, from the `skip_hook_storage_key`
|
|
33
|
+
* rule. The value is either a comma-separated key list — skip when ANY of them
|
|
34
|
+
* exists — or, packed into the same string, a JSON boolean expression over
|
|
35
|
+
* storage keys. See `skipExpression.ts` for the expression format.
|
|
36
|
+
*/
|
|
26
37
|
export const shouldSkipHook = async (
|
|
27
38
|
skipHookIfKeysExist?: string
|
|
28
39
|
): Promise<boolean> => {
|
|
@@ -32,6 +43,13 @@ export const shouldSkipHook = async (
|
|
|
32
43
|
return false;
|
|
33
44
|
}
|
|
34
45
|
|
|
46
|
+
if (looksLikeSkipExpression(skipHookIfKeysExist)) {
|
|
47
|
+
return await evaluateSkipExpression(
|
|
48
|
+
parseSkipExpression(skipHookIfKeysExist),
|
|
49
|
+
getKeyToSkipHook
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
35
53
|
const keyEntries = parseKeyEntries(skipHookIfKeysExist);
|
|
36
54
|
|
|
37
55
|
if (keyEntries.length === 0) {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import { usePlugins } from "@applicaster/zapp-react-native-redux/hooks";
|
|
4
|
+
import { getPluginByIdentifier } from "@applicaster/zapp-react-native-utils/pluginUtils";
|
|
6
5
|
import {
|
|
7
6
|
inflateString,
|
|
8
7
|
objectToReadableString,
|
|
@@ -40,12 +39,8 @@ export async function inflateUrl(url) {
|
|
|
40
39
|
|
|
41
40
|
export function LinkHandler(props: Props) {
|
|
42
41
|
const screenData = props?.screenData;
|
|
43
|
-
const plugins = usePlugins();
|
|
44
42
|
|
|
45
|
-
const ScreenPlugin =
|
|
46
|
-
WEBVIEW_SCREEN_IDENTIFIER,
|
|
47
|
-
plugins
|
|
48
|
-
);
|
|
43
|
+
const ScreenPlugin = getPluginByIdentifier(WEBVIEW_SCREEN_IDENTIFIER);
|
|
49
44
|
|
|
50
45
|
const Component =
|
|
51
46
|
R.path(["module", "Component"], ScreenPlugin) ||
|
|
@@ -2,6 +2,7 @@ import React, { useCallback, useEffect } from "react";
|
|
|
2
2
|
import { TouchableOpacity, ViewStyle } from "react-native";
|
|
3
3
|
|
|
4
4
|
import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
|
|
5
|
+
import { useUIComponentContext } from "@applicaster/zapp-react-native-ui-components/Contexts/UIComponentContext";
|
|
5
6
|
|
|
6
7
|
import Image from "./Image";
|
|
7
8
|
type Props = {
|
|
@@ -57,6 +58,7 @@ export const ActionButton = React.memo(function ActionButtonComponent(
|
|
|
57
58
|
) {
|
|
58
59
|
const { item, action, asset, flavour = "flavour_1", cellUUID } = props;
|
|
59
60
|
const actionContext = useActions(action?.identifier);
|
|
61
|
+
const component = useUIComponentContext();
|
|
60
62
|
|
|
61
63
|
// TODO: add subscription API for action availability
|
|
62
64
|
const actionDisabled =
|
|
@@ -81,8 +83,9 @@ export const ActionButton = React.memo(function ActionButtonComponent(
|
|
|
81
83
|
updateState: (state) => {
|
|
82
84
|
setActionState(state);
|
|
83
85
|
},
|
|
86
|
+
...(component ? { component } : {}),
|
|
84
87
|
});
|
|
85
|
-
}, [actionState, actionContext?.state, item
|
|
88
|
+
}, [actionState, actionContext?.state, item, component]);
|
|
86
89
|
|
|
87
90
|
useEffect(() => {
|
|
88
91
|
if (typeof actionContext?.addListener === "function") {
|
|
@@ -105,6 +108,7 @@ export const ActionButton = React.memo(function ActionButtonComponent(
|
|
|
105
108
|
testID={props?.testID || `${item?.id}`}
|
|
106
109
|
accessibilityLabel={props?.accessibilityLabel || `${item?.id}`}
|
|
107
110
|
accessibilityHint={props?.accessibilityHint}
|
|
111
|
+
accessibilityRole="button"
|
|
108
112
|
accessible={!!(props?.testID || props?.accessibilityLabel)}
|
|
109
113
|
style={props?.style}
|
|
110
114
|
>
|
|
@@ -6,6 +6,7 @@ import React, {
|
|
|
6
6
|
useState,
|
|
7
7
|
} from "react";
|
|
8
8
|
import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
|
|
9
|
+
import { useUIComponentContext } from "@applicaster/zapp-react-native-ui-components/Contexts/UIComponentContext";
|
|
9
10
|
|
|
10
11
|
type ActionDefinition = {
|
|
11
12
|
identifier?: string;
|
|
@@ -61,6 +62,7 @@ export function ActionButtonController({
|
|
|
61
62
|
const resolvedEntry = entry;
|
|
62
63
|
const resolvedIdentifier = action?.identifier || pluginIdentifier || "";
|
|
63
64
|
const actionContext = useActions(resolvedIdentifier);
|
|
65
|
+
const component = useUIComponentContext();
|
|
64
66
|
|
|
65
67
|
const actionDisabled =
|
|
66
68
|
typeof actionContext?.isActionAvailable === "function" &&
|
|
@@ -128,20 +130,33 @@ export function ActionButtonController({
|
|
|
128
130
|
return;
|
|
129
131
|
}
|
|
130
132
|
|
|
133
|
+
const invokeOptions: InvokeArgsOptions = {
|
|
134
|
+
...(component ? { component } : {}),
|
|
135
|
+
};
|
|
136
|
+
|
|
131
137
|
if (supportsEntryState) {
|
|
132
138
|
return actionContext.invokeAction?.(resolvedEntry, {
|
|
139
|
+
...invokeOptions,
|
|
133
140
|
updateState: setActionState,
|
|
134
141
|
});
|
|
135
142
|
}
|
|
136
143
|
|
|
144
|
+
if (typeof actionContext.invokeAction === "function") {
|
|
145
|
+
return actionContext.invokeAction(resolvedEntry, invokeOptions);
|
|
146
|
+
}
|
|
147
|
+
|
|
137
148
|
const favouritesAction = legacySelected
|
|
138
149
|
? actionContext.removeFavourite
|
|
139
150
|
: actionContext.addFavourite;
|
|
140
151
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
152
|
+
return favouritesAction?.(resolvedEntry);
|
|
153
|
+
}, [
|
|
154
|
+
actionContext,
|
|
155
|
+
supportsEntryState,
|
|
156
|
+
resolvedEntry,
|
|
157
|
+
legacySelected,
|
|
158
|
+
component,
|
|
159
|
+
]);
|
|
145
160
|
|
|
146
161
|
if (!actionContext || actionDisabled) {
|
|
147
162
|
if (!actionContext) {
|
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { Text } from "react-native";
|
|
3
3
|
import { render, fireEvent } from "@testing-library/react-native";
|
|
4
4
|
import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
|
|
5
|
+
import { UIComponentContext } from "@applicaster/zapp-react-native-ui-components/Contexts/UIComponentContext";
|
|
5
6
|
|
|
6
7
|
import { ActionButtonController } from "../ActionButtonController";
|
|
7
8
|
|
|
@@ -89,6 +90,47 @@ describe("ActionButtonController", () => {
|
|
|
89
90
|
);
|
|
90
91
|
});
|
|
91
92
|
|
|
93
|
+
it("passes the List UIComponentContext into invokeAction so the sheet can refresh it", () => {
|
|
94
|
+
const listComponent = {
|
|
95
|
+
id: "list-1",
|
|
96
|
+
data: { source: "https://example.com/user/collections/abc" },
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const actionContext = {
|
|
100
|
+
isActionAvailable: jest.fn(() => true),
|
|
101
|
+
initialEntryState: jest.fn(() => ({ active: false })),
|
|
102
|
+
invokeAction: jest.fn(),
|
|
103
|
+
addListener: jest.fn(() => jest.fn()),
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
mockUseActions.mockReturnValue(actionContext);
|
|
107
|
+
|
|
108
|
+
const { getByTestId } = render(
|
|
109
|
+
<UIComponentContext.Provider value={listComponent}>
|
|
110
|
+
<ActionButtonController
|
|
111
|
+
action={{ identifier: "open-modal-bottom-sheet-cell-action" }}
|
|
112
|
+
entry={entry}
|
|
113
|
+
>
|
|
114
|
+
{({ onPress }) => (
|
|
115
|
+
<Text testID="content" onPress={onPress}>
|
|
116
|
+
press
|
|
117
|
+
</Text>
|
|
118
|
+
)}
|
|
119
|
+
</ActionButtonController>
|
|
120
|
+
</UIComponentContext.Provider>
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
fireEvent.press(getByTestId("content"));
|
|
124
|
+
|
|
125
|
+
expect(actionContext.invokeAction).toHaveBeenCalledWith(
|
|
126
|
+
entry,
|
|
127
|
+
expect.objectContaining({
|
|
128
|
+
updateState: expect.any(Function),
|
|
129
|
+
component: listComponent,
|
|
130
|
+
})
|
|
131
|
+
);
|
|
132
|
+
});
|
|
133
|
+
|
|
92
134
|
it("updates state from addListener", () => {
|
|
93
135
|
let listener;
|
|
94
136
|
|
|
@@ -328,7 +370,7 @@ describe("ActionButtonController", () => {
|
|
|
328
370
|
|
|
329
371
|
fireEvent.press(getByTestId("content"));
|
|
330
372
|
|
|
331
|
-
expect(invokeAction).toHaveBeenCalledWith(entry);
|
|
373
|
+
expect(invokeAction).toHaveBeenCalledWith(entry, {});
|
|
332
374
|
expect(addFavourite).not.toHaveBeenCalled();
|
|
333
375
|
expect(removeFavourite).not.toHaveBeenCalled();
|
|
334
376
|
});
|
|
@@ -91,6 +91,7 @@ function ButtonComponent(props: Props) {
|
|
|
91
91
|
onPress={onPress}
|
|
92
92
|
testID={props?.testID || `${item?.id}`}
|
|
93
93
|
accessibilityLabel={props?.accessibilityLabel || `${item?.id}`}
|
|
94
|
+
accessibilityRole="button"
|
|
94
95
|
accessible={!!(props?.testID || props?.accessibilityLabel)}
|
|
95
96
|
style={props?.style}
|
|
96
97
|
>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
|
|
1
|
+
import { getPluginByIdentifier } from "@applicaster/zapp-react-native-utils/pluginUtils";
|
|
3
2
|
import { loggerLiveImageManager } from "../../../VideoLive/loggerHelper";
|
|
4
3
|
|
|
5
4
|
const { log_debug, log_error } = loggerLiveImageManager;
|
|
@@ -74,10 +73,9 @@ export async function executePreloadHooks({
|
|
|
74
73
|
let payload: any = entry;
|
|
75
74
|
|
|
76
75
|
let needsAbort = false;
|
|
77
|
-
const plugins = appStore.get("plugins");
|
|
78
76
|
|
|
79
77
|
for (const hookConfig of sortedHooks) {
|
|
80
|
-
const plugin =
|
|
78
|
+
const plugin = getPluginByIdentifier(hookConfig.identifier, true);
|
|
81
79
|
|
|
82
80
|
if (!plugin?.module) {
|
|
83
81
|
log_debug(
|
|
@@ -8,7 +8,7 @@ import Image from "../Image";
|
|
|
8
8
|
import { useTrackCurrentAutoScrollingElement } from "@applicaster/zapp-react-native-utils/reactHooks/autoscrolling/useTrackCurrentAutoScrollingElement";
|
|
9
9
|
import { useUIComponentContext } from "@applicaster/zapp-react-native-ui-components/Contexts/UIComponentContext";
|
|
10
10
|
import { getPropComponentType } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
11
|
-
import {
|
|
11
|
+
import { getPluginByIdentifier } from "@applicaster/zapp-react-native-utils/pluginUtils";
|
|
12
12
|
import { useAccessibilityState } from "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks";
|
|
13
13
|
|
|
14
14
|
type LiveImageProps = {
|
|
@@ -245,13 +245,21 @@ const LiveImageComponent = (props: LiveImageProps) => {
|
|
|
245
245
|
|
|
246
246
|
const isCurrentlyFocused = useTrackCurrentAutoScrollingElement(componentId);
|
|
247
247
|
|
|
248
|
-
|
|
249
|
-
|
|
248
|
+
// New object identities here restart PlayerLiveImage's register effect,
|
|
249
|
+
// which throws away the in-flight player and runs preload hooks again.
|
|
250
|
+
const playerConfig = React.useMemo(
|
|
251
|
+
() => getPlayerConfig(player_screen_id, actionIdentifier),
|
|
252
|
+
[player_screen_id, actionIdentifier]
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
const { playerPluginId, screenConfig, preloadHooks } = playerConfig ?? {};
|
|
250
256
|
|
|
251
|
-
const playableEntry =
|
|
252
|
-
|
|
257
|
+
const playableEntry = React.useMemo(
|
|
258
|
+
() => (playerPluginId ? getPlayableEntry(item) : null),
|
|
259
|
+
[playerPluginId, item?.id]
|
|
260
|
+
);
|
|
253
261
|
|
|
254
|
-
const playerPlugin =
|
|
262
|
+
const playerPlugin = getPluginByIdentifier(playerPluginId);
|
|
255
263
|
|
|
256
264
|
const isShouldRender =
|
|
257
265
|
playerPlugin &&
|
|
@@ -16,13 +16,7 @@ type Props = {
|
|
|
16
16
|
export const Toggle = (props: Props) => {
|
|
17
17
|
const { style, item, action, cellState } = props;
|
|
18
18
|
|
|
19
|
-
const {
|
|
20
|
-
trackColor,
|
|
21
|
-
trackColorActive,
|
|
22
|
-
thumbColor,
|
|
23
|
-
thumbColorActive,
|
|
24
|
-
iosBackgroundColor,
|
|
25
|
-
} = style;
|
|
19
|
+
const { trackColor, trackColorActive, thumbColor, thumbColorActive } = style;
|
|
26
20
|
|
|
27
21
|
// `focused_selected` is the selected state with a finger on the row, so the
|
|
28
22
|
// switch has to read as on for both. Leaving it out reads a pressed selected
|
|
@@ -73,7 +67,6 @@ export const Toggle = (props: Props) => {
|
|
|
73
67
|
<Switch
|
|
74
68
|
trackColor={{ false: trackColor, true: trackColorActive }}
|
|
75
69
|
thumbColor={isSelected ? thumbColorActive : thumbColor}
|
|
76
|
-
ios_backgroundColor={iosBackgroundColor}
|
|
77
70
|
onValueChange={onPress}
|
|
78
71
|
value={isSelected}
|
|
79
72
|
/>
|
|
@@ -25,7 +25,6 @@ const style = {
|
|
|
25
25
|
trackColorActive: "rgba(4,207,153,1)",
|
|
26
26
|
thumbColor: "rgba(255,255,255,1)",
|
|
27
27
|
thumbColorActive: "rgba(255,255,255,1)",
|
|
28
|
-
iosBackgroundColor: "rgba(0,0,0,1)",
|
|
29
28
|
} as any;
|
|
30
29
|
|
|
31
30
|
const item = { id: "true", title: "I agree" } as any;
|
|
@@ -87,10 +86,6 @@ describe("Toggle with an empty action identifier", () => {
|
|
|
87
86
|
expect(mockInitialEntryState).not.toHaveBeenCalled();
|
|
88
87
|
});
|
|
89
88
|
|
|
90
|
-
// ios_backgroundColor paints behind the track, so trackColor does not cover
|
|
91
|
-
// it and it has to be forwarded on its own. It was dropped once while the
|
|
92
|
-
// destructure feeding it was being reformatted, and nothing caught that.
|
|
93
|
-
//
|
|
94
89
|
// Asserted on the Switch element rather than the rendered host component:
|
|
95
90
|
// what Toggle owns is the props it hands to Switch, and React Native rewrites
|
|
96
91
|
// them into platform-specific ones (tintColor, a style entry) underneath.
|
|
@@ -100,9 +95,18 @@ describe("Toggle with an empty action identifier", () => {
|
|
|
100
95
|
expect(UNSAFE_getByType(Switch).props).toMatchObject({
|
|
101
96
|
trackColor: { false: style.trackColor, true: style.trackColorActive },
|
|
102
97
|
thumbColor: style.thumbColor,
|
|
103
|
-
ios_backgroundColor: style.iosBackgroundColor,
|
|
104
98
|
});
|
|
105
99
|
});
|
|
100
|
+
|
|
101
|
+
// ios_backgroundColor paints an opaque layer behind the track that the track
|
|
102
|
+
// color cannot cover, which on iOS reads as a halo around the switch. The
|
|
103
|
+
// switch is left on its platform default instead, so the prop must stay
|
|
104
|
+
// unset even if a style happens to carry a color for it.
|
|
105
|
+
it("does not set an iOS background color on the switch", () => {
|
|
106
|
+
const { UNSAFE_getByType } = renderToggle("", "default");
|
|
107
|
+
|
|
108
|
+
expect(UNSAFE_getByType(Switch).props.ios_backgroundColor).toBeUndefined();
|
|
109
|
+
});
|
|
106
110
|
});
|
|
107
111
|
|
|
108
112
|
describe("Toggle with an action plugin identifier", () => {
|
|
@@ -166,7 +166,7 @@ export const ActionButton = ({
|
|
|
166
166
|
<PressableView
|
|
167
167
|
testOnly_pressed={props.testOnly_pressed}
|
|
168
168
|
testID={props.testID || `${entry?.id}`}
|
|
169
|
-
style={style}
|
|
169
|
+
style={[style, props.alignment]}
|
|
170
170
|
pressedStyle={focusedStyles}
|
|
171
171
|
onPress={renderProps.onPress}
|
|
172
172
|
accessibilityLabel={props.accessibilityLabel || `${entry?.id}`}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Pressable, Text as RNText, View } from "react-native";
|
|
2
|
+
import { Pressable, StyleSheet, Text as RNText, View } from "react-native";
|
|
3
3
|
import { render, fireEvent } from "@testing-library/react-native";
|
|
4
4
|
import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
|
|
5
5
|
|
|
@@ -282,7 +282,9 @@ describe("MobileActionButton", () => {
|
|
|
282
282
|
expect(pressable.props.testID).toBe("mobile_action_button_1");
|
|
283
283
|
expect(pressable.props.accessibilityLabel).toBe("entry-1");
|
|
284
284
|
|
|
285
|
-
expect(
|
|
285
|
+
expect(
|
|
286
|
+
StyleSheet.flatten(pressable.props.style({ pressed: false }))
|
|
287
|
+
).toMatchObject({
|
|
286
288
|
backgroundColor: "rgba(1,1,1,1)",
|
|
287
289
|
borderColor: "rgba(2,2,2,1)",
|
|
288
290
|
borderWidth: 1,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CollapsibleTextContainer } from "../index";
|
|
2
|
+
|
|
3
|
+
const getValue = (key: string) => {
|
|
4
|
+
const values: Record<string, unknown> = {
|
|
5
|
+
text_alignment: "left",
|
|
6
|
+
margin_top: 0,
|
|
7
|
+
margin_right: 0,
|
|
8
|
+
margin_bottom: 0,
|
|
9
|
+
margin_left: 0,
|
|
10
|
+
padding_top: 0,
|
|
11
|
+
padding_right: 0,
|
|
12
|
+
padding_bottom: 0,
|
|
13
|
+
padding_left: 0,
|
|
14
|
+
corner_radius: 0,
|
|
15
|
+
data_key: "title",
|
|
16
|
+
custom_data_key: undefined,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return values[key];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
describe("CollapsibleTextContainer view tree", () => {
|
|
23
|
+
it("aligns the label to the text alignment instead of stretching the cell", () => {
|
|
24
|
+
const result = CollapsibleTextContainer({
|
|
25
|
+
getValue,
|
|
26
|
+
elements: [],
|
|
27
|
+
additionalStyles: { backgroundColor: "transparent" },
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
expect(result.style.alignSelf).toBe("flex-start");
|
|
31
|
+
});
|
|
32
|
+
});
|