@rocapine/react-native-onboarding-ui 1.9.0 → 1.11.1
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/UI/Pages/ComposableScreen/elements/BaseBoxProps.d.ts +26 -4
- package/dist/UI/Pages/ComposableScreen/elements/BaseBoxProps.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/BaseBoxProps.js +11 -2
- package/dist/UI/Pages/ComposableScreen/elements/BaseBoxProps.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ButtonElement.d.ts +22 -10
- package/dist/UI/Pages/ComposableScreen/elements/ButtonElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ButtonElement.js +3 -3
- package/dist/UI/Pages/ComposableScreen/elements/ButtonElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/CarouselElement.d.ts +79 -0
- package/dist/UI/Pages/ComposableScreen/elements/CarouselElement.d.ts.map +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/CarouselElement.js +133 -0
- package/dist/UI/Pages/ComposableScreen/elements/CarouselElement.js.map +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/CheckboxGroupElement.d.ts +16 -3
- package/dist/UI/Pages/ComposableScreen/elements/CheckboxGroupElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/CheckboxGroupElement.js +3 -2
- package/dist/UI/Pages/ComposableScreen/elements/CheckboxGroupElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/DatePickerElement.d.ts +81 -0
- package/dist/UI/Pages/ComposableScreen/elements/DatePickerElement.d.ts.map +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/DatePickerElement.js +121 -0
- package/dist/UI/Pages/ComposableScreen/elements/DatePickerElement.js.map +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/IconElement.d.ts +14 -2
- package/dist/UI/Pages/ComposableScreen/elements/IconElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/IconElement.js +12 -2
- package/dist/UI/Pages/ComposableScreen/elements/IconElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ImageElement.d.ts +15 -2
- package/dist/UI/Pages/ComposableScreen/elements/ImageElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/ImageElement.js +15 -7
- package/dist/UI/Pages/ComposableScreen/elements/ImageElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/InputElement.d.ts +20 -2
- package/dist/UI/Pages/ComposableScreen/elements/InputElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/InputElement.js +17 -2
- package/dist/UI/Pages/ComposableScreen/elements/InputElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/LottieElement.d.ts +15 -2
- package/dist/UI/Pages/ComposableScreen/elements/LottieElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/LottieElement.js +12 -2
- package/dist/UI/Pages/ComposableScreen/elements/LottieElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/RadioGroupElement.d.ts +15 -2
- package/dist/UI/Pages/ComposableScreen/elements/RadioGroupElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/RadioGroupElement.js +3 -2
- package/dist/UI/Pages/ComposableScreen/elements/RadioGroupElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/RiveElement.d.ts +17 -4
- package/dist/UI/Pages/ComposableScreen/elements/RiveElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/RiveElement.js +25 -14
- package/dist/UI/Pages/ComposableScreen/elements/RiveElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/StackElement.d.ts +28 -47
- package/dist/UI/Pages/ComposableScreen/elements/StackElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/StackElement.js +30 -47
- package/dist/UI/Pages/ComposableScreen/elements/StackElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/TextElement.d.ts +35 -23
- package/dist/UI/Pages/ComposableScreen/elements/TextElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/TextElement.js +35 -35
- package/dist/UI/Pages/ComposableScreen/elements/TextElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/VideoElement.d.ts +15 -2
- package/dist/UI/Pages/ComposableScreen/elements/VideoElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/VideoElement.js +12 -2
- package/dist/UI/Pages/ComposableScreen/elements/VideoElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/renderElement.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/renderElement.js +8 -0
- package/dist/UI/Pages/ComposableScreen/elements/renderElement.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/shared.d.ts +1 -0
- package/dist/UI/Pages/ComposableScreen/elements/shared.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/elements/shared.js +4 -1
- package/dist/UI/Pages/ComposableScreen/elements/shared.js.map +1 -1
- package/dist/UI/Pages/ComposableScreen/types.d.ts +15 -0
- package/dist/UI/Pages/ComposableScreen/types.d.ts.map +1 -1
- package/dist/UI/Pages/ComposableScreen/types.js +15 -0
- package/dist/UI/Pages/ComposableScreen/types.js.map +1 -1
- package/package.json +11 -4
- package/src/UI/Pages/ComposableScreen/elements/BaseBoxProps.ts +22 -4
- package/src/UI/Pages/ComposableScreen/elements/ButtonElement.tsx +3 -5
- package/src/UI/Pages/ComposableScreen/elements/CarouselElement.tsx +152 -0
- package/src/UI/Pages/ComposableScreen/elements/CheckboxGroupElement.tsx +3 -3
- package/src/UI/Pages/ComposableScreen/elements/DatePickerElement.tsx +172 -0
- package/src/UI/Pages/ComposableScreen/elements/IconElement.tsx +12 -3
- package/src/UI/Pages/ComposableScreen/elements/ImageElement.tsx +16 -8
- package/src/UI/Pages/ComposableScreen/elements/InputElement.tsx +20 -3
- package/src/UI/Pages/ComposableScreen/elements/LottieElement.tsx +12 -3
- package/src/UI/Pages/ComposableScreen/elements/RadioGroupElement.tsx +3 -3
- package/src/UI/Pages/ComposableScreen/elements/RiveElement.tsx +26 -16
- package/src/UI/Pages/ComposableScreen/elements/StackElement.tsx +31 -70
- package/src/UI/Pages/ComposableScreen/elements/TextElement.tsx +36 -47
- package/src/UI/Pages/ComposableScreen/elements/VideoElement.tsx +12 -3
- package/src/UI/Pages/ComposableScreen/elements/renderElement.tsx +10 -0
- package/src/UI/Pages/ComposableScreen/elements/shared.ts +4 -0
- package/src/UI/Pages/ComposableScreen/types.ts +30 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { Pressable, Text, View, Platform } from "react-native";
|
|
3
|
+
import DateTimePicker, { DateTimePickerEvent } from "@react-native-community/datetimepicker";
|
|
4
|
+
import { BaseBoxProps, BaseBoxPropsSchema } from "./BaseBoxProps";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import type { UIElement } from "../types";
|
|
7
|
+
import { dim, type RenderContext } from "./shared";
|
|
8
|
+
|
|
9
|
+
export type DatePickerElementProps = BaseBoxProps & {
|
|
10
|
+
variableName?: string;
|
|
11
|
+
defaultValue?: string;
|
|
12
|
+
minimumDate?: string;
|
|
13
|
+
maximumDate?: string;
|
|
14
|
+
mode?: "date" | "time" | "datetime";
|
|
15
|
+
display?: "default" | "spinner" | "calendar" | "clock" | "compact" | "inline";
|
|
16
|
+
textColor?: string;
|
|
17
|
+
accentColor?: string;
|
|
18
|
+
locale?: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const DatePickerElementPropsSchema = BaseBoxPropsSchema.extend({
|
|
22
|
+
variableName: z.string().min(1).optional(),
|
|
23
|
+
defaultValue: z.string().refine((s) => !isNaN(Date.parse(s)), { message: "Invalid date string" }).optional(),
|
|
24
|
+
minimumDate: z.string().refine((s) => !isNaN(Date.parse(s)), { message: "Invalid date string" }).optional(),
|
|
25
|
+
maximumDate: z.string().refine((s) => !isNaN(Date.parse(s)), { message: "Invalid date string" }).optional(),
|
|
26
|
+
mode: z.enum(["date", "time", "datetime"]).optional().default("date"),
|
|
27
|
+
display: z.enum(["default", "spinner", "calendar", "clock", "compact", "inline"]).optional(),
|
|
28
|
+
textColor: z.string().optional(),
|
|
29
|
+
accentColor: z.string().optional(),
|
|
30
|
+
locale: z.string().optional(),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
type DatePickerUIElement = Extract<UIElement, { type: "DatePicker" }>;
|
|
34
|
+
|
|
35
|
+
type Props = {
|
|
36
|
+
element: DatePickerUIElement;
|
|
37
|
+
ctx: RenderContext;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
function formatDate(date: Date, mode: "date" | "time" | "datetime"): string {
|
|
41
|
+
if (mode === "time") {
|
|
42
|
+
return date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
43
|
+
}
|
|
44
|
+
if (mode === "datetime") {
|
|
45
|
+
return date.toLocaleString([], { dateStyle: "medium", timeStyle: "short" });
|
|
46
|
+
}
|
|
47
|
+
return date.toLocaleDateString([], { dateStyle: "medium" });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const DatePickerElementComponent = ({ element, ctx }: Props): React.ReactElement => {
|
|
51
|
+
const { theme, variables, setVariable } = ctx;
|
|
52
|
+
const { props } = element;
|
|
53
|
+
|
|
54
|
+
const persistedValue = props.variableName ? variables[props.variableName]?.value : undefined;
|
|
55
|
+
const initialDate = persistedValue
|
|
56
|
+
? new Date(persistedValue)
|
|
57
|
+
: props.defaultValue
|
|
58
|
+
? new Date(props.defaultValue)
|
|
59
|
+
: new Date();
|
|
60
|
+
|
|
61
|
+
const [date, setDate] = useState<Date>(initialDate);
|
|
62
|
+
const [isPickerVisible, setPickerVisible] = useState(false);
|
|
63
|
+
const mode = props.mode ?? "date";
|
|
64
|
+
|
|
65
|
+
// Tracks which variableName has been seeded so re-renders don't clobber a
|
|
66
|
+
// persisted value that arrived after the first render.
|
|
67
|
+
const seededVariableRef = useRef<string | undefined>(undefined);
|
|
68
|
+
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (
|
|
71
|
+
props.variableName &&
|
|
72
|
+
persistedValue === undefined &&
|
|
73
|
+
seededVariableRef.current !== props.variableName
|
|
74
|
+
) {
|
|
75
|
+
seededVariableRef.current = props.variableName;
|
|
76
|
+
setVariable(props.variableName, {
|
|
77
|
+
value: initialDate.toISOString(),
|
|
78
|
+
label: formatDate(initialDate, mode),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}, [props.variableName, persistedValue, initialDate, mode, setVariable]);
|
|
82
|
+
|
|
83
|
+
const handleChange = (_event: DateTimePickerEvent, selected?: Date) => {
|
|
84
|
+
if (!selected) return;
|
|
85
|
+
setDate(selected);
|
|
86
|
+
if (props.variableName) {
|
|
87
|
+
setVariable(props.variableName, {
|
|
88
|
+
value: selected.toISOString(),
|
|
89
|
+
label: formatDate(selected, mode),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const containerStyle = {
|
|
95
|
+
alignSelf: props.alignSelf,
|
|
96
|
+
width: dim(props.width),
|
|
97
|
+
height: dim(props.height),
|
|
98
|
+
margin: props.margin,
|
|
99
|
+
marginHorizontal: props.marginHorizontal,
|
|
100
|
+
marginVertical: props.marginVertical,
|
|
101
|
+
padding: props.padding,
|
|
102
|
+
paddingHorizontal: props.paddingHorizontal,
|
|
103
|
+
paddingVertical: props.paddingVertical,
|
|
104
|
+
opacity: props.opacity,
|
|
105
|
+
borderWidth: props.borderWidth,
|
|
106
|
+
borderRadius: props.borderRadius,
|
|
107
|
+
borderColor: props.borderColor,
|
|
108
|
+
overflow: "hidden" as const,
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const pickerProps = {
|
|
112
|
+
value: date,
|
|
113
|
+
mode,
|
|
114
|
+
onChange: handleChange,
|
|
115
|
+
minimumDate: props.minimumDate ? new Date(props.minimumDate) : undefined,
|
|
116
|
+
maximumDate: props.maximumDate ? new Date(props.maximumDate) : undefined,
|
|
117
|
+
// Fall back to theme tokens when CMS props are not provided.
|
|
118
|
+
textColor: props.textColor ?? theme.colors.text.primary,
|
|
119
|
+
accentColor: props.accentColor ?? theme.colors.primary,
|
|
120
|
+
locale: props.locale,
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
if (Platform.OS === "android") {
|
|
124
|
+
return (
|
|
125
|
+
<View style={containerStyle}>
|
|
126
|
+
<Pressable
|
|
127
|
+
onPress={() => setPickerVisible(true)}
|
|
128
|
+
style={{
|
|
129
|
+
flexDirection: "row",
|
|
130
|
+
alignItems: "center",
|
|
131
|
+
justifyContent: "space-between",
|
|
132
|
+
paddingVertical: 12,
|
|
133
|
+
paddingHorizontal: 16,
|
|
134
|
+
borderRadius: props.borderRadius ?? 8,
|
|
135
|
+
borderWidth: props.borderWidth ?? 1,
|
|
136
|
+
borderColor: props.borderColor ?? theme.colors.neutral.low,
|
|
137
|
+
backgroundColor: theme.colors.neutral.lowest,
|
|
138
|
+
}}
|
|
139
|
+
>
|
|
140
|
+
<Text
|
|
141
|
+
style={{
|
|
142
|
+
color: props.textColor ?? theme.colors.text.primary,
|
|
143
|
+
fontSize: theme.typography.textStyles.body.fontSize,
|
|
144
|
+
}}
|
|
145
|
+
>
|
|
146
|
+
{formatDate(date, mode)}
|
|
147
|
+
</Text>
|
|
148
|
+
<Text style={{ color: theme.colors.text.tertiary, fontSize: 16 }}>›</Text>
|
|
149
|
+
</Pressable>
|
|
150
|
+
{isPickerVisible && (
|
|
151
|
+
<DateTimePicker
|
|
152
|
+
{...pickerProps}
|
|
153
|
+
display={(props.display ?? "default") as any}
|
|
154
|
+
onChange={(event, selected) => {
|
|
155
|
+
setPickerVisible(false);
|
|
156
|
+
handleChange(event, selected);
|
|
157
|
+
}}
|
|
158
|
+
/>
|
|
159
|
+
)}
|
|
160
|
+
</View>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return (
|
|
165
|
+
<View style={containerStyle}>
|
|
166
|
+
<DateTimePicker
|
|
167
|
+
{...pickerProps}
|
|
168
|
+
display={(props.display ?? "spinner") as any}
|
|
169
|
+
/>
|
|
170
|
+
</View>
|
|
171
|
+
);
|
|
172
|
+
};
|
|
@@ -3,7 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
import { View } from "react-native";
|
|
4
4
|
import { BaseBoxProps, BaseBoxPropsSchema } from "./BaseBoxProps";
|
|
5
5
|
import { UIElement } from "../types";
|
|
6
|
-
import { RenderContext } from "./shared";
|
|
6
|
+
import { RenderContext, dim } from "./shared";
|
|
7
7
|
|
|
8
8
|
export type IconElementProps = BaseBoxProps & {
|
|
9
9
|
name: string;
|
|
@@ -40,8 +40,17 @@ export const IconElementComponent = ({ element, ctx }: Props): React.ReactElemen
|
|
|
40
40
|
return (
|
|
41
41
|
<View
|
|
42
42
|
style={{
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
flex: element.props.flex,
|
|
44
|
+
flexShrink: element.props.flexShrink,
|
|
45
|
+
flexGrow: element.props.flexGrow,
|
|
46
|
+
alignSelf: element.props.alignSelf,
|
|
47
|
+
width: dim(element.props.width),
|
|
48
|
+
height: dim(element.props.height),
|
|
49
|
+
minWidth: element.props.minWidth,
|
|
50
|
+
maxWidth: element.props.maxWidth,
|
|
51
|
+
minHeight: element.props.minHeight,
|
|
52
|
+
maxHeight: element.props.maxHeight,
|
|
53
|
+
overflow: element.props.overflow,
|
|
45
54
|
margin: element.props.margin,
|
|
46
55
|
marginHorizontal: element.props.marginHorizontal,
|
|
47
56
|
marginVertical: element.props.marginVertical,
|
|
@@ -3,7 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
import { Image } from "react-native";
|
|
4
4
|
import { BaseBoxProps, BaseBoxPropsSchema } from "./BaseBoxProps";
|
|
5
5
|
import { UIElement } from "../types";
|
|
6
|
-
import { RenderContext } from "./shared";
|
|
6
|
+
import { RenderContext, dim } from "./shared";
|
|
7
7
|
|
|
8
8
|
export type ImageElementProps = BaseBoxProps & {
|
|
9
9
|
url: string;
|
|
@@ -26,16 +26,24 @@ type Props = {
|
|
|
26
26
|
|
|
27
27
|
export const ImageElementComponent = ({ element }: Props): React.ReactElement => {
|
|
28
28
|
const hasExplicitHeight = element.props.height !== undefined;
|
|
29
|
-
const aspectRatio = hasExplicitHeight ? undefined : (element.props.aspectRatio ?? 16 / 9);
|
|
30
29
|
|
|
31
30
|
return (
|
|
32
31
|
<Image
|
|
33
32
|
source={{ uri: element.props.url }}
|
|
34
|
-
resizeMode={element.props.resizeMode
|
|
35
|
-
style={{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
resizeMode={element.props.resizeMode}
|
|
34
|
+
style={({
|
|
35
|
+
flex: element.props.flex,
|
|
36
|
+
flexShrink: element.props.flexShrink,
|
|
37
|
+
flexGrow: element.props.flexGrow,
|
|
38
|
+
alignSelf: element.props.alignSelf,
|
|
39
|
+
width: dim(element.props.width),
|
|
40
|
+
height: dim(element.props.height),
|
|
41
|
+
minWidth: element.props.minWidth,
|
|
42
|
+
maxWidth: element.props.maxWidth,
|
|
43
|
+
minHeight: element.props.minHeight,
|
|
44
|
+
maxHeight: element.props.maxHeight,
|
|
45
|
+
backgroundColor: element.props.backgroundColor,
|
|
46
|
+
overflow: element.props.overflow,
|
|
39
47
|
borderRadius: element.props.borderRadius,
|
|
40
48
|
borderWidth: element.props.borderWidth,
|
|
41
49
|
borderColor: element.props.borderColor,
|
|
@@ -46,7 +54,7 @@ export const ImageElementComponent = ({ element }: Props): React.ReactElement =>
|
|
|
46
54
|
padding: element.props.padding,
|
|
47
55
|
paddingHorizontal: element.props.paddingHorizontal,
|
|
48
56
|
paddingVertical: element.props.paddingVertical,
|
|
49
|
-
}}
|
|
57
|
+
}) as any}
|
|
50
58
|
/>
|
|
51
59
|
);
|
|
52
60
|
};
|
|
@@ -3,7 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
import { View, TextInput } from "react-native";
|
|
4
4
|
import { BaseBoxProps, BaseBoxPropsSchema } from "./BaseBoxProps";
|
|
5
5
|
import { UIElement } from "../types";
|
|
6
|
-
import { RenderContext } from "./shared";
|
|
6
|
+
import { RenderContext, dim } from "./shared";
|
|
7
7
|
|
|
8
8
|
export type InputElementProps = BaseBoxProps & {
|
|
9
9
|
variableName?: string;
|
|
@@ -21,6 +21,9 @@ export type InputElementProps = BaseBoxProps & {
|
|
|
21
21
|
backgroundColor?: string;
|
|
22
22
|
fontSize?: number;
|
|
23
23
|
fontWeight?: string;
|
|
24
|
+
fontFamily?: string;
|
|
25
|
+
lineHeight?: number;
|
|
26
|
+
letterSpacing?: number;
|
|
24
27
|
textAlign?: "left" | "center" | "right";
|
|
25
28
|
placeholderColor?: string;
|
|
26
29
|
};
|
|
@@ -41,6 +44,9 @@ export const InputElementPropsSchema = BaseBoxPropsSchema.extend({
|
|
|
41
44
|
backgroundColor: z.string().optional(),
|
|
42
45
|
fontSize: z.number().optional(),
|
|
43
46
|
fontWeight: z.string().optional(),
|
|
47
|
+
fontFamily: z.string().optional(),
|
|
48
|
+
lineHeight: z.number().optional(),
|
|
49
|
+
letterSpacing: z.number().optional(),
|
|
44
50
|
textAlign: z.enum(["left", "center", "right"]).optional(),
|
|
45
51
|
placeholderColor: z.string().optional(),
|
|
46
52
|
});
|
|
@@ -85,10 +91,18 @@ export const InputElementComponent = ({ element, ctx }: Props): React.ReactEleme
|
|
|
85
91
|
numberOfLines={element.props.numberOfLines}
|
|
86
92
|
editable={element.props.editable ?? true}
|
|
87
93
|
style={{
|
|
94
|
+
flex: element.props.flex,
|
|
95
|
+
flexShrink: element.props.flexShrink,
|
|
96
|
+
flexGrow: element.props.flexGrow,
|
|
88
97
|
alignSelf: element.props.alignSelf,
|
|
89
|
-
width: element.props.width,
|
|
90
|
-
height: element.props.height,
|
|
98
|
+
width: dim(element.props.width),
|
|
99
|
+
height: dim(element.props.height),
|
|
100
|
+
minWidth: element.props.minWidth,
|
|
101
|
+
maxWidth: element.props.maxWidth,
|
|
102
|
+
minHeight: element.props.minHeight,
|
|
103
|
+
maxHeight: element.props.maxHeight,
|
|
91
104
|
opacity: element.props.opacity,
|
|
105
|
+
overflow: element.props.overflow,
|
|
92
106
|
margin: element.props.margin,
|
|
93
107
|
marginHorizontal: element.props.marginHorizontal,
|
|
94
108
|
marginVertical: element.props.marginVertical,
|
|
@@ -99,6 +113,9 @@ export const InputElementComponent = ({ element, ctx }: Props): React.ReactEleme
|
|
|
99
113
|
color: element.props.color ?? theme.colors.text.primary,
|
|
100
114
|
fontSize: element.props.fontSize ?? theme.typography.textStyles.body.fontSize,
|
|
101
115
|
fontWeight: element.props.fontWeight as any,
|
|
116
|
+
fontFamily: element.props.fontFamily,
|
|
117
|
+
lineHeight: element.props.lineHeight,
|
|
118
|
+
letterSpacing: element.props.letterSpacing,
|
|
102
119
|
textAlign: element.props.textAlign,
|
|
103
120
|
padding: element.props.padding ?? 12,
|
|
104
121
|
paddingHorizontal: element.props.paddingHorizontal,
|
|
@@ -3,7 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
import { View, Text, StyleSheet } from "react-native";
|
|
4
4
|
import { BaseBoxProps, BaseBoxPropsSchema } from "./BaseBoxProps";
|
|
5
5
|
import { UIElement } from "../types";
|
|
6
|
-
import { RenderContext } from "./shared";
|
|
6
|
+
import { RenderContext, dim } from "./shared";
|
|
7
7
|
import { getTextStyle } from "../../../Theme/helpers";
|
|
8
8
|
|
|
9
9
|
export type LottieElementProps = BaseBoxProps & {
|
|
@@ -43,9 +43,18 @@ type Props = {
|
|
|
43
43
|
export const LottieElementComponent = ({ element, ctx }: Props): React.ReactElement => {
|
|
44
44
|
const { theme } = ctx;
|
|
45
45
|
const wrapperStyle = {
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
flex: element.props.flex,
|
|
47
|
+
flexShrink: element.props.flexShrink,
|
|
48
|
+
flexGrow: element.props.flexGrow,
|
|
49
|
+
alignSelf: element.props.alignSelf,
|
|
50
|
+
width: dim(element.props.width) ?? ("100%" as `${number}%`),
|
|
51
|
+
height: dim(element.props.height ?? 200),
|
|
52
|
+
minWidth: element.props.minWidth,
|
|
53
|
+
maxWidth: element.props.maxWidth,
|
|
54
|
+
minHeight: element.props.minHeight,
|
|
55
|
+
maxHeight: element.props.maxHeight,
|
|
48
56
|
opacity: element.props.opacity,
|
|
57
|
+
backgroundColor: element.props.backgroundColor,
|
|
49
58
|
margin: element.props.margin,
|
|
50
59
|
marginHorizontal: element.props.marginHorizontal,
|
|
51
60
|
marginVertical: element.props.marginVertical,
|
|
@@ -3,7 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
import { View, Text, TouchableOpacity } from "react-native";
|
|
4
4
|
import { BaseBoxProps, BaseBoxPropsSchema } from "./BaseBoxProps";
|
|
5
5
|
import { UIElement } from "../types";
|
|
6
|
-
import { RenderContext } from "./shared";
|
|
6
|
+
import { RenderContext, dim } from "./shared";
|
|
7
7
|
|
|
8
8
|
export type RadioGroupElementProps = BaseBoxProps & {
|
|
9
9
|
variableName?: string;
|
|
@@ -92,8 +92,8 @@ export const RadioGroupComponent = ({ element, ctx }: Props): React.ReactElement
|
|
|
92
92
|
flexWrap: isHorizontal ? "wrap" : undefined,
|
|
93
93
|
alignSelf: element.props.alignSelf,
|
|
94
94
|
gap: element.props.gap ?? 8,
|
|
95
|
-
width: element.props.width,
|
|
96
|
-
height: element.props.height,
|
|
95
|
+
width: dim(element.props.width),
|
|
96
|
+
height: dim(element.props.height),
|
|
97
97
|
margin: element.props.margin,
|
|
98
98
|
marginHorizontal: element.props.marginHorizontal,
|
|
99
99
|
marginVertical: element.props.marginVertical,
|
|
@@ -3,12 +3,12 @@ import { z } from "zod";
|
|
|
3
3
|
import { View, Text, StyleSheet } from "react-native";
|
|
4
4
|
import { BaseBoxProps, BaseBoxPropsSchema } from "./BaseBoxProps";
|
|
5
5
|
import { UIElement } from "../types";
|
|
6
|
-
import { RenderContext } from "./shared";
|
|
6
|
+
import { RenderContext, dim } from "./shared";
|
|
7
7
|
import { getTextStyle } from "../../../Theme/helpers";
|
|
8
8
|
|
|
9
9
|
export type RiveElementProps = BaseBoxProps & {
|
|
10
10
|
url: string;
|
|
11
|
-
|
|
11
|
+
autoPlay?: boolean;
|
|
12
12
|
fit?: "Contain" | "Cover" | "Fill" | "FitWidth" | "FitHeight" | "None" | "ScaleDown" | "Layout";
|
|
13
13
|
alignment?: "TopLeft" | "TopCenter" | "TopRight" | "CenterLeft" | "Center" | "CenterRight" | "BottomLeft" | "BottomCenter" | "BottomRight";
|
|
14
14
|
artboardName?: string;
|
|
@@ -17,7 +17,7 @@ export type RiveElementProps = BaseBoxProps & {
|
|
|
17
17
|
|
|
18
18
|
export const RiveElementPropsSchema = BaseBoxPropsSchema.extend({
|
|
19
19
|
url: z.string().min(1, "url must not be empty"),
|
|
20
|
-
|
|
20
|
+
autoPlay: z.boolean().optional(),
|
|
21
21
|
fit: z.enum(["Contain", "Cover", "Fill", "FitWidth", "FitHeight", "None", "ScaleDown", "Layout"]).optional(),
|
|
22
22
|
alignment: z.enum(["TopLeft", "TopCenter", "TopRight", "CenterLeft", "Center", "CenterRight", "BottomLeft", "BottomCenter", "BottomRight"]).optional(),
|
|
23
23
|
artboardName: z.string().optional(),
|
|
@@ -35,7 +35,7 @@ try {
|
|
|
35
35
|
return (
|
|
36
36
|
<Rive
|
|
37
37
|
url={element.props.url}
|
|
38
|
-
autoplay={element.props.
|
|
38
|
+
autoplay={element.props.autoPlay ?? true}
|
|
39
39
|
fit={element.props.fit ? Fit[element.props.fit] : Fit.Contain}
|
|
40
40
|
alignment={element.props.alignment ? Alignment[element.props.alignment] : Alignment.Center}
|
|
41
41
|
artboardName={element.props.artboardName}
|
|
@@ -56,19 +56,29 @@ type Props = {
|
|
|
56
56
|
|
|
57
57
|
export const RiveElementRenderer = ({ element, ctx }: Props): React.ReactElement => {
|
|
58
58
|
const { theme } = ctx;
|
|
59
|
+
const p = element.props;
|
|
59
60
|
const wrapperStyle = {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
61
|
+
flex: p.flex,
|
|
62
|
+
flexShrink: p.flexShrink,
|
|
63
|
+
flexGrow: p.flexGrow,
|
|
64
|
+
alignSelf: p.alignSelf,
|
|
65
|
+
width: dim(p.width) ?? ("100%" as `${number}%`),
|
|
66
|
+
height: dim(p.height ?? 200),
|
|
67
|
+
minWidth: p.minWidth,
|
|
68
|
+
maxWidth: p.maxWidth,
|
|
69
|
+
minHeight: p.minHeight,
|
|
70
|
+
maxHeight: p.maxHeight,
|
|
71
|
+
opacity: p.opacity,
|
|
72
|
+
backgroundColor: p.backgroundColor,
|
|
73
|
+
margin: p.margin,
|
|
74
|
+
marginHorizontal: p.marginHorizontal,
|
|
75
|
+
marginVertical: p.marginVertical,
|
|
76
|
+
padding: p.padding,
|
|
77
|
+
paddingHorizontal: p.paddingHorizontal,
|
|
78
|
+
paddingVertical: p.paddingVertical,
|
|
79
|
+
borderWidth: p.borderWidth,
|
|
80
|
+
borderRadius: p.borderRadius,
|
|
81
|
+
borderColor: p.borderColor,
|
|
72
82
|
overflow: "hidden" as const,
|
|
73
83
|
};
|
|
74
84
|
|
|
@@ -1,63 +1,22 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { View } from "react-native";
|
|
4
|
+
import { BaseBoxProps, BaseBoxPropsSchema } from "./BaseBoxProps";
|
|
4
5
|
import { UIElement } from "../types";
|
|
5
|
-
import { RenderContext } from "./shared";
|
|
6
|
+
import { RenderContext, dim } from "./shared";
|
|
6
7
|
|
|
7
|
-
export type StackElementProps = {
|
|
8
|
+
export type StackElementProps = BaseBoxProps & {
|
|
8
9
|
gap?: number;
|
|
9
|
-
padding?: number;
|
|
10
|
-
paddingHorizontal?: number;
|
|
11
|
-
paddingVertical?: number;
|
|
12
|
-
margin?: number;
|
|
13
|
-
marginHorizontal?: number;
|
|
14
|
-
marginVertical?: number;
|
|
15
|
-
flex?: number;
|
|
16
|
-
width?: number;
|
|
17
|
-
height?: number;
|
|
18
|
-
minWidth?: number;
|
|
19
|
-
maxWidth?: number;
|
|
20
|
-
minHeight?: number;
|
|
21
|
-
maxHeight?: number;
|
|
22
10
|
alignItems?: "flex-start" | "center" | "flex-end" | "stretch";
|
|
23
|
-
alignSelf?: "auto" | "flex-start" | "flex-end" | "center" | "stretch" | "baseline";
|
|
24
11
|
justifyContent?: "flex-start" | "center" | "flex-end" | "space-between" | "space-around";
|
|
25
|
-
backgroundColor?: string;
|
|
26
12
|
flexWrap?: "wrap" | "nowrap";
|
|
27
|
-
flexShrink?: number;
|
|
28
|
-
borderWidth?: number;
|
|
29
|
-
borderRadius?: number;
|
|
30
|
-
borderColor?: string;
|
|
31
|
-
overflow?: "hidden" | "visible" | "scroll";
|
|
32
|
-
opacity?: number;
|
|
33
13
|
};
|
|
34
14
|
|
|
35
|
-
export const StackElementPropsSchema =
|
|
15
|
+
export const StackElementPropsSchema = BaseBoxPropsSchema.extend({
|
|
36
16
|
gap: z.number().optional(),
|
|
37
|
-
padding: z.number().optional(),
|
|
38
|
-
paddingHorizontal: z.number().optional(),
|
|
39
|
-
paddingVertical: z.number().optional(),
|
|
40
|
-
margin: z.number().optional(),
|
|
41
|
-
marginHorizontal: z.number().optional(),
|
|
42
|
-
marginVertical: z.number().optional(),
|
|
43
|
-
flex: z.number().optional(),
|
|
44
|
-
width: z.number().optional(),
|
|
45
|
-
height: z.number().optional(),
|
|
46
|
-
minWidth: z.number().optional(),
|
|
47
|
-
maxWidth: z.number().optional(),
|
|
48
|
-
minHeight: z.number().optional(),
|
|
49
|
-
maxHeight: z.number().optional(),
|
|
50
17
|
alignItems: z.enum(["flex-start", "center", "flex-end", "stretch"]).optional(),
|
|
51
|
-
alignSelf: z.enum(["auto", "flex-start", "flex-end", "center", "stretch", "baseline"]).optional(),
|
|
52
18
|
justifyContent: z.enum(["flex-start", "center", "flex-end", "space-between", "space-around"]).optional(),
|
|
53
|
-
backgroundColor: z.string().optional(),
|
|
54
19
|
flexWrap: z.enum(["wrap", "nowrap"]).optional(),
|
|
55
|
-
flexShrink: z.number().optional(),
|
|
56
|
-
borderWidth: z.number().optional(),
|
|
57
|
-
borderRadius: z.number().optional(),
|
|
58
|
-
borderColor: z.string().optional(),
|
|
59
|
-
overflow: z.enum(["hidden", "visible", "scroll"]).optional(),
|
|
60
|
-
opacity: z.number().min(0).max(1).optional(),
|
|
61
20
|
});
|
|
62
21
|
|
|
63
22
|
type StackUIElement = Extract<UIElement, { type: "YStack" | "XStack" }>;
|
|
@@ -69,35 +28,37 @@ type Props = {
|
|
|
69
28
|
};
|
|
70
29
|
|
|
71
30
|
export const StackElementComponent = ({ element, ctx, parentType }: Props): React.ReactElement => {
|
|
31
|
+
const p = element.props;
|
|
72
32
|
return (
|
|
73
33
|
<View
|
|
74
34
|
style={{
|
|
75
35
|
flexDirection: element.type === "XStack" ? "row" : "column",
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
36
|
+
gap: p.gap,
|
|
37
|
+
flex: p.flex,
|
|
38
|
+
flexShrink: p.flexShrink ?? (parentType === "XStack" ? 1 : undefined),
|
|
39
|
+
flexGrow: p.flexGrow,
|
|
40
|
+
flexWrap: p.flexWrap,
|
|
41
|
+
alignSelf: p.alignSelf,
|
|
42
|
+
alignItems: p.alignItems,
|
|
43
|
+
justifyContent: p.justifyContent,
|
|
44
|
+
width: dim(p.width),
|
|
45
|
+
height: dim(p.height),
|
|
46
|
+
minWidth: p.minWidth,
|
|
47
|
+
maxWidth: p.maxWidth,
|
|
48
|
+
minHeight: p.minHeight,
|
|
49
|
+
maxHeight: p.maxHeight,
|
|
50
|
+
padding: p.padding,
|
|
51
|
+
paddingHorizontal: p.paddingHorizontal,
|
|
52
|
+
paddingVertical: p.paddingVertical,
|
|
53
|
+
margin: p.margin,
|
|
54
|
+
marginHorizontal: p.marginHorizontal,
|
|
55
|
+
marginVertical: p.marginVertical,
|
|
56
|
+
backgroundColor: p.backgroundColor,
|
|
57
|
+
borderWidth: p.borderWidth,
|
|
58
|
+
borderRadius: p.borderRadius,
|
|
59
|
+
borderColor: p.borderColor,
|
|
60
|
+
overflow: p.overflow,
|
|
61
|
+
opacity: p.opacity,
|
|
101
62
|
}}
|
|
102
63
|
>
|
|
103
64
|
{ctx.renderChildren(element.children, element.type)}
|