@developer_tribe/react-builder 1.2.45 → 1.2.47

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.
Files changed (83) hide show
  1. package/dist/attributes-editor/Field.d.ts +3 -1
  2. package/dist/attributes-editor/attributesEditorModelTypes.d.ts +3 -0
  3. package/dist/attributes-editor/useAttributesEditorModel.d.ts +1 -1
  4. package/dist/build-components/FormSubmitButton/FormSubmitButtonProps.generated.d.ts +8 -3
  5. package/dist/build-components/GlobalProvider/GlobalContext.d.ts +28 -0
  6. package/dist/build-components/GlobalProvider/GlobalProvider.d.ts +5 -0
  7. package/dist/build-components/GlobalProvider/GlobalProviderProps.generated.d.ts +60 -0
  8. package/dist/build-components/GlobalProvider/globalProviderUtils.d.ts +28 -0
  9. package/dist/build-components/GlobalProvider/useGlobalNavigation.d.ts +19 -0
  10. package/dist/build-components/GlobalProvider/useGlobalProviderLogic.d.ts +15 -0
  11. package/dist/build-components/OnboardButton/OnboardButtonProps.generated.d.ts +8 -3
  12. package/dist/build-components/OnboardProvider/OnboardProviderProps.generated.d.ts +2 -0
  13. package/dist/build-components/PaywallProvider/PaywallProviderProps.generated.d.ts +2 -0
  14. package/dist/build-components/SystemButton/SystemButtonProps.generated.d.ts +8 -3
  15. package/dist/build-components/SystemButton/usePlacementButtonEvents.d.ts +15 -2
  16. package/dist/build-components/TermsProvider/TermsProvider.d.ts +5 -0
  17. package/dist/build-components/TermsProvider/TermsProviderProps.generated.d.ts +55 -0
  18. package/dist/build-components/index.d.ts +3 -1
  19. package/dist/build-components/patterns.generated.d.ts +2128 -1333
  20. package/dist/index.cjs.js +3 -3
  21. package/dist/index.cjs.js.map +1 -1
  22. package/dist/index.esm.js +3 -3
  23. package/dist/index.esm.js.map +1 -1
  24. package/dist/index.web.cjs.js +3 -3
  25. package/dist/index.web.cjs.js.map +1 -1
  26. package/dist/index.web.esm.js +3 -3
  27. package/dist/index.web.esm.js.map +1 -1
  28. package/dist/styles.css +1 -1
  29. package/dist/utils/nodeTree.d.ts +18 -0
  30. package/package.json +1 -1
  31. package/scripts/prebuild/utils/validateAllComponentsOrThrow.js +68 -4
  32. package/src/assets/meta.json +1 -1
  33. package/src/assets/prompt-scheme-onboard.generated.ts +1 -1
  34. package/src/assets/prompt-scheme-paywall.generated.ts +1 -1
  35. package/src/assets/samples/getSamples.ts +2 -0
  36. package/src/assets/samples/global-onboard-flow.json +735 -0
  37. package/src/assets/samples/terms-and-privacy-no-form.json +1 -1
  38. package/src/assets/samples/terms-and-privacy.json +1 -1
  39. package/src/attributes-editor/AttributesEditorView.tsx +3 -0
  40. package/src/attributes-editor/Field.tsx +91 -2
  41. package/src/attributes-editor/attributesEditorModelTypes.ts +3 -0
  42. package/src/attributes-editor/useAttributesEditorModel.ts +8 -0
  43. package/src/build-components/FormCheckbox/FormCheckbox.tsx +3 -3
  44. package/src/build-components/FormSubmitButton/FormSubmitButton.tsx +6 -0
  45. package/src/build-components/FormSubmitButton/FormSubmitButtonProps.generated.ts +26 -3
  46. package/src/build-components/GlobalProvider/GlobalContext.ts +48 -0
  47. package/src/build-components/GlobalProvider/GlobalProvider.tsx +51 -0
  48. package/src/build-components/GlobalProvider/GlobalProviderProps.generated.ts +78 -0
  49. package/src/build-components/GlobalProvider/globalProviderUtils.ts +204 -0
  50. package/src/build-components/GlobalProvider/pattern.json +55 -0
  51. package/src/build-components/GlobalProvider/useGlobalNavigation.ts +65 -0
  52. package/src/build-components/GlobalProvider/useGlobalProviderLogic.ts +172 -0
  53. package/src/build-components/OnboardButton/OnboardButton.tsx +8 -1
  54. package/src/build-components/OnboardButton/OnboardButtonProps.generated.ts +26 -3
  55. package/src/build-components/OnboardButton/pattern.json +5 -3
  56. package/src/build-components/OnboardProvider/OnboardProviderProps.generated.ts +12 -0
  57. package/src/build-components/OnboardProvider/pattern.json +9 -1
  58. package/src/build-components/PaywallProvider/PaywallProviderProps.generated.ts +12 -0
  59. package/src/build-components/PaywallProvider/pattern.json +9 -1
  60. package/src/build-components/RenderNode.generated.tsx +10 -0
  61. package/src/build-components/SystemButton/SystemButton.tsx +6 -0
  62. package/src/build-components/SystemButton/SystemButtonProps.generated.ts +26 -3
  63. package/src/build-components/SystemButton/pattern.json +5 -3
  64. package/src/build-components/SystemButton/usePlacementButtonEvents.ts +51 -27
  65. package/src/build-components/TermsProvider/TermsProvider.tsx +45 -0
  66. package/src/build-components/TermsProvider/TermsProviderProps.generated.ts +82 -0
  67. package/src/build-components/TermsProvider/pattern.json +35 -0
  68. package/src/build-components/index.ts +10 -0
  69. package/src/build-components/patterns.generated.ts +2290 -1399
  70. package/src/components/AttributesEditorPanel.tsx +1 -0
  71. package/src/modals/CreateDeviceModal.tsx +12 -2
  72. package/src/modals/DeviceSelectorModal.tsx +1 -1
  73. package/src/patterns/event-constants.json +19 -0
  74. package/src/product-base/calculations.ts +30 -1
  75. package/src/product-base/extractAndroidParams.ts +2 -3
  76. package/src/product-base/extractIOSParams.ts +4 -4
  77. package/src/product-base/mockProducts.json +102 -0
  78. package/src/styles/components/_global-provider.scss +131 -0
  79. package/src/styles/index.scss +1 -0
  80. package/src/utils/analyseNodeByPatterns.ts +5 -2
  81. package/src/utils/nodeTree.ts +115 -0
  82. package/src/.DS_Store +0 -0
  83. package/src/assets/.DS_Store +0 -0
@@ -0,0 +1,204 @@
1
+ import type { NodeData } from '../../types/Node';
2
+ import type { GlobalPage } from './GlobalContext';
3
+
4
+ /** Maps node type to a canonical page key when no explicit pageKey attribute is provided. */
5
+ const TYPE_KEY_MAP: Record<string, string> = {
6
+ TermsProvider: 'terms',
7
+ OnboardProvider: 'onboard',
8
+ PaywallProvider: 'paywall',
9
+ FormProvider: 'form',
10
+ CarouselProvider: 'carousel',
11
+ };
12
+
13
+ /**
14
+ * Derives a stable and unique page key for a child node.
15
+ * Priority: node.key → TYPE_KEY_MAP → "${type}-${index}"
16
+ */
17
+ export function derivePageKey(
18
+ node: NodeData,
19
+ index: number,
20
+ existingKeys: Set<string>,
21
+ ): string {
22
+ let baseKey = '';
23
+ if (typeof node.key === 'string' && node.key.trim()) {
24
+ baseKey = node.key.trim();
25
+ } else {
26
+ baseKey = TYPE_KEY_MAP[node.type] || node.type?.toLowerCase?.() || 'page';
27
+ }
28
+
29
+ let finalKey = baseKey;
30
+ let counter = 1;
31
+
32
+ // Ensure uniqueness among siblings
33
+ while (existingKeys.has(finalKey)) {
34
+ finalKey = `${baseKey}-${index + counter}`;
35
+ counter++;
36
+ }
37
+
38
+ existingKeys.add(finalKey);
39
+ return finalKey;
40
+ }
41
+
42
+ /** Runtime shape of a SkipConditionEntry (mirrors the types block in pattern.json). */
43
+ export interface SkipConditionEntry {
44
+ pageKey: string;
45
+ conditionKey: string;
46
+ }
47
+
48
+ /**
49
+ * Converts SkipConditionEntry[] (from pattern schema) to a lookup map for fast access.
50
+ */
51
+ export function normalizeSkipConditions(raw: unknown): Record<string, string> {
52
+ if (!Array.isArray(raw)) return {};
53
+ const result: Record<string, string> = {};
54
+ for (const entry of raw) {
55
+ if (
56
+ entry &&
57
+ typeof entry === 'object' &&
58
+ typeof (entry as SkipConditionEntry).pageKey === 'string' &&
59
+ typeof (entry as SkipConditionEntry).conditionKey === 'string'
60
+ ) {
61
+ result[(entry as SkipConditionEntry).pageKey] = (
62
+ entry as SkipConditionEntry
63
+ ).conditionKey;
64
+ }
65
+ }
66
+ return result;
67
+ }
68
+
69
+ /**
70
+ * Builds the page list for GlobalProvider.
71
+ */
72
+ export function buildPages(
73
+ children: NodeData[],
74
+ skipConditions: Record<string, string> = {},
75
+ ): GlobalPage[] {
76
+ const existingKeys = new Set<string>();
77
+ return children.map((node, index) => {
78
+ const key = derivePageKey(node, index, existingKeys);
79
+ const skipIf = skipConditions[key] ?? undefined;
80
+ const animation =
81
+ typeof (node.attributes as Record<string, unknown>)?.animation ===
82
+ 'string'
83
+ ? (node.attributes as Record<string, string>).animation
84
+ : undefined;
85
+ return {
86
+ key,
87
+ node,
88
+ skipIf,
89
+ animation,
90
+ index,
91
+ };
92
+ });
93
+ }
94
+
95
+ /** Returns the first non-skipped page key, starting from the requested key. */
96
+ export function resolveEffectivePage(
97
+ targetKey: string,
98
+ pages: GlobalPage[],
99
+ conditions: Record<string, boolean>,
100
+ ): string | null {
101
+ const targetIdx = pages.findIndex((p) => p.key === targetKey);
102
+ if (targetIdx === -1) {
103
+ // If target not found, start from the first non-skipped page
104
+ return resolveFirstNonSkippedPage(pages, conditions);
105
+ }
106
+
107
+ // Walk forward from target, skipping pages whose condition is met
108
+ for (let i = targetIdx; i < pages.length; i++) {
109
+ const page = pages[i];
110
+ if (!page) break;
111
+ if (page.skipIf && conditions[page.skipIf] === true) {
112
+ continue;
113
+ }
114
+ return page.key;
115
+ }
116
+
117
+ // If all remaining pages are skipped, return null instead of falling back to the last page.
118
+ // This allows the caller to handle the "no available pages" state explicitly.
119
+ return null;
120
+ }
121
+
122
+ function resolveFirstNonSkippedPage(
123
+ pages: GlobalPage[],
124
+ conditions: Record<string, boolean>,
125
+ ): string | null {
126
+ for (const page of pages) {
127
+ if (!(page.skipIf && conditions[page.skipIf] === true)) {
128
+ return page.key;
129
+ }
130
+ }
131
+ return null;
132
+ }
133
+
134
+ const STORAGE_KEY_PREFIX = 'global-provider-progress';
135
+
136
+ /**
137
+ * Internal storage abstraction. In a real RN environment, this would be swapped
138
+ * for AsyncStorage. For now, it defaults to localStorage with safe checks.
139
+ */
140
+ const storage = {
141
+ getItem: (key: string) => {
142
+ try {
143
+ return typeof localStorage !== 'undefined'
144
+ ? localStorage.getItem(key)
145
+ : null;
146
+ } catch {
147
+ return null;
148
+ }
149
+ },
150
+ setItem: (key: string, value: string) => {
151
+ try {
152
+ if (typeof localStorage !== 'undefined') localStorage.setItem(key, value);
153
+ } catch {
154
+ // ignore
155
+ }
156
+ },
157
+ removeItem: (key: string) => {
158
+ try {
159
+ if (typeof localStorage !== 'undefined') localStorage.removeItem(key);
160
+ } catch {
161
+ // ignore
162
+ }
163
+ },
164
+ };
165
+
166
+ export function persistProgress(
167
+ storageKey: string,
168
+ currentPageKey: string,
169
+ conditions: Record<string, boolean>,
170
+ ): void {
171
+ storage.setItem(
172
+ `${STORAGE_KEY_PREFIX}-${storageKey}`,
173
+ JSON.stringify({ currentPageKey, conditions }),
174
+ );
175
+ }
176
+
177
+ export function loadProgress(storageKey: string): {
178
+ currentPageKey: string;
179
+ conditions: Record<string, boolean>;
180
+ } | null {
181
+ const raw = storage.getItem(`${STORAGE_KEY_PREFIX}-${storageKey}`);
182
+ if (!raw) return null;
183
+ try {
184
+ const parsed = JSON.parse(raw) as unknown;
185
+ if (
186
+ parsed &&
187
+ typeof parsed === 'object' &&
188
+ !Array.isArray(parsed) &&
189
+ typeof (parsed as Record<string, unknown>).currentPageKey === 'string'
190
+ ) {
191
+ return parsed as {
192
+ currentPageKey: string;
193
+ conditions: Record<string, boolean>;
194
+ };
195
+ }
196
+ } catch {
197
+ // parse error
198
+ }
199
+ return null;
200
+ }
201
+
202
+ export function clearProgress(storageKey: string): void {
203
+ storage.removeItem(`${STORAGE_KEY_PREFIX}-${storageKey}`);
204
+ }
@@ -0,0 +1,55 @@
1
+ {
2
+ "schemaVersion": 2,
3
+ "types": {
4
+ "SkipConditionEntry": {
5
+ "pageKey": "string",
6
+ "conditionKey": "string"
7
+ }
8
+ },
9
+ "pattern": {
10
+ "type": "GlobalProvider",
11
+ "title": "title",
12
+ "description": "description",
13
+ "children": "node",
14
+ "extends": "View",
15
+ "attributes": {
16
+ "initialPage": "string",
17
+ "persistProgress": "boolean",
18
+ "skipConditions": "SkipConditionEntry[]"
19
+ }
20
+ },
21
+ "defaults": {
22
+ "styles": {
23
+ "flex": 1
24
+ }
25
+ },
26
+ "meta": {
27
+ "desiredParent": ["root"],
28
+ "label": "Global Provider",
29
+ "description": "Top-level provider that manages multi-page flow (Terms → Onboard → Paywall). Each direct child is treated as a page.",
30
+ "attributes": {
31
+ "initialPage": {
32
+ "label": "Initial Page Key",
33
+ "description": "The page key to show first. Defaults to the first child.",
34
+ "category": "other",
35
+ "specialCategory": null,
36
+ "sort": 1
37
+ },
38
+ "persistProgress": {
39
+ "label": "Persist Progress",
40
+ "description": "Save current page and conditions to localStorage so the user continues from where they left off.",
41
+ "category": "other",
42
+ "specialCategory": null,
43
+ "sort": 2
44
+ },
45
+ "skipConditions": {
46
+ "label": "Skip Conditions",
47
+ "description": "List of page skip rules. Each entry maps a pageKey to a conditionKey: when conditions[conditionKey] is true, that page is skipped on navigate.",
48
+ "category": "other",
49
+ "specialCategory": null,
50
+ "sort": 3
51
+ }
52
+ },
53
+ "styles": {}
54
+ }
55
+ }
@@ -0,0 +1,65 @@
1
+ import { useCallback } from 'react';
2
+ import { useGlobalContext } from './GlobalContext';
3
+ import { useMockOSContext } from '../../mockOS/context/MockOSContextBase';
4
+ import type { RouteType } from '../../mockOS/context/MockOSContextBase';
5
+
6
+ /**
7
+ * Maps route/placement aliases to their canonical GlobalProvider page keys.
8
+ *
9
+ * Add entries here when a new alias should resolve to an existing page key.
10
+ * Keys are the incoming target strings (from JSON events / usePlacementButtonEvents).
11
+ * Values are the canonical page key that GlobalContext.navigate() will receive.
12
+ *
13
+ * Exported so other modules (e.g. a navigation-flow visualiser) can inspect
14
+ * which aliases exist without duplicating this logic.
15
+ */
16
+ export const GLOBAL_ROUTE_ALIASES: Record<string, string> = {
17
+ subscription: 'paywall',
18
+ paywall: 'paywall',
19
+ onboard: 'onboard',
20
+ terms: 'terms',
21
+ home: 'home',
22
+ };
23
+
24
+ /**
25
+ * Returns a navigate function that first attempts to route within GlobalContext
26
+ * (when a GlobalProvider is active), then falls back to MockOSContext navigation.
27
+ *
28
+ * Used by SystemButton and OnboardButton so that events defined in JSON work
29
+ * transparently whether rendered inside a GlobalProvider or standalone.
30
+ */
31
+ export function useGlobalNavigation(): (target: string) => boolean {
32
+ const globalCtx = useGlobalContext();
33
+ const mockOS = useMockOSContext();
34
+
35
+ return useCallback(
36
+ (target: string): boolean => {
37
+ if (globalCtx) {
38
+ // Direct page key match
39
+ if (globalCtx.pages.some((p) => p.key === target)) {
40
+ globalCtx.navigate(target);
41
+ return true;
42
+ }
43
+
44
+ // Alias resolution: map incoming target to canonical page key
45
+ const canonicalKey = GLOBAL_ROUTE_ALIASES[target];
46
+ if (
47
+ canonicalKey &&
48
+ globalCtx.pages.some((p) => p.key === canonicalKey)
49
+ ) {
50
+ globalCtx.navigate(canonicalKey);
51
+ return true;
52
+ }
53
+ }
54
+
55
+ // Fallback: delegate to MockOSContext
56
+ if (mockOS) {
57
+ mockOS.navigation(target as RouteType);
58
+ return true;
59
+ }
60
+
61
+ return false;
62
+ },
63
+ [globalCtx, mockOS],
64
+ );
65
+ }
@@ -0,0 +1,172 @@
1
+ import { useCallback, useId, useMemo, useRef, useState } from 'react';
2
+ import type { GlobalContextValue } from './GlobalContext';
3
+ import {
4
+ buildPages,
5
+ loadProgress,
6
+ normalizeSkipConditions,
7
+ persistProgress,
8
+ resolveEffectivePage,
9
+ } from './globalProviderUtils';
10
+ import useNode from '../useNode';
11
+ import type { NodeData } from '../../types/Node';
12
+
13
+ export interface UseGlobalProviderLogicOptions {
14
+ node: NodeData;
15
+ }
16
+
17
+ export function useGlobalProviderLogic({
18
+ node: rawNode,
19
+ }: UseGlobalProviderLogicOptions) {
20
+ const node = useNode(rawNode);
21
+
22
+ const generatedId = useId();
23
+ const attributeName = node.sourceType ?? node.type ?? 'GlobalProvider';
24
+ const attributeKey = node.key ?? generatedId;
25
+ const attrs = node.attributes;
26
+ const shouldPersist = attrs?.persistProgress === true;
27
+
28
+ const childNodes = useMemo((): NodeData[] => {
29
+ const raw = node.children;
30
+ if (!raw) return [];
31
+ if (Array.isArray(raw)) return raw as NodeData[];
32
+ return [raw as NodeData];
33
+ }, [node.children]);
34
+
35
+ const skipConditions = useMemo(
36
+ () => normalizeSkipConditions(attrs?.skipConditions),
37
+ [attrs?.skipConditions],
38
+ );
39
+
40
+ const pages = useMemo(
41
+ () => buildPages(childNodes, skipConditions),
42
+ [childNodes, skipConditions],
43
+ );
44
+
45
+ const storageKey = attributeKey;
46
+
47
+ const [conditions, setConditions] = useState<Record<string, boolean>>(() => {
48
+ if (shouldPersist) {
49
+ return loadProgress(storageKey)?.conditions ?? {};
50
+ }
51
+ return {};
52
+ });
53
+
54
+ const [pageStack, setPageStack] = useState<string[]>(() => {
55
+ const saved = shouldPersist ? loadProgress(storageKey) : null;
56
+ const initialConditions = saved?.conditions ?? {};
57
+
58
+ const firstEffective = (() => {
59
+ if (saved?.currentPageKey) {
60
+ return resolveEffectivePage(
61
+ saved.currentPageKey,
62
+ pages,
63
+ initialConditions,
64
+ );
65
+ }
66
+
67
+ const requestedKey =
68
+ typeof attrs?.initialPage === 'string'
69
+ ? attrs.initialPage
70
+ : (pages[0]?.key ?? '');
71
+ return resolveEffectivePage(requestedKey, pages, initialConditions);
72
+ })();
73
+ return firstEffective ? [firstEffective] : [];
74
+ });
75
+
76
+ const currentPageKey = pageStack[pageStack.length - 1] ?? '';
77
+
78
+ const conditionsRef = useRef(conditions);
79
+ conditionsRef.current = conditions;
80
+
81
+ const setCondition = useCallback(
82
+ (key: string, value: boolean) => {
83
+ setConditions((prev) => {
84
+ const next = { ...prev, [key]: value };
85
+ if (shouldPersist) {
86
+ const currentKey = pageStack[pageStack.length - 1] ?? '';
87
+ persistProgress(storageKey, currentKey, next);
88
+ }
89
+ return next;
90
+ });
91
+ },
92
+ [shouldPersist, storageKey, pageStack],
93
+ );
94
+
95
+ const navigate = useCallback(
96
+ (key: string) => {
97
+ const effective = resolveEffectivePage(key, pages, conditionsRef.current);
98
+ if (!effective) return;
99
+
100
+ setPageStack((prev) => {
101
+ const last = prev[prev.length - 1];
102
+ if (last === effective) return prev;
103
+ const next = [...prev, effective];
104
+ if (shouldPersist) {
105
+ persistProgress(storageKey, effective, conditionsRef.current);
106
+ }
107
+ return next;
108
+ });
109
+ },
110
+ [pages, shouldPersist, storageKey],
111
+ );
112
+
113
+ const goNext = useCallback(() => {
114
+ const currentIdx = pages.findIndex((p) => p.key === currentPageKey);
115
+ if (currentIdx === -1 || currentIdx >= pages.length - 1) return;
116
+ const nextPage = pages[currentIdx + 1];
117
+ if (!nextPage) return;
118
+ navigate(nextPage.key);
119
+ }, [pages, currentPageKey, navigate]);
120
+
121
+ const goBack = useCallback((): boolean => {
122
+ if (pageStack.length <= 1) return false;
123
+ setPageStack((prev) => {
124
+ const next = prev.slice(0, -1);
125
+ const prevKey = next[next.length - 1] ?? '';
126
+ if (shouldPersist) {
127
+ persistProgress(storageKey, prevKey, conditionsRef.current);
128
+ }
129
+ return next;
130
+ });
131
+ return true;
132
+ }, [pageStack.length, shouldPersist, storageKey]);
133
+
134
+ const activePage = useMemo(
135
+ () => pages.find((p) => p.key === currentPageKey),
136
+ [pages, currentPageKey],
137
+ );
138
+
139
+ const contextValue = useMemo<GlobalContextValue>(
140
+ () => ({
141
+ currentPageKey,
142
+ pages,
143
+ pageStack,
144
+ navigate,
145
+ goNext,
146
+ goBack,
147
+ conditions,
148
+ setCondition,
149
+ }),
150
+ [
151
+ currentPageKey,
152
+ pages,
153
+ pageStack,
154
+ navigate,
155
+ goNext,
156
+ goBack,
157
+ conditions,
158
+ setCondition,
159
+ ],
160
+ );
161
+
162
+ return {
163
+ node,
164
+ attributeName,
165
+ attributeKey,
166
+ attrs,
167
+ pages,
168
+ currentPageKey,
169
+ activePage,
170
+ contextValue,
171
+ };
172
+ }
@@ -12,6 +12,8 @@ import {
12
12
  usePlacementButtonEvents,
13
13
  type PlacementEventObject,
14
14
  } from '../SystemButton/usePlacementButtonEvents';
15
+ import { useGlobalNavigation } from '../GlobalProvider/useGlobalNavigation';
16
+ import { useGlobalContext } from '../GlobalProvider/GlobalContext';
15
17
 
16
18
  export function OnboardButton({ node }: OnboardButtonComponentProps) {
17
19
  useLogRender('OnboardButton');
@@ -21,6 +23,8 @@ export function OnboardButton({ node }: OnboardButtonComponentProps) {
21
23
  const { selectedTheme: theme, projectColors } = useBuilderParams();
22
24
  const context = useMockOSContext();
23
25
  const mockPermissionManager = useMockPermission(context);
26
+ const globalNavigate = useGlobalNavigation();
27
+ const globalCtx = useGlobalContext();
24
28
  const generatedId = useId();
25
29
  const attributeKey = node.key ?? generatedId;
26
30
  const attrs = node.attributes;
@@ -39,6 +43,7 @@ export function OnboardButton({ node }: OnboardButtonComponentProps) {
39
43
  return true;
40
44
  }
41
45
  if (e.navigate_to && typeof e.navigate_to === 'string') {
46
+ if (globalNavigate(e.navigate_to)) return true;
42
47
  if (context) {
43
48
  context.navigation(
44
49
  e.navigate_to as
@@ -56,7 +61,7 @@ export function OnboardButton({ node }: OnboardButtonComponentProps) {
56
61
  }
57
62
  return false;
58
63
  },
59
- [emblaApi, context],
64
+ [emblaApi, context, globalNavigate],
60
65
  );
61
66
 
62
67
  const handleClick = usePlacementButtonEvents(attrs?.events, {
@@ -64,6 +69,8 @@ export function OnboardButton({ node }: OnboardButtonComponentProps) {
64
69
  requestPermission: (permission) =>
65
70
  mockPermissionManager.requestPermission(permission),
66
71
  onNavigateWithoutPlacement,
72
+ globalNavigate,
73
+ setCondition: globalCtx?.setCondition,
67
74
  });
68
75
 
69
76
  return (
@@ -2,7 +2,28 @@
2
2
 
3
3
  import type { NodeData } from '../../types/Node';
4
4
 
5
- export type TypeOptionType = 'Permission' | 'Navigate' | 'Placement';
5
+ export type TypeOptionType =
6
+ | 'Permission'
7
+ | 'Navigate'
8
+ | 'Placement'
9
+ | 'SetCondition';
10
+ export type PermissionOptionType =
11
+ | 'notification'
12
+ | 'camera'
13
+ | 'microphone'
14
+ | 'location'
15
+ | 'photos'
16
+ | 'contacts'
17
+ | 'att'
18
+ | 'rating'
19
+ | 'GDPR';
20
+ export type PlacementKeyOptionType =
21
+ | 'terms'
22
+ | 'onboard'
23
+ | 'paywall'
24
+ | 'subscription'
25
+ | 'home';
26
+ export type ConditionKeyOptionType = 'termsAccepted';
6
27
  export type TestIDOptionType = 'onboardSkip' | 'onboardNext';
7
28
  export type AnimationOptionType =
8
29
  | 'simple-animation'
@@ -29,10 +50,12 @@ export type PositionOptionType = 'relative' | 'absolute';
29
50
 
30
51
  export interface EventObjectGenerated {
31
52
  type?: TypeOptionType;
32
- permission?: string;
53
+ permission?: PermissionOptionType;
33
54
  navigate_to?: string;
34
55
  targetIndex?: number;
35
- placementKey?: string;
56
+ placementKey?: PlacementKeyOptionType;
57
+ conditionKey?: ConditionKeyOptionType;
58
+ value?: boolean;
36
59
  }
37
60
 
38
61
  export interface OnboardButtonStyleGenerated {
@@ -32,11 +32,13 @@
32
32
  },
33
33
  "types": {
34
34
  "EventObject": {
35
- "type": ["Permission", "Navigate", "Placement"],
36
- "permission": "string",
35
+ "type": "$ref:event-constants.eventTypes",
36
+ "permission": "$ref:event-constants.permissionTypes",
37
37
  "navigate_to": "string",
38
38
  "targetIndex": "number",
39
- "placementKey": "string"
39
+ "placementKey": "$ref:event-constants.placementKeys",
40
+ "conditionKey": "$ref:event-constants.conditionKeys",
41
+ "value": "boolean"
40
42
  }
41
43
  },
42
44
  "meta": {
@@ -3,6 +3,17 @@
3
3
  import type { NodeData } from '../../types/Node';
4
4
 
5
5
  export type ThemeOptionType = 'light' | 'dark' | 'all';
6
+ export type AnimationOptionType =
7
+ | 'default'
8
+ | 'fade'
9
+ | 'fade_from_bottom'
10
+ | 'fade_from_right'
11
+ | 'reveal_from_bottom'
12
+ | 'scale_from_center'
13
+ | 'slide_from_right'
14
+ | 'slide_from_left'
15
+ | 'slide_from_bottom'
16
+ | 'none';
6
17
  export type FlexDirectionOptionType = 'row' | 'column';
7
18
  export type FlexWrapOptionType = 'nowrap' | 'wrap' | 'wrap-reverse';
8
19
  export type AlignItemsOptionType =
@@ -65,6 +76,7 @@ export interface OnboardProviderPropsGenerated {
65
76
  testID?: string;
66
77
  theme?: ThemeOptionType;
67
78
  borderRadius?: never;
79
+ animation?: AnimationOptionType;
68
80
  };
69
81
  }
70
82
 
@@ -8,7 +8,8 @@
8
8
  "extends": "View",
9
9
  "attributes": {
10
10
  "theme": ["light", "dark", "all"],
11
- "borderRadius": "never"
11
+ "borderRadius": "never",
12
+ "animation": ["default", "fade", "fade_from_bottom", "fade_from_right", "reveal_from_bottom", "scale_from_center", "slide_from_right", "slide_from_left", "slide_from_bottom", "none"]
12
13
  }
13
14
  },
14
15
  "defaults": {
@@ -30,6 +31,13 @@
30
31
  "specialCategory": null,
31
32
  "sort": -10
32
33
  },
34
+ "animation": {
35
+ "label": "Page transition animation",
36
+ "description": "When this component is a GlobalProvider page: animation used when navigating to this screen.",
37
+ "category": "other",
38
+ "specialCategory": null,
39
+ "sort": 2
40
+ },
33
41
  "styles": {
34
42
  "paddingTop": {
35
43
  "label": "Padding Top",
@@ -2,6 +2,17 @@
2
2
 
3
3
  import type { NodeData } from '../../types/Node';
4
4
 
5
+ export type AnimationOptionType =
6
+ | 'default'
7
+ | 'fade'
8
+ | 'fade_from_bottom'
9
+ | 'fade_from_right'
10
+ | 'reveal_from_bottom'
11
+ | 'scale_from_center'
12
+ | 'slide_from_right'
13
+ | 'slide_from_left'
14
+ | 'slide_from_bottom'
15
+ | 'none';
5
16
  export type FlexDirectionOptionType = 'row' | 'column';
6
17
  export type FlexWrapOptionType = 'nowrap' | 'wrap' | 'wrap-reverse';
7
18
  export type AlignItemsOptionType =
@@ -63,6 +74,7 @@ export interface PaywallProviderPropsGenerated {
63
74
  scrollable?: boolean;
64
75
  testID?: string;
65
76
  delay?: number;
77
+ animation?: AnimationOptionType;
66
78
  };
67
79
  }
68
80