@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.
- package/dist/onboarding-example.d.ts +55 -0
- package/dist/onboarding-example.d.ts.map +1 -1
- package/dist/onboarding-example.js +8 -0
- package/dist/onboarding-example.js.map +1 -1
- package/dist/steps/ComposableScreen/elements/BaseBoxProps.d.ts +32 -0
- package/dist/steps/ComposableScreen/elements/BaseBoxProps.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/BaseBoxProps.js +2 -0
- package/dist/steps/ComposableScreen/elements/BaseBoxProps.js.map +1 -1
- package/dist/steps/ComposableScreen/elements/ButtonElement.d.ts +105 -62
- package/dist/steps/ComposableScreen/elements/ButtonElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/ButtonElement.js +7 -19
- package/dist/steps/ComposableScreen/elements/ButtonElement.js.map +1 -1
- package/dist/steps/ComposableScreen/elements/CarouselElement.d.ts +24 -0
- package/dist/steps/ComposableScreen/elements/CarouselElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/CheckboxGroupElement.d.ts +24 -0
- package/dist/steps/ComposableScreen/elements/CheckboxGroupElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/DatePickerElement.d.ts +24 -0
- package/dist/steps/ComposableScreen/elements/DatePickerElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/IconElement.d.ts +24 -0
- package/dist/steps/ComposableScreen/elements/IconElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/ImageElement.d.ts +24 -0
- package/dist/steps/ComposableScreen/elements/ImageElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/InputElement.d.ts +24 -0
- package/dist/steps/ComposableScreen/elements/InputElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/KeyboardAvoidingViewElement.d.ts +24 -0
- package/dist/steps/ComposableScreen/elements/KeyboardAvoidingViewElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/LottieElement.d.ts +24 -0
- package/dist/steps/ComposableScreen/elements/LottieElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/ProgressIndicatorElement.d.ts +24 -0
- package/dist/steps/ComposableScreen/elements/ProgressIndicatorElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/ProgressiveBlurImageElement.d.ts +24 -0
- package/dist/steps/ComposableScreen/elements/ProgressiveBlurImageElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/RadioGroupElement.d.ts +24 -0
- package/dist/steps/ComposableScreen/elements/RadioGroupElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/RichTextElement.d.ts +24 -0
- package/dist/steps/ComposableScreen/elements/RichTextElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/RiveElement.d.ts +24 -0
- package/dist/steps/ComposableScreen/elements/RiveElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/SafeAreaViewElement.d.ts +24 -0
- package/dist/steps/ComposableScreen/elements/SafeAreaViewElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/ScrollViewElement.d.ts +24 -0
- package/dist/steps/ComposableScreen/elements/ScrollViewElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/StackElement.d.ts +24 -0
- package/dist/steps/ComposableScreen/elements/StackElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/TextElement.d.ts +25 -1
- package/dist/steps/ComposableScreen/elements/TextElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/VideoElement.d.ts +24 -0
- package/dist/steps/ComposableScreen/elements/VideoElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/WheelPickerElement.d.ts +24 -0
- package/dist/steps/ComposableScreen/elements/WheelPickerElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/ZStackElement.d.ts +24 -0
- package/dist/steps/ComposableScreen/elements/ZStackElement.d.ts.map +1 -1
- package/dist/steps/common.types.d.ts +84 -0
- package/dist/steps/common.types.d.ts.map +1 -1
- package/dist/steps/common.types.js +20 -1
- package/dist/steps/common.types.js.map +1 -1
- package/package.json +1 -1
- package/src/onboarding-example.ts +8 -0
- package/src/steps/ComposableScreen/elements/BaseBoxProps.ts +9 -0
- package/src/steps/ComposableScreen/elements/ButtonElement.ts +10 -42
- 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.
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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([
|