@rocapine/react-native-onboarding 1.36.1 → 1.37.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/onboarding-example.d.ts +55 -0
  2. package/dist/onboarding-example.d.ts.map +1 -1
  3. package/dist/onboarding-example.js +8 -0
  4. package/dist/onboarding-example.js.map +1 -1
  5. package/dist/steps/ComposableScreen/elements/BaseBoxProps.d.ts +32 -0
  6. package/dist/steps/ComposableScreen/elements/BaseBoxProps.d.ts.map +1 -1
  7. package/dist/steps/ComposableScreen/elements/BaseBoxProps.js +2 -0
  8. package/dist/steps/ComposableScreen/elements/BaseBoxProps.js.map +1 -1
  9. package/dist/steps/ComposableScreen/elements/ButtonElement.d.ts +105 -62
  10. package/dist/steps/ComposableScreen/elements/ButtonElement.d.ts.map +1 -1
  11. package/dist/steps/ComposableScreen/elements/ButtonElement.js +7 -19
  12. package/dist/steps/ComposableScreen/elements/ButtonElement.js.map +1 -1
  13. package/dist/steps/ComposableScreen/elements/CarouselElement.d.ts +24 -0
  14. package/dist/steps/ComposableScreen/elements/CarouselElement.d.ts.map +1 -1
  15. package/dist/steps/ComposableScreen/elements/CheckboxGroupElement.d.ts +24 -0
  16. package/dist/steps/ComposableScreen/elements/CheckboxGroupElement.d.ts.map +1 -1
  17. package/dist/steps/ComposableScreen/elements/DatePickerElement.d.ts +24 -0
  18. package/dist/steps/ComposableScreen/elements/DatePickerElement.d.ts.map +1 -1
  19. package/dist/steps/ComposableScreen/elements/IconElement.d.ts +24 -0
  20. package/dist/steps/ComposableScreen/elements/IconElement.d.ts.map +1 -1
  21. package/dist/steps/ComposableScreen/elements/ImageElement.d.ts +24 -0
  22. package/dist/steps/ComposableScreen/elements/ImageElement.d.ts.map +1 -1
  23. package/dist/steps/ComposableScreen/elements/InputElement.d.ts +24 -0
  24. package/dist/steps/ComposableScreen/elements/InputElement.d.ts.map +1 -1
  25. package/dist/steps/ComposableScreen/elements/KeyboardAvoidingViewElement.d.ts +24 -0
  26. package/dist/steps/ComposableScreen/elements/KeyboardAvoidingViewElement.d.ts.map +1 -1
  27. package/dist/steps/ComposableScreen/elements/LottieElement.d.ts +24 -0
  28. package/dist/steps/ComposableScreen/elements/LottieElement.d.ts.map +1 -1
  29. package/dist/steps/ComposableScreen/elements/ProgressIndicatorElement.d.ts +24 -0
  30. package/dist/steps/ComposableScreen/elements/ProgressIndicatorElement.d.ts.map +1 -1
  31. package/dist/steps/ComposableScreen/elements/ProgressiveBlurImageElement.d.ts +24 -0
  32. package/dist/steps/ComposableScreen/elements/ProgressiveBlurImageElement.d.ts.map +1 -1
  33. package/dist/steps/ComposableScreen/elements/RadioGroupElement.d.ts +24 -0
  34. package/dist/steps/ComposableScreen/elements/RadioGroupElement.d.ts.map +1 -1
  35. package/dist/steps/ComposableScreen/elements/RichTextElement.d.ts +24 -0
  36. package/dist/steps/ComposableScreen/elements/RichTextElement.d.ts.map +1 -1
  37. package/dist/steps/ComposableScreen/elements/RiveElement.d.ts +24 -0
  38. package/dist/steps/ComposableScreen/elements/RiveElement.d.ts.map +1 -1
  39. package/dist/steps/ComposableScreen/elements/SafeAreaViewElement.d.ts +24 -0
  40. package/dist/steps/ComposableScreen/elements/SafeAreaViewElement.d.ts.map +1 -1
  41. package/dist/steps/ComposableScreen/elements/ScrollViewElement.d.ts +24 -0
  42. package/dist/steps/ComposableScreen/elements/ScrollViewElement.d.ts.map +1 -1
  43. package/dist/steps/ComposableScreen/elements/StackElement.d.ts +24 -0
  44. package/dist/steps/ComposableScreen/elements/StackElement.d.ts.map +1 -1
  45. package/dist/steps/ComposableScreen/elements/TextElement.d.ts +25 -1
  46. package/dist/steps/ComposableScreen/elements/TextElement.d.ts.map +1 -1
  47. package/dist/steps/ComposableScreen/elements/VideoElement.d.ts +24 -0
  48. package/dist/steps/ComposableScreen/elements/VideoElement.d.ts.map +1 -1
  49. package/dist/steps/ComposableScreen/elements/WheelPickerElement.d.ts +24 -0
  50. package/dist/steps/ComposableScreen/elements/WheelPickerElement.d.ts.map +1 -1
  51. package/dist/steps/ComposableScreen/elements/ZStackElement.d.ts +24 -0
  52. package/dist/steps/ComposableScreen/elements/ZStackElement.d.ts.map +1 -1
  53. package/dist/steps/common.types.d.ts +84 -0
  54. package/dist/steps/common.types.d.ts.map +1 -1
  55. package/dist/steps/common.types.js +20 -1
  56. package/dist/steps/common.types.js.map +1 -1
  57. package/package.json +1 -1
  58. package/src/onboarding-example.ts +8 -0
  59. package/src/steps/ComposableScreen/elements/BaseBoxProps.ts +9 -0
  60. package/src/steps/ComposableScreen/elements/ButtonElement.ts +10 -42
  61. package/src/steps/common.types.ts +66 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rocapine/react-native-onboarding",
3
- "version": "1.36.1",
3
+ "version": "1.37.0",
4
4
  "description": "Headless React Native SDK for Rocapine Onboarding Studio - Data fetching, state management, and hooks",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -153,6 +153,14 @@ export const onboardingExample = {
153
153
  animation: {
154
154
  entering: { preset: "FadeInDown", duration: 500, delay: 100, easing: "ease-out" },
155
155
  },
156
+ // Generic onPress: any non-pressable element can dispatch the same
157
+ // action list as Button. Tapping the hero records a flag, and
158
+ // toggles "hero" into the `favorites` multi-select (arrayOp) —
159
+ // same JSON-array encoding as CheckboxGroup, no widget needed.
160
+ onPress: [
161
+ { type: "setVariable", name: "hero_tapped", value: "true", kind: "string" },
162
+ { type: "setVariable", name: "favorites", value: "hero", label: "Hero", arrayOp: "toggle" },
163
+ ],
156
164
  },
157
165
  },
158
166
  {
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { type ButtonAction, ButtonActionSchema } from "../../common.types";
2
3
 
3
4
  export type GradientStop = {
4
5
  color: string;
@@ -289,6 +290,13 @@ export type BaseBoxProps = {
289
290
  elevation?: number;
290
291
  transform?: ElementTransform;
291
292
  animation?: ElementAnimation;
293
+ /**
294
+ * Ordered list of actions to run when the element is tapped. Same shape as
295
+ * `Button.actions` — sequential, `"continue"` is terminal. Makes any element
296
+ * pressable. Ignored for elements that own their own press/focus/scroll
297
+ * handling (Button, RadioGroup, CheckboxGroup, DatePicker, Input, WheelPicker).
298
+ */
299
+ onPress?: ButtonAction[];
292
300
  };
293
301
 
294
302
  export const BaseBoxPropsSchema = z.object({
@@ -323,4 +331,5 @@ export const BaseBoxPropsSchema = z.object({
323
331
  elevation: z.number().min(0).optional(),
324
332
  transform: TransformSchema.optional(),
325
333
  animation: ElementAnimationSchema.optional(),
334
+ onPress: z.array(ButtonActionSchema).optional(),
326
335
  });
@@ -4,55 +4,23 @@ import {
4
4
  type LeafCondition,
5
5
  type ConditionGroup,
6
6
  type HapticStyle,
7
+ type ButtonAction,
7
8
  LeafConditionSchema,
8
9
  ConditionGroupSchema,
9
10
  HapticStyleSchema,
11
+ ButtonActionSchema,
10
12
  } from "../../common.types";
11
13
 
12
- export type CustomButtonAction = {
13
- type: "custom";
14
- function: string;
15
- variables?: string[];
16
- };
17
-
18
- export const CustomButtonActionSchema = z.object({
19
- type: z.literal("custom"),
20
- function: z.string().min(1, "function must not be empty"),
21
- variables: z.array(z.string()).optional(),
22
- });
23
-
24
- export type SetVariableButtonAction = {
25
- type: "setVariable";
26
- name: string;
27
- value: string;
28
- label?: string;
29
- /**
30
- * When `"expression"`, `value` is parsed as an arithmetic expression with
31
- * `{{var}}` references, numeric literals, and `+ - * /` (parens supported).
32
- * On parse failure, falls back to plain interpolation (string).
33
- * Defaults to `"literal"` — `value` stored verbatim.
34
- */
35
- valueMode?: "literal" | "expression";
36
- /** Tags the stored variable's underlying type. */
37
- kind?: "int" | "float" | "string";
38
- };
39
-
40
- export const SetVariableButtonActionSchema = z.object({
41
- type: z.literal("setVariable"),
42
- name: z.string().min(1, "name must not be empty"),
43
- value: z.string(),
44
- label: z.string().optional(),
45
- valueMode: z.enum(["literal", "expression"]).optional(),
46
- kind: z.enum(["int", "float", "string"]).optional(),
47
- });
48
-
49
- export type ButtonAction = "continue" | CustomButtonAction | SetVariableButtonAction;
50
-
51
- export const ButtonActionSchema = z.union([
52
- z.literal("continue"),
14
+ // `ButtonAction` and its variants moved to `common.types.ts` (now shared with the
15
+ // generic `onPress` on BaseBoxProps). Re-exported here for back-compat.
16
+ export {
17
+ type CustomButtonAction,
53
18
  CustomButtonActionSchema,
19
+ type SetVariableButtonAction,
54
20
  SetVariableButtonActionSchema,
55
- ]);
21
+ } from "../../common.types";
22
+ export type { ButtonAction };
23
+ export { ButtonActionSchema };
56
24
 
57
25
  type ButtonOverridableProps = BaseBoxProps & {
58
26
  variant?: "filled" | "outlined" | "ghost";
@@ -43,6 +43,72 @@ export const HapticStyleSchema = z.enum([
43
43
  ]);
44
44
  export type HapticStyle = z.infer<typeof HapticStyleSchema>;
45
45
 
46
+ // ── Press actions ─────────────────────────────────────────────────────────────
47
+ // Shared by `Button.actions` and the generic `onPress` on every UIElement
48
+ // (BaseBoxProps). An action is `"continue"` (terminal — advances the onboarding),
49
+ // `{type:"custom"}` (invokes a host-registered customAction), or
50
+ // `{type:"setVariable"}` (writes an onboarding variable). Run sequentially.
51
+
52
+ export type CustomButtonAction = {
53
+ type: "custom";
54
+ function: string;
55
+ variables?: string[];
56
+ };
57
+
58
+ export const CustomButtonActionSchema = z.object({
59
+ type: z.literal("custom"),
60
+ function: z.string().min(1, "function must not be empty"),
61
+ variables: z.array(z.string()).optional(),
62
+ });
63
+
64
+ export type SetVariableButtonAction = {
65
+ type: "setVariable";
66
+ name: string;
67
+ value: string;
68
+ label?: string;
69
+ /**
70
+ * When `"expression"`, `value` is parsed as an arithmetic expression with
71
+ * `{{var}}` references, numeric literals, and `+ - * /` (parens supported).
72
+ * On parse failure, falls back to plain interpolation (string).
73
+ * Defaults to `"literal"` — `value` stored verbatim.
74
+ */
75
+ valueMode?: "literal" | "expression";
76
+ /** Tags the stored variable's underlying type. */
77
+ kind?: "int" | "float" | "string";
78
+ /**
79
+ * Treat the target variable as a multi-select collection (the JSON-encoded
80
+ * `string[]` used by `CheckboxGroup`) and apply `value` as a set operation
81
+ * instead of overwriting:
82
+ * - `"append"` — add `value` if absent (dedup; no-op if already present)
83
+ * - `"remove"` — drop `value` if present
84
+ * - `"toggle"` — add when absent, remove when present (matches CheckboxGroup tap)
85
+ *
86
+ * The variable's `value` is stored as `JSON.stringify(string[])` and its
87
+ * `label` as the comma-joined member labels (`label ?? value` for each entry),
88
+ * mirroring `CheckboxGroup`. `kind` is ignored in this mode (the stored value
89
+ * is always a JSON string). Omit `arrayOp` for the default overwrite behavior.
90
+ */
91
+ arrayOp?: "append" | "remove" | "toggle";
92
+ };
93
+
94
+ export const SetVariableButtonActionSchema = z.object({
95
+ type: z.literal("setVariable"),
96
+ name: z.string().min(1, "name must not be empty"),
97
+ value: z.string(),
98
+ label: z.string().optional(),
99
+ valueMode: z.enum(["literal", "expression"]).optional(),
100
+ kind: z.enum(["int", "float", "string"]).optional(),
101
+ arrayOp: z.enum(["append", "remove", "toggle"]).optional(),
102
+ });
103
+
104
+ export type ButtonAction = "continue" | CustomButtonAction | SetVariableButtonAction;
105
+
106
+ export const ButtonActionSchema = z.union([
107
+ z.literal("continue"),
108
+ CustomButtonActionSchema,
109
+ SetVariableButtonActionSchema,
110
+ ]);
111
+
46
112
  // ── Branching / nextStep schemas ─────────────────────────────────────────────
47
113
 
48
114
  export const ConditionOperatorSchema = z.enum([