@rocapine/react-native-onboarding 1.15.0 → 1.17.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 (80) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +4 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/infra/fonts/FontRegistryContext.d.ts +16 -0
  6. package/dist/infra/fonts/FontRegistryContext.d.ts.map +1 -0
  7. package/dist/infra/fonts/FontRegistryContext.js +35 -0
  8. package/dist/infra/fonts/FontRegistryContext.js.map +1 -0
  9. package/dist/infra/fonts/index.d.ts +3 -0
  10. package/dist/infra/fonts/index.d.ts.map +1 -0
  11. package/dist/infra/fonts/index.js +13 -0
  12. package/dist/infra/fonts/index.js.map +1 -0
  13. package/dist/infra/fonts/registry.d.ts +6 -0
  14. package/dist/infra/fonts/registry.d.ts.map +1 -0
  15. package/dist/infra/fonts/registry.js +96 -0
  16. package/dist/infra/fonts/registry.js.map +1 -0
  17. package/dist/infra/index.d.ts +1 -0
  18. package/dist/infra/index.d.ts.map +1 -1
  19. package/dist/infra/index.js +1 -0
  20. package/dist/infra/index.js.map +1 -1
  21. package/dist/infra/provider/FontLoader.d.ts +9 -0
  22. package/dist/infra/provider/FontLoader.d.ts.map +1 -0
  23. package/dist/infra/provider/FontLoader.js +38 -0
  24. package/dist/infra/provider/FontLoader.js.map +1 -0
  25. package/dist/infra/provider/OnboardingProvider.d.ts +20 -1
  26. package/dist/infra/provider/OnboardingProvider.d.ts.map +1 -1
  27. package/dist/infra/provider/OnboardingProvider.js +13 -3
  28. package/dist/infra/provider/OnboardingProvider.js.map +1 -1
  29. package/dist/infra/provider/index.d.ts +2 -0
  30. package/dist/infra/provider/index.d.ts.map +1 -1
  31. package/dist/infra/provider/index.js +3 -1
  32. package/dist/infra/provider/index.js.map +1 -1
  33. package/dist/onboarding-example.d.ts +100 -0
  34. package/dist/onboarding-example.d.ts.map +1 -1
  35. package/dist/onboarding-example.js +27 -1
  36. package/dist/onboarding-example.js.map +1 -1
  37. package/dist/steps/ComposableScreen/elements/ButtonElement.d.ts +35 -0
  38. package/dist/steps/ComposableScreen/elements/ButtonElement.d.ts.map +1 -1
  39. package/dist/steps/ComposableScreen/elements/ButtonElement.js +12 -1
  40. package/dist/steps/ComposableScreen/elements/ButtonElement.js.map +1 -1
  41. package/dist/steps/ComposableScreen/elements/CarouselElement.d.ts +1 -1
  42. package/dist/steps/ComposableScreen/elements/CheckboxGroupElement.d.ts +5 -0
  43. package/dist/steps/ComposableScreen/elements/CheckboxGroupElement.d.ts.map +1 -1
  44. package/dist/steps/ComposableScreen/elements/CheckboxGroupElement.js +1 -0
  45. package/dist/steps/ComposableScreen/elements/CheckboxGroupElement.js.map +1 -1
  46. package/dist/steps/ComposableScreen/elements/InputElement.d.ts +5 -0
  47. package/dist/steps/ComposableScreen/elements/InputElement.d.ts.map +1 -1
  48. package/dist/steps/ComposableScreen/elements/InputElement.js +1 -0
  49. package/dist/steps/ComposableScreen/elements/InputElement.js.map +1 -1
  50. package/dist/steps/ComposableScreen/elements/RadioGroupElement.d.ts +5 -0
  51. package/dist/steps/ComposableScreen/elements/RadioGroupElement.d.ts.map +1 -1
  52. package/dist/steps/ComposableScreen/elements/RadioGroupElement.js +1 -0
  53. package/dist/steps/ComposableScreen/elements/RadioGroupElement.js.map +1 -1
  54. package/dist/steps/ComposableScreen/elements/TextElement.d.ts +5 -0
  55. package/dist/steps/ComposableScreen/elements/TextElement.d.ts.map +1 -1
  56. package/dist/steps/ComposableScreen/elements/TextElement.js +1 -0
  57. package/dist/steps/ComposableScreen/elements/TextElement.js.map +1 -1
  58. package/dist/steps/ComposableScreen/types.d.ts +10 -1
  59. package/dist/steps/ComposableScreen/types.d.ts.map +1 -1
  60. package/dist/steps/ComposableScreen/types.js +4 -1
  61. package/dist/steps/ComposableScreen/types.js.map +1 -1
  62. package/dist/types.d.ts +4 -0
  63. package/dist/types.d.ts.map +1 -1
  64. package/package.json +7 -1
  65. package/src/index.ts +10 -0
  66. package/src/infra/fonts/FontRegistryContext.tsx +45 -0
  67. package/src/infra/fonts/index.ts +12 -0
  68. package/src/infra/fonts/registry.ts +104 -0
  69. package/src/infra/index.ts +1 -0
  70. package/src/infra/provider/FontLoader.tsx +40 -0
  71. package/src/infra/provider/OnboardingProvider.tsx +68 -6
  72. package/src/infra/provider/index.ts +5 -0
  73. package/src/onboarding-example.ts +27 -1
  74. package/src/steps/ComposableScreen/elements/ButtonElement.ts +31 -0
  75. package/src/steps/ComposableScreen/elements/CheckboxGroupElement.ts +2 -0
  76. package/src/steps/ComposableScreen/elements/InputElement.ts +2 -0
  77. package/src/steps/ComposableScreen/elements/RadioGroupElement.ts +2 -0
  78. package/src/steps/ComposableScreen/elements/TextElement.ts +2 -0
  79. package/src/steps/ComposableScreen/types.ts +8 -1
  80. package/src/types.ts +21 -0
@@ -9,6 +9,16 @@ export const onboardingExample = {
9
9
  audienceOrder: undefined,
10
10
  draft: true,
11
11
  },
12
+ fonts: {
13
+ Inter: {
14
+ regular: "https://cdn.jsdelivr.net/fontsource/fonts/inter@latest/latin-400-normal.ttf",
15
+ medium: "https://cdn.jsdelivr.net/fontsource/fonts/inter@latest/latin-500-normal.ttf",
16
+ bold: "https://cdn.jsdelivr.net/fontsource/fonts/inter@latest/latin-700-normal.ttf",
17
+ },
18
+ Lobster: {
19
+ regular: "https://cdn.jsdelivr.net/fontsource/fonts/lobster@latest/latin-400-normal.ttf",
20
+ },
21
+ },
12
22
  steps: [
13
23
  {
14
24
  id: "welcome",
@@ -188,10 +198,22 @@ export const onboardingExample = {
188
198
  content: "Built from the CMS",
189
199
  fontSize: 28,
190
200
  fontWeight: "700",
191
- fontFamily: "System",
201
+ fontFamily: "Inter",
192
202
  textAlign: "center",
193
203
  },
194
204
  },
205
+ {
206
+ id: "headline-display",
207
+ type: "Text",
208
+ props: {
209
+ content: "Runtime-loaded font",
210
+ fontSize: 32,
211
+ fontFamily: "Lobster",
212
+ fontStyle: "italic",
213
+ textAlign: "center",
214
+ marginVertical: 4,
215
+ },
216
+ },
195
217
  {
196
218
  id: "subheadline",
197
219
  type: "Text",
@@ -376,6 +398,10 @@ export const onboardingExample = {
376
398
  label: "Get Started",
377
399
  variant: "filled",
378
400
  marginVertical: 8,
401
+ actions: [
402
+ { type: "custom", function: "trackCta", variables: ["name", "plan", "goals"] },
403
+ "continue",
404
+ ],
379
405
  },
380
406
  },
381
407
  {
@@ -1,8 +1,36 @@
1
1
  import { z } from "zod";
2
2
  import { BaseBoxProps, BaseBoxPropsSchema } from "./BaseBoxProps";
3
3
 
4
+ export type CustomButtonAction = {
5
+ type: "custom";
6
+ function: string;
7
+ variables?: string[];
8
+ };
9
+
10
+ export const CustomButtonActionSchema = z.object({
11
+ type: z.literal("custom"),
12
+ function: z.string().min(1, "function must not be empty"),
13
+ variables: z.array(z.string()).optional(),
14
+ });
15
+
16
+ export type ButtonAction = "continue" | CustomButtonAction;
17
+
18
+ export const ButtonActionSchema = z.union([
19
+ z.literal("continue"),
20
+ CustomButtonActionSchema,
21
+ ]);
22
+
4
23
  export type ButtonElementProps = BaseBoxProps & {
5
24
  label: string;
25
+ /**
26
+ * Ordered list of actions to run on press. Sequential, await async handlers,
27
+ * abort on error, `"continue"` is terminal.
28
+ */
29
+ actions?: ButtonAction[];
30
+ /**
31
+ * @deprecated Use `actions` instead. When `actions` is absent and `action === "continue"`,
32
+ * runtime treats it as `actions: ["continue"]`.
33
+ */
6
34
  action?: "continue";
7
35
  variant?: "filled" | "outlined" | "ghost";
8
36
  backgroundColor?: string;
@@ -10,11 +38,13 @@ export type ButtonElementProps = BaseBoxProps & {
10
38
  fontSize?: number;
11
39
  fontWeight?: string;
12
40
  fontFamily?: string;
41
+ fontStyle?: "normal" | "italic";
13
42
  textAlign?: "left" | "center" | "right";
14
43
  };
15
44
 
16
45
  export const ButtonElementPropsSchema = BaseBoxPropsSchema.extend({
17
46
  label: z.string().min(1, "label must not be empty"),
47
+ actions: z.array(ButtonActionSchema).optional(),
18
48
  action: z.enum(["continue"]).optional(),
19
49
  variant: z.enum(["filled", "outlined", "ghost"]).optional(),
20
50
  backgroundColor: z.string().optional(),
@@ -22,5 +52,6 @@ export const ButtonElementPropsSchema = BaseBoxPropsSchema.extend({
22
52
  fontSize: z.number().optional(),
23
53
  fontWeight: z.string().optional(),
24
54
  fontFamily: z.string().optional(),
55
+ fontStyle: z.enum(["normal", "italic"]).optional(),
25
56
  textAlign: z.enum(["left", "center", "right"]).optional(),
26
57
  });
@@ -18,6 +18,7 @@ export type CheckboxGroupElementProps = BaseBoxProps & {
18
18
  itemFontSize?: number;
19
19
  itemFontWeight?: string;
20
20
  itemFontFamily?: string;
21
+ itemFontStyle?: "normal" | "italic";
21
22
  itemPadding?: number;
22
23
  itemPaddingHorizontal?: number;
23
24
  itemPaddingVertical?: number;
@@ -40,6 +41,7 @@ export const CheckboxGroupElementPropsSchema = BaseBoxPropsSchema.extend({
40
41
  itemFontSize: z.number().optional(),
41
42
  itemFontWeight: z.string().optional(),
42
43
  itemFontFamily: z.string().optional(),
44
+ itemFontStyle: z.enum(["normal", "italic"]).optional(),
43
45
  itemPadding: z.number().optional(),
44
46
  itemPaddingHorizontal: z.number().optional(),
45
47
  itemPaddingVertical: z.number().optional(),
@@ -18,6 +18,7 @@ export type InputElementProps = BaseBoxProps & {
18
18
  fontSize?: number;
19
19
  fontWeight?: string;
20
20
  fontFamily?: string;
21
+ fontStyle?: "normal" | "italic";
21
22
  lineHeight?: number;
22
23
  letterSpacing?: number;
23
24
  textAlign?: "left" | "center" | "right";
@@ -41,6 +42,7 @@ export const InputElementPropsSchema = BaseBoxPropsSchema.extend({
41
42
  fontSize: z.number().optional(),
42
43
  fontWeight: z.string().optional(),
43
44
  fontFamily: z.string().optional(),
45
+ fontStyle: z.enum(["normal", "italic"]).optional(),
44
46
  lineHeight: z.number().optional(),
45
47
  letterSpacing: z.number().optional(),
46
48
  textAlign: z.enum(["left", "center", "right"]).optional(),
@@ -18,6 +18,7 @@ export type RadioGroupElementProps = BaseBoxProps & {
18
18
  itemFontSize?: number;
19
19
  itemFontWeight?: string;
20
20
  itemFontFamily?: string;
21
+ itemFontStyle?: "normal" | "italic";
21
22
  itemPadding?: number;
22
23
  itemPaddingHorizontal?: number;
23
24
  itemPaddingVertical?: number;
@@ -40,6 +41,7 @@ export const RadioGroupElementPropsSchema = BaseBoxPropsSchema.extend({
40
41
  itemFontSize: z.number().optional(),
41
42
  itemFontWeight: z.string().optional(),
42
43
  itemFontFamily: z.string().optional(),
44
+ itemFontStyle: z.enum(["normal", "italic"]).optional(),
43
45
  itemPadding: z.number().optional(),
44
46
  itemPaddingHorizontal: z.number().optional(),
45
47
  itemPaddingVertical: z.number().optional(),
@@ -7,6 +7,7 @@ export type TextElementProps = BaseBoxProps & {
7
7
  fontSize?: number;
8
8
  fontWeight?: string;
9
9
  fontFamily?: string;
10
+ fontStyle?: "normal" | "italic";
10
11
  color?: string;
11
12
  textAlign?: "left" | "center" | "right";
12
13
  letterSpacing?: number;
@@ -19,6 +20,7 @@ export const TextElementPropsSchema = BaseBoxPropsSchema.extend({
19
20
  fontSize: z.number().optional(),
20
21
  fontWeight: z.string().optional(),
21
22
  fontFamily: z.string().optional(),
23
+ fontStyle: z.enum(["normal", "italic"]).optional(),
22
24
  color: z.string().optional(),
23
25
  textAlign: z.enum(["left", "center", "right"]).optional(),
24
26
  letterSpacing: z.number().optional(),
@@ -26,7 +26,8 @@ export type { RiveElementProps } from "./elements/RiveElement";
26
26
  export type { IconElementProps } from "./elements/IconElement";
27
27
  export type { VideoElementProps } from "./elements/VideoElement";
28
28
  export type { InputElementProps } from "./elements/InputElement";
29
- export type { ButtonElementProps } from "./elements/ButtonElement";
29
+ export type { ButtonElementProps, ButtonAction, CustomButtonAction } from "./elements/ButtonElement";
30
+ export { ButtonActionSchema, CustomButtonActionSchema } from "./elements/ButtonElement";
30
31
  export type { RadioGroupElementProps } from "./elements/RadioGroupElement";
31
32
  export type { CheckboxGroupElementProps } from "./elements/CheckboxGroupElement";
32
33
  export type { DatePickerElementProps } from "./elements/DatePickerElement";
@@ -34,6 +35,12 @@ export type { CarouselElementProps } from "./elements/CarouselElement";
34
35
  export type { ZStackElementProps } from "./elements/ZStackElement";
35
36
  export type { SafeAreaViewElementProps, SafeAreaEdge, SafeAreaEdgeMode } from "./elements/SafeAreaViewElement";
36
37
 
38
+ /**
39
+ * A variable entry stored in the ComposableScreen variables map.
40
+ * `value` is the canonical value (string), `label` is an optional display label.
41
+ */
42
+ export type ComposableVariableEntry = { value: string; label?: string };
43
+
37
44
  // UIElement union — must live here (not in elements/) to avoid circular deps
38
45
  // because the Stack variant's children: UIElement[] references itself.
39
46
  type UIElement =
package/src/types.ts CHANGED
@@ -44,10 +44,31 @@ export interface OnboardingMetadata {
44
44
  draft?: boolean;
45
45
  }
46
46
 
47
+ export type FontWeightKey =
48
+ | "regular"
49
+ | "medium"
50
+ | "semibold"
51
+ | "bold"
52
+ | "extrabold"
53
+ | "100"
54
+ | "200"
55
+ | "300"
56
+ | "400"
57
+ | "500"
58
+ | "600"
59
+ | "700"
60
+ | "800"
61
+ | "900";
62
+
63
+ export type FontFamilyManifest = Partial<Record<FontWeightKey, string>>;
64
+
65
+ export type FontsManifest = Record<string, FontFamilyManifest>;
66
+
47
67
  export interface Onboarding<StepType extends BaseStepType = BaseStepType> {
48
68
  metadata: OnboardingMetadata;
49
69
  steps: StepType[];
50
70
  configuration: any;
71
+ fonts?: FontsManifest;
51
72
  }
52
73
 
53
74
  export interface GetStepsResponseHeaders {