@rocapine/react-native-onboarding-ui 1.31.0 → 1.33.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/dist/UI/Pages/ComposableScreen/Renderer.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/AnimatedBox.d.ts +21 -0
- package/dist/UI/Pages/ComposableScreen/elements/AnimatedBox.d.ts.map +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/AnimatedBox.js +140 -0
- package/dist/UI/Pages/ComposableScreen/elements/AnimatedBox.js.map +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/BaseBoxProps.d.ts +220 -0
- package/dist/UI/Pages/ComposableScreen/elements/BaseBoxProps.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/BaseBoxProps.js +83 -0
- package/dist/UI/Pages/ComposableScreen/elements/BaseBoxProps.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ButtonElement.d.ts +640 -0
- package/dist/UI/Pages/ComposableScreen/elements/ButtonElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/CarouselElement.d.ts +160 -0
- package/dist/UI/Pages/ComposableScreen/elements/CarouselElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/CheckboxGroupElement.d.ts +160 -0
- package/dist/UI/Pages/ComposableScreen/elements/CheckboxGroupElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/DatePickerElement.d.ts +160 -0
- package/dist/UI/Pages/ComposableScreen/elements/DatePickerElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/IconElement.d.ts +160 -0
- package/dist/UI/Pages/ComposableScreen/elements/IconElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ImageElement.d.ts +160 -0
- package/dist/UI/Pages/ComposableScreen/elements/ImageElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/InputElement.d.ts +160 -0
- package/dist/UI/Pages/ComposableScreen/elements/InputElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/KeyboardAvoidingViewElement.d.ts +160 -0
- package/dist/UI/Pages/ComposableScreen/elements/KeyboardAvoidingViewElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/LottieElement.d.ts +160 -0
- package/dist/UI/Pages/ComposableScreen/elements/LottieElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ProgressIndicatorElement.d.ts +160 -0
- package/dist/UI/Pages/ComposableScreen/elements/ProgressIndicatorElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ProgressIndicatorElement.js +2 -8
- package/dist/UI/Pages/ComposableScreen/elements/ProgressIndicatorElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/RadioGroupElement.d.ts +160 -0
- package/dist/UI/Pages/ComposableScreen/elements/RadioGroupElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/RichTextElement.d.ts +305 -0
- package/dist/UI/Pages/ComposableScreen/elements/RichTextElement.d.ts.map +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/RichTextElement.js +133 -0
- package/dist/UI/Pages/ComposableScreen/elements/RichTextElement.js.map +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/RiveElement.d.ts +160 -0
- package/dist/UI/Pages/ComposableScreen/elements/RiveElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/SafeAreaViewElement.d.ts +160 -0
- package/dist/UI/Pages/ComposableScreen/elements/SafeAreaViewElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ScrollViewElement.d.ts +160 -0
- package/dist/UI/Pages/ComposableScreen/elements/ScrollViewElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/StackElement.d.ts +161 -1
- package/dist/UI/Pages/ComposableScreen/elements/StackElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/TextElement.d.ts +199 -1
- package/dist/UI/Pages/ComposableScreen/elements/TextElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/TextElement.js +38 -12
- package/dist/UI/Pages/ComposableScreen/elements/TextElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/VideoElement.d.ts +160 -0
- package/dist/UI/Pages/ComposableScreen/elements/VideoElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ZStackElement.d.ts +160 -0
- package/dist/UI/Pages/ComposableScreen/elements/ZStackElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/buildAnimation.d.ts +9 -0
- package/dist/UI/Pages/ComposableScreen/elements/buildAnimation.d.ts.map +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/buildAnimation.js +106 -0
- package/dist/UI/Pages/ComposableScreen/elements/buildAnimation.js.map +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/renderElement.d.ts +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/renderElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/renderElement.js +76 -58
- package/dist/UI/Pages/ComposableScreen/elements/renderElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/shared.d.ts +12 -1
- package/dist/UI/Pages/ComposableScreen/elements/shared.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/shared.js +6 -1
- package/dist/UI/Pages/ComposableScreen/elements/shared.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/types.d.ts +11 -0
- package/dist/UI/Pages/ComposableScreen/types.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/types.js +15 -2
- package/dist/UI/Pages/ComposableScreen/types.js.map +1 -1
- package/package.json +1 -1
- package/src/UI/Pages/ComposableScreen/Renderer.tsx +1 -1
- package/src/UI/Pages/ComposableScreen/elements/AnimatedBox.tsx +133 -0
- package/src/UI/Pages/ComposableScreen/elements/BaseBoxProps.ts +211 -0
- package/src/UI/Pages/ComposableScreen/elements/ProgressIndicatorElement.tsx +1 -9
- package/src/UI/Pages/ComposableScreen/elements/RichTextElement.tsx +177 -0
- package/src/UI/Pages/ComposableScreen/elements/StackElement.tsx +1 -1
- package/src/UI/Pages/ComposableScreen/elements/TextElement.tsx +39 -11
- package/src/UI/Pages/ComposableScreen/elements/buildAnimation.ts +83 -0
- package/src/UI/Pages/ComposableScreen/elements/renderElement.tsx +34 -2
- package/src/UI/Pages/ComposableScreen/elements/shared.ts +19 -1
- package/src/UI/Pages/ComposableScreen/types.ts +25 -2
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { evaluateCondition } from "@rocapine/react-native-onboarding";
|
|
3
3
|
import { UIElement } from "../types";
|
|
4
|
+
import { BaseBoxProps } from "./BaseBoxProps";
|
|
4
5
|
import { RenderContext } from "./shared";
|
|
5
6
|
import { StackElementComponent } from "./StackElement";
|
|
6
7
|
import { TextElementComponent } from "./TextElement";
|
|
8
|
+
import { RichTextElementComponent } from "./RichTextElement";
|
|
7
9
|
import { ImageElementComponent } from "./ImageElement";
|
|
8
10
|
import { LottieElementComponent } from "./LottieElement";
|
|
9
11
|
import { RiveElementRenderer } from "./RiveElement";
|
|
@@ -21,11 +23,12 @@ import { SafeAreaViewElementComponent } from "./SafeAreaViewElement";
|
|
|
21
23
|
import { ScrollViewElementComponent } from "./ScrollViewElement";
|
|
22
24
|
import { KeyboardAvoidingViewElementComponent } from "./KeyboardAvoidingViewElement";
|
|
23
25
|
import { ProgressIndicatorElementComponent } from "./ProgressIndicatorElement";
|
|
26
|
+
import { AnimatedBox } from "./AnimatedBox";
|
|
24
27
|
|
|
25
28
|
export const renderElement = (
|
|
26
29
|
element: UIElement,
|
|
27
30
|
ctx: RenderContext,
|
|
28
|
-
parentType?: "XStack" | "YStack" | "ZStack"
|
|
31
|
+
parentType?: "XStack" | "YStack" | "ZStack" | "RichText"
|
|
29
32
|
): React.ReactNode => {
|
|
30
33
|
if (element.renderWhen) {
|
|
31
34
|
const flatVars = Object.fromEntries(
|
|
@@ -34,6 +37,9 @@ export const renderElement = (
|
|
|
34
37
|
if (!evaluateCondition(element.renderWhen, flatVars)) return null;
|
|
35
38
|
}
|
|
36
39
|
|
|
40
|
+
// Dispatch to the concrete element renderer. Captured into `node` so a single
|
|
41
|
+
// AnimatedBox wrapper can apply animation/transform to any of the 15 types.
|
|
42
|
+
const node = ((): React.ReactNode => {
|
|
37
43
|
if (element.type === "YStack" || element.type === "XStack") {
|
|
38
44
|
return <StackElementComponent key={element.id} element={element} ctx={ctx} parentType={parentType} />;
|
|
39
45
|
}
|
|
@@ -42,6 +48,10 @@ export const renderElement = (
|
|
|
42
48
|
return <TextElementComponent key={element.id} element={element} ctx={ctx} parentType={parentType} />;
|
|
43
49
|
}
|
|
44
50
|
|
|
51
|
+
if (element.type === "RichText") {
|
|
52
|
+
return <RichTextElementComponent key={element.id} element={element} ctx={ctx} parentType={parentType} />;
|
|
53
|
+
}
|
|
54
|
+
|
|
45
55
|
if (element.type === "Image") {
|
|
46
56
|
return <ImageElementComponent key={element.id} element={element} ctx={ctx} />;
|
|
47
57
|
}
|
|
@@ -110,5 +120,27 @@ export const renderElement = (
|
|
|
110
120
|
return <ProgressIndicatorElementComponent key={element.id} element={element} ctx={ctx} />;
|
|
111
121
|
}
|
|
112
122
|
|
|
113
|
-
|
|
123
|
+
return null;
|
|
124
|
+
})();
|
|
125
|
+
|
|
126
|
+
// Wrap only when motion is requested — zero overhead (no extra view) otherwise.
|
|
127
|
+
// Cast to BaseBoxProps: not every element's props type extends it (e.g.
|
|
128
|
+
// WheelPicker), but the animation/transform/flex/alignSelf fields are all
|
|
129
|
+
// optional BaseBoxProps members and simply read as undefined when absent.
|
|
130
|
+
const p = element.props as BaseBoxProps;
|
|
131
|
+
if (node !== null && (p.animation || p.transform)) {
|
|
132
|
+
return (
|
|
133
|
+
<AnimatedBox
|
|
134
|
+
key={element.id}
|
|
135
|
+
animation={p.animation}
|
|
136
|
+
transform={p.transform}
|
|
137
|
+
flex={p.flex}
|
|
138
|
+
alignSelf={p.alignSelf}
|
|
139
|
+
>
|
|
140
|
+
{node}
|
|
141
|
+
</AnimatedBox>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return node;
|
|
114
146
|
};
|
|
@@ -11,9 +11,27 @@ export type RenderContext = {
|
|
|
11
11
|
setVariable: (key: string, entry: ComposableVariableEntry) => void;
|
|
12
12
|
onContinue: () => void;
|
|
13
13
|
customActions: CustomActions;
|
|
14
|
-
renderChildren: (elements: UIElement[], parentType: "XStack" | "YStack" | "ZStack") => React.ReactNode;
|
|
14
|
+
renderChildren: (elements: UIElement[], parentType: "XStack" | "YStack" | "ZStack" | "RichText") => React.ReactNode;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
// Text-style defaults a `RichText` container hands down to its child `Text`
|
|
18
|
+
// elements. A `<View>` doesn't propagate text style to nested `<Text>`, so the
|
|
19
|
+
// RichText renderer publishes these via context and `TextElementComponent`
|
|
20
|
+
// merges them under its own props (child always wins). Empty default ({}) means
|
|
21
|
+
// Text elements outside a RichText behave unchanged.
|
|
22
|
+
export type InheritedTextStyle = {
|
|
23
|
+
fontSize?: number;
|
|
24
|
+
fontWeight?: string;
|
|
25
|
+
fontFamily?: string | "inherit";
|
|
26
|
+
fontStyle?: "normal" | "italic";
|
|
27
|
+
color?: string;
|
|
28
|
+
textAlign?: "left" | "center" | "right";
|
|
29
|
+
letterSpacing?: number;
|
|
30
|
+
lineHeight?: number;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const RichTextStyleContext = React.createContext<InheritedTextStyle>({});
|
|
34
|
+
|
|
17
35
|
export const interpolate = (template: string, variables: Record<string, ComposableVariableEntry>): string =>
|
|
18
36
|
template.replace(/\{\{([^}]+?)\}\}/g, (_, key) => variables[key]?.label ?? variables[key]?.value ?? "");
|
|
19
37
|
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
import { CustomPayloadSchema } from "../types";
|
|
11
11
|
import { type StackElementProps, StackElementPropsSchema } from "./elements/StackElement";
|
|
12
12
|
import { type TextElementProps, TextElementPropsSchema } from "./elements/TextElement";
|
|
13
|
+
import { type RichTextElementProps, RichTextElementPropsSchema } from "./elements/RichTextElement";
|
|
13
14
|
import { type ImageElementProps, ImageElementPropsSchema } from "./elements/ImageElement";
|
|
14
15
|
import { type LottieElementProps, LottieElementPropsSchema } from "./elements/LottieElement";
|
|
15
16
|
import { type RiveElementProps, RiveElementPropsSchema } from "./elements/RiveElement";
|
|
@@ -37,6 +38,7 @@ export type { BaseBoxProps } from "./elements/BaseBoxProps";
|
|
|
37
38
|
export { BaseBoxPropsSchema } from "./elements/BaseBoxProps";
|
|
38
39
|
export type { StackElementProps } from "./elements/StackElement";
|
|
39
40
|
export type { TextElementProps } from "./elements/TextElement";
|
|
41
|
+
export type { RichTextElementProps } from "./elements/RichTextElement";
|
|
40
42
|
export type { ImageElementProps } from "./elements/ImageElement";
|
|
41
43
|
export type { LottieElementProps } from "./elements/LottieElement";
|
|
42
44
|
export type { RiveElementProps } from "./elements/RiveElement";
|
|
@@ -76,6 +78,14 @@ export type UIElement =
|
|
|
76
78
|
type: "Text";
|
|
77
79
|
props: TextElementProps;
|
|
78
80
|
}
|
|
81
|
+
| {
|
|
82
|
+
id: string;
|
|
83
|
+
name?: string;
|
|
84
|
+
renderWhen?: LeafCondition | ConditionGroup;
|
|
85
|
+
type: "RichText";
|
|
86
|
+
props: RichTextElementProps;
|
|
87
|
+
children: Array<Extract<UIElement, { type: "Text" }>>;
|
|
88
|
+
}
|
|
79
89
|
| {
|
|
80
90
|
id: string;
|
|
81
91
|
name?: string;
|
|
@@ -201,6 +211,17 @@ export type UIElement =
|
|
|
201
211
|
props: ProgressIndicatorElementProps;
|
|
202
212
|
};
|
|
203
213
|
|
|
214
|
+
// The `Text` variant, extracted so `RichText` can restrict its children to
|
|
215
|
+
// Text-only (children: z.array(TextUIElementSchema)) while the union references
|
|
216
|
+
// the same object.
|
|
217
|
+
const TextUIElementSchema = z.object({
|
|
218
|
+
id: z.string(),
|
|
219
|
+
name: z.string().optional(),
|
|
220
|
+
renderWhen: z.union([LeafConditionSchema, ConditionGroupSchema]).optional(),
|
|
221
|
+
type: z.literal("Text"),
|
|
222
|
+
props: TextElementPropsSchema,
|
|
223
|
+
});
|
|
224
|
+
|
|
204
225
|
export const UIElementSchema: z.ZodType<UIElement> = z.lazy(() =>
|
|
205
226
|
z.union([
|
|
206
227
|
z.object({
|
|
@@ -211,12 +232,14 @@ export const UIElementSchema: z.ZodType<UIElement> = z.lazy(() =>
|
|
|
211
232
|
props: StackElementPropsSchema,
|
|
212
233
|
children: z.array(UIElementSchema),
|
|
213
234
|
}),
|
|
235
|
+
TextUIElementSchema,
|
|
214
236
|
z.object({
|
|
215
237
|
id: z.string(),
|
|
216
238
|
name: z.string().optional(),
|
|
217
239
|
renderWhen: z.union([LeafConditionSchema, ConditionGroupSchema]).optional(),
|
|
218
|
-
type: z.literal("
|
|
219
|
-
props:
|
|
240
|
+
type: z.literal("RichText"),
|
|
241
|
+
props: RichTextElementPropsSchema,
|
|
242
|
+
children: z.array(TextUIElementSchema),
|
|
220
243
|
}),
|
|
221
244
|
z.object({
|
|
222
245
|
id: z.string(),
|