@rocapine/react-native-onboarding 1.24.0 → 1.25.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/onboarding-example.d.ts +253 -165
- package/dist/onboarding-example.d.ts.map +1 -1
- package/dist/onboarding-example.js +94 -8
- package/dist/onboarding-example.js.map +1 -1
- package/dist/steps/ComposableScreen/elements/KeyboardAvoidingViewElement.d.ts +86 -0
- package/dist/steps/ComposableScreen/elements/KeyboardAvoidingViewElement.d.ts.map +1 -0
- package/dist/steps/ComposableScreen/elements/KeyboardAvoidingViewElement.js +11 -0
- package/dist/steps/ComposableScreen/elements/KeyboardAvoidingViewElement.js.map +1 -0
- package/dist/steps/ComposableScreen/elements/ScrollViewElement.d.ts +108 -0
- package/dist/steps/ComposableScreen/elements/ScrollViewElement.d.ts.map +1 -0
- package/dist/steps/ComposableScreen/elements/ScrollViewElement.js +23 -0
- package/dist/steps/ComposableScreen/elements/ScrollViewElement.js.map +1 -0
- package/dist/steps/ComposableScreen/types.d.ts +18 -0
- package/dist/steps/ComposableScreen/types.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/types.js +52 -1
- package/dist/steps/ComposableScreen/types.js.map +1 -1
- package/package.json +1 -1
- package/src/onboarding-example.ts +94 -8
- package/src/steps/ComposableScreen/elements/KeyboardAvoidingViewElement.ts +16 -0
- package/src/steps/ComposableScreen/elements/ScrollViewElement.ts +40 -0
- package/src/steps/ComposableScreen/types.ts +84 -3
|
@@ -168,16 +168,102 @@ export const onboardingExample = {
|
|
|
168
168
|
},
|
|
169
169
|
},
|
|
170
170
|
{
|
|
171
|
-
id: "
|
|
172
|
-
type: "
|
|
171
|
+
id: "kav-input",
|
|
172
|
+
type: "KeyboardAvoidingView",
|
|
173
|
+
props: { keyboardVerticalOffset: 24 },
|
|
174
|
+
children: [
|
|
175
|
+
{
|
|
176
|
+
id: "hero-input",
|
|
177
|
+
type: "Input",
|
|
178
|
+
props: {
|
|
179
|
+
variableName: "name",
|
|
180
|
+
placeholder: "Enter your name",
|
|
181
|
+
keyboardType: "default",
|
|
182
|
+
returnKeyType: "done",
|
|
183
|
+
autoCapitalize: "words",
|
|
184
|
+
marginVertical: 8,
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
id: "scroll-demo",
|
|
191
|
+
type: "ScrollView",
|
|
173
192
|
props: {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
returnKeyType: "done",
|
|
178
|
-
autoCapitalize: "words",
|
|
179
|
-
marginVertical: 8,
|
|
193
|
+
horizontal: true,
|
|
194
|
+
showsHorizontalScrollIndicator: false,
|
|
195
|
+
contentContainerPadding: 4,
|
|
180
196
|
},
|
|
197
|
+
children: [
|
|
198
|
+
{
|
|
199
|
+
id: "scroll-card-1",
|
|
200
|
+
type: "Text",
|
|
201
|
+
props: {
|
|
202
|
+
content: "Card 1",
|
|
203
|
+
width: 160,
|
|
204
|
+
height: 100,
|
|
205
|
+
marginHorizontal: 6,
|
|
206
|
+
borderWidth: 1,
|
|
207
|
+
borderRadius: 12,
|
|
208
|
+
borderColor: "#00000020",
|
|
209
|
+
paddingVertical: 38,
|
|
210
|
+
textAlign: "center",
|
|
211
|
+
fontSize: 16,
|
|
212
|
+
fontWeight: "600",
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
id: "scroll-card-2",
|
|
217
|
+
type: "Text",
|
|
218
|
+
props: {
|
|
219
|
+
content: "Card 2",
|
|
220
|
+
width: 160,
|
|
221
|
+
height: 100,
|
|
222
|
+
marginHorizontal: 6,
|
|
223
|
+
borderWidth: 1,
|
|
224
|
+
borderRadius: 12,
|
|
225
|
+
borderColor: "#00000020",
|
|
226
|
+
paddingVertical: 38,
|
|
227
|
+
textAlign: "center",
|
|
228
|
+
fontSize: 16,
|
|
229
|
+
fontWeight: "600",
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
id: "scroll-card-3",
|
|
234
|
+
type: "Text",
|
|
235
|
+
props: {
|
|
236
|
+
content: "Card 3",
|
|
237
|
+
width: 160,
|
|
238
|
+
height: 100,
|
|
239
|
+
marginHorizontal: 6,
|
|
240
|
+
borderWidth: 1,
|
|
241
|
+
borderRadius: 12,
|
|
242
|
+
borderColor: "#00000020",
|
|
243
|
+
paddingVertical: 38,
|
|
244
|
+
textAlign: "center",
|
|
245
|
+
fontSize: 16,
|
|
246
|
+
fontWeight: "600",
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
id: "scroll-card-4",
|
|
251
|
+
type: "Text",
|
|
252
|
+
props: {
|
|
253
|
+
content: "Card 4",
|
|
254
|
+
width: 160,
|
|
255
|
+
height: 100,
|
|
256
|
+
marginHorizontal: 6,
|
|
257
|
+
borderWidth: 1,
|
|
258
|
+
borderRadius: 12,
|
|
259
|
+
borderColor: "#00000020",
|
|
260
|
+
paddingVertical: 38,
|
|
261
|
+
textAlign: "center",
|
|
262
|
+
fontSize: 16,
|
|
263
|
+
fontWeight: "600",
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
],
|
|
181
267
|
},
|
|
182
268
|
{
|
|
183
269
|
id: "greeting",
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { BaseBoxPropsSchema, type BaseBoxProps } from "./BaseBoxProps";
|
|
3
|
+
|
|
4
|
+
export type KeyboardAvoidingBehavior = "padding" | "height" | "position";
|
|
5
|
+
|
|
6
|
+
export type KeyboardAvoidingViewElementProps = BaseBoxProps & {
|
|
7
|
+
behavior?: KeyboardAvoidingBehavior;
|
|
8
|
+
keyboardVerticalOffset?: number;
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const KeyboardAvoidingViewElementPropsSchema = BaseBoxPropsSchema.extend({
|
|
13
|
+
behavior: z.enum(["padding", "height", "position"]).optional(),
|
|
14
|
+
keyboardVerticalOffset: z.number().optional(),
|
|
15
|
+
enabled: z.boolean().optional(),
|
|
16
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { BaseBoxPropsSchema, type BaseBoxProps } from "./BaseBoxProps";
|
|
3
|
+
|
|
4
|
+
export type ScrollViewContentInset = {
|
|
5
|
+
top?: number;
|
|
6
|
+
right?: number;
|
|
7
|
+
bottom?: number;
|
|
8
|
+
left?: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type ScrollViewElementProps = BaseBoxProps & {
|
|
12
|
+
horizontal?: boolean;
|
|
13
|
+
bounces?: boolean;
|
|
14
|
+
showsVerticalScrollIndicator?: boolean;
|
|
15
|
+
showsHorizontalScrollIndicator?: boolean;
|
|
16
|
+
alwaysBounceVertical?: boolean;
|
|
17
|
+
alwaysBounceHorizontal?: boolean;
|
|
18
|
+
contentInset?: ScrollViewContentInset;
|
|
19
|
+
contentContainerPadding?: number;
|
|
20
|
+
keyboardShouldPersistTaps?: "always" | "never" | "handled";
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const ContentInsetSchema = z.object({
|
|
24
|
+
top: z.number().optional(),
|
|
25
|
+
right: z.number().optional(),
|
|
26
|
+
bottom: z.number().optional(),
|
|
27
|
+
left: z.number().optional(),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const ScrollViewElementPropsSchema = BaseBoxPropsSchema.extend({
|
|
31
|
+
horizontal: z.boolean().optional(),
|
|
32
|
+
bounces: z.boolean().optional(),
|
|
33
|
+
showsVerticalScrollIndicator: z.boolean().optional(),
|
|
34
|
+
showsHorizontalScrollIndicator: z.boolean().optional(),
|
|
35
|
+
alwaysBounceVertical: z.boolean().optional(),
|
|
36
|
+
alwaysBounceHorizontal: z.boolean().optional(),
|
|
37
|
+
contentInset: ContentInsetSchema.optional(),
|
|
38
|
+
contentContainerPadding: z.number().min(0).optional(),
|
|
39
|
+
keyboardShouldPersistTaps: z.enum(["always", "never", "handled"]).optional(),
|
|
40
|
+
});
|
|
@@ -21,6 +21,11 @@ import { type DatePickerElementProps, DatePickerElementPropsSchema } from "./ele
|
|
|
21
21
|
import { type CarouselElementProps, CarouselElementPropsSchema } from "./elements/CarouselElement";
|
|
22
22
|
import { type ZStackElementProps, ZStackElementPropsSchema } from "./elements/ZStackElement";
|
|
23
23
|
import { type SafeAreaViewElementProps, SafeAreaViewElementPropsSchema } from "./elements/SafeAreaViewElement";
|
|
24
|
+
import { type ScrollViewElementProps, ScrollViewElementPropsSchema } from "./elements/ScrollViewElement";
|
|
25
|
+
import {
|
|
26
|
+
type KeyboardAvoidingViewElementProps,
|
|
27
|
+
KeyboardAvoidingViewElementPropsSchema,
|
|
28
|
+
} from "./elements/KeyboardAvoidingViewElement";
|
|
24
29
|
|
|
25
30
|
export type { BaseBoxProps, GradientBackground, GradientEdge, GradientStop, LinearGradientConfig } from "./elements/BaseBoxProps";
|
|
26
31
|
export { BaseBoxPropsSchema, GradientBackgroundSchema } from "./elements/BaseBoxProps";
|
|
@@ -40,6 +45,11 @@ export type { DatePickerElementProps } from "./elements/DatePickerElement";
|
|
|
40
45
|
export type { CarouselElementProps } from "./elements/CarouselElement";
|
|
41
46
|
export type { ZStackElementProps } from "./elements/ZStackElement";
|
|
42
47
|
export type { SafeAreaViewElementProps, SafeAreaEdge, SafeAreaEdgeMode } from "./elements/SafeAreaViewElement";
|
|
48
|
+
export type { ScrollViewElementProps, ScrollViewContentInset } from "./elements/ScrollViewElement";
|
|
49
|
+
export type {
|
|
50
|
+
KeyboardAvoidingViewElementProps,
|
|
51
|
+
KeyboardAvoidingBehavior,
|
|
52
|
+
} from "./elements/KeyboardAvoidingViewElement";
|
|
43
53
|
|
|
44
54
|
/**
|
|
45
55
|
* Type tag for a ComposableScreen variable. Drives expression-mode coercion
|
|
@@ -169,6 +179,22 @@ type UIElement =
|
|
|
169
179
|
type: "SafeAreaView";
|
|
170
180
|
props: SafeAreaViewElementProps;
|
|
171
181
|
children: UIElement[];
|
|
182
|
+
}
|
|
183
|
+
| {
|
|
184
|
+
id: string;
|
|
185
|
+
name?: string;
|
|
186
|
+
renderWhen?: LeafCondition | ConditionGroup;
|
|
187
|
+
type: "ScrollView";
|
|
188
|
+
props: ScrollViewElementProps;
|
|
189
|
+
children: UIElement[];
|
|
190
|
+
}
|
|
191
|
+
| {
|
|
192
|
+
id: string;
|
|
193
|
+
name?: string;
|
|
194
|
+
renderWhen?: LeafCondition | ConditionGroup;
|
|
195
|
+
type: "KeyboardAvoidingView";
|
|
196
|
+
props: KeyboardAvoidingViewElementProps;
|
|
197
|
+
children: UIElement[];
|
|
172
198
|
};
|
|
173
199
|
|
|
174
200
|
const UIElementSchema: z.ZodType<UIElement> = z.lazy(() =>
|
|
@@ -282,12 +308,67 @@ const UIElementSchema: z.ZodType<UIElement> = z.lazy(() =>
|
|
|
282
308
|
props: SafeAreaViewElementPropsSchema,
|
|
283
309
|
children: z.array(UIElementSchema),
|
|
284
310
|
}),
|
|
311
|
+
z.object({
|
|
312
|
+
id: z.string(),
|
|
313
|
+
name: z.string().optional(),
|
|
314
|
+
renderWhen: z.union([LeafConditionSchema, ConditionGroupSchema]).optional(),
|
|
315
|
+
type: z.literal("ScrollView"),
|
|
316
|
+
props: ScrollViewElementPropsSchema,
|
|
317
|
+
children: z.array(UIElementSchema),
|
|
318
|
+
}),
|
|
319
|
+
z.object({
|
|
320
|
+
id: z.string(),
|
|
321
|
+
name: z.string().optional(),
|
|
322
|
+
renderWhen: z.union([LeafConditionSchema, ConditionGroupSchema]).optional(),
|
|
323
|
+
type: z.literal("KeyboardAvoidingView"),
|
|
324
|
+
props: KeyboardAvoidingViewElementPropsSchema,
|
|
325
|
+
children: z.array(UIElementSchema),
|
|
326
|
+
}),
|
|
285
327
|
])
|
|
286
328
|
);
|
|
287
329
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
330
|
+
// Walk a UIElement tree; flag any KeyboardAvoidingView descendant of another KeyboardAvoidingView.
|
|
331
|
+
// RN behavior is undefined when a KAV nests another; KAV adjusts the layout of the host view, and
|
|
332
|
+
// stacking adjusters produces drift and clip artifacts on iOS + double height insets on Android.
|
|
333
|
+
const collectNestedKeyboardAvoidingViews = (
|
|
334
|
+
nodes: UIElement[],
|
|
335
|
+
insideKav: boolean,
|
|
336
|
+
out: string[]
|
|
337
|
+
): void => {
|
|
338
|
+
for (const node of nodes) {
|
|
339
|
+
if (node.type === "KeyboardAvoidingView") {
|
|
340
|
+
if (insideKav) out.push(node.id);
|
|
341
|
+
collectNestedKeyboardAvoidingViews(node.children, true, out);
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
if (
|
|
345
|
+
node.type === "YStack" ||
|
|
346
|
+
node.type === "XStack" ||
|
|
347
|
+
node.type === "ZStack" ||
|
|
348
|
+
node.type === "SafeAreaView" ||
|
|
349
|
+
node.type === "ScrollView" ||
|
|
350
|
+
node.type === "Carousel"
|
|
351
|
+
) {
|
|
352
|
+
collectNestedKeyboardAvoidingViews(node.children, insideKav, out);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
export const ComposableScreenStepPayloadSchema = z
|
|
358
|
+
.object({
|
|
359
|
+
elements: z.array(UIElementSchema),
|
|
360
|
+
})
|
|
361
|
+
.superRefine((payload, ctx) => {
|
|
362
|
+
const offenders: string[] = [];
|
|
363
|
+
collectNestedKeyboardAvoidingViews(payload.elements, false, offenders);
|
|
364
|
+
for (const id of offenders) {
|
|
365
|
+
ctx.addIssue({
|
|
366
|
+
code: z.ZodIssueCode.custom,
|
|
367
|
+
path: ["elements"],
|
|
368
|
+
message: `KeyboardAvoidingView (id="${id}") cannot be nested inside another KeyboardAvoidingView.`,
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
});
|
|
291
372
|
|
|
292
373
|
export const ComposableScreenStepTypeSchema = BaseStepTypeSchema.extend({
|
|
293
374
|
type: z.literal("ComposableScreen"),
|