@rocapine/react-native-onboarding 1.11.1 → 1.13.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/evaluateCondition.d.ts +6 -0
- package/dist/evaluateCondition.d.ts.map +1 -0
- package/dist/evaluateCondition.js +48 -0
- package/dist/evaluateCondition.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/infra/provider/OnboardingProvider.d.ts +2 -0
- package/dist/infra/provider/OnboardingProvider.d.ts.map +1 -1
- package/dist/infra/provider/OnboardingProvider.js +8 -0
- package/dist/infra/provider/OnboardingProvider.js.map +1 -1
- package/dist/onboarding-example.d.ts +174 -0
- package/dist/onboarding-example.d.ts.map +1 -1
- package/dist/onboarding-example.js +50 -0
- package/dist/onboarding-example.js.map +1 -1
- package/dist/resolveNextStepNumber.d.ts +11 -0
- package/dist/resolveNextStepNumber.d.ts.map +1 -0
- package/dist/resolveNextStepNumber.js +39 -0
- package/dist/resolveNextStepNumber.js.map +1 -0
- package/dist/steps/Carousel/types.d.ts +29 -8
- package/dist/steps/Carousel/types.d.ts.map +1 -1
- package/dist/steps/Carousel/types.js +1 -8
- package/dist/steps/Carousel/types.js.map +1 -1
- package/dist/steps/Commitment/types.d.ts +29 -8
- package/dist/steps/Commitment/types.d.ts.map +1 -1
- package/dist/steps/Commitment/types.js +1 -8
- package/dist/steps/Commitment/types.js.map +1 -1
- package/dist/steps/ComposableScreen/elements/BaseBoxProps.d.ts +67 -0
- package/dist/steps/ComposableScreen/elements/BaseBoxProps.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/BaseBoxProps.js +15 -1
- package/dist/steps/ComposableScreen/elements/BaseBoxProps.js.map +1 -1
- package/dist/steps/ComposableScreen/elements/ButtonElement.d.ts +28 -1
- package/dist/steps/ComposableScreen/elements/ButtonElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/CarouselElement.d.ts +27 -0
- package/dist/steps/ComposableScreen/elements/CarouselElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/CheckboxGroupElement.d.ts +27 -0
- package/dist/steps/ComposableScreen/elements/CheckboxGroupElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/DatePickerElement.d.ts +27 -0
- package/dist/steps/ComposableScreen/elements/DatePickerElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/IconElement.d.ts +27 -0
- package/dist/steps/ComposableScreen/elements/IconElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/ImageElement.d.ts +27 -0
- package/dist/steps/ComposableScreen/elements/ImageElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/InputElement.d.ts +30 -3
- package/dist/steps/ComposableScreen/elements/InputElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/LottieElement.d.ts +27 -0
- package/dist/steps/ComposableScreen/elements/LottieElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/RadioGroupElement.d.ts +27 -0
- package/dist/steps/ComposableScreen/elements/RadioGroupElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/RiveElement.d.ts +27 -0
- package/dist/steps/ComposableScreen/elements/RiveElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/StackElement.d.ts +27 -0
- package/dist/steps/ComposableScreen/elements/StackElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/TextElement.d.ts +28 -1
- package/dist/steps/ComposableScreen/elements/TextElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/VideoElement.d.ts +27 -0
- package/dist/steps/ComposableScreen/elements/VideoElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/types.d.ts +31 -6
- package/dist/steps/ComposableScreen/types.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/types.js +3 -8
- package/dist/steps/ComposableScreen/types.js.map +1 -1
- package/dist/steps/Loader/types.d.ts +29 -8
- package/dist/steps/Loader/types.d.ts.map +1 -1
- package/dist/steps/Loader/types.js +1 -8
- package/dist/steps/Loader/types.js.map +1 -1
- package/dist/steps/MediaContent/types.d.ts +29 -8
- package/dist/steps/MediaContent/types.d.ts.map +1 -1
- package/dist/steps/MediaContent/types.js +1 -8
- package/dist/steps/MediaContent/types.js.map +1 -1
- package/dist/steps/Picker/types.d.ts +30 -8
- package/dist/steps/Picker/types.d.ts.map +1 -1
- package/dist/steps/Picker/types.js +2 -8
- package/dist/steps/Picker/types.js.map +1 -1
- package/dist/steps/Question/types.d.ts +30 -8
- package/dist/steps/Question/types.d.ts.map +1 -1
- package/dist/steps/Question/types.js +2 -8
- package/dist/steps/Question/types.js.map +1 -1
- package/dist/steps/Ratings/types.d.ts +29 -8
- package/dist/steps/Ratings/types.d.ts.map +1 -1
- package/dist/steps/Ratings/types.js +1 -8
- package/dist/steps/Ratings/types.js.map +1 -1
- package/dist/steps/common.types.d.ts +109 -0
- package/dist/steps/common.types.d.ts.map +1 -1
- package/dist/steps/common.types.js +52 -1
- package/dist/steps/common.types.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -2
- package/src/__tests__/evaluateCondition.test.ts +167 -0
- package/src/__tests__/resolveNextStepNumber.test.ts +309 -0
- package/src/evaluateCondition.ts +50 -0
- package/src/index.ts +19 -0
- package/src/infra/provider/OnboardingProvider.tsx +11 -1
- package/src/onboarding-example.ts +50 -0
- package/src/resolveNextStepNumber.ts +41 -0
- package/src/steps/Carousel/types.ts +2 -9
- package/src/steps/Commitment/types.ts +2 -9
- package/src/steps/ComposableScreen/elements/BaseBoxProps.ts +42 -0
- package/src/steps/ComposableScreen/types.ts +4 -10
- package/src/steps/Loader/types.ts +2 -9
- package/src/steps/MediaContent/types.ts +2 -14
- package/src/steps/Picker/types.ts +3 -9
- package/src/steps/Question/types.ts +3 -9
- package/src/steps/Ratings/types.ts +2 -9
- package/src/steps/common.types.ts +72 -0
- package/src/types.ts +3 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { BaseStepTypeSchema, MediaSourceSchema } from "../common.types";
|
|
3
3
|
|
|
4
4
|
export const LoaderStepSchema = z.object({
|
|
5
5
|
label: z.string(),
|
|
@@ -17,16 +17,9 @@ export const LoaderStepPayloadSchema = z.object({
|
|
|
17
17
|
.default("bars"),
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
export const LoaderStepTypeSchema =
|
|
21
|
-
id: z.string(),
|
|
20
|
+
export const LoaderStepTypeSchema = BaseStepTypeSchema.extend({
|
|
22
21
|
type: z.literal("Loader"),
|
|
23
|
-
name: z.string(),
|
|
24
|
-
displayProgressHeader: z.boolean(),
|
|
25
22
|
payload: LoaderStepPayloadSchema,
|
|
26
|
-
customPayload: CustomPayloadSchema,
|
|
27
|
-
continueButtonLabel: z.string().optional().default("Continue"),
|
|
28
|
-
buttonSection: ButtonSectionSchema.optional(),
|
|
29
|
-
figmaUrl: z.string().nullish(),
|
|
30
23
|
});
|
|
31
24
|
|
|
32
25
|
export type LoaderStepType = z.infer<typeof LoaderStepTypeSchema>;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
ButtonSectionSchema,
|
|
4
|
-
CustomPayloadSchema,
|
|
5
|
-
MediaSourceSchema,
|
|
6
|
-
SocialProofSchema,
|
|
7
|
-
} from "../common.types";
|
|
2
|
+
import { BaseStepTypeSchema, MediaSourceSchema, SocialProofSchema } from "../common.types";
|
|
8
3
|
|
|
9
4
|
export const MediaContentLayoutStyleSchema = z.enum(["default", "media_top", "media_bottom"]).default("default");
|
|
10
5
|
|
|
@@ -16,16 +11,9 @@ export const MediaContentStepPayloadSchema = z.object({
|
|
|
16
11
|
layoutStyle: MediaContentLayoutStyleSchema.optional(),
|
|
17
12
|
});
|
|
18
13
|
|
|
19
|
-
export const MediaContentStepTypeSchema =
|
|
20
|
-
id: z.string(),
|
|
14
|
+
export const MediaContentStepTypeSchema = BaseStepTypeSchema.extend({
|
|
21
15
|
type: z.literal("MediaContent"),
|
|
22
|
-
name: z.string(),
|
|
23
|
-
displayProgressHeader: z.boolean(),
|
|
24
16
|
payload: MediaContentStepPayloadSchema,
|
|
25
|
-
customPayload: CustomPayloadSchema,
|
|
26
|
-
continueButtonLabel: z.string().optional().default("Continue"),
|
|
27
|
-
buttonSection: ButtonSectionSchema.optional(),
|
|
28
|
-
figmaUrl: z.string().nullish(),
|
|
29
17
|
});
|
|
30
18
|
|
|
31
19
|
export type MediaContentStepType = z.infer<typeof MediaContentStepTypeSchema>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { BaseStepTypeSchema } from "../common.types";
|
|
3
3
|
|
|
4
4
|
export const PickerTypeEnum = z.enum([
|
|
5
5
|
"height",
|
|
@@ -17,16 +17,10 @@ export const PickerStepPayloadSchema = z.object({
|
|
|
17
17
|
pickerType: z.union([PickerTypeEnum, z.string()]),
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
export const PickerStepTypeSchema =
|
|
21
|
-
id: z.string(),
|
|
20
|
+
export const PickerStepTypeSchema = BaseStepTypeSchema.extend({
|
|
22
21
|
type: z.literal("Picker"),
|
|
23
|
-
name: z.string(),
|
|
24
|
-
displayProgressHeader: z.boolean(),
|
|
25
22
|
payload: PickerStepPayloadSchema,
|
|
26
|
-
|
|
27
|
-
continueButtonLabel: z.string().optional().default("Continue"),
|
|
28
|
-
buttonSection: ButtonSectionSchema.optional(),
|
|
29
|
-
figmaUrl: z.string().nullish(),
|
|
23
|
+
variableName: z.string().min(1).optional(),
|
|
30
24
|
});
|
|
31
25
|
|
|
32
26
|
export type PickerStepType = z.infer<typeof PickerStepTypeSchema>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { BaseStepTypeSchema, InfoBoxSchema } from "../common.types";
|
|
3
3
|
|
|
4
4
|
export const AnswerSchema = z.object({
|
|
5
5
|
label: z.string(),
|
|
@@ -16,16 +16,10 @@ export const QuestionStepPayloadSchema = z.object({
|
|
|
16
16
|
infoBox: InfoBoxSchema.nullish(),
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
export const QuestionStepTypeSchema =
|
|
20
|
-
id: z.string(),
|
|
19
|
+
export const QuestionStepTypeSchema = BaseStepTypeSchema.extend({
|
|
21
20
|
type: z.literal("Question"),
|
|
22
|
-
name: z.string(),
|
|
23
|
-
displayProgressHeader: z.boolean(),
|
|
24
21
|
payload: QuestionStepPayloadSchema,
|
|
25
|
-
|
|
26
|
-
continueButtonLabel: z.string().optional().default("Continue"),
|
|
27
|
-
buttonSection: ButtonSectionSchema.optional(),
|
|
28
|
-
figmaUrl: z.string().nullish(),
|
|
22
|
+
variableName: z.string().min(1).optional(),
|
|
29
23
|
});
|
|
30
24
|
|
|
31
25
|
export type QuestionStepType = z.infer<typeof QuestionStepTypeSchema>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import z from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { BaseStepTypeSchema, SocialProofSchema } from "../common.types";
|
|
3
3
|
|
|
4
4
|
export const RatingsStepPayloadSchema = z.object({
|
|
5
5
|
title: z.string(),
|
|
@@ -8,16 +8,9 @@ export const RatingsStepPayloadSchema = z.object({
|
|
|
8
8
|
rateTheAppButtonLabel: z.string().optional().default("Rate the app"),
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
export const RatingsStepTypeSchema =
|
|
12
|
-
id: z.string(),
|
|
11
|
+
export const RatingsStepTypeSchema = BaseStepTypeSchema.extend({
|
|
13
12
|
type: z.literal("Ratings"),
|
|
14
|
-
name: z.string(),
|
|
15
|
-
displayProgressHeader: z.boolean(),
|
|
16
13
|
payload: RatingsStepPayloadSchema,
|
|
17
|
-
customPayload: CustomPayloadSchema,
|
|
18
|
-
continueButtonLabel: z.string().optional().default("Continue"),
|
|
19
|
-
buttonSection: ButtonSectionSchema.optional(),
|
|
20
|
-
figmaUrl: z.string().nullish(),
|
|
21
14
|
});
|
|
22
15
|
|
|
23
16
|
export type RatingsStepType = z.infer<typeof RatingsStepTypeSchema>;
|
|
@@ -28,3 +28,75 @@ export const ButtonSectionSchema = z.object({
|
|
|
28
28
|
label: z.string().optional(),
|
|
29
29
|
icon: z.string().nullish(),
|
|
30
30
|
});
|
|
31
|
+
|
|
32
|
+
// ── Branching / nextStep schemas ─────────────────────────────────────────────
|
|
33
|
+
|
|
34
|
+
export const ConditionOperatorSchema = z.enum([
|
|
35
|
+
"eq",
|
|
36
|
+
"neq",
|
|
37
|
+
"gt",
|
|
38
|
+
"lt",
|
|
39
|
+
"gte",
|
|
40
|
+
"lte",
|
|
41
|
+
"contains",
|
|
42
|
+
"in",
|
|
43
|
+
"not_in",
|
|
44
|
+
]);
|
|
45
|
+
export type ConditionOperator = z.infer<typeof ConditionOperatorSchema>;
|
|
46
|
+
|
|
47
|
+
export const ConditionValueSchema = z.union([
|
|
48
|
+
z.string(),
|
|
49
|
+
z.number(),
|
|
50
|
+
z.boolean(),
|
|
51
|
+
z.array(z.union([z.string(), z.number(), z.boolean()])),
|
|
52
|
+
]);
|
|
53
|
+
export type ConditionValue = z.infer<typeof ConditionValueSchema>;
|
|
54
|
+
|
|
55
|
+
export const LeafConditionSchema = z.object({
|
|
56
|
+
variable: z.string().min(1),
|
|
57
|
+
operator: ConditionOperatorSchema,
|
|
58
|
+
value: ConditionValueSchema,
|
|
59
|
+
});
|
|
60
|
+
export type LeafCondition = z.infer<typeof LeafConditionSchema>;
|
|
61
|
+
|
|
62
|
+
export type ConditionGroup = {
|
|
63
|
+
logic: "and" | "or";
|
|
64
|
+
conditions: Array<LeafCondition | ConditionGroup>;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const ConditionGroupSchema: z.ZodType<ConditionGroup> = z.lazy(() =>
|
|
68
|
+
z.object({
|
|
69
|
+
logic: z.enum(["and", "or"]),
|
|
70
|
+
conditions: z
|
|
71
|
+
.array(z.union([LeafConditionSchema, ConditionGroupSchema]))
|
|
72
|
+
.min(1),
|
|
73
|
+
})
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
export const BranchSchema = z.object({
|
|
77
|
+
condition: z.union([LeafConditionSchema, ConditionGroupSchema]).nullable().default(null),
|
|
78
|
+
targetStepId: z.string().min(1),
|
|
79
|
+
});
|
|
80
|
+
export type Branch = z.infer<typeof BranchSchema>;
|
|
81
|
+
|
|
82
|
+
export const NextStepSchema = z
|
|
83
|
+
.object({
|
|
84
|
+
defaultTargetStepId: z.string().min(1),
|
|
85
|
+
branches: z.array(BranchSchema).default([]),
|
|
86
|
+
})
|
|
87
|
+
.nullable()
|
|
88
|
+
.default(null);
|
|
89
|
+
export type NextStep = z.infer<typeof NextStepSchema>;
|
|
90
|
+
|
|
91
|
+
// ── Base step schema ──────────────────────────────────────────────────────────
|
|
92
|
+
|
|
93
|
+
export const BaseStepTypeSchema = z.object({
|
|
94
|
+
id: z.string(),
|
|
95
|
+
name: z.string(),
|
|
96
|
+
displayProgressHeader: z.boolean(),
|
|
97
|
+
customPayload: CustomPayloadSchema,
|
|
98
|
+
continueButtonLabel: z.string().optional().default("Continue"),
|
|
99
|
+
buttonSection: ButtonSectionSchema.optional(),
|
|
100
|
+
figmaUrl: z.string().nullish(),
|
|
101
|
+
nextStep: NextStepSchema,
|
|
102
|
+
});
|
package/src/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { NextStep } from "./steps/common.types";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Base step type that all onboarding steps must conform to.
|
|
3
5
|
* This is the minimal interface required by the headless SDK.
|
|
@@ -11,6 +13,7 @@ export type BaseStepType = {
|
|
|
11
13
|
customPayload?: any;
|
|
12
14
|
continueButtonLabel?: string;
|
|
13
15
|
figmaUrl?: string | null;
|
|
16
|
+
nextStep?: NextStep;
|
|
14
17
|
};
|
|
15
18
|
|
|
16
19
|
export type OnboardingStudioClientOptions<
|