@rocapine/react-native-onboarding 1.57.4 → 1.59.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/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/infra/hooks/index.d.ts +1 -0
- package/dist/infra/hooks/index.d.ts.map +1 -1
- package/dist/infra/hooks/index.js +3 -1
- package/dist/infra/hooks/index.js.map +1 -1
- package/dist/infra/hooks/useOnboardingStart.d.ts +12 -0
- package/dist/infra/hooks/useOnboardingStart.d.ts.map +1 -0
- package/dist/infra/hooks/useOnboardingStart.js +23 -0
- package/dist/infra/hooks/useOnboardingStart.js.map +1 -0
- package/dist/infra/hooks/useOnboardingStep.d.ts +1 -0
- package/dist/infra/hooks/useOnboardingStep.d.ts.map +1 -1
- package/dist/infra/hooks/useOnboardingStep.js +4 -1
- package/dist/infra/hooks/useOnboardingStep.js.map +1 -1
- package/dist/infra/provider/OnboardingProvider.d.ts +31 -3
- package/dist/infra/provider/OnboardingProvider.d.ts.map +1 -1
- package/dist/infra/provider/OnboardingProvider.js +20 -1
- package/dist/infra/provider/OnboardingProvider.js.map +1 -1
- package/dist/infra/provider/index.d.ts +1 -1
- package/dist/infra/provider/index.d.ts.map +1 -1
- package/dist/infra/provider/index.js.map +1 -1
- package/dist/onboarding-example.d.ts +10 -0
- package/dist/onboarding-example.d.ts.map +1 -1
- package/dist/onboarding-example.js +8 -0
- package/dist/onboarding-example.js.map +1 -1
- package/dist/resolveNextStepNumber.d.ts +3 -1
- package/dist/resolveNextStepNumber.d.ts.map +1 -1
- package/dist/resolveNextStepNumber.js +10 -1
- package/dist/resolveNextStepNumber.js.map +1 -1
- package/dist/resolveStartStepNumber.d.ts +14 -0
- package/dist/resolveStartStepNumber.d.ts.map +1 -0
- package/dist/resolveStartStepNumber.js +23 -0
- package/dist/resolveStartStepNumber.js.map +1 -0
- package/dist/steps/common.types.d.ts +8 -0
- package/dist/steps/common.types.d.ts.map +1 -1
- package/dist/steps/common.types.js +14 -2
- package/dist/steps/common.types.js.map +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/resolveNextStepNumber.test.ts +59 -0
- package/src/__tests__/resolveStartStepNumber.test.ts +41 -0
- package/src/index.ts +2 -0
- package/src/infra/hooks/index.ts +1 -0
- package/src/infra/hooks/useOnboardingStart.ts +39 -0
- package/src/infra/hooks/useOnboardingStep.ts +5 -0
- package/src/infra/provider/OnboardingProvider.tsx +57 -2
- package/src/infra/provider/index.ts +2 -0
- package/src/onboarding-example.ts +8 -0
- package/src/resolveNextStepNumber.ts +9 -1
- package/src/resolveStartStepNumber.ts +23 -0
- package/src/steps/common.types.ts +14 -1
- package/src/types.ts +7 -0
|
@@ -201,10 +201,23 @@ export const NextStepSchema = z
|
|
|
201
201
|
.default(null);
|
|
202
202
|
export type NextStep = z.infer<typeof NextStepSchema>;
|
|
203
203
|
|
|
204
|
+
/**
|
|
205
|
+
* Reserved `targetStepId` / `defaultTargetStepId` value that ends the onboarding.
|
|
206
|
+
* When branching resolves to this sentinel, `resolveNextStepNumber` returns
|
|
207
|
+
* `null` (completion) instead of a step number — so a branch or the default
|
|
208
|
+
* target can end the flow from any step, with no trailing screen required.
|
|
209
|
+
* It is not a real step id; no step should use it as its `id`.
|
|
210
|
+
*/
|
|
211
|
+
export const ONBOARDING_END_STEP_ID = "__END__";
|
|
212
|
+
|
|
204
213
|
// ── Base step schema ──────────────────────────────────────────────────────────
|
|
205
214
|
|
|
206
215
|
export const BaseStepTypeSchema = z.object({
|
|
207
|
-
id
|
|
216
|
+
// A step id may not collide with the reserved end sentinel — otherwise the
|
|
217
|
+
// step would be unreachable (branching to it ends the flow instead).
|
|
218
|
+
id: z.string().refine((v) => v !== ONBOARDING_END_STEP_ID, {
|
|
219
|
+
message: `"${ONBOARDING_END_STEP_ID}" is reserved as the onboarding end sentinel and cannot be used as a step id`,
|
|
220
|
+
}),
|
|
208
221
|
name: z.string(),
|
|
209
222
|
displayProgressHeader: z.boolean(),
|
|
210
223
|
customPayload: CustomPayloadSchema,
|
package/src/types.ts
CHANGED
|
@@ -52,6 +52,13 @@ export interface OnboardingMetadata {
|
|
|
52
52
|
audienceOrder?: number;
|
|
53
53
|
locale?: string;
|
|
54
54
|
draft?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Id of the unique step the onboarding starts on. Read first to resolve the
|
|
57
|
+
* entry point (see `resolveStartStepNumber`). Optional; when absent or when it
|
|
58
|
+
* references a missing step, the flow falls back to the first step in `steps`
|
|
59
|
+
* (legacy behavior).
|
|
60
|
+
*/
|
|
61
|
+
startStepId?: string;
|
|
55
62
|
}
|
|
56
63
|
|
|
57
64
|
export type FontWeightKey =
|