@rocapine/react-native-onboarding 1.29.0 → 1.31.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/src/index.ts CHANGED
@@ -12,6 +12,8 @@ export type {
12
12
  WheelPickerElementProps,
13
13
  WheelPickerItem,
14
14
  WheelPickerRange,
15
+ ProgressIndicatorElementProps,
16
+ ProgressEasing,
15
17
  } from "./steps/ComposableScreen/types";
16
18
  export {
17
19
  ButtonActionSchema,
@@ -163,6 +163,38 @@ export const onboardingExample = {
163
163
  marginVertical: 8,
164
164
  },
165
165
  },
166
+ {
167
+ id: "progress-linear",
168
+ type: "ProgressIndicator",
169
+ props: {
170
+ variant: "linear",
171
+ autoplay: true,
172
+ loop: true,
173
+ initialValue: 0,
174
+ duration: 2500,
175
+ easing: "ease-in-out",
176
+ thickness: 10,
177
+ showLabel: true,
178
+ marginVertical: 8,
179
+ },
180
+ },
181
+ {
182
+ id: "progress-circular",
183
+ type: "ProgressIndicator",
184
+ props: {
185
+ variant: "circular",
186
+ autoplay: true,
187
+ loop: false,
188
+ initialValue: 0,
189
+ duration: 1800,
190
+ delay: 500,
191
+ easing: "ease-out",
192
+ size: 120,
193
+ thickness: 12,
194
+ showLabel: true,
195
+ alignSelf: "center",
196
+ },
197
+ },
166
198
  {
167
199
  id: "hero-video",
168
200
  type: "Video",
@@ -209,6 +241,28 @@ export const onboardingExample = {
209
241
  marginVertical: 4,
210
242
  },
211
243
  },
244
+ {
245
+ // Inline rich text — `content` as an array of styled spans.
246
+ // Each span inherits the parent Text style and overrides only
247
+ // what it sets (here: weight, color, underline).
248
+ id: "richtext-demo",
249
+ type: "Text",
250
+ props: {
251
+ content: [
252
+ { text: "Lose " },
253
+ { text: "5kg", fontWeight: "700", color: "#E11D48" },
254
+ { text: " in 30 days — " },
255
+ {
256
+ text: "guaranteed",
257
+ fontStyle: "italic",
258
+ textDecorationLine: "underline",
259
+ },
260
+ ],
261
+ fontSize: 16,
262
+ textAlign: "center",
263
+ marginVertical: 4,
264
+ },
265
+ },
212
266
  {
213
267
  id: "scroll-demo",
214
268
  type: "ScrollView",
@@ -0,0 +1,66 @@
1
+ import { z } from "zod";
2
+ import { BaseBoxProps, BaseBoxPropsSchema } from "./BaseBoxProps";
3
+
4
+ /**
5
+ * Easing curve names selectable for the progress animation. Mapped to the
6
+ * matching CSS-style cubic-bezier curves in the renderer.
7
+ */
8
+ export type ProgressEasing = "linear" | "ease-in" | "ease-out" | "ease-in-out";
9
+
10
+ export type ProgressIndicatorElementProps = BaseBoxProps & {
11
+ /** Visual style of the indicator. */
12
+ variant?: "linear" | "circular";
13
+ /**
14
+ * Variable bound to the indicator (int 0-100). When `autoplay` is on, the
15
+ * current rounded progress is written to this variable on each frame; when
16
+ * `autoplay` is off, the indicator reflects (and animates to) this variable's
17
+ * value.
18
+ */
19
+ variableName?: string;
20
+ /** Static value (0-100) used when no `variableName` is provided. */
21
+ value?: number;
22
+ /** Animate from `initialValue` to 100 automatically on mount. */
23
+ autoplay?: boolean;
24
+ /** Repeat the autoplay animation indefinitely. */
25
+ loop?: boolean;
26
+ /** Starting value (0-100). Defaults to 0. */
27
+ initialValue?: number;
28
+ /** Animation duration in milliseconds. Defaults to 1000. */
29
+ duration?: number;
30
+ /** Delay in milliseconds before the animation starts. Defaults to 0. */
31
+ delay?: number;
32
+ /** Easing curve for the animation. Defaults to "ease-in-out". */
33
+ easing?: ProgressEasing;
34
+ /** Progress fill color. Defaults to theme primary. */
35
+ color?: string;
36
+ /** Track (unfilled) color. Defaults to theme neutral.lower. */
37
+ trackColor?: string;
38
+ /** Bar height (linear) / ring stroke width (circular). */
39
+ thickness?: number;
40
+ /** Diameter of the circular variant in px. Defaults to 120. */
41
+ size?: number;
42
+ /** Show the percentage label (centered for circular, alongside for linear). */
43
+ showLabel?: boolean;
44
+ /** Label text color. Defaults to theme text.primary. */
45
+ labelColor?: string;
46
+ };
47
+
48
+ const ProgressEasingSchema = z.enum(["linear", "ease-in", "ease-out", "ease-in-out"]);
49
+
50
+ export const ProgressIndicatorElementPropsSchema = BaseBoxPropsSchema.extend({
51
+ variant: z.enum(["linear", "circular"]).optional(),
52
+ variableName: z.string().min(1).optional(),
53
+ value: z.number().min(0).max(100).optional(),
54
+ autoplay: z.boolean().optional(),
55
+ loop: z.boolean().optional(),
56
+ initialValue: z.number().min(0).max(100).optional(),
57
+ duration: z.number().min(0).optional(),
58
+ delay: z.number().min(0).optional(),
59
+ easing: ProgressEasingSchema.optional(),
60
+ color: z.string().optional(),
61
+ trackColor: z.string().optional(),
62
+ thickness: z.number().min(0).optional(),
63
+ size: z.number().min(0).optional(),
64
+ showLabel: z.boolean().optional(),
65
+ labelColor: z.string().optional(),
66
+ });
@@ -1,8 +1,51 @@
1
1
  import { z } from "zod";
2
2
  import { BaseBoxProps, BaseBoxPropsSchema } from "./BaseBoxProps";
3
3
 
4
+ /**
5
+ * A styled inline run of text. Used to compose rich text inside a single
6
+ * `Text` element — spans render as nested `<Text>` and inherit any prop they
7
+ * omit from the parent `Text` (React Native nested-`<Text>` inheritance), so a
8
+ * span only declares the styling it overrides.
9
+ */
10
+ export type TextSpan = {
11
+ text: string;
12
+ fontWeight?: string;
13
+ fontStyle?: "normal" | "italic";
14
+ /**
15
+ * Font family name. Omit or set to `"inherit"` to inherit the parent
16
+ * `Text` element's resolved font family.
17
+ */
18
+ fontFamily?: string | "inherit";
19
+ fontSize?: number;
20
+ letterSpacing?: number;
21
+ color?: string;
22
+ textDecorationLine?:
23
+ | "none"
24
+ | "underline"
25
+ | "line-through"
26
+ | "underline line-through";
27
+ };
28
+
29
+ export const TextSpanSchema = z.object({
30
+ text: z.string(),
31
+ fontWeight: z.string().optional(),
32
+ fontStyle: z.enum(["normal", "italic"]).optional(),
33
+ fontFamily: z.string().optional(),
34
+ fontSize: z.number().optional(),
35
+ letterSpacing: z.number().optional(),
36
+ color: z.string().optional(),
37
+ textDecorationLine: z
38
+ .enum(["none", "underline", "line-through", "underline line-through"])
39
+ .optional(),
40
+ });
41
+
4
42
  export type TextElementProps = BaseBoxProps & {
5
- content: string;
43
+ /**
44
+ * Plain string, or an array of styled spans for inline rich text. In
45
+ * `expression` mode `{{variable}}` interpolation applies to the string or to
46
+ * each span's `text`.
47
+ */
48
+ content: string | TextSpan[];
6
49
  mode?: "plain" | "expression";
7
50
  fontSize?: number;
8
51
  fontWeight?: string;
@@ -19,7 +62,7 @@ export type TextElementProps = BaseBoxProps & {
19
62
  };
20
63
 
21
64
  export const TextElementPropsSchema = BaseBoxPropsSchema.extend({
22
- content: z.string(),
65
+ content: z.union([z.string(), z.array(TextSpanSchema)]),
23
66
  mode: z.enum(["plain", "expression"]).optional(),
24
67
  fontSize: z.number().optional(),
25
68
  fontWeight: z.string().optional(),
@@ -27,11 +27,13 @@ import {
27
27
  type KeyboardAvoidingViewElementProps,
28
28
  KeyboardAvoidingViewElementPropsSchema,
29
29
  } from "./elements/KeyboardAvoidingViewElement";
30
+ import { type ProgressIndicatorElementProps, ProgressIndicatorElementPropsSchema } from "./elements/ProgressIndicatorElement";
30
31
 
31
32
  export type { BaseBoxProps, GradientBackground, GradientEdge, GradientStop, LinearGradientConfig } from "./elements/BaseBoxProps";
32
33
  export { BaseBoxPropsSchema, GradientBackgroundSchema } from "./elements/BaseBoxProps";
33
34
  export type { StackElementProps } from "./elements/StackElement";
34
- export type { TextElementProps } from "./elements/TextElement";
35
+ export type { TextElementProps, TextSpan } from "./elements/TextElement";
36
+ export { TextSpanSchema } from "./elements/TextElement";
35
37
  export type { ImageElementProps } from "./elements/ImageElement";
36
38
  export type { LottieElementProps } from "./elements/LottieElement";
37
39
  export type { RiveElementProps } from "./elements/RiveElement";
@@ -53,6 +55,7 @@ export type {
53
55
  KeyboardAvoidingViewElementProps,
54
56
  KeyboardAvoidingBehavior,
55
57
  } from "./elements/KeyboardAvoidingViewElement";
58
+ export type { ProgressIndicatorElementProps, ProgressEasing } from "./elements/ProgressIndicatorElement";
56
59
 
57
60
  /**
58
61
  * Type tag for a ComposableScreen variable. Drives expression-mode coercion
@@ -205,6 +208,13 @@ type UIElement =
205
208
  type: "KeyboardAvoidingView";
206
209
  props: KeyboardAvoidingViewElementProps;
207
210
  children: UIElement[];
211
+ }
212
+ | {
213
+ id: string;
214
+ name?: string;
215
+ renderWhen?: LeafCondition | ConditionGroup;
216
+ type: "ProgressIndicator";
217
+ props: ProgressIndicatorElementProps;
208
218
  };
209
219
 
210
220
  const UIElementSchema: z.ZodType<UIElement> = z.lazy(() =>
@@ -341,6 +351,13 @@ const UIElementSchema: z.ZodType<UIElement> = z.lazy(() =>
341
351
  props: KeyboardAvoidingViewElementPropsSchema,
342
352
  children: z.array(UIElementSchema),
343
353
  }),
354
+ z.object({
355
+ id: z.string(),
356
+ name: z.string().optional(),
357
+ renderWhen: z.union([LeafConditionSchema, ConditionGroupSchema]).optional(),
358
+ type: z.literal("ProgressIndicator"),
359
+ props: ProgressIndicatorElementPropsSchema,
360
+ }),
344
361
  ])
345
362
  );
346
363