@rocapine/react-native-onboarding 1.32.0 → 1.33.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 +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/onboarding-example.d.ts +232 -30
- package/dist/onboarding-example.d.ts.map +1 -1
- package/dist/onboarding-example.js +42 -0
- package/dist/onboarding-example.js.map +1 -1
- package/dist/steps/ComposableScreen/elements/RichTextElement.d.ts +303 -0
- package/dist/steps/ComposableScreen/elements/RichTextElement.d.ts.map +1 -0
- package/dist/steps/ComposableScreen/elements/RichTextElement.js +20 -0
- package/dist/steps/ComposableScreen/elements/RichTextElement.js.map +1 -0
- package/dist/steps/ComposableScreen/types.d.ts +11 -0
- package/dist/steps/ComposableScreen/types.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/types.js +15 -2
- package/dist/steps/ComposableScreen/types.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/onboarding-example.ts +42 -0
- package/src/steps/ComposableScreen/elements/RichTextElement.ts +55 -0
- package/src/steps/ComposableScreen/types.ts +25 -2
|
@@ -273,6 +273,48 @@ export const onboardingExample = {
|
|
|
273
273
|
marginVertical: 4,
|
|
274
274
|
},
|
|
275
275
|
},
|
|
276
|
+
{
|
|
277
|
+
// RichText container — a wrapping flex row of `Text` elements.
|
|
278
|
+
// Each child is a real flex child (not nested `<Text>`), so it
|
|
279
|
+
// honors box props: the highlighted segment is a padded, rounded,
|
|
280
|
+
// rotated "chip". Children also keep their own renderWhen.
|
|
281
|
+
id: "richtext-container-demo",
|
|
282
|
+
type: "RichText",
|
|
283
|
+
props: {
|
|
284
|
+
alignItems: "center",
|
|
285
|
+
justifyContent: "center",
|
|
286
|
+
marginVertical: 4,
|
|
287
|
+
// Base typography declared once — children inherit it.
|
|
288
|
+
fontSize: 22,
|
|
289
|
+
fontWeight: "600",
|
|
290
|
+
},
|
|
291
|
+
children: [
|
|
292
|
+
// Plain-text children split into words → wrap word-by-word.
|
|
293
|
+
{ id: "rt-1", type: "Text", props: { content: "Boost your" } },
|
|
294
|
+
{
|
|
295
|
+
id: "rt-2",
|
|
296
|
+
type: "Text",
|
|
297
|
+
// Chip: box styling keeps it atomic; overrides inherited defaults.
|
|
298
|
+
props: {
|
|
299
|
+
content: "energy",
|
|
300
|
+
fontWeight: "700",
|
|
301
|
+
color: "#FFFFFF",
|
|
302
|
+
backgroundColor: "#E11D48",
|
|
303
|
+
paddingHorizontal: 14,
|
|
304
|
+
paddingVertical: 4,
|
|
305
|
+
borderRadius: 200,
|
|
306
|
+
marginHorizontal: 4,
|
|
307
|
+
transform: { rotate: -3 },
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
id: "rt-3",
|
|
312
|
+
type: "Text",
|
|
313
|
+
renderWhen: { variable: "name", operator: "is_not_empty" },
|
|
314
|
+
props: { content: ", {{name}}!", mode: "expression" },
|
|
315
|
+
},
|
|
316
|
+
],
|
|
317
|
+
},
|
|
276
318
|
{
|
|
277
319
|
id: "scroll-demo",
|
|
278
320
|
type: "ScrollView",
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { BaseBoxProps, BaseBoxPropsSchema } from "./BaseBoxProps";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Multi-element container that lays out child `Text` elements as a **wrapping
|
|
6
|
+
* flex row** — each child is a full `Text` UIElement that wraps to the next line
|
|
7
|
+
* as a whole unit (word or styled "chip"). Unlike inline `TextSpan`s (the `Text`
|
|
8
|
+
* element's `content[]`, which are nested `<Text>` and so cannot carry box
|
|
9
|
+
* styling), each `RichText` child is a real flex child, so it honors its own box
|
|
10
|
+
* props — `padding`, `borderRadius`, `borderWidth`, `backgroundColor`, `margin`,
|
|
11
|
+
* `transform` (e.g. rotated pills), `renderWhen`, and `expression` mode.
|
|
12
|
+
*
|
|
13
|
+
* The text-style fields below (`fontSize`, `color`, …) act as **inherited
|
|
14
|
+
* defaults**: every child `Text` uses them for any matching prop it omits, so a
|
|
15
|
+
* title's base typography is declared once on the container and only the
|
|
16
|
+
* highlighted "chip" children override (color, background, weight). Children
|
|
17
|
+
* always win over the inherited default.
|
|
18
|
+
*
|
|
19
|
+
* Use this to compose mixed runs of plain words and padded/rounded chips that
|
|
20
|
+
* wrap and align together (e.g. a marketing title with highlighted pills). For
|
|
21
|
+
* pure character-level inline flow with text-only styling, use `Text.content`
|
|
22
|
+
* spans instead.
|
|
23
|
+
*/
|
|
24
|
+
export type RichTextElementProps = BaseBoxProps & {
|
|
25
|
+
// Layout (wrapping row)
|
|
26
|
+
gap?: number;
|
|
27
|
+
alignItems?: "flex-start" | "center" | "flex-end" | "baseline" | "stretch";
|
|
28
|
+
justifyContent?: "flex-start" | "center" | "flex-end" | "space-between" | "space-around";
|
|
29
|
+
/** Defaults to `"wrap"` — the whole point of RichText is multi-line wrapping. */
|
|
30
|
+
flexWrap?: "wrap" | "nowrap";
|
|
31
|
+
// Inherited text-style defaults for children
|
|
32
|
+
fontSize?: number;
|
|
33
|
+
fontWeight?: string;
|
|
34
|
+
fontFamily?: string | "inherit";
|
|
35
|
+
fontStyle?: "normal" | "italic";
|
|
36
|
+
color?: string;
|
|
37
|
+
textAlign?: "left" | "center" | "right";
|
|
38
|
+
letterSpacing?: number;
|
|
39
|
+
lineHeight?: number;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const RichTextElementPropsSchema = BaseBoxPropsSchema.extend({
|
|
43
|
+
gap: z.number().optional(),
|
|
44
|
+
alignItems: z.enum(["flex-start", "center", "flex-end", "baseline", "stretch"]).optional(),
|
|
45
|
+
justifyContent: z.enum(["flex-start", "center", "flex-end", "space-between", "space-around"]).optional(),
|
|
46
|
+
flexWrap: z.enum(["wrap", "nowrap"]).optional(),
|
|
47
|
+
fontSize: z.number().optional(),
|
|
48
|
+
fontWeight: z.string().optional(),
|
|
49
|
+
fontFamily: z.string().optional(),
|
|
50
|
+
fontStyle: z.enum(["normal", "italic"]).optional(),
|
|
51
|
+
color: z.string().optional(),
|
|
52
|
+
textAlign: z.enum(["left", "center", "right"]).optional(),
|
|
53
|
+
letterSpacing: z.number().optional(),
|
|
54
|
+
lineHeight: z.number().optional(),
|
|
55
|
+
});
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from "../common.types";
|
|
9
9
|
import { type StackElementProps, StackElementPropsSchema } from "./elements/StackElement";
|
|
10
10
|
import { type TextElementProps, TextElementPropsSchema } from "./elements/TextElement";
|
|
11
|
+
import { type RichTextElementProps, RichTextElementPropsSchema } from "./elements/RichTextElement";
|
|
11
12
|
import { type ImageElementProps, ImageElementPropsSchema } from "./elements/ImageElement";
|
|
12
13
|
import { type LottieElementProps, LottieElementPropsSchema } from "./elements/LottieElement";
|
|
13
14
|
import { type RiveElementProps, RiveElementPropsSchema } from "./elements/RiveElement";
|
|
@@ -48,6 +49,7 @@ export { BaseBoxPropsSchema, GradientBackgroundSchema } from "./elements/BaseBox
|
|
|
48
49
|
export type { StackElementProps } from "./elements/StackElement";
|
|
49
50
|
export type { TextElementProps, TextSpan } from "./elements/TextElement";
|
|
50
51
|
export { TextSpanSchema } from "./elements/TextElement";
|
|
52
|
+
export type { RichTextElementProps } from "./elements/RichTextElement";
|
|
51
53
|
export type { ImageElementProps } from "./elements/ImageElement";
|
|
52
54
|
export type { LottieElementProps } from "./elements/LottieElement";
|
|
53
55
|
export type { RiveElementProps } from "./elements/RiveElement";
|
|
@@ -106,6 +108,14 @@ type UIElement =
|
|
|
106
108
|
type: "Text";
|
|
107
109
|
props: TextElementProps;
|
|
108
110
|
}
|
|
111
|
+
| {
|
|
112
|
+
id: string;
|
|
113
|
+
name?: string;
|
|
114
|
+
renderWhen?: LeafCondition | ConditionGroup;
|
|
115
|
+
type: "RichText";
|
|
116
|
+
props: RichTextElementProps;
|
|
117
|
+
children: Array<Extract<UIElement, { type: "Text" }>>;
|
|
118
|
+
}
|
|
109
119
|
| {
|
|
110
120
|
id: string;
|
|
111
121
|
name?: string;
|
|
@@ -231,6 +241,17 @@ type UIElement =
|
|
|
231
241
|
props: ProgressIndicatorElementProps;
|
|
232
242
|
};
|
|
233
243
|
|
|
244
|
+
// The `Text` variant, extracted so `RichText` can restrict its children to
|
|
245
|
+
// Text-only (children: z.array(TextUIElementSchema)) while the union references
|
|
246
|
+
// the same object.
|
|
247
|
+
const TextUIElementSchema = z.object({
|
|
248
|
+
id: z.string(),
|
|
249
|
+
name: z.string().optional(),
|
|
250
|
+
renderWhen: z.union([LeafConditionSchema, ConditionGroupSchema]).optional(),
|
|
251
|
+
type: z.literal("Text"),
|
|
252
|
+
props: TextElementPropsSchema,
|
|
253
|
+
});
|
|
254
|
+
|
|
234
255
|
const UIElementSchema: z.ZodType<UIElement> = z.lazy(() =>
|
|
235
256
|
z.union([
|
|
236
257
|
z.object({
|
|
@@ -241,12 +262,14 @@ const UIElementSchema: z.ZodType<UIElement> = z.lazy(() =>
|
|
|
241
262
|
props: StackElementPropsSchema,
|
|
242
263
|
children: z.array(UIElementSchema),
|
|
243
264
|
}),
|
|
265
|
+
TextUIElementSchema,
|
|
244
266
|
z.object({
|
|
245
267
|
id: z.string(),
|
|
246
268
|
name: z.string().optional(),
|
|
247
269
|
renderWhen: z.union([LeafConditionSchema, ConditionGroupSchema]).optional(),
|
|
248
|
-
type: z.literal("
|
|
249
|
-
props:
|
|
270
|
+
type: z.literal("RichText"),
|
|
271
|
+
props: RichTextElementPropsSchema,
|
|
272
|
+
children: z.array(TextUIElementSchema),
|
|
250
273
|
}),
|
|
251
274
|
z.object({
|
|
252
275
|
id: z.string(),
|