@rocapine/react-native-onboarding 1.30.0 → 1.32.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 (61) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/onboarding-example.d.ts +191 -0
  5. package/dist/onboarding-example.d.ts.map +1 -1
  6. package/dist/onboarding-example.js +32 -0
  7. package/dist/onboarding-example.js.map +1 -1
  8. package/dist/steps/ComposableScreen/elements/BaseBoxProps.d.ts +220 -0
  9. package/dist/steps/ComposableScreen/elements/BaseBoxProps.d.ts.map +1 -1
  10. package/dist/steps/ComposableScreen/elements/BaseBoxProps.js +83 -0
  11. package/dist/steps/ComposableScreen/elements/BaseBoxProps.js.map +1 -1
  12. package/dist/steps/ComposableScreen/elements/ButtonElement.d.ts +640 -0
  13. package/dist/steps/ComposableScreen/elements/ButtonElement.d.ts.map +1 -1
  14. package/dist/steps/ComposableScreen/elements/CarouselElement.d.ts +160 -0
  15. package/dist/steps/ComposableScreen/elements/CarouselElement.d.ts.map +1 -1
  16. package/dist/steps/ComposableScreen/elements/CheckboxGroupElement.d.ts +160 -0
  17. package/dist/steps/ComposableScreen/elements/CheckboxGroupElement.d.ts.map +1 -1
  18. package/dist/steps/ComposableScreen/elements/DatePickerElement.d.ts +160 -0
  19. package/dist/steps/ComposableScreen/elements/DatePickerElement.d.ts.map +1 -1
  20. package/dist/steps/ComposableScreen/elements/IconElement.d.ts +160 -0
  21. package/dist/steps/ComposableScreen/elements/IconElement.d.ts.map +1 -1
  22. package/dist/steps/ComposableScreen/elements/ImageElement.d.ts +160 -0
  23. package/dist/steps/ComposableScreen/elements/ImageElement.d.ts.map +1 -1
  24. package/dist/steps/ComposableScreen/elements/InputElement.d.ts +161 -1
  25. package/dist/steps/ComposableScreen/elements/InputElement.d.ts.map +1 -1
  26. package/dist/steps/ComposableScreen/elements/KeyboardAvoidingViewElement.d.ts +160 -0
  27. package/dist/steps/ComposableScreen/elements/KeyboardAvoidingViewElement.d.ts.map +1 -1
  28. package/dist/steps/ComposableScreen/elements/LottieElement.d.ts +160 -0
  29. package/dist/steps/ComposableScreen/elements/LottieElement.d.ts.map +1 -1
  30. package/dist/steps/ComposableScreen/elements/ProgressIndicatorElement.d.ts +160 -0
  31. package/dist/steps/ComposableScreen/elements/ProgressIndicatorElement.d.ts.map +1 -1
  32. package/dist/steps/ComposableScreen/elements/RadioGroupElement.d.ts +160 -0
  33. package/dist/steps/ComposableScreen/elements/RadioGroupElement.d.ts.map +1 -1
  34. package/dist/steps/ComposableScreen/elements/RiveElement.d.ts +160 -0
  35. package/dist/steps/ComposableScreen/elements/RiveElement.d.ts.map +1 -1
  36. package/dist/steps/ComposableScreen/elements/SafeAreaViewElement.d.ts +160 -0
  37. package/dist/steps/ComposableScreen/elements/SafeAreaViewElement.d.ts.map +1 -1
  38. package/dist/steps/ComposableScreen/elements/ScrollViewElement.d.ts +160 -0
  39. package/dist/steps/ComposableScreen/elements/ScrollViewElement.d.ts.map +1 -1
  40. package/dist/steps/ComposableScreen/elements/StackElement.d.ts +160 -0
  41. package/dist/steps/ComposableScreen/elements/StackElement.d.ts.map +1 -1
  42. package/dist/steps/ComposableScreen/elements/TextElement.d.ts +262 -2
  43. package/dist/steps/ComposableScreen/elements/TextElement.d.ts.map +1 -1
  44. package/dist/steps/ComposableScreen/elements/TextElement.js +20 -2
  45. package/dist/steps/ComposableScreen/elements/TextElement.js.map +1 -1
  46. package/dist/steps/ComposableScreen/elements/VideoElement.d.ts +160 -0
  47. package/dist/steps/ComposableScreen/elements/VideoElement.d.ts.map +1 -1
  48. package/dist/steps/ComposableScreen/elements/WheelPickerElement.d.ts +160 -0
  49. package/dist/steps/ComposableScreen/elements/WheelPickerElement.d.ts.map +1 -1
  50. package/dist/steps/ComposableScreen/elements/ZStackElement.d.ts +160 -0
  51. package/dist/steps/ComposableScreen/elements/ZStackElement.d.ts.map +1 -1
  52. package/dist/steps/ComposableScreen/types.d.ts +3 -1
  53. package/dist/steps/ComposableScreen/types.d.ts.map +1 -1
  54. package/dist/steps/ComposableScreen/types.js +3 -1
  55. package/dist/steps/ComposableScreen/types.js.map +1 -1
  56. package/package.json +1 -1
  57. package/src/index.ts +12 -0
  58. package/src/onboarding-example.ts +32 -0
  59. package/src/steps/ComposableScreen/elements/BaseBoxProps.ts +211 -0
  60. package/src/steps/ComposableScreen/elements/TextElement.ts +59 -2
  61. package/src/steps/ComposableScreen/types.ts +16 -1
package/src/index.ts CHANGED
@@ -14,6 +14,18 @@ export type {
14
14
  WheelPickerRange,
15
15
  ProgressIndicatorElementProps,
16
16
  ProgressEasing,
17
+ AnimationEasing,
18
+ SpringConfig,
19
+ EnteringPreset,
20
+ ExitingPreset,
21
+ LayoutPreset,
22
+ EffectPreset,
23
+ EnteringAnimation,
24
+ ExitingAnimation,
25
+ LayoutAnimation,
26
+ ElementEffect,
27
+ ElementAnimation,
28
+ ElementTransform,
17
29
  } from "./steps/ComposableScreen/types";
18
30
  export {
19
31
  ButtonActionSchema,
@@ -149,6 +149,10 @@ export const onboardingExample = {
149
149
  height: 180,
150
150
  resizeMode: "cover",
151
151
  borderRadius: 16,
152
+ // Slide + fade in on mount (reanimated builder name + modifiers).
153
+ animation: {
154
+ entering: { preset: "FadeInDown", duration: 500, delay: 100, easing: "ease-out" },
155
+ },
152
156
  },
153
157
  },
154
158
  {
@@ -161,6 +165,12 @@ export const onboardingExample = {
161
165
  fill: "#007AFF",
162
166
  fillOpacity: 0.2,
163
167
  marginVertical: 8,
168
+ // Static tilt + continuous breathing pulse.
169
+ transform: { rotate: -8 },
170
+ animation: {
171
+ entering: { preset: "ZoomIn", duration: 400, spring: { damping: 10, stiffness: 160 } },
172
+ effect: { preset: "pulse", duration: 1200, minScale: 0.92, maxScale: 1.08 },
173
+ },
164
174
  },
165
175
  },
166
176
  {
@@ -241,6 +251,28 @@ export const onboardingExample = {
241
251
  marginVertical: 4,
242
252
  },
243
253
  },
254
+ {
255
+ // Inline rich text — `content` as an array of styled spans.
256
+ // Each span inherits the parent Text style and overrides only
257
+ // what it sets (here: weight, color, underline).
258
+ id: "richtext-demo",
259
+ type: "Text",
260
+ props: {
261
+ content: [
262
+ { text: "Lose " },
263
+ { text: "5kg", fontWeight: "700", color: "#E11D48" },
264
+ { text: " in 30 days — " },
265
+ {
266
+ text: "guaranteed",
267
+ fontStyle: "italic",
268
+ textDecorationLine: "underline",
269
+ },
270
+ ],
271
+ fontSize: 16,
272
+ textAlign: "center",
273
+ marginVertical: 4,
274
+ },
275
+ },
244
276
  {
245
277
  id: "scroll-demo",
246
278
  type: "ScrollView",
@@ -50,6 +50,213 @@ export const ShadowOffsetSchema = z.object({
50
50
  height: z.number(),
51
51
  });
52
52
 
53
+ // ---------------------------------------------------------------------------
54
+ // Animation / Transform surface
55
+ //
56
+ // Schema stays intentionally close to react-native-reanimated: `preset` values
57
+ // are the *exact* reanimated builder names (e.g. `FadeInDown`, `SlideOutLeft`,
58
+ // `LinearTransition`), so the UI renderer resolves them by direct namespace
59
+ // lookup (`Reanimated[preset]`) rather than a translation table. Modifier fields
60
+ // (`duration`/`delay`/`spring`/`easing`) map to reanimated builder methods
61
+ // (`.duration().delay().springify().easing()`).
62
+ // ---------------------------------------------------------------------------
63
+
64
+ // Reuses the easing-name convention from ProgressIndicatorElement.
65
+ export type AnimationEasing = "linear" | "ease-in" | "ease-out" | "ease-in-out";
66
+
67
+ const AnimationEasingSchema = z.enum(["linear", "ease-in", "ease-out", "ease-in-out"]);
68
+
69
+ // Mirrors reanimated's `.springify(config)` — only the fields it accepts.
70
+ // When `spring` is present it wins over `easing` (matches reanimated semantics).
71
+ export type SpringConfig = {
72
+ damping?: number;
73
+ stiffness?: number;
74
+ mass?: number;
75
+ };
76
+
77
+ const SpringConfigSchema = z.object({
78
+ damping: z.number().positive().optional(),
79
+ stiffness: z.number().positive().optional(),
80
+ mass: z.number().positive().optional(),
81
+ });
82
+
83
+ // Exact reanimated entering builder names.
84
+ export type EnteringPreset =
85
+ | "FadeIn" | "FadeInUp" | "FadeInDown" | "FadeInLeft" | "FadeInRight"
86
+ | "SlideInUp" | "SlideInDown" | "SlideInLeft" | "SlideInRight"
87
+ | "ZoomIn" | "ZoomInRotate" | "ZoomInUp" | "ZoomInDown" | "ZoomInLeft" | "ZoomInRight"
88
+ | "ZoomInEasyUp" | "ZoomInEasyDown"
89
+ | "BounceIn" | "BounceInUp" | "BounceInDown" | "BounceInLeft" | "BounceInRight"
90
+ | "FlipInXUp" | "FlipInYLeft" | "FlipInXDown" | "FlipInYRight" | "FlipInEasyX" | "FlipInEasyY"
91
+ | "StretchInX" | "StretchInY"
92
+ | "RotateInDownLeft" | "RotateInDownRight" | "RotateInUpLeft" | "RotateInUpRight"
93
+ | "RollInLeft" | "RollInRight"
94
+ | "PinwheelIn"
95
+ | "LightSpeedInLeft" | "LightSpeedInRight";
96
+
97
+ const EnteringPresetSchema = z.enum([
98
+ "FadeIn", "FadeInUp", "FadeInDown", "FadeInLeft", "FadeInRight",
99
+ "SlideInUp", "SlideInDown", "SlideInLeft", "SlideInRight",
100
+ "ZoomIn", "ZoomInRotate", "ZoomInUp", "ZoomInDown", "ZoomInLeft", "ZoomInRight",
101
+ "ZoomInEasyUp", "ZoomInEasyDown",
102
+ "BounceIn", "BounceInUp", "BounceInDown", "BounceInLeft", "BounceInRight",
103
+ "FlipInXUp", "FlipInYLeft", "FlipInXDown", "FlipInYRight", "FlipInEasyX", "FlipInEasyY",
104
+ "StretchInX", "StretchInY",
105
+ "RotateInDownLeft", "RotateInDownRight", "RotateInUpLeft", "RotateInUpRight",
106
+ "RollInLeft", "RollInRight",
107
+ "PinwheelIn",
108
+ "LightSpeedInLeft", "LightSpeedInRight",
109
+ ]);
110
+
111
+ // Exact reanimated exiting builder names.
112
+ export type ExitingPreset =
113
+ | "FadeOut" | "FadeOutUp" | "FadeOutDown" | "FadeOutLeft" | "FadeOutRight"
114
+ | "SlideOutUp" | "SlideOutDown" | "SlideOutLeft" | "SlideOutRight"
115
+ | "ZoomOut" | "ZoomOutRotate" | "ZoomOutUp" | "ZoomOutDown" | "ZoomOutLeft" | "ZoomOutRight"
116
+ | "ZoomOutEasyUp" | "ZoomOutEasyDown"
117
+ | "BounceOut" | "BounceOutUp" | "BounceOutDown" | "BounceOutLeft" | "BounceOutRight"
118
+ | "FlipOutXUp" | "FlipOutYLeft" | "FlipOutXDown" | "FlipOutYRight" | "FlipOutEasyX" | "FlipOutEasyY"
119
+ | "StretchOutX" | "StretchOutY"
120
+ | "RotateOutDownLeft" | "RotateOutDownRight" | "RotateOutUpLeft" | "RotateOutUpRight"
121
+ | "RollOutLeft" | "RollOutRight"
122
+ | "PinwheelOut"
123
+ | "LightSpeedOutLeft" | "LightSpeedOutRight";
124
+
125
+ const ExitingPresetSchema = z.enum([
126
+ "FadeOut", "FadeOutUp", "FadeOutDown", "FadeOutLeft", "FadeOutRight",
127
+ "SlideOutUp", "SlideOutDown", "SlideOutLeft", "SlideOutRight",
128
+ "ZoomOut", "ZoomOutRotate", "ZoomOutUp", "ZoomOutDown", "ZoomOutLeft", "ZoomOutRight",
129
+ "ZoomOutEasyUp", "ZoomOutEasyDown",
130
+ "BounceOut", "BounceOutUp", "BounceOutDown", "BounceOutLeft", "BounceOutRight",
131
+ "FlipOutXUp", "FlipOutYLeft", "FlipOutXDown", "FlipOutYRight", "FlipOutEasyX", "FlipOutEasyY",
132
+ "StretchOutX", "StretchOutY",
133
+ "RotateOutDownLeft", "RotateOutDownRight", "RotateOutUpLeft", "RotateOutUpRight",
134
+ "RollOutLeft", "RollOutRight",
135
+ "PinwheelOut",
136
+ "LightSpeedOutLeft", "LightSpeedOutRight",
137
+ ]);
138
+
139
+ // Exact reanimated layout-transition builder names.
140
+ export type LayoutPreset =
141
+ | "LinearTransition" | "FadingTransition" | "SequencedTransition"
142
+ | "JumpingTransition" | "CurvedTransition" | "EntryExitTransition";
143
+
144
+ const LayoutPresetSchema = z.enum([
145
+ "LinearTransition", "FadingTransition", "SequencedTransition",
146
+ "JumpingTransition", "CurvedTransition", "EntryExitTransition",
147
+ ]);
148
+
149
+ export type EnteringAnimation = {
150
+ preset: EnteringPreset;
151
+ duration?: number;
152
+ delay?: number;
153
+ easing?: AnimationEasing;
154
+ spring?: SpringConfig;
155
+ };
156
+
157
+ const EnteringAnimationSchema = z.object({
158
+ preset: EnteringPresetSchema,
159
+ duration: z.number().min(0).optional(),
160
+ delay: z.number().min(0).optional(),
161
+ easing: AnimationEasingSchema.optional(),
162
+ spring: SpringConfigSchema.optional(),
163
+ });
164
+
165
+ export type ExitingAnimation = {
166
+ preset: ExitingPreset;
167
+ duration?: number;
168
+ delay?: number;
169
+ easing?: AnimationEasing;
170
+ spring?: SpringConfig;
171
+ };
172
+
173
+ const ExitingAnimationSchema = z.object({
174
+ preset: ExitingPresetSchema,
175
+ duration: z.number().min(0).optional(),
176
+ delay: z.number().min(0).optional(),
177
+ easing: AnimationEasingSchema.optional(),
178
+ spring: SpringConfigSchema.optional(),
179
+ });
180
+
181
+ export type LayoutAnimation = {
182
+ preset: LayoutPreset;
183
+ duration?: number;
184
+ spring?: SpringConfig;
185
+ };
186
+
187
+ const LayoutAnimationSchema = z.object({
188
+ preset: LayoutPresetSchema,
189
+ duration: z.number().min(0).optional(),
190
+ spring: SpringConfigSchema.optional(),
191
+ });
192
+
193
+ // Continuous looping effects — the one piece not named after a reanimated
194
+ // builder. Rendered imperatively with `withRepeat` over `withTiming`.
195
+ export type EffectPreset = "pulse" | "fade" | "rotate" | "shimmer" | "bounce";
196
+
197
+ const EffectPresetSchema = z.enum(["pulse", "fade", "rotate", "shimmer", "bounce"]);
198
+
199
+ export type ElementEffect = {
200
+ preset: EffectPreset;
201
+ duration?: number;
202
+ delay?: number;
203
+ easing?: AnimationEasing;
204
+ loop?: boolean;
205
+ /** pulse: scale bounds (default 0.95 / 1.05). */
206
+ minScale?: number;
207
+ maxScale?: number;
208
+ /** fade: lower opacity bound (default 0.4). */
209
+ minOpacity?: number;
210
+ /** rotate: sweep in degrees (default 360). */
211
+ degrees?: number;
212
+ };
213
+
214
+ const EffectSchema = z.object({
215
+ preset: EffectPresetSchema,
216
+ duration: z.number().min(0).optional(),
217
+ delay: z.number().min(0).optional(),
218
+ easing: AnimationEasingSchema.optional(),
219
+ loop: z.boolean().optional(),
220
+ minScale: z.number().positive().optional(),
221
+ maxScale: z.number().positive().optional(),
222
+ minOpacity: z.number().min(0).max(1).optional(),
223
+ degrees: z.number().optional(),
224
+ });
225
+
226
+ export type ElementAnimation = {
227
+ entering?: EnteringAnimation;
228
+ exiting?: ExitingAnimation;
229
+ layout?: LayoutAnimation;
230
+ effect?: ElementEffect;
231
+ };
232
+
233
+ const ElementAnimationSchema = z.object({
234
+ entering: EnteringAnimationSchema.optional(),
235
+ exiting: ExitingAnimationSchema.optional(),
236
+ layout: LayoutAnimationSchema.optional(),
237
+ effect: EffectSchema.optional(),
238
+ });
239
+
240
+ // Static transform surface — also what `effect` animates at runtime.
241
+ export type ElementTransform = {
242
+ translateX?: number;
243
+ translateY?: number;
244
+ scale?: number;
245
+ scaleX?: number;
246
+ scaleY?: number;
247
+ /** degrees */
248
+ rotate?: number;
249
+ };
250
+
251
+ const TransformSchema = z.object({
252
+ translateX: z.number().optional(),
253
+ translateY: z.number().optional(),
254
+ scale: z.number().optional(),
255
+ scaleX: z.number().optional(),
256
+ scaleY: z.number().optional(),
257
+ rotate: z.number().optional(),
258
+ });
259
+
53
260
  export type BaseBoxProps = {
54
261
  width?: number | string;
55
262
  height?: number | string;
@@ -80,6 +287,8 @@ export type BaseBoxProps = {
80
287
  shadowOpacity?: number;
81
288
  shadowRadius?: number;
82
289
  elevation?: number;
290
+ transform?: ElementTransform;
291
+ animation?: ElementAnimation;
83
292
  };
84
293
 
85
294
  export const BaseBoxPropsSchema = z.object({
@@ -112,4 +321,6 @@ export const BaseBoxPropsSchema = z.object({
112
321
  shadowOpacity: z.number().min(0).max(1).optional(),
113
322
  shadowRadius: z.number().min(0).optional(),
114
323
  elevation: z.number().min(0).optional(),
324
+ transform: TransformSchema.optional(),
325
+ animation: ElementAnimationSchema.optional(),
115
326
  });
@@ -1,8 +1,65 @@
1
1
  import { z } from "zod";
2
2
  import { BaseBoxProps, BaseBoxPropsSchema } from "./BaseBoxProps";
3
3
 
4
+ /**
5
+ * A styled inline run of text. Used to compose rich text inside a single
6
+ * `Text` element — spans render as nested `<Text>` and inherit any prop they
7
+ * omit from the parent `Text` (React Native nested-`<Text>` inheritance), so a
8
+ * span only declares the styling it overrides.
9
+ */
10
+ export type TextSpan = {
11
+ text: string;
12
+ fontWeight?: string;
13
+ fontStyle?: "normal" | "italic";
14
+ /**
15
+ * Font family name. Omit or set to `"inherit"` to inherit the parent
16
+ * `Text` element's resolved font family.
17
+ */
18
+ fontFamily?: string | "inherit";
19
+ fontSize?: number;
20
+ letterSpacing?: number;
21
+ lineHeight?: number;
22
+ color?: string;
23
+ /** Inline highlight behind the span text. */
24
+ backgroundColor?: string;
25
+ /** Per-span opacity (0–1). */
26
+ opacity?: number;
27
+ textTransform?: "none" | "uppercase" | "lowercase" | "capitalize";
28
+ textDecorationLine?:
29
+ | "none"
30
+ | "underline"
31
+ | "line-through"
32
+ | "underline line-through";
33
+ textDecorationColor?: string;
34
+ textDecorationStyle?: "solid" | "double" | "dotted" | "dashed";
35
+ };
36
+
37
+ export const TextSpanSchema = z.object({
38
+ text: z.string(),
39
+ fontWeight: z.string().optional(),
40
+ fontStyle: z.enum(["normal", "italic"]).optional(),
41
+ fontFamily: z.string().optional(),
42
+ fontSize: z.number().optional(),
43
+ letterSpacing: z.number().optional(),
44
+ lineHeight: z.number().optional(),
45
+ color: z.string().optional(),
46
+ backgroundColor: z.string().optional(),
47
+ opacity: z.number().min(0).max(1).optional(),
48
+ textTransform: z.enum(["none", "uppercase", "lowercase", "capitalize"]).optional(),
49
+ textDecorationLine: z
50
+ .enum(["none", "underline", "line-through", "underline line-through"])
51
+ .optional(),
52
+ textDecorationColor: z.string().optional(),
53
+ textDecorationStyle: z.enum(["solid", "double", "dotted", "dashed"]).optional(),
54
+ });
55
+
4
56
  export type TextElementProps = BaseBoxProps & {
5
- content: string;
57
+ /**
58
+ * Plain string, or an array of styled spans for inline rich text. In
59
+ * `expression` mode `{{variable}}` interpolation applies to the string or to
60
+ * each span's `text`.
61
+ */
62
+ content: string | TextSpan[];
6
63
  mode?: "plain" | "expression";
7
64
  fontSize?: number;
8
65
  fontWeight?: string;
@@ -19,7 +76,7 @@ export type TextElementProps = BaseBoxProps & {
19
76
  };
20
77
 
21
78
  export const TextElementPropsSchema = BaseBoxPropsSchema.extend({
22
- content: z.string(),
79
+ content: z.union([z.string(), z.array(TextSpanSchema)]),
23
80
  mode: z.enum(["plain", "expression"]).optional(),
24
81
  fontSize: z.number().optional(),
25
82
  fontWeight: z.string().optional(),
@@ -30,9 +30,24 @@ import {
30
30
  import { type ProgressIndicatorElementProps, ProgressIndicatorElementPropsSchema } from "./elements/ProgressIndicatorElement";
31
31
 
32
32
  export type { BaseBoxProps, GradientBackground, GradientEdge, GradientStop, LinearGradientConfig } from "./elements/BaseBoxProps";
33
+ export type {
34
+ AnimationEasing,
35
+ SpringConfig,
36
+ EnteringPreset,
37
+ ExitingPreset,
38
+ LayoutPreset,
39
+ EffectPreset,
40
+ EnteringAnimation,
41
+ ExitingAnimation,
42
+ LayoutAnimation,
43
+ ElementEffect,
44
+ ElementAnimation,
45
+ ElementTransform,
46
+ } from "./elements/BaseBoxProps";
33
47
  export { BaseBoxPropsSchema, GradientBackgroundSchema } from "./elements/BaseBoxProps";
34
48
  export type { StackElementProps } from "./elements/StackElement";
35
- export type { TextElementProps } from "./elements/TextElement";
49
+ export type { TextElementProps, TextSpan } from "./elements/TextElement";
50
+ export { TextSpanSchema } from "./elements/TextElement";
36
51
  export type { ImageElementProps } from "./elements/ImageElement";
37
52
  export type { LottieElementProps } from "./elements/LottieElement";
38
53
  export type { RiveElementProps } from "./elements/RiveElement";