@developer_tribe/react-builder 1.2.42 → 1.2.44-test.1
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/build-components/BIcon/BIconProps.generated.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/CountDown/CountDownProps.generated.d.ts +1 -1
- 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 +73 -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 +37 -0
- package/dist/build-components/GlobalProvider/useGlobalNavigation.d.ts +19 -0
- package/dist/build-components/OnboardButton/OnboardButtonProps.generated.d.ts +17 -10
- package/dist/build-components/OnboardFooter/OnboardFooterProps.generated.d.ts +1 -1
- package/dist/build-components/OnboardProvider/OnboardProviderProps.generated.d.ts +2 -0
- package/dist/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.d.ts +1 -1
- package/dist/build-components/OnboardTitle/OnboardTitleProps.generated.d.ts +1 -1
- package/dist/build-components/PaywallCloseButton/PaywallCloseButtonProps.generated.d.ts +1 -1
- package/dist/build-components/PaywallFooter/PaywallFooterProps.generated.d.ts +1 -1
- package/dist/build-components/PaywallProvider/PaywallProviderProps.generated.d.ts +2 -0
- package/dist/build-components/PriceTag/PriceTagProps.generated.d.ts +1 -1
- package/dist/build-components/Pricing/PricingProps.generated.d.ts +1 -1
- package/dist/build-components/Promo/PromoProps.generated.d.ts +1 -1
- package/dist/build-components/SystemButton/SystemButton.d.ts +7 -0
- package/dist/build-components/SystemButton/SystemButtonProps.generated.d.ts +71 -0
- package/dist/build-components/SystemButton/usePlacementButtonEvents.d.ts +28 -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/Text/TextProps.generated.d.ts +1 -1
- 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 +5507 -1543
- 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/package.json +2 -1
- package/src/RenderPage.tsx +4 -1
- 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 +729 -0
- package/src/assets/samples/paywall-1.json +2 -2
- 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/FallbackLocalizationField.tsx +725 -250
- package/src/build-components/BIcon/BIconProps.generated.ts +1 -1
- 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/CountDown/CountDownProps.generated.ts +1 -1
- package/src/build-components/FormCheckbox/FormCheckbox.tsx +106 -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 +49 -0
- package/src/build-components/FormSubmitButton/FormSubmitButtonProps.generated.ts +91 -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 +191 -0
- package/src/build-components/GlobalProvider/GlobalProviderProps.generated.ts +78 -0
- package/src/build-components/GlobalProvider/globalProviderUtils.ts +163 -0
- package/src/build-components/GlobalProvider/pattern.json +55 -0
- package/src/build-components/GlobalProvider/useGlobalNavigation.ts +70 -0
- package/src/build-components/OnboardButton/OnboardButton.tsx +41 -36
- package/src/build-components/OnboardButton/OnboardButtonProps.generated.ts +17 -10
- package/src/build-components/OnboardButton/pattern.json +5 -4
- package/src/build-components/OnboardFooter/OnboardFooterProps.generated.ts +1 -1
- package/src/build-components/OnboardProvider/OnboardProviderProps.generated.ts +12 -0
- package/src/build-components/OnboardProvider/pattern.json +9 -1
- package/src/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.ts +1 -1
- package/src/build-components/OnboardTitle/OnboardTitleProps.generated.ts +1 -1
- package/src/build-components/PaywallCloseButton/PaywallCloseButtonProps.generated.ts +1 -1
- package/src/build-components/PaywallFooter/PaywallFooterProps.generated.ts +1 -1
- package/src/build-components/PaywallProvider/PaywallProviderProps.generated.ts +12 -0
- package/src/build-components/PaywallProvider/pattern.json +9 -1
- package/src/build-components/PriceTag/PriceTagProps.generated.ts +1 -1
- package/src/build-components/Pricing/PricingProps.generated.ts +1 -1
- package/src/build-components/Promo/PromoProps.generated.ts +1 -1
- package/src/build-components/RenderNode.generated.tsx +46 -1
- package/src/build-components/SystemButton/SystemButton.tsx +71 -0
- package/src/build-components/SystemButton/SystemButtonProps.generated.ts +89 -0
- package/src/build-components/SystemButton/pattern.json +61 -0
- package/src/build-components/SystemButton/usePlacementButtonEvents.ts +101 -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/Text/Text.tsx +5 -4
- package/src/build-components/Text/TextProps.generated.ts +1 -1
- package/src/build-components/Text/pattern.json +2 -1
- 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 +5712 -1559
- package/src/hooks/useSafeAreaViewStyle.ts +1 -11
- 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/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/extractViewStyle/extractViewStyle.ts +0 -1
- package/src/utils/projectColors.ts +4 -0
- package/src/utils/useMergedStyle.ts +1 -1
- package/src/.DS_Store +0 -0
- package/src/assets/.DS_Store +0 -0
|
@@ -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": {
|
|
@@ -21,7 +21,13 @@ import type { CarouselButtonsComponentProps } from './CarouselButtons/CarouselBu
|
|
|
21
21
|
import type { CarouselDotsComponentProps } from './CarouselDots/CarouselDotsProps.generated';
|
|
22
22
|
import type { CarouselItemComponentProps } from './CarouselItem/CarouselItemProps.generated';
|
|
23
23
|
import type { CarouselProviderComponentProps } from './CarouselProvider/CarouselProviderProps.generated';
|
|
24
|
+
import type { CheckboxComponentProps } from './Checkbox/CheckboxProps.generated';
|
|
24
25
|
import type { CountDownComponentProps } from './CountDown/CountDownProps.generated';
|
|
26
|
+
import type { FormCheckboxComponentProps } from './FormCheckbox/FormCheckboxProps.generated';
|
|
27
|
+
import type { FormErrorTextComponentProps } from './FormErrorText/FormErrorTextProps.generated';
|
|
28
|
+
import type { FormProviderComponentProps } from './FormProvider/FormProviderProps.generated';
|
|
29
|
+
import type { FormSubmitButtonComponentProps } from './FormSubmitButton/FormSubmitButtonProps.generated';
|
|
30
|
+
import type { GlobalProviderComponentProps } from './GlobalProvider/GlobalProviderProps.generated';
|
|
25
31
|
import type { ImageComponentProps } from './Image/ImageProps.generated';
|
|
26
32
|
import type { MainComponentProps } from './Main/MainProps.generated';
|
|
27
33
|
import type { NavigationBarColorComponentProps } from './NavigationBarColor/NavigationBarColorProps.generated';
|
|
@@ -47,8 +53,11 @@ import type { PromoComponentProps } from './Promo/PromoProps.generated';
|
|
|
47
53
|
import type { RadioButtonComponentProps } from './RadioButton/RadioButtonProps.generated';
|
|
48
54
|
import type { SeparatorComponentProps } from './Separator/SeparatorProps.generated';
|
|
49
55
|
import type { StatusBarColorComponentProps } from './StatusBarColor/StatusBarColorProps.generated';
|
|
56
|
+
import type { SystemButtonComponentProps } from './SystemButton/SystemButtonProps.generated';
|
|
57
|
+
import type { TermsProviderComponentProps } from './TermsProvider/TermsProviderProps.generated';
|
|
50
58
|
import type { TextComponentProps } from './Text/TextProps.generated';
|
|
51
59
|
import type { ViewComponentProps } from './View/ViewProps.generated';
|
|
60
|
+
import type { WebViewComponentProps } from './WebView/WebViewProps.generated';
|
|
52
61
|
import { BIcon } from './BIcon/BIcon';
|
|
53
62
|
import { BackgroundImage } from './BackgroundImage/BackgroundImage';
|
|
54
63
|
import { Button } from './Button/Button';
|
|
@@ -57,7 +66,13 @@ import CarouselButtons from './CarouselButtons/CarouselButtons';
|
|
|
57
66
|
import CarouselDots from './CarouselDots/CarouselDots';
|
|
58
67
|
import { CarouselItem } from './CarouselItem/CarouselItem';
|
|
59
68
|
import CarouselProvider from './CarouselProvider/CarouselProvider';
|
|
69
|
+
import { Checkbox } from './Checkbox/Checkbox';
|
|
60
70
|
import { CountDown } from './CountDown/CountDown';
|
|
71
|
+
import { FormCheckbox } from './FormCheckbox/FormCheckbox';
|
|
72
|
+
import { FormErrorText } from './FormErrorText/FormErrorText';
|
|
73
|
+
import { FormProvider } from './FormProvider/FormProvider';
|
|
74
|
+
import { FormSubmitButton } from './FormSubmitButton/FormSubmitButton';
|
|
75
|
+
import GlobalProvider from './GlobalProvider/GlobalProvider';
|
|
61
76
|
import Image from './Image/Image';
|
|
62
77
|
import Main from './Main/Main';
|
|
63
78
|
import NavigationBarColor from './NavigationBarColor/NavigationBarColor';
|
|
@@ -83,8 +98,11 @@ import Promo from './Promo/Promo';
|
|
|
83
98
|
import RadioButton from './RadioButton/RadioButton';
|
|
84
99
|
import Separator from './Separator/Separator';
|
|
85
100
|
import StatusBarColor from './StatusBarColor/StatusBarColor';
|
|
101
|
+
import { SystemButton } from './SystemButton/SystemButton';
|
|
102
|
+
import TermsProvider from './TermsProvider/TermsProvider';
|
|
86
103
|
import { Text } from './Text/Text';
|
|
87
104
|
import View from './View/View';
|
|
105
|
+
import { WebView } from './WebView/WebView';
|
|
88
106
|
|
|
89
107
|
type BuilderNode =
|
|
90
108
|
| (BIconComponentProps['node'] & { type: 'BIcon' })
|
|
@@ -95,7 +113,13 @@ type BuilderNode =
|
|
|
95
113
|
| (CarouselDotsComponentProps['node'] & { type: 'CarouselDots' })
|
|
96
114
|
| (CarouselItemComponentProps['node'] & { type: 'CarouselItem' })
|
|
97
115
|
| (CarouselProviderComponentProps['node'] & { type: 'CarouselProvider' })
|
|
116
|
+
| (CheckboxComponentProps['node'] & { type: 'Checkbox' })
|
|
98
117
|
| (CountDownComponentProps['node'] & { type: 'CountDown' })
|
|
118
|
+
| (FormCheckboxComponentProps['node'] & { type: 'FormCheckbox' })
|
|
119
|
+
| (FormErrorTextComponentProps['node'] & { type: 'FormErrorText' })
|
|
120
|
+
| (FormProviderComponentProps['node'] & { type: 'FormProvider' })
|
|
121
|
+
| (FormSubmitButtonComponentProps['node'] & { type: 'FormSubmitButton' })
|
|
122
|
+
| (GlobalProviderComponentProps['node'] & { type: 'GlobalProvider' })
|
|
99
123
|
| (ImageComponentProps['node'] & { type: 'Image' })
|
|
100
124
|
| (MainComponentProps['node'] & { type: 'Main' })
|
|
101
125
|
| (NavigationBarColorComponentProps['node'] & { type: 'NavigationBarColor' })
|
|
@@ -123,8 +147,11 @@ type BuilderNode =
|
|
|
123
147
|
| (RadioButtonComponentProps['node'] & { type: 'RadioButton' })
|
|
124
148
|
| (SeparatorComponentProps['node'] & { type: 'Separator' })
|
|
125
149
|
| (StatusBarColorComponentProps['node'] & { type: 'StatusBarColor' })
|
|
150
|
+
| (SystemButtonComponentProps['node'] & { type: 'SystemButton' })
|
|
151
|
+
| (TermsProviderComponentProps['node'] & { type: 'TermsProvider' })
|
|
126
152
|
| (TextComponentProps['node'] & { type: 'Text' })
|
|
127
|
-
| (ViewComponentProps['node'] & { type: 'View' })
|
|
153
|
+
| (ViewComponentProps['node'] & { type: 'View' })
|
|
154
|
+
| (WebViewComponentProps['node'] & { type: 'WebView' });
|
|
128
155
|
|
|
129
156
|
function RenderNode({ node }: { node: Node }) {
|
|
130
157
|
if (isNodeNullOrUndefined(node)) {
|
|
@@ -172,8 +199,20 @@ function RenderNode({ node }: { node: Node }) {
|
|
|
172
199
|
return <CarouselItem node={normalizedNode} />;
|
|
173
200
|
case 'CarouselProvider':
|
|
174
201
|
return <CarouselProvider node={normalizedNode} />;
|
|
202
|
+
case 'Checkbox':
|
|
203
|
+
return <Checkbox node={normalizedNode} />;
|
|
175
204
|
case 'CountDown':
|
|
176
205
|
return <CountDown node={normalizedNode} />;
|
|
206
|
+
case 'FormCheckbox':
|
|
207
|
+
return <FormCheckbox node={normalizedNode} />;
|
|
208
|
+
case 'FormErrorText':
|
|
209
|
+
return <FormErrorText node={normalizedNode} />;
|
|
210
|
+
case 'FormProvider':
|
|
211
|
+
return <FormProvider node={normalizedNode} />;
|
|
212
|
+
case 'FormSubmitButton':
|
|
213
|
+
return <FormSubmitButton node={normalizedNode} />;
|
|
214
|
+
case 'GlobalProvider':
|
|
215
|
+
return <GlobalProvider node={normalizedNode} />;
|
|
177
216
|
case 'Image':
|
|
178
217
|
return <Image node={normalizedNode} />;
|
|
179
218
|
case 'Main':
|
|
@@ -224,10 +263,16 @@ function RenderNode({ node }: { node: Node }) {
|
|
|
224
263
|
return <Separator node={normalizedNode} />;
|
|
225
264
|
case 'StatusBarColor':
|
|
226
265
|
return <StatusBarColor node={normalizedNode} />;
|
|
266
|
+
case 'SystemButton':
|
|
267
|
+
return <SystemButton node={normalizedNode} />;
|
|
268
|
+
case 'TermsProvider':
|
|
269
|
+
return <TermsProvider node={normalizedNode} />;
|
|
227
270
|
case 'Text':
|
|
228
271
|
return <Text node={normalizedNode} />;
|
|
229
272
|
case 'View':
|
|
230
273
|
return <View node={normalizedNode} />;
|
|
274
|
+
case 'WebView':
|
|
275
|
+
return <WebView node={normalizedNode} />;
|
|
231
276
|
default:
|
|
232
277
|
return other(nodeType, node);
|
|
233
278
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React, { useId } from 'react';
|
|
2
|
+
import type { SystemButtonComponentProps } from './SystemButtonProps.generated';
|
|
3
|
+
import useNode from '../useNode';
|
|
4
|
+
import { useLogRender } from '../../utils/useLogRender';
|
|
5
|
+
import { useExtractViewStyle } from '../../attribute-analyser/style/web/useExtractViewStyle';
|
|
6
|
+
import { useExtractTextStyle } from '../../attribute-analyser/style/web/useExtractTextStyle';
|
|
7
|
+
import { useMergedStyle } from '../../utils/useMergedStyle';
|
|
8
|
+
import { useMockOSContext, useMockPermission } from '../../mockOS';
|
|
9
|
+
import { useLocalize } from '../../hooks/useLocalize';
|
|
10
|
+
import { usePlacementButtonEvents } from './usePlacementButtonEvents';
|
|
11
|
+
import { useGlobalNavigation } from '../GlobalProvider/useGlobalNavigation';
|
|
12
|
+
|
|
13
|
+
export type SystemButtonOptionalProps = {
|
|
14
|
+
onClick?: () => void;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export function SystemButton({
|
|
19
|
+
node,
|
|
20
|
+
onClick: onClickProp,
|
|
21
|
+
disabled = false,
|
|
22
|
+
}: SystemButtonComponentProps & SystemButtonOptionalProps) {
|
|
23
|
+
useLogRender('SystemButton');
|
|
24
|
+
node = useNode(node);
|
|
25
|
+
const attributeName = node.sourceType ?? node.type ?? 'SystemButton';
|
|
26
|
+
const context = useMockOSContext();
|
|
27
|
+
const mockPermissionManager = useMockPermission(context);
|
|
28
|
+
const globalNavigate = useGlobalNavigation();
|
|
29
|
+
const generatedId = useId();
|
|
30
|
+
const attributeKey = node.key ?? generatedId;
|
|
31
|
+
const attrs = node.attributes;
|
|
32
|
+
const labelRaw = attrs?.labelKey ?? '';
|
|
33
|
+
const localize = useLocalize();
|
|
34
|
+
const label = localize(labelRaw);
|
|
35
|
+
const viewStyle = useExtractViewStyle(node as any);
|
|
36
|
+
const textStyle = useExtractTextStyle(node as any);
|
|
37
|
+
|
|
38
|
+
const placementClick = usePlacementButtonEvents(attrs?.events, {
|
|
39
|
+
context,
|
|
40
|
+
requestPermission: (permission) =>
|
|
41
|
+
mockPermissionManager.requestPermission(permission),
|
|
42
|
+
globalNavigate,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const handleClick = onClickProp ?? placementClick;
|
|
46
|
+
|
|
47
|
+
const buttonStyle = useMergedStyle(viewStyle, textStyle, {
|
|
48
|
+
border: 'none',
|
|
49
|
+
display: 'flex',
|
|
50
|
+
justifyContent: 'center',
|
|
51
|
+
alignItems: 'center',
|
|
52
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
53
|
+
opacity: disabled ? 0.6 : 1,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<button
|
|
58
|
+
{...(attrs?.testID ? { 'data-testid': attrs.testID } : {})}
|
|
59
|
+
attribute-name={attributeName}
|
|
60
|
+
attribute-key={attributeKey}
|
|
61
|
+
onClick={handleClick}
|
|
62
|
+
disabled={disabled}
|
|
63
|
+
type="button"
|
|
64
|
+
style={buttonStyle}
|
|
65
|
+
>
|
|
66
|
+
{label || 'Button'}
|
|
67
|
+
</button>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export default SystemButton;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
import type { NodeData } from '../../types/Node';
|
|
4
|
+
|
|
5
|
+
export type TypeOptionType = 'Permission' | 'Navigate' | 'Placement';
|
|
6
|
+
export type FlexDirectionOptionType = 'row' | 'column';
|
|
7
|
+
export type FlexWrapOptionType = 'nowrap' | 'wrap' | 'wrap-reverse';
|
|
8
|
+
export type AlignItemsOptionType =
|
|
9
|
+
| 'flex-start'
|
|
10
|
+
| 'center'
|
|
11
|
+
| 'flex-end'
|
|
12
|
+
| 'stretch'
|
|
13
|
+
| 'baseline';
|
|
14
|
+
export type JustifyContentOptionType =
|
|
15
|
+
| 'flex-start'
|
|
16
|
+
| 'center'
|
|
17
|
+
| 'flex-end'
|
|
18
|
+
| 'space-between'
|
|
19
|
+
| 'space-around'
|
|
20
|
+
| 'space-evenly';
|
|
21
|
+
export type PositionOptionType = 'relative' | 'absolute';
|
|
22
|
+
|
|
23
|
+
export interface EventObjectGenerated {
|
|
24
|
+
type?: TypeOptionType;
|
|
25
|
+
permission?: string;
|
|
26
|
+
navigate_to?: string;
|
|
27
|
+
targetIndex?: number;
|
|
28
|
+
placementKey?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface SystemButtonStyleGenerated {
|
|
32
|
+
color?: string;
|
|
33
|
+
fontSize?: number;
|
|
34
|
+
fontFamily?: string;
|
|
35
|
+
fontWeight?: string;
|
|
36
|
+
textAlign?: string;
|
|
37
|
+
flexDirection?: FlexDirectionOptionType;
|
|
38
|
+
flexWrap?: FlexWrapOptionType;
|
|
39
|
+
alignItems?: AlignItemsOptionType;
|
|
40
|
+
justifyContent?: JustifyContentOptionType;
|
|
41
|
+
gap?: string;
|
|
42
|
+
padding?: string;
|
|
43
|
+
paddingHorizontal?: string;
|
|
44
|
+
paddingVertical?: string;
|
|
45
|
+
paddingTop?: string;
|
|
46
|
+
paddingBottom?: string;
|
|
47
|
+
paddingLeft?: string;
|
|
48
|
+
paddingRight?: string;
|
|
49
|
+
margin?: string;
|
|
50
|
+
marginHorizontal?: string;
|
|
51
|
+
marginVertical?: string;
|
|
52
|
+
marginTop?: string;
|
|
53
|
+
marginBottom?: string;
|
|
54
|
+
marginLeft?: string;
|
|
55
|
+
marginRight?: string;
|
|
56
|
+
backgroundColor?: string;
|
|
57
|
+
borderRadius?: number;
|
|
58
|
+
width?: string;
|
|
59
|
+
minWidth?: string;
|
|
60
|
+
maxWidth?: string;
|
|
61
|
+
height?: number;
|
|
62
|
+
minHeight?: string;
|
|
63
|
+
maxHeight?: string;
|
|
64
|
+
flex?: number;
|
|
65
|
+
position?: PositionOptionType;
|
|
66
|
+
top?: string;
|
|
67
|
+
bottom?: string;
|
|
68
|
+
left?: string;
|
|
69
|
+
right?: string;
|
|
70
|
+
zIndex?: number;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface SystemButtonPropsGenerated {
|
|
74
|
+
child: string;
|
|
75
|
+
attributes: {
|
|
76
|
+
styles?: SystemButtonStyleGenerated;
|
|
77
|
+
adjustsFontSizeToFit?: boolean;
|
|
78
|
+
numberOfLines?: number;
|
|
79
|
+
translateCounter?: number;
|
|
80
|
+
scrollable?: boolean;
|
|
81
|
+
testID?: string;
|
|
82
|
+
labelKey?: string;
|
|
83
|
+
events?: EventObjectGenerated[];
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface SystemButtonComponentProps {
|
|
88
|
+
node: NodeData<SystemButtonPropsGenerated['attributes']>;
|
|
89
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 2,
|
|
3
|
+
"pattern": {
|
|
4
|
+
"type": "SystemButton",
|
|
5
|
+
"title": "SystemButton",
|
|
6
|
+
"description": "A reusable button component for system actions.",
|
|
7
|
+
"children": "never",
|
|
8
|
+
"extends": "Text",
|
|
9
|
+
"attributes": {
|
|
10
|
+
"labelKey": "string",
|
|
11
|
+
"events": "EventObject[]",
|
|
12
|
+
"testID": "string",
|
|
13
|
+
"styles": {
|
|
14
|
+
"color": "color",
|
|
15
|
+
"backgroundColor": "color",
|
|
16
|
+
"height": "number",
|
|
17
|
+
"borderRadius": "number",
|
|
18
|
+
"fontSize": "number",
|
|
19
|
+
"fontWeight": "string"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"defaults": {
|
|
24
|
+
"attributes": {
|
|
25
|
+
"labelKey": "Button"
|
|
26
|
+
},
|
|
27
|
+
"styles": {
|
|
28
|
+
"height": 48,
|
|
29
|
+
"borderRadius": 8,
|
|
30
|
+
"backgroundColor": "THEME_COLORS.SYSTEM_BUTTON_BACKGROUND",
|
|
31
|
+
"color": "THEME_COLORS.SYSTEM_BUTTON_TEXT"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"types": {
|
|
35
|
+
"EventObject": {
|
|
36
|
+
"type": ["Permission", "Navigate", "Placement"],
|
|
37
|
+
"permission": "string",
|
|
38
|
+
"navigate_to": "string",
|
|
39
|
+
"targetIndex": "number",
|
|
40
|
+
"placementKey": "string"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"meta": {
|
|
44
|
+
"label": "System Button",
|
|
45
|
+
"description": "Versatile button for navigation, permissions, and more.",
|
|
46
|
+
"attributes": {
|
|
47
|
+
"labelKey": {
|
|
48
|
+
"label": "Label Key",
|
|
49
|
+
"description": "Localization key for button text.",
|
|
50
|
+
"category": "other",
|
|
51
|
+
"sort": 1
|
|
52
|
+
},
|
|
53
|
+
"events": {
|
|
54
|
+
"label": "Events",
|
|
55
|
+
"description": "Actions to perform on click.",
|
|
56
|
+
"category": "other",
|
|
57
|
+
"sort": 2
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { useRef, useCallback } from 'react';
|
|
2
|
+
import type { MockOSContextValue } from '../../mockOS/context/MockOSContextBase';
|
|
3
|
+
import type { PermissionStatus } from '../../mockOS/managers/mockPermissionManager';
|
|
4
|
+
|
|
5
|
+
/** Event shape shared by SystemButton and OnboardButton. Placement = go to placementKey (onboard/terms/paywall); Navigate = navigate_to or carousel. */
|
|
6
|
+
export interface PlacementEventObject {
|
|
7
|
+
type?: 'Permission' | 'Navigate' | 'Placement';
|
|
8
|
+
permission?: string | null;
|
|
9
|
+
placementKey?: string;
|
|
10
|
+
navigate_to?: string;
|
|
11
|
+
targetIndex?: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface UsePlacementButtonEventsOptions {
|
|
15
|
+
context: MockOSContextValue | null;
|
|
16
|
+
requestPermission: (permission: string) => Promise<PermissionStatus>;
|
|
17
|
+
/** Called for Navigate events when placementKey is not set (e.g. carousel or navigate_to). Return true if handled. */
|
|
18
|
+
onNavigateWithoutPlacement?: (
|
|
19
|
+
e: PlacementEventObject,
|
|
20
|
+
) => Promise<boolean> | boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Optional global navigate function (from useGlobalNavigation).
|
|
23
|
+
* When provided, Navigate/Placement events try this first before falling back
|
|
24
|
+
* to MockOSContext. Return true if the navigation was handled.
|
|
25
|
+
*/
|
|
26
|
+
globalNavigate?: (target: string) => boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Shared hook for Permission + Navigate(placementKey / navigate_to) used by SystemButton and OnboardButton.
|
|
31
|
+
* OnboardButton can pass onNavigateWithoutPlacement to handle carousel (targetIndex) and navigate_to.
|
|
32
|
+
* Onboard events are pushed to handledEventsRef too: double-click is ignored; "back to terms then click again" still works because the terms screen remounts and the ref is fresh.
|
|
33
|
+
*/
|
|
34
|
+
export function usePlacementButtonEvents(
|
|
35
|
+
events: PlacementEventObject[] | undefined,
|
|
36
|
+
options: UsePlacementButtonEventsOptions,
|
|
37
|
+
): () => Promise<void> {
|
|
38
|
+
const {
|
|
39
|
+
context,
|
|
40
|
+
requestPermission,
|
|
41
|
+
onNavigateWithoutPlacement,
|
|
42
|
+
globalNavigate,
|
|
43
|
+
} = options;
|
|
44
|
+
const handledEventsRef = useRef<PlacementEventObject[]>([]);
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Attempts to navigate to a target. Tries globalNavigate first (GlobalProvider),
|
|
48
|
+
* then falls back to MockOSContext.
|
|
49
|
+
*/
|
|
50
|
+
function navigateTo(target: string): void {
|
|
51
|
+
if (globalNavigate?.(target)) return;
|
|
52
|
+
context?.navigation(target as Parameters<typeof context.navigation>[0]);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const handleClick = useCallback(async () => {
|
|
56
|
+
const list = events ?? [];
|
|
57
|
+
|
|
58
|
+
for (const e of list) {
|
|
59
|
+
if (handledEventsRef.current.includes(e)) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (e.type === 'Permission') {
|
|
64
|
+
const permission = e.permission ?? 'camera';
|
|
65
|
+
await requestPermission(permission);
|
|
66
|
+
handledEventsRef.current.push(e);
|
|
67
|
+
} else if (e.type === 'Placement' && e.placementKey) {
|
|
68
|
+
const target =
|
|
69
|
+
e.placementKey === 'paywall' ? 'paywall' : e.placementKey;
|
|
70
|
+
navigateTo(target);
|
|
71
|
+
handledEventsRef.current.push(e);
|
|
72
|
+
} else if (e.type === 'Navigate') {
|
|
73
|
+
if (e.placementKey) {
|
|
74
|
+
const target =
|
|
75
|
+
e.placementKey === 'paywall' ? 'paywall' : e.placementKey;
|
|
76
|
+
navigateTo(target);
|
|
77
|
+
handledEventsRef.current.push(e);
|
|
78
|
+
} else {
|
|
79
|
+
const handled =
|
|
80
|
+
onNavigateWithoutPlacement != null &&
|
|
81
|
+
(await Promise.resolve(onNavigateWithoutPlacement(e)));
|
|
82
|
+
if (handled) {
|
|
83
|
+
handledEventsRef.current.push(e);
|
|
84
|
+
} else if (e.navigate_to && typeof e.navigate_to === 'string') {
|
|
85
|
+
navigateTo(e.navigate_to);
|
|
86
|
+
handledEventsRef.current.push(e);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
92
|
+
}, [
|
|
93
|
+
events,
|
|
94
|
+
context,
|
|
95
|
+
requestPermission,
|
|
96
|
+
onNavigateWithoutPlacement,
|
|
97
|
+
globalNavigate,
|
|
98
|
+
]);
|
|
99
|
+
|
|
100
|
+
return handleClick;
|
|
101
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React, { useId } from 'react';
|
|
2
|
+
import type { TermsProviderComponentProps } from './TermsProviderProps.generated';
|
|
3
|
+
import RenderNode from '../RenderNode.generated';
|
|
4
|
+
import type { Node } from '../../types/Node';
|
|
5
|
+
import useNode from '../useNode';
|
|
6
|
+
import { useBuilderParams } from '../../components/BuilderProvider';
|
|
7
|
+
import { useExtractViewStyle } from '../../attribute-analyser/style/web/useExtractViewStyle';
|
|
8
|
+
import { useLogRender } from '../../utils/useLogRender';
|
|
9
|
+
import { isNodeSelected, SELECTED_OUTLINE_STYLE } from '../../utils/selection';
|
|
10
|
+
import { useMergedStyle } from '../../utils/useMergedStyle';
|
|
11
|
+
|
|
12
|
+
function TermsProvider({ node }: TermsProviderComponentProps) {
|
|
13
|
+
useLogRender('TermsProvider');
|
|
14
|
+
node = useNode(node);
|
|
15
|
+
|
|
16
|
+
const generatedId = useId();
|
|
17
|
+
const attributeName = node.sourceType ?? node.type ?? 'TermsProvider';
|
|
18
|
+
const attributeKey = node.key ?? generatedId;
|
|
19
|
+
|
|
20
|
+
const { previewMode, selectedKey } = useBuilderParams();
|
|
21
|
+
|
|
22
|
+
const baseStyle = useExtractViewStyle(node);
|
|
23
|
+
|
|
24
|
+
const isSelected = isNodeSelected({
|
|
25
|
+
previewMode: !!previewMode,
|
|
26
|
+
current: selectedKey ? { key: selectedKey } : undefined,
|
|
27
|
+
node,
|
|
28
|
+
});
|
|
29
|
+
const style = useMergedStyle(
|
|
30
|
+
baseStyle,
|
|
31
|
+
isSelected ? SELECTED_OUTLINE_STYLE : undefined,
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div
|
|
36
|
+
attribute-name={attributeName}
|
|
37
|
+
attribute-key={attributeKey}
|
|
38
|
+
style={style}
|
|
39
|
+
>
|
|
40
|
+
{node.children && <RenderNode node={node.children as Node} />}
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default React.memo(TermsProvider);
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
import type { NodeData } from '../../types/Node';
|
|
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';
|
|
16
|
+
export type FlexDirectionOptionType = 'row' | 'column';
|
|
17
|
+
export type FlexWrapOptionType = 'nowrap' | 'wrap' | 'wrap-reverse';
|
|
18
|
+
export type AlignItemsOptionType =
|
|
19
|
+
| 'flex-start'
|
|
20
|
+
| 'center'
|
|
21
|
+
| 'flex-end'
|
|
22
|
+
| 'stretch'
|
|
23
|
+
| 'baseline';
|
|
24
|
+
export type JustifyContentOptionType =
|
|
25
|
+
| 'flex-start'
|
|
26
|
+
| 'center'
|
|
27
|
+
| 'flex-end'
|
|
28
|
+
| 'space-between'
|
|
29
|
+
| 'space-around'
|
|
30
|
+
| 'space-evenly';
|
|
31
|
+
export type PositionOptionType = 'relative' | 'absolute';
|
|
32
|
+
|
|
33
|
+
export interface TermsProviderStyleGenerated {
|
|
34
|
+
flexDirection?: FlexDirectionOptionType;
|
|
35
|
+
flexWrap?: FlexWrapOptionType;
|
|
36
|
+
alignItems?: AlignItemsOptionType;
|
|
37
|
+
justifyContent?: JustifyContentOptionType;
|
|
38
|
+
gap?: string;
|
|
39
|
+
padding?: string;
|
|
40
|
+
paddingHorizontal?: string;
|
|
41
|
+
paddingVertical?: string;
|
|
42
|
+
paddingTop?: string;
|
|
43
|
+
paddingBottom?: string;
|
|
44
|
+
paddingLeft?: string;
|
|
45
|
+
paddingRight?: string;
|
|
46
|
+
margin?: string;
|
|
47
|
+
marginHorizontal?: string;
|
|
48
|
+
marginVertical?: string;
|
|
49
|
+
marginTop?: string;
|
|
50
|
+
marginBottom?: string;
|
|
51
|
+
marginLeft?: string;
|
|
52
|
+
marginRight?: string;
|
|
53
|
+
backgroundColor?: string;
|
|
54
|
+
borderRadius?: string;
|
|
55
|
+
width?: string;
|
|
56
|
+
minWidth?: string;
|
|
57
|
+
maxWidth?: string;
|
|
58
|
+
height?: string;
|
|
59
|
+
minHeight?: string;
|
|
60
|
+
maxHeight?: string;
|
|
61
|
+
flex?: number;
|
|
62
|
+
position?: PositionOptionType;
|
|
63
|
+
top?: string;
|
|
64
|
+
bottom?: string;
|
|
65
|
+
left?: string;
|
|
66
|
+
right?: string;
|
|
67
|
+
zIndex?: number;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface TermsProviderPropsGenerated {
|
|
71
|
+
child: string;
|
|
72
|
+
attributes: {
|
|
73
|
+
styles?: TermsProviderStyleGenerated;
|
|
74
|
+
scrollable?: boolean;
|
|
75
|
+
testID?: string;
|
|
76
|
+
animation?: AnimationOptionType;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface TermsProviderComponentProps {
|
|
81
|
+
node: NodeData<TermsProviderPropsGenerated['attributes']>;
|
|
82
|
+
}
|