@rocapine/react-native-onboarding-ui 1.31.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 (62) hide show
  1. package/dist/UI/Pages/ComposableScreen/elements/AnimatedBox.d.ts +21 -0
  2. package/dist/UI/Pages/ComposableScreen/elements/AnimatedBox.d.ts.map +1 -0
  3. package/dist/UI/Pages/ComposableScreen/elements/AnimatedBox.js +140 -0
  4. package/dist/UI/Pages/ComposableScreen/elements/AnimatedBox.js.map +1 -0
  5. package/dist/UI/Pages/ComposableScreen/elements/BaseBoxProps.d.ts +220 -0
  6. package/dist/UI/Pages/ComposableScreen/elements/BaseBoxProps.d.ts.map +1 -1
  7. package/dist/UI/Pages/ComposableScreen/elements/BaseBoxProps.js +83 -0
  8. package/dist/UI/Pages/ComposableScreen/elements/BaseBoxProps.js.map +1 -1
  9. package/dist/UI/Pages/ComposableScreen/elements/ButtonElement.d.ts +640 -0
  10. package/dist/UI/Pages/ComposableScreen/elements/ButtonElement.d.ts.map +1 -1
  11. package/dist/UI/Pages/ComposableScreen/elements/CarouselElement.d.ts +160 -0
  12. package/dist/UI/Pages/ComposableScreen/elements/CarouselElement.d.ts.map +1 -1
  13. package/dist/UI/Pages/ComposableScreen/elements/CheckboxGroupElement.d.ts +160 -0
  14. package/dist/UI/Pages/ComposableScreen/elements/CheckboxGroupElement.d.ts.map +1 -1
  15. package/dist/UI/Pages/ComposableScreen/elements/DatePickerElement.d.ts +160 -0
  16. package/dist/UI/Pages/ComposableScreen/elements/DatePickerElement.d.ts.map +1 -1
  17. package/dist/UI/Pages/ComposableScreen/elements/IconElement.d.ts +160 -0
  18. package/dist/UI/Pages/ComposableScreen/elements/IconElement.d.ts.map +1 -1
  19. package/dist/UI/Pages/ComposableScreen/elements/ImageElement.d.ts +160 -0
  20. package/dist/UI/Pages/ComposableScreen/elements/ImageElement.d.ts.map +1 -1
  21. package/dist/UI/Pages/ComposableScreen/elements/InputElement.d.ts +160 -0
  22. package/dist/UI/Pages/ComposableScreen/elements/InputElement.d.ts.map +1 -1
  23. package/dist/UI/Pages/ComposableScreen/elements/KeyboardAvoidingViewElement.d.ts +160 -0
  24. package/dist/UI/Pages/ComposableScreen/elements/KeyboardAvoidingViewElement.d.ts.map +1 -1
  25. package/dist/UI/Pages/ComposableScreen/elements/LottieElement.d.ts +160 -0
  26. package/dist/UI/Pages/ComposableScreen/elements/LottieElement.d.ts.map +1 -1
  27. package/dist/UI/Pages/ComposableScreen/elements/ProgressIndicatorElement.d.ts +160 -0
  28. package/dist/UI/Pages/ComposableScreen/elements/ProgressIndicatorElement.d.ts.map +1 -1
  29. package/dist/UI/Pages/ComposableScreen/elements/ProgressIndicatorElement.js +2 -8
  30. package/dist/UI/Pages/ComposableScreen/elements/ProgressIndicatorElement.js.map +1 -1
  31. package/dist/UI/Pages/ComposableScreen/elements/RadioGroupElement.d.ts +160 -0
  32. package/dist/UI/Pages/ComposableScreen/elements/RadioGroupElement.d.ts.map +1 -1
  33. package/dist/UI/Pages/ComposableScreen/elements/RiveElement.d.ts +160 -0
  34. package/dist/UI/Pages/ComposableScreen/elements/RiveElement.d.ts.map +1 -1
  35. package/dist/UI/Pages/ComposableScreen/elements/SafeAreaViewElement.d.ts +160 -0
  36. package/dist/UI/Pages/ComposableScreen/elements/SafeAreaViewElement.d.ts.map +1 -1
  37. package/dist/UI/Pages/ComposableScreen/elements/ScrollViewElement.d.ts +160 -0
  38. package/dist/UI/Pages/ComposableScreen/elements/ScrollViewElement.d.ts.map +1 -1
  39. package/dist/UI/Pages/ComposableScreen/elements/StackElement.d.ts +160 -0
  40. package/dist/UI/Pages/ComposableScreen/elements/StackElement.d.ts.map +1 -1
  41. package/dist/UI/Pages/ComposableScreen/elements/TextElement.d.ts +198 -0
  42. package/dist/UI/Pages/ComposableScreen/elements/TextElement.d.ts.map +1 -1
  43. package/dist/UI/Pages/ComposableScreen/elements/TextElement.js +12 -0
  44. package/dist/UI/Pages/ComposableScreen/elements/TextElement.js.map +1 -1
  45. package/dist/UI/Pages/ComposableScreen/elements/VideoElement.d.ts +160 -0
  46. package/dist/UI/Pages/ComposableScreen/elements/VideoElement.d.ts.map +1 -1
  47. package/dist/UI/Pages/ComposableScreen/elements/ZStackElement.d.ts +160 -0
  48. package/dist/UI/Pages/ComposableScreen/elements/ZStackElement.d.ts.map +1 -1
  49. package/dist/UI/Pages/ComposableScreen/elements/buildAnimation.d.ts +9 -0
  50. package/dist/UI/Pages/ComposableScreen/elements/buildAnimation.d.ts.map +1 -0
  51. package/dist/UI/Pages/ComposableScreen/elements/buildAnimation.js +106 -0
  52. package/dist/UI/Pages/ComposableScreen/elements/buildAnimation.js.map +1 -0
  53. package/dist/UI/Pages/ComposableScreen/elements/renderElement.d.ts.map +1 -1
  54. package/dist/UI/Pages/ComposableScreen/elements/renderElement.js +72 -58
  55. package/dist/UI/Pages/ComposableScreen/elements/renderElement.js.map +1 -1
  56. package/package.json +1 -1
  57. package/src/UI/Pages/ComposableScreen/elements/AnimatedBox.tsx +133 -0
  58. package/src/UI/Pages/ComposableScreen/elements/BaseBoxProps.ts +211 -0
  59. package/src/UI/Pages/ComposableScreen/elements/ProgressIndicatorElement.tsx +1 -9
  60. package/src/UI/Pages/ComposableScreen/elements/TextElement.tsx +18 -0
  61. package/src/UI/Pages/ComposableScreen/elements/buildAnimation.ts +83 -0
  62. package/src/UI/Pages/ComposableScreen/elements/renderElement.tsx +28 -1
@@ -0,0 +1,83 @@
1
+ import * as Reanimated from "react-native-reanimated";
2
+ import { Easing } from "react-native-reanimated";
3
+ import type {
4
+ AnimationEasing,
5
+ EnteringAnimation,
6
+ ExitingAnimation,
7
+ LayoutAnimation,
8
+ } from "@rocapine/react-native-onboarding";
9
+
10
+ // CSS-style cubic-bezier curves matching the selectable easing names. Shared by
11
+ // the animation builders here and by ProgressIndicatorElement (single source).
12
+ export const EASING_MAP: Record<
13
+ AnimationEasing,
14
+ ReturnType<typeof Easing.bezier> | typeof Easing.linear
15
+ > = {
16
+ linear: Easing.linear,
17
+ "ease-in": Easing.bezier(0.42, 0, 1, 1),
18
+ "ease-out": Easing.bezier(0, 0, 0.58, 1),
19
+ "ease-in-out": Easing.bezier(0.42, 0, 0.58, 1),
20
+ };
21
+
22
+ // Reanimated builders are exported by name off the namespace. Looking them up by
23
+ // the schema's `preset` string is what keeps the JSON 1:1 with reanimated — the
24
+ // preset value *is* the builder name. Unknown/typo presets degrade to `undefined`
25
+ // (no animation) instead of crashing, so a payload referencing a preset the host's
26
+ // installed reanimated version lacks still mounts.
27
+ type AnyBuilder = any;
28
+
29
+ const resolveBuilder = (preset: string): AnyBuilder | undefined => {
30
+ const b = (Reanimated as unknown as Record<string, AnyBuilder>)[preset];
31
+ return b ?? undefined;
32
+ };
33
+
34
+ const applySpringOrEasing = (
35
+ builder: AnyBuilder,
36
+ spring?: { damping?: number; stiffness?: number; mass?: number },
37
+ easing?: AnimationEasing
38
+ ): AnyBuilder => {
39
+ // reanimated: `spring` (`.springify()`) and `.easing()` are mutually exclusive.
40
+ // Spring wins, matching the schema contract.
41
+ if (spring) {
42
+ let b = builder.springify();
43
+ if (spring.damping != null) b = b.damping(spring.damping);
44
+ if (spring.stiffness != null) b = b.stiffness(spring.stiffness);
45
+ if (spring.mass != null) b = b.mass(spring.mass);
46
+ return b;
47
+ }
48
+ if (easing) return builder.easing(EASING_MAP[easing]);
49
+ return builder;
50
+ };
51
+
52
+ const buildTransition = (
53
+ cfg: EnteringAnimation | ExitingAnimation | undefined
54
+ ): AnyBuilder | undefined => {
55
+ if (!cfg) return undefined;
56
+ let b = resolveBuilder(cfg.preset);
57
+ if (!b) return undefined;
58
+ if (cfg.duration != null) b = b.duration(cfg.duration);
59
+ if (cfg.delay != null) b = b.delay(cfg.delay);
60
+ return applySpringOrEasing(b, cfg.spring, cfg.easing);
61
+ };
62
+
63
+ export const buildEntering = (cfg: EnteringAnimation | undefined): AnyBuilder | undefined =>
64
+ buildTransition(cfg);
65
+
66
+ export const buildExiting = (cfg: ExitingAnimation | undefined): AnyBuilder | undefined =>
67
+ buildTransition(cfg);
68
+
69
+ export const buildLayout = (cfg: LayoutAnimation | undefined): AnyBuilder | undefined => {
70
+ if (!cfg) return undefined;
71
+ let b = resolveBuilder(cfg.preset);
72
+ if (!b) return undefined;
73
+ // Layout transitions are referenced as static builder objects; calling a
74
+ // modifier returns a configured instance.
75
+ if (cfg.duration != null) b = b.duration(cfg.duration);
76
+ if (cfg.spring) {
77
+ b = b.springify();
78
+ if (cfg.spring.damping != null) b = b.damping(cfg.spring.damping);
79
+ if (cfg.spring.stiffness != null) b = b.stiffness(cfg.spring.stiffness);
80
+ if (cfg.spring.mass != null) b = b.mass(cfg.spring.mass);
81
+ }
82
+ return b;
83
+ };
@@ -1,6 +1,7 @@
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";
@@ -21,6 +22,7 @@ import { SafeAreaViewElementComponent } from "./SafeAreaViewElement";
21
22
  import { ScrollViewElementComponent } from "./ScrollViewElement";
22
23
  import { KeyboardAvoidingViewElementComponent } from "./KeyboardAvoidingViewElement";
23
24
  import { ProgressIndicatorElementComponent } from "./ProgressIndicatorElement";
25
+ import { AnimatedBox } from "./AnimatedBox";
24
26
 
25
27
  export const renderElement = (
26
28
  element: UIElement,
@@ -34,6 +36,9 @@ export const renderElement = (
34
36
  if (!evaluateCondition(element.renderWhen, flatVars)) return null;
35
37
  }
36
38
 
39
+ // Dispatch to the concrete element renderer. Captured into `node` so a single
40
+ // AnimatedBox wrapper can apply animation/transform to any of the 15 types.
41
+ const node = ((): React.ReactNode => {
37
42
  if (element.type === "YStack" || element.type === "XStack") {
38
43
  return <StackElementComponent key={element.id} element={element} ctx={ctx} parentType={parentType} />;
39
44
  }
@@ -110,5 +115,27 @@ export const renderElement = (
110
115
  return <ProgressIndicatorElementComponent key={element.id} element={element} ctx={ctx} />;
111
116
  }
112
117
 
113
- return null;
118
+ return null;
119
+ })();
120
+
121
+ // Wrap only when motion is requested — zero overhead (no extra view) otherwise.
122
+ // Cast to BaseBoxProps: not every element's props type extends it (e.g.
123
+ // WheelPicker), but the animation/transform/flex/alignSelf fields are all
124
+ // optional BaseBoxProps members and simply read as undefined when absent.
125
+ const p = element.props as BaseBoxProps;
126
+ if (node !== null && (p.animation || p.transform)) {
127
+ return (
128
+ <AnimatedBox
129
+ key={element.id}
130
+ animation={p.animation}
131
+ transform={p.transform}
132
+ flex={p.flex}
133
+ alignSelf={p.alignSelf}
134
+ >
135
+ {node}
136
+ </AnimatedBox>
137
+ );
138
+ }
139
+
140
+ return node;
114
141
  };