@rocapine/react-native-onboarding-ui 1.1.6 β 1.2.0
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/README.md +193 -0
- package/dist/UI/OnboardingPage.d.ts.map +1 -1
- package/dist/UI/OnboardingPage.js +2 -0
- package/dist/UI/OnboardingPage.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/Renderer.d.ts +13 -0
- package/dist/UI/Pages/ComposableScreen/Renderer.d.ts.map +1 -0
- package/dist/UI/Pages/ComposableScreen/Renderer.js +96 -0
- package/dist/UI/Pages/ComposableScreen/Renderer.js.map +1 -0
- package/dist/UI/Pages/ComposableScreen/index.d.ts +3 -0
- package/dist/UI/Pages/ComposableScreen/index.d.ts.map +1 -0
- package/dist/UI/Pages/ComposableScreen/index.js +19 -0
- package/dist/UI/Pages/ComposableScreen/index.js.map +1 -0
- package/dist/UI/Pages/ComposableScreen/types.d.ts +75 -0
- package/dist/UI/Pages/ComposableScreen/types.d.ts.map +1 -0
- package/dist/UI/Pages/ComposableScreen/types.js +80 -0
- package/dist/UI/Pages/ComposableScreen/types.js.map +1 -0
- package/dist/UI/Pages/index.d.ts +1 -0
- package/dist/UI/Pages/index.d.ts.map +1 -1
- package/dist/UI/Pages/index.js +1 -0
- package/dist/UI/Pages/index.js.map +1 -1
- package/dist/UI/types.d.ts +2 -2
- package/dist/UI/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/UI/OnboardingPage.tsx +3 -1
- package/src/UI/Pages/ComposableScreen/Renderer.tsx +146 -0
- package/src/UI/Pages/ComposableScreen/index.ts +2 -0
- package/src/UI/Pages/ComposableScreen/types.ts +145 -0
- package/src/UI/Pages/index.ts +1 -0
- package/src/UI/types.ts +2 -0
package/README.md
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# @rocapine/react-native-onboarding-ui
|
|
2
|
+
|
|
3
|
+
**UI layer for the Rocapine Onboarding Studio SDK.**
|
|
4
|
+
|
|
5
|
+
Pre-built renderers, components, and a theme system on top of
|
|
6
|
+
`@rocapine/react-native-onboarding`.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @rocapine/react-native-onboarding-ui @rocapine/react-native-onboarding
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
Render any CMS-driven step with a single component:
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { OnboardingPage } from "@rocapine/react-native-onboarding-ui";
|
|
24
|
+
|
|
25
|
+
export default function OnboardingScreen() {
|
|
26
|
+
const { step } = useOnboardingQuestions({ stepNumber: 1 });
|
|
27
|
+
return <OnboardingPage step={step} onContinue={handleContinue} />;
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## π¨ Page Types
|
|
34
|
+
|
|
35
|
+
| Type | Description |
|
|
36
|
+
| ---------------------------------------- | ------------------------------------------------------ |
|
|
37
|
+
| `Question` | Single / multi-select answer screens |
|
|
38
|
+
| `MediaContent` | Image or video with title and description |
|
|
39
|
+
| `Carousel` | Horizontal paginated slides |
|
|
40
|
+
| `Picker` | Structured data pickers (weight, height, age, genderβ¦) |
|
|
41
|
+
| `Loader` | Animated progress bars with optional carousel |
|
|
42
|
+
| `Ratings` | App store rating prompts with social proof |
|
|
43
|
+
| `Commitment` | Agreement / signature screens |
|
|
44
|
+
| `ComposableScreen` _(under development)_ | Declarative layout system β see below |
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## π§± ComposableScreen _(under development)_
|
|
49
|
+
|
|
50
|
+
> **This page type is still under active development. The API may change before
|
|
51
|
+
> it is considered stable.**
|
|
52
|
+
|
|
53
|
+
`ComposableScreen` lets you build arbitrary onboarding screens entirely from CMS
|
|
54
|
+
data, without writing a custom renderer. You compose a tree of layout and text
|
|
55
|
+
elements that is rendered directly to native views.
|
|
56
|
+
|
|
57
|
+
### Element types
|
|
58
|
+
|
|
59
|
+
**`YStack`** β vertical flex container (`flexDirection: "column"`)
|
|
60
|
+
|
|
61
|
+
**`XStack`** β horizontal flex container (`flexDirection: "row"`)
|
|
62
|
+
|
|
63
|
+
**`Text`** β text node
|
|
64
|
+
|
|
65
|
+
### Supported props
|
|
66
|
+
|
|
67
|
+
#### Stack elements (`YStack` / `XStack`)
|
|
68
|
+
|
|
69
|
+
| Prop | Type | Notes |
|
|
70
|
+
| ------------------- | ----------------------------------------------------------------------------- | -------------------------------------- |
|
|
71
|
+
| `gap` | `number` | Space between children |
|
|
72
|
+
| `padding` | `number` | |
|
|
73
|
+
| `paddingHorizontal` | `number` | |
|
|
74
|
+
| `paddingVertical` | `number` | |
|
|
75
|
+
| `margin` | `number` | |
|
|
76
|
+
| `marginHorizontal` | `number` | |
|
|
77
|
+
| `marginVertical` | `number` | |
|
|
78
|
+
| `flex` | `number` | |
|
|
79
|
+
| `flexShrink` | `number` | Defaults to `1` inside an `XStack` |
|
|
80
|
+
| `flexWrap` | `"wrap" \| "nowrap"` | |
|
|
81
|
+
| `alignItems` | `"flex-start" \| "center" \| "flex-end" \| "stretch"` | |
|
|
82
|
+
| `justifyContent` | `"flex-start" \| "center" \| "flex-end" \| "space-between" \| "space-around"` | |
|
|
83
|
+
| `width` | `number` | |
|
|
84
|
+
| `height` | `number` | |
|
|
85
|
+
| `minWidth` | `number` | |
|
|
86
|
+
| `maxWidth` | `number` | |
|
|
87
|
+
| `minHeight` | `number` | |
|
|
88
|
+
| `maxHeight` | `number` | |
|
|
89
|
+
| `backgroundColor` | `string` | |
|
|
90
|
+
| `borderWidth` | `number` | |
|
|
91
|
+
| `borderRadius` | `number` | |
|
|
92
|
+
| `borderColor` | `string` | |
|
|
93
|
+
| `overflow` | `"hidden" \| "visible" \| "scroll"` | Use `"hidden"` to clip rounded corners |
|
|
94
|
+
| `opacity` | `number` | |
|
|
95
|
+
|
|
96
|
+
#### Text elements
|
|
97
|
+
|
|
98
|
+
| Prop | Type | Notes |
|
|
99
|
+
| ------------------- | ------------------------------- | --------------------------------------- |
|
|
100
|
+
| `content` | `string` | **Required** |
|
|
101
|
+
| `fontSize` | `number` | |
|
|
102
|
+
| `fontWeight` | `string` | |
|
|
103
|
+
| `color` | `string` | Defaults to `theme.colors.text.primary` |
|
|
104
|
+
| `textAlign` | `"left" \| "center" \| "right"` | |
|
|
105
|
+
| `letterSpacing` | `number` | |
|
|
106
|
+
| `lineHeight` | `number` | |
|
|
107
|
+
| `backgroundColor` | `string` | |
|
|
108
|
+
| `padding` | `number` | |
|
|
109
|
+
| `paddingHorizontal` | `number` | |
|
|
110
|
+
| `paddingVertical` | `number` | |
|
|
111
|
+
| `margin` | `number` | |
|
|
112
|
+
| `marginHorizontal` | `number` | |
|
|
113
|
+
| `marginVertical` | `number` | |
|
|
114
|
+
| `borderWidth` | `number` | |
|
|
115
|
+
| `borderRadius` | `number` | |
|
|
116
|
+
| `borderColor` | `string` | |
|
|
117
|
+
| `opacity` | `number` | |
|
|
118
|
+
|
|
119
|
+
### Example payload
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"type": "ComposableScreen",
|
|
124
|
+
"payload": {
|
|
125
|
+
"elements": [
|
|
126
|
+
{
|
|
127
|
+
"id": "card",
|
|
128
|
+
"type": "YStack",
|
|
129
|
+
"props": {
|
|
130
|
+
"padding": 24,
|
|
131
|
+
"gap": 12,
|
|
132
|
+
"borderWidth": 1,
|
|
133
|
+
"borderRadius": 16,
|
|
134
|
+
"borderColor": "#E0E0E0",
|
|
135
|
+
"overflow": "hidden"
|
|
136
|
+
},
|
|
137
|
+
"children": [
|
|
138
|
+
{
|
|
139
|
+
"id": "title",
|
|
140
|
+
"type": "Text",
|
|
141
|
+
"props": {
|
|
142
|
+
"content": "Welcome aboard",
|
|
143
|
+
"fontSize": 24,
|
|
144
|
+
"fontWeight": "700"
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"id": "subtitle",
|
|
149
|
+
"type": "Text",
|
|
150
|
+
"props": {
|
|
151
|
+
"content": "Let's get you set up.",
|
|
152
|
+
"fontSize": 16
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## π Theming
|
|
165
|
+
|
|
166
|
+
Pass a `theme` prop (or `lightTheme` / `darkTheme`) to `OnboardingProvider`:
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
<OnboardingProvider
|
|
170
|
+
theme={{
|
|
171
|
+
colors: { primary: "#FF5733" },
|
|
172
|
+
typography: { fontFamily: { title: "CustomFont-Bold" } },
|
|
173
|
+
}}
|
|
174
|
+
/>;
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
See `@rocapine/react-native-onboarding` for the full token reference.
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## π¦ Optional Dependencies
|
|
182
|
+
|
|
183
|
+
| Feature | Package |
|
|
184
|
+
| ---------------------- | ----------------------------- |
|
|
185
|
+
| Picker screens | `@react-native-picker/picker` |
|
|
186
|
+
| Ratings screen | `expo-store-review` |
|
|
187
|
+
| Commitment (signature) | `@shopify/react-native-skia` |
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## π License
|
|
192
|
+
|
|
193
|
+
MIT Β© [Rocapine](https://rocapine.com)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OnboardingPage.d.ts","sourceRoot":"","sources":["../../src/UI/OnboardingPage.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,
|
|
1
|
+
{"version":3,"file":"OnboardingPage.d.ts","sourceRoot":"","sources":["../../src/UI/OnboardingPage.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAA2J,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAGvO,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,UAAU,mBAAmB;IAC3B,IAAI,EAAE,kBAAkB,CAAC;IACzB,UAAU,EAAE,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACjC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,gBAAgB,CAAC,EAAE;QACjB,oBAAoB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;QACtE,mBAAmB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,wBAAwB,CAAC,CAAC;KACrE,CAAC;CACH;AAED,eAAO,MAAM,cAAc,GAAI,iCAAiC,mBAAmB,4CAoClF,CAAC"}
|
|
@@ -22,6 +22,8 @@ const OnboardingPage = ({ step, onContinue, isSandbox }) => {
|
|
|
22
22
|
return (0, jsx_runtime_1.jsx)(Pages_1.LoaderRenderer, { step: step, onContinue: onContinue, theme: theme });
|
|
23
23
|
case 'Question':
|
|
24
24
|
return (0, jsx_runtime_1.jsx)(Pages_1.QuestionRenderer, { step: step, onContinue: onContinue, theme: theme });
|
|
25
|
+
case 'ComposableScreen':
|
|
26
|
+
return (0, jsx_runtime_1.jsx)(Pages_1.ComposableScreenRenderer, { step: step, onContinue: onContinue, theme: theme });
|
|
25
27
|
default:
|
|
26
28
|
if (isSandbox) {
|
|
27
29
|
// @ts-ignore
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OnboardingPage.js","sourceRoot":"","sources":["../../src/UI/OnboardingPage.tsx"],"names":[],"mappings":";;;;AACA,
|
|
1
|
+
{"version":3,"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;YACrB,OAAO,uBAAC,gCAAwB,IAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,GAAI,CAAC;QACxF;YACE,IAAI,SAAS,EAAE,CAAC;gBACd,aAAa;gBACb,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;gBAC3B,OAAO,wBAAC,mBAAI,eACV,wBAAC,mBAAI,0BAAS,QAAQ,wBAAwB,EAC9C,uBAAC,qBAAM,IAAC,KAAK,EAAC,UAAU,EAAC,OAAO,EAAE,UAAU,GAAI,IAC3C,CAAA;YACT,CAAC;iBAAM,CAAC;gBACN,UAAU,CAAC,mCAAmC,CAAC,CAAC;gBAChD,OAAO,wBAAC,mBAAI,eACV,uBAAC,mBAAI,sCAA2B,EAChC,uBAAC,qBAAM,IAAC,KAAK,EAAC,UAAU,EAAC,OAAO,EAAE,UAAU,GAAI,IAC3C,CAAA;YACT,CAAC;IACL,CAAC;AACH,CAAC,CAAC;AApCW,QAAA,cAAc,kBAoCzB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComposableScreenStepType } from "./types";
|
|
2
|
+
import { Theme } from "../../Theme/types";
|
|
3
|
+
type ContentProps = {
|
|
4
|
+
step: ComposableScreenStepType;
|
|
5
|
+
onContinue: () => void;
|
|
6
|
+
theme?: Theme;
|
|
7
|
+
};
|
|
8
|
+
export declare const ComposableScreenRenderer: {
|
|
9
|
+
(props: ContentProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
displayName: string;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=Renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Renderer.d.ts","sourceRoot":"","sources":["../../../../src/UI/Pages/ComposableScreen/Renderer.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAA6C,MAAM,SAAS,CAAC;AAC9F,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAO1C,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,wBAAwB,CAAC;IAC/B,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CAAC;AAkIF,eAAO,MAAM,wBAAwB;;;CAAsE,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComposableScreenRenderer = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_native_1 = require("react-native");
|
|
6
|
+
const react_native_safe_area_context_1 = require("react-native-safe-area-context");
|
|
7
|
+
const types_1 = require("./types");
|
|
8
|
+
const defaultTheme_1 = require("../../Theme/defaultTheme");
|
|
9
|
+
const helpers_1 = require("../../Theme/helpers");
|
|
10
|
+
const ErrorBoundary_1 = require("../../ErrorBoundary");
|
|
11
|
+
const OnboardingTemplate_1 = require("../../Templates/OnboardingTemplate");
|
|
12
|
+
const renderElement = (element, theme, parentType) => {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
if (element.type === "YStack" || element.type === "XStack") {
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: {
|
|
16
|
+
flexDirection: element.type === "XStack" ? "row" : "column",
|
|
17
|
+
gap: element.props.gap,
|
|
18
|
+
padding: element.props.padding,
|
|
19
|
+
paddingHorizontal: element.props.paddingHorizontal,
|
|
20
|
+
paddingVertical: element.props.paddingVertical,
|
|
21
|
+
margin: element.props.margin,
|
|
22
|
+
marginHorizontal: element.props.marginHorizontal,
|
|
23
|
+
marginVertical: element.props.marginVertical,
|
|
24
|
+
flex: element.props.flex,
|
|
25
|
+
width: element.props.width,
|
|
26
|
+
height: element.props.height,
|
|
27
|
+
minWidth: element.props.minWidth,
|
|
28
|
+
maxWidth: element.props.maxWidth,
|
|
29
|
+
minHeight: element.props.minHeight,
|
|
30
|
+
maxHeight: element.props.maxHeight,
|
|
31
|
+
flexShrink: (_a = element.props.flexShrink) !== null && _a !== void 0 ? _a : (parentType === "XStack" ? 1 : undefined),
|
|
32
|
+
flexWrap: element.props.flexWrap,
|
|
33
|
+
alignItems: element.props.alignItems,
|
|
34
|
+
justifyContent: element.props.justifyContent,
|
|
35
|
+
backgroundColor: element.props.backgroundColor,
|
|
36
|
+
borderWidth: element.props.borderWidth,
|
|
37
|
+
borderRadius: element.props.borderRadius,
|
|
38
|
+
borderColor: element.props.borderColor,
|
|
39
|
+
overflow: element.props.overflow,
|
|
40
|
+
opacity: element.props.opacity,
|
|
41
|
+
}, children: element.children.map((child) => renderElement(child, theme, element.type)) }, element.id));
|
|
42
|
+
}
|
|
43
|
+
if (element.type === "Text") {
|
|
44
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.Text, { style: {
|
|
45
|
+
fontSize: element.props.fontSize,
|
|
46
|
+
fontWeight: element.props.fontWeight,
|
|
47
|
+
color: (_b = element.props.color) !== null && _b !== void 0 ? _b : theme.colors.text.primary,
|
|
48
|
+
textAlign: element.props.textAlign,
|
|
49
|
+
letterSpacing: element.props.letterSpacing,
|
|
50
|
+
lineHeight: element.props.lineHeight,
|
|
51
|
+
backgroundColor: element.props.backgroundColor,
|
|
52
|
+
padding: element.props.padding,
|
|
53
|
+
paddingHorizontal: element.props.paddingHorizontal,
|
|
54
|
+
paddingVertical: element.props.paddingVertical,
|
|
55
|
+
margin: element.props.margin,
|
|
56
|
+
marginHorizontal: element.props.marginHorizontal,
|
|
57
|
+
marginVertical: element.props.marginVertical,
|
|
58
|
+
borderWidth: element.props.borderWidth,
|
|
59
|
+
borderRadius: element.props.borderRadius,
|
|
60
|
+
borderColor: element.props.borderColor,
|
|
61
|
+
opacity: element.props.opacity,
|
|
62
|
+
flexShrink: parentType === "XStack" ? 1 : undefined,
|
|
63
|
+
}, children: element.props.content }, element.id));
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
};
|
|
67
|
+
const ComposableScreenRendererBase = ({ step, onContinue, theme = defaultTheme_1.defaultTheme }) => {
|
|
68
|
+
const { top, bottom } = (0, react_native_safe_area_context_1.useSafeAreaInsets)();
|
|
69
|
+
const validatedData = types_1.ComposableScreenStepTypeSchema.parse(step);
|
|
70
|
+
const { elements } = validatedData.payload;
|
|
71
|
+
return ((0, jsx_runtime_1.jsx)(OnboardingTemplate_1.OnboardingTemplate, { step: step, onContinue: onContinue, theme: theme, children: (0, jsx_runtime_1.jsxs)(react_native_1.ScrollView, { contentContainerStyle: styles.scrollContent, showsVerticalScrollIndicator: false, alwaysBounceVertical: false, children: [elements.map((element) => renderElement(element, theme)), (0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.bottomSection, children: (0, jsx_runtime_1.jsx)(react_native_1.TouchableOpacity, { style: [styles.ctaButton, { backgroundColor: theme.colors.primary }], onPress: onContinue, activeOpacity: 0.8, children: (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: [
|
|
72
|
+
(0, helpers_1.getTextStyle)(theme, "button"),
|
|
73
|
+
{ color: theme.colors.text.opposite },
|
|
74
|
+
], children: validatedData.continueButtonLabel }) }) })] }) }));
|
|
75
|
+
};
|
|
76
|
+
const styles = react_native_1.StyleSheet.create({
|
|
77
|
+
container: {
|
|
78
|
+
flex: 1,
|
|
79
|
+
},
|
|
80
|
+
scrollContent: {
|
|
81
|
+
flexGrow: 1,
|
|
82
|
+
},
|
|
83
|
+
bottomSection: {
|
|
84
|
+
paddingHorizontal: 32,
|
|
85
|
+
alignItems: "center",
|
|
86
|
+
},
|
|
87
|
+
ctaButton: {
|
|
88
|
+
borderRadius: 90,
|
|
89
|
+
paddingVertical: 18,
|
|
90
|
+
paddingHorizontal: 24,
|
|
91
|
+
minWidth: 234,
|
|
92
|
+
alignItems: "center",
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
exports.ComposableScreenRenderer = (0, ErrorBoundary_1.withErrorBoundary)(ComposableScreenRendererBase, "Compos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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/UI/Pages/ComposableScreen/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Renderer"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/UI/Pages/ComposableScreen/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,0CAAwB"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export type UIElement = {
|
|
3
|
+
id: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
type: "YStack" | "XStack";
|
|
6
|
+
props: {
|
|
7
|
+
gap?: number;
|
|
8
|
+
padding?: number;
|
|
9
|
+
paddingHorizontal?: number;
|
|
10
|
+
paddingVertical?: number;
|
|
11
|
+
margin?: number;
|
|
12
|
+
marginHorizontal?: number;
|
|
13
|
+
marginVertical?: number;
|
|
14
|
+
flex?: number;
|
|
15
|
+
width?: number;
|
|
16
|
+
height?: number;
|
|
17
|
+
minWidth?: number;
|
|
18
|
+
maxWidth?: number;
|
|
19
|
+
minHeight?: number;
|
|
20
|
+
maxHeight?: number;
|
|
21
|
+
alignItems?: "flex-start" | "center" | "flex-end" | "stretch";
|
|
22
|
+
justifyContent?: "flex-start" | "center" | "flex-end" | "space-between" | "space-around";
|
|
23
|
+
backgroundColor?: string;
|
|
24
|
+
flexWrap?: "wrap" | "nowrap";
|
|
25
|
+
flexShrink?: number;
|
|
26
|
+
borderWidth?: number;
|
|
27
|
+
borderRadius?: number;
|
|
28
|
+
borderColor?: string;
|
|
29
|
+
overflow?: "hidden" | "visible" | "scroll";
|
|
30
|
+
opacity?: number;
|
|
31
|
+
};
|
|
32
|
+
children: UIElement[];
|
|
33
|
+
} | {
|
|
34
|
+
id: string;
|
|
35
|
+
name?: string;
|
|
36
|
+
type: "Text";
|
|
37
|
+
props: {
|
|
38
|
+
content: string;
|
|
39
|
+
fontSize?: number;
|
|
40
|
+
fontWeight?: string;
|
|
41
|
+
color?: string;
|
|
42
|
+
textAlign?: "left" | "center" | "right";
|
|
43
|
+
letterSpacing?: number;
|
|
44
|
+
lineHeight?: number;
|
|
45
|
+
backgroundColor?: string;
|
|
46
|
+
padding?: number;
|
|
47
|
+
paddingHorizontal?: number;
|
|
48
|
+
paddingVertical?: number;
|
|
49
|
+
margin?: number;
|
|
50
|
+
marginHorizontal?: number;
|
|
51
|
+
marginVertical?: number;
|
|
52
|
+
borderWidth?: number;
|
|
53
|
+
borderRadius?: number;
|
|
54
|
+
borderColor?: string;
|
|
55
|
+
opacity?: number;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
export declare const UIElementSchema: z.ZodType<UIElement>;
|
|
59
|
+
export declare const ComposableScreenStepPayloadSchema: z.ZodObject<{
|
|
60
|
+
elements: z.ZodArray<z.ZodType<UIElement, unknown, z.core.$ZodTypeInternals<UIElement, unknown>>>;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
export declare const ComposableScreenStepTypeSchema: z.ZodObject<{
|
|
63
|
+
id: z.ZodString;
|
|
64
|
+
type: z.ZodLiteral<"ComposableScreen">;
|
|
65
|
+
name: z.ZodString;
|
|
66
|
+
displayProgressHeader: z.ZodBoolean;
|
|
67
|
+
payload: z.ZodObject<{
|
|
68
|
+
elements: z.ZodArray<z.ZodType<UIElement, unknown, z.core.$ZodTypeInternals<UIElement, unknown>>>;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
customPayload: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
71
|
+
continueButtonLabel: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
72
|
+
figmaUrl: z.ZodNullable<z.ZodString>;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
export type ComposableScreenStepType = z.infer<typeof ComposableScreenStepTypeSchema>;
|
|
75
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/UI/Pages/ComposableScreen/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,MAAM,SAAS,GACjB;IACE,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC1B,KAAK,EAAE;QACL,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;Q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Aa,CAAC,EAAE,MAAM,CAAC;QACvB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,CAAC;AAkDN,eAAO,MAAM,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAgBhD,CAAC;AAGF,eAAO,MAAM,iCAAiC;;iBAE5C,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;;iBASzC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComposableScreenStepTypeSchema = exports.ComposableScreenStepPayloadSchema = exports.UIElementSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
const StackElementPropsSchema = zod_1.z.object({
|
|
7
|
+
gap: zod_1.z.number().optional(),
|
|
8
|
+
padding: zod_1.z.number().optional(),
|
|
9
|
+
paddingHorizontal: zod_1.z.number().optional(),
|
|
10
|
+
paddingVertical: zod_1.z.number().optional(),
|
|
11
|
+
margin: zod_1.z.number().optional(),
|
|
12
|
+
marginHorizontal: zod_1.z.number().optional(),
|
|
13
|
+
marginVertical: zod_1.z.number().optional(),
|
|
14
|
+
flex: zod_1.z.number().optional(),
|
|
15
|
+
width: zod_1.z.number().optional(),
|
|
16
|
+
height: zod_1.z.number().optional(),
|
|
17
|
+
minWidth: zod_1.z.number().optional(),
|
|
18
|
+
maxWidth: zod_1.z.number().optional(),
|
|
19
|
+
minHeight: zod_1.z.number().optional(),
|
|
20
|
+
maxHeight: zod_1.z.number().optional(),
|
|
21
|
+
alignItems: zod_1.z.enum(["flex-start", "center", "flex-end", "stretch"]).optional(),
|
|
22
|
+
justifyContent: zod_1.z.enum(["flex-start", "center", "flex-end", "space-between", "space-around"]).optional(),
|
|
23
|
+
backgroundColor: zod_1.z.string().optional(),
|
|
24
|
+
flexWrap: zod_1.z.enum(["wrap", "nowrap"]).optional(),
|
|
25
|
+
flexShrink: zod_1.z.number().optional(),
|
|
26
|
+
borderWidth: zod_1.z.number().optional(),
|
|
27
|
+
borderRadius: zod_1.z.number().optional(),
|
|
28
|
+
borderColor: zod_1.z.string().optional(),
|
|
29
|
+
overflow: zod_1.z.enum(["hidden", "visible", "scroll"]).optional(),
|
|
30
|
+
opacity: zod_1.z.number().min(0).max(1).optional(),
|
|
31
|
+
});
|
|
32
|
+
const TextElementPropsSchema = zod_1.z.object({
|
|
33
|
+
content: zod_1.z.string(),
|
|
34
|
+
fontSize: zod_1.z.number().optional(),
|
|
35
|
+
fontWeight: zod_1.z.string().optional(),
|
|
36
|
+
color: zod_1.z.string().optional(),
|
|
37
|
+
textAlign: zod_1.z.enum(["left", "center", "right"]).optional(),
|
|
38
|
+
letterSpacing: zod_1.z.number().optional(),
|
|
39
|
+
lineHeight: zod_1.z.number().optional(),
|
|
40
|
+
backgroundColor: zod_1.z.string().optional(),
|
|
41
|
+
padding: zod_1.z.number().optional(),
|
|
42
|
+
paddingHorizontal: zod_1.z.number().optional(),
|
|
43
|
+
paddingVertical: zod_1.z.number().optional(),
|
|
44
|
+
margin: zod_1.z.number().optional(),
|
|
45
|
+
marginHorizontal: zod_1.z.number().optional(),
|
|
46
|
+
marginVertical: zod_1.z.number().optional(),
|
|
47
|
+
borderWidth: zod_1.z.number().optional(),
|
|
48
|
+
borderRadius: zod_1.z.number().optional(),
|
|
49
|
+
borderColor: zod_1.z.string().optional(),
|
|
50
|
+
opacity: zod_1.z.number().min(0).max(1).optional(),
|
|
51
|
+
});
|
|
52
|
+
exports.UIElementSchema = zod_1.z.lazy(() => zod_1.z.union([
|
|
53
|
+
zod_1.z.object({
|
|
54
|
+
id: zod_1.z.string(),
|
|
55
|
+
name: zod_1.z.string().optional(),
|
|
56
|
+
type: zod_1.z.union([zod_1.z.literal("YStack"), zod_1.z.literal("XStack")]),
|
|
57
|
+
props: StackElementPropsSchema,
|
|
58
|
+
children: zod_1.z.array(exports.UIElementSchema),
|
|
59
|
+
}),
|
|
60
|
+
zod_1.z.object({
|
|
61
|
+
id: zod_1.z.string(),
|
|
62
|
+
name: zod_1.z.string().optional(),
|
|
63
|
+
type: zod_1.z.literal("Text"),
|
|
64
|
+
props: TextElementPropsSchema,
|
|
65
|
+
}),
|
|
66
|
+
]));
|
|
67
|
+
exports.ComposableScreenStepPayloadSchema = zod_1.z.object({
|
|
68
|
+
elements: zod_1.z.array(exports.UIElementSchema),
|
|
69
|
+
});
|
|
70
|
+
exports.ComposableScreenStepTypeSchema = zod_1.z.object({
|
|
71
|
+
id: zod_1.z.string(),
|
|
72
|
+
type: zod_1.z.literal("ComposableScreen"),
|
|
73
|
+
name: zod_1.z.string(),
|
|
74
|
+
displayProgressHeader: zod_1.z.boolean(),
|
|
75
|
+
payload: exports.ComposableScreenStepPayloadSchema,
|
|
76
|
+
customPayload: types_1.CustomPayloadSchema,
|
|
77
|
+
continueButtonLabel: zod_1.z.string().optional().default("Continue"),
|
|
78
|
+
figmaUrl: zod_1.z.string().nullable(),
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources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ACP,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;QACd,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC3B,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,MAAM,CAAC;QACvB,KAAK,EAAE,sBAAsB;KAC9B,CAAC;CACH,CAAC,CACH,CAAC;AAGW,QAAA,iCAAiC,GAAG,OAAC,CAAC,MAAM,CAAC;IACxD,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,uBAAe,CAAC;CACnC,CAAC,CAAC;AAEU,QAAA,8BAA8B,GAAG,OAAC,CAAC,MAAM,CAAC;IACrD,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;IACd,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC;IACnC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,qBAAqB,EAAE,OAAC,CAAC,OAAO,EAAE;IAClC,OAAO,EAAE,yCAAiC;IAC1C,aAAa,EAAE,2BAAmB;IAClC,mBAAmB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC;IAC9D,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAChC,CAAC,CAAC"}
|
package/dist/UI/Pages/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/UI/Pages/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAG1B,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/UI/Pages/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAG1B,cAAc,SAAS,CAAC"}
|
package/dist/UI/Pages/index.js
CHANGED
|
@@ -18,6 +18,7 @@ __exportStar(require("./Carousel"), exports);
|
|
|
18
18
|
__exportStar(require("./Commitment"), exports);
|
|
19
19
|
__exportStar(require("./Loader"), exports);
|
|
20
20
|
__exportStar(require("./MediaContent"), exports);
|
|
21
|
+
__exportStar(require("./ComposableScreen"), exports);
|
|
21
22
|
__exportStar(require("./Picker"), exports);
|
|
22
23
|
__exportStar(require("./Question"), exports);
|
|
23
24
|
__exportStar(require("./Ratings"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/UI/Pages/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,+CAA6B;AAC7B,2CAAyB;AACzB,iDAA+B;AAC/B,2CAAyB;AACzB,6CAA2B;AAC3B,4CAA0B;AAE1B,eAAe;AACf,0CAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/UI/Pages/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,+CAA6B;AAC7B,2CAAyB;AACzB,iDAA+B;AAC/B,qDAAmC;AACnC,2CAAyB;AACzB,6CAA2B;AAC3B,4CAA0B;AAE1B,eAAe;AACf,0CAAwB"}
|
package/dist/UI/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CarouselStepType, CommitmentStepType, LoaderStepType, MediaContentStepType, PickerStepType, RatingsStepType, QuestionStepType } from "./Pages";
|
|
1
|
+
import { CarouselStepType, CommitmentStepType, LoaderStepType, MediaContentStepType, ComposableScreenStepType, PickerStepType, RatingsStepType, QuestionStepType } from "./Pages";
|
|
2
2
|
export type CustomStepType<StepPayload = any> = {
|
|
3
3
|
id: string;
|
|
4
4
|
type: "CustomScreen";
|
|
@@ -19,5 +19,5 @@ export type BaseStepType = {
|
|
|
19
19
|
payload?: any;
|
|
20
20
|
customPayload?: any;
|
|
21
21
|
};
|
|
22
|
-
export type OnboardingStepType = RatingsStepType | MediaContentStepType | PickerStepType | CommitmentStepType | CarouselStepType | LoaderStepType | QuestionStepType | CustomStepType;
|
|
22
|
+
export type OnboardingStepType = RatingsStepType | MediaContentStepType | ComposableScreenStepType | PickerStepType | CommitmentStepType | CarouselStepType | LoaderStepType | QuestionStepType | CustomStepType;
|
|
23
23
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/UI/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/UI/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,cAAc,CAAC,WAAW,GAAG,GAAG,IAAI;IAC9C,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB,EAAE,OAAO,CAAC;IAC/B,OAAO,EAAE;QACP,cAAc,EAAE,MAAM,CAAC;QACvB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,aAAa,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,aAAa,CAAC,EAAE,GAAG,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAC1B,eAAe,GACf,oBAAoB,GACpB,cAAc,GACd,kBAAkB,GAClB,gBAAgB,GAChB,cAAc,GACd,gBAAgB,GAChB,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/UI/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,wBAAwB,EACxB,cAAc,EACd,eAAe,EACf,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,cAAc,CAAC,WAAW,GAAG,GAAG,IAAI;IAC9C,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB,EAAE,OAAO,CAAC;IAC/B,OAAO,EAAE;QACP,cAAc,EAAE,MAAM,CAAC;QACvB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,aAAa,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,aAAa,CAAC,EAAE,GAAG,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAC1B,eAAe,GACf,oBAAoB,GACpB,wBAAwB,GACxB,cAAc,GACd,kBAAkB,GAClB,gBAAgB,GAChB,cAAc,GACd,gBAAgB,GAChB,cAAc,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OnboardingStepType } from "./types";
|
|
2
|
-
import { RatingsRenderer, PickerRenderer, CommitmentRenderer, CarouselRenderer, LoaderRenderer, MediaContentRenderer, QuestionRenderer, QuestionAnswerButtonProps, QuestionAnswersListProps } from "./Pages";
|
|
2
|
+
import { RatingsRenderer, PickerRenderer, CommitmentRenderer, CarouselRenderer, LoaderRenderer, MediaContentRenderer, ComposableScreenRenderer, QuestionRenderer, QuestionAnswerButtonProps, QuestionAnswersListProps } from "./Pages";
|
|
3
3
|
import { View, Text, Button } from 'react-native';
|
|
4
4
|
import { useTheme } from "./Theme/useTheme";
|
|
5
5
|
import { Theme } from "./Theme";
|
|
@@ -34,6 +34,8 @@ export const OnboardingPage = ({ step, onContinue, isSandbox }: OnboardingPagePr
|
|
|
34
34
|
return <LoaderRenderer step={step} onContinue={onContinue} theme={theme} />;
|
|
35
35
|
case 'Question':
|
|
36
36
|
return <QuestionRenderer step={step} onContinue={onContinue} theme={theme} />;
|
|
37
|
+
case 'ComposableScreen':
|
|
38
|
+
return <ComposableScreenRenderer step={step} onContinue={onContinue} theme={theme} />;
|
|
37
39
|
default:
|
|
38
40
|
if (isSandbox) {
|
|
39
41
|
// @ts-ignore
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, Text, ScrollView, StyleSheet, TouchableOpacity } from "react-native";
|
|
3
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
4
|
+
import { ComposableScreenStepType, ComposableScreenStepTypeSchema, UIElement } from "./types";
|
|
5
|
+
import { Theme } from "../../Theme/types";
|
|
6
|
+
import { defaultTheme } from "../../Theme/defaultTheme";
|
|
7
|
+
import { getTextStyle } from "../../Theme/helpers";
|
|
8
|
+
|
|
9
|
+
import { withErrorBoundary } from "../../ErrorBoundary";
|
|
10
|
+
import { OnboardingTemplate } from "../../Templates/OnboardingTemplate";
|
|
11
|
+
|
|
12
|
+
type ContentProps = {
|
|
13
|
+
step: ComposableScreenStepType;
|
|
14
|
+
onContinue: () => void;
|
|
15
|
+
theme?: Theme;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const renderElement = (element: UIElement, theme: Theme, parentType?: "XStack" | "YStack"): React.ReactNode => {
|
|
19
|
+
if (element.type === "YStack" || element.type === "XStack") {
|
|
20
|
+
return (
|
|
21
|
+
<View
|
|
22
|
+
key={element.id}
|
|
23
|
+
style={{
|
|
24
|
+
flexDirection: element.type === "XStack" ? "row" : "column",
|
|
25
|
+
gap: element.props.gap,
|
|
26
|
+
padding: element.props.padding,
|
|
27
|
+
paddingHorizontal: element.props.paddingHorizontal,
|
|
28
|
+
paddingVertical: element.props.paddingVertical,
|
|
29
|
+
margin: element.props.margin,
|
|
30
|
+
marginHorizontal: element.props.marginHorizontal,
|
|
31
|
+
marginVertical: element.props.marginVertical,
|
|
32
|
+
flex: element.props.flex,
|
|
33
|
+
width: element.props.width,
|
|
34
|
+
height: element.props.height,
|
|
35
|
+
minWidth: element.props.minWidth,
|
|
36
|
+
maxWidth: element.props.maxWidth,
|
|
37
|
+
minHeight: element.props.minHeight,
|
|
38
|
+
maxHeight: element.props.maxHeight,
|
|
39
|
+
flexShrink: element.props.flexShrink ?? (parentType === "XStack" ? 1 : undefined),
|
|
40
|
+
flexWrap: element.props.flexWrap,
|
|
41
|
+
alignItems: element.props.alignItems,
|
|
42
|
+
justifyContent: element.props.justifyContent,
|
|
43
|
+
backgroundColor: element.props.backgroundColor,
|
|
44
|
+
borderWidth: element.props.borderWidth,
|
|
45
|
+
borderRadius: element.props.borderRadius,
|
|
46
|
+
borderColor: element.props.borderColor,
|
|
47
|
+
overflow: element.props.overflow,
|
|
48
|
+
opacity: element.props.opacity,
|
|
49
|
+
}}
|
|
50
|
+
>
|
|
51
|
+
{element.children.map((child) => renderElement(child, theme, element.type))}
|
|
52
|
+
</View>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (element.type === "Text") {
|
|
57
|
+
return (
|
|
58
|
+
<Text
|
|
59
|
+
key={element.id}
|
|
60
|
+
style={{
|
|
61
|
+
fontSize: element.props.fontSize,
|
|
62
|
+
fontWeight: element.props.fontWeight as any,
|
|
63
|
+
color: element.props.color ?? theme.colors.text.primary,
|
|
64
|
+
textAlign: element.props.textAlign,
|
|
65
|
+
letterSpacing: element.props.letterSpacing,
|
|
66
|
+
lineHeight: element.props.lineHeight,
|
|
67
|
+
backgroundColor: element.props.backgroundColor,
|
|
68
|
+
padding: element.props.padding,
|
|
69
|
+
paddingHorizontal: element.props.paddingHorizontal,
|
|
70
|
+
paddingVertical: element.props.paddingVertical,
|
|
71
|
+
margin: element.props.margin,
|
|
72
|
+
marginHorizontal: element.props.marginHorizontal,
|
|
73
|
+
marginVertical: element.props.marginVertical,
|
|
74
|
+
borderWidth: element.props.borderWidth,
|
|
75
|
+
borderRadius: element.props.borderRadius,
|
|
76
|
+
borderColor: element.props.borderColor,
|
|
77
|
+
opacity: element.props.opacity,
|
|
78
|
+
flexShrink: parentType === "XStack" ? 1 : undefined,
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
{element.props.content}
|
|
82
|
+
</Text>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return null;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const ComposableScreenRendererBase = ({ step, onContinue, theme = defaultTheme }: ContentProps) => {
|
|
90
|
+
const { top, bottom } = useSafeAreaInsets();
|
|
91
|
+
const validatedData = ComposableScreenStepTypeSchema.parse(step);
|
|
92
|
+
const { elements } = validatedData.payload;
|
|
93
|
+
return (
|
|
94
|
+
<OnboardingTemplate
|
|
95
|
+
step={step}
|
|
96
|
+
onContinue={onContinue}
|
|
97
|
+
theme={theme}
|
|
98
|
+
>
|
|
99
|
+
<ScrollView
|
|
100
|
+
contentContainerStyle={styles.scrollContent}
|
|
101
|
+
showsVerticalScrollIndicator={false}
|
|
102
|
+
alwaysBounceVertical={false}
|
|
103
|
+
>
|
|
104
|
+
{elements.map((element) => renderElement(element, theme))}
|
|
105
|
+
<View style={styles.bottomSection}>
|
|
106
|
+
<TouchableOpacity
|
|
107
|
+
style={[styles.ctaButton, { backgroundColor: theme.colors.primary }]}
|
|
108
|
+
onPress={onContinue}
|
|
109
|
+
activeOpacity={0.8}
|
|
110
|
+
>
|
|
111
|
+
<Text
|
|
112
|
+
style={[
|
|
113
|
+
getTextStyle(theme, "button"),
|
|
114
|
+
{ color: theme.colors.text.opposite },
|
|
115
|
+
]}
|
|
116
|
+
>
|
|
117
|
+
{validatedData.continueButtonLabel}
|
|
118
|
+
</Text>
|
|
119
|
+
</TouchableOpacity>
|
|
120
|
+
</View>
|
|
121
|
+
</ScrollView>
|
|
122
|
+
</OnboardingTemplate>
|
|
123
|
+
)
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const styles = StyleSheet.create({
|
|
127
|
+
container: {
|
|
128
|
+
flex: 1,
|
|
129
|
+
},
|
|
130
|
+
scrollContent: {
|
|
131
|
+
flexGrow: 1,
|
|
132
|
+
},
|
|
133
|
+
bottomSection: {
|
|
134
|
+
paddingHorizontal: 32,
|
|
135
|
+
alignItems: "center",
|
|
136
|
+
},
|
|
137
|
+
ctaButton: {
|
|
138
|
+
borderRadius: 90,
|
|
139
|
+
paddingVertical: 18,
|
|
140
|
+
paddingHorizontal: 24,
|
|
141
|
+
minWidth: 234,
|
|
142
|
+
alignItems: "center",
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
export const ComposableScreenRenderer = withErrorBoundary(ComposableScreenRendererBase, "ComposableScreen");
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { CustomPayloadSchema } from "../types";
|
|
3
|
+
|
|
4
|
+
export type UIElement =
|
|
5
|
+
| {
|
|
6
|
+
id: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
type: "YStack" | "XStack";
|
|
9
|
+
props: {
|
|
10
|
+
gap?: number;
|
|
11
|
+
padding?: number;
|
|
12
|
+
paddingHorizontal?: number;
|
|
13
|
+
paddingVertical?: number;
|
|
14
|
+
margin?: number;
|
|
15
|
+
marginHorizontal?: number;
|
|
16
|
+
marginVertical?: number;
|
|
17
|
+
flex?: number;
|
|
18
|
+
width?: number;
|
|
19
|
+
height?: number;
|
|
20
|
+
minWidth?: number;
|
|
21
|
+
maxWidth?: number;
|
|
22
|
+
minHeight?: number;
|
|
23
|
+
maxHeight?: number;
|
|
24
|
+
alignItems?: "flex-start" | "center" | "flex-end" | "stretch";
|
|
25
|
+
justifyContent?: "flex-start" | "center" | "flex-end" | "space-between" | "space-around";
|
|
26
|
+
backgroundColor?: string;
|
|
27
|
+
flexWrap?: "wrap" | "nowrap";
|
|
28
|
+
flexShrink?: number;
|
|
29
|
+
borderWidth?: number;
|
|
30
|
+
borderRadius?: number;
|
|
31
|
+
borderColor?: string;
|
|
32
|
+
overflow?: "hidden" | "visible" | "scroll";
|
|
33
|
+
opacity?: number;
|
|
34
|
+
};
|
|
35
|
+
children: UIElement[];
|
|
36
|
+
}
|
|
37
|
+
| {
|
|
38
|
+
id: string;
|
|
39
|
+
name?: string;
|
|
40
|
+
type: "Text";
|
|
41
|
+
props: {
|
|
42
|
+
content: string;
|
|
43
|
+
fontSize?: number;
|
|
44
|
+
fontWeight?: string;
|
|
45
|
+
color?: string;
|
|
46
|
+
textAlign?: "left" | "center" | "right";
|
|
47
|
+
letterSpacing?: number;
|
|
48
|
+
lineHeight?: number;
|
|
49
|
+
backgroundColor?: string;
|
|
50
|
+
padding?: number;
|
|
51
|
+
paddingHorizontal?: number;
|
|
52
|
+
paddingVertical?: number;
|
|
53
|
+
margin?: number;
|
|
54
|
+
marginHorizontal?: number;
|
|
55
|
+
marginVertical?: number;
|
|
56
|
+
borderWidth?: number;
|
|
57
|
+
borderRadius?: number;
|
|
58
|
+
borderColor?: string;
|
|
59
|
+
opacity?: number;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const StackElementPropsSchema = z.object({
|
|
64
|
+
gap: z.number().optional(),
|
|
65
|
+
padding: z.number().optional(),
|
|
66
|
+
paddingHorizontal: z.number().optional(),
|
|
67
|
+
paddingVertical: z.number().optional(),
|
|
68
|
+
margin: z.number().optional(),
|
|
69
|
+
marginHorizontal: z.number().optional(),
|
|
70
|
+
marginVertical: z.number().optional(),
|
|
71
|
+
flex: z.number().optional(),
|
|
72
|
+
width: z.number().optional(),
|
|
73
|
+
height: z.number().optional(),
|
|
74
|
+
minWidth: z.number().optional(),
|
|
75
|
+
maxWidth: z.number().optional(),
|
|
76
|
+
minHeight: z.number().optional(),
|
|
77
|
+
maxHeight: z.number().optional(),
|
|
78
|
+
alignItems: z.enum(["flex-start", "center", "flex-end", "stretch"]).optional(),
|
|
79
|
+
justifyContent: z.enum(["flex-start", "center", "flex-end", "space-between", "space-around"]).optional(),
|
|
80
|
+
backgroundColor: z.string().optional(),
|
|
81
|
+
flexWrap: z.enum(["wrap", "nowrap"]).optional(),
|
|
82
|
+
flexShrink: z.number().optional(),
|
|
83
|
+
borderWidth: z.number().optional(),
|
|
84
|
+
borderRadius: z.number().optional(),
|
|
85
|
+
borderColor: z.string().optional(),
|
|
86
|
+
overflow: z.enum(["hidden", "visible", "scroll"]).optional(),
|
|
87
|
+
opacity: z.number().min(0).max(1).optional(),
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const TextElementPropsSchema = z.object({
|
|
91
|
+
content: z.string(),
|
|
92
|
+
fontSize: z.number().optional(),
|
|
93
|
+
fontWeight: z.string().optional(),
|
|
94
|
+
color: z.string().optional(),
|
|
95
|
+
textAlign: z.enum(["left", "center", "right"]).optional(),
|
|
96
|
+
letterSpacing: z.number().optional(),
|
|
97
|
+
lineHeight: z.number().optional(),
|
|
98
|
+
backgroundColor: z.string().optional(),
|
|
99
|
+
padding: z.number().optional(),
|
|
100
|
+
paddingHorizontal: z.number().optional(),
|
|
101
|
+
paddingVertical: z.number().optional(),
|
|
102
|
+
margin: z.number().optional(),
|
|
103
|
+
marginHorizontal: z.number().optional(),
|
|
104
|
+
marginVertical: z.number().optional(),
|
|
105
|
+
borderWidth: z.number().optional(),
|
|
106
|
+
borderRadius: z.number().optional(),
|
|
107
|
+
borderColor: z.string().optional(),
|
|
108
|
+
opacity: z.number().min(0).max(1).optional(),
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
export const UIElementSchema: z.ZodType<UIElement> = z.lazy(() =>
|
|
112
|
+
z.union([
|
|
113
|
+
z.object({
|
|
114
|
+
id: z.string(),
|
|
115
|
+
name: z.string().optional(),
|
|
116
|
+
type: z.union([z.literal("YStack"), z.literal("XStack")]),
|
|
117
|
+
props: StackElementPropsSchema,
|
|
118
|
+
children: z.array(UIElementSchema),
|
|
119
|
+
}),
|
|
120
|
+
z.object({
|
|
121
|
+
id: z.string(),
|
|
122
|
+
name: z.string().optional(),
|
|
123
|
+
type: z.literal("Text"),
|
|
124
|
+
props: TextElementPropsSchema,
|
|
125
|
+
}),
|
|
126
|
+
])
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
export const ComposableScreenStepPayloadSchema = z.object({
|
|
131
|
+
elements: z.array(UIElementSchema),
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
export const ComposableScreenStepTypeSchema = z.object({
|
|
135
|
+
id: z.string(),
|
|
136
|
+
type: z.literal("ComposableScreen"),
|
|
137
|
+
name: z.string(),
|
|
138
|
+
displayProgressHeader: z.boolean(),
|
|
139
|
+
payload: ComposableScreenStepPayloadSchema,
|
|
140
|
+
customPayload: CustomPayloadSchema,
|
|
141
|
+
continueButtonLabel: z.string().optional().default("Continue"),
|
|
142
|
+
figmaUrl: z.string().nullable(),
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
export type ComposableScreenStepType = z.infer<typeof ComposableScreenStepTypeSchema>;
|
package/src/UI/Pages/index.ts
CHANGED
package/src/UI/types.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
CommitmentStepType,
|
|
4
4
|
LoaderStepType,
|
|
5
5
|
MediaContentStepType,
|
|
6
|
+
ComposableScreenStepType,
|
|
6
7
|
PickerStepType,
|
|
7
8
|
RatingsStepType,
|
|
8
9
|
QuestionStepType,
|
|
@@ -33,6 +34,7 @@ export type BaseStepType = {
|
|
|
33
34
|
export type OnboardingStepType =
|
|
34
35
|
| RatingsStepType
|
|
35
36
|
| MediaContentStepType
|
|
37
|
+
| ComposableScreenStepType
|
|
36
38
|
| PickerStepType
|
|
37
39
|
| CommitmentStepType
|
|
38
40
|
| CarouselStepType
|