react-native-onboarding-steps 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/LICENSE +21 -0
- package/README.md +195 -0
- package/lib/commonjs/Button.js +62 -0
- package/lib/commonjs/Button.js.map +1 -0
- package/lib/commonjs/Onboarding.js +137 -0
- package/lib/commonjs/Onboarding.js.map +1 -0
- package/lib/commonjs/Step.js +45 -0
- package/lib/commonjs/Step.js.map +1 -0
- package/lib/commonjs/Steps.js +66 -0
- package/lib/commonjs/Steps.js.map +1 -0
- package/lib/commonjs/index.js +54 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/theme.js +42 -0
- package/lib/commonjs/theme.js.map +1 -0
- package/lib/commonjs/types.js +6 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/Button.js +58 -0
- package/lib/module/Button.js.map +1 -0
- package/lib/module/Onboarding.js +131 -0
- package/lib/module/Onboarding.js.map +1 -0
- package/lib/module/Step.js +40 -0
- package/lib/module/Step.js.map +1 -0
- package/lib/module/Steps.js +60 -0
- package/lib/module/Steps.js.map +1 -0
- package/lib/module/index.js +8 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/theme.js +36 -0
- package/lib/module/theme.js.map +1 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/Button.d.ts +15 -0
- package/lib/typescript/commonjs/src/Button.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Onboarding.d.ts +4 -0
- package/lib/typescript/commonjs/src/Onboarding.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Step.d.ts +11 -0
- package/lib/typescript/commonjs/src/Step.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Steps.d.ts +9 -0
- package/lib/typescript/commonjs/src/Steps.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +7 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/theme.d.ts +14 -0
- package/lib/typescript/commonjs/src/theme.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types.d.ts +90 -0
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/Button.d.ts +15 -0
- package/lib/typescript/module/src/Button.d.ts.map +1 -0
- package/lib/typescript/module/src/Onboarding.d.ts +4 -0
- package/lib/typescript/module/src/Onboarding.d.ts.map +1 -0
- package/lib/typescript/module/src/Step.d.ts +11 -0
- package/lib/typescript/module/src/Step.d.ts.map +1 -0
- package/lib/typescript/module/src/Steps.d.ts +9 -0
- package/lib/typescript/module/src/Steps.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +7 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/theme.d.ts +14 -0
- package/lib/typescript/module/src/theme.d.ts.map +1 -0
- package/lib/typescript/module/src/types.d.ts +90 -0
- package/lib/typescript/module/src/types.d.ts.map +1 -0
- package/package.json +100 -0
- package/src/Button.tsx +72 -0
- package/src/Onboarding.tsx +147 -0
- package/src/Step.tsx +38 -0
- package/src/Steps.tsx +62 -0
- package/src/index.ts +15 -0
- package/src/theme.ts +34 -0
- package/src/types.ts +99 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import type { WithSpringConfig } from 'react-native-reanimated';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A single step of the onboarding flow.
|
|
7
|
+
*
|
|
8
|
+
* Everything except `id` is optional so a flow can be as thin as
|
|
9
|
+
* `[{ id: 0 }, { id: 1 }]` and still render.
|
|
10
|
+
*/
|
|
11
|
+
export type OnboardingStep = {
|
|
12
|
+
/** Stable identity for this step. Used as the React key. */
|
|
13
|
+
id: string | number;
|
|
14
|
+
/** What fills the area above the step indicator while this step is active. */
|
|
15
|
+
content?: ReactNode;
|
|
16
|
+
/** Overrides the default "Back" label while this step is active. */
|
|
17
|
+
backButtonLabel?: string;
|
|
18
|
+
/** Overrides the default "Continue" label while this step is active. */
|
|
19
|
+
continueButtonLabel?: string;
|
|
20
|
+
/** Overrides the default "Finish" label. Only used on the last step. */
|
|
21
|
+
finishButtonLabel?: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Fully resolved look of the animated step indicator. Every field is required
|
|
26
|
+
* here; consumers supply a `StepsThemeInput` and the gaps are filled from
|
|
27
|
+
* `defaultStepsTheme`.
|
|
28
|
+
*/
|
|
29
|
+
export type StepsTheme = {
|
|
30
|
+
/** Diameter of a step's slot — also the height of the track. */
|
|
31
|
+
stepSize: number;
|
|
32
|
+
/** Diameter of the dot drawn inside each slot. */
|
|
33
|
+
dotSize: number;
|
|
34
|
+
/** Horizontal space between two step slots. */
|
|
35
|
+
stepGap: number;
|
|
36
|
+
/** Colour of the pill that connects completed steps. */
|
|
37
|
+
trackColor: string;
|
|
38
|
+
/** Dot colour once the track has swept over it. */
|
|
39
|
+
activeDotColor: string;
|
|
40
|
+
/** Dot colour before the track reaches it. */
|
|
41
|
+
inactiveDotColor: string;
|
|
42
|
+
/** Spring driving the track's sweep and the dot colour crossfade. */
|
|
43
|
+
spring: WithSpringConfig;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/** Partial theme accepted from consumers; merged over `defaultStepsTheme`. */
|
|
47
|
+
export type StepsThemeInput = Partial<StepsTheme>;
|
|
48
|
+
|
|
49
|
+
/** Everything a custom button renderer needs to draw itself and act. */
|
|
50
|
+
export type OnboardingButtonProps = {
|
|
51
|
+
/** Label resolved from the step, falling back to the built-in default. */
|
|
52
|
+
label: string;
|
|
53
|
+
/** Advances or rewinds the flow. Call this from your own component. */
|
|
54
|
+
onPress: () => void;
|
|
55
|
+
/** Zero-based index of the active step. */
|
|
56
|
+
currentStep: number;
|
|
57
|
+
/** Total number of steps in the flow. */
|
|
58
|
+
totalSteps: number;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/** A function returning the React element to use in place of a stock button. */
|
|
62
|
+
export type OnboardingButtonRenderer = (props: OnboardingButtonProps) => ReactNode;
|
|
63
|
+
|
|
64
|
+
export type OnboardingProps = {
|
|
65
|
+
/** The flow. Rendering is skipped entirely when this is empty. */
|
|
66
|
+
steps: OnboardingStep[];
|
|
67
|
+
/** Step to open on. Clamped into range. Defaults to 0. */
|
|
68
|
+
initialStep?: number;
|
|
69
|
+
|
|
70
|
+
/** Called when the primary button is pressed on the last step. The flow
|
|
71
|
+
* stays on that step — navigating away is the consumer's call. */
|
|
72
|
+
onComplete?: () => void;
|
|
73
|
+
/** Called on every step change, forwards and backwards. */
|
|
74
|
+
onStepChange?: (index: number, step: OnboardingStep) => void;
|
|
75
|
+
/** Called when the back button moves the flow to a previous step.
|
|
76
|
+
* `onStepChange` fires as well. */
|
|
77
|
+
onBack?: (index: number, step: OnboardingStep) => void;
|
|
78
|
+
|
|
79
|
+
/** Partial override of the step indicator's look. */
|
|
80
|
+
stepsTheme?: StepsThemeInput;
|
|
81
|
+
|
|
82
|
+
/** Background of the stock back button. */
|
|
83
|
+
backButtonColor?: string;
|
|
84
|
+
/** Label colour of the stock back button. */
|
|
85
|
+
backButtonLabelColor?: string;
|
|
86
|
+
/** Replaces the stock back button. Still fades in/out with the flow. */
|
|
87
|
+
backButton?: OnboardingButtonRenderer;
|
|
88
|
+
/** Background of the stock continue/finish button. */
|
|
89
|
+
continueButtonColor?: string;
|
|
90
|
+
/** Label colour of the stock continue/finish button. */
|
|
91
|
+
continueButtonLabelColor?: string;
|
|
92
|
+
/** Replaces the stock continue/finish button. */
|
|
93
|
+
continueButton?: OnboardingButtonRenderer;
|
|
94
|
+
|
|
95
|
+
/** Style for the outermost container. */
|
|
96
|
+
style?: StyleProp<ViewStyle>;
|
|
97
|
+
/** Style for the region that hosts the active step's `content`. */
|
|
98
|
+
contentStyle?: StyleProp<ViewStyle>;
|
|
99
|
+
};
|