@rocapine/react-native-onboarding-ui 1.36.2 → 1.38.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/UI/Pages/ComposableScreen/elements/BaseBoxProps.d.ts +26 -0
- package/dist/UI/Pages/ComposableScreen/elements/BaseBoxProps.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/BaseBoxProps.js +2 -0
- package/dist/UI/Pages/ComposableScreen/elements/BaseBoxProps.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ButtonElement.d.ts +106 -67
- package/dist/UI/Pages/ComposableScreen/elements/ButtonElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ButtonElement.js +11 -59
- package/dist/UI/Pages/ComposableScreen/elements/ButtonElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/CarouselElement.d.ts +24 -0
- package/dist/UI/Pages/ComposableScreen/elements/CarouselElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/CheckboxGroupElement.d.ts +24 -0
- package/dist/UI/Pages/ComposableScreen/elements/CheckboxGroupElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/DatePickerElement.d.ts +24 -0
- package/dist/UI/Pages/ComposableScreen/elements/DatePickerElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/IconElement.d.ts +24 -0
- package/dist/UI/Pages/ComposableScreen/elements/IconElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ImageElement.d.ts +24 -0
- package/dist/UI/Pages/ComposableScreen/elements/ImageElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/InputElement.d.ts +24 -0
- package/dist/UI/Pages/ComposableScreen/elements/InputElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/KeyboardAvoidingViewElement.d.ts +24 -0
- package/dist/UI/Pages/ComposableScreen/elements/KeyboardAvoidingViewElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/LottieElement.d.ts +24 -0
- package/dist/UI/Pages/ComposableScreen/elements/LottieElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ProgressIndicatorElement.d.ts +32 -0
- package/dist/UI/Pages/ComposableScreen/elements/ProgressIndicatorElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ProgressIndicatorElement.js +71 -50
- package/dist/UI/Pages/ComposableScreen/elements/ProgressIndicatorElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ProgressiveBlurImageElement.d.ts +24 -0
- package/dist/UI/Pages/ComposableScreen/elements/ProgressiveBlurImageElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/RadioGroupElement.d.ts +24 -0
- package/dist/UI/Pages/ComposableScreen/elements/RadioGroupElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/RichTextElement.d.ts +24 -0
- package/dist/UI/Pages/ComposableScreen/elements/RichTextElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/RiveElement.d.ts +24 -0
- package/dist/UI/Pages/ComposableScreen/elements/RiveElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/SafeAreaViewElement.d.ts +24 -0
- package/dist/UI/Pages/ComposableScreen/elements/SafeAreaViewElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ScrollViewElement.d.ts +24 -0
- package/dist/UI/Pages/ComposableScreen/elements/ScrollViewElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/StackElement.d.ts +24 -0
- package/dist/UI/Pages/ComposableScreen/elements/StackElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/TextElement.d.ts +25 -1
- package/dist/UI/Pages/ComposableScreen/elements/TextElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/VideoElement.d.ts +24 -0
- package/dist/UI/Pages/ComposableScreen/elements/VideoElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ZStackElement.d.ts +24 -0
- package/dist/UI/Pages/ComposableScreen/elements/ZStackElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/actions.d.ts +72 -0
- package/dist/UI/Pages/ComposableScreen/elements/actions.d.ts.map +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/actions.js +24 -0
- package/dist/UI/Pages/ComposableScreen/elements/actions.js.map +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/renderElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/renderElement.js +47 -4
- package/dist/UI/Pages/ComposableScreen/elements/renderElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/runActions.d.ts +4 -0
- package/dist/UI/Pages/ComposableScreen/elements/runActions.d.ts.map +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/runActions.js +98 -0
- package/dist/UI/Pages/ComposableScreen/elements/runActions.js.map +1 -0
- package/package.json +1 -1
- package/src/UI/Pages/ComposableScreen/elements/BaseBoxProps.ts +3 -0
- package/src/UI/Pages/ComposableScreen/elements/ButtonElement.tsx +15 -91
- package/src/UI/Pages/ComposableScreen/elements/ProgressIndicatorElement.tsx +61 -34
- package/src/UI/Pages/ComposableScreen/elements/actions.ts +53 -0
- package/src/UI/Pages/ComposableScreen/elements/renderElement.tsx +59 -4
- package/src/UI/Pages/ComposableScreen/elements/runActions.ts +109 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ComposableVariableEntry,
|
|
3
|
+
ComposableVariableKind,
|
|
4
|
+
} from "@rocapine/react-native-onboarding";
|
|
5
|
+
import type { ButtonAction } from "./actions";
|
|
6
|
+
import type { RenderContext } from "./shared";
|
|
7
|
+
import { evaluateSetVariableExpression } from "./expression";
|
|
8
|
+
|
|
9
|
+
// Decode a multi-select variable's stored value (JSON-encoded string[], as
|
|
10
|
+
// written by CheckboxGroup) into a string array. Tolerates undefined / non-array
|
|
11
|
+
// / unparseable input by returning [].
|
|
12
|
+
function decodeArrayValue(raw: string | undefined): string[] {
|
|
13
|
+
if (!raw) return [];
|
|
14
|
+
try {
|
|
15
|
+
const parsed = JSON.parse(raw);
|
|
16
|
+
return Array.isArray(parsed) ? parsed.map(String) : [];
|
|
17
|
+
} catch {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Sequentially runs a list of press actions against the render context. Shared
|
|
23
|
+
// by `Button` (its `actions`) and the generic `onPress` on every UIElement
|
|
24
|
+
// (wired centrally in renderElement.tsx). Semantics:
|
|
25
|
+
// - "continue" → advance the onboarding; terminal (stops the loop).
|
|
26
|
+
// - {setVariable} → write a variable (expression-evaluated when valueMode === "expression").
|
|
27
|
+
// - {custom} → invoke the host-registered customAction with the requested
|
|
28
|
+
// variables; warns if unregistered, aborts the loop on throw.
|
|
29
|
+
export async function runActions(
|
|
30
|
+
actions: ButtonAction[],
|
|
31
|
+
ctx: RenderContext
|
|
32
|
+
): Promise<void> {
|
|
33
|
+
const { onContinue, setVariable, customActions, variables } = ctx;
|
|
34
|
+
|
|
35
|
+
for (const act of actions) {
|
|
36
|
+
if (act === "continue") {
|
|
37
|
+
onContinue();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (act.type === "setVariable") {
|
|
41
|
+
let value: string;
|
|
42
|
+
let kind: ComposableVariableKind | undefined;
|
|
43
|
+
if (act.valueMode === "expression") {
|
|
44
|
+
const computed = evaluateSetVariableExpression(act.value, variables);
|
|
45
|
+
value = computed.value;
|
|
46
|
+
kind = computed.kind;
|
|
47
|
+
} else {
|
|
48
|
+
value = act.value;
|
|
49
|
+
kind = act.kind;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (act.arrayOp) {
|
|
53
|
+
// Multi-select set operation on the JSON-encoded string[] used by
|
|
54
|
+
// CheckboxGroup. value/label are the single member being added/removed.
|
|
55
|
+
const entry = variables[act.name];
|
|
56
|
+
const curValues = decodeArrayValue(entry?.value);
|
|
57
|
+
const curLabels = entry?.label ? entry.label.split(", ") : [];
|
|
58
|
+
const memberLabel = act.label ?? value;
|
|
59
|
+
const idx = curValues.indexOf(value);
|
|
60
|
+
const present = idx !== -1;
|
|
61
|
+
const add =
|
|
62
|
+
act.arrayOp === "append" || (act.arrayOp === "toggle" && !present);
|
|
63
|
+
|
|
64
|
+
let nextValues: string[];
|
|
65
|
+
let nextLabels: string[];
|
|
66
|
+
if (add) {
|
|
67
|
+
// Dedup: appending an already-present member is a no-op.
|
|
68
|
+
nextValues = present ? curValues : [...curValues, value];
|
|
69
|
+
nextLabels = present ? curLabels : [...curLabels, memberLabel];
|
|
70
|
+
} else {
|
|
71
|
+
// remove, or toggle-when-present
|
|
72
|
+
nextValues = curValues.filter((_, i) => i !== idx);
|
|
73
|
+
nextLabels =
|
|
74
|
+
present && idx < curLabels.length
|
|
75
|
+
? curLabels.filter((_, i) => i !== idx)
|
|
76
|
+
: curLabels.filter((l) => l !== memberLabel);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
setVariable(act.name, {
|
|
80
|
+
value: JSON.stringify(nextValues),
|
|
81
|
+
label: nextLabels.join(", "),
|
|
82
|
+
});
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
setVariable(act.name, { value, label: act.label, kind });
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const handler = customActions[act.function];
|
|
90
|
+
if (!handler) {
|
|
91
|
+
console.warn(
|
|
92
|
+
`[ComposableScreen] No customAction registered for "${act.function}"`
|
|
93
|
+
);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const requested = act.variables ?? [];
|
|
97
|
+
const vars: Record<string, ComposableVariableEntry | undefined> = {};
|
|
98
|
+
for (const name of requested) vars[name] = variables[name];
|
|
99
|
+
try {
|
|
100
|
+
await handler({ variables: vars });
|
|
101
|
+
} catch (err) {
|
|
102
|
+
console.error(
|
|
103
|
+
`[ComposableScreen] customAction "${act.function}" threw:`,
|
|
104
|
+
err
|
|
105
|
+
);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|