@developer_tribe/react-builder 0.1.30 → 0.1.32

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.
Files changed (59) hide show
  1. package/dist/build-components/Button/ButtonProps.generated.d.ts +2 -1
  2. package/dist/build-components/CarouselButtons/CarouselButtonsProps.generated.d.ts +2 -1
  3. package/dist/build-components/CarouselDots/CarouselDotsProps.generated.d.ts +2 -1
  4. package/dist/build-components/Image/ImageProps.generated.d.ts +2 -1
  5. package/dist/build-components/OnboardButton/OnboardButtonProps.generated.d.ts +8 -5
  6. package/dist/build-components/OnboardButtons/OnboardButtonsProps.generated.d.ts +6 -3
  7. package/dist/build-components/OnboardDot/OnboardDotProps.generated.d.ts +2 -1
  8. package/dist/build-components/OnboardFooter/OnboardFooterProps.generated.d.ts +10 -4
  9. package/dist/build-components/OnboardImage/OnboardImageProps.generated.d.ts +4 -1
  10. package/dist/build-components/OnboardItem/OnboardItemProps.generated.d.ts +4 -2
  11. package/dist/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.d.ts +10 -4
  12. package/dist/build-components/OnboardTitle/OnboardTitleProps.generated.d.ts +10 -4
  13. package/dist/build-components/Text/TextProps.generated.d.ts +10 -4
  14. package/dist/build-components/View/ViewProps.generated.d.ts +6 -3
  15. package/dist/build-components/patterns.generated.d.ts +11 -7
  16. package/dist/index.cjs.js +6 -4
  17. package/dist/index.d.ts +3 -0
  18. package/dist/index.esm.js +6 -4
  19. package/dist/utils/extractImageStyle.d.ts +3 -0
  20. package/dist/utils/extractTextStyle.d.ts +3 -0
  21. package/dist/utils/extractViewStyle.d.ts +3 -0
  22. package/package.json +2 -1
  23. package/scripts/prebuild/prebuild.js +1 -1
  24. package/scripts/prebuild/utils/createGeneratedProps.js +64 -5
  25. package/src/assets/samples/getSamples.ts +6 -0
  26. package/src/assets/samples/vpn-onboard-5.json +1025 -0
  27. package/src/assets/samples/vpn-onboard-6.json +709 -0
  28. package/src/build-components/Button/ButtonProps.generated.ts +14 -12
  29. package/src/build-components/CarouselButtons/CarouselButtonsProps.generated.ts +6 -1
  30. package/src/build-components/CarouselDots/CarouselDotsProps.generated.ts +9 -7
  31. package/src/build-components/Image/Image.tsx +2 -13
  32. package/src/build-components/Image/ImageProps.generated.ts +3 -1
  33. package/src/build-components/OnboardButton/OnboardButton.tsx +4 -5
  34. package/src/build-components/OnboardButton/OnboardButtonProps.generated.ts +14 -10
  35. package/src/build-components/OnboardButton/pattern.json +3 -3
  36. package/src/build-components/OnboardButtons/OnboardButtonsProps.generated.ts +10 -3
  37. package/src/build-components/OnboardDot/OnboardDotProps.generated.ts +9 -7
  38. package/src/build-components/OnboardFooter/OnboardFooter.tsx +2 -29
  39. package/src/build-components/OnboardFooter/OnboardFooterProps.generated.ts +33 -21
  40. package/src/build-components/OnboardImage/OnboardImage.tsx +24 -1
  41. package/src/build-components/OnboardImage/OnboardImageProps.generated.ts +5 -1
  42. package/src/build-components/OnboardImage/pattern.json +3 -5
  43. package/src/build-components/OnboardItem/OnboardItemProps.generated.ts +5 -2
  44. package/src/build-components/OnboardProvider/OnboardProvider.tsx +0 -1
  45. package/src/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.ts +33 -21
  46. package/src/build-components/OnboardTitle/OnboardTitle.tsx +0 -1
  47. package/src/build-components/OnboardTitle/OnboardTitleProps.generated.ts +33 -21
  48. package/src/build-components/Text/Text.tsx +3 -12
  49. package/src/build-components/Text/TextProps.generated.ts +33 -21
  50. package/src/build-components/Text/pattern.json +3 -3
  51. package/src/build-components/View/View.tsx +2 -45
  52. package/src/build-components/View/ViewProps.generated.ts +18 -9
  53. package/src/build-components/patterns.generated.ts +11 -7
  54. package/src/build-components/useNode.ts +0 -1
  55. package/src/index.ts +3 -0
  56. package/src/utils/extractImageStyle.ts +24 -0
  57. package/src/utils/extractTextStyle.ts +109 -0
  58. package/src/utils/extractViewStyle.ts +44 -0
  59. package/src/utils/novaToJson.ts +10 -2
@@ -2,23 +2,25 @@
2
2
 
3
3
  import type { NodeData } from '../../types/Node';
4
4
 
5
+ export type FontWeightOptionType =
6
+ | 'normal'
7
+ | 'bold'
8
+ | '100'
9
+ | '200'
10
+ | '300'
11
+ | '400'
12
+ | '500'
13
+ | '600'
14
+ | '700'
15
+ | '800'
16
+ | '900';
17
+
5
18
  export interface ButtonPropsGenerated {
6
19
  child: string;
7
20
  attributes: {
8
21
  color?: string;
9
22
  fontSize?: number;
10
- fontWeight?:
11
- | 'normal'
12
- | 'bold'
13
- | '100'
14
- | '200'
15
- | '300'
16
- | '400'
17
- | '500'
18
- | '600'
19
- | '700'
20
- | '800'
21
- | '900';
23
+ fontWeight?: FontWeightOptionType;
22
24
  };
23
25
  }
24
26
 
@@ -2,10 +2,15 @@
2
2
 
3
3
  import type { NodeData } from '../../types/Node';
4
4
 
5
+ export type ButtonTypeOptionType =
6
+ | 'previous_button'
7
+ | 'next_button'
8
+ | 'skip_button';
9
+
5
10
  export interface CarouselButtonsPropsGenerated {
6
11
  child: string;
7
12
  attributes: {
8
- buttonType?: 'previous_button' | 'next_button' | 'skip_button';
13
+ buttonType?: ButtonTypeOptionType;
9
14
  skipNumber?: number;
10
15
  };
11
16
  }
@@ -2,16 +2,18 @@
2
2
 
3
3
  import type { NodeData } from '../../types/Node';
4
4
 
5
+ export type DotTypeOptionType =
6
+ | 'expanding_dot'
7
+ | 'normal_dot'
8
+ | 'scaling_dot'
9
+ | 'sliding_border'
10
+ | 'sliding_dot'
11
+ | 'liquid_like';
12
+
5
13
  export interface CarouselDotsPropsGenerated {
6
14
  child: string;
7
15
  attributes: {
8
- dotType?:
9
- | 'expanding_dot'
10
- | 'normal_dot'
11
- | 'scaling_dot'
12
- | 'sliding_border'
13
- | 'sliding_dot'
14
- | 'liquid_like';
16
+ dotType?: DotTypeOptionType;
15
17
  };
16
18
  }
17
19
 
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { ImageComponentProps } from './ImageProps.generated';
3
3
  import useNode from '../useNode';
4
+ import { extractImageStyle } from '../../utils/extractImageStyle';
4
5
 
5
6
  function Image({ node }: ImageComponentProps) {
6
7
  node = useNode(node);
@@ -10,19 +11,7 @@ function Image({ node }: ImageComponentProps) {
10
11
  src={node.attributes?.src}
11
12
  width={node.attributes?.width}
12
13
  height={node.attributes?.height}
13
- style={{
14
- width: node.attributes?.width,
15
- height: node.attributes?.height,
16
- borderRadius: node.attributes?.borderRadius,
17
- objectFit:
18
- node.attributes?.resizeMode === 'cover'
19
- ? 'cover'
20
- : node.attributes?.resizeMode === 'contain'
21
- ? 'contain'
22
- : node.attributes?.resizeMode === 'stretch'
23
- ? 'fill'
24
- : undefined,
25
- }}
14
+ style={extractImageStyle(node)}
26
15
  alt=""
27
16
  />
28
17
  );
@@ -2,13 +2,15 @@
2
2
 
3
3
  import type { NodeData } from '../../types/Node';
4
4
 
5
+ export type ResizeModeOptionType = 'cover' | 'contain' | 'stretch' | 'center';
6
+
5
7
  export interface ImagePropsGenerated {
6
8
  child: string;
7
9
  attributes: {
8
10
  src?: string;
9
11
  width?: number;
10
12
  height?: number;
11
- resizeMode?: 'cover' | 'contain' | 'stretch' | 'center';
13
+ resizeMode?: ResizeModeOptionType;
12
14
  borderRadius?: number;
13
15
  };
14
16
  }
@@ -27,15 +27,14 @@ function OnboardButton({ node }: OnboardButtonComponentProps) {
27
27
  if (e.type === 'Permission') {
28
28
  alert(`Permission requested: ${e.permission ?? 'unknown'}`);
29
29
  } else if (e.type === 'Navigate') {
30
- if (typeof node.attributes?.targetIndex === 'number') {
31
- emblaApi?.scrollTo(node.attributes.targetIndex);
30
+ const eventTargetIndex = (e as any)?.targetIndex;
31
+ if (typeof eventTargetIndex === 'number') {
32
+ emblaApi?.scrollTo(eventTargetIndex);
32
33
  navigateHandled = true;
33
34
  }
34
35
  }
35
36
  }
36
- if (!navigateHandled && typeof node.attributes?.targetIndex === 'number') {
37
- emblaApi?.scrollTo(node.attributes.targetIndex);
38
- }
37
+ // Fallback: do nothing when there is no Navigate event
39
38
  };
40
39
 
41
40
  return (
@@ -2,10 +2,20 @@
2
2
 
3
3
  import type { NodeData } from '../../types/Node';
4
4
 
5
+ export type TypeOptionType = 'Permission' | 'Navigate';
6
+ export type PermissionOptionType = 'att' | 'notification' | 'rating' | 'GDPR';
7
+ export type AnimationOptionType =
8
+ | 'simple-animation'
9
+ | 'line-animation'
10
+ | 'blur'
11
+ | 'blur-animation'
12
+ | 'blur-line-animation';
13
+
5
14
  export interface EventObjectGenerated {
6
- type?: 'Permission' | 'Navigate';
7
- permission?: 'att' | 'notification' | 'rating' | 'null';
8
- navigate_to?: 'string' | 'null';
15
+ type?: TypeOptionType;
16
+ permission?: PermissionOptionType | null;
17
+ navigate_to?: string;
18
+ targetIndex?: number;
9
19
  }
10
20
 
11
21
  export interface OnboardButtonPropsGenerated {
@@ -13,16 +23,10 @@ export interface OnboardButtonPropsGenerated {
13
23
  attributes: {
14
24
  labelKey?: string;
15
25
  button_text_color?: string;
16
- animation?:
17
- | 'simple-animation'
18
- | 'line-animation'
19
- | 'blur'
20
- | 'blur-animation'
21
- | 'blur-line-animation';
26
+ animation?: AnimationOptionType;
22
27
  animation_color?: string;
23
28
  button_background_color?: string;
24
29
  flex?: number;
25
- targetIndex?: number;
26
30
  events?: EventObjectGenerated[];
27
31
  };
28
32
  }
@@ -17,15 +17,15 @@
17
17
  "animation_color": "string",
18
18
  "button_background_color": "string",
19
19
  "flex": "number",
20
- "targetIndex": "number",
21
20
  "events": "EventObject[]"
22
21
  }
23
22
  },
24
23
  "types": {
25
24
  "EventObject": {
26
25
  "type": ["Permission", "Navigate"],
27
- "permission": ["att", "notification", "rating", "null"],
28
- "navigate_to": ["string", "null"]
26
+ "permission": ["att", "notification", "rating", "GDPR", "null"],
27
+ "navigate_to": "string",
28
+ "targetIndex": "number"
29
29
  }
30
30
  }
31
31
  }
@@ -2,15 +2,22 @@
2
2
 
3
3
  import type { NodeData } from '../../types/Node';
4
4
 
5
+ export type ButtonTypeOptionType =
6
+ | 'previous_button'
7
+ | 'next_button'
8
+ | 'skip_button';
9
+ export type ButtonsDirectionOptionType = 'row' | 'column';
10
+ export type ConditionOptionType = 'carousel-index';
11
+
5
12
  export interface OnboardButtonsPropsGenerated {
6
13
  child: string;
7
14
  attributes: {
8
- buttonType?: 'previous_button' | 'next_button' | 'skip_button';
15
+ buttonType?: ButtonTypeOptionType;
9
16
  skipNumber?: number;
10
- buttons_direction?: 'row' | 'column';
17
+ buttons_direction?: ButtonsDirectionOptionType;
11
18
  forIndex?: number;
12
19
  seperatorColor?: string;
13
- condition?: 'carousel-index';
20
+ condition?: ConditionOptionType;
14
21
  conditionVariable?: number;
15
22
  };
16
23
  }
@@ -2,16 +2,18 @@
2
2
 
3
3
  import type { NodeData } from '../../types/Node';
4
4
 
5
+ export type DotTypeOptionType =
6
+ | 'expanding_dot'
7
+ | 'normal_dot'
8
+ | 'scaling_dot'
9
+ | 'sliding_border'
10
+ | 'sliding_dot'
11
+ | 'liquid_like';
12
+
5
13
  export interface OnboardDotPropsGenerated {
6
14
  child: string;
7
15
  attributes: {
8
- dotType?:
9
- | 'expanding_dot'
10
- | 'normal_dot'
11
- | 'scaling_dot'
12
- | 'sliding_border'
13
- | 'sliding_dot'
14
- | 'liquid_like';
16
+ dotType?: DotTypeOptionType;
15
17
  inactive_dot_opacity?: number;
16
18
  expanding_dot_width?: number;
17
19
  dot_style?: string;
@@ -3,6 +3,7 @@ import type { OnboardFooterComponentProps } from './OnboardFooterProps.generated
3
3
  import useNode from '../useNode';
4
4
  import { useRenderStore } from '../../store';
5
5
  import { parseSize } from '../../size-matters';
6
+ import { extractTextStyle } from '../../utils/extractTextStyle';
6
7
 
7
8
  type Segment =
8
9
  | { type: 'text'; value: string }
@@ -94,34 +95,7 @@ function OnboardFooter({ node }: OnboardFooterComponentProps) {
94
95
  key ? (localication?.[defaultLanguage ?? 'en']?.[key] ?? key) : '';
95
96
 
96
97
  const text = t(node?.attributes?.textLocalizationKey);
97
- const style: React.CSSProperties = {
98
- display: 'flex',
99
- flexDirection: (node?.attributes?.flexDirection as any) ?? 'column',
100
- gap: typeof node?.attributes?.gap === 'number' ? node.attributes.gap : 0,
101
- padding:
102
- typeof node?.attributes?.padding === 'number'
103
- ? node.attributes.padding
104
- : undefined,
105
- margin:
106
- typeof node?.attributes?.margin === 'number'
107
- ? node.attributes.margin
108
- : undefined,
109
- backgroundColor: node?.attributes?.backgroundColor,
110
- borderRadius:
111
- typeof node?.attributes?.borderRadius === 'number'
112
- ? node.attributes.borderRadius
113
- : undefined,
114
- width:
115
- typeof node?.attributes?.width === 'number'
116
- ? node.attributes.width
117
- : undefined,
118
- height:
119
- typeof node?.attributes?.height === 'number'
120
- ? node.attributes.height
121
- : undefined,
122
- alignItems: node?.attributes?.alignItems as any,
123
- justifyContent: node?.attributes?.justifyContent as any,
124
- };
98
+ const style: React.CSSProperties = extractTextStyle(node);
125
99
 
126
100
  const linkStyle = (color?: string): React.CSSProperties => ({
127
101
  color,
@@ -129,7 +103,6 @@ function OnboardFooter({ node }: OnboardFooterComponentProps) {
129
103
  });
130
104
 
131
105
  const paddingHorizontal = parseSize(node?.attributes?.paddingHorizontal);
132
- console.log('----', node?.attributes);
133
106
  return (
134
107
  <div
135
108
  style={{
@@ -2,33 +2,45 @@
2
2
 
3
3
  import type { NodeData } from '../../types/Node';
4
4
 
5
+ export type FontWeightOptionType =
6
+ | 'normal'
7
+ | 'bold'
8
+ | '100'
9
+ | '200'
10
+ | '300'
11
+ | '400'
12
+ | '500'
13
+ | '600'
14
+ | '700'
15
+ | '800'
16
+ | '900';
17
+ export type TextAlignOptionType = 'left' | 'center' | 'right' | 'justify';
18
+ export type FlexDirectionOptionType = 'row' | 'column';
19
+ export type AlignItemsOptionType =
20
+ | 'flex-start'
21
+ | 'center'
22
+ | 'flex-end'
23
+ | 'stretch'
24
+ | 'baseline';
25
+ export type JustifyContentOptionType =
26
+ | 'flex-start'
27
+ | 'center'
28
+ | 'flex-end'
29
+ | 'space-between'
30
+ | 'space-around'
31
+ | 'space-evenly';
32
+
5
33
  export interface OnboardFooterPropsGenerated {
6
34
  child: string;
7
35
  attributes: {
8
36
  color?: string;
9
37
  fontSize?: number;
10
- fontWeight?:
11
- | 'normal'
12
- | 'bold'
13
- | '100'
14
- | '200'
15
- | '300'
16
- | '400'
17
- | '500'
18
- | '600'
19
- | '700'
20
- | '800'
21
- | '900';
38
+ fontWeight?: FontWeightOptionType;
39
+ textAlign?: TextAlignOptionType;
22
40
  scrollable?: boolean;
23
- flexDirection?: 'row' | 'column';
24
- alignItems?: 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline';
25
- justifyContent?:
26
- | 'flex-start'
27
- | 'center'
28
- | 'flex-end'
29
- | 'space-between'
30
- | 'space-around'
31
- | 'space-evenly';
41
+ flexDirection?: FlexDirectionOptionType;
42
+ alignItems?: AlignItemsOptionType;
43
+ justifyContent?: JustifyContentOptionType;
32
44
  gap?: string;
33
45
  padding?: number;
34
46
  paddingHorizontal?: string;
@@ -1,10 +1,33 @@
1
- import React from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import type { OnboardImageComponentProps } from './OnboardImageProps.generated';
3
3
  import Image from '../Image/Image';
4
4
  import useNode from '../useNode';
5
+ import Lottie from 'lottie-react';
5
6
 
6
7
  function OnboardImage({ node }: OnboardImageComponentProps) {
7
8
  node = useNode(node);
9
+ const [lottie, setLottie] = useState<string | null>(null);
10
+
11
+ useEffect(() => {
12
+ if (node.attributes?.lottie) {
13
+ fetch(node.attributes?.lottie)
14
+ .then((res) => res.json())
15
+ .then((data) => setLottie(data));
16
+ }
17
+ }, [node.attributes?.lottie]);
18
+
19
+ if (node.attributes?.video_url) {
20
+ return <video autoPlay muted loop src={node.attributes?.video_url} />;
21
+ }
22
+
23
+ if (node.attributes?.lottie) {
24
+ if (lottie) {
25
+ return <Lottie animationData={lottie} />;
26
+ } else {
27
+ return <div>Loading...</div>;
28
+ }
29
+ }
30
+
8
31
  return <Image node={{ ...node, type: 'image' } as any} />;
9
32
  }
10
33
 
@@ -2,14 +2,18 @@
2
2
 
3
3
  import type { NodeData } from '../../types/Node';
4
4
 
5
+ export type ResizeModeOptionType = 'cover' | 'contain' | 'stretch' | 'center';
6
+
5
7
  export interface OnboardImagePropsGenerated {
6
8
  child: string;
7
9
  attributes: {
8
10
  src?: string;
9
11
  width?: number;
10
12
  height?: number;
11
- resizeMode?: 'cover' | 'contain' | 'stretch' | 'center';
13
+ resizeMode?: ResizeModeOptionType;
12
14
  borderRadius?: number;
15
+ video_url?: string;
16
+ lottie?: string;
13
17
  };
14
18
  }
15
19
 
@@ -4,12 +4,10 @@
4
4
  "pattern": {
5
5
  "type": "OnboardImage",
6
6
  "children": "node",
7
+ "extends": "Image",
7
8
  "attributes": {
8
- "src": "string",
9
- "width": "number",
10
- "height": "number",
11
- "resizeMode": ["cover", "contain", "stretch", "center"],
12
- "borderRadius": "number"
9
+ "video_url": "string",
10
+ "lottie": "string"
13
11
  }
14
12
  }
15
13
  }
@@ -2,12 +2,15 @@
2
2
 
3
3
  import type { NodeData } from '../../types/Node';
4
4
 
5
+ export type DisplayOptionType = 'flex' | 'block';
6
+ export type FlexDirectionOptionType = 'row' | 'column';
7
+
5
8
  export interface OnboardItemPropsGenerated {
6
9
  child: string;
7
10
  attributes: {
8
- display?: 'flex' | 'block';
11
+ display?: DisplayOptionType;
9
12
  gap?: string;
10
- flexDirection?: 'row' | 'column';
13
+ flexDirection?: FlexDirectionOptionType;
11
14
  paddingHorizontal?: string;
12
15
  };
13
16
  }
@@ -15,7 +15,6 @@ import useNode from '../useNode';
15
15
  export const onboardContext = createContext<any>(undefined);
16
16
  function OnboardProvider({ node }: OnboardProviderComponentProps) {
17
17
  node = useNode(node);
18
- console.log('node', node);
19
18
  const device = useRenderStore((s) => s.device);
20
19
  const [emblaRef, emblaApi] = useEmblaCarousel(node.attributes as any);
21
20
  const [selectedIndex, setSelectedIndex] = useState(0);
@@ -2,33 +2,45 @@
2
2
 
3
3
  import type { NodeData } from '../../types/Node';
4
4
 
5
+ export type FontWeightOptionType =
6
+ | 'normal'
7
+ | 'bold'
8
+ | '100'
9
+ | '200'
10
+ | '300'
11
+ | '400'
12
+ | '500'
13
+ | '600'
14
+ | '700'
15
+ | '800'
16
+ | '900';
17
+ export type TextAlignOptionType = 'left' | 'center' | 'right' | 'justify';
18
+ export type FlexDirectionOptionType = 'row' | 'column';
19
+ export type AlignItemsOptionType =
20
+ | 'flex-start'
21
+ | 'center'
22
+ | 'flex-end'
23
+ | 'stretch'
24
+ | 'baseline';
25
+ export type JustifyContentOptionType =
26
+ | 'flex-start'
27
+ | 'center'
28
+ | 'flex-end'
29
+ | 'space-between'
30
+ | 'space-around'
31
+ | 'space-evenly';
32
+
5
33
  export interface OnboardSubtitlePropsGenerated {
6
34
  child: string;
7
35
  attributes: {
8
36
  color?: string;
9
37
  fontSize?: number;
10
- fontWeight?:
11
- | 'normal'
12
- | 'bold'
13
- | '100'
14
- | '200'
15
- | '300'
16
- | '400'
17
- | '500'
18
- | '600'
19
- | '700'
20
- | '800'
21
- | '900';
38
+ fontWeight?: FontWeightOptionType;
39
+ textAlign?: TextAlignOptionType;
22
40
  scrollable?: boolean;
23
- flexDirection?: 'row' | 'column';
24
- alignItems?: 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline';
25
- justifyContent?:
26
- | 'flex-start'
27
- | 'center'
28
- | 'flex-end'
29
- | 'space-between'
30
- | 'space-around'
31
- | 'space-evenly';
41
+ flexDirection?: FlexDirectionOptionType;
42
+ alignItems?: AlignItemsOptionType;
43
+ justifyContent?: JustifyContentOptionType;
32
44
  gap?: string;
33
45
  padding?: number;
34
46
  paddingHorizontal?: string;
@@ -5,7 +5,6 @@ import useNode from '../useNode';
5
5
 
6
6
  function OnboardTitle({ node }: OnboardTitleComponentProps) {
7
7
  node = useNode(node);
8
- console.log('node', node);
9
8
  return <Text node={node} />;
10
9
  }
11
10
 
@@ -2,33 +2,45 @@
2
2
 
3
3
  import type { NodeData } from '../../types/Node';
4
4
 
5
+ export type FontWeightOptionType =
6
+ | 'normal'
7
+ | 'bold'
8
+ | '100'
9
+ | '200'
10
+ | '300'
11
+ | '400'
12
+ | '500'
13
+ | '600'
14
+ | '700'
15
+ | '800'
16
+ | '900';
17
+ export type TextAlignOptionType = 'left' | 'center' | 'right' | 'justify';
18
+ export type FlexDirectionOptionType = 'row' | 'column';
19
+ export type AlignItemsOptionType =
20
+ | 'flex-start'
21
+ | 'center'
22
+ | 'flex-end'
23
+ | 'stretch'
24
+ | 'baseline';
25
+ export type JustifyContentOptionType =
26
+ | 'flex-start'
27
+ | 'center'
28
+ | 'flex-end'
29
+ | 'space-between'
30
+ | 'space-around'
31
+ | 'space-evenly';
32
+
5
33
  export interface OnboardTitlePropsGenerated {
6
34
  child: string;
7
35
  attributes: {
8
36
  color?: string;
9
37
  fontSize?: number;
10
- fontWeight?:
11
- | 'normal'
12
- | 'bold'
13
- | '100'
14
- | '200'
15
- | '300'
16
- | '400'
17
- | '500'
18
- | '600'
19
- | '700'
20
- | '800'
21
- | '900';
38
+ fontWeight?: FontWeightOptionType;
39
+ textAlign?: TextAlignOptionType;
22
40
  scrollable?: boolean;
23
- flexDirection?: 'row' | 'column';
24
- alignItems?: 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline';
25
- justifyContent?:
26
- | 'flex-start'
27
- | 'center'
28
- | 'flex-end'
29
- | 'space-between'
30
- | 'space-around'
31
- | 'space-evenly';
41
+ flexDirection?: FlexDirectionOptionType;
42
+ alignItems?: AlignItemsOptionType;
43
+ justifyContent?: JustifyContentOptionType;
32
44
  gap?: string;
33
45
  padding?: number;
34
46
  paddingHorizontal?: string;
@@ -2,28 +2,19 @@ import React from 'react';
2
2
  import type { TextComponentProps } from './TextProps.generated';
3
3
  import useNode from '../useNode';
4
4
  import { useRenderStore } from '../../store';
5
- import { fs, parseSize } from '../../size-matters';
5
+ import { extractTextStyle } from '../../utils/extractTextStyle';
6
6
 
7
7
  function Text({ node }: TextComponentProps) {
8
8
  node = useNode(node);
9
- const { screenStyle, theme } = useRenderStore((s) => ({
10
- screenStyle: s.screenStyle,
11
- theme: s.theme,
12
- }));
13
- const color =
14
- theme === 'light' ? screenStyle.light.color : screenStyle.dark.color;
15
9
  const { defaultLanguage, localication } = useRenderStore((s) => ({
16
10
  defaultLanguage: s.defaultLanguage,
17
11
  localication: s.localication,
18
12
  }));
19
13
  const keyOrText: string = node.children as string;
20
- const style = (node.attributes as React.CSSProperties) ?? {};
21
- const fontSize = node.attributes?.fontSize
22
- ? parseSize(node.attributes.fontSize)
23
- : fs(14);
14
+ const style = extractTextStyle(node);
24
15
 
25
16
  return (
26
- <p style={{ ...style, fontSize, color: style.color ?? color }}>
17
+ <p style={style}>
27
18
  {localication?.[defaultLanguage ?? 'en']?.[keyOrText] ?? keyOrText}
28
19
  </p>
29
20
  );