@rocapine/react-native-onboarding-ui 1.19.0 → 1.22.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/ButtonElement.d.ts +62 -0
- package/dist/UI/Pages/ComposableScreen/elements/ButtonElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ButtonElement.js +60 -25
- package/dist/UI/Pages/ComposableScreen/elements/ButtonElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/CarouselElement.d.ts +4 -0
- package/dist/UI/Pages/ComposableScreen/elements/CarouselElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/CarouselElement.js +46 -12
- package/dist/UI/Pages/ComposableScreen/elements/CarouselElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/expression.d.ts +17 -0
- package/dist/UI/Pages/ComposableScreen/elements/expression.d.ts.map +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/expression.js +210 -0
- package/dist/UI/Pages/ComposableScreen/elements/expression.js.map +1 -0
- package/package.json +1 -1
- package/src/UI/Pages/ComposableScreen/elements/ButtonElement.tsx +80 -13
- package/src/UI/Pages/ComposableScreen/elements/CarouselElement.tsx +36 -1
- package/src/UI/Pages/ComposableScreen/elements/expression.ts +199 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import { type LeafCondition, type ConditionGroup, type ComposableVariableKind } from "@rocapine/react-native-onboarding";
|
|
3
4
|
import { BaseBoxProps } from "./BaseBoxProps";
|
|
4
5
|
import { UIElement } from "../types";
|
|
5
6
|
import { RenderContext } from "./shared";
|
|
@@ -18,12 +19,35 @@ export type SetVariableButtonAction = {
|
|
|
18
19
|
name: string;
|
|
19
20
|
value: string;
|
|
20
21
|
label?: string;
|
|
22
|
+
/**
|
|
23
|
+
* When `"expression"`, `value` is parsed as an arithmetic expression with
|
|
24
|
+
* `{{var}}` references, numeric literals, and `+ - * /` (parens supported).
|
|
25
|
+
* On parse failure, falls back to plain interpolation (string).
|
|
26
|
+
* Defaults to `"literal"` — `value` stored verbatim.
|
|
27
|
+
*/
|
|
28
|
+
valueMode?: "literal" | "expression";
|
|
29
|
+
/**
|
|
30
|
+
* Tags the stored variable's underlying type. In `"literal"` mode this is
|
|
31
|
+
* used as-is. In `"expression"` mode the inferred result kind is used
|
|
32
|
+
* unless `kind` is explicitly set (ignored — expression mode derives kind
|
|
33
|
+
* from evaluation).
|
|
34
|
+
*/
|
|
35
|
+
kind?: ComposableVariableKind;
|
|
21
36
|
};
|
|
22
37
|
export declare const SetVariableButtonActionSchema: z.ZodObject<{
|
|
23
38
|
type: z.ZodLiteral<"setVariable">;
|
|
24
39
|
name: z.ZodString;
|
|
25
40
|
value: z.ZodString;
|
|
26
41
|
label: z.ZodOptional<z.ZodString>;
|
|
42
|
+
valueMode: z.ZodOptional<z.ZodEnum<{
|
|
43
|
+
literal: "literal";
|
|
44
|
+
expression: "expression";
|
|
45
|
+
}>>;
|
|
46
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
47
|
+
string: "string";
|
|
48
|
+
int: "int";
|
|
49
|
+
float: "float";
|
|
50
|
+
}>>;
|
|
27
51
|
}, z.core.$strip>;
|
|
28
52
|
export type ButtonAction = "continue" | CustomButtonAction | SetVariableButtonAction;
|
|
29
53
|
export declare const ButtonActionSchema: z.ZodUnion<readonly [z.ZodLiteral<"continue">, z.ZodObject<{
|
|
@@ -35,6 +59,15 @@ export declare const ButtonActionSchema: z.ZodUnion<readonly [z.ZodLiteral<"cont
|
|
|
35
59
|
name: z.ZodString;
|
|
36
60
|
value: z.ZodString;
|
|
37
61
|
label: z.ZodOptional<z.ZodString>;
|
|
62
|
+
valueMode: z.ZodOptional<z.ZodEnum<{
|
|
63
|
+
literal: "literal";
|
|
64
|
+
expression: "expression";
|
|
65
|
+
}>>;
|
|
66
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
67
|
+
string: "string";
|
|
68
|
+
int: "int";
|
|
69
|
+
float: "float";
|
|
70
|
+
}>>;
|
|
38
71
|
}, z.core.$strip>]>;
|
|
39
72
|
export type ButtonElementProps = BaseBoxProps & {
|
|
40
73
|
label: string;
|
|
@@ -53,6 +86,9 @@ export type ButtonElementProps = BaseBoxProps & {
|
|
|
53
86
|
fontFamily?: string | "inherit";
|
|
54
87
|
fontStyle?: "normal" | "italic";
|
|
55
88
|
textAlign?: "left" | "center" | "right";
|
|
89
|
+
disabledWhen?: LeafCondition | ConditionGroup;
|
|
90
|
+
disabledBackgroundColor?: string;
|
|
91
|
+
disabledColor?: string;
|
|
56
92
|
};
|
|
57
93
|
export declare const ButtonElementPropsSchema: z.ZodObject<{
|
|
58
94
|
width: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
@@ -124,6 +160,15 @@ export declare const ButtonElementPropsSchema: z.ZodObject<{
|
|
|
124
160
|
name: z.ZodString;
|
|
125
161
|
value: z.ZodString;
|
|
126
162
|
label: z.ZodOptional<z.ZodString>;
|
|
163
|
+
valueMode: z.ZodOptional<z.ZodEnum<{
|
|
164
|
+
literal: "literal";
|
|
165
|
+
expression: "expression";
|
|
166
|
+
}>>;
|
|
167
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
168
|
+
string: "string";
|
|
169
|
+
int: "int";
|
|
170
|
+
float: "float";
|
|
171
|
+
}>>;
|
|
127
172
|
}, z.core.$strip>]>>>;
|
|
128
173
|
action: z.ZodOptional<z.ZodEnum<{
|
|
129
174
|
continue: "continue";
|
|
@@ -147,6 +192,23 @@ export declare const ButtonElementPropsSchema: z.ZodObject<{
|
|
|
147
192
|
right: "right";
|
|
148
193
|
center: "center";
|
|
149
194
|
}>>;
|
|
195
|
+
disabledWhen: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
196
|
+
variable: z.ZodString;
|
|
197
|
+
operator: z.ZodEnum<{
|
|
198
|
+
eq: "eq";
|
|
199
|
+
neq: "neq";
|
|
200
|
+
gt: "gt";
|
|
201
|
+
lt: "lt";
|
|
202
|
+
gte: "gte";
|
|
203
|
+
lte: "lte";
|
|
204
|
+
contains: "contains";
|
|
205
|
+
in: "in";
|
|
206
|
+
not_in: "not_in";
|
|
207
|
+
}>;
|
|
208
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>;
|
|
209
|
+
}, z.core.$strip>, z.ZodType<ConditionGroup, unknown, z.core.$ZodTypeInternals<ConditionGroup, unknown>>]>>;
|
|
210
|
+
disabledBackgroundColor: z.ZodOptional<z.ZodString>;
|
|
211
|
+
disabledColor: z.ZodOptional<z.ZodString>;
|
|
150
212
|
}, z.core.$strip>;
|
|
151
213
|
type ButtonUIElement = Extract<UIElement, {
|
|
152
214
|
type: "Button";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonElement.d.ts","sourceRoot":"","sources":["../../../../../src/UI/Pages/ComposableScreen/elements/ButtonElement.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ButtonElement.d.ts","sourceRoot":"","sources":["../../../../../src/UI/Pages/ComposableScreen/elements/ButtonElement.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAG5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAsB,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,aAAa,EAAmC,MAAM,UAAU,CAAC;AAK1E,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EA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AAC,EAAE,MAAM,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAenC,CAAC;AAEH,KAAK,eAAe,GAAG,OAAO,CAAC,SAAS,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC;AAE9D,KAAK,KAAK,GAAG;IACX,OAAO,EAAE,eAAe,CAAC;IACzB,GAAG,EAAE,aAAa,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,kBAAkB,KAAK,KAAG,KAAK,CAAC,YA6KtE,CAAC"}
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ButtonElementComponent = exports.ButtonElementPropsSchema = exports.ButtonActionSchema = exports.SetVariableButtonActionSchema = exports.CustomButtonActionSchema = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
5
6
|
const zod_1 = require("zod");
|
|
6
7
|
const react_native_1 = require("react-native");
|
|
7
8
|
const react_native_onboarding_1 = require("@rocapine/react-native-onboarding");
|
|
8
9
|
const BaseBoxProps_1 = require("./BaseBoxProps");
|
|
9
10
|
const shared_1 = require("./shared");
|
|
10
11
|
const GradientBox_1 = require("./GradientBox");
|
|
12
|
+
const expression_1 = require("./expression");
|
|
11
13
|
exports.CustomButtonActionSchema = zod_1.z.object({
|
|
12
14
|
type: zod_1.z.literal("custom"),
|
|
13
15
|
function: zod_1.z.string().min(1, "function must not be empty"),
|
|
@@ -18,6 +20,8 @@ exports.SetVariableButtonActionSchema = zod_1.z.object({
|
|
|
18
20
|
name: zod_1.z.string().min(1, "name must not be empty"),
|
|
19
21
|
value: zod_1.z.string(),
|
|
20
22
|
label: zod_1.z.string().optional(),
|
|
23
|
+
valueMode: zod_1.z.enum(["literal", "expression"]).optional(),
|
|
24
|
+
kind: zod_1.z.enum(["int", "float", "string"]).optional(),
|
|
21
25
|
});
|
|
22
26
|
exports.ButtonActionSchema = zod_1.z.union([
|
|
23
27
|
zod_1.z.literal("continue"),
|
|
@@ -36,12 +40,21 @@ exports.ButtonElementPropsSchema = BaseBoxProps_1.BaseBoxPropsSchema.extend({
|
|
|
36
40
|
fontFamily: zod_1.z.string().optional(),
|
|
37
41
|
fontStyle: zod_1.z.enum(["normal", "italic"]).optional(),
|
|
38
42
|
textAlign: zod_1.z.enum(["left", "center", "right"]).optional(),
|
|
43
|
+
disabledWhen: zod_1.z.union([react_native_onboarding_1.LeafConditionSchema, react_native_onboarding_1.ConditionGroupSchema]).optional(),
|
|
44
|
+
disabledBackgroundColor: zod_1.z.string().optional(),
|
|
45
|
+
disabledColor: zod_1.z.string().optional(),
|
|
39
46
|
});
|
|
40
47
|
const ButtonElementComponent = ({ element, ctx }) => {
|
|
41
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
48
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
42
49
|
const { theme, onContinue, customActions, variables, setVariable } = ctx;
|
|
50
|
+
const flatVariables = (0, react_1.useMemo)(() => Object.fromEntries(Object.entries(variables).map(([k, v]) => [k, v === null || v === void 0 ? void 0 : v.value])), [variables]);
|
|
51
|
+
const isDisabled = element.props.disabledWhen
|
|
52
|
+
? (0, react_native_onboarding_1.evaluateCondition)(element.props.disabledWhen, flatVariables)
|
|
53
|
+
: false;
|
|
43
54
|
const handlePress = async () => {
|
|
44
55
|
var _a;
|
|
56
|
+
if (isDisabled)
|
|
57
|
+
return;
|
|
45
58
|
const { actions, action } = element.props;
|
|
46
59
|
const effective = actions !== null && actions !== void 0 ? actions : (action === "continue" ? ["continue"] : []);
|
|
47
60
|
for (const act of effective) {
|
|
@@ -50,7 +63,18 @@ const ButtonElementComponent = ({ element, ctx }) => {
|
|
|
50
63
|
return;
|
|
51
64
|
}
|
|
52
65
|
if (act.type === "setVariable") {
|
|
53
|
-
|
|
66
|
+
let value;
|
|
67
|
+
let kind;
|
|
68
|
+
if (act.valueMode === "expression") {
|
|
69
|
+
const computed = (0, expression_1.evaluateSetVariableExpression)(act.value, variables);
|
|
70
|
+
value = computed.value;
|
|
71
|
+
kind = computed.kind;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
value = act.value;
|
|
75
|
+
kind = act.kind;
|
|
76
|
+
}
|
|
77
|
+
setVariable(act.name, { value, label: act.label, kind });
|
|
54
78
|
continue;
|
|
55
79
|
}
|
|
56
80
|
const handler = customActions[act.function];
|
|
@@ -74,63 +98,74 @@ const ButtonElementComponent = ({ element, ctx }) => {
|
|
|
74
98
|
const variant = (_a = element.props.variant) !== null && _a !== void 0 ? _a : "filled";
|
|
75
99
|
const isFilled = variant === "filled";
|
|
76
100
|
const isOutlined = variant === "outlined";
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
101
|
+
const disabledBg = (_b = element.props.disabledBackgroundColor) !== null && _b !== void 0 ? _b : theme.colors.disable;
|
|
102
|
+
const disabledText = (_c = element.props.disabledColor) !== null && _c !== void 0 ? _c : theme.colors.text.disable;
|
|
103
|
+
const bgColor = isDisabled
|
|
104
|
+
? isFilled
|
|
105
|
+
? disabledBg
|
|
106
|
+
: "transparent"
|
|
107
|
+
: isFilled
|
|
108
|
+
? ((_d = element.props.backgroundColor) !== null && _d !== void 0 ? _d : theme.colors.primary)
|
|
109
|
+
: "transparent";
|
|
110
|
+
const textColor = isDisabled
|
|
111
|
+
? disabledText
|
|
112
|
+
: isFilled
|
|
113
|
+
? ((_e = element.props.color) !== null && _e !== void 0 ? _e : theme.colors.text.opposite)
|
|
114
|
+
: ((_f = element.props.color) !== null && _f !== void 0 ? _f : theme.colors.primary);
|
|
115
|
+
const outlinedBorderColor = isDisabled
|
|
116
|
+
? disabledBg
|
|
117
|
+
: ((_g = element.props.borderColor) !== null && _g !== void 0 ? _g : theme.colors.primary);
|
|
118
|
+
const hasGradient = isFilled && !isDisabled && !!element.props.backgroundGradient;
|
|
119
|
+
const borderRadius = (_h = element.props.borderRadius) !== null && _h !== void 0 ? _h : 90;
|
|
85
120
|
const inheritedFontFamily = (0, shared_1.resolveInheritedFontFamily)(element.props.fontFamily, theme.typography.defaultFontFamily);
|
|
86
121
|
const resolvedFont = (0, react_native_onboarding_1.useResolvedFontStyle)(inheritedFontFamily, element.props.fontWeight);
|
|
87
122
|
const labelNode = ((0, jsx_runtime_1.jsx)(react_native_1.Text, { style: {
|
|
88
123
|
color: textColor,
|
|
89
|
-
fontSize: (
|
|
124
|
+
fontSize: (_j = element.props.fontSize) !== null && _j !== void 0 ? _j : theme.typography.textStyles.button.fontSize,
|
|
90
125
|
fontWeight: resolvedFont.resolvedToVariant
|
|
91
126
|
? undefined
|
|
92
|
-
: ((
|
|
127
|
+
: ((_k = resolvedFont.fontWeight) !== null && _k !== void 0 ? _k : theme.typography.textStyles.button.fontWeight),
|
|
93
128
|
fontFamily: resolvedFont.fontFamily,
|
|
94
129
|
fontStyle: element.props.fontStyle,
|
|
95
|
-
textAlign: (
|
|
130
|
+
textAlign: (_l = element.props.textAlign) !== null && _l !== void 0 ? _l : "center",
|
|
96
131
|
}, children: element.props.label }));
|
|
97
132
|
if (hasGradient) {
|
|
98
133
|
return ((0, jsx_runtime_1.jsx)(GradientBox_1.GradientBox, { gradient: element.props.backgroundGradient, style: {
|
|
99
134
|
borderRadius,
|
|
100
|
-
borderWidth: isOutlined ? ((
|
|
101
|
-
borderColor: isOutlined ?
|
|
135
|
+
borderWidth: isOutlined ? ((_m = element.props.borderWidth) !== null && _m !== void 0 ? _m : 1) : ((_o = element.props.borderWidth) !== null && _o !== void 0 ? _o : 0),
|
|
136
|
+
borderColor: isOutlined ? outlinedBorderColor : element.props.borderColor,
|
|
102
137
|
width: (0, shared_1.dim)(element.props.width),
|
|
103
138
|
height: (0, shared_1.dim)(element.props.height),
|
|
104
139
|
margin: element.props.margin,
|
|
105
140
|
marginHorizontal: element.props.marginHorizontal,
|
|
106
141
|
marginVertical: element.props.marginVertical,
|
|
107
142
|
opacity: element.props.opacity,
|
|
108
|
-
alignSelf: (
|
|
143
|
+
alignSelf: (_p = element.props.alignSelf) !== null && _p !== void 0 ? _p : (element.props.width ? undefined : "stretch"),
|
|
109
144
|
overflow: "hidden",
|
|
110
|
-
}, children: (0, jsx_runtime_1.jsx)(react_native_1.TouchableOpacity, { activeOpacity: 0.8, onPress: handlePress, style: {
|
|
145
|
+
}, children: (0, jsx_runtime_1.jsx)(react_native_1.TouchableOpacity, { activeOpacity: 0.8, onPress: handlePress, disabled: isDisabled, style: {
|
|
111
146
|
flex: 1,
|
|
112
147
|
padding: element.props.padding,
|
|
113
|
-
paddingVertical: (
|
|
114
|
-
paddingHorizontal: (
|
|
148
|
+
paddingVertical: (_q = element.props.paddingVertical) !== null && _q !== void 0 ? _q : 14,
|
|
149
|
+
paddingHorizontal: (_r = element.props.paddingHorizontal) !== null && _r !== void 0 ? _r : 24,
|
|
115
150
|
alignItems: "center",
|
|
116
151
|
justifyContent: "center",
|
|
117
152
|
}, children: labelNode }) }));
|
|
118
153
|
}
|
|
119
|
-
return ((0, jsx_runtime_1.jsx)(react_native_1.TouchableOpacity, { activeOpacity: 0.8, onPress: handlePress, style: {
|
|
154
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.TouchableOpacity, { activeOpacity: 0.8, onPress: handlePress, disabled: isDisabled, style: {
|
|
120
155
|
backgroundColor: bgColor,
|
|
121
156
|
borderRadius,
|
|
122
|
-
borderWidth: isOutlined ? ((
|
|
123
|
-
borderColor: isOutlined ?
|
|
157
|
+
borderWidth: isOutlined ? ((_s = element.props.borderWidth) !== null && _s !== void 0 ? _s : 1) : ((_t = element.props.borderWidth) !== null && _t !== void 0 ? _t : 0),
|
|
158
|
+
borderColor: isOutlined ? outlinedBorderColor : element.props.borderColor,
|
|
124
159
|
padding: element.props.padding,
|
|
125
|
-
paddingVertical: (
|
|
126
|
-
paddingHorizontal: (
|
|
160
|
+
paddingVertical: (_u = element.props.paddingVertical) !== null && _u !== void 0 ? _u : 14,
|
|
161
|
+
paddingHorizontal: (_v = element.props.paddingHorizontal) !== null && _v !== void 0 ? _v : 24,
|
|
127
162
|
width: (0, shared_1.dim)(element.props.width),
|
|
128
163
|
height: (0, shared_1.dim)(element.props.height),
|
|
129
164
|
margin: element.props.margin,
|
|
130
165
|
marginHorizontal: element.props.marginHorizontal,
|
|
131
166
|
marginVertical: element.props.marginVertical,
|
|
132
167
|
opacity: element.props.opacity,
|
|
133
|
-
alignSelf: (
|
|
168
|
+
alignSelf: (_w = element.props.alignSelf) !== null && _w !== void 0 ? _w : (element.props.width ? undefined : "stretch"),
|
|
134
169
|
alignItems: "center",
|
|
135
170
|
justifyContent: "center",
|
|
136
171
|
}, children: labelNode }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonElement.js","sourceRoot":"","sources":["../../../../../src/UI/Pages/ComposableScreen/elements/ButtonElement.tsx"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"ButtonElement.js","sourceRoot":"","sources":["../../../../../src/UI/Pages/ComposableScreen/elements/ButtonElement.tsx"],"names":[],"mappings":";;;;AAAA,iCAAuC;AACvC,6BAAwB;AACxB,+CAAsD;AACtD,+EAQ2C;AAC3C,iDAAkE;AAElE,qCAA0E;AAC1E,+CAA4C;AAE5C,6CAA6D;AAQhD,QAAA,wBAAwB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC/C,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;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AAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;YAC/B,MAAM,EAAE,IAAA,YAAG,EAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC;YACjC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM;YAC5B,gBAAgB,EAAE,OAAO,CAAC,KAAK,CAAC,gBAAgB;YAChD,cAAc,EAAE,OAAO,CAAC,KAAK,CAAC,cAAc;YAC5C,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,OAAO;YAC9B,SAAS,EAAE,MAAA,OAAO,CAAC,KAAK,CAAC,SAAS,mCAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;YACnF,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,QAAQ;SACzB,YAEA,SAAS,GACO,CACpB,CAAC;AACJ,CAAC,CAAC;AA7KW,QAAA,sBAAsB,0BA6KjC"}
|
|
@@ -15,6 +15,8 @@ export type CarouselElementProps = BaseBoxProps & {
|
|
|
15
15
|
dotHeight?: number;
|
|
16
16
|
dotsGap?: number;
|
|
17
17
|
dotsMarginTop?: number;
|
|
18
|
+
defaultIndex?: number | null;
|
|
19
|
+
variableName?: string;
|
|
18
20
|
};
|
|
19
21
|
export declare const CarouselElementPropsSchema: z.ZodObject<{
|
|
20
22
|
width: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
@@ -93,6 +95,8 @@ export declare const CarouselElementPropsSchema: z.ZodObject<{
|
|
|
93
95
|
dotHeight: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
94
96
|
dotsGap: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
95
97
|
dotsMarginTop: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
98
|
+
defaultIndex: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
99
|
+
variableName: z.ZodOptional<z.ZodString>;
|
|
96
100
|
}, z.core.$strip>;
|
|
97
101
|
type CarouselUIElement = Extract<UIElement, {
|
|
98
102
|
type: "Carousel";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CarouselElement.d.ts","sourceRoot":"","sources":["../../../../../src/UI/Pages/ComposableScreen/elements/CarouselElement.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"CarouselElement.d.ts","sourceRoot":"","sources":["../../../../../src/UI/Pages/ComposableScreen/elements/CarouselElement.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAsB,MAAM,gBAAgB,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAO,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAGnD,MAAM,MAAM,oBAAoB,GAAG,YAAY,GAAG;IAChD,YAAY,CAAC,EAAE,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;IAC9D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAcrC,CAAC;AAEH,KAAK,iBAAiB,GAAG,OAAO,CAAC,SAAS,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CAAC;AAIlE,KAAK,KAAK,GAAG;IACX,OAAO,EAAE,iBAAiB,CAAC;IAC3B,GAAG,EAAE,aAAa,CAAC;CACpB,CAAC;AAEF,wBAAgB,wBAAwB,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,KAAK,GAAG,KAAK,CAAC,YAAY,CA2JpF"}
|
|
@@ -56,16 +56,43 @@ exports.CarouselElementPropsSchema = BaseBoxProps_1.BaseBoxPropsSchema.extend({
|
|
|
56
56
|
dotHeight: zod_1.z.number().nonnegative().optional().default(4),
|
|
57
57
|
dotsGap: zod_1.z.number().nonnegative().optional().default(8),
|
|
58
58
|
dotsMarginTop: zod_1.z.number().optional().default(12),
|
|
59
|
+
defaultIndex: zod_1.z.number().int().nonnegative().nullable().optional(),
|
|
60
|
+
variableName: zod_1.z.string().min(1).optional(),
|
|
59
61
|
});
|
|
60
62
|
const DEFAULT_HEIGHT = 240;
|
|
61
63
|
function CarouselElementComponent({ element, ctx }) {
|
|
62
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
64
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
63
65
|
const { theme } = ctx;
|
|
64
66
|
const { props, children } = element;
|
|
65
67
|
const progress = (0, react_native_reanimated_1.useSharedValue)(0);
|
|
66
68
|
const ref = (0, react_1.useRef)(null);
|
|
67
69
|
const [size, setSize] = (0, react_1.useState)(null);
|
|
68
70
|
const carouselType = (_a = props.carouselType) !== null && _a !== void 0 ? _a : "normal";
|
|
71
|
+
const variableName = props.variableName;
|
|
72
|
+
const variableValue = variableName ? (_b = ctx.variables[variableName]) === null || _b === void 0 ? void 0 : _b.value : undefined;
|
|
73
|
+
const childrenCount = children.length;
|
|
74
|
+
const clampIndex = (n) => Math.max(0, Math.min(n, Math.max(0, childrenCount - 1)));
|
|
75
|
+
// Frozen on first mount — RNRC `defaultIndex` only applies at mount.
|
|
76
|
+
const initialIndexRef = (0, react_1.useRef)(null);
|
|
77
|
+
if (initialIndexRef.current === null) {
|
|
78
|
+
const parsed = variableValue !== undefined ? parseInt(variableValue, 10) : NaN;
|
|
79
|
+
const fromVar = Number.isFinite(parsed) ? parsed : null;
|
|
80
|
+
initialIndexRef.current = clampIndex((_c = fromVar !== null && fromVar !== void 0 ? fromVar : props.defaultIndex) !== null && _c !== void 0 ? _c : 0);
|
|
81
|
+
}
|
|
82
|
+
const lastSyncedIndexRef = (0, react_1.useRef)(initialIndexRef.current);
|
|
83
|
+
(0, react_1.useEffect)(() => {
|
|
84
|
+
var _a;
|
|
85
|
+
if (!variableName)
|
|
86
|
+
return;
|
|
87
|
+
const parsed = parseInt(variableValue !== null && variableValue !== void 0 ? variableValue : "", 10);
|
|
88
|
+
if (!Number.isFinite(parsed))
|
|
89
|
+
return;
|
|
90
|
+
const target = clampIndex(parsed);
|
|
91
|
+
if (target === lastSyncedIndexRef.current)
|
|
92
|
+
return;
|
|
93
|
+
lastSyncedIndexRef.current = target;
|
|
94
|
+
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.scrollTo({ count: target - progress.value, animated: true });
|
|
95
|
+
}, [variableName, variableValue, childrenCount]);
|
|
69
96
|
const onLayout = (e) => {
|
|
70
97
|
const { width, height } = e.nativeEvent.layout;
|
|
71
98
|
if (!size || size.width !== width || size.height !== height) {
|
|
@@ -73,7 +100,7 @@ function CarouselElementComponent({ element, ctx }) {
|
|
|
73
100
|
}
|
|
74
101
|
};
|
|
75
102
|
// Stack uses 75% width (shows side items); left-align uses 82% (peek effect)
|
|
76
|
-
const availableWidth = (
|
|
103
|
+
const availableWidth = (_d = size === null || size === void 0 ? void 0 : size.width) !== null && _d !== void 0 ? _d : 0;
|
|
77
104
|
const itemWidth = carouselType === "stack"
|
|
78
105
|
? availableWidth * 0.75
|
|
79
106
|
: carouselType === "left-align"
|
|
@@ -87,7 +114,7 @@ function CarouselElementComponent({ element, ctx }) {
|
|
|
87
114
|
flexShrink: props.flexShrink,
|
|
88
115
|
flexGrow: props.flexGrow,
|
|
89
116
|
width: (0, shared_1.dim)(props.width),
|
|
90
|
-
height: (
|
|
117
|
+
height: (_e = (0, shared_1.dim)(props.height)) !== null && _e !== void 0 ? _e : heightFallback,
|
|
91
118
|
minWidth: props.minWidth,
|
|
92
119
|
maxWidth: props.maxWidth,
|
|
93
120
|
minHeight: props.minHeight,
|
|
@@ -104,7 +131,7 @@ function CarouselElementComponent({ element, ctx }) {
|
|
|
104
131
|
backgroundColor: props.backgroundGradient ? undefined : props.backgroundColor,
|
|
105
132
|
opacity: props.opacity,
|
|
106
133
|
// Left-align shows the next slide peeking — must not clip
|
|
107
|
-
overflow: carouselType === "left-align" ? "visible" : ((
|
|
134
|
+
overflow: carouselType === "left-align" ? "visible" : ((_f = props.overflow) !== null && _f !== void 0 ? _f : "hidden"),
|
|
108
135
|
};
|
|
109
136
|
const modeProps = carouselType === "parallax"
|
|
110
137
|
? {
|
|
@@ -118,16 +145,23 @@ function CarouselElementComponent({ element, ctx }) {
|
|
|
118
145
|
customConfig: () => ({ type: "positive", viewCount: 5 }),
|
|
119
146
|
}
|
|
120
147
|
: {};
|
|
121
|
-
const dotW = (
|
|
122
|
-
const dotH = (
|
|
123
|
-
const dotsGap = (
|
|
124
|
-
const dotsMarginTop = (
|
|
125
|
-
const dotBg = (
|
|
126
|
-
const activeDotBg = (
|
|
148
|
+
const dotW = (_g = props.dotWidth) !== null && _g !== void 0 ? _g : 20;
|
|
149
|
+
const dotH = (_h = props.dotHeight) !== null && _h !== void 0 ? _h : 4;
|
|
150
|
+
const dotsGap = (_j = props.dotsGap) !== null && _j !== void 0 ? _j : 8;
|
|
151
|
+
const dotsMarginTop = (_k = props.dotsMarginTop) !== null && _k !== void 0 ? _k : 12;
|
|
152
|
+
const dotBg = (_l = props.dotColor) !== null && _l !== void 0 ? _l : theme.colors.neutral.low;
|
|
153
|
+
const activeDotBg = (_m = props.activeDotColor) !== null && _m !== void 0 ? _m : theme.colors.primary;
|
|
127
154
|
const ready = !!size && size.width > 0 && size.height > 0;
|
|
128
|
-
return ((0, jsx_runtime_1.jsxs)(GradientBox_1.GradientBox, { gradient: props.backgroundGradient, style: containerStyle, children: [(0, jsx_runtime_1.jsx)(react_native_1.View, { style: { flex: 1 }, onLayout: onLayout, children: ready && ((0, jsx_runtime_1.jsx)(react_native_reanimated_carousel_1.default, Object.assign({ ref: ref, loop: props.loop, autoPlay: props.autoPlay, autoPlayInterval: props.autoPlayInterval, snapEnabled: true, pagingEnabled: true, data: children, width: itemWidth, height: size.height, style: { width: size.width, height: size.height }, renderItem: ({ item }) => ctx.renderChildren([item], "YStack"), onProgressChange: (_, absoluteProgress) => {
|
|
155
|
+
return ((0, jsx_runtime_1.jsxs)(GradientBox_1.GradientBox, { gradient: props.backgroundGradient, style: containerStyle, children: [(0, jsx_runtime_1.jsx)(react_native_1.View, { style: { flex: 1 }, onLayout: onLayout, children: ready && ((0, jsx_runtime_1.jsx)(react_native_reanimated_carousel_1.default, Object.assign({ ref: ref, loop: props.loop, autoPlay: props.autoPlay, autoPlayInterval: props.autoPlayInterval, defaultIndex: (_o = initialIndexRef.current) !== null && _o !== void 0 ? _o : 0, snapEnabled: true, pagingEnabled: true, data: children, width: itemWidth, height: size.height, style: { width: size.width, height: size.height }, renderItem: ({ item }) => ctx.renderChildren([item], "YStack"), onProgressChange: (_, absoluteProgress) => {
|
|
129
156
|
progress.value = absoluteProgress;
|
|
130
|
-
}
|
|
157
|
+
}, onSnapToItem: (index) => {
|
|
158
|
+
if (!variableName)
|
|
159
|
+
return;
|
|
160
|
+
if (index === lastSyncedIndexRef.current)
|
|
161
|
+
return;
|
|
162
|
+
lastSyncedIndexRef.current = index;
|
|
163
|
+
ctx.setVariable(variableName, { value: String(index) });
|
|
164
|
+
} }, modeProps))) }), ((_p = props.showDots) !== null && _p !== void 0 ? _p : true) && ((0, jsx_runtime_1.jsx)(react_native_reanimated_carousel_1.Pagination.Basic, { progress: progress, data: children, dotStyle: {
|
|
131
165
|
width: dotW,
|
|
132
166
|
height: dotH,
|
|
133
167
|
borderRadius: dotH / 2,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CarouselElement.js","sourceRoot":"","sources":["../../../../../src/UI/Pages/ComposableScreen/elements/CarouselElement.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"CarouselElement.js","sourceRoot":"","sources":["../../../../../src/UI/Pages/ComposableScreen/elements/CarouselElement.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,4DA2JC;;AA9MD,iCAA2D;AAC3D,+CAA4D;AAC5D,6BAAwB;AACxB,qEAAyD;AACzD,qGAA2F;AAC3F,iDAAkE;AAElE,qCAAmD;AACnD,+CAA4C;AAkB/B,QAAA,0BAA0B,GAAG,iCAAkB,CAAC,MAAM,CAAC;IAClE,YAAY,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC;IAChG,QAAQ,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IAC/C,gBAAgB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IACnE,IAAI,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAC1C,QAAQ,EAAE,OAAC,CAAC,OAAO,EAAE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oBACZ,YAAY,EAAE,IAAI,GAAG,CAAC;oBACtB,eAAe,EAAE,KAAK;iBACvB,EACD,cAAc,EAAE;oBACd,QAAQ,EAAE,QAAQ;oBAClB,eAAe,EAAE,WAAW;iBAC7B,EACD,cAAc,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,EAC1D,UAAU,QACV,OAAO,EAAE,CAAC,KAAa,EAAE,EAAE;;oBACzB,MAAA,GAAG,CAAC,OAAO,0CAAE,QAAQ,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC3E,CAAC,GACD,CACH,IACW,CACf,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ComposableVariableEntry, ComposableVariableKind } from "@rocapine/react-native-onboarding";
|
|
2
|
+
/**
|
|
3
|
+
* Evaluate a `setVariable` expression-mode value template.
|
|
4
|
+
*
|
|
5
|
+
* Accepts `{{var}}` references, numeric literals (int / float), `+ - * /` and
|
|
6
|
+
* parentheses. Variable values are coerced according to their `kind` tag
|
|
7
|
+
* (string / int / float), or inferred from their string content when no tag
|
|
8
|
+
* is present. `+` on any non-numeric operand becomes string concat.
|
|
9
|
+
*
|
|
10
|
+
* On any parse or evaluation failure, falls back to plain interpolation
|
|
11
|
+
* (existing `interpolate()` semantics, returns a string).
|
|
12
|
+
*/
|
|
13
|
+
export declare function evaluateSetVariableExpression(template: string, vars: Record<string, ComposableVariableEntry>): {
|
|
14
|
+
value: string;
|
|
15
|
+
kind: ComposableVariableKind;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=expression.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expression.d.ts","sourceRoot":"","sources":["../../../../../src/UI/Pages/ComposableScreen/elements/expression.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AA4KzG;;;;;;;;;;GAUG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,GAC5C;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,sBAAsB,CAAA;CAAE,CAYjD"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.evaluateSetVariableExpression = evaluateSetVariableExpression;
|
|
4
|
+
const shared_1 = require("./shared");
|
|
5
|
+
const isDigit = (c) => c >= "0" && c <= "9";
|
|
6
|
+
const isSpace = (c) => c === " " || c === "\t" || c === "\n" || c === "\r";
|
|
7
|
+
function tokenize(input) {
|
|
8
|
+
var _a;
|
|
9
|
+
const tokens = [];
|
|
10
|
+
let i = 0;
|
|
11
|
+
while (i < input.length) {
|
|
12
|
+
const c = input[i];
|
|
13
|
+
if (isSpace(c)) {
|
|
14
|
+
i++;
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (c === "{" && input[i + 1] === "{") {
|
|
18
|
+
const end = input.indexOf("}}", i + 2);
|
|
19
|
+
if (end === -1)
|
|
20
|
+
return null;
|
|
21
|
+
const name = input.slice(i + 2, end).trim();
|
|
22
|
+
if (!name)
|
|
23
|
+
return null;
|
|
24
|
+
tokens.push({ kind: "var", name });
|
|
25
|
+
i = end + 2;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (c === "(") {
|
|
29
|
+
tokens.push({ kind: "lparen" });
|
|
30
|
+
i++;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (c === ")") {
|
|
34
|
+
tokens.push({ kind: "rparen" });
|
|
35
|
+
i++;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (c === "+" || c === "-" || c === "*" || c === "/") {
|
|
39
|
+
tokens.push({ kind: "op", op: c });
|
|
40
|
+
i++;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (isDigit(c) || (c === "." && isDigit((_a = input[i + 1]) !== null && _a !== void 0 ? _a : ""))) {
|
|
44
|
+
let j = i;
|
|
45
|
+
let dot = false;
|
|
46
|
+
while (j < input.length && (isDigit(input[j]) || input[j] === ".")) {
|
|
47
|
+
if (input[j] === ".") {
|
|
48
|
+
if (dot)
|
|
49
|
+
return null;
|
|
50
|
+
dot = true;
|
|
51
|
+
}
|
|
52
|
+
j++;
|
|
53
|
+
}
|
|
54
|
+
const num = parseFloat(input.slice(i, j));
|
|
55
|
+
if (!Number.isFinite(num))
|
|
56
|
+
return null;
|
|
57
|
+
tokens.push({ kind: "num", value: num, isInt: !dot });
|
|
58
|
+
i = j;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
tokens.push({ kind: "eof" });
|
|
64
|
+
return tokens;
|
|
65
|
+
}
|
|
66
|
+
function resolveVar(name, vars) {
|
|
67
|
+
const entry = vars[name];
|
|
68
|
+
// Missing variable in arithmetic context defaults to numeric 0 so increment
|
|
69
|
+
// / decrement patterns work on first click before the variable is seeded.
|
|
70
|
+
if (!entry)
|
|
71
|
+
return { kind: "number", n: 0, isInt: true };
|
|
72
|
+
const raw = entry.value;
|
|
73
|
+
const k = entry.kind;
|
|
74
|
+
if (k === "string")
|
|
75
|
+
return { kind: "string", s: raw };
|
|
76
|
+
if (k === "int") {
|
|
77
|
+
const n = parseInt(raw, 10);
|
|
78
|
+
return Number.isFinite(n) ? { kind: "number", n, isInt: true } : { kind: "string", s: raw };
|
|
79
|
+
}
|
|
80
|
+
if (k === "float") {
|
|
81
|
+
const n = parseFloat(raw);
|
|
82
|
+
return Number.isFinite(n) ? { kind: "number", n, isInt: false } : { kind: "string", s: raw };
|
|
83
|
+
}
|
|
84
|
+
// No kind tag — infer from string content.
|
|
85
|
+
const trimmed = raw.trim();
|
|
86
|
+
if (trimmed !== "" && /^-?\d+(\.\d+)?$/.test(trimmed)) {
|
|
87
|
+
const n = parseFloat(trimmed);
|
|
88
|
+
if (Number.isFinite(n))
|
|
89
|
+
return { kind: "number", n, isInt: Number.isInteger(n) && !trimmed.includes(".") };
|
|
90
|
+
}
|
|
91
|
+
return { kind: "string", s: raw };
|
|
92
|
+
}
|
|
93
|
+
function valueToString(v) {
|
|
94
|
+
if (v.kind === "string")
|
|
95
|
+
return v.s;
|
|
96
|
+
if (v.isInt)
|
|
97
|
+
return Math.trunc(v.n).toString();
|
|
98
|
+
return v.n.toString();
|
|
99
|
+
}
|
|
100
|
+
function parse(tokens, vars) {
|
|
101
|
+
let pos = 0;
|
|
102
|
+
const peek = () => tokens[pos];
|
|
103
|
+
const advance = () => tokens[pos++];
|
|
104
|
+
const factor = () => {
|
|
105
|
+
const t = peek();
|
|
106
|
+
if (t.kind === "lparen") {
|
|
107
|
+
advance();
|
|
108
|
+
const v = expr();
|
|
109
|
+
if (!v)
|
|
110
|
+
return null;
|
|
111
|
+
if (peek().kind !== "rparen")
|
|
112
|
+
return null;
|
|
113
|
+
advance();
|
|
114
|
+
return v;
|
|
115
|
+
}
|
|
116
|
+
if (t.kind === "op" && t.op === "-") {
|
|
117
|
+
advance();
|
|
118
|
+
const v = factor();
|
|
119
|
+
if (!v || v.kind !== "number")
|
|
120
|
+
return null;
|
|
121
|
+
return { kind: "number", n: -v.n, isInt: v.isInt };
|
|
122
|
+
}
|
|
123
|
+
if (t.kind === "num") {
|
|
124
|
+
advance();
|
|
125
|
+
return { kind: "number", n: t.value, isInt: t.isInt };
|
|
126
|
+
}
|
|
127
|
+
if (t.kind === "var") {
|
|
128
|
+
advance();
|
|
129
|
+
return resolveVar(t.name, vars);
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
};
|
|
133
|
+
const term = () => {
|
|
134
|
+
let left = factor();
|
|
135
|
+
if (!left)
|
|
136
|
+
return null;
|
|
137
|
+
while (peek().kind === "op" && (peek().op === "*" || peek().op === "/")) {
|
|
138
|
+
const op = advance().op;
|
|
139
|
+
const right = factor();
|
|
140
|
+
if (!right)
|
|
141
|
+
return null;
|
|
142
|
+
if (left.kind !== "number" || right.kind !== "number")
|
|
143
|
+
return null;
|
|
144
|
+
if (op === "/" && right.n === 0)
|
|
145
|
+
return null;
|
|
146
|
+
const result = op === "*" ? left.n * right.n : left.n / right.n;
|
|
147
|
+
if (!Number.isFinite(result))
|
|
148
|
+
return null;
|
|
149
|
+
const isInt = op === "*" ? left.isInt && right.isInt : Number.isInteger(result);
|
|
150
|
+
left = { kind: "number", n: result, isInt };
|
|
151
|
+
}
|
|
152
|
+
return left;
|
|
153
|
+
};
|
|
154
|
+
const expr = () => {
|
|
155
|
+
let left = term();
|
|
156
|
+
if (!left)
|
|
157
|
+
return null;
|
|
158
|
+
while (peek().kind === "op" && (peek().op === "+" || peek().op === "-")) {
|
|
159
|
+
const op = advance().op;
|
|
160
|
+
const right = term();
|
|
161
|
+
if (!right)
|
|
162
|
+
return null;
|
|
163
|
+
if (op === "+") {
|
|
164
|
+
if (left.kind === "number" && right.kind === "number") {
|
|
165
|
+
left = { kind: "number", n: left.n + right.n, isInt: left.isInt && right.isInt };
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
left = { kind: "string", s: valueToString(left) + valueToString(right) };
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
if (left.kind !== "number" || right.kind !== "number")
|
|
173
|
+
return null;
|
|
174
|
+
left = { kind: "number", n: left.n - right.n, isInt: left.isInt && right.isInt };
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return left;
|
|
178
|
+
};
|
|
179
|
+
const result = expr();
|
|
180
|
+
if (!result)
|
|
181
|
+
return null;
|
|
182
|
+
if (peek().kind !== "eof")
|
|
183
|
+
return null;
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Evaluate a `setVariable` expression-mode value template.
|
|
188
|
+
*
|
|
189
|
+
* Accepts `{{var}}` references, numeric literals (int / float), `+ - * /` and
|
|
190
|
+
* parentheses. Variable values are coerced according to their `kind` tag
|
|
191
|
+
* (string / int / float), or inferred from their string content when no tag
|
|
192
|
+
* is present. `+` on any non-numeric operand becomes string concat.
|
|
193
|
+
*
|
|
194
|
+
* On any parse or evaluation failure, falls back to plain interpolation
|
|
195
|
+
* (existing `interpolate()` semantics, returns a string).
|
|
196
|
+
*/
|
|
197
|
+
function evaluateSetVariableExpression(template, vars) {
|
|
198
|
+
const tokens = tokenize(template);
|
|
199
|
+
if (tokens) {
|
|
200
|
+
const result = parse(tokens, vars);
|
|
201
|
+
if (result) {
|
|
202
|
+
if (result.kind === "number") {
|
|
203
|
+
return { value: valueToString(result), kind: result.isInt ? "int" : "float" };
|
|
204
|
+
}
|
|
205
|
+
return { value: result.s, kind: "string" };
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return { value: (0, shared_1.interpolate)(template, vars), kind: "string" };
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=expression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expression.js","sourceRoot":"","sources":["../../../../../src/UI/Pages/ComposableScreen/elements/expression.ts"],"names":[],"mappings":";;AAuLA,sEAeC;AArMD,qCAAuC;AAcvC,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,GAAG,CAAC;AACpD,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC;AAEnF,SAAS,QAAQ,CAAC,KAAa;;IAC7B,MAAM,MAAM,GAAY,EAAE,CAAC;IAC3B,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,C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ACnC,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC7B,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;YAChF,CAAC;YACD,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QAC7C,CAAC;IACH,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAA,oBAAW,EAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAChE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rocapine/react-native-onboarding-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.0",
|
|
4
4
|
"description": "UI components and renderers for Rocapine Onboarding Studio - Built on top of the headless SDK",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { Text, TouchableOpacity } from "react-native";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
useResolvedFontStyle,
|
|
6
|
+
evaluateCondition,
|
|
7
|
+
type LeafCondition,
|
|
8
|
+
type ConditionGroup,
|
|
9
|
+
type ComposableVariableKind,
|
|
10
|
+
LeafConditionSchema,
|
|
11
|
+
ConditionGroupSchema,
|
|
12
|
+
} from "@rocapine/react-native-onboarding";
|
|
5
13
|
import { BaseBoxProps, BaseBoxPropsSchema } from "./BaseBoxProps";
|
|
6
14
|
import { UIElement } from "../types";
|
|
7
15
|
import { RenderContext, dim, resolveInheritedFontFamily } from "./shared";
|
|
8
16
|
import { GradientBox } from "./GradientBox";
|
|
9
17
|
import { ComposableVariableEntry } from "../../../Provider/OnboardingProgressProvider";
|
|
18
|
+
import { evaluateSetVariableExpression } from "./expression";
|
|
10
19
|
|
|
11
20
|
export type CustomButtonAction = {
|
|
12
21
|
type: "custom";
|
|
@@ -25,6 +34,20 @@ export type SetVariableButtonAction = {
|
|
|
25
34
|
name: string;
|
|
26
35
|
value: string;
|
|
27
36
|
label?: string;
|
|
37
|
+
/**
|
|
38
|
+
* When `"expression"`, `value` is parsed as an arithmetic expression with
|
|
39
|
+
* `{{var}}` references, numeric literals, and `+ - * /` (parens supported).
|
|
40
|
+
* On parse failure, falls back to plain interpolation (string).
|
|
41
|
+
* Defaults to `"literal"` — `value` stored verbatim.
|
|
42
|
+
*/
|
|
43
|
+
valueMode?: "literal" | "expression";
|
|
44
|
+
/**
|
|
45
|
+
* Tags the stored variable's underlying type. In `"literal"` mode this is
|
|
46
|
+
* used as-is. In `"expression"` mode the inferred result kind is used
|
|
47
|
+
* unless `kind` is explicitly set (ignored — expression mode derives kind
|
|
48
|
+
* from evaluation).
|
|
49
|
+
*/
|
|
50
|
+
kind?: ComposableVariableKind;
|
|
28
51
|
};
|
|
29
52
|
|
|
30
53
|
export const SetVariableButtonActionSchema = z.object({
|
|
@@ -32,6 +55,8 @@ export const SetVariableButtonActionSchema = z.object({
|
|
|
32
55
|
name: z.string().min(1, "name must not be empty"),
|
|
33
56
|
value: z.string(),
|
|
34
57
|
label: z.string().optional(),
|
|
58
|
+
valueMode: z.enum(["literal", "expression"]).optional(),
|
|
59
|
+
kind: z.enum(["int", "float", "string"]).optional(),
|
|
35
60
|
});
|
|
36
61
|
|
|
37
62
|
export type ButtonAction = "continue" | CustomButtonAction | SetVariableButtonAction;
|
|
@@ -59,6 +84,9 @@ export type ButtonElementProps = BaseBoxProps & {
|
|
|
59
84
|
fontFamily?: string | "inherit";
|
|
60
85
|
fontStyle?: "normal" | "italic";
|
|
61
86
|
textAlign?: "left" | "center" | "right";
|
|
87
|
+
disabledWhen?: LeafCondition | ConditionGroup;
|
|
88
|
+
disabledBackgroundColor?: string;
|
|
89
|
+
disabledColor?: string;
|
|
62
90
|
};
|
|
63
91
|
|
|
64
92
|
export const ButtonElementPropsSchema = BaseBoxPropsSchema.extend({
|
|
@@ -73,6 +101,9 @@ export const ButtonElementPropsSchema = BaseBoxPropsSchema.extend({
|
|
|
73
101
|
fontFamily: z.string().optional(),
|
|
74
102
|
fontStyle: z.enum(["normal", "italic"]).optional(),
|
|
75
103
|
textAlign: z.enum(["left", "center", "right"]).optional(),
|
|
104
|
+
disabledWhen: z.union([LeafConditionSchema, ConditionGroupSchema]).optional(),
|
|
105
|
+
disabledBackgroundColor: z.string().optional(),
|
|
106
|
+
disabledColor: z.string().optional(),
|
|
76
107
|
});
|
|
77
108
|
|
|
78
109
|
type ButtonUIElement = Extract<UIElement, { type: "Button" }>;
|
|
@@ -84,7 +115,18 @@ type Props = {
|
|
|
84
115
|
|
|
85
116
|
export const ButtonElementComponent = ({ element, ctx }: Props): React.ReactElement => {
|
|
86
117
|
const { theme, onContinue, customActions, variables, setVariable } = ctx;
|
|
118
|
+
const flatVariables = useMemo(
|
|
119
|
+
() =>
|
|
120
|
+
Object.fromEntries(
|
|
121
|
+
Object.entries(variables).map(([k, v]) => [k, v?.value])
|
|
122
|
+
),
|
|
123
|
+
[variables]
|
|
124
|
+
);
|
|
125
|
+
const isDisabled = element.props.disabledWhen
|
|
126
|
+
? evaluateCondition(element.props.disabledWhen, flatVariables)
|
|
127
|
+
: false;
|
|
87
128
|
const handlePress = async () => {
|
|
129
|
+
if (isDisabled) return;
|
|
88
130
|
const { actions, action } = element.props;
|
|
89
131
|
const effective: ButtonAction[] =
|
|
90
132
|
actions ?? (action === "continue" ? ["continue"] : []);
|
|
@@ -95,7 +137,17 @@ export const ButtonElementComponent = ({ element, ctx }: Props): React.ReactElem
|
|
|
95
137
|
return;
|
|
96
138
|
}
|
|
97
139
|
if (act.type === "setVariable") {
|
|
98
|
-
|
|
140
|
+
let value: string;
|
|
141
|
+
let kind: ComposableVariableKind | undefined;
|
|
142
|
+
if (act.valueMode === "expression") {
|
|
143
|
+
const computed = evaluateSetVariableExpression(act.value, variables);
|
|
144
|
+
value = computed.value;
|
|
145
|
+
kind = computed.kind;
|
|
146
|
+
} else {
|
|
147
|
+
value = act.value;
|
|
148
|
+
kind = act.kind;
|
|
149
|
+
}
|
|
150
|
+
setVariable(act.name, { value, label: act.label, kind });
|
|
99
151
|
continue;
|
|
100
152
|
}
|
|
101
153
|
const handler = customActions[act.function];
|
|
@@ -122,14 +174,27 @@ export const ButtonElementComponent = ({ element, ctx }: Props): React.ReactElem
|
|
|
122
174
|
const variant = element.props.variant ?? "filled";
|
|
123
175
|
const isFilled = variant === "filled";
|
|
124
176
|
const isOutlined = variant === "outlined";
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
177
|
+
const disabledBg =
|
|
178
|
+
element.props.disabledBackgroundColor ?? theme.colors.disable;
|
|
179
|
+
const disabledText =
|
|
180
|
+
element.props.disabledColor ?? theme.colors.text.disable;
|
|
181
|
+
const bgColor = isDisabled
|
|
182
|
+
? isFilled
|
|
183
|
+
? disabledBg
|
|
184
|
+
: "transparent"
|
|
185
|
+
: isFilled
|
|
186
|
+
? (element.props.backgroundColor ?? theme.colors.primary)
|
|
187
|
+
: "transparent";
|
|
188
|
+
const textColor = isDisabled
|
|
189
|
+
? disabledText
|
|
190
|
+
: isFilled
|
|
191
|
+
? (element.props.color ?? theme.colors.text.opposite)
|
|
192
|
+
: (element.props.color ?? theme.colors.primary);
|
|
193
|
+
const outlinedBorderColor = isDisabled
|
|
194
|
+
? disabledBg
|
|
195
|
+
: (element.props.borderColor ?? theme.colors.primary);
|
|
196
|
+
|
|
197
|
+
const hasGradient = isFilled && !isDisabled && !!element.props.backgroundGradient;
|
|
133
198
|
const borderRadius = element.props.borderRadius ?? 90;
|
|
134
199
|
const inheritedFontFamily = resolveInheritedFontFamily(
|
|
135
200
|
element.props.fontFamily,
|
|
@@ -164,7 +229,7 @@ export const ButtonElementComponent = ({ element, ctx }: Props): React.ReactElem
|
|
|
164
229
|
style={{
|
|
165
230
|
borderRadius,
|
|
166
231
|
borderWidth: isOutlined ? (element.props.borderWidth ?? 1) : (element.props.borderWidth ?? 0),
|
|
167
|
-
borderColor: isOutlined ?
|
|
232
|
+
borderColor: isOutlined ? outlinedBorderColor : element.props.borderColor,
|
|
168
233
|
width: dim(element.props.width),
|
|
169
234
|
height: dim(element.props.height),
|
|
170
235
|
margin: element.props.margin,
|
|
@@ -178,6 +243,7 @@ export const ButtonElementComponent = ({ element, ctx }: Props): React.ReactElem
|
|
|
178
243
|
<TouchableOpacity
|
|
179
244
|
activeOpacity={0.8}
|
|
180
245
|
onPress={handlePress}
|
|
246
|
+
disabled={isDisabled}
|
|
181
247
|
style={{
|
|
182
248
|
flex: 1,
|
|
183
249
|
padding: element.props.padding,
|
|
@@ -197,11 +263,12 @@ export const ButtonElementComponent = ({ element, ctx }: Props): React.ReactElem
|
|
|
197
263
|
<TouchableOpacity
|
|
198
264
|
activeOpacity={0.8}
|
|
199
265
|
onPress={handlePress}
|
|
266
|
+
disabled={isDisabled}
|
|
200
267
|
style={{
|
|
201
268
|
backgroundColor: bgColor,
|
|
202
269
|
borderRadius,
|
|
203
270
|
borderWidth: isOutlined ? (element.props.borderWidth ?? 1) : (element.props.borderWidth ?? 0),
|
|
204
|
-
borderColor: isOutlined ?
|
|
271
|
+
borderColor: isOutlined ? outlinedBorderColor : element.props.borderColor,
|
|
205
272
|
padding: element.props.padding,
|
|
206
273
|
paddingVertical: element.props.paddingVertical ?? 14,
|
|
207
274
|
paddingHorizontal: element.props.paddingHorizontal ?? 24,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useRef, useState } from "react";
|
|
1
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
2
2
|
import { View, type LayoutChangeEvent } from "react-native";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { useSharedValue } from "react-native-reanimated";
|
|
@@ -20,6 +20,8 @@ export type CarouselElementProps = BaseBoxProps & {
|
|
|
20
20
|
dotHeight?: number;
|
|
21
21
|
dotsGap?: number;
|
|
22
22
|
dotsMarginTop?: number;
|
|
23
|
+
defaultIndex?: number | null;
|
|
24
|
+
variableName?: string;
|
|
23
25
|
};
|
|
24
26
|
|
|
25
27
|
export const CarouselElementPropsSchema = BaseBoxPropsSchema.extend({
|
|
@@ -34,6 +36,8 @@ export const CarouselElementPropsSchema = BaseBoxPropsSchema.extend({
|
|
|
34
36
|
dotHeight: z.number().nonnegative().optional().default(4),
|
|
35
37
|
dotsGap: z.number().nonnegative().optional().default(8),
|
|
36
38
|
dotsMarginTop: z.number().optional().default(12),
|
|
39
|
+
defaultIndex: z.number().int().nonnegative().nullable().optional(),
|
|
40
|
+
variableName: z.string().min(1).optional(),
|
|
37
41
|
});
|
|
38
42
|
|
|
39
43
|
type CarouselUIElement = Extract<UIElement, { type: "Carousel" }>;
|
|
@@ -54,6 +58,30 @@ export function CarouselElementComponent({ element, ctx }: Props): React.ReactEl
|
|
|
54
58
|
|
|
55
59
|
const carouselType = props.carouselType ?? "normal";
|
|
56
60
|
|
|
61
|
+
const variableName = props.variableName;
|
|
62
|
+
const variableValue = variableName ? ctx.variables[variableName]?.value : undefined;
|
|
63
|
+
const childrenCount = children.length;
|
|
64
|
+
const clampIndex = (n: number) => Math.max(0, Math.min(n, Math.max(0, childrenCount - 1)));
|
|
65
|
+
|
|
66
|
+
// Frozen on first mount — RNRC `defaultIndex` only applies at mount.
|
|
67
|
+
const initialIndexRef = useRef<number | null>(null);
|
|
68
|
+
if (initialIndexRef.current === null) {
|
|
69
|
+
const parsed = variableValue !== undefined ? parseInt(variableValue, 10) : NaN;
|
|
70
|
+
const fromVar = Number.isFinite(parsed) ? parsed : null;
|
|
71
|
+
initialIndexRef.current = clampIndex(fromVar ?? props.defaultIndex ?? 0);
|
|
72
|
+
}
|
|
73
|
+
const lastSyncedIndexRef = useRef<number>(initialIndexRef.current);
|
|
74
|
+
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (!variableName) return;
|
|
77
|
+
const parsed = parseInt(variableValue ?? "", 10);
|
|
78
|
+
if (!Number.isFinite(parsed)) return;
|
|
79
|
+
const target = clampIndex(parsed);
|
|
80
|
+
if (target === lastSyncedIndexRef.current) return;
|
|
81
|
+
lastSyncedIndexRef.current = target;
|
|
82
|
+
ref.current?.scrollTo({ count: target - progress.value, animated: true });
|
|
83
|
+
}, [variableName, variableValue, childrenCount]);
|
|
84
|
+
|
|
57
85
|
const onLayout = (e: LayoutChangeEvent) => {
|
|
58
86
|
const { width, height } = e.nativeEvent.layout;
|
|
59
87
|
if (!size || size.width !== width || size.height !== height) {
|
|
@@ -132,6 +160,7 @@ export function CarouselElementComponent({ element, ctx }: Props): React.ReactEl
|
|
|
132
160
|
loop={props.loop}
|
|
133
161
|
autoPlay={props.autoPlay}
|
|
134
162
|
autoPlayInterval={props.autoPlayInterval}
|
|
163
|
+
defaultIndex={initialIndexRef.current ?? 0}
|
|
135
164
|
snapEnabled={true}
|
|
136
165
|
pagingEnabled={true}
|
|
137
166
|
data={children}
|
|
@@ -142,6 +171,12 @@ export function CarouselElementComponent({ element, ctx }: Props): React.ReactEl
|
|
|
142
171
|
onProgressChange={(_: number, absoluteProgress: number) => {
|
|
143
172
|
progress.value = absoluteProgress;
|
|
144
173
|
}}
|
|
174
|
+
onSnapToItem={(index: number) => {
|
|
175
|
+
if (!variableName) return;
|
|
176
|
+
if (index === lastSyncedIndexRef.current) return;
|
|
177
|
+
lastSyncedIndexRef.current = index;
|
|
178
|
+
ctx.setVariable(variableName, { value: String(index) });
|
|
179
|
+
}}
|
|
145
180
|
{...(modeProps as any)}
|
|
146
181
|
/>
|
|
147
182
|
)}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import type { ComposableVariableEntry, ComposableVariableKind } from "@rocapine/react-native-onboarding";
|
|
2
|
+
import { interpolate } from "./shared";
|
|
3
|
+
|
|
4
|
+
type Token =
|
|
5
|
+
| { kind: "num"; value: number; isInt: boolean }
|
|
6
|
+
| { kind: "var"; name: string }
|
|
7
|
+
| { kind: "op"; op: "+" | "-" | "*" | "/" }
|
|
8
|
+
| { kind: "lparen" }
|
|
9
|
+
| { kind: "rparen" }
|
|
10
|
+
| { kind: "eof" };
|
|
11
|
+
|
|
12
|
+
type Value =
|
|
13
|
+
| { kind: "number"; n: number; isInt: boolean }
|
|
14
|
+
| { kind: "string"; s: string };
|
|
15
|
+
|
|
16
|
+
const isDigit = (c: string) => c >= "0" && c <= "9";
|
|
17
|
+
const isSpace = (c: string) => c === " " || c === "\t" || c === "\n" || c === "\r";
|
|
18
|
+
|
|
19
|
+
function tokenize(input: string): Token[] | null {
|
|
20
|
+
const tokens: Token[] = [];
|
|
21
|
+
let i = 0;
|
|
22
|
+
while (i < input.length) {
|
|
23
|
+
const c = input[i];
|
|
24
|
+
if (isSpace(c)) {
|
|
25
|
+
i++;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (c === "{" && input[i + 1] === "{") {
|
|
29
|
+
const end = input.indexOf("}}", i + 2);
|
|
30
|
+
if (end === -1) return null;
|
|
31
|
+
const name = input.slice(i + 2, end).trim();
|
|
32
|
+
if (!name) return null;
|
|
33
|
+
tokens.push({ kind: "var", name });
|
|
34
|
+
i = end + 2;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (c === "(") { tokens.push({ kind: "lparen" }); i++; continue; }
|
|
38
|
+
if (c === ")") { tokens.push({ kind: "rparen" }); i++; continue; }
|
|
39
|
+
if (c === "+" || c === "-" || c === "*" || c === "/") {
|
|
40
|
+
tokens.push({ kind: "op", op: c });
|
|
41
|
+
i++;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (isDigit(c) || (c === "." && isDigit(input[i + 1] ?? ""))) {
|
|
45
|
+
let j = i;
|
|
46
|
+
let dot = false;
|
|
47
|
+
while (j < input.length && (isDigit(input[j]) || input[j] === ".")) {
|
|
48
|
+
if (input[j] === ".") {
|
|
49
|
+
if (dot) return null;
|
|
50
|
+
dot = true;
|
|
51
|
+
}
|
|
52
|
+
j++;
|
|
53
|
+
}
|
|
54
|
+
const num = parseFloat(input.slice(i, j));
|
|
55
|
+
if (!Number.isFinite(num)) return null;
|
|
56
|
+
tokens.push({ kind: "num", value: num, isInt: !dot });
|
|
57
|
+
i = j;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
tokens.push({ kind: "eof" });
|
|
63
|
+
return tokens;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function resolveVar(name: string, vars: Record<string, ComposableVariableEntry>): Value {
|
|
67
|
+
const entry = vars[name];
|
|
68
|
+
// Missing variable in arithmetic context defaults to numeric 0 so increment
|
|
69
|
+
// / decrement patterns work on first click before the variable is seeded.
|
|
70
|
+
if (!entry) return { kind: "number", n: 0, isInt: true };
|
|
71
|
+
const raw = entry.value;
|
|
72
|
+
const k = entry.kind;
|
|
73
|
+
if (k === "string") return { kind: "string", s: raw };
|
|
74
|
+
if (k === "int") {
|
|
75
|
+
const n = parseInt(raw, 10);
|
|
76
|
+
return Number.isFinite(n) ? { kind: "number", n, isInt: true } : { kind: "string", s: raw };
|
|
77
|
+
}
|
|
78
|
+
if (k === "float") {
|
|
79
|
+
const n = parseFloat(raw);
|
|
80
|
+
return Number.isFinite(n) ? { kind: "number", n, isInt: false } : { kind: "string", s: raw };
|
|
81
|
+
}
|
|
82
|
+
// No kind tag — infer from string content.
|
|
83
|
+
const trimmed = raw.trim();
|
|
84
|
+
if (trimmed !== "" && /^-?\d+(\.\d+)?$/.test(trimmed)) {
|
|
85
|
+
const n = parseFloat(trimmed);
|
|
86
|
+
if (Number.isFinite(n)) return { kind: "number", n, isInt: Number.isInteger(n) && !trimmed.includes(".") };
|
|
87
|
+
}
|
|
88
|
+
return { kind: "string", s: raw };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function valueToString(v: Value): string {
|
|
92
|
+
if (v.kind === "string") return v.s;
|
|
93
|
+
if (v.isInt) return Math.trunc(v.n).toString();
|
|
94
|
+
return v.n.toString();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function parse(tokens: Token[], vars: Record<string, ComposableVariableEntry>): Value | null {
|
|
98
|
+
let pos = 0;
|
|
99
|
+
const peek = () => tokens[pos];
|
|
100
|
+
const advance = () => tokens[pos++];
|
|
101
|
+
|
|
102
|
+
const factor = (): Value | null => {
|
|
103
|
+
const t = peek();
|
|
104
|
+
if (t.kind === "lparen") {
|
|
105
|
+
advance();
|
|
106
|
+
const v = expr();
|
|
107
|
+
if (!v) return null;
|
|
108
|
+
if (peek().kind !== "rparen") return null;
|
|
109
|
+
advance();
|
|
110
|
+
return v;
|
|
111
|
+
}
|
|
112
|
+
if (t.kind === "op" && t.op === "-") {
|
|
113
|
+
advance();
|
|
114
|
+
const v = factor();
|
|
115
|
+
if (!v || v.kind !== "number") return null;
|
|
116
|
+
return { kind: "number", n: -v.n, isInt: v.isInt };
|
|
117
|
+
}
|
|
118
|
+
if (t.kind === "num") {
|
|
119
|
+
advance();
|
|
120
|
+
return { kind: "number", n: t.value, isInt: t.isInt };
|
|
121
|
+
}
|
|
122
|
+
if (t.kind === "var") {
|
|
123
|
+
advance();
|
|
124
|
+
return resolveVar(t.name, vars);
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const term = (): Value | null => {
|
|
130
|
+
let left = factor();
|
|
131
|
+
if (!left) return null;
|
|
132
|
+
while (peek().kind === "op" && ((peek() as any).op === "*" || (peek() as any).op === "/")) {
|
|
133
|
+
const op = (advance() as any).op as "*" | "/";
|
|
134
|
+
const right = factor();
|
|
135
|
+
if (!right) return null;
|
|
136
|
+
if (left.kind !== "number" || right.kind !== "number") return null;
|
|
137
|
+
if (op === "/" && right.n === 0) return null;
|
|
138
|
+
const result: number = op === "*" ? left.n * right.n : left.n / right.n;
|
|
139
|
+
if (!Number.isFinite(result)) return null;
|
|
140
|
+
const isInt: boolean = op === "*" ? left.isInt && right.isInt : Number.isInteger(result);
|
|
141
|
+
left = { kind: "number", n: result, isInt };
|
|
142
|
+
}
|
|
143
|
+
return left;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const expr = (): Value | null => {
|
|
147
|
+
let left = term();
|
|
148
|
+
if (!left) return null;
|
|
149
|
+
while (peek().kind === "op" && ((peek() as any).op === "+" || (peek() as any).op === "-")) {
|
|
150
|
+
const op = (advance() as any).op as "+" | "-";
|
|
151
|
+
const right = term();
|
|
152
|
+
if (!right) return null;
|
|
153
|
+
if (op === "+") {
|
|
154
|
+
if (left.kind === "number" && right.kind === "number") {
|
|
155
|
+
left = { kind: "number", n: left.n + right.n, isInt: left.isInt && right.isInt };
|
|
156
|
+
} else {
|
|
157
|
+
left = { kind: "string", s: valueToString(left) + valueToString(right) };
|
|
158
|
+
}
|
|
159
|
+
} else {
|
|
160
|
+
if (left.kind !== "number" || right.kind !== "number") return null;
|
|
161
|
+
left = { kind: "number", n: left.n - right.n, isInt: left.isInt && right.isInt };
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return left;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const result = expr();
|
|
168
|
+
if (!result) return null;
|
|
169
|
+
if (peek().kind !== "eof") return null;
|
|
170
|
+
return result;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Evaluate a `setVariable` expression-mode value template.
|
|
175
|
+
*
|
|
176
|
+
* Accepts `{{var}}` references, numeric literals (int / float), `+ - * /` and
|
|
177
|
+
* parentheses. Variable values are coerced according to their `kind` tag
|
|
178
|
+
* (string / int / float), or inferred from their string content when no tag
|
|
179
|
+
* is present. `+` on any non-numeric operand becomes string concat.
|
|
180
|
+
*
|
|
181
|
+
* On any parse or evaluation failure, falls back to plain interpolation
|
|
182
|
+
* (existing `interpolate()` semantics, returns a string).
|
|
183
|
+
*/
|
|
184
|
+
export function evaluateSetVariableExpression(
|
|
185
|
+
template: string,
|
|
186
|
+
vars: Record<string, ComposableVariableEntry>
|
|
187
|
+
): { value: string; kind: ComposableVariableKind } {
|
|
188
|
+
const tokens = tokenize(template);
|
|
189
|
+
if (tokens) {
|
|
190
|
+
const result = parse(tokens, vars);
|
|
191
|
+
if (result) {
|
|
192
|
+
if (result.kind === "number") {
|
|
193
|
+
return { value: valueToString(result), kind: result.isInt ? "int" : "float" };
|
|
194
|
+
}
|
|
195
|
+
return { value: result.s, kind: "string" };
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return { value: interpolate(template, vars), kind: "string" };
|
|
199
|
+
}
|