@developer_tribe/react-builder 1.0.1 → 1.0.3

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 (218) hide show
  1. package/dist/AttributesEditor.d.ts +3 -1
  2. package/dist/DeviceMockFrame.d.ts +2 -1
  3. package/dist/RenderPage.d.ts +5 -3
  4. package/dist/attributes-editor/Field.d.ts +17 -0
  5. package/dist/attributes-editor/FieldInfoTooltip.d.ts +7 -0
  6. package/dist/attributes-editor/LayoutPreviewPicker.d.ts +12 -0
  7. package/dist/attributes-editor/SpecialCategorySection.d.ts +20 -0
  8. package/dist/attributes-editor/types.d.ts +14 -0
  9. package/dist/background.jpg +0 -0
  10. package/dist/build-components/BackgroundImage/BackgroundImage.d.ts +5 -0
  11. package/dist/build-components/BackgroundImage/BackgroundImageProps.generated.d.ts +44 -0
  12. package/dist/build-components/Button/Button.d.ts +1 -1
  13. package/dist/build-components/Button/ButtonProps.generated.d.ts +33 -1
  14. package/dist/build-components/Carousel/CarouselProps.generated.d.ts +34 -1
  15. package/dist/build-components/CarouselButtons/CarouselButtonsProps.generated.d.ts +32 -0
  16. package/dist/build-components/CarouselDots/CarouselDotsProps.generated.d.ts +32 -0
  17. package/dist/build-components/CarouselItem/CarouselItemProps.generated.d.ts +34 -1
  18. package/dist/build-components/CarouselProvider/CarouselProviderProps.generated.d.ts +34 -1
  19. package/dist/build-components/Image/ImageProps.generated.d.ts +32 -3
  20. package/dist/build-components/Onboard/OnboardProps.generated.d.ts +34 -1
  21. package/dist/build-components/OnboardButton/OnboardButtonProps.generated.d.ts +32 -0
  22. package/dist/build-components/OnboardButtons/OnboardButtonsProps.generated.d.ts +32 -0
  23. package/dist/build-components/OnboardDot/OnboardDot.d.ts +1 -1
  24. package/dist/build-components/OnboardDot/OnboardDotProps.generated.d.ts +29 -0
  25. package/dist/build-components/OnboardFooter/OnboardFooterProps.generated.d.ts +11 -5
  26. package/dist/build-components/OnboardImage/OnboardImageProps.generated.d.ts +32 -3
  27. package/dist/build-components/OnboardItem/OnboardItemProps.generated.d.ts +31 -3
  28. package/dist/build-components/OnboardProvider/OnboardProviderProps.generated.d.ts +32 -5
  29. package/dist/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.d.ts +11 -5
  30. package/dist/build-components/OnboardTitle/OnboardTitleProps.generated.d.ts +11 -5
  31. package/dist/build-components/Text/TextProps.generated.d.ts +11 -5
  32. package/dist/build-components/View/ViewProps.generated.d.ts +10 -4
  33. package/dist/build-components/index.d.ts +2 -1
  34. package/dist/build-components/patterns.generated.d.ts +6288 -136
  35. package/dist/components/AttributesEditorPanel.d.ts +3 -4
  36. package/dist/components/Breadcrumb.d.ts +3 -1
  37. package/dist/components/Builder.d.ts +2 -1
  38. package/dist/components/BuilderButton.d.ts +9 -0
  39. package/dist/components/Checkbox.d.ts +17 -0
  40. package/dist/components/DeviceButton.d.ts +8 -0
  41. package/dist/components/DeviceNavigationBar.d.ts +10 -0
  42. package/dist/components/DeviceStatusBar.d.ts +9 -0
  43. package/dist/components/EditorHeader.d.ts +3 -8
  44. package/dist/index.cjs.js +5 -5
  45. package/dist/index.cjs.js.map +1 -1
  46. package/dist/index.d.ts +2 -2
  47. package/dist/index.esm.js +5 -5
  48. package/dist/index.esm.js.map +1 -1
  49. package/dist/mockOS/components/MockLaunchScreenComponent.d.ts +6 -0
  50. package/dist/mockOS/components/MockOSRouter.d.ts +8 -0
  51. package/dist/mockOS/components/PermissionModal.d.ts +9 -0
  52. package/dist/mockOS/context/MockOSContext.d.ts +36 -0
  53. package/dist/mockOS/hooks/useMockNavigation.d.ts +3 -0
  54. package/dist/mockOS/hooks/useMockPermission.d.ts +3 -0
  55. package/dist/mockOS/index.d.ts +9 -0
  56. package/dist/mockOS/managers/mockPermissionManager.d.ts +10 -0
  57. package/dist/mockOS/managers/navigationManager.d.ts +17 -0
  58. package/dist/modals/AddComponentModal.d.ts +8 -0
  59. package/dist/modals/ColorModal.d.ts +11 -0
  60. package/dist/modals/DeviceSelectorModal.d.ts +9 -0
  61. package/dist/modals/LocalicationModal.d.ts +8 -0
  62. package/dist/modals/Modal.d.ts +12 -0
  63. package/dist/modals/index.d.ts +5 -0
  64. package/dist/pages/ProjectPage.d.ts +3 -3
  65. package/dist/pages/tabs/BuilderPanel.d.ts +8 -0
  66. package/dist/pages/tabs/{DebugTab.d.ts → SideTool.d.ts} +2 -2
  67. package/dist/store.d.ts +7 -3
  68. package/dist/styles.css +1 -1
  69. package/dist/types/Project.d.ts +11 -0
  70. package/dist/utils/analyseNode.d.ts +1 -0
  71. package/dist/utils/extractTextStyle.d.ts +8 -1
  72. package/dist/utils/extractViewStyle.d.ts +8 -1
  73. package/dist/utils/parseColor.d.ts +7 -0
  74. package/dist/utils/patterns.d.ts +24 -0
  75. package/package.json +2 -1
  76. package/scripts/prebuild/utils/createGeneratedProps.js +11 -3
  77. package/scripts/prebuild/utils/validateAllComponentsOrThrow.js +45 -6
  78. package/scripts/prebuild/utils/validatePatternJson.js +13 -5
  79. package/src/AttributesEditor.tsx +493 -310
  80. package/src/DeviceMockFrame.tsx +21 -37
  81. package/src/RenderPage.tsx +86 -7
  82. package/src/assets/images/android.svg +42 -42
  83. package/src/assets/images/apple.svg +15 -15
  84. package/src/attributes-editor/Field.tsx +669 -0
  85. package/src/attributes-editor/FieldInfoTooltip.tsx +49 -0
  86. package/src/attributes-editor/LayoutPreviewPicker.tsx +199 -0
  87. package/src/attributes-editor/SpecialCategorySection.tsx +285 -0
  88. package/src/attributes-editor/types.ts +30 -0
  89. package/src/build-components/BackgroundImage/BackgroundImage.tsx +87 -0
  90. package/src/build-components/BackgroundImage/BackgroundImageProps.generated.ts +60 -0
  91. package/src/build-components/BackgroundImage/pattern.json +45 -0
  92. package/src/build-components/Button/Button.tsx +37 -2
  93. package/src/build-components/Button/ButtonProps.generated.ts +44 -1
  94. package/src/build-components/Button/pattern.json +31 -2
  95. package/src/build-components/Carousel/Carousel.tsx +39 -2
  96. package/src/build-components/Carousel/CarouselProps.generated.ts +46 -1
  97. package/src/build-components/Carousel/pattern.json +10 -0
  98. package/src/build-components/CarouselButtons/CarouselButtons.tsx +21 -2
  99. package/src/build-components/CarouselButtons/CarouselButtonsProps.generated.ts +43 -0
  100. package/src/build-components/CarouselButtons/pattern.json +22 -0
  101. package/src/build-components/CarouselDots/CarouselDots.tsx +49 -8
  102. package/src/build-components/CarouselDots/CarouselDotsProps.generated.ts +43 -0
  103. package/src/build-components/CarouselDots/pattern.json +15 -0
  104. package/src/build-components/CarouselItem/CarouselItem.tsx +21 -2
  105. package/src/build-components/CarouselItem/CarouselItemProps.generated.ts +46 -1
  106. package/src/build-components/CarouselItem/pattern.json +7 -0
  107. package/src/build-components/CarouselProvider/CarouselProvider.tsx +21 -2
  108. package/src/build-components/CarouselProvider/CarouselProviderProps.generated.ts +46 -1
  109. package/src/build-components/CarouselProvider/pattern.json +7 -0
  110. package/src/build-components/Image/Image.tsx +33 -2
  111. package/src/build-components/Image/ImageProps.generated.ts +43 -3
  112. package/src/build-components/Image/pattern.json +46 -3
  113. package/src/build-components/Onboard/Onboard.tsx +6 -1
  114. package/src/build-components/Onboard/OnboardProps.generated.ts +46 -1
  115. package/src/build-components/Onboard/pattern.json +11 -0
  116. package/src/build-components/OnboardButton/OnboardButton.tsx +54 -6
  117. package/src/build-components/OnboardButton/OnboardButtonProps.generated.ts +43 -0
  118. package/src/build-components/OnboardButton/pattern.json +71 -5
  119. package/src/build-components/OnboardButtons/OnboardButtons.tsx +33 -11
  120. package/src/build-components/OnboardButtons/OnboardButtonsProps.generated.ts +43 -0
  121. package/src/build-components/OnboardButtons/pattern.json +70 -4
  122. package/src/build-components/OnboardDot/OnboardDot.tsx +113 -4
  123. package/src/build-components/OnboardDot/OnboardDotProps.generated.ts +29 -0
  124. package/src/build-components/OnboardDot/pattern.json +55 -2
  125. package/src/build-components/OnboardFooter/OnboardFooter.tsx +20 -4
  126. package/src/build-components/OnboardFooter/OnboardFooterProps.generated.ts +11 -5
  127. package/src/build-components/OnboardFooter/pattern.json +58 -2
  128. package/src/build-components/OnboardImage/OnboardImage.tsx +49 -5
  129. package/src/build-components/OnboardImage/OnboardImageProps.generated.ts +43 -3
  130. package/src/build-components/OnboardImage/pattern.json +21 -0
  131. package/src/build-components/OnboardItem/OnboardItem.tsx +17 -1
  132. package/src/build-components/OnboardItem/OnboardItemProps.generated.ts +42 -3
  133. package/src/build-components/OnboardItem/pattern.json +38 -2
  134. package/src/build-components/OnboardProvider/OnboardProvider.tsx +52 -18
  135. package/src/build-components/OnboardProvider/OnboardProviderProps.generated.ts +44 -5
  136. package/src/build-components/OnboardProvider/pattern.json +44 -5
  137. package/src/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.ts +11 -5
  138. package/src/build-components/OnboardSubtitle/pattern.json +7 -1
  139. package/src/build-components/OnboardTitle/OnboardTitleProps.generated.ts +11 -5
  140. package/src/build-components/OnboardTitle/pattern.json +7 -1
  141. package/src/build-components/RenderNode.generated.tsx +3 -0
  142. package/src/build-components/Text/Text.tsx +34 -6
  143. package/src/build-components/Text/TextProps.generated.ts +11 -5
  144. package/src/build-components/Text/pattern.json +38 -2
  145. package/src/build-components/View/View.tsx +33 -6
  146. package/src/build-components/View/ViewProps.generated.ts +10 -4
  147. package/src/build-components/View/pattern.json +285 -19
  148. package/src/build-components/index.ts +5 -0
  149. package/src/build-components/patterns.generated.ts +6346 -143
  150. package/src/components/AttributesEditorPanel.tsx +17 -64
  151. package/src/components/Breadcrumb.tsx +37 -5
  152. package/src/components/Builder.tsx +311 -108
  153. package/src/components/BuilderButton.tsx +127 -0
  154. package/src/components/Checkbox.tsx +81 -0
  155. package/src/components/DeviceButton.tsx +39 -0
  156. package/src/components/DeviceNavigationBar.tsx +201 -0
  157. package/src/components/DeviceStatusBar.tsx +85 -0
  158. package/src/components/EditorHeader.tsx +26 -74
  159. package/src/index.ts +2 -2
  160. package/src/mockOS/components/MockLaunchScreenComponent.tsx +43 -0
  161. package/src/mockOS/components/MockOSRouter.tsx +123 -0
  162. package/src/mockOS/components/PermissionModal.tsx +270 -0
  163. package/src/mockOS/context/MockOSContext.tsx +179 -0
  164. package/src/mockOS/hooks/useMockNavigation.ts +11 -0
  165. package/src/mockOS/hooks/useMockPermission.ts +11 -0
  166. package/src/mockOS/index.ts +26 -0
  167. package/src/mockOS/managers/mockPermissionManager.ts +54 -0
  168. package/src/mockOS/managers/navigationManager.ts +91 -0
  169. package/src/modals/AddComponentModal.tsx +313 -0
  170. package/src/modals/ColorModal.tsx +425 -0
  171. package/src/modals/DeviceSelectorModal.tsx +57 -0
  172. package/src/modals/LocalicationModal.tsx +54 -0
  173. package/src/modals/Modal.tsx +57 -0
  174. package/src/modals/index.ts +5 -0
  175. package/src/pages/ProjectPage.tsx +307 -71
  176. package/src/pages/tabs/{BuilderTab.tsx → BuilderPanel.tsx} +13 -9
  177. package/src/pages/tabs/SideTool.tsx +259 -0
  178. package/src/size-matters/index.ts +27 -5
  179. package/src/store.ts +13 -5
  180. package/src/styles/base/_global.scss +404 -0
  181. package/src/styles/components/_attributes-editor.scss +273 -0
  182. package/src/styles/components/_editor-shell.scss +212 -0
  183. package/src/styles/components/_mockos-router.scss +140 -0
  184. package/src/styles/components/_ui-components.scss +183 -0
  185. package/src/styles/foundation/_colors.scss +8 -0
  186. package/src/styles/{_mixins.scss → foundation/_mixins.scss} +5 -4
  187. package/src/styles/{_reset.scss → foundation/_reset.scss} +5 -2
  188. package/src/styles/foundation/_sizes.scss +37 -0
  189. package/src/styles/foundation/_typography.scss +4 -0
  190. package/src/styles/foundation/_variables.scss +3 -0
  191. package/src/styles/index.scss +22 -136
  192. package/src/styles/layout/_builder.scss +124 -0
  193. package/src/styles/layout/_pages.scss +3 -0
  194. package/src/styles/modals/_add-component.scss +122 -0
  195. package/src/styles/modals/_color-modal.scss +159 -0
  196. package/src/styles/modals/_device-selector.scss +18 -0
  197. package/src/styles/modals/_localication-modal.scss +68 -0
  198. package/src/styles/modals/_modal-shell.scss +46 -0
  199. package/src/styles/utilities/_carousel.scss +125 -0
  200. package/src/types/Project.ts +14 -0
  201. package/src/types/images.d.ts +8 -0
  202. package/src/utils/analyseNode.ts +98 -0
  203. package/src/utils/extractTextStyle.ts +28 -10
  204. package/src/utils/extractViewStyle.ts +77 -9
  205. package/src/utils/parseColor.ts +43 -0
  206. package/src/utils/patterns.ts +33 -0
  207. package/dist/build-components/OnboardDot/OnboardExpandingDotProps.generated.d.ts +0 -10
  208. package/dist/pages/tabs/BuilderTab.d.ts +0 -9
  209. package/dist/pages/tabs/PreviewTab.d.ts +0 -3
  210. package/src/build-components/OnboardDot/OnboardExpandingDotProps.generated.ts +0 -20
  211. package/src/pages/tabs/DebugTab.tsx +0 -23
  212. package/src/pages/tabs/PreviewTab.tsx +0 -194
  213. package/src/styles/_variables.scss +0 -27
  214. package/src/styles/builder.scss +0 -60
  215. package/src/styles/components.scss +0 -88
  216. package/src/styles/editor.scss +0 -174
  217. package/src/styles/global.scss +0 -200
  218. package/src/styles/pages.scss +0 -2
@@ -1,14 +1,28 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import React, { useEffect, useId, useMemo, 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
5
  import Lottie from 'lottie-react';
6
6
  import { useLogRender } from '../../utils/useLogRender';
7
+ import { extractViewStyle } from '../../utils/extractViewStyle';
8
+ import { useRenderStore } from '../../store';
7
9
 
8
10
  function OnboardImage({ node }: OnboardImageComponentProps) {
9
11
  useLogRender('OnboardImage');
10
12
  node = useNode(node);
13
+ const generatedId = useId();
14
+ const attributeName =
15
+ (node as any)?.sourceType ?? node.type ?? 'OnboardImage';
16
+ const attributeKey = node.key ?? generatedId;
11
17
  const [lottie, setLottie] = useState<string | null>(null);
18
+ const { appConfig, projectColors } = useRenderStore((s) => ({
19
+ appConfig: s.appConfig,
20
+ projectColors: s.projectColors,
21
+ }));
22
+ const viewStyle = useMemo(
23
+ () => extractViewStyle(node, { appConfig, projectColors }),
24
+ [node, appConfig, projectColors],
25
+ );
12
26
 
13
27
  useEffect(() => {
14
28
  if (node.attributes?.lottie) {
@@ -19,18 +33,48 @@ function OnboardImage({ node }: OnboardImageComponentProps) {
19
33
  }, [node.attributes?.lottie]);
20
34
 
21
35
  if (node.attributes?.video_url) {
22
- return <video autoPlay muted loop src={node.attributes?.video_url} />;
36
+ return (
37
+ <video
38
+ attribute-name={attributeName}
39
+ attribute-key={attributeKey}
40
+ autoPlay
41
+ muted
42
+ loop
43
+ src={node.attributes?.video_url}
44
+ style={viewStyle}
45
+ />
46
+ );
23
47
  }
24
48
 
25
49
  if (node.attributes?.lottie) {
26
50
  if (lottie) {
27
- return <Lottie animationData={lottie} />;
51
+ return (
52
+ <div
53
+ attribute-name={attributeName}
54
+ attribute-key={attributeKey}
55
+ style={viewStyle}
56
+ >
57
+ <Lottie animationData={lottie} />
58
+ </div>
59
+ );
28
60
  } else {
29
- return <div>Loading...</div>;
61
+ return (
62
+ <div
63
+ attribute-name={attributeName}
64
+ attribute-key={attributeKey}
65
+ style={viewStyle}
66
+ >
67
+ Loading...
68
+ </div>
69
+ );
30
70
  }
31
71
  }
32
72
 
33
- return <Image node={{ ...node, type: 'image' } as any} />;
73
+ return (
74
+ <Image
75
+ node={{ ...node, type: 'image', sourceType: attributeName } as any}
76
+ />
77
+ );
34
78
  }
35
79
 
36
80
  export default React.memo(OnboardImage);
@@ -3,15 +3,55 @@
3
3
  import type { NodeData } from '../../types/Node';
4
4
 
5
5
  export type ResizeModeOptionType = 'cover' | 'contain' | 'stretch' | 'center';
6
+ export type FlexDirectionOptionType = 'row' | 'column';
7
+ export type AlignItemsOptionType =
8
+ | 'flex-start'
9
+ | 'center'
10
+ | 'flex-end'
11
+ | 'stretch'
12
+ | 'baseline';
13
+ export type JustifyContentOptionType =
14
+ | 'flex-start'
15
+ | 'center'
16
+ | 'flex-end'
17
+ | 'space-between'
18
+ | 'space-around'
19
+ | 'space-evenly';
20
+ export type PositionOptionType = 'relative' | 'absolute';
6
21
 
7
22
  export interface OnboardImagePropsGenerated {
8
23
  child: string;
9
24
  attributes: {
10
25
  src?: string;
11
- width?: number;
12
- height?: number;
26
+ width?: string;
27
+ height?: string;
13
28
  resizeMode?: ResizeModeOptionType;
14
- borderRadius?: number;
29
+ borderRadius?: string;
30
+ scrollable?: boolean;
31
+ flexDirection?: FlexDirectionOptionType;
32
+ alignItems?: AlignItemsOptionType;
33
+ justifyContent?: JustifyContentOptionType;
34
+ gap?: string;
35
+ padding?: string;
36
+ paddingHorizontal?: string;
37
+ paddingVertical?: string;
38
+ paddingTop?: string;
39
+ paddingBottom?: string;
40
+ paddingLeft?: string;
41
+ paddingRight?: string;
42
+ margin?: string;
43
+ marginVertical?: string;
44
+ marginTop?: string;
45
+ marginBottom?: string;
46
+ marginLeft?: string;
47
+ marginRight?: string;
48
+ backgroundColor?: string;
49
+ position?: PositionOptionType;
50
+ top?: string;
51
+ bottom?: string;
52
+ left?: string;
53
+ right?: string;
54
+ zIndex?: number;
15
55
  video_url?: string;
16
56
  lottie?: string;
17
57
  };
@@ -9,5 +9,26 @@
9
9
  "video_url": "string",
10
10
  "lottie": "string"
11
11
  }
12
+ },
13
+ "meta": {
14
+ "desiredParent": [">OnboardProvider", ">OnboardItem", "!=Onboard"],
15
+ "label": "Onboard Image",
16
+ "description": "Onboarding hero image with media.",
17
+ "attributes": {
18
+ "video_url": {
19
+ "label": "Video Url",
20
+ "description": "URL for the onboarding video.",
21
+ "category": "other",
22
+ "specialCategory": null,
23
+ "sort": 1
24
+ },
25
+ "lottie": {
26
+ "label": "Lottie",
27
+ "description": "Path to the lottie animation.",
28
+ "category": "other",
29
+ "specialCategory": null,
30
+ "sort": 2
31
+ }
32
+ }
12
33
  }
13
34
  }
@@ -1,20 +1,36 @@
1
- import React from 'react';
1
+ import React, { useId, useMemo } from 'react';
2
2
  import type { OnboardItemComponentProps } from './OnboardItemProps.generated';
3
3
  import useNode from '../useNode';
4
4
  import { RenderNode } from '../..';
5
+ import { useRenderStore } from '../../store';
5
6
  import { parseSize } from '../../size-matters';
6
7
  import { useLogRender } from '../../utils/useLogRender';
8
+ import { extractViewStyle } from '../../utils/extractViewStyle';
7
9
 
8
10
  function OnboardItem({ node }: OnboardItemComponentProps) {
9
11
  useLogRender('OnboardItem');
10
12
  node = useNode(node);
13
+ const generatedId = useId();
14
+ const attributeName = (node as any)?.sourceType ?? node.type ?? 'OnboardItem';
15
+ const attributeKey = node.key ?? generatedId;
11
16
  const flexDirection = node.attributes?.flexDirection;
12
17
  const display = node.attributes?.display;
13
18
  const paddingHorizontal = parseSize(node.attributes?.paddingHorizontal);
19
+ const { appConfig, projectColors } = useRenderStore((s) => ({
20
+ appConfig: s.appConfig,
21
+ projectColors: s.projectColors,
22
+ }));
23
+ const viewStyle = useMemo(
24
+ () => extractViewStyle(node, { appConfig, projectColors }),
25
+ [node, appConfig, projectColors],
26
+ );
14
27
  return (
15
28
  <div
29
+ attribute-name={attributeName}
30
+ attribute-key={attributeKey}
16
31
  className="embla__slide"
17
32
  style={{
33
+ ...viewStyle,
18
34
  gap: parseSize(node.attributes?.gap),
19
35
  flexDirection,
20
36
  display,
@@ -2,16 +2,55 @@
2
2
 
3
3
  import type { NodeData } from '../../types/Node';
4
4
 
5
- export type DisplayOptionType = 'flex' | 'block';
6
5
  export type FlexDirectionOptionType = 'row' | 'column';
6
+ export type AlignItemsOptionType =
7
+ | 'flex-start'
8
+ | 'center'
9
+ | 'flex-end'
10
+ | 'stretch'
11
+ | 'baseline';
12
+ export type JustifyContentOptionType =
13
+ | 'flex-start'
14
+ | 'center'
15
+ | 'flex-end'
16
+ | 'space-between'
17
+ | 'space-around'
18
+ | 'space-evenly';
19
+ export type PositionOptionType = 'relative' | 'absolute';
20
+ export type DisplayOptionType = 'flex' | 'block';
7
21
 
8
22
  export interface OnboardItemPropsGenerated {
9
23
  child: string;
10
24
  attributes: {
11
- display?: DisplayOptionType;
12
- gap?: string;
25
+ scrollable?: boolean;
13
26
  flexDirection?: FlexDirectionOptionType;
27
+ alignItems?: AlignItemsOptionType;
28
+ justifyContent?: JustifyContentOptionType;
29
+ gap?: string;
30
+ padding?: string;
14
31
  paddingHorizontal?: string;
32
+ paddingVertical?: string;
33
+ paddingTop?: string;
34
+ paddingBottom?: string;
35
+ paddingLeft?: string;
36
+ paddingRight?: string;
37
+ margin?: string;
38
+ marginVertical?: string;
39
+ marginTop?: string;
40
+ marginBottom?: string;
41
+ marginLeft?: string;
42
+ marginRight?: string;
43
+ backgroundColor?: string;
44
+ borderRadius?: string;
45
+ width?: string;
46
+ height?: string;
47
+ position?: PositionOptionType;
48
+ top?: string;
49
+ bottom?: string;
50
+ left?: string;
51
+ right?: string;
52
+ zIndex?: number;
53
+ display?: DisplayOptionType;
15
54
  };
16
55
  }
17
56
 
@@ -4,11 +4,12 @@
4
4
  "pattern": {
5
5
  "type": "OnboardItem",
6
6
  "children": "node",
7
+ "extends": "View",
7
8
  "attributes": {
8
9
  "display": ["flex", "block"],
9
- "gap": "string",
10
+ "gap": "size",
10
11
  "flexDirection": ["row", "column"],
11
- "paddingHorizontal": "string"
12
+ "paddingHorizontal": "size"
12
13
  }
13
14
  },
14
15
  "defaults": {
@@ -16,5 +17,40 @@
16
17
  "display": "flex",
17
18
  "flexDirection": "column",
18
19
  "paddingHorizontal": "24@s"
20
+ },
21
+ "meta": {
22
+ "desiredParent": ["=Onboard"],
23
+ "label": "Onboard Item",
24
+ "description": "Single onboarding screen section.",
25
+ "attributes": {
26
+ "display": {
27
+ "label": "Display",
28
+ "description": "Controls layout display mode.",
29
+ "category": "container",
30
+ "specialCategory": null,
31
+ "sort": 1
32
+ },
33
+ "gap": {
34
+ "label": "Gap",
35
+ "description": "Space between child blocks.",
36
+ "category": "container",
37
+ "specialCategory": null,
38
+ "sort": 2
39
+ },
40
+ "flexDirection": {
41
+ "label": "Flex Direction",
42
+ "description": "Order of child stacking.",
43
+ "category": "container",
44
+ "specialCategory": null,
45
+ "sort": 3
46
+ },
47
+ "paddingHorizontal": {
48
+ "label": "Padding Horizontal",
49
+ "description": "Left and right padding.",
50
+ "category": "container",
51
+ "specialCategory": "padding",
52
+ "sort": 4
53
+ }
54
+ }
19
55
  }
20
56
  }
@@ -2,6 +2,7 @@ import React, {
2
2
  createContext,
3
3
  useContext,
4
4
  useEffect,
5
+ useId,
5
6
  useMemo,
6
7
  useState,
7
8
  } from 'react';
@@ -12,29 +13,52 @@ import RenderNode from '../RenderNode.generated';
12
13
  import { useRenderStore } from '../../store';
13
14
  import useNode from '../useNode';
14
15
  import { useLogRender } from '../../utils/useLogRender';
16
+ import { extractViewStyle } from '../../utils/extractViewStyle';
17
+ import { ViewPropsGenerated } from '../View/ViewProps.generated';
15
18
 
16
19
  export const onboardContext = createContext<any>(undefined);
17
20
  function OnboardProvider({ node }: OnboardProviderComponentProps) {
18
21
  useLogRender('OnboardProvider');
19
22
  node = useNode(node);
23
+ const generatedId = useId();
24
+ const attributeName =
25
+ (node as any)?.sourceType ?? node.type ?? 'OnboardProvider';
20
26
  const device = useRenderStore((s) => s.device);
27
+ const { appConfig, projectColors } = useRenderStore((s) => ({
28
+ appConfig: s.appConfig,
29
+ projectColors: s.projectColors,
30
+ }));
21
31
  const [emblaRef, emblaApi] = useEmblaCarousel(node.attributes as any);
22
32
  const [selectedIndex, setSelectedIndex] = useState(0);
33
+ const attributeKey = node.key ?? generatedId;
23
34
 
24
35
  const children = useMemo(() => {
25
- const onboardChild: NodeData = (node.children as NodeData[]).filter(
26
- (c) => c.type === 'Onboard',
27
- )[0];
28
- if (onboardChild?.type !== 'Onboard') {
29
- throw new Error('OnboardProvider at least has an Onboard child');
36
+ const allChildren = (node.children as NodeData[]) ?? [];
37
+
38
+ // Find the main Onboard child, if any
39
+ const onboardChild = allChildren.find((c) => c.type === 'Onboard');
40
+ if (!onboardChild || onboardChild.type !== 'Onboard') {
41
+ // Fallback: no onboard structure, just render original children
42
+ return allChildren;
43
+ }
44
+
45
+ const onboardItems = (onboardChild.children as NodeData[]) ?? [];
46
+ if (!onboardItems.length) {
47
+ return allChildren;
30
48
  }
31
- const onboardItems = onboardChild.children as NodeData[];
32
49
 
50
+ // Clamp selected index to available items
51
+ const clampedIndex = Math.min(
52
+ Math.max(selectedIndex, 0),
53
+ onboardItems.length - 1,
54
+ );
55
+
56
+ const selectedItem = onboardItems[clampedIndex];
33
57
  const onboardButtons = (
34
- onboardItems[selectedIndex].children as NodeData[]
35
- ).filter((s) => (s as NodeData)?.type == 'OnboardButtons');
36
- const children: NodeData[] = node.children as NodeData[];
37
- return [...children, ...onboardButtons];
58
+ (selectedItem?.children as NodeData[]) ?? []
59
+ ).filter((s) => (s as NodeData)?.type === 'OnboardButtons');
60
+
61
+ return [...allChildren, ...onboardButtons];
38
62
  }, [selectedIndex, node.children]);
39
63
 
40
64
  useEffect(() => {
@@ -51,19 +75,29 @@ function OnboardProvider({ node }: OnboardProviderComponentProps) {
51
75
  }
52
76
  }, [theme]);*/
53
77
 
78
+ //TODO: pattern içinde direk gömmek yerine orada da inhertince eklenebilir
79
+ const viewStyle = useMemo(() => {
80
+ const style = extractViewStyle(
81
+ node as NodeData<ViewPropsGenerated['attributes']>,
82
+ { appConfig, projectColors },
83
+ );
84
+ //NOTE: Embla için istisna
85
+ style.display = 'block';
86
+ return style;
87
+ }, [node, appConfig, projectColors]);
88
+
54
89
  return (
55
90
  <onboardContext.Provider value={{ emblaApi, selectedIndex }}>
56
91
  <div
92
+ attribute-name={attributeName}
93
+ attribute-key={attributeKey}
57
94
  className="carousel-provider"
58
95
  style={{
59
- paddingTop:
60
- device?.insets?.[0] + (node.attributes as any)?.paddingTop,
61
- paddingRight:
62
- device?.insets?.[1] + (node.attributes as any)?.paddingRight,
63
- paddingBottom:
64
- device?.insets?.[2] + (node.attributes as any)?.paddingBottom,
65
- paddingLeft:
66
- device?.insets?.[3] + (node.attributes as any)?.paddingLeft,
96
+ ...viewStyle,
97
+ paddingTop: node.attributes?.paddingTop,
98
+ paddingRight: node.attributes?.paddingRight,
99
+ paddingBottom: node.attributes?.paddingBottom,
100
+ paddingLeft: node.attributes?.paddingLeft,
67
101
  }}
68
102
  >
69
103
  <div className="embla">
@@ -2,15 +2,54 @@
2
2
 
3
3
  import type { NodeData } from '../../types/Node';
4
4
 
5
+ export type FlexDirectionOptionType = 'row' | 'column';
6
+ export type AlignItemsOptionType =
7
+ | 'flex-start'
8
+ | 'center'
9
+ | 'flex-end'
10
+ | 'stretch'
11
+ | 'baseline';
12
+ export type JustifyContentOptionType =
13
+ | 'flex-start'
14
+ | 'center'
15
+ | 'flex-end'
16
+ | 'space-between'
17
+ | 'space-around'
18
+ | 'space-evenly';
19
+ export type PositionOptionType = 'relative' | 'absolute';
20
+
5
21
  export interface OnboardProviderPropsGenerated {
6
22
  child: string;
7
23
  attributes: {
8
- theme?: string;
24
+ scrollable?: boolean;
25
+ flexDirection?: FlexDirectionOptionType;
26
+ alignItems?: AlignItemsOptionType;
27
+ justifyContent?: JustifyContentOptionType;
28
+ gap?: string;
29
+ padding?: string;
30
+ paddingHorizontal?: string;
31
+ paddingVertical?: string;
32
+ paddingTop?: string;
33
+ paddingBottom?: string;
34
+ paddingLeft?: string;
35
+ paddingRight?: string;
36
+ margin?: string;
37
+ marginVertical?: string;
38
+ marginTop?: string;
39
+ marginBottom?: string;
40
+ marginLeft?: string;
41
+ marginRight?: string;
42
+ backgroundColor?: string;
43
+ borderRadius?: never;
44
+ width?: string;
45
+ height?: string;
46
+ position?: PositionOptionType;
47
+ top?: string;
48
+ bottom?: string;
49
+ left?: string;
50
+ right?: string;
51
+ zIndex?: number;
9
52
  use_safe_area_inset?: boolean;
10
- paddingTop?: number;
11
- paddingRight?: number;
12
- paddingBottom?: number;
13
- paddingLeft?: number;
14
53
  };
15
54
  }
16
55
 
@@ -4,13 +4,10 @@
4
4
  "pattern": {
5
5
  "type": "OnboardProvider",
6
6
  "children": "node",
7
+ "extends": "View",
7
8
  "attributes": {
8
- "theme": "string",
9
9
  "use_safe_area_inset": "boolean",
10
- "paddingTop": "number",
11
- "paddingRight": "number",
12
- "paddingBottom": "number",
13
- "paddingLeft": "number"
10
+ "borderRadius": "never"
14
11
  }
15
12
  },
16
13
  "defaults": {
@@ -18,5 +15,47 @@
18
15
  "paddingRight": 0,
19
16
  "paddingBottom": 8,
20
17
  "paddingLeft": 0
18
+ },
19
+ "meta": {
20
+ "desiredParent": ["root"],
21
+ "label": "Onboard Provider",
22
+ "description": "Provides shared settings for onboarding.",
23
+ "attributes": {
24
+ "use_safe_area_inset": {
25
+ "label": "Use Safe Area Inset",
26
+ "description": "Adds safe area padding.",
27
+ "category": "container",
28
+ "specialCategory": null,
29
+ "sort": 2
30
+ },
31
+ "paddingTop": {
32
+ "label": "Padding Top",
33
+ "description": "Top padding for the provider.",
34
+ "category": "container",
35
+ "specialCategory": "padding",
36
+ "sort": 3
37
+ },
38
+ "paddingRight": {
39
+ "label": "Padding Right",
40
+ "description": "Right padding for the provider.",
41
+ "category": "container",
42
+ "specialCategory": "padding",
43
+ "sort": 4
44
+ },
45
+ "paddingBottom": {
46
+ "label": "Padding Bottom",
47
+ "description": "Bottom padding for the provider.",
48
+ "category": "container",
49
+ "specialCategory": "padding",
50
+ "sort": 5
51
+ },
52
+ "paddingLeft": {
53
+ "label": "Padding Left",
54
+ "description": "Left padding for the provider.",
55
+ "category": "container",
56
+ "specialCategory": "padding",
57
+ "sort": 6
58
+ }
59
+ }
21
60
  }
22
61
  }
@@ -29,12 +29,13 @@ export type JustifyContentOptionType =
29
29
  | 'space-between'
30
30
  | 'space-around'
31
31
  | 'space-evenly';
32
+ export type PositionOptionType = 'relative' | 'absolute';
32
33
 
33
34
  export interface OnboardSubtitlePropsGenerated {
34
35
  child: string;
35
36
  attributes: {
36
37
  color?: string;
37
- fontSize?: number;
38
+ fontSize?: string;
38
39
  fontWeight?: FontWeightOptionType;
39
40
  textAlign?: TextAlignOptionType;
40
41
  scrollable?: boolean;
@@ -42,7 +43,7 @@ export interface OnboardSubtitlePropsGenerated {
42
43
  alignItems?: AlignItemsOptionType;
43
44
  justifyContent?: JustifyContentOptionType;
44
45
  gap?: string;
45
- padding?: number;
46
+ padding?: string;
46
47
  paddingHorizontal?: string;
47
48
  paddingVertical?: string;
48
49
  paddingTop?: string;
@@ -50,7 +51,6 @@ export interface OnboardSubtitlePropsGenerated {
50
51
  paddingLeft?: string;
51
52
  paddingRight?: string;
52
53
  margin?: string;
53
- marginHorizontal?: string;
54
54
  marginVertical?: string;
55
55
  marginTop?: string;
56
56
  marginBottom?: string;
@@ -58,8 +58,14 @@ export interface OnboardSubtitlePropsGenerated {
58
58
  marginRight?: string;
59
59
  backgroundColor?: string;
60
60
  borderRadius?: string;
61
- width?: number;
62
- height?: number;
61
+ width?: string;
62
+ height?: string;
63
+ position?: PositionOptionType;
64
+ top?: string;
65
+ bottom?: string;
66
+ left?: string;
67
+ right?: string;
68
+ zIndex?: number;
63
69
  };
64
70
  }
65
71
 
@@ -3,12 +3,18 @@
3
3
  "allowUnknownAttributes": false,
4
4
  "pattern": {
5
5
  "type": "OnboardSubtitle",
6
- "children": "node",
6
+ "children": "string",
7
7
  "extends": "Text",
8
8
  "attributes": {}
9
9
  },
10
10
  "defaults": {
11
11
  "fontSize": "14@fs",
12
12
  "fontWeight": "600"
13
+ },
14
+ "meta": {
15
+ "desiredParent": [">OnboardProvider", ">OnboardItem"],
16
+ "label": "Onboard Subtitle",
17
+ "description": "Subtitle text for an onboarding step.",
18
+ "attributes": {}
13
19
  }
14
20
  }
@@ -29,12 +29,13 @@ export type JustifyContentOptionType =
29
29
  | 'space-between'
30
30
  | 'space-around'
31
31
  | 'space-evenly';
32
+ export type PositionOptionType = 'relative' | 'absolute';
32
33
 
33
34
  export interface OnboardTitlePropsGenerated {
34
35
  child: string;
35
36
  attributes: {
36
37
  color?: string;
37
- fontSize?: number;
38
+ fontSize?: string;
38
39
  fontWeight?: FontWeightOptionType;
39
40
  textAlign?: TextAlignOptionType;
40
41
  scrollable?: boolean;
@@ -42,7 +43,7 @@ export interface OnboardTitlePropsGenerated {
42
43
  alignItems?: AlignItemsOptionType;
43
44
  justifyContent?: JustifyContentOptionType;
44
45
  gap?: string;
45
- padding?: number;
46
+ padding?: string;
46
47
  paddingHorizontal?: string;
47
48
  paddingVertical?: string;
48
49
  paddingTop?: string;
@@ -50,7 +51,6 @@ export interface OnboardTitlePropsGenerated {
50
51
  paddingLeft?: string;
51
52
  paddingRight?: string;
52
53
  margin?: string;
53
- marginHorizontal?: string;
54
54
  marginVertical?: string;
55
55
  marginTop?: string;
56
56
  marginBottom?: string;
@@ -58,8 +58,14 @@ export interface OnboardTitlePropsGenerated {
58
58
  marginRight?: string;
59
59
  backgroundColor?: string;
60
60
  borderRadius?: string;
61
- width?: number;
62
- height?: number;
61
+ width?: string;
62
+ height?: string;
63
+ position?: PositionOptionType;
64
+ top?: string;
65
+ bottom?: string;
66
+ left?: string;
67
+ right?: string;
68
+ zIndex?: number;
63
69
  };
64
70
  }
65
71