@developer_tribe/react-builder 1.2.43 → 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/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 +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/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 +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/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 +5639 -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/package.json +2 -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/terms-and-privacy-no-form.json +108 -0
- package/src/assets/samples/terms-and-privacy.json +130 -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 +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/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 +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/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 +5701 -1559
- 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/projectColors.ts +4 -0
- package/src/.DS_Store +0 -0
- package/src/assets/.DS_Store +0 -0
|
@@ -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,11 @@ 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';
|
|
14
16
|
|
|
15
17
|
export function OnboardButton({ node }: OnboardButtonComponentProps) {
|
|
16
18
|
useLogRender('OnboardButton');
|
|
@@ -20,7 +22,7 @@ export function OnboardButton({ node }: OnboardButtonComponentProps) {
|
|
|
20
22
|
const { selectedTheme: theme, projectColors } = useBuilderParams();
|
|
21
23
|
const context = useMockOSContext();
|
|
22
24
|
const mockPermissionManager = useMockPermission(context);
|
|
23
|
-
const
|
|
25
|
+
const globalNavigate = useGlobalNavigation();
|
|
24
26
|
const generatedId = useId();
|
|
25
27
|
const attributeKey = node.key ?? generatedId;
|
|
26
28
|
const attrs = node.attributes;
|
|
@@ -30,40 +32,43 @@ export function OnboardButton({ node }: OnboardButtonComponentProps) {
|
|
|
30
32
|
const rawTextColor = attrs?.styles?.color as string | undefined;
|
|
31
33
|
const textColor = parseColor(rawTextColor, { projectColors, theme });
|
|
32
34
|
const viewStyle = useExtractViewStyle(node);
|
|
33
|
-
const handleClick = async () => {
|
|
34
|
-
//TODO: any ??
|
|
35
|
-
const events: EventObjectGenerated[] = attrs?.events ?? [];
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
const onNavigateWithoutPlacement = useCallback(
|
|
37
|
+
(e: PlacementEventObject): boolean => {
|
|
38
|
+
const eventTargetIndex = e.targetIndex;
|
|
39
|
+
if (typeof eventTargetIndex === 'number') {
|
|
40
|
+
emblaApi?.scrollTo(eventTargetIndex);
|
|
41
|
+
return true;
|
|
41
42
|
}
|
|
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
|
-
}
|
|
43
|
+
if (e.navigate_to && typeof e.navigate_to === 'string') {
|
|
44
|
+
if (globalNavigate(e.navigate_to)) return true;
|
|
45
|
+
if (context) {
|
|
46
|
+
context.navigation(
|
|
47
|
+
e.navigate_to as
|
|
48
|
+
| 'onboard'
|
|
49
|
+
| 'terms'
|
|
50
|
+
| 'subscription'
|
|
51
|
+
| 'app'
|
|
52
|
+
| 'home'
|
|
53
|
+
| 'launchscreen',
|
|
54
|
+
);
|
|
55
|
+
} else {
|
|
56
|
+
console.warn('Mock OS context not available for navigation.');
|
|
62
57
|
}
|
|
58
|
+
return true;
|
|
63
59
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
return false;
|
|
61
|
+
},
|
|
62
|
+
[emblaApi, context, globalNavigate],
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const handleClick = usePlacementButtonEvents(attrs?.events, {
|
|
66
|
+
context,
|
|
67
|
+
requestPermission: (permission) =>
|
|
68
|
+
mockPermissionManager.requestPermission(permission),
|
|
69
|
+
onNavigateWithoutPlacement,
|
|
70
|
+
globalNavigate,
|
|
71
|
+
});
|
|
67
72
|
|
|
68
73
|
return (
|
|
69
74
|
<button
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import type { NodeData } from '../../types/Node';
|
|
4
4
|
|
|
5
|
-
export type TypeOptionType = 'Permission' | 'Navigate';
|
|
6
|
-
export type PermissionOptionType = 'att' | 'notification' | 'rating' | 'GDPR';
|
|
5
|
+
export type TypeOptionType = 'Permission' | 'Navigate' | 'Placement';
|
|
7
6
|
export type TestIDOptionType = 'onboardSkip' | 'onboardNext';
|
|
8
7
|
export type AnimationOptionType =
|
|
9
8
|
| 'simple-animation'
|
|
@@ -30,12 +29,21 @@ export type PositionOptionType = 'relative' | 'absolute';
|
|
|
30
29
|
|
|
31
30
|
export interface EventObjectGenerated {
|
|
32
31
|
type?: TypeOptionType;
|
|
33
|
-
permission?:
|
|
32
|
+
permission?: string;
|
|
34
33
|
navigate_to?: string;
|
|
35
34
|
targetIndex?: number;
|
|
35
|
+
placementKey?: string;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export interface OnboardButtonStyleGenerated {
|
|
39
|
+
color?: string;
|
|
40
|
+
backgroundColor?: string;
|
|
41
|
+
height?: string;
|
|
42
|
+
borderRadius?: string;
|
|
43
|
+
fontSize?: string;
|
|
44
|
+
fontWeight?: string;
|
|
45
|
+
fontFamily?: string;
|
|
46
|
+
textAlign?: string;
|
|
39
47
|
flexDirection?: FlexDirectionOptionType;
|
|
40
48
|
flexWrap?: FlexWrapOptionType;
|
|
41
49
|
alignItems?: AlignItemsOptionType;
|
|
@@ -55,12 +63,9 @@ export interface OnboardButtonStyleGenerated {
|
|
|
55
63
|
marginBottom?: string;
|
|
56
64
|
marginLeft?: string;
|
|
57
65
|
marginRight?: string;
|
|
58
|
-
backgroundColor?: string;
|
|
59
|
-
borderRadius?: string;
|
|
60
66
|
width?: string;
|
|
61
67
|
minWidth?: string;
|
|
62
68
|
maxWidth?: string;
|
|
63
|
-
height?: string;
|
|
64
69
|
minHeight?: string;
|
|
65
70
|
maxHeight?: string;
|
|
66
71
|
flex?: number;
|
|
@@ -70,19 +75,21 @@ export interface OnboardButtonStyleGenerated {
|
|
|
70
75
|
left?: string;
|
|
71
76
|
right?: string;
|
|
72
77
|
zIndex?: number;
|
|
73
|
-
color?: string;
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
export interface OnboardButtonPropsGenerated {
|
|
77
81
|
child: string;
|
|
78
82
|
attributes: {
|
|
79
83
|
styles?: OnboardButtonStyleGenerated;
|
|
80
|
-
scrollable?: boolean;
|
|
81
|
-
testID?: TestIDOptionType;
|
|
82
84
|
labelKey?: string;
|
|
85
|
+
events?: EventObjectGenerated[];
|
|
86
|
+
testID?: TestIDOptionType;
|
|
87
|
+
adjustsFontSizeToFit?: boolean;
|
|
88
|
+
numberOfLines?: number;
|
|
89
|
+
translateCounter?: number;
|
|
90
|
+
scrollable?: boolean;
|
|
83
91
|
animation?: AnimationOptionType;
|
|
84
92
|
animation_color?: string;
|
|
85
|
-
events?: EventObjectGenerated[];
|
|
86
93
|
};
|
|
87
94
|
}
|
|
88
95
|
|
|
@@ -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,11 @@
|
|
|
32
32
|
},
|
|
33
33
|
"types": {
|
|
34
34
|
"EventObject": {
|
|
35
|
-
"type": ["Permission", "Navigate"],
|
|
36
|
-
"permission":
|
|
35
|
+
"type": ["Permission", "Navigate", "Placement"],
|
|
36
|
+
"permission": "string",
|
|
37
37
|
"navigate_to": "string",
|
|
38
|
-
"targetIndex": "number"
|
|
38
|
+
"targetIndex": "number",
|
|
39
|
+
"placementKey": "string"
|
|
39
40
|
}
|
|
40
41
|
},
|
|
41
42
|
"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": {
|
|
@@ -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
|
+
}
|