@developer_tribe/react-builder 1.2.43 → 1.2.44-test.2
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/dist/attributes-editor/Field.d.ts +3 -1
- package/dist/attributes-editor/attributesEditorModelTypes.d.ts +3 -0
- package/dist/attributes-editor/useAttributesEditorModel.d.ts +1 -1
- package/dist/build-components/Checkbox/Checkbox.d.ts +6 -0
- package/dist/build-components/Checkbox/CheckboxProps.generated.d.ts +67 -0
- package/dist/build-components/FormCheckbox/FormCheckbox.d.ts +3 -0
- package/dist/build-components/FormCheckbox/FormCheckboxProps.generated.d.ts +69 -0
- package/dist/build-components/FormErrorText/FormErrorText.d.ts +3 -0
- package/dist/build-components/FormErrorText/FormErrorTextProps.generated.d.ts +61 -0
- package/dist/build-components/FormProvider/FormProvider.d.ts +11 -0
- package/dist/build-components/FormProvider/FormProviderProps.generated.d.ts +55 -0
- package/dist/build-components/FormSubmitButton/FormSubmitButton.d.ts +2 -0
- package/dist/build-components/FormSubmitButton/FormSubmitButtonProps.generated.d.ts +78 -0
- package/dist/build-components/GlobalProvider/GlobalContext.d.ts +28 -0
- package/dist/build-components/GlobalProvider/GlobalProvider.d.ts +5 -0
- package/dist/build-components/GlobalProvider/GlobalProviderProps.generated.d.ts +60 -0
- package/dist/build-components/GlobalProvider/globalProviderUtils.d.ts +28 -0
- package/dist/build-components/GlobalProvider/useGlobalNavigation.d.ts +19 -0
- package/dist/build-components/GlobalProvider/useGlobalProviderLogic.d.ts +15 -0
- package/dist/build-components/OnboardButton/OnboardButtonProps.generated.d.ts +22 -10
- package/dist/build-components/OnboardProvider/OnboardProviderProps.generated.d.ts +2 -0
- package/dist/build-components/PaywallProvider/PaywallProviderProps.generated.d.ts +2 -0
- package/dist/build-components/SystemButton/SystemButton.d.ts +7 -0
- package/dist/build-components/SystemButton/SystemButtonProps.generated.d.ts +76 -0
- package/dist/build-components/SystemButton/usePlacementButtonEvents.d.ts +35 -0
- package/dist/build-components/TermsProvider/TermsProvider.d.ts +5 -0
- package/dist/build-components/TermsProvider/TermsProviderProps.generated.d.ts +55 -0
- package/dist/build-components/WebView/WebView.d.ts +2 -0
- package/dist/build-components/WebView/WebViewProps.generated.d.ts +59 -0
- package/dist/build-components/index.d.ts +10 -1
- package/dist/build-components/patterns.generated.d.ts +5645 -1686
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.web.cjs.js +5 -5
- package/dist/index.web.cjs.js.map +1 -1
- package/dist/index.web.d.ts +1 -0
- package/dist/index.web.esm.js +4 -4
- package/dist/index.web.esm.js.map +1 -1
- package/dist/mockOS/context/MockOSContextBase.d.ts +3 -1
- package/dist/styles.css +1 -1
- package/dist/types/PreviewConfig.d.ts +1 -1
- package/dist/utils/nodeTree.d.ts +18 -0
- package/package.json +2 -1
- package/scripts/prebuild/utils/validateAllComponentsOrThrow.js +68 -4
- package/src/assets/meta.json +1 -1
- package/src/assets/prompt-scheme-onboard.generated.ts +1 -1
- package/src/assets/prompt-scheme-paywall.generated.ts +1 -1
- package/src/assets/samples/getSamples.ts +7 -0
- package/src/assets/samples/global-onboard-flow.json +735 -0
- package/src/assets/samples/terms-and-privacy-no-form.json +108 -0
- package/src/assets/samples/terms-and-privacy.json +130 -0
- package/src/attributes-editor/AttributesEditorView.tsx +3 -0
- package/src/attributes-editor/Field.tsx +91 -2
- package/src/attributes-editor/attributesEditorModelTypes.ts +3 -0
- package/src/attributes-editor/useAttributesEditorModel.ts +8 -0
- package/src/build-components/Checkbox/Checkbox.tsx +165 -0
- package/src/build-components/Checkbox/CheckboxProps.generated.ts +84 -0
- package/src/build-components/Checkbox/pattern.json +83 -0
- package/src/build-components/FormCheckbox/FormCheckbox.tsx +108 -0
- package/src/build-components/FormCheckbox/FormCheckboxProps.generated.ts +86 -0
- package/src/build-components/FormCheckbox/pattern.json +39 -0
- package/src/build-components/FormErrorText/FormErrorText.tsx +34 -0
- package/src/build-components/FormErrorText/FormErrorTextProps.generated.ts +78 -0
- package/src/build-components/FormErrorText/pattern.json +21 -0
- package/src/build-components/FormProvider/FormProvider.tsx +131 -0
- package/src/build-components/FormProvider/FormProviderProps.generated.ts +72 -0
- package/src/build-components/FormProvider/pattern.json +33 -0
- package/src/build-components/FormSubmitButton/FormSubmitButton.tsx +52 -0
- package/src/build-components/FormSubmitButton/FormSubmitButtonProps.generated.ts +114 -0
- package/src/build-components/FormSubmitButton/pattern.json +33 -0
- package/src/build-components/GlobalProvider/GlobalContext.ts +48 -0
- package/src/build-components/GlobalProvider/GlobalProvider.tsx +51 -0
- package/src/build-components/GlobalProvider/GlobalProviderProps.generated.ts +78 -0
- package/src/build-components/GlobalProvider/globalProviderUtils.ts +204 -0
- package/src/build-components/GlobalProvider/pattern.json +55 -0
- package/src/build-components/GlobalProvider/useGlobalNavigation.ts +65 -0
- package/src/build-components/GlobalProvider/useGlobalProviderLogic.ts +172 -0
- package/src/build-components/OnboardButton/OnboardButton.tsx +44 -36
- package/src/build-components/OnboardButton/OnboardButtonProps.generated.ts +40 -10
- package/src/build-components/OnboardButton/pattern.json +7 -4
- package/src/build-components/OnboardProvider/OnboardProviderProps.generated.ts +12 -0
- package/src/build-components/OnboardProvider/pattern.json +9 -1
- package/src/build-components/PaywallProvider/PaywallProviderProps.generated.ts +12 -0
- package/src/build-components/PaywallProvider/pattern.json +9 -1
- package/src/build-components/RenderNode.generated.tsx +46 -1
- package/src/build-components/SystemButton/SystemButton.tsx +74 -0
- package/src/build-components/SystemButton/SystemButtonProps.generated.ts +112 -0
- package/src/build-components/SystemButton/pattern.json +63 -0
- package/src/build-components/SystemButton/usePlacementButtonEvents.ts +114 -0
- package/src/build-components/TermsProvider/TermsProvider.tsx +45 -0
- package/src/build-components/TermsProvider/TermsProviderProps.generated.ts +82 -0
- package/src/build-components/TermsProvider/pattern.json +35 -0
- package/src/build-components/WebView/WebView.tsx +149 -0
- package/src/build-components/WebView/WebViewProps.generated.ts +76 -0
- package/src/build-components/WebView/pattern.json +71 -0
- package/src/build-components/index.ts +45 -0
- package/src/build-components/patterns.generated.ts +5735 -1557
- package/src/components/AttributesEditorPanel.tsx +1 -0
- package/src/index.web.ts +3 -0
- package/src/mockOS/components/MockOSRouter.tsx +21 -0
- package/src/mockOS/context/MockOSContext.tsx +7 -0
- package/src/mockOS/context/MockOSContextBase.ts +4 -0
- package/src/patterns/event-constants.json +19 -0
- package/src/styles/components/_checkbox.scss +19 -0
- package/src/styles/components/_global-provider.scss +131 -0
- package/src/styles/components/_webview.scss +52 -0
- package/src/styles/index.scss +4 -0
- package/src/types/PreviewConfig.ts +19 -0
- package/src/utils/analyseNodeByPatterns.ts +5 -2
- package/src/utils/nodeTree.ts +115 -0
- package/src/utils/projectColors.ts +4 -0
- package/src/.DS_Store +0 -0
- package/src/assets/.DS_Store +0 -0
|
@@ -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
|
+
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import React, { useContext, useId,
|
|
2
|
-
import type {
|
|
3
|
-
EventObjectGenerated,
|
|
4
|
-
OnboardButtonComponentProps,
|
|
5
|
-
} from './OnboardButtonProps.generated';
|
|
1
|
+
import React, { useContext, useId, useCallback } from 'react';
|
|
2
|
+
import type { OnboardButtonComponentProps } from './OnboardButtonProps.generated';
|
|
6
3
|
import { onboardContext } from '../OnboardProvider/OnboardProvider';
|
|
7
4
|
import useNode from '../useNode';
|
|
8
5
|
import { useBuilderParams } from '../../components/BuilderProvider';
|
|
@@ -11,6 +8,12 @@ import { useExtractViewStyle } from '../../attribute-analyser/style/web/useExtra
|
|
|
11
8
|
import { useMockOSContext, useMockPermission } from '../../mockOS';
|
|
12
9
|
import { useLocalize } from '../../hooks/useLocalize';
|
|
13
10
|
import { parseColor } from '../../utils/parseColor';
|
|
11
|
+
import {
|
|
12
|
+
usePlacementButtonEvents,
|
|
13
|
+
type PlacementEventObject,
|
|
14
|
+
} from '../SystemButton/usePlacementButtonEvents';
|
|
15
|
+
import { useGlobalNavigation } from '../GlobalProvider/useGlobalNavigation';
|
|
16
|
+
import { useGlobalContext } from '../GlobalProvider/GlobalContext';
|
|
14
17
|
|
|
15
18
|
export function OnboardButton({ node }: OnboardButtonComponentProps) {
|
|
16
19
|
useLogRender('OnboardButton');
|
|
@@ -20,7 +23,8 @@ export function OnboardButton({ node }: OnboardButtonComponentProps) {
|
|
|
20
23
|
const { selectedTheme: theme, projectColors } = useBuilderParams();
|
|
21
24
|
const context = useMockOSContext();
|
|
22
25
|
const mockPermissionManager = useMockPermission(context);
|
|
23
|
-
const
|
|
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;
|
|
@@ -30,40 +34,44 @@ export function OnboardButton({ node }: OnboardButtonComponentProps) {
|
|
|
30
34
|
const rawTextColor = attrs?.styles?.color as string | undefined;
|
|
31
35
|
const textColor = parseColor(rawTextColor, { projectColors, theme });
|
|
32
36
|
const viewStyle = useExtractViewStyle(node);
|
|
33
|
-
const handleClick = async () => {
|
|
34
|
-
//TODO: any ??
|
|
35
|
-
const events: EventObjectGenerated[] = attrs?.events ?? [];
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const onNavigateWithoutPlacement = useCallback(
|
|
39
|
+
(e: PlacementEventObject): boolean => {
|
|
40
|
+
const eventTargetIndex = e.targetIndex;
|
|
41
|
+
if (typeof eventTargetIndex === 'number') {
|
|
42
|
+
emblaApi?.scrollTo(eventTargetIndex);
|
|
43
|
+
return true;
|
|
41
44
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (context) {
|
|
57
|
-
context.navigation(eventTarget as any);
|
|
58
|
-
} else {
|
|
59
|
-
console.warn('Mock OS context not available for navigation.');
|
|
60
|
-
}
|
|
61
|
-
}
|
|
45
|
+
if (e.navigate_to && typeof e.navigate_to === 'string') {
|
|
46
|
+
if (globalNavigate(e.navigate_to)) return true;
|
|
47
|
+
if (context) {
|
|
48
|
+
context.navigation(
|
|
49
|
+
e.navigate_to as
|
|
50
|
+
| 'onboard'
|
|
51
|
+
| 'terms'
|
|
52
|
+
| 'subscription'
|
|
53
|
+
| 'app'
|
|
54
|
+
| 'home'
|
|
55
|
+
| 'launchscreen',
|
|
56
|
+
);
|
|
57
|
+
} else {
|
|
58
|
+
console.warn('Mock OS context not available for navigation.');
|
|
62
59
|
}
|
|
60
|
+
return true;
|
|
63
61
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
return false;
|
|
63
|
+
},
|
|
64
|
+
[emblaApi, context, globalNavigate],
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const handleClick = usePlacementButtonEvents(attrs?.events, {
|
|
68
|
+
context,
|
|
69
|
+
requestPermission: (permission) =>
|
|
70
|
+
mockPermissionManager.requestPermission(permission),
|
|
71
|
+
onNavigateWithoutPlacement,
|
|
72
|
+
globalNavigate,
|
|
73
|
+
setCondition: globalCtx?.setCondition,
|
|
74
|
+
});
|
|
67
75
|
|
|
68
76
|
return (
|
|
69
77
|
<button
|
|
@@ -2,8 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
import type { NodeData } from '../../types/Node';
|
|
4
4
|
|
|
5
|
-
export type TypeOptionType =
|
|
6
|
-
|
|
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';
|
|
7
27
|
export type TestIDOptionType = 'onboardSkip' | 'onboardNext';
|
|
8
28
|
export type AnimationOptionType =
|
|
9
29
|
| 'simple-animation'
|
|
@@ -30,12 +50,23 @@ export type PositionOptionType = 'relative' | 'absolute';
|
|
|
30
50
|
|
|
31
51
|
export interface EventObjectGenerated {
|
|
32
52
|
type?: TypeOptionType;
|
|
33
|
-
permission?: PermissionOptionType
|
|
53
|
+
permission?: PermissionOptionType;
|
|
34
54
|
navigate_to?: string;
|
|
35
55
|
targetIndex?: number;
|
|
56
|
+
placementKey?: PlacementKeyOptionType;
|
|
57
|
+
conditionKey?: ConditionKeyOptionType;
|
|
58
|
+
value?: boolean;
|
|
36
59
|
}
|
|
37
60
|
|
|
38
61
|
export interface OnboardButtonStyleGenerated {
|
|
62
|
+
color?: string;
|
|
63
|
+
backgroundColor?: string;
|
|
64
|
+
height?: string;
|
|
65
|
+
borderRadius?: string;
|
|
66
|
+
fontSize?: string;
|
|
67
|
+
fontWeight?: string;
|
|
68
|
+
fontFamily?: string;
|
|
69
|
+
textAlign?: string;
|
|
39
70
|
flexDirection?: FlexDirectionOptionType;
|
|
40
71
|
flexWrap?: FlexWrapOptionType;
|
|
41
72
|
alignItems?: AlignItemsOptionType;
|
|
@@ -55,12 +86,9 @@ export interface OnboardButtonStyleGenerated {
|
|
|
55
86
|
marginBottom?: string;
|
|
56
87
|
marginLeft?: string;
|
|
57
88
|
marginRight?: string;
|
|
58
|
-
backgroundColor?: string;
|
|
59
|
-
borderRadius?: string;
|
|
60
89
|
width?: string;
|
|
61
90
|
minWidth?: string;
|
|
62
91
|
maxWidth?: string;
|
|
63
|
-
height?: string;
|
|
64
92
|
minHeight?: string;
|
|
65
93
|
maxHeight?: string;
|
|
66
94
|
flex?: number;
|
|
@@ -70,19 +98,21 @@ export interface OnboardButtonStyleGenerated {
|
|
|
70
98
|
left?: string;
|
|
71
99
|
right?: string;
|
|
72
100
|
zIndex?: number;
|
|
73
|
-
color?: string;
|
|
74
101
|
}
|
|
75
102
|
|
|
76
103
|
export interface OnboardButtonPropsGenerated {
|
|
77
104
|
child: string;
|
|
78
105
|
attributes: {
|
|
79
106
|
styles?: OnboardButtonStyleGenerated;
|
|
80
|
-
scrollable?: boolean;
|
|
81
|
-
testID?: TestIDOptionType;
|
|
82
107
|
labelKey?: string;
|
|
108
|
+
events?: EventObjectGenerated[];
|
|
109
|
+
testID?: TestIDOptionType;
|
|
110
|
+
adjustsFontSizeToFit?: boolean;
|
|
111
|
+
numberOfLines?: number;
|
|
112
|
+
translateCounter?: number;
|
|
113
|
+
scrollable?: boolean;
|
|
83
114
|
animation?: AnimationOptionType;
|
|
84
115
|
animation_color?: string;
|
|
85
|
-
events?: EventObjectGenerated[];
|
|
86
116
|
};
|
|
87
117
|
}
|
|
88
118
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"title": "title",
|
|
6
6
|
"description": "description",
|
|
7
7
|
"children": "never",
|
|
8
|
-
"extends": "
|
|
8
|
+
"extends": "SystemButton",
|
|
9
9
|
"attributes": {
|
|
10
10
|
"labelKey": "string",
|
|
11
11
|
"animation": [
|
|
@@ -32,10 +32,13 @@
|
|
|
32
32
|
},
|
|
33
33
|
"types": {
|
|
34
34
|
"EventObject": {
|
|
35
|
-
"type":
|
|
36
|
-
"permission":
|
|
35
|
+
"type": "$ref:event-constants.eventTypes",
|
|
36
|
+
"permission": "$ref:event-constants.permissionTypes",
|
|
37
37
|
"navigate_to": "string",
|
|
38
|
-
"targetIndex": "number"
|
|
38
|
+
"targetIndex": "number",
|
|
39
|
+
"placementKey": "$ref:event-constants.placementKeys",
|
|
40
|
+
"conditionKey": "$ref:event-constants.conditionKeys",
|
|
41
|
+
"value": "boolean"
|
|
39
42
|
}
|
|
40
43
|
},
|
|
41
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
|
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
"children": "node",
|
|
8
8
|
"extends": "View",
|
|
9
9
|
"attributes": {
|
|
10
|
-
"delay": "number"
|
|
10
|
+
"delay": "number",
|
|
11
|
+
"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"]
|
|
11
12
|
}
|
|
12
13
|
},
|
|
13
14
|
"defaults": {
|
|
@@ -27,6 +28,13 @@
|
|
|
27
28
|
"category": "other",
|
|
28
29
|
"specialCategory": null,
|
|
29
30
|
"sort": 1
|
|
31
|
+
},
|
|
32
|
+
"animation": {
|
|
33
|
+
"label": "Page transition animation",
|
|
34
|
+
"description": "When this component is a GlobalProvider page: animation used when navigating to this screen.",
|
|
35
|
+
"category": "other",
|
|
36
|
+
"specialCategory": null,
|
|
37
|
+
"sort": 2
|
|
30
38
|
}
|
|
31
39
|
},
|
|
32
40
|
"mockableFeatures": {
|