@applicaster/zapp-react-native-utils 13.0.0-rc.98 → 14.0.0-alpha.1054425138
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/actionsExecutor/ActionExecutorContext.tsx +86 -66
- package/actionsExecutor/ScreenActions.ts +90 -0
- package/actionsExecutor/StorageActions.ts +110 -0
- package/actionsExecutor/consts.ts +4 -0
- package/appUtils/__tests__/__snapshots__/localizationsHelper.test.ts.snap +151 -0
- package/appUtils/__tests__/allZappLocales.ts +79 -0
- package/appUtils/__tests__/{localizationsHelper.test.js → localizationsHelper.test.ts} +11 -0
- package/appUtils/accessibilityManager/const.ts +18 -0
- package/appUtils/contextKeysManager/contextResolver.ts +15 -1
- package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +1 -0
- package/appUtils/focusManager/index.ios.ts +14 -4
- package/appUtils/focusManager/utils/__tests__/findChild.test.ts +35 -0
- package/appUtils/focusManager/utils/index.ts +5 -0
- package/appUtils/localizationsHelper.ts +10 -2
- package/appUtils/playerManager/playerHooks/usePlayerCurrentTime.tsx +11 -7
- package/cellUtils/index.ts +9 -5
- package/componentsUtils/index.ts +8 -1
- package/localizationUtils/index.ts +3 -3
- package/manifestUtils/defaultManifestConfigurations/generalContent.js +13 -0
- package/manifestUtils/defaultManifestConfigurations/player.js +0 -8
- package/manifestUtils/index.js +2 -0
- package/manifestUtils/keys.js +27 -2
- package/navigationUtils/__tests__/navigationUtils.test.js +0 -65
- package/navigationUtils/index.ts +0 -31
- package/package.json +2 -2
- package/playerUtils/configurationGenerator.ts +0 -16
- package/playerUtils/index.ts +17 -0
- package/reactHooks/app/useAppState.ts +2 -2
- package/reactHooks/cell-click/index.ts +5 -1
- package/reactHooks/feed/useBatchLoading.ts +10 -12
- package/reactHooks/feed/useFeedLoader.tsx +13 -6
- package/reactHooks/navigation/{useGetTabBarHeight.ts → getTabBarHeight.ts} +1 -1
- package/reactHooks/navigation/useGetBottomTabBarHeight.ts +10 -3
- package/reactHooks/navigation/useNavigationPluginData.ts +8 -4
- package/reactHooks/navigation/useNavigationType.ts +4 -2
- package/reactHooks/screen/__tests__/useScreenBackgroundColor.test.tsx +69 -0
- package/reactHooks/screen/useScreenBackgroundColor.ts +3 -15
- package/reactHooks/state/README.md +79 -0
- package/reactHooks/state/ZStoreProvider.tsx +71 -0
- package/reactHooks/state/__tests__/ZStoreProvider.test.tsx +66 -0
- package/reactHooks/state/index.ts +2 -0
- package/reactHooks/useListenEventBusEvent.ts +1 -1
- package/reactUtils/index.ts +9 -0
- package/typeGuards/index.ts +3 -0
- package/utils/index.ts +1 -1
- package/zappFrameworkUtils/localStorageHelper.ts +32 -10
|
@@ -5,13 +5,17 @@ import {
|
|
|
5
5
|
actionExecutor as _actionExecutor,
|
|
6
6
|
ActionResult,
|
|
7
7
|
} from "./ActionExecutor";
|
|
8
|
-
import {
|
|
9
|
-
|
|
8
|
+
import {
|
|
9
|
+
batchRemoveAllFromNamespaceForStorage,
|
|
10
|
+
batchSave,
|
|
11
|
+
} from "../zappFrameworkUtils/localStorageHelper";
|
|
12
|
+
import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
|
|
13
|
+
|
|
10
14
|
import * as QuickBrickManager from "@applicaster/zapp-react-native-bridge/QuickBrick";
|
|
15
|
+
import { QUICK_BRICK_EVENTS } from "@applicaster/zapp-react-native-bridge/QuickBrick";
|
|
11
16
|
import { showConfirmationDialog } from "../alertUtils";
|
|
12
17
|
import { createCloudEvent, sendCloudEvent } from "../cloudEventsUtils";
|
|
13
18
|
import { createLogger } from "../logger";
|
|
14
|
-
import { StorageMultiSelectProvider } from "@applicaster/zapp-react-native-bridge/ZappStorage/StorageMultiSelectProvider";
|
|
15
19
|
import { ACTIVE_LAYOUT_ID_STORAGE_KEY } from "@applicaster/quick-brick-core/App/remoteContextReloader/consts";
|
|
16
20
|
import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
|
|
17
21
|
import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
|
|
@@ -20,12 +24,20 @@ import {
|
|
|
20
24
|
resolveObjectValues,
|
|
21
25
|
} from "../appUtils/contextKeysManager/contextResolver";
|
|
22
26
|
import { useNavigation } from "../reactHooks";
|
|
23
|
-
import { get } from "lodash";
|
|
24
27
|
|
|
25
28
|
import {
|
|
26
29
|
useContentTypes,
|
|
27
30
|
usePickFromState,
|
|
28
31
|
} from "@applicaster/zapp-react-native-redux/hooks";
|
|
32
|
+
import { useSubscriberFor } from "../reactHooks/useSubscriberFor";
|
|
33
|
+
import { APP_EVENTS } from "../appUtils/events";
|
|
34
|
+
import {
|
|
35
|
+
localStorageToggleFlag,
|
|
36
|
+
sessionStorageToggleFlag,
|
|
37
|
+
} from "./StorageActions";
|
|
38
|
+
|
|
39
|
+
import { ScreenSingleValueProvider } from "@applicaster/zapp-react-native-bridge/ZappStorage/ScreenSingleValueProvider";
|
|
40
|
+
import { screenSetVariable, screenToggleFlag } from "./ScreenActions";
|
|
29
41
|
|
|
30
42
|
export const { log_error, log_info, log_debug } = createLogger({
|
|
31
43
|
subsystem: "ActionExecutorContext",
|
|
@@ -77,7 +89,15 @@ function findParentComponent(
|
|
|
77
89
|
const prepareDefaultActions = (actionExecutor) => {
|
|
78
90
|
actionExecutor.registerAction("localStorageSet", async (action) => {
|
|
79
91
|
const namespaces = action.options.content;
|
|
80
|
-
await
|
|
92
|
+
await batchSave(namespaces, localStorage);
|
|
93
|
+
// TODO: Add support for ownershipKey and ownershipNamespace
|
|
94
|
+
|
|
95
|
+
return ActionResult.Success;
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
actionExecutor.registerAction("sessionStorageSet", async (action) => {
|
|
99
|
+
const namespaces = action.options.content;
|
|
100
|
+
await batchSave(namespaces, sessionStorage);
|
|
81
101
|
// TODO: Add support for ownershipKey and ownershipNamespace
|
|
82
102
|
|
|
83
103
|
return ActionResult.Success;
|
|
@@ -134,15 +154,13 @@ const prepareDefaultActions = (actionExecutor) => {
|
|
|
134
154
|
actionExecutor.registerAction("confirmDialog", async (action) => {
|
|
135
155
|
log_info("handleAction: confirmDialog event");
|
|
136
156
|
|
|
137
|
-
|
|
157
|
+
return new Promise<ActionResult>((resolve) => {
|
|
138
158
|
showConfirmationDialog({
|
|
139
159
|
...action.options,
|
|
140
160
|
confirmCompletion: () => resolve(ActionResult.Success),
|
|
141
161
|
cancelCompletion: () => resolve(ActionResult.Cancel),
|
|
142
162
|
});
|
|
143
163
|
});
|
|
144
|
-
|
|
145
|
-
return confirmationPromise;
|
|
146
164
|
});
|
|
147
165
|
|
|
148
166
|
actionExecutor.registerAction("sendCloudEvent", async (action, context) => {
|
|
@@ -151,10 +169,16 @@ const prepareDefaultActions = (actionExecutor) => {
|
|
|
151
169
|
|
|
152
170
|
const entry = context?.entry || {};
|
|
153
171
|
const entryResolver = new EntryResolver(entry);
|
|
172
|
+
const route = context.screenRoute;
|
|
173
|
+
const screenData = ScreenSingleValueProvider.getState(route) as any;
|
|
174
|
+
const screenResolver = new EntryResolver(screenData || {});
|
|
154
175
|
|
|
155
176
|
const data =
|
|
156
177
|
options?.data && options.inflateData
|
|
157
|
-
? await resolveObjectValues(options.data, {
|
|
178
|
+
? await resolveObjectValues(options.data, {
|
|
179
|
+
entry: entryResolver,
|
|
180
|
+
screen: screenResolver,
|
|
181
|
+
})
|
|
158
182
|
: options?.data || entry;
|
|
159
183
|
|
|
160
184
|
const cloudEvent = await createCloudEvent({
|
|
@@ -189,73 +213,54 @@ const prepareDefaultActions = (actionExecutor) => {
|
|
|
189
213
|
});
|
|
190
214
|
|
|
191
215
|
actionExecutor.registerAction(
|
|
192
|
-
"
|
|
216
|
+
"sessionStorageToggleFlag",
|
|
193
217
|
async (
|
|
194
218
|
action: ActionType,
|
|
195
219
|
context?: Record<string, any>
|
|
196
220
|
): Promise<ActionResult> => {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
);
|
|
201
|
-
|
|
202
|
-
return ActionResult.Error;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
const entry = context?.entry as ZappEntry;
|
|
206
|
-
|
|
207
|
-
if (!entry) {
|
|
208
|
-
log_error(
|
|
209
|
-
"handleAction: localStorageToggleFlag action missing entry. Entry is required to get the tag."
|
|
210
|
-
);
|
|
211
|
-
|
|
212
|
-
return ActionResult.Error;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
const tag = action.options?.selector
|
|
216
|
-
? get(entry, action.options.selector)
|
|
217
|
-
: (entry.extensions?.tag ?? entry.id);
|
|
218
|
-
|
|
219
|
-
const keyNamespace = action.options?.key;
|
|
220
|
-
|
|
221
|
-
if (keyNamespace && tag) {
|
|
222
|
-
const multiSelectProvider =
|
|
223
|
-
StorageMultiSelectProvider.getProvider(keyNamespace);
|
|
224
|
-
|
|
225
|
-
const selectedItems = await multiSelectProvider.getSelectedAsync();
|
|
226
|
-
const isTagInSelectedItems = selectedItems.includes(tag);
|
|
227
|
-
|
|
228
|
-
log_info(
|
|
229
|
-
`handleAction: localStorageToggleFlag event will ${
|
|
230
|
-
isTagInSelectedItems ? "remove" : "add"
|
|
231
|
-
} tag: ${tag} for keyNamespace: ${keyNamespace}, current selectedItems: ${selectedItems}`
|
|
232
|
-
);
|
|
221
|
+
return await sessionStorageToggleFlag(context, action);
|
|
222
|
+
}
|
|
223
|
+
);
|
|
233
224
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
225
|
+
actionExecutor.registerAction(
|
|
226
|
+
"localStorageToggleFlag",
|
|
227
|
+
async (
|
|
228
|
+
action: ActionType,
|
|
229
|
+
context?: Record<string, any>
|
|
230
|
+
): Promise<ActionResult> => {
|
|
231
|
+
return await localStorageToggleFlag(context, action);
|
|
232
|
+
}
|
|
233
|
+
);
|
|
238
234
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
235
|
+
actionExecutor.registerAction(
|
|
236
|
+
"screenSetVariable",
|
|
237
|
+
async (
|
|
238
|
+
action: ActionType,
|
|
239
|
+
context?: Record<string, any>
|
|
240
|
+
): Promise<ActionResult> => {
|
|
241
|
+
const route = context?.screenRoute;
|
|
242
|
+
const { key, value } = action.options;
|
|
243
|
+
screenSetVariable(route, key, value);
|
|
243
244
|
|
|
244
|
-
|
|
245
|
-
|
|
245
|
+
return Promise.resolve(ActionResult.Success);
|
|
246
|
+
}
|
|
247
|
+
);
|
|
246
248
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
249
|
+
actionExecutor.registerAction(
|
|
250
|
+
"screenToggleFlag",
|
|
251
|
+
async (
|
|
252
|
+
action: ActionType,
|
|
253
|
+
context?: Record<string, any>
|
|
254
|
+
): Promise<ActionResult> => {
|
|
255
|
+
const screenRoute = context?.screenRoute;
|
|
254
256
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
+
await screenToggleFlag(
|
|
258
|
+
screenRoute,
|
|
259
|
+
{ entry: context?.entry, options: action.options },
|
|
260
|
+
action
|
|
261
|
+
);
|
|
257
262
|
|
|
258
|
-
return ActionResult.Success;
|
|
263
|
+
return Promise.resolve(ActionResult.Success);
|
|
259
264
|
}
|
|
260
265
|
);
|
|
261
266
|
};
|
|
@@ -281,9 +286,24 @@ export function withActionExecutor(Component) {
|
|
|
281
286
|
};
|
|
282
287
|
}, []);
|
|
283
288
|
|
|
289
|
+
useSubscriberFor(APP_EVENTS.onLogout, () => {
|
|
290
|
+
log_debug(
|
|
291
|
+
"User profile: onLogout event received, clearing user profile data"
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
const userAccountKey = "user_account";
|
|
295
|
+
void batchRemoveAllFromNamespaceForStorage(userAccountKey, localStorage);
|
|
296
|
+
|
|
297
|
+
void batchRemoveAllFromNamespaceForStorage(
|
|
298
|
+
userAccountKey,
|
|
299
|
+
sessionStorage
|
|
300
|
+
);
|
|
301
|
+
});
|
|
302
|
+
|
|
284
303
|
useEffect(() => {
|
|
285
304
|
return _actionExecutor.registerAction(
|
|
286
305
|
"navigateToScreen",
|
|
306
|
+
|
|
287
307
|
async (action: ActionType, context?: Record<string, any>) => {
|
|
288
308
|
const screenType = action.options?.typeMapping;
|
|
289
309
|
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
|
|
2
|
+
|
|
3
|
+
import { log_error, log_info } from "./ActionExecutorContext";
|
|
4
|
+
import { ActionResult } from "./ActionExecutor";
|
|
5
|
+
import { get } from "lodash";
|
|
6
|
+
|
|
7
|
+
import { ScreenMultiSelectProvider } from "@applicaster/zapp-react-native-bridge/ZappStorage/ScreenStateMultiSelectProvider";
|
|
8
|
+
import { onMaxTagsReached } from "./StorageActions";
|
|
9
|
+
|
|
10
|
+
export const screenSetVariable = (
|
|
11
|
+
_screenRoute: string,
|
|
12
|
+
_key: string,
|
|
13
|
+
_value: string
|
|
14
|
+
) => {};
|
|
15
|
+
|
|
16
|
+
export const screenToggleFlag = async (
|
|
17
|
+
screenRoute: string,
|
|
18
|
+
context: Record<string, any>,
|
|
19
|
+
action: ActionType
|
|
20
|
+
) => {
|
|
21
|
+
if (!context) {
|
|
22
|
+
log_error("handleAction: localStorageToggleFlag action missing context");
|
|
23
|
+
|
|
24
|
+
return ActionResult.Error;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const entry = context?.entry as ZappEntry;
|
|
28
|
+
|
|
29
|
+
if (!entry) {
|
|
30
|
+
log_error(
|
|
31
|
+
"handleAction: localStorageToggleFlag action missing entry. Entry is required to get the tag."
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return ActionResult.Error;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const tag = action.options?.selector
|
|
38
|
+
? get(entry, action.options.selector)
|
|
39
|
+
: (entry.extensions?.tag ?? entry.id);
|
|
40
|
+
|
|
41
|
+
const keyNamespace = action.options?.key;
|
|
42
|
+
|
|
43
|
+
if (keyNamespace && tag) {
|
|
44
|
+
const multiSelectProvider = ScreenMultiSelectProvider.getProvider(
|
|
45
|
+
keyNamespace,
|
|
46
|
+
screenRoute
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const selectedItems = await multiSelectProvider.getSelectedAsync();
|
|
50
|
+
const isTagInSelectedItems = selectedItems.includes(tag);
|
|
51
|
+
|
|
52
|
+
log_info(
|
|
53
|
+
`handleAction: screenToggleFlag event will ${
|
|
54
|
+
isTagInSelectedItems ? "remove" : "add"
|
|
55
|
+
} tag: ${tag} for keyNamespace: ${keyNamespace}, current selectedItems: ${selectedItems}`
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
if (selectedItems.includes(tag)) {
|
|
59
|
+
await multiSelectProvider.removeItem(tag);
|
|
60
|
+
} else {
|
|
61
|
+
const maxItems = action.options?.max_items;
|
|
62
|
+
|
|
63
|
+
if (maxItems && selectedItems.length >= maxItems) {
|
|
64
|
+
log_info(
|
|
65
|
+
`handleAction: screenToggleFlag event reached max items limit: ${maxItems}, cannot add tag: ${tag}`
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
await onMaxTagsReached({
|
|
69
|
+
selectedItems,
|
|
70
|
+
maxItems,
|
|
71
|
+
tag,
|
|
72
|
+
keyNamespace,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
return ActionResult.Cancel;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
await multiSelectProvider.addItem(tag);
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
log_error(
|
|
82
|
+
"handleAction: screenToggleFlag event missing keyNamespace or tag",
|
|
83
|
+
{ keyNamespace, tag }
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
return ActionResult.Error;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return ActionResult.Success;
|
|
90
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { ActionResult } from "./ActionExecutor";
|
|
2
|
+
import { get } from "lodash";
|
|
3
|
+
import { StorageMultiSelectProvider } from "@applicaster/zapp-react-native-bridge/ZappStorage/StorageMultiSelectProvider";
|
|
4
|
+
import { log_error, log_info } from "./ActionExecutorContext";
|
|
5
|
+
import { postEvent } from "../reactHooks/useSubscriberFor";
|
|
6
|
+
import { TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT } from "./consts";
|
|
7
|
+
import { StorageType } from "../appUtils/contextKeysManager/consts";
|
|
8
|
+
|
|
9
|
+
// send all data just in case (like for message string formatting)
|
|
10
|
+
// Type is not exported for now
|
|
11
|
+
type MaxTagsReachedEvent = {
|
|
12
|
+
selectedItems: string[];
|
|
13
|
+
maxItems: number;
|
|
14
|
+
tag: string;
|
|
15
|
+
keyNamespace: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export async function onMaxTagsReached(data: MaxTagsReachedEvent) {
|
|
19
|
+
postEvent(TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT, [data]);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export async function storageToggleFlag(
|
|
23
|
+
context: Record<string, any>,
|
|
24
|
+
action: ActionType,
|
|
25
|
+
storageType: StorageType
|
|
26
|
+
) {
|
|
27
|
+
if (!context) {
|
|
28
|
+
log_error("handleAction: localStorageToggleFlag action missing context");
|
|
29
|
+
|
|
30
|
+
return ActionResult.Error;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const entry = context?.entry as ZappEntry;
|
|
34
|
+
|
|
35
|
+
if (!entry) {
|
|
36
|
+
log_error(
|
|
37
|
+
"handleAction: localStorageToggleFlag action missing entry. Entry is required to get the tag."
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return ActionResult.Error;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const tag = action.options?.selector
|
|
44
|
+
? get(entry, action.options.selector)
|
|
45
|
+
: (entry.extensions?.tag ?? entry.id);
|
|
46
|
+
|
|
47
|
+
const keyNamespace = action.options?.key;
|
|
48
|
+
|
|
49
|
+
if (keyNamespace && tag) {
|
|
50
|
+
const multiSelectProvider = StorageMultiSelectProvider.getProvider(
|
|
51
|
+
keyNamespace,
|
|
52
|
+
storageType
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const selectedItems = await multiSelectProvider.getSelectedAsync();
|
|
56
|
+
const isTagInSelectedItems = selectedItems.includes(tag);
|
|
57
|
+
|
|
58
|
+
log_info(
|
|
59
|
+
`handleAction: localStorageToggleFlag event will ${
|
|
60
|
+
isTagInSelectedItems ? "remove" : "add"
|
|
61
|
+
} tag: ${tag} for keyNamespace: ${keyNamespace}, current selectedItems: ${selectedItems}`
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
if (selectedItems.includes(tag)) {
|
|
65
|
+
await multiSelectProvider.removeItem(tag);
|
|
66
|
+
} else {
|
|
67
|
+
const maxItems = action.options?.max_items;
|
|
68
|
+
|
|
69
|
+
if (maxItems && selectedItems.length >= maxItems) {
|
|
70
|
+
log_info(
|
|
71
|
+
`handleAction: localStorageToggleFlag event reached max items limit: ${maxItems}, cannot add tag: ${tag}`
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
await onMaxTagsReached({
|
|
75
|
+
selectedItems,
|
|
76
|
+
maxItems,
|
|
77
|
+
tag,
|
|
78
|
+
keyNamespace,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return ActionResult.Cancel;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
await multiSelectProvider.addItem(tag);
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
log_error(
|
|
88
|
+
"handleAction: localStorageToggleFlag event missing keyNamespace or tag",
|
|
89
|
+
{ keyNamespace, tag }
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
return ActionResult.Error;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return ActionResult.Success;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export async function sessionStorageToggleFlag(
|
|
99
|
+
context: Record<string, any>,
|
|
100
|
+
action: ActionType
|
|
101
|
+
) {
|
|
102
|
+
return storageToggleFlag(context, action, StorageType.session);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export async function localStorageToggleFlag(
|
|
106
|
+
context: Record<string, any>,
|
|
107
|
+
action: ActionType
|
|
108
|
+
) {
|
|
109
|
+
return storageToggleFlag(context, action, StorageType.local);
|
|
110
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`toDayJSLocaleMap [af] returns a valid dayjs locale 1`] = `"af"`;
|
|
4
|
+
|
|
5
|
+
exports[`toDayJSLocaleMap [ar] returns a valid dayjs locale 1`] = `"ar"`;
|
|
6
|
+
|
|
7
|
+
exports[`toDayJSLocaleMap [bg] returns a valid dayjs locale 1`] = `"bg"`;
|
|
8
|
+
|
|
9
|
+
exports[`toDayJSLocaleMap [bn] returns a valid dayjs locale 1`] = `"bn"`;
|
|
10
|
+
|
|
11
|
+
exports[`toDayJSLocaleMap [bo] returns a valid dayjs locale 1`] = `"bo"`;
|
|
12
|
+
|
|
13
|
+
exports[`toDayJSLocaleMap [ca] returns a valid dayjs locale 1`] = `"ca"`;
|
|
14
|
+
|
|
15
|
+
exports[`toDayJSLocaleMap [cs] returns a valid dayjs locale 1`] = `"cs"`;
|
|
16
|
+
|
|
17
|
+
exports[`toDayJSLocaleMap [da] returns a valid dayjs locale 1`] = `"da"`;
|
|
18
|
+
|
|
19
|
+
exports[`toDayJSLocaleMap [de] returns a valid dayjs locale 1`] = `"de"`;
|
|
20
|
+
|
|
21
|
+
exports[`toDayJSLocaleMap [el] returns a valid dayjs locale 1`] = `"el"`;
|
|
22
|
+
|
|
23
|
+
exports[`toDayJSLocaleMap [en] returns a valid dayjs locale 1`] = `"en"`;
|
|
24
|
+
|
|
25
|
+
exports[`toDayJSLocaleMap [en-GB] returns a valid dayjs locale 1`] = `"en-gb"`;
|
|
26
|
+
|
|
27
|
+
exports[`toDayJSLocaleMap [en-UK] returns a valid dayjs locale 1`] = `"en-gb"`;
|
|
28
|
+
|
|
29
|
+
exports[`toDayJSLocaleMap [es] returns a valid dayjs locale 1`] = `"es"`;
|
|
30
|
+
|
|
31
|
+
exports[`toDayJSLocaleMap [es-LA] returns a valid dayjs locale 1`] = `"es"`;
|
|
32
|
+
|
|
33
|
+
exports[`toDayJSLocaleMap [es-MX] returns a valid dayjs locale 1`] = `"es-mx"`;
|
|
34
|
+
|
|
35
|
+
exports[`toDayJSLocaleMap [es-US] returns a valid dayjs locale 1`] = `"es-us"`;
|
|
36
|
+
|
|
37
|
+
exports[`toDayJSLocaleMap [et] returns a valid dayjs locale 1`] = `"et"`;
|
|
38
|
+
|
|
39
|
+
exports[`toDayJSLocaleMap [eu] returns a valid dayjs locale 1`] = `"eu"`;
|
|
40
|
+
|
|
41
|
+
exports[`toDayJSLocaleMap [fa] returns a valid dayjs locale 1`] = `"fa"`;
|
|
42
|
+
|
|
43
|
+
exports[`toDayJSLocaleMap [fi] returns a valid dayjs locale 1`] = `"fi"`;
|
|
44
|
+
|
|
45
|
+
exports[`toDayJSLocaleMap [fj] returns a valid dayjs locale 1`] = `"en"`;
|
|
46
|
+
|
|
47
|
+
exports[`toDayJSLocaleMap [fr] returns a valid dayjs locale 1`] = `"fr"`;
|
|
48
|
+
|
|
49
|
+
exports[`toDayJSLocaleMap [ga] returns a valid dayjs locale 1`] = `"ga"`;
|
|
50
|
+
|
|
51
|
+
exports[`toDayJSLocaleMap [gu] returns a valid dayjs locale 1`] = `"gu"`;
|
|
52
|
+
|
|
53
|
+
exports[`toDayJSLocaleMap [he] returns a valid dayjs locale 1`] = `"he"`;
|
|
54
|
+
|
|
55
|
+
exports[`toDayJSLocaleMap [hi] returns a valid dayjs locale 1`] = `"hi"`;
|
|
56
|
+
|
|
57
|
+
exports[`toDayJSLocaleMap [hr] returns a valid dayjs locale 1`] = `"hr"`;
|
|
58
|
+
|
|
59
|
+
exports[`toDayJSLocaleMap [hu] returns a valid dayjs locale 1`] = `"hu"`;
|
|
60
|
+
|
|
61
|
+
exports[`toDayJSLocaleMap [hy] returns a valid dayjs locale 1`] = `"hy-am"`;
|
|
62
|
+
|
|
63
|
+
exports[`toDayJSLocaleMap [id] returns a valid dayjs locale 1`] = `"id"`;
|
|
64
|
+
|
|
65
|
+
exports[`toDayJSLocaleMap [is] returns a valid dayjs locale 1`] = `"is"`;
|
|
66
|
+
|
|
67
|
+
exports[`toDayJSLocaleMap [it] returns a valid dayjs locale 1`] = `"it"`;
|
|
68
|
+
|
|
69
|
+
exports[`toDayJSLocaleMap [ja] returns a valid dayjs locale 1`] = `"ja"`;
|
|
70
|
+
|
|
71
|
+
exports[`toDayJSLocaleMap [ka] returns a valid dayjs locale 1`] = `"ka"`;
|
|
72
|
+
|
|
73
|
+
exports[`toDayJSLocaleMap [km] returns a valid dayjs locale 1`] = `"km"`;
|
|
74
|
+
|
|
75
|
+
exports[`toDayJSLocaleMap [ko] returns a valid dayjs locale 1`] = `"ko"`;
|
|
76
|
+
|
|
77
|
+
exports[`toDayJSLocaleMap [la] returns a valid dayjs locale 1`] = `"en"`;
|
|
78
|
+
|
|
79
|
+
exports[`toDayJSLocaleMap [lt] returns a valid dayjs locale 1`] = `"lt"`;
|
|
80
|
+
|
|
81
|
+
exports[`toDayJSLocaleMap [lv] returns a valid dayjs locale 1`] = `"lv"`;
|
|
82
|
+
|
|
83
|
+
exports[`toDayJSLocaleMap [mi] returns a valid dayjs locale 1`] = `"mi"`;
|
|
84
|
+
|
|
85
|
+
exports[`toDayJSLocaleMap [mk] returns a valid dayjs locale 1`] = `"mk"`;
|
|
86
|
+
|
|
87
|
+
exports[`toDayJSLocaleMap [ml] returns a valid dayjs locale 1`] = `"ml"`;
|
|
88
|
+
|
|
89
|
+
exports[`toDayJSLocaleMap [mn] returns a valid dayjs locale 1`] = `"mn"`;
|
|
90
|
+
|
|
91
|
+
exports[`toDayJSLocaleMap [mr] returns a valid dayjs locale 1`] = `"mr"`;
|
|
92
|
+
|
|
93
|
+
exports[`toDayJSLocaleMap [ms] returns a valid dayjs locale 1`] = `"ms"`;
|
|
94
|
+
|
|
95
|
+
exports[`toDayJSLocaleMap [mt] returns a valid dayjs locale 1`] = `"mt"`;
|
|
96
|
+
|
|
97
|
+
exports[`toDayJSLocaleMap [ne] returns a valid dayjs locale 1`] = `"ne"`;
|
|
98
|
+
|
|
99
|
+
exports[`toDayJSLocaleMap [nl] returns a valid dayjs locale 1`] = `"nl"`;
|
|
100
|
+
|
|
101
|
+
exports[`toDayJSLocaleMap [no] returns a valid dayjs locale 1`] = `"en"`;
|
|
102
|
+
|
|
103
|
+
exports[`toDayJSLocaleMap [pa] returns a valid dayjs locale 1`] = `"pa-in"`;
|
|
104
|
+
|
|
105
|
+
exports[`toDayJSLocaleMap [pl] returns a valid dayjs locale 1`] = `"pl"`;
|
|
106
|
+
|
|
107
|
+
exports[`toDayJSLocaleMap [pt] returns a valid dayjs locale 1`] = `"pt"`;
|
|
108
|
+
|
|
109
|
+
exports[`toDayJSLocaleMap [pt-BR] returns a valid dayjs locale 1`] = `"pt-br"`;
|
|
110
|
+
|
|
111
|
+
exports[`toDayJSLocaleMap [qu] returns a valid dayjs locale 1`] = `"en"`;
|
|
112
|
+
|
|
113
|
+
exports[`toDayJSLocaleMap [ro] returns a valid dayjs locale 1`] = `"ro"`;
|
|
114
|
+
|
|
115
|
+
exports[`toDayJSLocaleMap [ru] returns a valid dayjs locale 1`] = `"ru"`;
|
|
116
|
+
|
|
117
|
+
exports[`toDayJSLocaleMap [sk] returns a valid dayjs locale 1`] = `"sk"`;
|
|
118
|
+
|
|
119
|
+
exports[`toDayJSLocaleMap [sl] returns a valid dayjs locale 1`] = `"sl"`;
|
|
120
|
+
|
|
121
|
+
exports[`toDayJSLocaleMap [sm] returns a valid dayjs locale 1`] = `"en"`;
|
|
122
|
+
|
|
123
|
+
exports[`toDayJSLocaleMap [sq] returns a valid dayjs locale 1`] = `"sq"`;
|
|
124
|
+
|
|
125
|
+
exports[`toDayJSLocaleMap [sr] returns a valid dayjs locale 1`] = `"sr"`;
|
|
126
|
+
|
|
127
|
+
exports[`toDayJSLocaleMap [sv] returns a valid dayjs locale 1`] = `"sv"`;
|
|
128
|
+
|
|
129
|
+
exports[`toDayJSLocaleMap [sw] returns a valid dayjs locale 1`] = `"sw"`;
|
|
130
|
+
|
|
131
|
+
exports[`toDayJSLocaleMap [ta] returns a valid dayjs locale 1`] = `"ta"`;
|
|
132
|
+
|
|
133
|
+
exports[`toDayJSLocaleMap [te] returns a valid dayjs locale 1`] = `"te"`;
|
|
134
|
+
|
|
135
|
+
exports[`toDayJSLocaleMap [th] returns a valid dayjs locale 1`] = `"th"`;
|
|
136
|
+
|
|
137
|
+
exports[`toDayJSLocaleMap [to] returns a valid dayjs locale 1`] = `"en"`;
|
|
138
|
+
|
|
139
|
+
exports[`toDayJSLocaleMap [tr] returns a valid dayjs locale 1`] = `"tr"`;
|
|
140
|
+
|
|
141
|
+
exports[`toDayJSLocaleMap [tt] returns a valid dayjs locale 1`] = `"en"`;
|
|
142
|
+
|
|
143
|
+
exports[`toDayJSLocaleMap [uk] returns a valid dayjs locale 1`] = `"uk"`;
|
|
144
|
+
|
|
145
|
+
exports[`toDayJSLocaleMap [ur] returns a valid dayjs locale 1`] = `"ur"`;
|
|
146
|
+
|
|
147
|
+
exports[`toDayJSLocaleMap [uz] returns a valid dayjs locale 1`] = `"uz"`;
|
|
148
|
+
|
|
149
|
+
exports[`toDayJSLocaleMap [vi] returns a valid dayjs locale 1`] = `"vi"`;
|
|
150
|
+
|
|
151
|
+
exports[`toDayJSLocaleMap [zh] returns a valid dayjs locale 1`] = `"zh"`;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export default [
|
|
2
|
+
// common locales from https://rubygems.org/gems/language_list
|
|
3
|
+
"en",
|
|
4
|
+
"fr",
|
|
5
|
+
"de",
|
|
6
|
+
"nl",
|
|
7
|
+
"ru",
|
|
8
|
+
"es",
|
|
9
|
+
"he",
|
|
10
|
+
"hy",
|
|
11
|
+
"sq",
|
|
12
|
+
"af",
|
|
13
|
+
"ar",
|
|
14
|
+
"eu",
|
|
15
|
+
"bn",
|
|
16
|
+
"bg",
|
|
17
|
+
"zh",
|
|
18
|
+
"cs",
|
|
19
|
+
"km",
|
|
20
|
+
"ca",
|
|
21
|
+
"hr",
|
|
22
|
+
"da",
|
|
23
|
+
"et",
|
|
24
|
+
"fj",
|
|
25
|
+
"fi",
|
|
26
|
+
"gu",
|
|
27
|
+
"ka",
|
|
28
|
+
"hu",
|
|
29
|
+
"hi",
|
|
30
|
+
"it",
|
|
31
|
+
"is",
|
|
32
|
+
"id",
|
|
33
|
+
"ga",
|
|
34
|
+
"ja",
|
|
35
|
+
"ko",
|
|
36
|
+
"la",
|
|
37
|
+
"lv",
|
|
38
|
+
"lt",
|
|
39
|
+
"ms",
|
|
40
|
+
"mi",
|
|
41
|
+
"mn",
|
|
42
|
+
"mt",
|
|
43
|
+
"mk",
|
|
44
|
+
"el",
|
|
45
|
+
"mr",
|
|
46
|
+
"ml",
|
|
47
|
+
"ne",
|
|
48
|
+
"no",
|
|
49
|
+
"pa",
|
|
50
|
+
"pl",
|
|
51
|
+
"pt",
|
|
52
|
+
"fa",
|
|
53
|
+
"qu",
|
|
54
|
+
"ro",
|
|
55
|
+
"sk",
|
|
56
|
+
"sm",
|
|
57
|
+
"sr",
|
|
58
|
+
"sw",
|
|
59
|
+
"sv",
|
|
60
|
+
"sl",
|
|
61
|
+
"to",
|
|
62
|
+
"tr",
|
|
63
|
+
"th",
|
|
64
|
+
"te",
|
|
65
|
+
"bo",
|
|
66
|
+
"tt",
|
|
67
|
+
"ta",
|
|
68
|
+
"uk",
|
|
69
|
+
"ur",
|
|
70
|
+
"uz",
|
|
71
|
+
"vi",
|
|
72
|
+
// Extra locales https://github.com/applicaster/zapp/blob/5604794f15cfd270ae494b0db85e542de4cebfaa/config/additional_languages.yml
|
|
73
|
+
"en-UK",
|
|
74
|
+
"en-GB",
|
|
75
|
+
"es-LA",
|
|
76
|
+
"pt-BR",
|
|
77
|
+
"es-MX",
|
|
78
|
+
"es-US",
|
|
79
|
+
];
|
|
@@ -8,6 +8,7 @@ const {
|
|
|
8
8
|
getLocale,
|
|
9
9
|
getLanguageCode,
|
|
10
10
|
getCountryCode,
|
|
11
|
+
toDayJSLocaleMap,
|
|
11
12
|
} = require("../localizationsHelper");
|
|
12
13
|
|
|
13
14
|
describe("getLocale", () => {
|
|
@@ -69,3 +70,13 @@ describe("getCountryCode", () => {
|
|
|
69
70
|
expect(currentValue).toEqual(expectedValue);
|
|
70
71
|
});
|
|
71
72
|
});
|
|
73
|
+
|
|
74
|
+
describe("toDayJSLocaleMap", () => {
|
|
75
|
+
const allZappLocales: string[] = require("./allZappLocales").default;
|
|
76
|
+
|
|
77
|
+
it.each(allZappLocales)("[%s] returns a valid dayjs locale", (locale) => {
|
|
78
|
+
const dayJSLocale = toDayJSLocaleMap(locale);
|
|
79
|
+
expect(dayJSLocale).toBeDefined();
|
|
80
|
+
expect(dayJSLocale).toMatchSnapshot();
|
|
81
|
+
});
|
|
82
|
+
});
|