@applicaster/zapp-react-native-utils 16.0.0-rc.118 → 16.0.0-rc.119
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/cellUtils/__tests__/getButtonsEnabled.test.ts +28 -0
- package/cellUtils/__tests__/getCellNavigationEnabled.test.ts +36 -0
- package/cellUtils/__tests__/getIsCellNavigationEnabled.test.ts +35 -0
- package/cellUtils/__tests__/isCellNavigationEnabled.test.ts +21 -0
- package/cellUtils/index.ts +40 -0
- package/manifestUtils/keys.js +6 -0
- package/manifestUtils/mobileAction/container/__tests__/mobileActionButtonsContainer.test.js +21 -0
- package/manifestUtils/mobileAction/groups/defaults.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getButtonsEnabled } from "..";
|
|
2
|
+
|
|
3
|
+
describe("getButtonsEnabled", () => {
|
|
4
|
+
it("returns true when the buttons container is enabled", () => {
|
|
5
|
+
expect(
|
|
6
|
+
getButtonsEnabled({ mobile_buttons_container_buttons_enabled: true })
|
|
7
|
+
).toBe(true);
|
|
8
|
+
|
|
9
|
+
expect(
|
|
10
|
+
getButtonsEnabled({ mobile_buttons_container_buttons_enabled: "true" })
|
|
11
|
+
).toBe(true);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("returns false when the buttons container is disabled", () => {
|
|
15
|
+
expect(
|
|
16
|
+
getButtonsEnabled({ mobile_buttons_container_buttons_enabled: false })
|
|
17
|
+
).toBe(false);
|
|
18
|
+
|
|
19
|
+
expect(
|
|
20
|
+
getButtonsEnabled({ mobile_buttons_container_buttons_enabled: "false" })
|
|
21
|
+
).toBe(false);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("returns false when the key or styles are missing", () => {
|
|
25
|
+
expect(getButtonsEnabled({})).toBe(false);
|
|
26
|
+
expect(getButtonsEnabled(undefined)).toBe(false);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { getCellNavigationEnabled } from "..";
|
|
2
|
+
|
|
3
|
+
describe("getCellNavigationEnabled", () => {
|
|
4
|
+
it("returns true when cell navigation is enabled", () => {
|
|
5
|
+
expect(
|
|
6
|
+
getCellNavigationEnabled({
|
|
7
|
+
mobile_buttons_container_cell_navigation_enabled: true,
|
|
8
|
+
})
|
|
9
|
+
).toBe(true);
|
|
10
|
+
|
|
11
|
+
expect(
|
|
12
|
+
getCellNavigationEnabled({
|
|
13
|
+
mobile_buttons_container_cell_navigation_enabled: "true",
|
|
14
|
+
})
|
|
15
|
+
).toBe(true);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("returns false when cell navigation is disabled", () => {
|
|
19
|
+
expect(
|
|
20
|
+
getCellNavigationEnabled({
|
|
21
|
+
mobile_buttons_container_cell_navigation_enabled: false,
|
|
22
|
+
})
|
|
23
|
+
).toBe(false);
|
|
24
|
+
|
|
25
|
+
expect(
|
|
26
|
+
getCellNavigationEnabled({
|
|
27
|
+
mobile_buttons_container_cell_navigation_enabled: "false",
|
|
28
|
+
})
|
|
29
|
+
).toBe(false);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("returns false when the key or styles are missing", () => {
|
|
33
|
+
expect(getCellNavigationEnabled({})).toBe(false);
|
|
34
|
+
expect(getCellNavigationEnabled(undefined)).toBe(false);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getIsCellNavigationEnabled } from "..";
|
|
2
|
+
|
|
3
|
+
describe("getIsCellNavigationEnabled", () => {
|
|
4
|
+
it("is disabled when buttons are enabled and cell navigation is off", () => {
|
|
5
|
+
expect(
|
|
6
|
+
getIsCellNavigationEnabled({
|
|
7
|
+
mobile_buttons_container_buttons_enabled: true,
|
|
8
|
+
mobile_buttons_container_cell_navigation_enabled: false,
|
|
9
|
+
})
|
|
10
|
+
).toBe(false);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("is enabled when buttons and cell navigation are both on", () => {
|
|
14
|
+
expect(
|
|
15
|
+
getIsCellNavigationEnabled({
|
|
16
|
+
mobile_buttons_container_buttons_enabled: true,
|
|
17
|
+
mobile_buttons_container_cell_navigation_enabled: true,
|
|
18
|
+
})
|
|
19
|
+
).toBe(true);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("is enabled when buttons are disabled", () => {
|
|
23
|
+
expect(
|
|
24
|
+
getIsCellNavigationEnabled({
|
|
25
|
+
mobile_buttons_container_buttons_enabled: false,
|
|
26
|
+
mobile_buttons_container_cell_navigation_enabled: false,
|
|
27
|
+
})
|
|
28
|
+
).toBe(true);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("is enabled when the keys or styles are missing", () => {
|
|
32
|
+
expect(getIsCellNavigationEnabled({})).toBe(true);
|
|
33
|
+
expect(getIsCellNavigationEnabled(undefined)).toBe(true);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isCellNavigationEnabled } from "..";
|
|
2
|
+
|
|
3
|
+
describe("isCellNavigationEnabled", () => {
|
|
4
|
+
it("is enabled when buttons are disabled, regardless of the toggle", () => {
|
|
5
|
+
expect(isCellNavigationEnabled(false, false)).toBe(true);
|
|
6
|
+
expect(isCellNavigationEnabled(false, true)).toBe(true);
|
|
7
|
+
expect(isCellNavigationEnabled(undefined, undefined)).toBe(true);
|
|
8
|
+
expect(isCellNavigationEnabled("false", false)).toBe(true);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("is disabled when buttons are enabled and the toggle is off or missing", () => {
|
|
12
|
+
expect(isCellNavigationEnabled(true, false)).toBe(false);
|
|
13
|
+
expect(isCellNavigationEnabled(true, undefined)).toBe(false);
|
|
14
|
+
expect(isCellNavigationEnabled("true", "false")).toBe(false);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("is enabled when buttons and the toggle are both enabled", () => {
|
|
18
|
+
expect(isCellNavigationEnabled(true, true)).toBe(true);
|
|
19
|
+
expect(isCellNavigationEnabled("true", "true")).toBe(true);
|
|
20
|
+
});
|
|
21
|
+
});
|
package/cellUtils/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
|
12
12
|
import { isNotNil } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
|
|
13
13
|
|
|
14
14
|
import { toNumberWithDefault, toNumberWithDefaultZero } from "../numberUtils";
|
|
15
|
+
import { isTrue } from "../booleanUtils";
|
|
15
16
|
|
|
16
17
|
const CUSTOM_KEY = "other";
|
|
17
18
|
|
|
@@ -572,3 +573,42 @@ export const hasTextLabelsEnabled = (
|
|
|
572
573
|
return Boolean(value);
|
|
573
574
|
});
|
|
574
575
|
};
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Reads the mobile buttons container "buttons enabled" switch from cell styles.
|
|
579
|
+
*/
|
|
580
|
+
export const getButtonsEnabled = (styles?: Record<string, any>): boolean => {
|
|
581
|
+
return isTrue(styles?.mobile_buttons_container_buttons_enabled);
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Reads the mobile buttons container "cell navigation enabled" switch from cell styles.
|
|
586
|
+
*/
|
|
587
|
+
export const getCellNavigationEnabled = (
|
|
588
|
+
styles?: Record<string, any>
|
|
589
|
+
): boolean => {
|
|
590
|
+
return isTrue(styles?.mobile_buttons_container_cell_navigation_enabled);
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Whether tapping a cell outside its action buttons triggers the cell's navigation.
|
|
595
|
+
* Always true when the buttons are disabled.
|
|
596
|
+
* @param buttonsEnabled the cell's "buttons enabled" switch value
|
|
597
|
+
* @param cellNavigationEnabled the cell's "cell navigation enabled" switch value
|
|
598
|
+
*/
|
|
599
|
+
export const isCellNavigationEnabled = (
|
|
600
|
+
buttonsEnabled: unknown,
|
|
601
|
+
cellNavigationEnabled: unknown
|
|
602
|
+
): boolean => !isTrue(buttonsEnabled) || isTrue(cellNavigationEnabled);
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Whether tapping a mobile cell outside its action buttons triggers the cell's navigation,
|
|
606
|
+
* read from the cell styles.
|
|
607
|
+
*/
|
|
608
|
+
export const getIsCellNavigationEnabled = (
|
|
609
|
+
styles?: Record<string, any>
|
|
610
|
+
): boolean =>
|
|
611
|
+
isCellNavigationEnabled(
|
|
612
|
+
getButtonsEnabled(styles),
|
|
613
|
+
getCellNavigationEnabled(styles)
|
|
614
|
+
);
|
package/manifestUtils/keys.js
CHANGED
|
@@ -412,6 +412,12 @@ const mobileActionButtonContainerFields = (positionOptions) => [
|
|
|
412
412
|
type: ZAPPIFEST_FIELDS.switch,
|
|
413
413
|
suffix: "buttons enabled",
|
|
414
414
|
},
|
|
415
|
+
{
|
|
416
|
+
type: ZAPPIFEST_FIELDS.switch,
|
|
417
|
+
suffix: "cell navigation enabled",
|
|
418
|
+
label_tooltip:
|
|
419
|
+
"Controls whether tapping on the cell (outside the buttons) triggers its navigation behavior. When disabled, only the configured buttons are interactive. Useful for Home screens (tap anywhere to open) vs. Details screens (only buttons should work).",
|
|
420
|
+
},
|
|
415
421
|
{
|
|
416
422
|
type: ZAPPIFEST_FIELDS.select,
|
|
417
423
|
suffix: "position",
|
|
@@ -7,6 +7,7 @@ describe("mobileActionButtonsContainer", () => {
|
|
|
7
7
|
description: "container",
|
|
8
8
|
defaults: {
|
|
9
9
|
buttonsEnabled: false,
|
|
10
|
+
cellNavigationEnabled: false,
|
|
10
11
|
position: ["over_image", "text_label_1", "text_label_2"],
|
|
11
12
|
align: "left",
|
|
12
13
|
overImagePosition: "bottom_left",
|
|
@@ -31,6 +32,26 @@ describe("mobileActionButtonsContainer", () => {
|
|
|
31
32
|
expect(enabledField).toBeTruthy();
|
|
32
33
|
expect(enabledField.type).toBe("switch");
|
|
33
34
|
|
|
35
|
+
const cellNavigationField = result.fields.find(
|
|
36
|
+
(field) =>
|
|
37
|
+
field.key === "mobile_buttons_container_cell_navigation_enabled"
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
expect(cellNavigationField).toMatchObject({
|
|
41
|
+
type: "switch",
|
|
42
|
+
label: "Cell navigation enabled",
|
|
43
|
+
initial_value: false,
|
|
44
|
+
label_tooltip: expect.stringContaining(
|
|
45
|
+
"Controls whether tapping on the cell"
|
|
46
|
+
),
|
|
47
|
+
conditional_fields: [
|
|
48
|
+
{
|
|
49
|
+
key: "styles/mobile_buttons_container_buttons_enabled",
|
|
50
|
+
condition_value: true,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
});
|
|
54
|
+
|
|
34
55
|
const positionField = result.fields.find(
|
|
35
56
|
(field) => field.key === "mobile_buttons_container_position"
|
|
36
57
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "16.0.0-rc.
|
|
3
|
+
"version": "16.0.0-rc.119",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@applicaster/applicaster-types": "16.0.0-rc.
|
|
30
|
+
"@applicaster/applicaster-types": "16.0.0-rc.119",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|