@rocapine/react-native-onboarding-ui 1.24.0 → 1.25.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/UI/Pages/ComposableScreen/Renderer.js +3 -3
- package/dist/UI/Pages/ComposableScreen/Renderer.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/BaseBoxProps.d.ts +2 -0
- package/dist/UI/Pages/ComposableScreen/elements/BaseBoxProps.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/BaseBoxProps.js +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/BaseBoxProps.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ButtonElement.d.ts +4 -0
- package/dist/UI/Pages/ComposableScreen/elements/ButtonElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ButtonElement.js +5 -14
- package/dist/UI/Pages/ComposableScreen/elements/ButtonElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/CarouselElement.d.ts +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/CarouselElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/CheckboxGroupElement.d.ts +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/CheckboxGroupElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/DatePickerElement.d.ts +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/DatePickerElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/IconElement.d.ts +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/IconElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ImageElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ImageElement.js +17 -24
- package/dist/UI/Pages/ComposableScreen/elements/ImageElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/InputElement.d.ts +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/InputElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/KeyboardAvoidingViewElement.d.ts +99 -0
- package/dist/UI/Pages/ComposableScreen/elements/KeyboardAvoidingViewElement.d.ts.map +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/KeyboardAvoidingViewElement.js +51 -0
- package/dist/UI/Pages/ComposableScreen/elements/KeyboardAvoidingViewElement.js.map +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/LottieElement.d.ts +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/LottieElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/RadioGroupElement.d.ts +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/RadioGroupElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/RiveElement.d.ts +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/RiveElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/RiveElement.js +13 -2
- package/dist/UI/Pages/ComposableScreen/elements/RiveElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/SafeAreaViewElement.d.ts +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/SafeAreaViewElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ScrollViewElement.d.ts +121 -0
- package/dist/UI/Pages/ComposableScreen/elements/ScrollViewElement.d.ts.map +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/ScrollViewElement.js +67 -0
- package/dist/UI/Pages/ComposableScreen/elements/ScrollViewElement.js.map +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/StackElement.d.ts +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/StackElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/TextElement.d.ts +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/TextElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/VideoElement.d.ts +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/VideoElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ZStackElement.d.ts +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/ZStackElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/collectDefaults.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/collectDefaults.js +2 -0
- package/dist/UI/Pages/ComposableScreen/elements/collectDefaults.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/renderElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/renderElement.js +8 -0
- package/dist/UI/Pages/ComposableScreen/elements/renderElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/shared.d.ts +9 -0
- package/dist/UI/Pages/ComposableScreen/elements/shared.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/shared.js +13 -1
- package/dist/UI/Pages/ComposableScreen/elements/shared.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/types.d.ts +18 -0
- package/dist/UI/Pages/ComposableScreen/types.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/types.js +51 -1
- package/dist/UI/Pages/ComposableScreen/types.js.map +1 -1
- package/package.json +1 -1
- package/src/UI/Pages/ComposableScreen/Renderer.tsx +10 -10
- package/src/UI/Pages/ComposableScreen/elements/BaseBoxProps.ts +2 -0
- package/src/UI/Pages/ComposableScreen/elements/ButtonElement.tsx +5 -15
- package/src/UI/Pages/ComposableScreen/elements/ImageElement.tsx +49 -35
- package/src/UI/Pages/ComposableScreen/elements/KeyboardAvoidingViewElement.tsx +81 -0
- package/src/UI/Pages/ComposableScreen/elements/RiveElement.tsx +13 -1
- package/src/UI/Pages/ComposableScreen/elements/ScrollViewElement.tsx +115 -0
- package/src/UI/Pages/ComposableScreen/elements/collectDefaults.ts +2 -0
- package/src/UI/Pages/ComposableScreen/elements/renderElement.tsx +10 -0
- package/src/UI/Pages/ComposableScreen/elements/shared.ts +20 -0
- package/src/UI/Pages/ComposableScreen/types.ts +83 -3
|
@@ -19,6 +19,8 @@ const DatePickerElement_1 = require("./elements/DatePickerElement");
|
|
|
19
19
|
const CarouselElement_1 = require("./elements/CarouselElement");
|
|
20
20
|
const ZStackElement_1 = require("./elements/ZStackElement");
|
|
21
21
|
const SafeAreaViewElement_1 = require("./elements/SafeAreaViewElement");
|
|
22
|
+
const ScrollViewElement_1 = require("./elements/ScrollViewElement");
|
|
23
|
+
const KeyboardAvoidingViewElement_1 = require("./elements/KeyboardAvoidingViewElement");
|
|
22
24
|
var BaseBoxProps_1 = require("./elements/BaseBoxProps");
|
|
23
25
|
Object.defineProperty(exports, "BaseBoxPropsSchema", { enumerable: true, get: function () { return BaseBoxProps_1.BaseBoxPropsSchema; } });
|
|
24
26
|
exports.UIElementSchema = zod_1.z.lazy(() => zod_1.z.union([
|
|
@@ -131,9 +133,57 @@ exports.UIElementSchema = zod_1.z.lazy(() => zod_1.z.union([
|
|
|
131
133
|
props: SafeAreaViewElement_1.SafeAreaViewElementPropsSchema,
|
|
132
134
|
children: zod_1.z.array(exports.UIElementSchema),
|
|
133
135
|
}),
|
|
136
|
+
zod_1.z.object({
|
|
137
|
+
id: zod_1.z.string(),
|
|
138
|
+
name: zod_1.z.string().optional(),
|
|
139
|
+
renderWhen: zod_1.z.union([react_native_onboarding_1.LeafConditionSchema, react_native_onboarding_1.ConditionGroupSchema]).optional(),
|
|
140
|
+
type: zod_1.z.literal("ScrollView"),
|
|
141
|
+
props: ScrollViewElement_1.ScrollViewElementPropsSchema,
|
|
142
|
+
children: zod_1.z.array(exports.UIElementSchema),
|
|
143
|
+
}),
|
|
144
|
+
zod_1.z.object({
|
|
145
|
+
id: zod_1.z.string(),
|
|
146
|
+
name: zod_1.z.string().optional(),
|
|
147
|
+
renderWhen: zod_1.z.union([react_native_onboarding_1.LeafConditionSchema, react_native_onboarding_1.ConditionGroupSchema]).optional(),
|
|
148
|
+
type: zod_1.z.literal("KeyboardAvoidingView"),
|
|
149
|
+
props: KeyboardAvoidingViewElement_1.KeyboardAvoidingViewElementPropsSchema,
|
|
150
|
+
children: zod_1.z.array(exports.UIElementSchema),
|
|
151
|
+
}),
|
|
134
152
|
]));
|
|
135
|
-
|
|
153
|
+
// See packages/onboarding for the canonical comment; mirror nesting guard here because
|
|
154
|
+
// the UI re-parses the step with `ComposableScreenStepTypeSchema.parse(step)` in Renderer.tsx.
|
|
155
|
+
const collectNestedKeyboardAvoidingViews = (nodes, insideKav, out) => {
|
|
156
|
+
for (const node of nodes) {
|
|
157
|
+
if (node.type === "KeyboardAvoidingView") {
|
|
158
|
+
if (insideKav)
|
|
159
|
+
out.push(node.id);
|
|
160
|
+
collectNestedKeyboardAvoidingViews(node.children, true, out);
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
if (node.type === "YStack" ||
|
|
164
|
+
node.type === "XStack" ||
|
|
165
|
+
node.type === "ZStack" ||
|
|
166
|
+
node.type === "SafeAreaView" ||
|
|
167
|
+
node.type === "ScrollView" ||
|
|
168
|
+
node.type === "Carousel") {
|
|
169
|
+
collectNestedKeyboardAvoidingViews(node.children, insideKav, out);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
exports.ComposableScreenStepPayloadSchema = zod_1.z
|
|
174
|
+
.object({
|
|
136
175
|
elements: zod_1.z.array(exports.UIElementSchema),
|
|
176
|
+
})
|
|
177
|
+
.superRefine((payload, ctx) => {
|
|
178
|
+
const offenders = [];
|
|
179
|
+
collectNestedKeyboardAvoidingViews(payload.elements, false, offenders);
|
|
180
|
+
for (const id of offenders) {
|
|
181
|
+
ctx.addIssue({
|
|
182
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
183
|
+
path: ["elements"],
|
|
184
|
+
message: `KeyboardAvoidingView (id="${id}") cannot be nested inside another KeyboardAvoidingView.`,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
137
187
|
});
|
|
138
188
|
exports.ComposableScreenStepTypeSchema = zod_1.z.object({
|
|
139
189
|
id: zod_1.z.string(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/UI/Pages/ComposableScreen/types.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,+EAK2C;AAC3C,oCAA+C;AAC/C,0DAA0F;AAC1F,wDAAuF;AACvF,0DAA0F;AAC1F,4DAA6F;AAC7F,wDAAuF;AACvF,wDAAuF;AACvF,0DAA0F;AAC1F,0DAA0F;AAC1F,4DAA6F;AAC7F,oEAAyG;AACzG,0EAAkH;AAClH,oEAAyG;AACzG,gEAAmG;AACnG,4DAA6F;AAC7F,wEAA+G;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/UI/Pages/ComposableScreen/types.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,+EAK2C;AAC3C,oCAA+C;AAC/C,0DAA0F;AAC1F,wDAAuF;AACvF,0DAA0F;AAC1F,4DAA6F;AAC7F,wDAAuF;AACvF,wDAAuF;AACvF,0DAA0F;AAC1F,0DAA0F;AAC1F,4DAA6F;AAC7F,oEAAyG;AACzG,0EAAkH;AAClH,oEAAyG;AACzG,gEAAmG;AACnG,4DAA6F;AAC7F,wEAA+G;AAC/G,oEAAyG;AACzG,wFAGgD;AAGhD,wDAA6D;AAApD,kHAAA,kBAAkB,OAAA;AAuJd,QAAA,eAAe,GAAyB,OAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAC/D,OAAC,CAAC,KAAK,CAAC;IACN,OAAC,CAAC,MAAM,CAAC;QACP,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;QACd,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC3B,UAAU,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,6CAAmB,EAAE,8CAAoB,CAAC,CAAC,CAAC,QAAQ,EAAE;QAC3E,IAAI,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,O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C,UAAU,CAAC;IAC9D,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;CAC/B,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rocapine/react-native-onboarding-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.25.1",
|
|
4
4
|
"description": "UI components and renderers for Rocapine Onboarding Studio - Built on top of the headless SDK",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useContext, useMemo } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { KeyboardAvoidingView, Platform, StyleSheet, View } from "react-native";
|
|
3
3
|
import { OnboardingProgressContext as HeadlessProgressContext } from "@rocapine/react-native-onboarding";
|
|
4
4
|
import { ComposableScreenStepType, ComposableScreenStepTypeSchema, UIElement } from "./types";
|
|
5
5
|
import { withErrorBoundary } from "../../ErrorBoundary";
|
|
@@ -59,21 +59,21 @@ const ComposableScreenRendererBase = ({ step, onContinue }: ContentProps) => {
|
|
|
59
59
|
theme={theme}
|
|
60
60
|
disableTopPadding
|
|
61
61
|
>
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
alwaysBounceVertical={false}
|
|
66
|
-
keyboardShouldPersistTaps="handled"
|
|
62
|
+
<KeyboardAvoidingView
|
|
63
|
+
style={styles.flex}
|
|
64
|
+
behavior={Platform.OS === "ios" ? "padding" : "height"}
|
|
67
65
|
>
|
|
68
|
-
{
|
|
69
|
-
|
|
66
|
+
<View style={styles.flex}>
|
|
67
|
+
{elements.map((element) => renderElement(element, ctx))}
|
|
68
|
+
</View>
|
|
69
|
+
</KeyboardAvoidingView>
|
|
70
70
|
</OnboardingTemplate>
|
|
71
71
|
);
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
const styles = StyleSheet.create({
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
flex: {
|
|
76
|
+
flex: 1,
|
|
77
77
|
},
|
|
78
78
|
});
|
|
79
79
|
|
|
@@ -60,6 +60,7 @@ export type BaseBoxProps = {
|
|
|
60
60
|
flex?: number;
|
|
61
61
|
flexShrink?: number;
|
|
62
62
|
flexGrow?: number;
|
|
63
|
+
aspectRatio?: number;
|
|
63
64
|
alignSelf?: "auto" | "flex-start" | "flex-end" | "center" | "stretch" | "baseline";
|
|
64
65
|
opacity?: number;
|
|
65
66
|
backgroundColor?: string;
|
|
@@ -91,6 +92,7 @@ export const BaseBoxPropsSchema = z.object({
|
|
|
91
92
|
flex: z.number().min(0).optional(),
|
|
92
93
|
flexShrink: z.number().min(0).optional(),
|
|
93
94
|
flexGrow: z.number().min(0).optional(),
|
|
95
|
+
aspectRatio: z.number().positive().optional(),
|
|
94
96
|
alignSelf: z.enum(["auto", "flex-start", "flex-end", "center", "stretch", "baseline"]).optional(),
|
|
95
97
|
opacity: z.number().min(0).max(1).optional(),
|
|
96
98
|
backgroundColor: z.string().optional(),
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "@rocapine/react-native-onboarding";
|
|
13
13
|
import { BaseBoxProps, BaseBoxPropsSchema } from "./BaseBoxProps";
|
|
14
14
|
import { UIElement } from "../types";
|
|
15
|
-
import { RenderContext, dim, resolveInheritedFontFamily } from "./shared";
|
|
15
|
+
import { RenderContext, buildShadowStyle, dim, resolveInheritedFontFamily } from "./shared";
|
|
16
16
|
import { GradientBox } from "./GradientBox";
|
|
17
17
|
import { ComposableVariableEntry } from "../../../Provider/OnboardingProgressProvider";
|
|
18
18
|
import { evaluateSetVariableExpression } from "./expression";
|
|
@@ -141,14 +141,6 @@ type Props = {
|
|
|
141
141
|
ctx: RenderContext;
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
-
const buildShadowStyle = (p: Pick<BaseBoxProps, "shadowColor" | "shadowOffset" | "shadowOpacity" | "shadowRadius" | "elevation">) => ({
|
|
145
|
-
shadowColor: p.shadowColor,
|
|
146
|
-
shadowOffset: p.shadowOffset,
|
|
147
|
-
shadowOpacity: p.shadowOpacity,
|
|
148
|
-
shadowRadius: p.shadowRadius,
|
|
149
|
-
elevation: p.elevation,
|
|
150
|
-
});
|
|
151
|
-
|
|
152
144
|
export const ButtonElementComponent = ({ element, ctx }: Props): React.ReactElement => {
|
|
153
145
|
const { theme, onContinue, customActions, variables, setVariable } = ctx;
|
|
154
146
|
const flatVariables = useMemo(
|
|
@@ -338,9 +330,8 @@ export const ButtonElementComponent = ({ element, ctx }: Props): React.ReactElem
|
|
|
338
330
|
style={{
|
|
339
331
|
flex: 1,
|
|
340
332
|
padding: eff.padding,
|
|
341
|
-
paddingVertical: eff.paddingVertical ?? 14,
|
|
342
|
-
paddingHorizontal: eff.paddingHorizontal ?? 24,
|
|
343
|
-
alignItems: "center",
|
|
333
|
+
paddingVertical: eff.paddingVertical ?? (eff.padding != null ? undefined : 14),
|
|
334
|
+
paddingHorizontal: eff.paddingHorizontal ?? (eff.padding != null ? undefined : 24),
|
|
344
335
|
justifyContent: "center",
|
|
345
336
|
}}
|
|
346
337
|
>
|
|
@@ -375,9 +366,8 @@ export const ButtonElementComponent = ({ element, ctx }: Props): React.ReactElem
|
|
|
375
366
|
disabled={isDisabled}
|
|
376
367
|
style={{
|
|
377
368
|
padding: eff.padding,
|
|
378
|
-
paddingVertical: eff.paddingVertical ?? 14,
|
|
379
|
-
paddingHorizontal: eff.paddingHorizontal ?? 24,
|
|
380
|
-
alignItems: "center",
|
|
369
|
+
paddingVertical: eff.paddingVertical ?? (eff.padding != null ? undefined : 14),
|
|
370
|
+
paddingHorizontal: eff.paddingHorizontal ?? (eff.padding != null ? undefined : 24),
|
|
381
371
|
justifyContent: "center",
|
|
382
372
|
borderRadius,
|
|
383
373
|
}}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { Image } from "react-native";
|
|
3
|
+
import { Image, View } from "react-native";
|
|
4
4
|
import { BaseBoxProps, BaseBoxPropsSchema } from "./BaseBoxProps";
|
|
5
5
|
import { UIElement } from "../types";
|
|
6
|
-
import { RenderContext, dim } from "./shared";
|
|
6
|
+
import { RenderContext, buildShadowStyle, dim } from "./shared";
|
|
7
7
|
import { GradientBox } from "./GradientBox";
|
|
8
8
|
|
|
9
9
|
export type ImageElementProps = BaseBoxProps & {
|
|
@@ -26,45 +26,58 @@ type Props = {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
export const ImageElementComponent = ({ element }: Props): React.ReactElement => {
|
|
29
|
-
const hasExplicitHeight = element.props.height !== undefined;
|
|
30
|
-
|
|
31
29
|
const p = element.props;
|
|
30
|
+
const hasShadow = p.shadowColor != null || p.elevation != null;
|
|
31
|
+
// iOS clips shadows when overflow:hidden, so a shadow-bearing Image needs a
|
|
32
|
+
// wrapper View carrying the shadow (no overflow clip) and the Image inside
|
|
33
|
+
// with the rounded clip.
|
|
34
|
+
const shadowStyle = hasShadow ? buildShadowStyle(p) : null;
|
|
32
35
|
|
|
33
|
-
if (p.backgroundGradient) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
if (p.backgroundGradient || hasShadow) {
|
|
37
|
+
const wrapperStyle = {
|
|
38
|
+
flex: p.flex,
|
|
39
|
+
flexShrink: p.flexShrink,
|
|
40
|
+
flexGrow: p.flexGrow,
|
|
41
|
+
alignSelf: p.alignSelf,
|
|
42
|
+
aspectRatio: p.aspectRatio,
|
|
43
|
+
width: dim(p.width),
|
|
44
|
+
height: dim(p.height),
|
|
45
|
+
minWidth: p.minWidth,
|
|
46
|
+
maxWidth: p.maxWidth,
|
|
47
|
+
minHeight: p.minHeight,
|
|
48
|
+
maxHeight: p.maxHeight,
|
|
49
|
+
borderRadius: p.borderRadius,
|
|
50
|
+
borderWidth: p.borderWidth,
|
|
51
|
+
borderColor: p.borderColor,
|
|
52
|
+
opacity: p.opacity,
|
|
53
|
+
margin: p.margin,
|
|
54
|
+
marginHorizontal: p.marginHorizontal,
|
|
55
|
+
marginVertical: p.marginVertical,
|
|
56
|
+
padding: p.padding,
|
|
57
|
+
paddingHorizontal: p.paddingHorizontal,
|
|
58
|
+
paddingVertical: p.paddingVertical,
|
|
59
|
+
...(shadowStyle ?? {}),
|
|
60
|
+
};
|
|
61
|
+
const innerImage = (
|
|
62
|
+
<Image
|
|
63
|
+
source={{ uri: p.url }}
|
|
64
|
+
resizeMode={p.resizeMode}
|
|
37
65
|
style={{
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
flexGrow: p.flexGrow,
|
|
41
|
-
alignSelf: p.alignSelf,
|
|
42
|
-
width: dim(p.width),
|
|
43
|
-
height: dim(p.height),
|
|
44
|
-
minWidth: p.minWidth,
|
|
45
|
-
maxWidth: p.maxWidth,
|
|
46
|
-
minHeight: p.minHeight,
|
|
47
|
-
maxHeight: p.maxHeight,
|
|
48
|
-
overflow: (p.overflow ?? "hidden") as any,
|
|
66
|
+
width: "100%",
|
|
67
|
+
height: "100%",
|
|
49
68
|
borderRadius: p.borderRadius,
|
|
50
|
-
|
|
51
|
-
borderColor: p.borderColor,
|
|
52
|
-
opacity: p.opacity,
|
|
53
|
-
margin: p.margin,
|
|
54
|
-
marginHorizontal: p.marginHorizontal,
|
|
55
|
-
marginVertical: p.marginVertical,
|
|
56
|
-
padding: p.padding,
|
|
57
|
-
paddingHorizontal: p.paddingHorizontal,
|
|
58
|
-
paddingVertical: p.paddingVertical,
|
|
69
|
+
overflow: (p.overflow ?? "hidden") as any,
|
|
59
70
|
}}
|
|
60
|
-
|
|
61
|
-
<Image
|
|
62
|
-
source={{ uri: p.url }}
|
|
63
|
-
resizeMode={p.resizeMode}
|
|
64
|
-
style={{ width: "100%", height: "100%" }}
|
|
65
|
-
/>
|
|
66
|
-
</GradientBox>
|
|
71
|
+
/>
|
|
67
72
|
);
|
|
73
|
+
if (p.backgroundGradient) {
|
|
74
|
+
return (
|
|
75
|
+
<GradientBox gradient={p.backgroundGradient} style={wrapperStyle as any}>
|
|
76
|
+
{innerImage}
|
|
77
|
+
</GradientBox>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return <View style={wrapperStyle as any}>{innerImage}</View>;
|
|
68
81
|
}
|
|
69
82
|
|
|
70
83
|
return (
|
|
@@ -76,6 +89,7 @@ export const ImageElementComponent = ({ element }: Props): React.ReactElement =>
|
|
|
76
89
|
flexShrink: p.flexShrink,
|
|
77
90
|
flexGrow: p.flexGrow,
|
|
78
91
|
alignSelf: p.alignSelf,
|
|
92
|
+
aspectRatio: p.aspectRatio,
|
|
79
93
|
width: dim(p.width),
|
|
80
94
|
height: dim(p.height),
|
|
81
95
|
minWidth: p.minWidth,
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { KeyboardAvoidingView, Platform } from "react-native";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { BaseBoxProps, BaseBoxPropsSchema } from "./BaseBoxProps";
|
|
5
|
+
import { GradientBox } from "./GradientBox";
|
|
6
|
+
import { UIElement } from "../types";
|
|
7
|
+
import { RenderContext, dim } from "./shared";
|
|
8
|
+
|
|
9
|
+
export type KeyboardAvoidingBehavior = "padding" | "height" | "position";
|
|
10
|
+
|
|
11
|
+
export type KeyboardAvoidingViewElementProps = BaseBoxProps & {
|
|
12
|
+
behavior?: KeyboardAvoidingBehavior;
|
|
13
|
+
keyboardVerticalOffset?: number;
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const KeyboardAvoidingViewElementPropsSchema = BaseBoxPropsSchema.extend({
|
|
18
|
+
behavior: z.enum(["padding", "height", "position"]).optional(),
|
|
19
|
+
keyboardVerticalOffset: z.number().optional(),
|
|
20
|
+
enabled: z.boolean().optional(),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
type KAVUIElement = Extract<UIElement, { type: "KeyboardAvoidingView" }>;
|
|
24
|
+
|
|
25
|
+
type Props = {
|
|
26
|
+
element: KAVUIElement;
|
|
27
|
+
ctx: RenderContext;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const defaultBehavior = (): KeyboardAvoidingBehavior => (Platform.OS === "ios" ? "padding" : "height");
|
|
31
|
+
|
|
32
|
+
export const KeyboardAvoidingViewElementComponent = ({ element, ctx }: Props): React.ReactElement => {
|
|
33
|
+
const p = element.props;
|
|
34
|
+
const hasGradient = !!p.backgroundGradient;
|
|
35
|
+
|
|
36
|
+
const containerStyle = {
|
|
37
|
+
flex: p.flex,
|
|
38
|
+
flexShrink: p.flexShrink,
|
|
39
|
+
flexGrow: p.flexGrow,
|
|
40
|
+
alignSelf: p.alignSelf,
|
|
41
|
+
width: dim(p.width),
|
|
42
|
+
height: dim(p.height),
|
|
43
|
+
minWidth: p.minWidth,
|
|
44
|
+
maxWidth: p.maxWidth,
|
|
45
|
+
minHeight: p.minHeight,
|
|
46
|
+
maxHeight: p.maxHeight,
|
|
47
|
+
margin: p.margin,
|
|
48
|
+
marginHorizontal: p.marginHorizontal,
|
|
49
|
+
marginVertical: p.marginVertical,
|
|
50
|
+
padding: p.padding,
|
|
51
|
+
paddingHorizontal: p.paddingHorizontal,
|
|
52
|
+
paddingVertical: p.paddingVertical,
|
|
53
|
+
backgroundColor: hasGradient ? undefined : p.backgroundColor,
|
|
54
|
+
borderWidth: p.borderWidth,
|
|
55
|
+
borderRadius: p.borderRadius,
|
|
56
|
+
borderColor: p.borderColor,
|
|
57
|
+
overflow: hasGradient ? ("hidden" as const) : p.overflow,
|
|
58
|
+
opacity: p.opacity,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const kav = (
|
|
62
|
+
<KeyboardAvoidingView
|
|
63
|
+
behavior={p.behavior ?? defaultBehavior()}
|
|
64
|
+
keyboardVerticalOffset={p.keyboardVerticalOffset ?? 0}
|
|
65
|
+
enabled={p.enabled ?? true}
|
|
66
|
+
style={hasGradient ? { flex: 1 } : containerStyle}
|
|
67
|
+
>
|
|
68
|
+
{ctx.renderChildren(element.children, "YStack")}
|
|
69
|
+
</KeyboardAvoidingView>
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
if (hasGradient) {
|
|
73
|
+
return (
|
|
74
|
+
<GradientBox gradient={p.backgroundGradient} style={containerStyle}>
|
|
75
|
+
{kav}
|
|
76
|
+
</GradientBox>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return kav;
|
|
81
|
+
};
|
|
@@ -57,13 +57,25 @@ type Props = {
|
|
|
57
57
|
export const RiveElementRenderer = ({ element, ctx }: Props): React.ReactElement => {
|
|
58
58
|
const { theme } = ctx;
|
|
59
59
|
const p = element.props;
|
|
60
|
+
// rive-react-native doesn't report artboard intrinsic to JS, so a Rive view
|
|
61
|
+
// with no height/flex/aspectRatio reports its native artboard pixel size as
|
|
62
|
+
// intrinsic — which fills the screen. Fall back to aspectRatio:1 (square)
|
|
63
|
+
// so width:100% bounds the box deterministically when the author hasn't
|
|
64
|
+
// sized it.
|
|
65
|
+
const hasExplicitSize =
|
|
66
|
+
p.height != null ||
|
|
67
|
+
p.flex != null ||
|
|
68
|
+
p.aspectRatio != null ||
|
|
69
|
+
p.minHeight != null ||
|
|
70
|
+
p.maxHeight != null;
|
|
60
71
|
const wrapperStyle = {
|
|
61
72
|
flex: p.flex,
|
|
62
73
|
flexShrink: p.flexShrink,
|
|
63
74
|
flexGrow: p.flexGrow,
|
|
75
|
+
aspectRatio: p.aspectRatio ?? (hasExplicitSize ? undefined : 1),
|
|
64
76
|
alignSelf: p.alignSelf,
|
|
65
77
|
width: dim(p.width) ?? ("100%" as `${number}%`),
|
|
66
|
-
height: dim(p.height
|
|
78
|
+
height: dim(p.height),
|
|
67
79
|
minWidth: p.minWidth,
|
|
68
80
|
maxWidth: p.maxWidth,
|
|
69
81
|
minHeight: p.minHeight,
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ScrollView } from "react-native";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { BaseBoxProps, BaseBoxPropsSchema } from "./BaseBoxProps";
|
|
5
|
+
import { GradientBox } from "./GradientBox";
|
|
6
|
+
import { UIElement } from "../types";
|
|
7
|
+
import { RenderContext, dim } from "./shared";
|
|
8
|
+
|
|
9
|
+
export type ScrollViewContentInset = {
|
|
10
|
+
top?: number;
|
|
11
|
+
right?: number;
|
|
12
|
+
bottom?: number;
|
|
13
|
+
left?: number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type ScrollViewElementProps = BaseBoxProps & {
|
|
17
|
+
horizontal?: boolean;
|
|
18
|
+
bounces?: boolean;
|
|
19
|
+
showsVerticalScrollIndicator?: boolean;
|
|
20
|
+
showsHorizontalScrollIndicator?: boolean;
|
|
21
|
+
alwaysBounceVertical?: boolean;
|
|
22
|
+
alwaysBounceHorizontal?: boolean;
|
|
23
|
+
contentInset?: ScrollViewContentInset;
|
|
24
|
+
contentContainerPadding?: number;
|
|
25
|
+
keyboardShouldPersistTaps?: "always" | "never" | "handled";
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const ContentInsetSchema = z.object({
|
|
29
|
+
top: z.number().optional(),
|
|
30
|
+
right: z.number().optional(),
|
|
31
|
+
bottom: z.number().optional(),
|
|
32
|
+
left: z.number().optional(),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const ScrollViewElementPropsSchema = BaseBoxPropsSchema.extend({
|
|
36
|
+
horizontal: z.boolean().optional(),
|
|
37
|
+
bounces: z.boolean().optional(),
|
|
38
|
+
showsVerticalScrollIndicator: z.boolean().optional(),
|
|
39
|
+
showsHorizontalScrollIndicator: z.boolean().optional(),
|
|
40
|
+
alwaysBounceVertical: z.boolean().optional(),
|
|
41
|
+
alwaysBounceHorizontal: z.boolean().optional(),
|
|
42
|
+
contentInset: ContentInsetSchema.optional(),
|
|
43
|
+
contentContainerPadding: z.number().min(0).optional(),
|
|
44
|
+
keyboardShouldPersistTaps: z.enum(["always", "never", "handled"]).optional(),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
type ScrollViewUIElement = Extract<UIElement, { type: "ScrollView" }>;
|
|
48
|
+
|
|
49
|
+
type Props = {
|
|
50
|
+
element: ScrollViewUIElement;
|
|
51
|
+
ctx: RenderContext;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const ScrollViewElementComponent = ({ element, ctx }: Props): React.ReactElement => {
|
|
55
|
+
const p = element.props;
|
|
56
|
+
const hasGradient = !!p.backgroundGradient;
|
|
57
|
+
const horizontal = p.horizontal === true;
|
|
58
|
+
|
|
59
|
+
const containerStyle = {
|
|
60
|
+
flex: p.flex,
|
|
61
|
+
flexShrink: p.flexShrink,
|
|
62
|
+
flexGrow: p.flexGrow,
|
|
63
|
+
alignSelf: p.alignSelf,
|
|
64
|
+
width: dim(p.width),
|
|
65
|
+
height: dim(p.height),
|
|
66
|
+
minWidth: p.minWidth,
|
|
67
|
+
maxWidth: p.maxWidth,
|
|
68
|
+
minHeight: p.minHeight,
|
|
69
|
+
maxHeight: p.maxHeight,
|
|
70
|
+
margin: p.margin,
|
|
71
|
+
marginHorizontal: p.marginHorizontal,
|
|
72
|
+
marginVertical: p.marginVertical,
|
|
73
|
+
padding: p.padding,
|
|
74
|
+
paddingHorizontal: p.paddingHorizontal,
|
|
75
|
+
paddingVertical: p.paddingVertical,
|
|
76
|
+
backgroundColor: hasGradient ? undefined : p.backgroundColor,
|
|
77
|
+
borderWidth: p.borderWidth,
|
|
78
|
+
borderRadius: p.borderRadius,
|
|
79
|
+
borderColor: p.borderColor,
|
|
80
|
+
overflow: hasGradient ? ("hidden" as const) : p.overflow,
|
|
81
|
+
opacity: p.opacity,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const contentContainerStyle = {
|
|
85
|
+
flexGrow: 1,
|
|
86
|
+
padding: p.contentContainerPadding,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const scroll = (
|
|
90
|
+
<ScrollView
|
|
91
|
+
horizontal={horizontal}
|
|
92
|
+
bounces={p.bounces}
|
|
93
|
+
showsVerticalScrollIndicator={p.showsVerticalScrollIndicator}
|
|
94
|
+
showsHorizontalScrollIndicator={p.showsHorizontalScrollIndicator}
|
|
95
|
+
alwaysBounceVertical={p.alwaysBounceVertical}
|
|
96
|
+
alwaysBounceHorizontal={p.alwaysBounceHorizontal}
|
|
97
|
+
contentInset={p.contentInset}
|
|
98
|
+
keyboardShouldPersistTaps={p.keyboardShouldPersistTaps ?? "handled"}
|
|
99
|
+
style={hasGradient ? { flex: 1 } : containerStyle}
|
|
100
|
+
contentContainerStyle={contentContainerStyle}
|
|
101
|
+
>
|
|
102
|
+
{ctx.renderChildren(element.children, horizontal ? "XStack" : "YStack")}
|
|
103
|
+
</ScrollView>
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
if (hasGradient) {
|
|
107
|
+
return (
|
|
108
|
+
<GradientBox gradient={p.backgroundGradient} style={containerStyle}>
|
|
109
|
+
{scroll}
|
|
110
|
+
</GradientBox>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return scroll;
|
|
115
|
+
};
|
|
@@ -17,6 +17,8 @@ import { DatePickerElementComponent } from "./DatePickerElement";
|
|
|
17
17
|
import { CarouselElementComponent } from "./CarouselElement";
|
|
18
18
|
import { ZStackElementComponent } from "./ZStackElement";
|
|
19
19
|
import { SafeAreaViewElementComponent } from "./SafeAreaViewElement";
|
|
20
|
+
import { ScrollViewElementComponent } from "./ScrollViewElement";
|
|
21
|
+
import { KeyboardAvoidingViewElementComponent } from "./KeyboardAvoidingViewElement";
|
|
20
22
|
|
|
21
23
|
export const renderElement = (
|
|
22
24
|
element: UIElement,
|
|
@@ -90,5 +92,13 @@ export const renderElement = (
|
|
|
90
92
|
return <SafeAreaViewElementComponent key={element.id} element={element} ctx={ctx} />;
|
|
91
93
|
}
|
|
92
94
|
|
|
95
|
+
if (element.type === "ScrollView") {
|
|
96
|
+
return <ScrollViewElementComponent key={element.id} element={element} ctx={ctx} />;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (element.type === "KeyboardAvoidingView") {
|
|
100
|
+
return <KeyboardAvoidingViewElementComponent key={element.id} element={element} ctx={ctx} />;
|
|
101
|
+
}
|
|
102
|
+
|
|
93
103
|
return null;
|
|
94
104
|
};
|
|
@@ -3,6 +3,7 @@ import { CustomActions } from "@rocapine/react-native-onboarding";
|
|
|
3
3
|
import { UIElement } from "../types";
|
|
4
4
|
import { Theme } from "../../../Theme/types";
|
|
5
5
|
import { ComposableVariableEntry } from "../../../Provider/OnboardingProgressProvider";
|
|
6
|
+
import type { BaseBoxProps } from "./BaseBoxProps";
|
|
6
7
|
|
|
7
8
|
export type RenderContext = {
|
|
8
9
|
theme: Theme;
|
|
@@ -20,6 +21,25 @@ export const interpolate = (template: string, variables: Record<string, Composab
|
|
|
20
21
|
export const dim = (v: number | string | undefined): import("react-native").DimensionValue | undefined =>
|
|
21
22
|
v as import("react-native").DimensionValue | undefined;
|
|
22
23
|
|
|
24
|
+
// Build a RN shadow style with sensible iOS defaults. iOS defaults
|
|
25
|
+
// `shadowOpacity` to 0 and `shadowRadius` to 0, so an author setting only
|
|
26
|
+
// `shadowColor` would see no shadow. Fill in 1 / 4 when those are unset.
|
|
27
|
+
// Android shadows go through `elevation` independently.
|
|
28
|
+
export type ShadowStyleInput = Pick<
|
|
29
|
+
BaseBoxProps,
|
|
30
|
+
"shadowColor" | "shadowOffset" | "shadowOpacity" | "shadowRadius" | "elevation"
|
|
31
|
+
>;
|
|
32
|
+
export const buildShadowStyle = (p: ShadowStyleInput) => {
|
|
33
|
+
const hasShadow = p.shadowColor != null;
|
|
34
|
+
return {
|
|
35
|
+
shadowColor: p.shadowColor,
|
|
36
|
+
shadowOffset: p.shadowOffset,
|
|
37
|
+
shadowOpacity: p.shadowOpacity ?? (hasShadow ? 1 : undefined),
|
|
38
|
+
shadowRadius: p.shadowRadius ?? (hasShadow ? 4 : undefined),
|
|
39
|
+
elevation: p.elevation,
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
23
43
|
// Resolve element fontFamily against theme `typography.defaultFontFamily`.
|
|
24
44
|
// Returns the theme default when element omits fontFamily or sets it to "inherit".
|
|
25
45
|
export const resolveInheritedFontFamily = (
|