@rocapine/react-native-onboarding 1.10.0 → 1.12.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.
Files changed (124) hide show
  1. package/dist/evaluateCondition.d.ts +6 -0
  2. package/dist/evaluateCondition.d.ts.map +1 -0
  3. package/dist/evaluateCondition.js +48 -0
  4. package/dist/evaluateCondition.js.map +1 -0
  5. package/dist/index.d.ts +3 -0
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +12 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/infra/provider/OnboardingProvider.d.ts +2 -0
  10. package/dist/infra/provider/OnboardingProvider.d.ts.map +1 -1
  11. package/dist/infra/provider/OnboardingProvider.js +8 -0
  12. package/dist/infra/provider/OnboardingProvider.js.map +1 -1
  13. package/dist/onboarding-example.d.ts +109 -15
  14. package/dist/onboarding-example.d.ts.map +1 -1
  15. package/dist/onboarding-example.js +44 -1
  16. package/dist/onboarding-example.js.map +1 -1
  17. package/dist/resolveNextStepNumber.d.ts +11 -0
  18. package/dist/resolveNextStepNumber.d.ts.map +1 -0
  19. package/dist/resolveNextStepNumber.js +39 -0
  20. package/dist/resolveNextStepNumber.js.map +1 -0
  21. package/dist/steps/Carousel/types.d.ts +29 -8
  22. package/dist/steps/Carousel/types.d.ts.map +1 -1
  23. package/dist/steps/Carousel/types.js +1 -8
  24. package/dist/steps/Carousel/types.js.map +1 -1
  25. package/dist/steps/Commitment/types.d.ts +29 -8
  26. package/dist/steps/Commitment/types.d.ts.map +1 -1
  27. package/dist/steps/Commitment/types.js +1 -8
  28. package/dist/steps/Commitment/types.js.map +1 -1
  29. package/dist/steps/ComposableScreen/elements/BaseBoxProps.d.ts +28 -6
  30. package/dist/steps/ComposableScreen/elements/BaseBoxProps.d.ts.map +1 -1
  31. package/dist/steps/ComposableScreen/elements/BaseBoxProps.js +11 -2
  32. package/dist/steps/ComposableScreen/elements/BaseBoxProps.js.map +1 -1
  33. package/dist/steps/ComposableScreen/elements/ButtonElement.d.ts +22 -10
  34. package/dist/steps/ComposableScreen/elements/ButtonElement.d.ts.map +1 -1
  35. package/dist/steps/ComposableScreen/elements/ButtonElement.js +0 -1
  36. package/dist/steps/ComposableScreen/elements/ButtonElement.js.map +1 -1
  37. package/dist/steps/ComposableScreen/elements/CarouselElement.d.ts +67 -0
  38. package/dist/steps/ComposableScreen/elements/CarouselElement.d.ts.map +1 -0
  39. package/dist/steps/ComposableScreen/elements/CarouselElement.js +19 -0
  40. package/dist/steps/ComposableScreen/elements/CarouselElement.js.map +1 -0
  41. package/dist/steps/ComposableScreen/elements/CheckboxGroupElement.d.ts +17 -4
  42. package/dist/steps/ComposableScreen/elements/CheckboxGroupElement.d.ts.map +1 -1
  43. package/dist/steps/ComposableScreen/elements/DatePickerElement.d.ts +17 -4
  44. package/dist/steps/ComposableScreen/elements/DatePickerElement.d.ts.map +1 -1
  45. package/dist/steps/ComposableScreen/elements/IconElement.d.ts +16 -4
  46. package/dist/steps/ComposableScreen/elements/IconElement.d.ts.map +1 -1
  47. package/dist/steps/ComposableScreen/elements/ImageElement.d.ts +17 -4
  48. package/dist/steps/ComposableScreen/elements/ImageElement.d.ts.map +1 -1
  49. package/dist/steps/ComposableScreen/elements/InputElement.d.ts +24 -6
  50. package/dist/steps/ComposableScreen/elements/InputElement.d.ts.map +1 -1
  51. package/dist/steps/ComposableScreen/elements/InputElement.js +3 -0
  52. package/dist/steps/ComposableScreen/elements/InputElement.js.map +1 -1
  53. package/dist/steps/ComposableScreen/elements/LottieElement.d.ts +17 -4
  54. package/dist/steps/ComposableScreen/elements/LottieElement.d.ts.map +1 -1
  55. package/dist/steps/ComposableScreen/elements/RadioGroupElement.d.ts +17 -4
  56. package/dist/steps/ComposableScreen/elements/RadioGroupElement.d.ts.map +1 -1
  57. package/dist/steps/ComposableScreen/elements/RiveElement.d.ts +19 -6
  58. package/dist/steps/ComposableScreen/elements/RiveElement.d.ts.map +1 -1
  59. package/dist/steps/ComposableScreen/elements/RiveElement.js +1 -1
  60. package/dist/steps/ComposableScreen/elements/StackElement.d.ts +31 -50
  61. package/dist/steps/ComposableScreen/elements/StackElement.d.ts.map +1 -1
  62. package/dist/steps/ComposableScreen/elements/StackElement.js +2 -22
  63. package/dist/steps/ComposableScreen/elements/StackElement.js.map +1 -1
  64. package/dist/steps/ComposableScreen/elements/TextElement.d.ts +35 -23
  65. package/dist/steps/ComposableScreen/elements/TextElement.d.ts.map +1 -1
  66. package/dist/steps/ComposableScreen/elements/TextElement.js +2 -12
  67. package/dist/steps/ComposableScreen/elements/TextElement.js.map +1 -1
  68. package/dist/steps/ComposableScreen/elements/VideoElement.d.ts +17 -4
  69. package/dist/steps/ComposableScreen/elements/VideoElement.d.ts.map +1 -1
  70. package/dist/steps/ComposableScreen/types.d.ts +37 -4
  71. package/dist/steps/ComposableScreen/types.d.ts.map +1 -1
  72. package/dist/steps/ComposableScreen/types.js +9 -7
  73. package/dist/steps/ComposableScreen/types.js.map +1 -1
  74. package/dist/steps/Loader/types.d.ts +29 -8
  75. package/dist/steps/Loader/types.d.ts.map +1 -1
  76. package/dist/steps/Loader/types.js +1 -8
  77. package/dist/steps/Loader/types.js.map +1 -1
  78. package/dist/steps/MediaContent/types.d.ts +29 -8
  79. package/dist/steps/MediaContent/types.d.ts.map +1 -1
  80. package/dist/steps/MediaContent/types.js +1 -8
  81. package/dist/steps/MediaContent/types.js.map +1 -1
  82. package/dist/steps/Picker/types.d.ts +30 -8
  83. package/dist/steps/Picker/types.d.ts.map +1 -1
  84. package/dist/steps/Picker/types.js +2 -8
  85. package/dist/steps/Picker/types.js.map +1 -1
  86. package/dist/steps/Question/types.d.ts +30 -8
  87. package/dist/steps/Question/types.d.ts.map +1 -1
  88. package/dist/steps/Question/types.js +2 -8
  89. package/dist/steps/Question/types.js.map +1 -1
  90. package/dist/steps/Ratings/types.d.ts +29 -8
  91. package/dist/steps/Ratings/types.d.ts.map +1 -1
  92. package/dist/steps/Ratings/types.js +1 -8
  93. package/dist/steps/Ratings/types.js.map +1 -1
  94. package/dist/steps/common.types.d.ts +109 -0
  95. package/dist/steps/common.types.d.ts.map +1 -1
  96. package/dist/steps/common.types.js +52 -1
  97. package/dist/steps/common.types.js.map +1 -1
  98. package/dist/types.d.ts +2 -0
  99. package/dist/types.d.ts.map +1 -1
  100. package/package.json +5 -2
  101. package/src/__tests__/evaluateCondition.test.ts +167 -0
  102. package/src/__tests__/resolveNextStepNumber.test.ts +309 -0
  103. package/src/evaluateCondition.ts +50 -0
  104. package/src/index.ts +19 -0
  105. package/src/infra/provider/OnboardingProvider.tsx +11 -1
  106. package/src/onboarding-example.ts +44 -1
  107. package/src/resolveNextStepNumber.ts +41 -0
  108. package/src/steps/Carousel/types.ts +2 -9
  109. package/src/steps/Commitment/types.ts +2 -9
  110. package/src/steps/ComposableScreen/elements/BaseBoxProps.ts +22 -4
  111. package/src/steps/ComposableScreen/elements/ButtonElement.ts +0 -2
  112. package/src/steps/ComposableScreen/elements/CarouselElement.ts +30 -0
  113. package/src/steps/ComposableScreen/elements/InputElement.ts +6 -0
  114. package/src/steps/ComposableScreen/elements/RiveElement.ts +2 -2
  115. package/src/steps/ComposableScreen/elements/StackElement.ts +3 -44
  116. package/src/steps/ComposableScreen/elements/TextElement.ts +3 -24
  117. package/src/steps/ComposableScreen/types.ts +18 -8
  118. package/src/steps/Loader/types.ts +2 -9
  119. package/src/steps/MediaContent/types.ts +2 -14
  120. package/src/steps/Picker/types.ts +3 -9
  121. package/src/steps/Question/types.ts +3 -9
  122. package/src/steps/Ratings/types.ts +2 -9
  123. package/src/steps/common.types.ts +72 -0
  124. package/src/types.ts +3 -0
@@ -3,7 +3,7 @@ import { BaseBoxProps, BaseBoxPropsSchema } from "./BaseBoxProps";
3
3
 
4
4
  export type RiveElementProps = BaseBoxProps & {
5
5
  url: string;
6
- autoplay?: boolean;
6
+ autoPlay?: boolean;
7
7
  fit?: "Contain" | "Cover" | "Fill" | "FitWidth" | "FitHeight" | "None" | "ScaleDown" | "Layout";
8
8
  alignment?: "TopLeft" | "TopCenter" | "TopRight" | "CenterLeft" | "Center" | "CenterRight" | "BottomLeft" | "BottomCenter" | "BottomRight";
9
9
  artboardName?: string;
@@ -12,7 +12,7 @@ export type RiveElementProps = BaseBoxProps & {
12
12
 
13
13
  export const RiveElementPropsSchema = BaseBoxPropsSchema.extend({
14
14
  url: z.string().min(1, "url must not be empty"),
15
- autoplay: z.boolean().optional(),
15
+ autoPlay: z.boolean().optional(),
16
16
  fit: z.enum(["Contain", "Cover", "Fill", "FitWidth", "FitHeight", "None", "ScaleDown", "Layout"]).optional(),
17
17
  alignment: z.enum(["TopLeft", "TopCenter", "TopRight", "CenterLeft", "Center", "CenterRight", "BottomLeft", "BottomCenter", "BottomRight"]).optional(),
18
18
  artboardName: z.string().optional(),
@@ -1,57 +1,16 @@
1
1
  import { z } from "zod";
2
+ import { BaseBoxProps, BaseBoxPropsSchema } from "./BaseBoxProps";
2
3
 
3
- export type StackElementProps = {
4
+ export type StackElementProps = BaseBoxProps & {
4
5
  gap?: number;
5
- padding?: number;
6
- paddingHorizontal?: number;
7
- paddingVertical?: number;
8
- margin?: number;
9
- marginHorizontal?: number;
10
- marginVertical?: number;
11
- flex?: number;
12
- width?: number;
13
- height?: number;
14
- minWidth?: number;
15
- maxWidth?: number;
16
- minHeight?: number;
17
- maxHeight?: number;
18
6
  alignItems?: "flex-start" | "center" | "flex-end" | "stretch";
19
- alignSelf?: "auto" | "flex-start" | "flex-end" | "center" | "stretch" | "baseline";
20
7
  justifyContent?: "flex-start" | "center" | "flex-end" | "space-between" | "space-around";
21
- backgroundColor?: string;
22
8
  flexWrap?: "wrap" | "nowrap";
23
- flexShrink?: number;
24
- borderWidth?: number;
25
- borderRadius?: number;
26
- borderColor?: string;
27
- overflow?: "hidden" | "visible" | "scroll";
28
- opacity?: number;
29
9
  };
30
10
 
31
- export const StackElementPropsSchema = z.object({
11
+ export const StackElementPropsSchema = BaseBoxPropsSchema.extend({
32
12
  gap: z.number().optional(),
33
- padding: z.number().optional(),
34
- paddingHorizontal: z.number().optional(),
35
- paddingVertical: z.number().optional(),
36
- margin: z.number().optional(),
37
- marginHorizontal: z.number().optional(),
38
- marginVertical: z.number().optional(),
39
- flex: z.number().optional(),
40
- width: z.number().optional(),
41
- height: z.number().optional(),
42
- minWidth: z.number().optional(),
43
- maxWidth: z.number().optional(),
44
- minHeight: z.number().optional(),
45
- maxHeight: z.number().optional(),
46
13
  alignItems: z.enum(["flex-start", "center", "flex-end", "stretch"]).optional(),
47
- alignSelf: z.enum(["auto", "flex-start", "flex-end", "center", "stretch", "baseline"]).optional(),
48
14
  justifyContent: z.enum(["flex-start", "center", "flex-end", "space-between", "space-around"]).optional(),
49
- backgroundColor: z.string().optional(),
50
15
  flexWrap: z.enum(["wrap", "nowrap"]).optional(),
51
- flexShrink: z.number().optional(),
52
- borderWidth: z.number().optional(),
53
- borderRadius: z.number().optional(),
54
- borderColor: z.string().optional(),
55
- overflow: z.enum(["hidden", "visible", "scroll"]).optional(),
56
- opacity: z.number().min(0).max(1).optional(),
57
16
  });
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
+ import { BaseBoxProps, BaseBoxPropsSchema } from "./BaseBoxProps";
2
3
 
3
- export type TextElementProps = {
4
+ export type TextElementProps = BaseBoxProps & {
4
5
  content: string;
5
6
  mode?: "plain" | "expression";
6
7
  fontSize?: number;
@@ -10,20 +11,9 @@ export type TextElementProps = {
10
11
  textAlign?: "left" | "center" | "right";
11
12
  letterSpacing?: number;
12
13
  lineHeight?: number;
13
- backgroundColor?: string;
14
- padding?: number;
15
- paddingHorizontal?: number;
16
- paddingVertical?: number;
17
- margin?: number;
18
- marginHorizontal?: number;
19
- marginVertical?: number;
20
- borderWidth?: number;
21
- borderRadius?: number;
22
- borderColor?: string;
23
- opacity?: number;
24
14
  };
25
15
 
26
- export const TextElementPropsSchema = z.object({
16
+ export const TextElementPropsSchema = BaseBoxPropsSchema.extend({
27
17
  content: z.string(),
28
18
  mode: z.enum(["plain", "expression"]).optional(),
29
19
  fontSize: z.number().optional(),
@@ -33,15 +23,4 @@ export const TextElementPropsSchema = z.object({
33
23
  textAlign: z.enum(["left", "center", "right"]).optional(),
34
24
  letterSpacing: z.number().optional(),
35
25
  lineHeight: z.number().optional(),
36
- backgroundColor: z.string().optional(),
37
- padding: z.number().optional(),
38
- paddingHorizontal: z.number().optional(),
39
- paddingVertical: z.number().optional(),
40
- margin: z.number().optional(),
41
- marginHorizontal: z.number().optional(),
42
- marginVertical: z.number().optional(),
43
- borderWidth: z.number().optional(),
44
- borderRadius: z.number().optional(),
45
- borderColor: z.string().optional(),
46
- opacity: z.number().min(0).max(1).optional(),
47
26
  });
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { CustomPayloadSchema } from "../common.types";
2
+ import { BaseStepTypeSchema } from "../common.types";
3
3
  import { type StackElementProps, StackElementPropsSchema } from "./elements/StackElement";
4
4
  import { type TextElementProps, TextElementPropsSchema } from "./elements/TextElement";
5
5
  import { type ImageElementProps, ImageElementPropsSchema } from "./elements/ImageElement";
@@ -12,6 +12,7 @@ import { type ButtonElementProps, ButtonElementPropsSchema } from "./elements/Bu
12
12
  import { type RadioGroupElementProps, RadioGroupElementPropsSchema } from "./elements/RadioGroupElement";
13
13
  import { type CheckboxGroupElementProps, CheckboxGroupElementPropsSchema } from "./elements/CheckboxGroupElement";
14
14
  import { type DatePickerElementProps, DatePickerElementPropsSchema } from "./elements/DatePickerElement";
15
+ import { type CarouselElementProps, CarouselElementPropsSchema } from "./elements/CarouselElement";
15
16
 
16
17
  export type { BaseBoxProps } from "./elements/BaseBoxProps";
17
18
  export { BaseBoxPropsSchema } from "./elements/BaseBoxProps";
@@ -27,6 +28,7 @@ export type { ButtonElementProps } from "./elements/ButtonElement";
27
28
  export type { RadioGroupElementProps } from "./elements/RadioGroupElement";
28
29
  export type { CheckboxGroupElementProps } from "./elements/CheckboxGroupElement";
29
30
  export type { DatePickerElementProps } from "./elements/DatePickerElement";
31
+ export type { CarouselElementProps } from "./elements/CarouselElement";
30
32
 
31
33
  // UIElement union — must live here (not in elements/) to avoid circular deps
32
34
  // because the Stack variant's children: UIElement[] references itself.
@@ -103,6 +105,13 @@ type UIElement =
103
105
  name?: string;
104
106
  type: "DatePicker";
105
107
  props: DatePickerElementProps;
108
+ }
109
+ | {
110
+ id: string;
111
+ name?: string;
112
+ type: "Carousel";
113
+ props: CarouselElementProps;
114
+ children: UIElement[];
106
115
  };
107
116
 
108
117
  const UIElementSchema: z.ZodType<UIElement> = z.lazy(() =>
@@ -180,6 +189,13 @@ const UIElementSchema: z.ZodType<UIElement> = z.lazy(() =>
180
189
  type: z.literal("DatePicker"),
181
190
  props: DatePickerElementPropsSchema,
182
191
  }),
192
+ z.object({
193
+ id: z.string(),
194
+ name: z.string().optional(),
195
+ type: z.literal("Carousel"),
196
+ props: CarouselElementPropsSchema,
197
+ children: z.array(UIElementSchema),
198
+ }),
183
199
  ])
184
200
  );
185
201
 
@@ -187,15 +203,9 @@ export const ComposableScreenStepPayloadSchema = z.object({
187
203
  elements: z.array(UIElementSchema),
188
204
  });
189
205
 
190
- export const ComposableScreenStepTypeSchema = z.object({
191
- id: z.string(),
206
+ export const ComposableScreenStepTypeSchema = BaseStepTypeSchema.extend({
192
207
  type: z.literal("ComposableScreen"),
193
- name: z.string(),
194
- displayProgressHeader: z.boolean(),
195
208
  payload: ComposableScreenStepPayloadSchema,
196
- customPayload: CustomPayloadSchema,
197
- continueButtonLabel: z.string().optional().default("Continue"),
198
- figmaUrl: z.string().nullable(),
199
209
  });
200
210
 
201
211
  export type ComposableScreenStepType = z.infer<typeof ComposableScreenStepTypeSchema>;
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { ButtonSectionSchema, CustomPayloadSchema, MediaSourceSchema } from "../common.types";
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 = z.object({
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 = z.object({
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 { ButtonSectionSchema, CustomPayloadSchema } from "../common.types";
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 = z.object({
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
- customPayload: CustomPayloadSchema,
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 { ButtonSectionSchema, CustomPayloadSchema, InfoBoxSchema } from "../common.types";
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 = z.object({
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
- customPayload: CustomPayloadSchema,
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 { ButtonSectionSchema, CustomPayloadSchema, SocialProofSchema } from "../common.types";
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 = z.object({
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<