@rocapine/react-native-onboarding 1.0.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/README.md +216 -0
- package/dist/OnboardingStudioClient.d.ts +13 -0
- package/dist/OnboardingStudioClient.d.ts.map +1 -0
- package/dist/OnboardingStudioClient.js +71 -0
- package/dist/OnboardingStudioClient.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/infra/hooks/index.d.ts +3 -0
- package/dist/infra/hooks/index.d.ts.map +1 -0
- package/dist/infra/hooks/index.js +8 -0
- package/dist/infra/hooks/index.js.map +1 -0
- package/dist/infra/hooks/useOnboarding.d.ts +6 -0
- package/dist/infra/hooks/useOnboarding.d.ts.map +1 -0
- package/dist/infra/hooks/useOnboarding.js +17 -0
- package/dist/infra/hooks/useOnboarding.js.map +1 -0
- package/dist/infra/hooks/useOnboarding.old.d.ts +7 -0
- package/dist/infra/hooks/useOnboarding.old.d.ts.map +1 -0
- package/dist/infra/hooks/useOnboarding.old.js +20 -0
- package/dist/infra/hooks/useOnboarding.old.js.map +1 -0
- package/dist/infra/hooks/useOnboardingStep.d.ts +12 -0
- package/dist/infra/hooks/useOnboardingStep.d.ts.map +1 -0
- package/dist/infra/hooks/useOnboardingStep.js +37 -0
- package/dist/infra/hooks/useOnboardingStep.js.map +1 -0
- package/dist/infra/hooks/useOnboardingStep.old.d.ts +12 -0
- package/dist/infra/hooks/useOnboardingStep.old.d.ts.map +1 -0
- package/dist/infra/hooks/useOnboardingStep.old.js +37 -0
- package/dist/infra/hooks/useOnboardingStep.old.js.map +1 -0
- package/dist/infra/index.d.ts +3 -0
- package/dist/infra/index.d.ts.map +1 -0
- package/dist/infra/index.js +19 -0
- package/dist/infra/index.js.map +1 -0
- package/dist/infra/provider/OnboardingProvider.d.ts +29 -0
- package/dist/infra/provider/OnboardingProvider.d.ts.map +1 -0
- package/dist/infra/provider/OnboardingProvider.js +48 -0
- package/dist/infra/provider/OnboardingProvider.js.map +1 -0
- package/dist/infra/provider/OnboardingProvider.old.d.ts +61 -0
- package/dist/infra/provider/OnboardingProvider.old.d.ts.map +1 -0
- package/dist/infra/provider/OnboardingProvider.old.js +55 -0
- package/dist/infra/provider/OnboardingProvider.old.js.map +1 -0
- package/dist/infra/provider/index.d.ts +2 -0
- package/dist/infra/provider/index.d.ts.map +1 -0
- package/dist/infra/provider/index.js +7 -0
- package/dist/infra/provider/index.js.map +1 -0
- package/dist/infra/queries/getOnboarding.query.d.ts +8 -0
- package/dist/infra/queries/getOnboarding.query.d.ts.map +1 -0
- package/dist/infra/queries/getOnboarding.query.js +52 -0
- package/dist/infra/queries/getOnboarding.query.js.map +1 -0
- package/dist/steps/Carousel/types.d.ts +32 -0
- package/dist/steps/Carousel/types.d.ts.map +1 -0
- package/dist/steps/Carousel/types.js +24 -0
- package/dist/steps/Carousel/types.js.map +1 -0
- package/dist/steps/Commitment/types.d.ts +41 -0
- package/dist/steps/Commitment/types.d.ts.map +1 -0
- package/dist/steps/Commitment/types.js +27 -0
- package/dist/steps/Commitment/types.js.map +1 -0
- package/dist/steps/Loader/types.d.ts +57 -0
- package/dist/steps/Loader/types.d.ts.map +1 -0
- package/dist/steps/Loader/types.js +30 -0
- package/dist/steps/Loader/types.js.map +1 -0
- package/dist/steps/MediaContent/types.d.ts +44 -0
- package/dist/steps/MediaContent/types.d.ts.map +1 -0
- package/dist/steps/MediaContent/types.js +22 -0
- package/dist/steps/MediaContent/types.js.map +1 -0
- package/dist/steps/Picker/types.d.ts +49 -0
- package/dist/steps/Picker/types.d.ts.map +1 -0
- package/dist/steps/Picker/types.js +30 -0
- package/dist/steps/Picker/types.js.map +1 -0
- package/dist/steps/Question/types.d.ts +47 -0
- package/dist/steps/Question/types.d.ts.map +1 -0
- package/dist/steps/Question/types.js +28 -0
- package/dist/steps/Question/types.js.map +1 -0
- package/dist/steps/Ratings/types.d.ts +32 -0
- package/dist/steps/Ratings/types.d.ts.map +1 -0
- package/dist/steps/Ratings/types.js +25 -0
- package/dist/steps/Ratings/types.js.map +1 -0
- package/dist/steps/common.types.d.ts +19 -0
- package/dist/steps/common.types.d.ts.map +1 -0
- package/dist/steps/common.types.js +25 -0
- package/dist/steps/common.types.js.map +1 -0
- package/dist/steps/types.d.ts +9 -0
- package/dist/steps/types.d.ts.map +1 -0
- package/dist/steps/types.js +3 -0
- package/dist/steps/types.js.map +1 -0
- package/dist/types.d.ts +46 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +48 -0
- package/src/OnboardingStudioClient.ts +92 -0
- package/src/global.d.ts +41 -0
- package/src/index.ts +6 -0
- package/src/infra/hooks/index.ts +2 -0
- package/src/infra/hooks/useOnboarding.ts +16 -0
- package/src/infra/hooks/useOnboardingStep.ts +66 -0
- package/src/infra/index.ts +2 -0
- package/src/infra/provider/OnboardingProvider.tsx +80 -0
- package/src/infra/provider/index.ts +4 -0
- package/src/infra/queries/getOnboarding.query.ts +58 -0
- package/src/steps/Carousel/types.ts +26 -0
- package/src/steps/Commitment/types.ts +28 -0
- package/src/steps/Loader/types.ts +32 -0
- package/src/steps/MediaContent/types.ts +26 -0
- package/src/steps/Picker/types.ts +34 -0
- package/src/steps/Question/types.ts +29 -0
- package/src/steps/Ratings/types.ts +22 -0
- package/src/steps/common.types.ts +25 -0
- package/src/steps/types.ts +16 -0
- package/src/types.ts +51 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const PickerTypeEnum: z.ZodEnum<{
|
|
3
|
+
date: "date";
|
|
4
|
+
name: "name";
|
|
5
|
+
height: "height";
|
|
6
|
+
weight: "weight";
|
|
7
|
+
age: "age";
|
|
8
|
+
gender: "gender";
|
|
9
|
+
coach: "coach";
|
|
10
|
+
}>;
|
|
11
|
+
export declare const PickerStepPayloadSchema: z.ZodObject<{
|
|
12
|
+
title: z.ZodString;
|
|
13
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
14
|
+
pickerType: z.ZodUnion<readonly [z.ZodEnum<{
|
|
15
|
+
date: "date";
|
|
16
|
+
name: "name";
|
|
17
|
+
height: "height";
|
|
18
|
+
weight: "weight";
|
|
19
|
+
age: "age";
|
|
20
|
+
gender: "gender";
|
|
21
|
+
coach: "coach";
|
|
22
|
+
}>, z.ZodString]>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export declare const PickerStepTypeSchema: z.ZodObject<{
|
|
25
|
+
id: z.ZodString;
|
|
26
|
+
type: z.ZodLiteral<"Picker">;
|
|
27
|
+
name: z.ZodString;
|
|
28
|
+
displayProgressHeader: z.ZodBoolean;
|
|
29
|
+
payload: z.ZodObject<{
|
|
30
|
+
title: z.ZodString;
|
|
31
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
32
|
+
pickerType: z.ZodUnion<readonly [z.ZodEnum<{
|
|
33
|
+
date: "date";
|
|
34
|
+
name: "name";
|
|
35
|
+
height: "height";
|
|
36
|
+
weight: "weight";
|
|
37
|
+
age: "age";
|
|
38
|
+
gender: "gender";
|
|
39
|
+
coach: "coach";
|
|
40
|
+
}>, z.ZodString]>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
customPayload: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
43
|
+
continueButtonLabel: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
44
|
+
figmaUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
export type PickerStepType = z.infer<typeof PickerStepTypeSchema>;
|
|
47
|
+
export type WeightUnit = "kg" | "lb";
|
|
48
|
+
export type HeightUnit = "cm" | "ft";
|
|
49
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/steps/Picker/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,cAAc;;;;;;;;EAQzB,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;iBAIlC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;iBAS/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,CAAC;AACrC,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PickerStepTypeSchema = exports.PickerStepPayloadSchema = exports.PickerTypeEnum = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_types_1 = require("../common.types");
|
|
6
|
+
exports.PickerTypeEnum = zod_1.z.enum([
|
|
7
|
+
"height",
|
|
8
|
+
"weight",
|
|
9
|
+
"age",
|
|
10
|
+
"date",
|
|
11
|
+
"gender",
|
|
12
|
+
"coach",
|
|
13
|
+
"name",
|
|
14
|
+
]);
|
|
15
|
+
exports.PickerStepPayloadSchema = zod_1.z.object({
|
|
16
|
+
title: zod_1.z.string(),
|
|
17
|
+
description: zod_1.z.string().nullish(),
|
|
18
|
+
pickerType: zod_1.z.union([exports.PickerTypeEnum, zod_1.z.string()]),
|
|
19
|
+
});
|
|
20
|
+
exports.PickerStepTypeSchema = zod_1.z.object({
|
|
21
|
+
id: zod_1.z.string(),
|
|
22
|
+
type: zod_1.z.literal("Picker"),
|
|
23
|
+
name: zod_1.z.string(),
|
|
24
|
+
displayProgressHeader: zod_1.z.boolean(),
|
|
25
|
+
payload: exports.PickerStepPayloadSchema,
|
|
26
|
+
customPayload: common_types_1.CustomPayloadSchema,
|
|
27
|
+
continueButtonLabel: zod_1.z.string().optional().default("Continue"),
|
|
28
|
+
figmaUrl: zod_1.z.string().nullish(),
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/steps/Picker/types.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,kDAAsD;AAEzC,QAAA,cAAc,GAAG,OAAC,CAAC,IAAI,CAAC;IACnC,QAAQ;IACR,QAAQ;IACR,KAAK;IACL,MAAM;IACN,QAAQ;IACR,OAAO;IACP,MAAM;CACP,CAAC,CAAC;AAEU,QAAA,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC9C,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;IACjC,UAAU,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,sBAAc,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC;CAClD,CAAC,CAAC;AAEU,QAAA,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3C,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;IACd,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;IACzB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,qBAAqB,EAAE,OAAC,CAAC,OAAO,EAAE;IAClC,OAAO,EAAE,+BAAuB;IAChC,aAAa,EAAE,kCAAmB;IAClC,mBAAmB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC;IAC9D,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;CAC/B,CAAC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const AnswerSchema: z.ZodObject<{
|
|
3
|
+
label: z.ZodString;
|
|
4
|
+
value: z.ZodString;
|
|
5
|
+
icon: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
6
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export declare const QuestionStepPayloadSchema: z.ZodObject<{
|
|
9
|
+
answers: z.ZodArray<z.ZodObject<{
|
|
10
|
+
label: z.ZodString;
|
|
11
|
+
value: z.ZodString;
|
|
12
|
+
icon: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
13
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
14
|
+
}, z.core.$strip>>;
|
|
15
|
+
title: z.ZodString;
|
|
16
|
+
subtitle: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
17
|
+
multipleAnswer: z.ZodBoolean;
|
|
18
|
+
infoBox: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
19
|
+
title: z.ZodString;
|
|
20
|
+
content: z.ZodString;
|
|
21
|
+
}, z.core.$strip>>>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export declare const QuestionStepTypeSchema: z.ZodObject<{
|
|
24
|
+
id: z.ZodString;
|
|
25
|
+
type: z.ZodLiteral<"Question">;
|
|
26
|
+
name: z.ZodString;
|
|
27
|
+
displayProgressHeader: z.ZodBoolean;
|
|
28
|
+
payload: z.ZodObject<{
|
|
29
|
+
answers: z.ZodArray<z.ZodObject<{
|
|
30
|
+
label: z.ZodString;
|
|
31
|
+
value: z.ZodString;
|
|
32
|
+
icon: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
33
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
34
|
+
}, z.core.$strip>>;
|
|
35
|
+
title: z.ZodString;
|
|
36
|
+
subtitle: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
37
|
+
multipleAnswer: z.ZodBoolean;
|
|
38
|
+
infoBox: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
39
|
+
title: z.ZodString;
|
|
40
|
+
content: z.ZodString;
|
|
41
|
+
}, z.core.$strip>>>;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
customPayload: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
44
|
+
figmaUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
export type QuestionStepType = z.infer<typeof QuestionStepTypeSchema>;
|
|
47
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/steps/Question/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,YAAY;;;;;iBAKvB,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;iBAMpC,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;iBAQjC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QuestionStepTypeSchema = exports.QuestionStepPayloadSchema = exports.AnswerSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_types_1 = require("../common.types");
|
|
6
|
+
exports.AnswerSchema = zod_1.z.object({
|
|
7
|
+
label: zod_1.z.string(),
|
|
8
|
+
value: zod_1.z.string(),
|
|
9
|
+
icon: zod_1.z.string().nullish(),
|
|
10
|
+
description: zod_1.z.string().nullish(),
|
|
11
|
+
});
|
|
12
|
+
exports.QuestionStepPayloadSchema = zod_1.z.object({
|
|
13
|
+
answers: zod_1.z.array(exports.AnswerSchema),
|
|
14
|
+
title: zod_1.z.string(),
|
|
15
|
+
subtitle: zod_1.z.string().nullish(),
|
|
16
|
+
multipleAnswer: zod_1.z.boolean(),
|
|
17
|
+
infoBox: common_types_1.InfoBoxSchema.nullish(),
|
|
18
|
+
});
|
|
19
|
+
exports.QuestionStepTypeSchema = zod_1.z.object({
|
|
20
|
+
id: zod_1.z.string(),
|
|
21
|
+
type: zod_1.z.literal("Question"),
|
|
22
|
+
name: zod_1.z.string(),
|
|
23
|
+
displayProgressHeader: zod_1.z.boolean(),
|
|
24
|
+
payload: exports.QuestionStepPayloadSchema,
|
|
25
|
+
customPayload: common_types_1.CustomPayloadSchema,
|
|
26
|
+
figmaUrl: zod_1.z.string().nullish(),
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/steps/Question/types.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,kDAAqE;AAExD,QAAA,YAAY,GAAG,OAAC,CAAC,MAAM,CAAC;IACnC,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;IAC1B,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;CAClC,CAAC,CAAC;AAEU,QAAA,yBAAyB,GAAG,OAAC,CAAC,MAAM,CAAC;IAChD,OAAO,EAAE,OAAC,CAAC,KAAK,CAAC,oBAAY,CAAC;IAC9B,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;IAC9B,cAAc,EAAE,OAAC,CAAC,OAAO,EAAE;IAC3B,OAAO,EAAE,4BAAa,CAAC,OAAO,EAAE;CACjC,CAAC,CAAC;AAEU,QAAA,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC7C,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;IACd,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,UAAU,CAAC;IAC3B,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,qBAAqB,EAAE,OAAC,CAAC,OAAO,EAAE;IAClC,OAAO,EAAE,iCAAyB;IAClC,aAAa,EAAE,kCAAmB;IAClC,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;CAC/B,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
export declare const RatingsStepPayloadSchema: z.ZodObject<{
|
|
3
|
+
title: z.ZodString;
|
|
4
|
+
subtitle: z.ZodString;
|
|
5
|
+
socialProofs: z.ZodArray<z.ZodObject<{
|
|
6
|
+
numberOfStar: z.ZodNumber;
|
|
7
|
+
content: z.ZodString;
|
|
8
|
+
authorName: z.ZodString;
|
|
9
|
+
}, z.core.$strip>>;
|
|
10
|
+
rateTheAppButtonLabel: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export declare const RatingsStepTypeSchema: z.ZodObject<{
|
|
13
|
+
id: z.ZodString;
|
|
14
|
+
type: z.ZodLiteral<"Ratings">;
|
|
15
|
+
name: z.ZodString;
|
|
16
|
+
displayProgressHeader: z.ZodBoolean;
|
|
17
|
+
payload: z.ZodObject<{
|
|
18
|
+
title: z.ZodString;
|
|
19
|
+
subtitle: z.ZodString;
|
|
20
|
+
socialProofs: z.ZodArray<z.ZodObject<{
|
|
21
|
+
numberOfStar: z.ZodNumber;
|
|
22
|
+
content: z.ZodString;
|
|
23
|
+
authorName: z.ZodString;
|
|
24
|
+
}, z.core.$strip>>;
|
|
25
|
+
rateTheAppButtonLabel: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
customPayload: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
28
|
+
continueButtonLabel: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
29
|
+
figmaUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
export type RatingsStepType = z.infer<typeof RatingsStepTypeSchema>;
|
|
32
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/steps/Ratings/types.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAGpB,eAAO,MAAM,wBAAwB;;;;;;;;;iBAKnC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;iBAShC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.RatingsStepTypeSchema = exports.RatingsStepPayloadSchema = void 0;
|
|
7
|
+
const zod_1 = __importDefault(require("zod"));
|
|
8
|
+
const common_types_1 = require("../common.types");
|
|
9
|
+
exports.RatingsStepPayloadSchema = zod_1.default.object({
|
|
10
|
+
title: zod_1.default.string(),
|
|
11
|
+
subtitle: zod_1.default.string(),
|
|
12
|
+
socialProofs: zod_1.default.array(common_types_1.SocialProofSchema),
|
|
13
|
+
rateTheAppButtonLabel: zod_1.default.string().optional().default("Rate the app"),
|
|
14
|
+
});
|
|
15
|
+
exports.RatingsStepTypeSchema = zod_1.default.object({
|
|
16
|
+
id: zod_1.default.string(),
|
|
17
|
+
type: zod_1.default.literal("Ratings"),
|
|
18
|
+
name: zod_1.default.string(),
|
|
19
|
+
displayProgressHeader: zod_1.default.boolean(),
|
|
20
|
+
payload: exports.RatingsStepPayloadSchema,
|
|
21
|
+
customPayload: common_types_1.CustomPayloadSchema,
|
|
22
|
+
continueButtonLabel: zod_1.default.string().optional().default("Continue"),
|
|
23
|
+
figmaUrl: zod_1.default.string().nullish(),
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/steps/Ratings/types.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAoB;AACpB,kDAAyE;AAE5D,QAAA,wBAAwB,GAAG,aAAC,CAAC,MAAM,CAAC;IAC/C,KAAK,EAAE,aAAC,CAAC,MAAM,EAAE;IACjB,QAAQ,EAAE,aAAC,CAAC,MAAM,EAAE;IACpB,YAAY,EAAE,aAAC,CAAC,KAAK,CAAC,gCAAiB,CAAC;IACxC,qBAAqB,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC;CACrE,CAAC,CAAC;AAEU,QAAA,qBAAqB,GAAG,aAAC,CAAC,MAAM,CAAC;IAC5C,EAAE,EAAE,aAAC,CAAC,MAAM,EAAE;IACd,IAAI,EAAE,aAAC,CAAC,OAAO,CAAC,SAAS,CAAC;IAC1B,IAAI,EAAE,aAAC,CAAC,MAAM,EAAE;IAChB,qBAAqB,EAAE,aAAC,CAAC,OAAO,EAAE;IAClC,OAAO,EAAE,gCAAwB;IACjC,aAAa,EAAE,kCAAmB;IAClC,mBAAmB,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC;IAC9D,QAAQ,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;CAC/B,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const CustomPayloadSchema: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
3
|
+
export declare const MediaSourceSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
4
|
+
type: z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"image">, z.ZodLiteral<"lottie">]>, z.ZodLiteral<"rive">]>;
|
|
5
|
+
localPathId: z.ZodString;
|
|
6
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
7
|
+
type: z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"image">, z.ZodLiteral<"lottie">]>, z.ZodLiteral<"rive">]>;
|
|
8
|
+
url: z.ZodString;
|
|
9
|
+
}, z.core.$strip>]>;
|
|
10
|
+
export declare const SocialProofSchema: z.ZodObject<{
|
|
11
|
+
numberOfStar: z.ZodNumber;
|
|
12
|
+
content: z.ZodString;
|
|
13
|
+
authorName: z.ZodString;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export declare const InfoBoxSchema: z.ZodObject<{
|
|
16
|
+
title: z.ZodString;
|
|
17
|
+
content: z.ZodString;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
//# sourceMappingURL=common.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.types.d.ts","sourceRoot":"","sources":["../../src/steps/common.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,mBAAmB,kEAA0C,CAAC;AAE3E,eAAO,MAAM,iBAAiB;;;;;;mBAS5B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;iBAI5B,CAAC;AAEH,eAAO,MAAM,aAAa;;;iBAGxB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InfoBoxSchema = exports.SocialProofSchema = exports.MediaSourceSchema = exports.CustomPayloadSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.CustomPayloadSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.any()).nullish();
|
|
6
|
+
exports.MediaSourceSchema = zod_1.z.union([
|
|
7
|
+
zod_1.z.object({
|
|
8
|
+
type: zod_1.z.literal("image").or(zod_1.z.literal("lottie")).or(zod_1.z.literal("rive")),
|
|
9
|
+
localPathId: zod_1.z.string(),
|
|
10
|
+
}),
|
|
11
|
+
zod_1.z.object({
|
|
12
|
+
type: zod_1.z.literal("image").or(zod_1.z.literal("lottie")).or(zod_1.z.literal("rive")),
|
|
13
|
+
url: zod_1.z.string(),
|
|
14
|
+
}),
|
|
15
|
+
]);
|
|
16
|
+
exports.SocialProofSchema = zod_1.z.object({
|
|
17
|
+
numberOfStar: zod_1.z.number(),
|
|
18
|
+
content: zod_1.z.string(),
|
|
19
|
+
authorName: zod_1.z.string(),
|
|
20
|
+
});
|
|
21
|
+
exports.InfoBoxSchema = zod_1.z.object({
|
|
22
|
+
title: zod_1.z.string(),
|
|
23
|
+
content: zod_1.z.string(),
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=common.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.types.js","sourceRoot":"","sources":["../../src/steps/common.types.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAEX,QAAA,mBAAmB,GAAG,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;AAE9D,QAAA,iBAAiB,GAAG,OAAC,CAAC,KAAK,CAAC;IACvC,OAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,OAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,OAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACtE,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE;KACxB,CAAC;IACF,OAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,OAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,OAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACtE,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;KAChB,CAAC;CACH,CAAC,CAAC;AAEU,QAAA,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE;IACxB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;IACnB,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE;CACvB,CAAC,CAAC;AAEU,QAAA,aAAa,GAAG,OAAC,CAAC,MAAM,CAAC;IACpC,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CarouselStepType } from "./Carousel/types";
|
|
2
|
+
import { CommitmentStepType } from "./Commitment/types";
|
|
3
|
+
import { LoaderStepType } from "./Loader/types";
|
|
4
|
+
import { MediaContentStepType } from "./MediaContent/types";
|
|
5
|
+
import { PickerStepType } from "./Picker/types";
|
|
6
|
+
import { QuestionStepType } from "./Question/types";
|
|
7
|
+
import { RatingsStepType } from "./Ratings/types";
|
|
8
|
+
export type OnboardingStepType = CarouselStepType | CommitmentStepType | LoaderStepType | MediaContentStepType | PickerStepType | QuestionStepType | RatingsStepType;
|
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/steps/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,kBAAkB,GAC1B,gBAAgB,GAChB,kBAAkB,GAClB,cAAc,GACd,oBAAoB,GACpB,cAAc,GACd,gBAAgB,GAChB,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/steps/types.ts"],"names":[],"mappings":""}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base step type that all onboarding steps must conform to.
|
|
3
|
+
* This is the minimal interface required by the headless SDK.
|
|
4
|
+
*/
|
|
5
|
+
export type BaseStepType = {
|
|
6
|
+
id: string;
|
|
7
|
+
type: string;
|
|
8
|
+
name: string;
|
|
9
|
+
displayProgressHeader?: boolean;
|
|
10
|
+
payload?: any;
|
|
11
|
+
customPayload?: any;
|
|
12
|
+
continueButtonLabel?: string;
|
|
13
|
+
figmaUrl?: string | null;
|
|
14
|
+
};
|
|
15
|
+
export type OnboardingStudioClientOptions<StepType extends BaseStepType = BaseStepType> = {
|
|
16
|
+
appVersion?: string;
|
|
17
|
+
isSandbox?: boolean;
|
|
18
|
+
baseUrl?: string;
|
|
19
|
+
fallbackOnboarding?: Onboarding<StepType>;
|
|
20
|
+
};
|
|
21
|
+
export type OnboardingOptions = {
|
|
22
|
+
locale?: string;
|
|
23
|
+
};
|
|
24
|
+
export type UserDefinedParams = {
|
|
25
|
+
[key: string]: string;
|
|
26
|
+
};
|
|
27
|
+
export interface OnboardingMetadata {
|
|
28
|
+
id: string;
|
|
29
|
+
name?: string;
|
|
30
|
+
audienceId?: string;
|
|
31
|
+
audienceName?: string;
|
|
32
|
+
audienceOrder?: number;
|
|
33
|
+
locale?: string;
|
|
34
|
+
draft?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface Onboarding<StepType extends BaseStepType = BaseStepType> {
|
|
37
|
+
metadata: OnboardingMetadata;
|
|
38
|
+
steps: StepType[];
|
|
39
|
+
configuration: any;
|
|
40
|
+
}
|
|
41
|
+
export interface GetStepsResponseHeaders {
|
|
42
|
+
"ONBS-Onboarding-Id": string | null;
|
|
43
|
+
"ONBS-Audience-Id": string | null;
|
|
44
|
+
"ONBS-Onboarding-Name": string | null;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,6BAA6B,CAAC,QAAQ,SAAS,YAAY,GAAG,YAAY,IAAI;IACxF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kBAAkB,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,UAAU,CAAC,QAAQ,SAAS,YAAY,GAAG,YAAY;IACtE,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,aAAa,EAAE,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,uBAAuB;IACtC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rocapine/react-native-onboarding",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Headless React Native SDK for Rocapine Onboarding Studio - Data fetching, state management, and hooks",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"prepare": "npm run build",
|
|
10
|
+
"watch": "tsc --watch",
|
|
11
|
+
"patch": "npm version patch && npm run build && npm publish"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"react-native",
|
|
15
|
+
"onboarding",
|
|
16
|
+
"rocapine",
|
|
17
|
+
"headless",
|
|
18
|
+
"cms",
|
|
19
|
+
"onboarding-studio"
|
|
20
|
+
],
|
|
21
|
+
"author": "Rocapine",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@react-native-async-storage/async-storage": "^2.1.0",
|
|
25
|
+
"@tanstack/react-query": "^5.64.2",
|
|
26
|
+
"zod": "^4.1.11"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/react": "^19.0.0",
|
|
30
|
+
"react": "19.1.0",
|
|
31
|
+
"react-native": "0.81.4",
|
|
32
|
+
"typescript": "^5.0.0"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"react": "*",
|
|
36
|
+
"react-native": "*"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"src",
|
|
41
|
+
"README.md"
|
|
42
|
+
],
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "https://github.com/rocapine/react-native-onboarding-studio.git",
|
|
46
|
+
"directory": "packages/onboarding"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { OnboardingStepType } from "./steps/types";
|
|
2
|
+
import {
|
|
3
|
+
Onboarding,
|
|
4
|
+
GetStepsResponseHeaders,
|
|
5
|
+
OnboardingOptions,
|
|
6
|
+
OnboardingStudioClientOptions,
|
|
7
|
+
UserDefinedParams,
|
|
8
|
+
BaseStepType,
|
|
9
|
+
} from "./types";
|
|
10
|
+
|
|
11
|
+
import { Platform } from "react-native";
|
|
12
|
+
|
|
13
|
+
export class OnboardingStudioClient {
|
|
14
|
+
private baseUrl: string;
|
|
15
|
+
public projectId: string;
|
|
16
|
+
public options: OnboardingStudioClientOptions;
|
|
17
|
+
|
|
18
|
+
constructor(projectId: string, options: OnboardingStudioClientOptions) {
|
|
19
|
+
console.info("OnboardingStudioClient init: projectId ", projectId);
|
|
20
|
+
this.projectId = projectId;
|
|
21
|
+
this.options = options;
|
|
22
|
+
this.baseUrl =
|
|
23
|
+
options.baseUrl ||
|
|
24
|
+
"https://takbcvjljqialzqyksic.supabase.co/functions/v1";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async getSteps<StepType extends BaseStepType = OnboardingStepType>(
|
|
28
|
+
onboardingOptions?: OnboardingOptions,
|
|
29
|
+
userDefinedParams?: UserDefinedParams
|
|
30
|
+
): Promise<{ data: Onboarding<StepType>; headers: GetStepsResponseHeaders }> {
|
|
31
|
+
console.info("OnboardingStudioClient getSteps");
|
|
32
|
+
const isSandbox = this.options.isSandbox;
|
|
33
|
+
|
|
34
|
+
const urlParams = new URLSearchParams();
|
|
35
|
+
// Add userDefinedParams to URL
|
|
36
|
+
if (userDefinedParams) {
|
|
37
|
+
Object.entries(userDefinedParams).forEach(([key, value]) => {
|
|
38
|
+
urlParams.append(key, value);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
urlParams.append("projectId", this.projectId);
|
|
43
|
+
urlParams.append("platform", Platform.OS);
|
|
44
|
+
|
|
45
|
+
const appVersion = this.options.appVersion; // TODO get the version from the expo app
|
|
46
|
+
if (appVersion) {
|
|
47
|
+
urlParams.append("appVersion", appVersion);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (isSandbox) {
|
|
51
|
+
urlParams.append("draft", "true");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Add onboardingOptions to URL
|
|
55
|
+
if (onboardingOptions?.locale) {
|
|
56
|
+
urlParams.append("locale", onboardingOptions.locale);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const url = `${this.baseUrl}/get-onboarding-steps?${urlParams.toString()}`;
|
|
60
|
+
console.info("OnboardingStudioClient getSteps url", url);
|
|
61
|
+
try {
|
|
62
|
+
const response = await fetch(url);
|
|
63
|
+
if (!response.ok) {
|
|
64
|
+
throw new Error(
|
|
65
|
+
`Failed to fetch onboarding steps: ${response.status} ${response.statusText}`
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
const data = await response.json();
|
|
69
|
+
return {
|
|
70
|
+
data,
|
|
71
|
+
headers: {
|
|
72
|
+
"ONBS-Onboarding-Id": response.headers.get("ONBS-Onboarding-Id"),
|
|
73
|
+
"ONBS-Audience-Id": response.headers.get("ONBS-Audience-Id"),
|
|
74
|
+
"ONBS-Onboarding-Name": response.headers.get("ONBS-Onboarding-Name"),
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.error(error);
|
|
79
|
+
if (this.options.fallbackOnboarding) {
|
|
80
|
+
return {
|
|
81
|
+
data: this.options.fallbackOnboarding as Onboarding<StepType>,
|
|
82
|
+
headers: {
|
|
83
|
+
"ONBS-Onboarding-Id": "fallback",
|
|
84
|
+
"ONBS-Audience-Id": "fallback",
|
|
85
|
+
"ONBS-Onboarding-Name": "fallback",
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
package/src/global.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Global types for React Native environment
|
|
2
|
+
declare function fetch(
|
|
3
|
+
input: RequestInfo | URL,
|
|
4
|
+
init?: RequestInit
|
|
5
|
+
): Promise<Response>;
|
|
6
|
+
|
|
7
|
+
interface RequestInit {
|
|
8
|
+
method?: string;
|
|
9
|
+
headers?: HeadersInit;
|
|
10
|
+
body?: BodyInit | null;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type HeadersInit = string[][] | Record<string, string> | Headers;
|
|
15
|
+
type BodyInit = string | Blob | ArrayBufferView | ArrayBuffer | FormData;
|
|
16
|
+
|
|
17
|
+
declare class Headers {
|
|
18
|
+
constructor(init?: HeadersInit);
|
|
19
|
+
append(name: string, value: string): void;
|
|
20
|
+
delete(name: string): void;
|
|
21
|
+
get(name: string): string | null;
|
|
22
|
+
has(name: string): boolean;
|
|
23
|
+
set(name: string, value: string): void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare class Response {
|
|
27
|
+
readonly ok: boolean;
|
|
28
|
+
readonly status: number;
|
|
29
|
+
readonly statusText: string;
|
|
30
|
+
readonly headers: Headers;
|
|
31
|
+
json<T = any>(): Promise<T>;
|
|
32
|
+
text(): Promise<string>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type RequestInfo = Request | string;
|
|
36
|
+
|
|
37
|
+
declare class Request {
|
|
38
|
+
constructor(input: RequestInfo | URL, init?: RequestInit);
|
|
39
|
+
readonly url: string;
|
|
40
|
+
readonly method: string;
|
|
41
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { OnboardingProgressContext } from "../provider/OnboardingProvider";
|
|
3
|
+
|
|
4
|
+
export const useOnboarding = () => {
|
|
5
|
+
const { activeStep, totalSteps, onboarding } = useContext(
|
|
6
|
+
OnboardingProgressContext
|
|
7
|
+
);
|
|
8
|
+
const progressPercentage =
|
|
9
|
+
totalSteps > 0 ? Math.round((100 * activeStep.number) / totalSteps) : 0;
|
|
10
|
+
const isProgressBarVisible = activeStep.displayProgressHeader;
|
|
11
|
+
return {
|
|
12
|
+
progressPercentage,
|
|
13
|
+
isProgressBarVisible,
|
|
14
|
+
onboarding,
|
|
15
|
+
};
|
|
16
|
+
};
|