flowboard-react 0.1.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/FlowboardReact.podspec +20 -0
- package/LICENSE +20 -0
- package/README.md +122 -0
- package/android/build.gradle +67 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/flowboardreact/FlowboardReactModule.kt +15 -0
- package/android/src/main/java/com/flowboardreact/FlowboardReactPackage.kt +33 -0
- package/ios/FlowboardReact.h +5 -0
- package/ios/FlowboardReact.mm +21 -0
- package/lib/module/Flowboard.js +167 -0
- package/lib/module/Flowboard.js.map +1 -0
- package/lib/module/FlowboardProvider.js +52 -0
- package/lib/module/FlowboardProvider.js.map +1 -0
- package/lib/module/NativeFlowboardReact.js +5 -0
- package/lib/module/NativeFlowboardReact.js.map +1 -0
- package/lib/module/components/FlowboardFlow.js +389 -0
- package/lib/module/components/FlowboardFlow.js.map +1 -0
- package/lib/module/components/FlowboardRenderer.js +1684 -0
- package/lib/module/components/FlowboardRenderer.js.map +1 -0
- package/lib/module/components/widgets/sliderRegistry.js +48 -0
- package/lib/module/components/widgets/sliderRegistry.js.map +1 -0
- package/lib/module/core/analyticsManager.js +110 -0
- package/lib/module/core/analyticsManager.js.map +1 -0
- package/lib/module/core/assetPreloader.js +72 -0
- package/lib/module/core/assetPreloader.js.map +1 -0
- package/lib/module/core/clientContext.js +105 -0
- package/lib/module/core/clientContext.js.map +1 -0
- package/lib/module/core/fontAwesome.js +110 -0
- package/lib/module/core/fontAwesome.js.map +1 -0
- package/lib/module/core/onboardingRepository.js +62 -0
- package/lib/module/core/onboardingRepository.js.map +1 -0
- package/lib/module/core/resolverService.js +58 -0
- package/lib/module/core/resolverService.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types/flowboard.js +4 -0
- package/lib/module/types/flowboard.js.map +1 -0
- package/lib/module/types/react-native-vector-icons.d.js +2 -0
- package/lib/module/types/react-native-vector-icons.d.js.map +1 -0
- package/lib/module/utils/flowboardUtils.js +379 -0
- package/lib/module/utils/flowboardUtils.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/Flowboard.d.ts +33 -0
- package/lib/typescript/src/Flowboard.d.ts.map +1 -0
- package/lib/typescript/src/FlowboardProvider.d.ts +5 -0
- package/lib/typescript/src/FlowboardProvider.d.ts.map +1 -0
- package/lib/typescript/src/NativeFlowboardReact.d.ts +7 -0
- package/lib/typescript/src/NativeFlowboardReact.d.ts.map +1 -0
- package/lib/typescript/src/components/FlowboardFlow.d.ts +14 -0
- package/lib/typescript/src/components/FlowboardFlow.d.ts.map +1 -0
- package/lib/typescript/src/components/FlowboardRenderer.d.ts +31 -0
- package/lib/typescript/src/components/FlowboardRenderer.d.ts.map +1 -0
- package/lib/typescript/src/components/widgets/sliderRegistry.d.ts +16 -0
- package/lib/typescript/src/components/widgets/sliderRegistry.d.ts.map +1 -0
- package/lib/typescript/src/core/analyticsManager.d.ts +42 -0
- package/lib/typescript/src/core/analyticsManager.d.ts.map +1 -0
- package/lib/typescript/src/core/assetPreloader.d.ts +8 -0
- package/lib/typescript/src/core/assetPreloader.d.ts.map +1 -0
- package/lib/typescript/src/core/clientContext.d.ts +27 -0
- package/lib/typescript/src/core/clientContext.d.ts.map +1 -0
- package/lib/typescript/src/core/fontAwesome.d.ts +8 -0
- package/lib/typescript/src/core/fontAwesome.d.ts.map +1 -0
- package/lib/typescript/src/core/onboardingRepository.d.ts +15 -0
- package/lib/typescript/src/core/onboardingRepository.d.ts.map +1 -0
- package/lib/typescript/src/core/resolverService.d.ts +11 -0
- package/lib/typescript/src/core/resolverService.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types/flowboard.d.ts +34 -0
- package/lib/typescript/src/types/flowboard.d.ts.map +1 -0
- package/lib/typescript/src/utils/flowboardUtils.d.ts +31 -0
- package/lib/typescript/src/utils/flowboardUtils.d.ts.map +1 -0
- package/package.json +192 -0
- package/src/Flowboard.ts +223 -0
- package/src/FlowboardProvider.tsx +60 -0
- package/src/NativeFlowboardReact.ts +7 -0
- package/src/components/FlowboardFlow.tsx +513 -0
- package/src/components/FlowboardRenderer.tsx +1957 -0
- package/src/components/widgets/sliderRegistry.tsx +56 -0
- package/src/core/analyticsManager.ts +125 -0
- package/src/core/assetPreloader.ts +103 -0
- package/src/core/clientContext.ts +132 -0
- package/src/core/fontAwesome.ts +90 -0
- package/src/core/onboardingRepository.ts +79 -0
- package/src/core/resolverService.ts +69 -0
- package/src/index.tsx +11 -0
- package/src/types/flowboard.ts +50 -0
- package/src/types/react-native-vector-icons.d.ts +15 -0
- package/src/utils/flowboardUtils.ts +400 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
|
|
3
|
+
export type JsonMap = Record<string, any>;
|
|
4
|
+
|
|
5
|
+
export type FlowboardScreen = JsonMap;
|
|
6
|
+
|
|
7
|
+
export type FlowboardData = {
|
|
8
|
+
screens: FlowboardScreen[];
|
|
9
|
+
flow_id?: string;
|
|
10
|
+
variant_id?: string;
|
|
11
|
+
audience_id?: string;
|
|
12
|
+
bucket?: string;
|
|
13
|
+
experiment_id?: string;
|
|
14
|
+
} & JsonMap;
|
|
15
|
+
|
|
16
|
+
export type FlowboardContext = {
|
|
17
|
+
context?: any;
|
|
18
|
+
currentIndex: number;
|
|
19
|
+
totalScreens: number;
|
|
20
|
+
formData: JsonMap;
|
|
21
|
+
screenData: FlowboardScreen;
|
|
22
|
+
onNext: () => void;
|
|
23
|
+
onPrevious: () => void;
|
|
24
|
+
onFinish: () => void;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type CustomScreenBuilder = (ctx: FlowboardContext) => React.ReactNode;
|
|
28
|
+
|
|
29
|
+
export type CustomActionBuilder = (
|
|
30
|
+
action: string,
|
|
31
|
+
ctx: FlowboardContext,
|
|
32
|
+
data?: JsonMap
|
|
33
|
+
) => void;
|
|
34
|
+
|
|
35
|
+
export type OnboardingEndCallback = (formData: JsonMap) => void;
|
|
36
|
+
|
|
37
|
+
export type OnStepChangeCallback = (
|
|
38
|
+
pageId: string | null | undefined,
|
|
39
|
+
pageStep: number,
|
|
40
|
+
formData: JsonMap
|
|
41
|
+
) => void;
|
|
42
|
+
|
|
43
|
+
export type FlowboardLaunchOptions = {
|
|
44
|
+
customScreenBuilder?: CustomScreenBuilder;
|
|
45
|
+
customActionBuilder?: CustomActionBuilder;
|
|
46
|
+
onOnboardEnd?: OnboardingEndCallback;
|
|
47
|
+
onStepChange?: OnStepChangeCallback;
|
|
48
|
+
enableAnalytics?: boolean;
|
|
49
|
+
alwaysRestart?: boolean;
|
|
50
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare module 'react-native-vector-icons/FontAwesome6' {
|
|
2
|
+
import type { ComponentType } from 'react';
|
|
3
|
+
import type { TextStyle } from 'react-native';
|
|
4
|
+
|
|
5
|
+
interface FontAwesome6Props {
|
|
6
|
+
name: string;
|
|
7
|
+
size?: number;
|
|
8
|
+
color?: string;
|
|
9
|
+
style?: TextStyle | TextStyle[];
|
|
10
|
+
solid?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const FontAwesome6: ComponentType<FontAwesome6Props>;
|
|
14
|
+
export default FontAwesome6;
|
|
15
|
+
}
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import { Parser } from 'expr-eval';
|
|
2
|
+
|
|
3
|
+
export type Insets = {
|
|
4
|
+
top: number;
|
|
5
|
+
right: number;
|
|
6
|
+
bottom: number;
|
|
7
|
+
left: number;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const EMPTY_INSETS: Insets = {
|
|
11
|
+
top: 0,
|
|
12
|
+
right: 0,
|
|
13
|
+
bottom: 0,
|
|
14
|
+
left: 0,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const parser = new Parser();
|
|
18
|
+
|
|
19
|
+
export function parseColor(hex?: string | number | null): string {
|
|
20
|
+
if (hex === null || hex === undefined) return 'transparent';
|
|
21
|
+
if (typeof hex === 'number' && Number.isFinite(hex)) {
|
|
22
|
+
return argbIntToRgba(hex);
|
|
23
|
+
}
|
|
24
|
+
if (typeof hex !== 'string') return 'transparent';
|
|
25
|
+
const raw = hex.trim();
|
|
26
|
+
if (!raw) return 'transparent';
|
|
27
|
+
|
|
28
|
+
if (raw.startsWith('#')) {
|
|
29
|
+
const hexVal = raw.slice(1);
|
|
30
|
+
if (hexVal.length === 6) {
|
|
31
|
+
const r = parseInt(hexVal.slice(0, 2), 16);
|
|
32
|
+
const g = parseInt(hexVal.slice(2, 4), 16);
|
|
33
|
+
const b = parseInt(hexVal.slice(4, 6), 16);
|
|
34
|
+
return `rgba(${r},${g},${b},1)`;
|
|
35
|
+
}
|
|
36
|
+
if (hexVal.length === 8) {
|
|
37
|
+
const a = parseInt(hexVal.slice(0, 2), 16) / 255;
|
|
38
|
+
const r = parseInt(hexVal.slice(2, 4), 16);
|
|
39
|
+
const g = parseInt(hexVal.slice(4, 6), 16);
|
|
40
|
+
const b = parseInt(hexVal.slice(6, 8), 16);
|
|
41
|
+
return `rgba(${r},${g},${b},${clampAlpha(a)})`;
|
|
42
|
+
}
|
|
43
|
+
return 'transparent';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (raw.startsWith('0x') || raw.startsWith('0X')) {
|
|
47
|
+
const hexVal = raw.slice(2);
|
|
48
|
+
if (hexVal.length === 8) {
|
|
49
|
+
const a = parseInt(hexVal.slice(0, 2), 16) / 255;
|
|
50
|
+
const r = parseInt(hexVal.slice(2, 4), 16);
|
|
51
|
+
const g = parseInt(hexVal.slice(4, 6), 16);
|
|
52
|
+
const b = parseInt(hexVal.slice(6, 8), 16);
|
|
53
|
+
return `rgba(${r},${g},${b},${clampAlpha(a)})`;
|
|
54
|
+
}
|
|
55
|
+
if (hexVal.length === 6) {
|
|
56
|
+
const r = parseInt(hexVal.slice(0, 2), 16);
|
|
57
|
+
const g = parseInt(hexVal.slice(2, 4), 16);
|
|
58
|
+
const b = parseInt(hexVal.slice(4, 6), 16);
|
|
59
|
+
return `rgba(${r},${g},${b},1)`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return 'transparent';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function clampAlpha(value: number): number {
|
|
67
|
+
if (Number.isNaN(value)) return 1;
|
|
68
|
+
return Math.max(0, Math.min(1, value));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function argbIntToRgba(value: number): string {
|
|
72
|
+
const hex = value.toString(16).padStart(8, '0');
|
|
73
|
+
const a = parseInt(hex.slice(0, 2), 16) / 255;
|
|
74
|
+
const r = parseInt(hex.slice(2, 4), 16);
|
|
75
|
+
const g = parseInt(hex.slice(4, 6), 16);
|
|
76
|
+
const b = parseInt(hex.slice(6, 8), 16);
|
|
77
|
+
return `rgba(${r},${g},${b},${clampAlpha(a)})`;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function parseDimension(
|
|
81
|
+
value: any,
|
|
82
|
+
zeroIsNull = false
|
|
83
|
+
): number | undefined {
|
|
84
|
+
if (value === null || value === undefined) return undefined;
|
|
85
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
86
|
+
if (zeroIsNull && value === 0) return undefined;
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
if (typeof value === 'string') {
|
|
90
|
+
if (value.toLowerCase() === 'infinity') return Number.POSITIVE_INFINITY;
|
|
91
|
+
const numeric = Number(value);
|
|
92
|
+
if (!Number.isNaN(numeric)) {
|
|
93
|
+
if (zeroIsNull && numeric === 0) return undefined;
|
|
94
|
+
return numeric;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function parseInsets(value: any): Insets {
|
|
101
|
+
if (typeof value === 'number') {
|
|
102
|
+
return { top: value, right: value, bottom: value, left: value };
|
|
103
|
+
}
|
|
104
|
+
if (value && typeof value === 'object') {
|
|
105
|
+
if ('horizontal' in value || 'vertical' in value) {
|
|
106
|
+
const horizontal = Number(value.horizontal ?? 0);
|
|
107
|
+
const vertical = Number(value.vertical ?? 0);
|
|
108
|
+
return {
|
|
109
|
+
top: vertical,
|
|
110
|
+
right: horizontal,
|
|
111
|
+
bottom: vertical,
|
|
112
|
+
left: horizontal,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
top: Number(value.top ?? 0),
|
|
117
|
+
right: Number(value.right ?? 0),
|
|
118
|
+
bottom: Number(value.bottom ?? 0),
|
|
119
|
+
left: Number(value.left ?? 0),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return { ...EMPTY_INSETS };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function insetsToStyle(insets: Insets): {
|
|
126
|
+
paddingTop: number;
|
|
127
|
+
paddingRight: number;
|
|
128
|
+
paddingBottom: number;
|
|
129
|
+
paddingLeft: number;
|
|
130
|
+
} {
|
|
131
|
+
return {
|
|
132
|
+
paddingTop: insets.top,
|
|
133
|
+
paddingRight: insets.right,
|
|
134
|
+
paddingBottom: insets.bottom,
|
|
135
|
+
paddingLeft: insets.left,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function formatDate(pattern: string, date = new Date()): string {
|
|
140
|
+
const pad = (value: number, len = 2) => value.toString().padStart(len, '0');
|
|
141
|
+
const replacements: Record<string, string> = {
|
|
142
|
+
yyyy: date.getFullYear().toString(),
|
|
143
|
+
yy: date.getFullYear().toString().slice(-2),
|
|
144
|
+
MM: pad(date.getMonth() + 1),
|
|
145
|
+
dd: pad(date.getDate()),
|
|
146
|
+
HH: pad(date.getHours()),
|
|
147
|
+
mm: pad(date.getMinutes()),
|
|
148
|
+
ss: pad(date.getSeconds()),
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
let output = pattern;
|
|
152
|
+
Object.keys(replacements).forEach((token) => {
|
|
153
|
+
output = output.split(token).join(replacements[token]);
|
|
154
|
+
});
|
|
155
|
+
return output;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function resolveText(
|
|
159
|
+
text: string,
|
|
160
|
+
formData: Record<string, any>
|
|
161
|
+
): string {
|
|
162
|
+
const regex = /\{\{(.*?)\}\}/g;
|
|
163
|
+
return text.replace(regex, (_match, content) => {
|
|
164
|
+
const resolved = evaluateExpression(String(content ?? ''), formData);
|
|
165
|
+
return resolved === null || resolved === undefined ? '' : String(resolved);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export function evaluateExpression(
|
|
170
|
+
content: string,
|
|
171
|
+
formData: Record<string, any>
|
|
172
|
+
): any {
|
|
173
|
+
let expressionPart = content;
|
|
174
|
+
let defaultValue: string | undefined;
|
|
175
|
+
|
|
176
|
+
if (content.includes('|')) {
|
|
177
|
+
const pipeIndex = content.lastIndexOf('|');
|
|
178
|
+
expressionPart = content.substring(0, pipeIndex).trim();
|
|
179
|
+
defaultValue = content.substring(pipeIndex + 1).trim();
|
|
180
|
+
} else {
|
|
181
|
+
expressionPart = content.trim();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (!expressionPart) return defaultValue ?? '';
|
|
185
|
+
|
|
186
|
+
try {
|
|
187
|
+
if (expressionPart.startsWith('DATE(') && expressionPart.endsWith(')')) {
|
|
188
|
+
const format = expressionPart.substring(5, expressionPart.length - 1);
|
|
189
|
+
return formatDate(format);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (/^[a-zA-Z0-9_]+$/.test(expressionPart)) {
|
|
193
|
+
const val = formData[expressionPart];
|
|
194
|
+
return val ?? defaultValue ?? '';
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const context: Record<string, any> = { ...formData };
|
|
198
|
+
let usedNumericString = false;
|
|
199
|
+
Object.keys(context).forEach((key) => {
|
|
200
|
+
if (typeof context[key] === 'string') {
|
|
201
|
+
const numeric = Number(context[key]);
|
|
202
|
+
if (!Number.isNaN(numeric)) {
|
|
203
|
+
context[key] = numeric;
|
|
204
|
+
usedNumericString = true;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
const expr = parser.parse(expressionPart);
|
|
210
|
+
const result = expr.evaluate(context);
|
|
211
|
+
if (
|
|
212
|
+
usedNumericString &&
|
|
213
|
+
typeof result === 'number' &&
|
|
214
|
+
Number.isInteger(result)
|
|
215
|
+
) {
|
|
216
|
+
return result.toFixed(1);
|
|
217
|
+
}
|
|
218
|
+
return result ?? defaultValue ?? '';
|
|
219
|
+
} catch {
|
|
220
|
+
return defaultValue ?? '';
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export function resolveNumericValue(
|
|
225
|
+
value: any,
|
|
226
|
+
formData: Record<string, any>
|
|
227
|
+
): number | null {
|
|
228
|
+
if (value === null || value === undefined) return null;
|
|
229
|
+
if (typeof value === 'number' && Number.isFinite(value)) return value;
|
|
230
|
+
if (typeof value === 'string') {
|
|
231
|
+
const trimmed = value.trim();
|
|
232
|
+
if (trimmed.startsWith('{{') && trimmed.endsWith('}}')) {
|
|
233
|
+
const content = trimmed.substring(2, trimmed.length - 2);
|
|
234
|
+
const result = evaluateExpression(content, formData);
|
|
235
|
+
if (typeof result === 'number') return result;
|
|
236
|
+
if (typeof result === 'string') {
|
|
237
|
+
const numeric = Number(result);
|
|
238
|
+
if (!Number.isNaN(numeric)) return numeric;
|
|
239
|
+
}
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
const numeric = Number(trimmed);
|
|
243
|
+
if (!Number.isNaN(numeric)) return numeric;
|
|
244
|
+
}
|
|
245
|
+
if (typeof value === 'string') return null;
|
|
246
|
+
if (typeof value === 'boolean') return value ? 1 : 0;
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export function parseFontWeight(value?: string | number): any {
|
|
251
|
+
if (typeof value === 'number') {
|
|
252
|
+
if (value >= 900) return '900';
|
|
253
|
+
if (value >= 800) return '800';
|
|
254
|
+
if (value >= 700) return '700';
|
|
255
|
+
if (value >= 600) return '600';
|
|
256
|
+
if (value >= 500) return '500';
|
|
257
|
+
if (value >= 400) return '400';
|
|
258
|
+
if (value >= 300) return '300';
|
|
259
|
+
if (value >= 200) return '200';
|
|
260
|
+
if (value >= 100) return '100';
|
|
261
|
+
}
|
|
262
|
+
switch ((value ?? '').toString().toLowerCase()) {
|
|
263
|
+
case 'bold':
|
|
264
|
+
case '700':
|
|
265
|
+
return '700';
|
|
266
|
+
case 'w100':
|
|
267
|
+
case 'thin':
|
|
268
|
+
return '100';
|
|
269
|
+
case 'w200':
|
|
270
|
+
case 'extralight':
|
|
271
|
+
return '200';
|
|
272
|
+
case 'w300':
|
|
273
|
+
case 'light':
|
|
274
|
+
return '300';
|
|
275
|
+
case 'w400':
|
|
276
|
+
case 'regular':
|
|
277
|
+
case 'normal':
|
|
278
|
+
return '400';
|
|
279
|
+
case 'w500':
|
|
280
|
+
case 'medium':
|
|
281
|
+
return '500';
|
|
282
|
+
case 'w600':
|
|
283
|
+
case 'semibold':
|
|
284
|
+
return '600';
|
|
285
|
+
case 'w800':
|
|
286
|
+
case 'extrabold':
|
|
287
|
+
return '800';
|
|
288
|
+
case 'w900':
|
|
289
|
+
case 'black':
|
|
290
|
+
return '900';
|
|
291
|
+
default:
|
|
292
|
+
return '400';
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export function parseTextDecoration(value?: string): any {
|
|
297
|
+
switch (value) {
|
|
298
|
+
case 'underline':
|
|
299
|
+
return 'underline';
|
|
300
|
+
case 'lineThrough':
|
|
301
|
+
return 'line-through';
|
|
302
|
+
case 'overline':
|
|
303
|
+
return 'underline';
|
|
304
|
+
default:
|
|
305
|
+
return 'none';
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export function parseTextAlign(value?: string): any {
|
|
310
|
+
switch (value) {
|
|
311
|
+
case 'center':
|
|
312
|
+
return 'center';
|
|
313
|
+
case 'right':
|
|
314
|
+
case 'end':
|
|
315
|
+
return 'right';
|
|
316
|
+
case 'left':
|
|
317
|
+
case 'start':
|
|
318
|
+
default:
|
|
319
|
+
return 'left';
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export function parseFlexAlignment(value?: string): any {
|
|
324
|
+
switch (value) {
|
|
325
|
+
case 'center':
|
|
326
|
+
return 'center';
|
|
327
|
+
case 'end':
|
|
328
|
+
return 'flex-end';
|
|
329
|
+
case 'spaceBetween':
|
|
330
|
+
return 'space-between';
|
|
331
|
+
case 'spaceAround':
|
|
332
|
+
return 'space-around';
|
|
333
|
+
case 'spaceEvenly':
|
|
334
|
+
return 'space-evenly';
|
|
335
|
+
case 'start':
|
|
336
|
+
default:
|
|
337
|
+
return 'flex-start';
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export function parseCrossAlignment(value?: string): any {
|
|
342
|
+
switch (value) {
|
|
343
|
+
case 'center':
|
|
344
|
+
return 'center';
|
|
345
|
+
case 'end':
|
|
346
|
+
return 'flex-end';
|
|
347
|
+
case 'stretch':
|
|
348
|
+
return 'stretch';
|
|
349
|
+
case 'start':
|
|
350
|
+
default:
|
|
351
|
+
return 'flex-start';
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
export function parseResizeMode(value?: string): any {
|
|
356
|
+
switch (value) {
|
|
357
|
+
case 'contain':
|
|
358
|
+
return 'contain';
|
|
359
|
+
case 'cover':
|
|
360
|
+
return 'cover';
|
|
361
|
+
case 'fill':
|
|
362
|
+
return 'stretch';
|
|
363
|
+
case 'fitWidth':
|
|
364
|
+
case 'fitHeight':
|
|
365
|
+
return 'contain';
|
|
366
|
+
case 'none':
|
|
367
|
+
return 'center';
|
|
368
|
+
case 'scaleDown':
|
|
369
|
+
return 'contain';
|
|
370
|
+
default:
|
|
371
|
+
return 'contain';
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export function parseAlignment(value?: string): {
|
|
376
|
+
justifyContent: any;
|
|
377
|
+
alignItems: any;
|
|
378
|
+
} {
|
|
379
|
+
switch (value) {
|
|
380
|
+
case 'topCenter':
|
|
381
|
+
return { justifyContent: 'flex-start', alignItems: 'center' };
|
|
382
|
+
case 'bottomCenter':
|
|
383
|
+
return { justifyContent: 'flex-end', alignItems: 'center' };
|
|
384
|
+
case 'centerLeft':
|
|
385
|
+
return { justifyContent: 'center', alignItems: 'flex-start' };
|
|
386
|
+
case 'centerRight':
|
|
387
|
+
return { justifyContent: 'center', alignItems: 'flex-end' };
|
|
388
|
+
case 'center':
|
|
389
|
+
return { justifyContent: 'center', alignItems: 'center' };
|
|
390
|
+
case 'bottomLeft':
|
|
391
|
+
return { justifyContent: 'flex-end', alignItems: 'flex-start' };
|
|
392
|
+
case 'bottomRight':
|
|
393
|
+
return { justifyContent: 'flex-end', alignItems: 'flex-end' };
|
|
394
|
+
case 'topRight':
|
|
395
|
+
return { justifyContent: 'flex-start', alignItems: 'flex-end' };
|
|
396
|
+
case 'topLeft':
|
|
397
|
+
default:
|
|
398
|
+
return { justifyContent: 'flex-start', alignItems: 'flex-start' };
|
|
399
|
+
}
|
|
400
|
+
}
|