@rocapine/react-native-onboarding-ui 1.6.0 → 1.8.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 (84) hide show
  1. package/dist/UI/OnboardingPage.js +1 -1
  2. package/dist/UI/OnboardingPage.js.map +1 -1
  3. package/dist/UI/Pages/ComposableScreen/Renderer.d.ts +0 -2
  4. package/dist/UI/Pages/ComposableScreen/Renderer.d.ts.map +1 -1
  5. package/dist/UI/Pages/ComposableScreen/Renderer.js +13 -273
  6. package/dist/UI/Pages/ComposableScreen/Renderer.js.map +1 -1
  7. package/dist/UI/Pages/ComposableScreen/elements/BaseBoxProps.d.ts +30 -0
  8. package/dist/UI/Pages/ComposableScreen/elements/BaseBoxProps.d.ts.map +1 -0
  9. package/dist/UI/Pages/ComposableScreen/elements/BaseBoxProps.js +19 -0
  10. package/dist/UI/Pages/ComposableScreen/elements/BaseBoxProps.js.map +1 -0
  11. package/dist/UI/Pages/ComposableScreen/elements/ButtonElement.d.ts +67 -0
  12. package/dist/UI/Pages/ComposableScreen/elements/ButtonElement.d.ts.map +1 -0
  13. package/dist/UI/Pages/ComposableScreen/elements/ButtonElement.js +65 -0
  14. package/dist/UI/Pages/ComposableScreen/elements/ButtonElement.js.map +1 -0
  15. package/dist/UI/Pages/ComposableScreen/elements/IconElement.d.ts +41 -0
  16. package/dist/UI/Pages/ComposableScreen/elements/IconElement.d.ts.map +1 -0
  17. package/dist/UI/Pages/ComposableScreen/elements/IconElement.js +37 -0
  18. package/dist/UI/Pages/ComposableScreen/elements/IconElement.js.map +1 -0
  19. package/dist/UI/Pages/ComposableScreen/elements/ImageElement.d.ts +42 -0
  20. package/dist/UI/Pages/ComposableScreen/elements/ImageElement.d.ts.map +1 -0
  21. package/dist/UI/Pages/ComposableScreen/elements/ImageElement.js +34 -0
  22. package/dist/UI/Pages/ComposableScreen/elements/ImageElement.js.map +1 -0
  23. package/dist/UI/Pages/ComposableScreen/elements/InputElement.d.ts +102 -0
  24. package/dist/UI/Pages/ComposableScreen/elements/InputElement.d.ts.map +1 -0
  25. package/dist/UI/Pages/ComposableScreen/elements/InputElement.js +68 -0
  26. package/dist/UI/Pages/ComposableScreen/elements/InputElement.js.map +1 -0
  27. package/dist/UI/Pages/ComposableScreen/elements/LottieElement.d.ts +39 -0
  28. package/dist/UI/Pages/ComposableScreen/elements/LottieElement.d.ts.map +1 -0
  29. package/dist/UI/Pages/ComposableScreen/elements/LottieElement.js +60 -0
  30. package/dist/UI/Pages/ComposableScreen/elements/LottieElement.js.map +1 -0
  31. package/dist/UI/Pages/ComposableScreen/elements/RadioGroupElement.d.ts +78 -0
  32. package/dist/UI/Pages/ComposableScreen/elements/RadioGroupElement.d.ts.map +1 -0
  33. package/dist/UI/Pages/ComposableScreen/elements/RadioGroupElement.js +119 -0
  34. package/dist/UI/Pages/ComposableScreen/elements/RadioGroupElement.js.map +1 -0
  35. package/dist/UI/Pages/ComposableScreen/elements/RiveElement.d.ts +62 -0
  36. package/dist/UI/Pages/ComposableScreen/elements/RiveElement.d.ts.map +1 -0
  37. package/dist/UI/Pages/ComposableScreen/elements/RiveElement.js +68 -0
  38. package/dist/UI/Pages/ComposableScreen/elements/RiveElement.js.map +1 -0
  39. package/dist/UI/Pages/ComposableScreen/elements/StackElement.d.ts +85 -0
  40. package/dist/UI/Pages/ComposableScreen/elements/StackElement.d.ts.map +1 -0
  41. package/dist/UI/Pages/ComposableScreen/elements/StackElement.js +64 -0
  42. package/dist/UI/Pages/ComposableScreen/elements/StackElement.js.map +1 -0
  43. package/dist/UI/Pages/ComposableScreen/elements/TextElement.d.ts +66 -0
  44. package/dist/UI/Pages/ComposableScreen/elements/TextElement.d.ts.map +1 -0
  45. package/dist/UI/Pages/ComposableScreen/elements/TextElement.js +59 -0
  46. package/dist/UI/Pages/ComposableScreen/elements/TextElement.js.map +1 -0
  47. package/dist/UI/Pages/ComposableScreen/elements/VideoElement.d.ts +41 -0
  48. package/dist/UI/Pages/ComposableScreen/elements/VideoElement.d.ts.map +1 -0
  49. package/dist/UI/Pages/ComposableScreen/elements/VideoElement.js +84 -0
  50. package/dist/UI/Pages/ComposableScreen/elements/VideoElement.js.map +1 -0
  51. package/dist/UI/Pages/ComposableScreen/elements/renderElement.d.ts +5 -0
  52. package/dist/UI/Pages/ComposableScreen/elements/renderElement.d.ts.map +1 -0
  53. package/dist/UI/Pages/ComposableScreen/elements/renderElement.js +49 -0
  54. package/dist/UI/Pages/ComposableScreen/elements/renderElement.js.map +1 -0
  55. package/dist/UI/Pages/ComposableScreen/elements/shared.d.ts +13 -0
  56. package/dist/UI/Pages/ComposableScreen/elements/shared.d.ts.map +1 -0
  57. package/dist/UI/Pages/ComposableScreen/elements/shared.js +6 -0
  58. package/dist/UI/Pages/ComposableScreen/elements/shared.js.map +1 -0
  59. package/dist/UI/Pages/ComposableScreen/types.d.ts +40 -113
  60. package/dist/UI/Pages/ComposableScreen/types.d.ts.map +1 -1
  61. package/dist/UI/Pages/ComposableScreen/types.js +33 -121
  62. package/dist/UI/Pages/ComposableScreen/types.js.map +1 -1
  63. package/dist/UI/Provider/OnboardingProgressProvider.d.ts +6 -2
  64. package/dist/UI/Provider/OnboardingProgressProvider.d.ts.map +1 -1
  65. package/dist/UI/Provider/OnboardingProgressProvider.js +4 -3
  66. package/dist/UI/Provider/OnboardingProgressProvider.js.map +1 -1
  67. package/package.json +2 -2
  68. package/src/UI/OnboardingPage.tsx +1 -1
  69. package/src/UI/Pages/ComposableScreen/Renderer.tsx +22 -430
  70. package/src/UI/Pages/ComposableScreen/elements/BaseBoxProps.ts +31 -0
  71. package/src/UI/Pages/ComposableScreen/elements/ButtonElement.tsx +96 -0
  72. package/src/UI/Pages/ComposableScreen/elements/IconElement.tsx +67 -0
  73. package/src/UI/Pages/ComposableScreen/elements/ImageElement.tsx +52 -0
  74. package/src/UI/Pages/ComposableScreen/elements/InputElement.tsx +115 -0
  75. package/src/UI/Pages/ComposableScreen/elements/LottieElement.tsx +97 -0
  76. package/src/UI/Pages/ComposableScreen/elements/RadioGroupElement.tsx +181 -0
  77. package/src/UI/Pages/ComposableScreen/elements/RiveElement.tsx +105 -0
  78. package/src/UI/Pages/ComposableScreen/elements/StackElement.tsx +103 -0
  79. package/src/UI/Pages/ComposableScreen/elements/TextElement.tsx +95 -0
  80. package/src/UI/Pages/ComposableScreen/elements/VideoElement.tsx +113 -0
  81. package/src/UI/Pages/ComposableScreen/elements/renderElement.tsx +61 -0
  82. package/src/UI/Pages/ComposableScreen/elements/shared.ts +15 -0
  83. package/src/UI/Pages/ComposableScreen/types.ts +56 -233
  84. package/src/UI/Provider/OnboardingProgressProvider.tsx +8 -5
@@ -1,283 +1,94 @@
1
1
  import { z } from "zod";
2
2
  import { CustomPayloadSchema } from "../types";
3
+ import { type StackElementProps, StackElementPropsSchema } from "./elements/StackElement";
4
+ import { type TextElementProps, TextElementPropsSchema } from "./elements/TextElement";
5
+ import { type ImageElementProps, ImageElementPropsSchema } from "./elements/ImageElement";
6
+ import { type LottieElementProps, LottieElementPropsSchema } from "./elements/LottieElement";
7
+ import { type RiveElementProps, RiveElementPropsSchema } from "./elements/RiveElement";
8
+ import { type IconElementProps, IconElementPropsSchema } from "./elements/IconElement";
9
+ import { type VideoElementProps, VideoElementPropsSchema } from "./elements/VideoElement";
10
+ import { type InputElementProps, InputElementPropsSchema } from "./elements/InputElement";
11
+ import { type ButtonElementProps, ButtonElementPropsSchema } from "./elements/ButtonElement";
12
+ import { type RadioGroupElementProps, RadioGroupElementPropsSchema } from "./elements/RadioGroupElement";
3
13
 
4
- type BaseBoxProps = {
5
- width?: number;
6
- height?: number;
7
- opacity?: number;
8
- margin?: number;
9
- marginHorizontal?: number;
10
- marginVertical?: number;
11
- padding?: number;
12
- paddingHorizontal?: number;
13
- paddingVertical?: number;
14
- borderWidth?: number;
15
- borderRadius?: number;
16
- borderColor?: string;
17
- };
14
+ export type { BaseBoxProps } from "./elements/BaseBoxProps";
15
+ export { BaseBoxPropsSchema } from "./elements/BaseBoxProps";
16
+ export type { StackElementProps } from "./elements/StackElement";
17
+ export type { TextElementProps } from "./elements/TextElement";
18
+ export type { ImageElementProps } from "./elements/ImageElement";
19
+ export type { LottieElementProps } from "./elements/LottieElement";
20
+ export type { RiveElementProps } from "./elements/RiveElement";
21
+ export type { IconElementProps } from "./elements/IconElement";
22
+ export type { VideoElementProps } from "./elements/VideoElement";
23
+ export type { InputElementProps } from "./elements/InputElement";
24
+ export type { ButtonElementProps } from "./elements/ButtonElement";
25
+ export type { RadioGroupElementProps } from "./elements/RadioGroupElement";
18
26
 
27
+ // UIElement union — must live here (not in elements/) to avoid circular deps
28
+ // because the Stack variant's children: UIElement[] references itself.
19
29
  export type UIElement =
20
30
  | {
21
31
  id: string;
22
32
  name?: string;
23
33
  type: "YStack" | "XStack";
24
- props: {
25
- gap?: number;
26
- padding?: number;
27
- paddingHorizontal?: number;
28
- paddingVertical?: number;
29
- margin?: number;
30
- marginHorizontal?: number;
31
- marginVertical?: number;
32
- flex?: number;
33
- width?: number;
34
- height?: number;
35
- minWidth?: number;
36
- maxWidth?: number;
37
- minHeight?: number;
38
- maxHeight?: number;
39
- alignItems?: "flex-start" | "center" | "flex-end" | "stretch";
40
- justifyContent?: "flex-start" | "center" | "flex-end" | "space-between" | "space-around";
41
- backgroundColor?: string;
42
- flexWrap?: "wrap" | "nowrap";
43
- flexShrink?: number;
44
- borderWidth?: number;
45
- borderRadius?: number;
46
- borderColor?: string;
47
- overflow?: "hidden" | "visible" | "scroll";
48
- opacity?: number;
49
- };
34
+ props: StackElementProps;
50
35
  children: UIElement[];
51
36
  }
52
37
  | {
53
38
  id: string;
54
39
  name?: string;
55
40
  type: "Text";
56
- props: {
57
- content: string;
58
- mode?: "plain" | "expression";
59
- fontSize?: number;
60
- fontWeight?: string;
61
- color?: string;
62
- textAlign?: "left" | "center" | "right";
63
- letterSpacing?: number;
64
- lineHeight?: number;
65
- backgroundColor?: string;
66
- padding?: number;
67
- paddingHorizontal?: number;
68
- paddingVertical?: number;
69
- margin?: number;
70
- marginHorizontal?: number;
71
- marginVertical?: number;
72
- borderWidth?: number;
73
- borderRadius?: number;
74
- borderColor?: string;
75
- opacity?: number;
76
- };
41
+ props: TextElementProps;
77
42
  }
78
43
  | {
79
44
  id: string;
80
45
  name?: string;
81
46
  type: "Image";
82
- props: BaseBoxProps & {
83
- url: string;
84
- aspectRatio?: number;
85
- resizeMode?: "cover" | "contain" | "stretch" | "center";
86
- };
47
+ props: ImageElementProps;
87
48
  }
88
49
  | {
89
50
  id: string;
90
51
  name?: string;
91
52
  type: "Lottie";
92
- props: BaseBoxProps & {
93
- source: string;
94
- autoPlay?: boolean;
95
- loop?: boolean;
96
- speed?: number;
97
- };
53
+ props: LottieElementProps;
98
54
  }
99
55
  | {
100
56
  id: string;
101
57
  name?: string;
102
58
  type: "Rive";
103
- props: BaseBoxProps & {
104
- url: string;
105
- autoplay?: boolean;
106
- fit?: "Contain" | "Cover" | "Fill" | "FitWidth" | "FitHeight" | "None" | "ScaleDown" | "Layout";
107
- alignment?: "TopLeft" | "TopCenter" | "TopRight" | "CenterLeft" | "Center" | "CenterRight" | "BottomLeft" | "BottomCenter" | "BottomRight";
108
- artboardName?: string;
109
- stateMachineName?: string;
110
- };
59
+ props: RiveElementProps;
111
60
  }
112
61
  | {
113
62
  id: string;
114
63
  name?: string;
115
64
  type: "Icon";
116
- props: BaseBoxProps & {
117
- name: string;
118
- size?: number;
119
- color?: string;
120
- strokeWidth?: number;
121
- };
65
+ props: IconElementProps;
122
66
  }
123
67
  | {
124
68
  id: string;
125
69
  name?: string;
126
70
  type: "Video";
127
- props: BaseBoxProps & {
128
- url: string;
129
- autoPlay?: boolean;
130
- loop?: boolean;
131
- muted?: boolean;
132
- controls?: boolean;
133
- };
71
+ props: VideoElementProps;
134
72
  }
135
73
  | {
136
74
  id: string;
137
75
  name?: string;
138
76
  type: "Input";
139
- props: BaseBoxProps & {
140
- variableName?: string;
141
- placeholder?: string;
142
- defaultValue?: string;
143
- keyboardType?: "default" | "email-address" | "numeric" | "phone-pad" | "decimal-pad" | "url" | "number-pad" | "ascii-capable" | "numbers-and-punctuation" | "name-phone-pad" | "twitter" | "web-search" | "visible-password";
144
- returnKeyType?: "done" | "next" | "go" | "search" | "send" | "default" | "emergency-call" | "google" | "join" | "route" | "yahoo" | "none" | "previous";
145
- autoCapitalize?: "none" | "sentences" | "words" | "characters";
146
- secureTextEntry?: boolean;
147
- maxLength?: number;
148
- multiline?: boolean;
149
- numberOfLines?: number;
150
- editable?: boolean;
151
- color?: string;
152
- backgroundColor?: string;
153
- fontSize?: number;
154
- fontWeight?: string;
155
- textAlign?: "left" | "center" | "right";
156
- placeholderColor?: string;
157
- };
77
+ props: InputElementProps;
78
+ }
79
+ | {
80
+ id: string;
81
+ name?: string;
82
+ type: "Button";
83
+ props: ButtonElementProps;
84
+ }
85
+ | {
86
+ id: string;
87
+ name?: string;
88
+ type: "RadioGroup";
89
+ props: RadioGroupElementProps;
158
90
  };
159
91
 
160
- const BaseBoxPropsSchema = z.object({
161
- width: z.number().optional(),
162
- height: z.number().optional(),
163
- opacity: z.number().min(0).max(1).optional(),
164
- margin: z.number().optional(),
165
- marginHorizontal: z.number().optional(),
166
- marginVertical: z.number().optional(),
167
- padding: z.number().optional(),
168
- paddingHorizontal: z.number().optional(),
169
- paddingVertical: z.number().optional(),
170
- borderWidth: z.number().optional(),
171
- borderRadius: z.number().optional(),
172
- borderColor: z.string().optional(),
173
- });
174
-
175
- const StackElementPropsSchema = z.object({
176
- gap: z.number().optional(),
177
- padding: z.number().optional(),
178
- paddingHorizontal: z.number().optional(),
179
- paddingVertical: z.number().optional(),
180
- margin: z.number().optional(),
181
- marginHorizontal: z.number().optional(),
182
- marginVertical: z.number().optional(),
183
- flex: z.number().optional(),
184
- width: z.number().optional(),
185
- height: z.number().optional(),
186
- minWidth: z.number().optional(),
187
- maxWidth: z.number().optional(),
188
- minHeight: z.number().optional(),
189
- maxHeight: z.number().optional(),
190
- alignItems: z.enum(["flex-start", "center", "flex-end", "stretch"]).optional(),
191
- justifyContent: z.enum(["flex-start", "center", "flex-end", "space-between", "space-around"]).optional(),
192
- backgroundColor: z.string().optional(),
193
- flexWrap: z.enum(["wrap", "nowrap"]).optional(),
194
- flexShrink: z.number().optional(),
195
- borderWidth: z.number().optional(),
196
- borderRadius: z.number().optional(),
197
- borderColor: z.string().optional(),
198
- overflow: z.enum(["hidden", "visible", "scroll"]).optional(),
199
- opacity: z.number().min(0).max(1).optional(),
200
- });
201
-
202
- const TextElementPropsSchema = z.object({
203
- content: z.string(),
204
- mode: z.enum(["plain", "expression"]).optional(),
205
- fontSize: z.number().optional(),
206
- fontWeight: z.string().optional(),
207
- color: z.string().optional(),
208
- textAlign: z.enum(["left", "center", "right"]).optional(),
209
- letterSpacing: z.number().optional(),
210
- lineHeight: z.number().optional(),
211
- backgroundColor: z.string().optional(),
212
- padding: z.number().optional(),
213
- paddingHorizontal: z.number().optional(),
214
- paddingVertical: z.number().optional(),
215
- margin: z.number().optional(),
216
- marginHorizontal: z.number().optional(),
217
- marginVertical: z.number().optional(),
218
- borderWidth: z.number().optional(),
219
- borderRadius: z.number().optional(),
220
- borderColor: z.string().optional(),
221
- opacity: z.number().min(0).max(1).optional(),
222
- });
223
-
224
- const ImageElementPropsSchema = BaseBoxPropsSchema.extend({
225
- url: z.string(),
226
- aspectRatio: z.number().optional(),
227
- resizeMode: z.enum(["cover", "contain", "stretch", "center"]).optional(),
228
- });
229
-
230
- const LottieElementPropsSchema = BaseBoxPropsSchema.extend({
231
- source: z.string(),
232
- autoPlay: z.boolean().optional(),
233
- loop: z.boolean().optional(),
234
- speed: z.number().optional(),
235
- });
236
-
237
- const RiveElementPropsSchema = BaseBoxPropsSchema.extend({
238
- url: z.string(),
239
- autoplay: z.boolean().optional(),
240
- fit: z.enum(["Contain", "Cover", "Fill", "FitWidth", "FitHeight", "None", "ScaleDown", "Layout"]).optional(),
241
- alignment: z.enum(["TopLeft", "TopCenter", "TopRight", "CenterLeft", "Center", "CenterRight", "BottomLeft", "BottomCenter", "BottomRight"]).optional(),
242
- artboardName: z.string().optional(),
243
- stateMachineName: z.string().optional(),
244
- });
245
-
246
- const IconElementPropsSchema = BaseBoxPropsSchema.extend({
247
- name: z.string(),
248
- size: z.number().optional(),
249
- color: z.string().optional(),
250
- strokeWidth: z.number().optional(),
251
- });
252
-
253
- const VideoElementPropsSchema = BaseBoxPropsSchema.extend({
254
- url: z.string(),
255
- autoPlay: z.boolean().optional(),
256
- loop: z.boolean().optional(),
257
- muted: z.boolean().optional(),
258
- controls: z.boolean().optional(),
259
- });
260
-
261
- const InputElementPropsSchema = BaseBoxPropsSchema.extend({
262
- variableName: z.string().optional(),
263
- placeholder: z.string().optional(),
264
- defaultValue: z.string().optional(),
265
- keyboardType: z.enum(["default", "email-address", "numeric", "phone-pad", "decimal-pad", "url", "number-pad", "ascii-capable", "numbers-and-punctuation", "name-phone-pad", "twitter", "web-search", "visible-password"]).optional(),
266
- returnKeyType: z.enum(["done", "next", "go", "search", "send", "default", "emergency-call", "google", "join", "route", "yahoo", "none", "previous"]).optional(),
267
- autoCapitalize: z.enum(["none", "sentences", "words", "characters"]).optional(),
268
- secureTextEntry: z.boolean().optional(),
269
- maxLength: z.number().int().nonnegative().optional(),
270
- multiline: z.boolean().optional(),
271
- numberOfLines: z.number().int().nonnegative().optional(),
272
- editable: z.boolean().optional(),
273
- color: z.string().optional(),
274
- backgroundColor: z.string().optional(),
275
- fontSize: z.number().optional(),
276
- fontWeight: z.string().optional(),
277
- textAlign: z.enum(["left", "center", "right"]).optional(),
278
- placeholderColor: z.string().optional(),
279
- });
280
-
281
92
  export const UIElementSchema: z.ZodType<UIElement> = z.lazy(() =>
282
93
  z.union([
283
94
  z.object({
@@ -329,6 +140,18 @@ export const UIElementSchema: z.ZodType<UIElement> = z.lazy(() =>
329
140
  type: z.literal("Input"),
330
141
  props: InputElementPropsSchema,
331
142
  }),
143
+ z.object({
144
+ id: z.string(),
145
+ name: z.string().optional(),
146
+ type: z.literal("Button"),
147
+ props: ButtonElementPropsSchema,
148
+ }),
149
+ z.object({
150
+ id: z.string(),
151
+ name: z.string().optional(),
152
+ type: z.literal("RadioGroup"),
153
+ props: RadioGroupElementPropsSchema,
154
+ }),
332
155
  ])
333
156
  );
334
157
 
@@ -15,10 +15,11 @@ export const OnboardingProgressProvider = ({
15
15
  displayProgressHeader: false,
16
16
  });
17
17
  const [totalSteps, setTotalSteps] = useState(0);
18
- const [composableVariables, setComposableVariables] = useState<Record<string, string>>({});
18
+ const [composableVariables, setComposableVariables] = useState<Record<string, ComposableVariableEntry>>({});
19
19
 
20
- const setComposableVariable = useCallback((key: string, value: string) => {
21
- setComposableVariables((prev) => ({ ...prev, [key]: value }));
20
+ const setComposableVariable = useCallback((key: string, entry: ComposableVariableEntry | string) => {
21
+ const normalizedEntry: ComposableVariableEntry = typeof entry === "string" ? { value: entry } : entry;
22
+ setComposableVariables((prev) => ({ ...prev, [key]: normalizedEntry }));
22
23
  }, []);
23
24
 
24
25
  return (
@@ -34,6 +35,8 @@ export const OnboardingProgressProvider = ({
34
35
  );
35
36
  };
36
37
 
38
+ export type ComposableVariableEntry = { value: string; label?: string };
39
+
37
40
  export const OnboardingProgressContext = createContext({
38
41
  activeStep: { number: 0, displayProgressHeader: false },
39
42
  setActiveStep: (_step: {
@@ -42,6 +45,6 @@ export const OnboardingProgressContext = createContext({
42
45
  }) => { },
43
46
  totalSteps: 0,
44
47
  setTotalSteps: (_steps: number) => { },
45
- composableVariables: {} as Record<string, string>,
46
- setComposableVariable: (_key: string, _value: string) => { },
48
+ composableVariables: {} as Record<string, ComposableVariableEntry>,
49
+ setComposableVariable: (_key: string, _entry: ComposableVariableEntry | string) => { },
47
50
  });