@rocapine/react-native-onboarding 1.26.0 → 1.27.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/evaluateCondition.d.ts.map +1 -1
- package/dist/evaluateCondition.js +44 -1
- package/dist/evaluateCondition.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/onboarding-example.d.ts +282 -111
- package/dist/onboarding-example.d.ts.map +1 -1
- package/dist/onboarding-example.js +38 -0
- package/dist/onboarding-example.js.map +1 -1
- package/dist/steps/Carousel/types.d.ts +5 -1
- package/dist/steps/Carousel/types.d.ts.map +1 -1
- package/dist/steps/Commitment/types.d.ts +5 -1
- package/dist/steps/Commitment/types.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/ButtonElement.d.ts +5 -1
- package/dist/steps/ComposableScreen/elements/ButtonElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/WheelPickerElement.d.ts +124 -0
- package/dist/steps/ComposableScreen/elements/WheelPickerElement.d.ts.map +1 -0
- package/dist/steps/ComposableScreen/elements/WheelPickerElement.js +96 -0
- package/dist/steps/ComposableScreen/elements/WheelPickerElement.js.map +1 -0
- package/dist/steps/ComposableScreen/types.d.ts +14 -1
- package/dist/steps/ComposableScreen/types.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/types.js +13 -1
- package/dist/steps/ComposableScreen/types.js.map +1 -1
- package/dist/steps/Loader/types.d.ts +5 -1
- package/dist/steps/Loader/types.d.ts.map +1 -1
- package/dist/steps/MediaContent/types.d.ts +5 -1
- package/dist/steps/MediaContent/types.d.ts.map +1 -1
- package/dist/steps/Picker/types.d.ts +5 -1
- package/dist/steps/Picker/types.d.ts.map +1 -1
- package/dist/steps/Question/types.d.ts +5 -1
- package/dist/steps/Question/types.d.ts.map +1 -1
- package/dist/steps/Ratings/types.d.ts +5 -1
- package/dist/steps/Ratings/types.d.ts.map +1 -1
- package/dist/steps/common.types.d.ts +30 -4
- package/dist/steps/common.types.d.ts.map +1 -1
- package/dist/steps/common.types.js +33 -3
- package/dist/steps/common.types.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/evaluateCondition.test.ts +35 -0
- package/src/evaluateCondition.ts +41 -1
- package/src/index.ts +8 -0
- package/src/onboarding-example.ts +38 -0
- package/src/steps/ComposableScreen/elements/WheelPickerElement.ts +115 -0
- package/src/steps/ComposableScreen/types.ts +17 -0
- package/src/steps/common.types.ts +38 -5
|
@@ -41,9 +41,32 @@ export const ConditionOperatorSchema = z.enum([
|
|
|
41
41
|
"contains",
|
|
42
42
|
"in",
|
|
43
43
|
"not_in",
|
|
44
|
+
// Unary presence operators — no `value` required. `empty` is type-aware
|
|
45
|
+
// (empty string / empty array / null|undefined); `null` is strictly
|
|
46
|
+
// null|undefined (a set-but-empty value is "not null" yet "is empty").
|
|
47
|
+
"is_empty",
|
|
48
|
+
"is_not_empty",
|
|
49
|
+
"is_null",
|
|
50
|
+
"is_not_null",
|
|
44
51
|
]);
|
|
45
52
|
export type ConditionOperator = z.infer<typeof ConditionOperatorSchema>;
|
|
46
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Operators that test the variable alone and ignore `value`. A LeafCondition
|
|
56
|
+
* using one of these may omit `value`; all other operators require it.
|
|
57
|
+
*/
|
|
58
|
+
export const UNARY_CONDITION_OPERATORS = [
|
|
59
|
+
"is_empty",
|
|
60
|
+
"is_not_empty",
|
|
61
|
+
"is_null",
|
|
62
|
+
"is_not_null",
|
|
63
|
+
] as const satisfies readonly ConditionOperator[];
|
|
64
|
+
|
|
65
|
+
const UNARY_OPERATOR_SET = new Set<ConditionOperator>(UNARY_CONDITION_OPERATORS);
|
|
66
|
+
|
|
67
|
+
export const isUnaryConditionOperator = (operator: ConditionOperator): boolean =>
|
|
68
|
+
UNARY_OPERATOR_SET.has(operator);
|
|
69
|
+
|
|
47
70
|
export const ConditionValueSchema = z.union([
|
|
48
71
|
z.string(),
|
|
49
72
|
z.number(),
|
|
@@ -52,11 +75,21 @@ export const ConditionValueSchema = z.union([
|
|
|
52
75
|
]);
|
|
53
76
|
export type ConditionValue = z.infer<typeof ConditionValueSchema>;
|
|
54
77
|
|
|
55
|
-
export const LeafConditionSchema = z
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
78
|
+
export const LeafConditionSchema = z
|
|
79
|
+
.object({
|
|
80
|
+
variable: z.string().min(1),
|
|
81
|
+
operator: ConditionOperatorSchema,
|
|
82
|
+
value: ConditionValueSchema.optional(),
|
|
83
|
+
})
|
|
84
|
+
.superRefine((data, ctx) => {
|
|
85
|
+
if (!isUnaryConditionOperator(data.operator) && data.value === undefined) {
|
|
86
|
+
ctx.addIssue({
|
|
87
|
+
code: z.ZodIssueCode.custom,
|
|
88
|
+
message: `operator "${data.operator}" requires a value`,
|
|
89
|
+
path: ["value"],
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
60
93
|
export type LeafCondition = z.infer<typeof LeafConditionSchema>;
|
|
61
94
|
|
|
62
95
|
export type ConditionGroup = {
|