@rocapine/react-native-onboarding 1.25.1 → 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.
Files changed (52) hide show
  1. package/dist/evaluateCondition.d.ts.map +1 -1
  2. package/dist/evaluateCondition.js +44 -1
  3. package/dist/evaluateCondition.js.map +1 -1
  4. package/dist/index.d.ts +3 -3
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +6 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/onboarding-example.d.ts +2215 -1976
  9. package/dist/onboarding-example.d.ts.map +1 -1
  10. package/dist/onboarding-example.js +592 -545
  11. package/dist/onboarding-example.js.map +1 -1
  12. package/dist/steps/Carousel/types.d.ts +5 -1
  13. package/dist/steps/Carousel/types.d.ts.map +1 -1
  14. package/dist/steps/Commitment/types.d.ts +5 -1
  15. package/dist/steps/Commitment/types.d.ts.map +1 -1
  16. package/dist/steps/ComposableScreen/elements/ButtonElement.d.ts +5 -1
  17. package/dist/steps/ComposableScreen/elements/ButtonElement.d.ts.map +1 -1
  18. package/dist/steps/ComposableScreen/elements/IconElement.d.ts +4 -0
  19. package/dist/steps/ComposableScreen/elements/IconElement.d.ts.map +1 -1
  20. package/dist/steps/ComposableScreen/elements/IconElement.js +2 -0
  21. package/dist/steps/ComposableScreen/elements/IconElement.js.map +1 -1
  22. package/dist/steps/ComposableScreen/elements/WheelPickerElement.d.ts +124 -0
  23. package/dist/steps/ComposableScreen/elements/WheelPickerElement.d.ts.map +1 -0
  24. package/dist/steps/ComposableScreen/elements/WheelPickerElement.js +96 -0
  25. package/dist/steps/ComposableScreen/elements/WheelPickerElement.js.map +1 -0
  26. package/dist/steps/ComposableScreen/types.d.ts +14 -1
  27. package/dist/steps/ComposableScreen/types.d.ts.map +1 -1
  28. package/dist/steps/ComposableScreen/types.js +13 -1
  29. package/dist/steps/ComposableScreen/types.js.map +1 -1
  30. package/dist/steps/Loader/types.d.ts +5 -1
  31. package/dist/steps/Loader/types.d.ts.map +1 -1
  32. package/dist/steps/MediaContent/types.d.ts +5 -1
  33. package/dist/steps/MediaContent/types.d.ts.map +1 -1
  34. package/dist/steps/Picker/types.d.ts +5 -1
  35. package/dist/steps/Picker/types.d.ts.map +1 -1
  36. package/dist/steps/Question/types.d.ts +5 -1
  37. package/dist/steps/Question/types.d.ts.map +1 -1
  38. package/dist/steps/Ratings/types.d.ts +5 -1
  39. package/dist/steps/Ratings/types.d.ts.map +1 -1
  40. package/dist/steps/common.types.d.ts +30 -4
  41. package/dist/steps/common.types.d.ts.map +1 -1
  42. package/dist/steps/common.types.js +33 -3
  43. package/dist/steps/common.types.js.map +1 -1
  44. package/package.json +2 -2
  45. package/src/__tests__/evaluateCondition.test.ts +35 -0
  46. package/src/evaluateCondition.ts +41 -1
  47. package/src/index.ts +8 -0
  48. package/src/onboarding-example.ts +47 -0
  49. package/src/steps/ComposableScreen/elements/IconElement.ts +4 -0
  50. package/src/steps/ComposableScreen/elements/WheelPickerElement.ts +115 -0
  51. package/src/steps/ComposableScreen/types.ts +17 -0
  52. 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.object({
56
- variable: z.string().min(1),
57
- operator: ConditionOperatorSchema,
58
- value: ConditionValueSchema,
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 = {