@rocapine/react-native-onboarding 1.23.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 +724 -139
- package/dist/onboarding-example.d.ts.map +1 -1
- package/dist/onboarding-example.js +171 -8
- package/dist/onboarding-example.js.map +1 -1
- package/dist/steps/ComposableScreen/elements/BaseBoxProps.d.ts +21 -0
- package/dist/steps/ComposableScreen/elements/BaseBoxProps.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/BaseBoxProps.js +10 -1
- package/dist/steps/ComposableScreen/elements/BaseBoxProps.js.map +1 -1
- package/dist/steps/ComposableScreen/elements/ButtonElement.d.ts +294 -2
- package/dist/steps/ComposableScreen/elements/ButtonElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/ButtonElement.js +14 -1
- package/dist/steps/ComposableScreen/elements/ButtonElement.js.map +1 -1
- package/dist/steps/ComposableScreen/elements/CarouselElement.d.ts +8 -0
- package/dist/steps/ComposableScreen/elements/CarouselElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/CheckboxGroupElement.d.ts +8 -0
- package/dist/steps/ComposableScreen/elements/CheckboxGroupElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/DatePickerElement.d.ts +8 -0
- package/dist/steps/ComposableScreen/elements/DatePickerElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/IconElement.d.ts +8 -0
- package/dist/steps/ComposableScreen/elements/IconElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/ImageElement.d.ts +8 -0
- package/dist/steps/ComposableScreen/elements/ImageElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/InputElement.d.ts +8 -0
- package/dist/steps/ComposableScreen/elements/InputElement.d.ts.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/LottieElement.d.ts +8 -0
- package/dist/steps/ComposableScreen/elements/LottieElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/RadioGroupElement.d.ts +8 -0
- package/dist/steps/ComposableScreen/elements/RadioGroupElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/RiveElement.d.ts +8 -0
- package/dist/steps/ComposableScreen/elements/RiveElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/SafeAreaViewElement.d.ts +8 -0
- package/dist/steps/ComposableScreen/elements/SafeAreaViewElement.d.ts.map +1 -1
- 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/elements/StackElement.d.ts +8 -0
- package/dist/steps/ComposableScreen/elements/StackElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/TextElement.d.ts +8 -0
- package/dist/steps/ComposableScreen/elements/TextElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/VideoElement.d.ts +8 -0
- package/dist/steps/ComposableScreen/elements/VideoElement.d.ts.map +1 -1
- package/dist/steps/ComposableScreen/elements/ZStackElement.d.ts +8 -0
- package/dist/steps/ComposableScreen/elements/ZStackElement.d.ts.map +1 -1
- 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 +171 -8
- package/src/steps/ComposableScreen/elements/BaseBoxProps.ts +20 -0
- package/src/steps/ComposableScreen/elements/ButtonElement.ts +36 -2
- 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",
|
|
@@ -545,6 +631,67 @@ export const onboardingExample = {
|
|
|
545
631
|
},
|
|
546
632
|
},
|
|
547
633
|
},
|
|
634
|
+
{
|
|
635
|
+
id: "states-heading",
|
|
636
|
+
type: "Text",
|
|
637
|
+
props: {
|
|
638
|
+
content: "Button states & shadow",
|
|
639
|
+
fontSize: 13,
|
|
640
|
+
fontWeight: "700",
|
|
641
|
+
marginVertical: 4,
|
|
642
|
+
opacity: 0.5,
|
|
643
|
+
},
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
id: "btn-shadow",
|
|
647
|
+
type: "Button",
|
|
648
|
+
props: {
|
|
649
|
+
label: "Elevated (shadow)",
|
|
650
|
+
variant: "filled",
|
|
651
|
+
marginVertical: 4,
|
|
652
|
+
backgroundColor: "#6C63FF",
|
|
653
|
+
shadowColor: "#6C63FF",
|
|
654
|
+
shadowOffset: { width: 0, height: 6 },
|
|
655
|
+
shadowOpacity: 0.4,
|
|
656
|
+
shadowRadius: 12,
|
|
657
|
+
elevation: 8,
|
|
658
|
+
},
|
|
659
|
+
},
|
|
660
|
+
{
|
|
661
|
+
id: "btn-pressed",
|
|
662
|
+
type: "Button",
|
|
663
|
+
props: {
|
|
664
|
+
label: "Press me (hold)",
|
|
665
|
+
variant: "filled",
|
|
666
|
+
marginVertical: 4,
|
|
667
|
+
backgroundColor: "#10b981",
|
|
668
|
+
transitionDurationMs: 300,
|
|
669
|
+
pressedStyle: {
|
|
670
|
+
opacity: 0.6,
|
|
671
|
+
backgroundColor: "#065f46",
|
|
672
|
+
},
|
|
673
|
+
},
|
|
674
|
+
},
|
|
675
|
+
{
|
|
676
|
+
id: "btn-disabled",
|
|
677
|
+
type: "Button",
|
|
678
|
+
props: {
|
|
679
|
+
label: "Always disabled",
|
|
680
|
+
variant: "filled",
|
|
681
|
+
marginVertical: 4,
|
|
682
|
+
actions: ["continue"],
|
|
683
|
+
disabledWhen: {
|
|
684
|
+
variable: "never_enabled",
|
|
685
|
+
operator: "neq",
|
|
686
|
+
value: "yes",
|
|
687
|
+
},
|
|
688
|
+
disabledStyle: {
|
|
689
|
+
backgroundColor: "#fee2e2",
|
|
690
|
+
color: "#b91c1c",
|
|
691
|
+
borderRadius: 12,
|
|
692
|
+
},
|
|
693
|
+
},
|
|
694
|
+
},
|
|
548
695
|
{
|
|
549
696
|
id: "consent-toggle",
|
|
550
697
|
type: "Button",
|
|
@@ -570,6 +717,22 @@ export const onboardingExample = {
|
|
|
570
717
|
operator: "neq",
|
|
571
718
|
value: "yes",
|
|
572
719
|
},
|
|
720
|
+
transitionDurationMs: 180,
|
|
721
|
+
shadowColor: "#000",
|
|
722
|
+
shadowOffset: { width: 0, height: 4 },
|
|
723
|
+
shadowOpacity: 0.18,
|
|
724
|
+
shadowRadius: 8,
|
|
725
|
+
elevation: 4,
|
|
726
|
+
pressedStyle: {
|
|
727
|
+
opacity: 0.7,
|
|
728
|
+
backgroundColor: "#4f46e5",
|
|
729
|
+
},
|
|
730
|
+
disabledStyle: {
|
|
731
|
+
backgroundColor: "#d1d5db",
|
|
732
|
+
color: "#6b7280",
|
|
733
|
+
shadowOpacity: 0,
|
|
734
|
+
elevation: 0,
|
|
735
|
+
},
|
|
573
736
|
},
|
|
574
737
|
},
|
|
575
738
|
],
|
|
@@ -40,6 +40,16 @@ export const GradientBackgroundSchema = z.discriminatedUnion("type", [
|
|
|
40
40
|
}),
|
|
41
41
|
]);
|
|
42
42
|
|
|
43
|
+
export type ShadowOffset = {
|
|
44
|
+
width: number;
|
|
45
|
+
height: number;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const ShadowOffsetSchema = z.object({
|
|
49
|
+
width: z.number(),
|
|
50
|
+
height: z.number(),
|
|
51
|
+
});
|
|
52
|
+
|
|
43
53
|
export type BaseBoxProps = {
|
|
44
54
|
width?: number | string;
|
|
45
55
|
height?: number | string;
|
|
@@ -64,6 +74,11 @@ export type BaseBoxProps = {
|
|
|
64
74
|
borderWidth?: number;
|
|
65
75
|
borderRadius?: number;
|
|
66
76
|
borderColor?: string;
|
|
77
|
+
shadowColor?: string;
|
|
78
|
+
shadowOffset?: ShadowOffset;
|
|
79
|
+
shadowOpacity?: number;
|
|
80
|
+
shadowRadius?: number;
|
|
81
|
+
elevation?: number;
|
|
67
82
|
};
|
|
68
83
|
|
|
69
84
|
export const BaseBoxPropsSchema = z.object({
|
|
@@ -90,4 +105,9 @@ export const BaseBoxPropsSchema = z.object({
|
|
|
90
105
|
borderWidth: z.number().min(0).optional(),
|
|
91
106
|
borderRadius: z.number().min(0).optional(),
|
|
92
107
|
borderColor: z.string().optional(),
|
|
108
|
+
shadowColor: z.string().optional(),
|
|
109
|
+
shadowOffset: ShadowOffsetSchema.optional(),
|
|
110
|
+
shadowOpacity: z.number().min(0).max(1).optional(),
|
|
111
|
+
shadowRadius: z.number().min(0).optional(),
|
|
112
|
+
elevation: z.number().min(0).optional(),
|
|
93
113
|
});
|
|
@@ -26,6 +26,20 @@ export const ButtonActionSchema = z.union([
|
|
|
26
26
|
CustomButtonActionSchema,
|
|
27
27
|
]);
|
|
28
28
|
|
|
29
|
+
type ButtonOverridableProps = BaseBoxProps & {
|
|
30
|
+
variant?: "filled" | "outlined" | "ghost";
|
|
31
|
+
backgroundColor?: string;
|
|
32
|
+
color?: string;
|
|
33
|
+
fontSize?: number;
|
|
34
|
+
fontWeight?: string;
|
|
35
|
+
fontFamily?: string | "inherit";
|
|
36
|
+
fontStyle?: "normal" | "italic";
|
|
37
|
+
textAlign?: "left" | "center" | "right";
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** Subset of ButtonElementProps that can be overridden per-state. */
|
|
41
|
+
export type ButtonStyleOverride = Partial<ButtonOverridableProps>;
|
|
42
|
+
|
|
29
43
|
export type ButtonElementProps = BaseBoxProps & {
|
|
30
44
|
label: string;
|
|
31
45
|
/**
|
|
@@ -56,12 +70,29 @@ export type ButtonElementProps = BaseBoxProps & {
|
|
|
56
70
|
* the same condition schema as `Branch.condition`.
|
|
57
71
|
*/
|
|
58
72
|
disabledWhen?: LeafCondition | ConditionGroup;
|
|
59
|
-
/**
|
|
73
|
+
/** @deprecated Use `disabledStyle.backgroundColor`. Falls back when `disabledStyle` omitted. */
|
|
60
74
|
disabledBackgroundColor?: string;
|
|
61
|
-
/**
|
|
75
|
+
/** @deprecated Use `disabledStyle.color`. Falls back when `disabledStyle` omitted. */
|
|
62
76
|
disabledColor?: string;
|
|
77
|
+
/** Style overrides merged on top of base props while pressed. */
|
|
78
|
+
pressedStyle?: ButtonStyleOverride;
|
|
79
|
+
/** Style overrides merged on top of base props while disabled. Wins over deprecated `disabled*` fields. */
|
|
80
|
+
disabledStyle?: ButtonStyleOverride;
|
|
81
|
+
/** Animation duration (ms) between rest/pressed/disabled. Default 150. */
|
|
82
|
+
transitionDurationMs?: number;
|
|
63
83
|
};
|
|
64
84
|
|
|
85
|
+
export const ButtonStyleOverrideSchema = BaseBoxPropsSchema.extend({
|
|
86
|
+
variant: z.enum(["filled", "outlined", "ghost"]).optional(),
|
|
87
|
+
backgroundColor: z.string().optional(),
|
|
88
|
+
color: z.string().optional(),
|
|
89
|
+
fontSize: z.number().optional(),
|
|
90
|
+
fontWeight: z.string().optional(),
|
|
91
|
+
fontFamily: z.string().optional(),
|
|
92
|
+
fontStyle: z.enum(["normal", "italic"]).optional(),
|
|
93
|
+
textAlign: z.enum(["left", "center", "right"]).optional(),
|
|
94
|
+
}).partial();
|
|
95
|
+
|
|
65
96
|
export const ButtonElementPropsSchema = BaseBoxPropsSchema.extend({
|
|
66
97
|
label: z.string().min(1, "label must not be empty"),
|
|
67
98
|
actions: z.array(ButtonActionSchema).optional(),
|
|
@@ -77,4 +108,7 @@ export const ButtonElementPropsSchema = BaseBoxPropsSchema.extend({
|
|
|
77
108
|
disabledWhen: z.union([LeafConditionSchema, ConditionGroupSchema]).optional(),
|
|
78
109
|
disabledBackgroundColor: z.string().optional(),
|
|
79
110
|
disabledColor: z.string().optional(),
|
|
111
|
+
pressedStyle: ButtonStyleOverrideSchema.optional(),
|
|
112
|
+
disabledStyle: ButtonStyleOverrideSchema.optional(),
|
|
113
|
+
transitionDurationMs: z.number().min(0).optional(),
|
|
80
114
|
});
|
|
@@ -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"),
|