@developer_tribe/react-builder 1.2.0 → 1.2.2

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 (53) hide show
  1. package/dist/hooks/useExtractTextStyle.d.ts +9 -0
  2. package/dist/hooks/useExtractViewStyle.d.ts +9 -0
  3. package/dist/index.cjs.js +2 -2
  4. package/dist/index.cjs.js.map +1 -1
  5. package/dist/index.d.ts +2 -0
  6. package/dist/index.esm.js +2 -2
  7. package/dist/index.esm.js.map +1 -1
  8. package/dist/index.native.cjs.js +1 -1
  9. package/dist/index.native.cjs.js.map +1 -1
  10. package/dist/index.native.d.ts +1 -0
  11. package/dist/index.native.esm.js +1 -1
  12. package/dist/index.native.esm.js.map +1 -1
  13. package/dist/pages/ProjectPage.d.ts +10 -3
  14. package/dist/types/Fonts.d.ts +5 -1
  15. package/dist/utils/extractTextStyle/extractTextStyle.d.ts +9 -0
  16. package/dist/utils/extractTextStyle.d.ts +2 -10
  17. package/dist/utils/extractViewStyle/extractViewStyle.d.ts +9 -0
  18. package/dist/utils/extractViewStyle.d.ts +2 -9
  19. package/package.json +1 -1
  20. package/src/build-components/BIcon/BIcon.tsx +5 -6
  21. package/src/build-components/BackgroundImage/BackgroundImage.tsx +2 -5
  22. package/src/build-components/Button/Button.tsx +20 -15
  23. package/src/build-components/Carousel/Carousel.tsx +5 -5
  24. package/src/build-components/CarouselButtons/CarouselButtons.tsx +3 -6
  25. package/src/build-components/CarouselDots/CarouselDots.tsx +3 -5
  26. package/src/build-components/CarouselItem/CarouselItem.tsx +3 -6
  27. package/src/build-components/CarouselProvider/CarouselProvider.tsx +2 -5
  28. package/src/build-components/Main/Main.tsx +5 -9
  29. package/src/build-components/OnboardButton/OnboardButton.tsx +5 -5
  30. package/src/build-components/OnboardButtons/OnboardButtons.tsx +6 -6
  31. package/src/build-components/OnboardDot/OnboardDot.tsx +8 -4
  32. package/src/build-components/OnboardFooter/OnboardFooter.tsx +10 -10
  33. package/src/build-components/OnboardImage/OnboardImage.tsx +6 -6
  34. package/src/build-components/OnboardItem/OnboardItem.tsx +5 -6
  35. package/src/build-components/OnboardProvider/OnboardProvider.tsx +13 -10
  36. package/src/build-components/PaywallBackground/PaywallBackground.tsx +2 -5
  37. package/src/build-components/PaywallCloseButton/PaywallCloseButton.tsx +5 -5
  38. package/src/build-components/PaywallOptions/PaywallOptionButton.tsx +2 -5
  39. package/src/build-components/PaywallProvider/PaywallProvider.tsx +5 -5
  40. package/src/build-components/PaywallSubscribeButton/PaywallSubscribeButton.tsx +5 -5
  41. package/src/build-components/RadioButton/RadioButton.tsx +5 -5
  42. package/src/build-components/Text/Text.tsx +2 -5
  43. package/src/build-components/View/View.tsx +3 -6
  44. package/src/hooks/useExtractTextStyle.ts +30 -0
  45. package/src/hooks/useExtractViewStyle.ts +28 -0
  46. package/src/index.native.ts +3 -0
  47. package/src/index.ts +2 -0
  48. package/src/pages/ProjectPage.tsx +15 -5
  49. package/src/types/Fonts.ts +5 -1
  50. package/src/utils/extractTextStyle/extractTextStyle.ts +160 -0
  51. package/src/utils/extractTextStyle.ts +2 -160
  52. package/src/utils/extractViewStyle/extractViewStyle.ts +145 -0
  53. package/src/utils/extractViewStyle.ts +2 -145
@@ -10,7 +10,14 @@ export type ProjectPageProps = {
10
10
  projectColors?: ProjectColors;
11
11
  onSaveProjectColors?: (colors: ProjectColors) => void;
12
12
  name?: string;
13
- fonts: Fonts;
14
- appFont: string | undefined;
13
+ typography: {
14
+ fonts: Fonts;
15
+ };
16
+ /**
17
+ * Optional. If omitted, `ProjectPage` will infer it from `typography.fonts`:
18
+ * - first font with `isMain: true`
19
+ * - else first font in the list
20
+ */
21
+ appFont?: string | undefined;
15
22
  };
16
- export declare function ProjectPage({ project, appConfig, onSaveProject, logLevel, projectColors, onSaveProjectColors, name, fonts, appFont, }: ProjectPageProps): import("react/jsx-runtime").JSX.Element;
23
+ export declare function ProjectPage({ project, appConfig, onSaveProject, logLevel, projectColors, onSaveProjectColors, name, typography, appFont, }: ProjectPageProps): import("react/jsx-runtime").JSX.Element;
@@ -3,10 +3,14 @@ export type FontWeightKey = string;
3
3
  /** URL to a font file (ttf/otf/woff/woff2). */
4
4
  export type FontFileUrl = string;
5
5
  /** Map of font-weight -> font file URL. */
6
- export type FontFamilySources = Record<FontWeightKey, FontFileUrl>;
6
+ export type FontFamilySources = Record<FontWeightKey, FontFileUrl | undefined>;
7
7
  export type FontDefinition = {
8
8
  name: string;
9
9
  family: FontFamilySources;
10
10
  projects?: string[];
11
+ /** Optional language target for this font (e.g. "ar"). */
12
+ targetLanguage?: string;
13
+ /** Optional marker to pick a default app font. */
14
+ isMain?: boolean;
11
15
  };
12
16
  export type Fonts = FontDefinition[];
@@ -0,0 +1,9 @@
1
+ import type { NodeData } from '../../types/Node';
2
+ import type { TextPropsGenerated } from '../../build-components/Text/TextProps.generated';
3
+ import type { AppConfig } from '../../types/PreviewConfig';
4
+ import type { ProjectColors } from '../../types/Project';
5
+ export type ExtractTextStyleOptions = {
6
+ appConfig?: AppConfig;
7
+ projectColors?: ProjectColors;
8
+ };
9
+ export declare function extractTextStyle<T extends TextPropsGenerated['attributes']>(node: NodeData<T>, options?: ExtractTextStyleOptions): import("react").CSSProperties;
@@ -1,10 +1,2 @@
1
- import type { NodeData } from '../types/Node';
2
- import type { TextPropsGenerated } from '../build-components/Text/TextProps.generated';
3
- import type { AppConfig } from '../types/PreviewConfig';
4
- import type { ProjectColors } from '../types/Project';
5
- type ExtractTextStyleOptions = {
6
- appConfig?: AppConfig;
7
- projectColors?: ProjectColors;
8
- };
9
- export declare function extractTextStyle<T extends TextPropsGenerated['attributes']>(node: NodeData<T>, options?: ExtractTextStyleOptions): import("react").CSSProperties;
10
- export {};
1
+ export type { ExtractTextStyleOptions } from './extractTextStyle/extractTextStyle';
2
+ export { extractTextStyle } from './extractTextStyle/extractTextStyle';
@@ -0,0 +1,9 @@
1
+ import { ViewPropsGenerated } from '../../build-components/View/ViewProps.generated';
2
+ import type { NodeData } from '../../types/Node';
3
+ import type { AppConfig } from '../../types/PreviewConfig';
4
+ import type { ProjectColors } from '../../types/Project';
5
+ export type ExtractViewStyleOptions = {
6
+ appConfig?: AppConfig;
7
+ projectColors?: ProjectColors;
8
+ };
9
+ export declare function extractViewStyle<T extends ViewPropsGenerated['attributes']>(node: NodeData<T>, options?: ExtractViewStyleOptions): import("react").CSSProperties;
@@ -1,9 +1,2 @@
1
- import { ViewPropsGenerated } from '../build-components/View/ViewProps.generated';
2
- import type { NodeData } from '../types/Node';
3
- import type { AppConfig } from '../types/PreviewConfig';
4
- import type { ProjectColors } from '../types/Project';
5
- export type ExtractViewStyleOptions = {
6
- appConfig?: AppConfig;
7
- projectColors?: ProjectColors;
8
- };
9
- export declare function extractViewStyle<T extends ViewPropsGenerated['attributes']>(node: NodeData<T>, options?: ExtractViewStyleOptions): import("react").CSSProperties;
1
+ export type { ExtractViewStyleOptions } from './extractViewStyle/extractViewStyle';
2
+ export { extractViewStyle } from './extractViewStyle/extractViewStyle';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@developer_tribe/react-builder",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "license": "UNLICENSED",
5
5
  "type": "module",
6
6
  "restricted": true,
@@ -2,13 +2,12 @@ import React, { useId, useMemo } from 'react';
2
2
  import type { BIconComponentProps } from './BIconProps.generated';
3
3
  import useNode from '../useNode';
4
4
  import { useRenderStore } from '../../store';
5
- import { extractViewStyle } from '../../utils/extractViewStyle';
6
5
  import { useLogRender } from '../../utils/useLogRender';
7
6
  import { isNodeSelected, SELECTED_OUTLINE_STYLE } from '../../utils/selection';
8
7
  import { useMergedStyle } from '../../utils/useMergedStyle';
9
8
  import { Icon } from '../../components/Icon.generated';
10
9
  import { IconsType } from '../../types/Icons';
11
- import { extractTextStyle } from '../../utils/extractTextStyle';
10
+ import { useExtractTextStyle } from '../../hooks/useExtractTextStyle';
12
11
 
13
12
  function BIcon({ node }: BIconComponentProps) {
14
13
  useLogRender('BIcon');
@@ -26,10 +25,10 @@ function BIcon({ node }: BIconComponentProps) {
26
25
  }),
27
26
  );
28
27
 
29
- const baseStyle = useMemo(
30
- () => extractTextStyle(node, { appConfig, projectColors }),
31
- [node, appConfig, projectColors],
32
- );
28
+ const baseStyle = useExtractTextStyle(node as any, {
29
+ appConfig,
30
+ projectColors,
31
+ });
33
32
  const isSelected = isNodeSelected({ previewMode, current, node });
34
33
  const style = useMergedStyle(
35
34
  baseStyle,
@@ -2,7 +2,7 @@ import React, { useId, useMemo } from 'react';
2
2
  import type { BackgroundImageComponentProps } from './BackgroundImageProps.generated';
3
3
  import useNode from '../useNode';
4
4
  import { useRenderStore } from '../../store';
5
- import { extractViewStyle } from '../../utils/extractViewStyle';
5
+ import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
6
6
  import { resolveImageSrc } from '../../utils/getImage';
7
7
  import { useLogRender } from '../../utils/useLogRender';
8
8
  import { isNodeSelected, SELECTED_OUTLINE_STYLE } from '../../utils/selection';
@@ -25,10 +25,7 @@ function BackgroundImage({ node }: BackgroundImageComponentProps) {
25
25
  }),
26
26
  );
27
27
 
28
- const baseStyle = useMemo(
29
- () => extractViewStyle(node, { appConfig, projectColors }),
30
- [node, appConfig, projectColors],
31
- );
28
+ const baseStyle = useExtractViewStyle(node, { appConfig, projectColors });
32
29
  const backgroundStyle = useMemo(() => {
33
30
  const attrs = node.attributes;
34
31
  const style: React.CSSProperties = {
@@ -3,8 +3,8 @@ import type { ButtonComponentProps } from './ButtonProps.generated';
3
3
  import useNode from '../useNode';
4
4
  import { useRenderStore } from '../../store';
5
5
  import { useLogRender } from '../../utils/useLogRender';
6
- import { extractViewStyle } from '../../utils/extractViewStyle';
7
- import { extractTextStyle } from '../../utils/extractTextStyle';
6
+ import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
7
+ import { useExtractTextStyle } from '../../hooks/useExtractTextStyle';
8
8
  import { isNodeSelected, SELECTED_OUTLINE_STYLE } from '../../utils/selection';
9
9
  import { useMergedStyle } from '../../utils/useMergedStyle';
10
10
  import { useLocalize } from '../../hooks/useLocalize';
@@ -24,22 +24,27 @@ function Button({ node }: ButtonComponentProps) {
24
24
  }),
25
25
  );
26
26
  const localize = useLocalize();
27
- const baseStyle = useMemo(
28
- () => extractViewStyle(node, { appConfig, projectColors }),
29
- [node, appConfig, projectColors],
30
- );
27
+ const baseStyle = useExtractViewStyle(node as any, {
28
+ appConfig,
29
+ projectColors,
30
+ });
31
+ const combinedTextStyle = useExtractTextStyle(node as any, {
32
+ appConfig,
33
+ projectColors,
34
+ });
31
35
  const textStyle = useMemo(() => {
32
- const combined = extractTextStyle(node as any, {
33
- appConfig,
34
- projectColors,
35
- });
36
36
  return {
37
- color: combined.color,
38
- fontSize: combined.fontSize,
39
- fontWeight: combined.fontWeight,
40
- textAlign: combined.textAlign,
37
+ color: combinedTextStyle.color,
38
+ fontSize: combinedTextStyle.fontSize,
39
+ fontWeight: combinedTextStyle.fontWeight,
40
+ textAlign: combinedTextStyle.textAlign,
41
41
  } as React.CSSProperties;
42
- }, [node, appConfig, projectColors]);
42
+ }, [
43
+ combinedTextStyle.color,
44
+ combinedTextStyle.fontSize,
45
+ combinedTextStyle.fontWeight,
46
+ combinedTextStyle.textAlign,
47
+ ]);
43
48
  const buttonDefaults = useMemo(() => {
44
49
  const hasExplicitBackground =
45
50
  node?.attributes?.backgroundColor !== undefined &&
@@ -5,7 +5,7 @@ import { isCarouselItem } from '../../utils/isCarousel';
5
5
  import useNode from '../useNode';
6
6
  import { useRenderStore } from '../../store';
7
7
  import { useLogRender } from '../../utils/useLogRender';
8
- import { extractViewStyle } from '../../utils/extractViewStyle';
8
+ import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
9
9
  import { isNodeSelected, SELECTED_OUTLINE_STYLE } from '../../utils/selection';
10
10
  import { useMergedStyle } from '../../utils/useMergedStyle';
11
11
 
@@ -23,10 +23,10 @@ function Carousel({ node }: CarouselComponentProps) {
23
23
  projectColors: s.projectColors,
24
24
  }),
25
25
  );
26
- const baseStyle = useMemo(
27
- () => extractViewStyle(node, { appConfig, projectColors }),
28
- [node, appConfig, projectColors],
29
- );
26
+ const baseStyle = useExtractViewStyle(node as any, {
27
+ appConfig,
28
+ projectColors,
29
+ });
30
30
  const isSelected = isNodeSelected({ previewMode, current, node });
31
31
  const style = useMergedStyle(
32
32
  baseStyle,
@@ -1,9 +1,9 @@
1
- import React, { useContext, useId, useMemo } from 'react';
1
+ import React, { useContext, useId } from 'react';
2
2
  import type { CarouselButtonsComponentProps } from './CarouselButtonsProps.generated';
3
3
  import { carouselContext } from '../CarouselProvider/CarouselProvider';
4
4
  import useNode from '../useNode';
5
5
  import { useLogRender } from '../../utils/useLogRender';
6
- import { extractViewStyle } from '../../utils/extractViewStyle';
6
+ import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
7
7
  import { useRenderStore } from '../../store';
8
8
 
9
9
  function CarouselButtons({ node }: CarouselButtonsComponentProps) {
@@ -17,10 +17,7 @@ function CarouselButtons({ node }: CarouselButtonsComponentProps) {
17
17
  appConfig: s.appConfig,
18
18
  projectColors: s.projectColors,
19
19
  }));
20
- const style = useMemo(
21
- () => extractViewStyle(node, { appConfig, projectColors }),
22
- [node, appConfig, projectColors],
23
- );
20
+ const style = useExtractViewStyle(node as any, { appConfig, projectColors });
24
21
  const emblaApi = useContext(carouselContext);
25
22
  const buttonTypes = node.attributes?.buttonType || [
26
23
  'previous_button',
@@ -1,10 +1,10 @@
1
- import React, { useContext, useEffect, useId, useMemo, useState } from 'react';
1
+ import React, { useContext, useEffect, useId, useState } from 'react';
2
2
  import type { CarouselDotsComponentProps } from './CarouselDotsProps.generated';
3
3
  import { carouselContext } from '../CarouselProvider/CarouselProvider';
4
4
  import { onboardContext } from '../OnboardProvider/OnboardProvider';
5
5
  import useNode from '../useNode';
6
6
  import { useLogRender } from '../../utils/useLogRender';
7
- import { extractViewStyle } from '../../utils/extractViewStyle';
7
+ import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
8
8
  import { useRenderStore } from '../../store';
9
9
 
10
10
  function CarouselDots({ node }: CarouselDotsComponentProps) {
@@ -23,9 +23,7 @@ function CarouselDots({ node }: CarouselDotsComponentProps) {
23
23
  projectColors: s.projectColors,
24
24
  }));
25
25
 
26
- const style = useMemo(() => {
27
- return extractViewStyle(node, { appConfig, projectColors });
28
- }, [node, appConfig, projectColors]);
26
+ const style = useExtractViewStyle(node as any, { appConfig, projectColors });
29
27
 
30
28
  // Use the appropriate context based on sourceType
31
29
  const isOnboard = (node as any)?.sourceType === 'OnboardDot';
@@ -1,9 +1,9 @@
1
- import React, { useId, useMemo } from 'react';
1
+ import React, { useId } from 'react';
2
2
  import type { CarouselItemComponentProps } from './CarouselItemProps.generated';
3
3
  import RenderNode from '../RenderNode.generated';
4
4
  import useNode from '../useNode';
5
5
  import { useLogRender } from '../../utils/useLogRender';
6
- import { extractViewStyle } from '../../utils/extractViewStyle';
6
+ import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
7
7
  import { useRenderStore } from '../../store';
8
8
 
9
9
  export function CarouselItem({ node }: CarouselItemComponentProps) {
@@ -17,10 +17,7 @@ export function CarouselItem({ node }: CarouselItemComponentProps) {
17
17
  appConfig: s.appConfig,
18
18
  projectColors: s.projectColors,
19
19
  }));
20
- const style = useMemo(
21
- () => extractViewStyle(node, { appConfig, projectColors }),
22
- [node, appConfig, projectColors],
23
- );
20
+ const style = useExtractViewStyle(node as any, { appConfig, projectColors });
24
21
  return (
25
22
  <div
26
23
  className="embla__slide"
@@ -3,7 +3,7 @@ import type { CarouselProviderComponentProps } from './CarouselProviderProps.gen
3
3
  import RenderNode from '../RenderNode.generated';
4
4
  import useEmblaCarousel from 'embla-carousel-react';
5
5
  import useNode from '../useNode';
6
- import { extractViewStyle } from '../../utils/extractViewStyle';
6
+ import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
7
7
  import { useRenderStore } from '../../store';
8
8
  import { isCarousel } from '../../utils/isCarousel';
9
9
  import type { Node, NodeData } from '../../types/Node';
@@ -20,10 +20,7 @@ function CarouselProvider({ node }: CarouselProviderComponentProps) {
20
20
  appConfig: s.appConfig,
21
21
  projectColors: s.projectColors,
22
22
  }));
23
- const viewStyle = useMemo(
24
- () => extractViewStyle(node, { appConfig, projectColors }),
25
- [node, appConfig, projectColors],
26
- );
23
+ const viewStyle = useExtractViewStyle(node, { appConfig, projectColors });
27
24
 
28
25
  const { carouselChild, otherChildren } = useMemo(() => {
29
26
  const children = node.children as Node;
@@ -1,10 +1,10 @@
1
- import React, { useId, useMemo } from 'react';
1
+ import React, { useId } from 'react';
2
2
  import type { MainComponentProps } from './MainProps.generated';
3
3
  import RenderNode from '../RenderNode.generated';
4
4
  import type { Node } from '../../types/Node';
5
5
  import useNode from '../useNode';
6
6
  import { useRenderStore } from '../../store';
7
- import { extractViewStyle } from '../../utils/extractViewStyle';
7
+ import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
8
8
  import { useLogRender } from '../../utils/useLogRender';
9
9
  import { isNodeSelected, SELECTED_OUTLINE_STYLE } from '../../utils/selection';
10
10
  import { useMergedStyle } from '../../utils/useMergedStyle';
@@ -29,13 +29,9 @@ function Main({ node }: MainComponentProps) {
29
29
  }),
30
30
  );
31
31
 
32
- const baseStyle = useMemo(
33
- () =>
34
- extractViewStyle(node as NodeData<ViewPropsGenerated['attributes']>, {
35
- appConfig,
36
- projectColors,
37
- }),
38
- [node, appConfig, projectColors],
32
+ const baseStyle = useExtractViewStyle(
33
+ node as NodeData<ViewPropsGenerated['attributes']>,
34
+ { appConfig, projectColors },
39
35
  );
40
36
 
41
37
  const useSafeAreaView = (node.attributes as any)?.useSafeAreaView ?? true;
@@ -7,7 +7,7 @@ import { onboardContext } from '../OnboardProvider/OnboardProvider';
7
7
  import useNode from '../useNode';
8
8
  import { useRenderStore } from '../../store';
9
9
  import { useLogRender } from '../../utils/useLogRender';
10
- import { extractViewStyle } from '../../utils/extractViewStyle';
10
+ import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
11
11
  import { useMockOSContext, useMockPermission } from '../../mockOS';
12
12
 
13
13
  function OnboardButton({ node }: OnboardButtonComponentProps) {
@@ -36,10 +36,10 @@ function OnboardButton({ node }: OnboardButtonComponentProps) {
36
36
  const flex = node.attributes?.flex ?? 1;
37
37
  const textColor = node.attributes?.button_text_color ?? '#FFFFFF';
38
38
  const backgroundColor = node.attributes?.button_background_color ?? '#0066FF';
39
- const viewStyle = useMemo(
40
- () => extractViewStyle(node, { appConfig, projectColors }),
41
- [node, appConfig, projectColors],
42
- );
39
+ const viewStyle = useExtractViewStyle(node as any, {
40
+ appConfig,
41
+ projectColors,
42
+ });
43
43
 
44
44
  const handleClick = () => {
45
45
  //TODO: any ??
@@ -1,4 +1,4 @@
1
- import React, { useContext, useEffect, useId, useMemo, useState } from 'react';
1
+ import React, { useContext, useEffect, useId, useState } from 'react';
2
2
  import type { Node } from '../../types/Node';
3
3
  import type { OnboardButtonsComponentProps } from './OnboardButtonsProps.generated';
4
4
  import { onboardContext } from '../OnboardProvider/OnboardProvider';
@@ -6,7 +6,7 @@ import RenderNode from '../RenderNode.generated';
6
6
  import useNode from '../useNode';
7
7
  import { useRenderStore } from '../../store';
8
8
  import { useLogRender } from '../../utils/useLogRender';
9
- import { extractViewStyle } from '../../utils/extractViewStyle';
9
+ import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
10
10
 
11
11
  function OnboardButtons({ node }: OnboardButtonsComponentProps) {
12
12
  useLogRender('OnboardButtons');
@@ -44,10 +44,10 @@ function OnboardButtons({ node }: OnboardButtonsComponentProps) {
44
44
  return <RenderNode node={node.children as Node} />;
45
45
  };
46
46
 
47
- const viewStyle = useMemo(
48
- () => extractViewStyle(node, { appConfig, projectColors }),
49
- [node, appConfig, projectColors],
50
- );
47
+ const viewStyle = useExtractViewStyle(node as any, {
48
+ appConfig,
49
+ projectColors,
50
+ });
51
51
 
52
52
  // NOTE: Hooks must not be called conditionally.
53
53
  // Generate the id before any early returns so the hook order stays stable.
@@ -3,7 +3,7 @@ import type { OnboardDotComponentProps } from './OnboardDotProps.generated';
3
3
  import { onboardContext } from '../OnboardProvider/OnboardProvider';
4
4
  import useNode from '../useNode';
5
5
  import { useLogRender } from '../../utils/useLogRender';
6
- import { extractViewStyle } from '../../utils/extractViewStyle';
6
+ import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
7
7
  import { useRenderStore } from '../../store';
8
8
  import { isNodeSelected, SELECTED_OUTLINE_STYLE } from '../../utils/selection';
9
9
  import { useMergedStyle } from '../../utils/useMergedStyle';
@@ -42,11 +42,15 @@ function OnboardDot({ node }: OnboardDotComponentProps) {
42
42
  [activeDotColor, appConfig, projectColors],
43
43
  );
44
44
 
45
+ const extractedStyle = useExtractViewStyle(node as any, {
46
+ appConfig,
47
+ projectColors,
48
+ });
45
49
  const baseStyle = useMemo(() => {
46
- let innerStyle = extractViewStyle(node, { appConfig, projectColors });
47
- delete innerStyle.flexDirection;
50
+ const innerStyle = { ...extractedStyle };
51
+ delete (innerStyle as any).flexDirection;
48
52
  return innerStyle;
49
- }, [node, appConfig, projectColors]);
53
+ }, [extractedStyle]);
50
54
  const isSelected = isNodeSelected({ previewMode, current, node });
51
55
  const style = useMergedStyle(
52
56
  baseStyle,
@@ -3,8 +3,8 @@ 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';
7
- import { extractViewStyle } from '../../utils/extractViewStyle';
6
+ import { useExtractTextStyle } from '../../hooks/useExtractTextStyle';
7
+ import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
8
8
  import { useLogRender } from '../../utils/useLogRender';
9
9
  import { isNodeSelected } from '../../utils/selection';
10
10
  import { useMergedStyle } from '../../utils/useMergedStyle';
@@ -107,14 +107,14 @@ function OnboardFooter({ node }: OnboardFooterComponentProps) {
107
107
  key ? (localication?.[defaultLanguage ?? 'en']?.[key] ?? key) : '';
108
108
 
109
109
  const text = t(node?.attributes?.textLocalizationKey);
110
- const textStyle = useMemo(
111
- () => extractTextStyle(node, { appConfig, projectColors }),
112
- [node, appConfig, projectColors],
113
- );
114
- const viewStyle = useMemo(
115
- () => extractViewStyle(node, { appConfig, projectColors }),
116
- [node, appConfig, projectColors],
117
- );
110
+ const textStyle = useExtractTextStyle(node as any, {
111
+ appConfig,
112
+ projectColors,
113
+ });
114
+ const viewStyle = useExtractViewStyle(node as any, {
115
+ appConfig,
116
+ projectColors,
117
+ });
118
118
 
119
119
  const linkStyle = (color?: string): React.CSSProperties => ({
120
120
  color,
@@ -1,10 +1,10 @@
1
- import React, { useEffect, useId, useMemo, useState } from 'react';
1
+ import React, { useEffect, useId, 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';
7
+ import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
8
8
  import { useRenderStore } from '../../store';
9
9
 
10
10
  function OnboardImage({ node }: OnboardImageComponentProps) {
@@ -19,10 +19,10 @@ function OnboardImage({ node }: OnboardImageComponentProps) {
19
19
  appConfig: s.appConfig,
20
20
  projectColors: s.projectColors,
21
21
  }));
22
- const viewStyle = useMemo(
23
- () => extractViewStyle(node, { appConfig, projectColors }),
24
- [node, appConfig, projectColors],
25
- );
22
+ const viewStyle = useExtractViewStyle(node as any, {
23
+ appConfig,
24
+ projectColors,
25
+ });
26
26
 
27
27
  useEffect(() => {
28
28
  if (node.attributes?.lottie) {
@@ -3,9 +3,8 @@ import type { OnboardItemComponentProps } from './OnboardItemProps.generated';
3
3
  import useNode from '../useNode';
4
4
  import RenderNode from '../RenderNode.generated';
5
5
  import { useRenderStore } from '../../store';
6
- import { parseSize } from '../../size-matters';
7
6
  import { useLogRender } from '../../utils/useLogRender';
8
- import { extractViewStyle } from '../../utils/extractViewStyle';
7
+ import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
9
8
 
10
9
  function OnboardItem({ node }: OnboardItemComponentProps) {
11
10
  useLogRender('OnboardItem');
@@ -17,10 +16,10 @@ function OnboardItem({ node }: OnboardItemComponentProps) {
17
16
  appConfig: s.appConfig,
18
17
  projectColors: s.projectColors,
19
18
  }));
20
- const viewStyle = useMemo(
21
- () => extractViewStyle(node, { appConfig, projectColors }),
22
- [node, appConfig, projectColors],
23
- );
19
+ const viewStyle = useExtractViewStyle(node as any, {
20
+ appConfig,
21
+ projectColors,
22
+ });
24
23
  return (
25
24
  <div
26
25
  attribute-name={attributeName}
@@ -13,7 +13,7 @@ import RenderNode from '../RenderNode.generated';
13
13
  import { useRenderStore } from '../../store';
14
14
  import useNode from '../useNode';
15
15
  import { useLogRender } from '../../utils/useLogRender';
16
- import { extractViewStyle } from '../../utils/extractViewStyle';
16
+ import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
17
17
  import { ViewPropsGenerated } from '../View/ViewProps.generated';
18
18
 
19
19
  export const onboardContext = createContext<any>(undefined);
@@ -75,15 +75,18 @@ function OnboardProvider({ node }: OnboardProviderComponentProps) {
75
75
  }, [theme]);*/
76
76
 
77
77
  //TODO: pattern içinde direk gömmek yerine orada da inhertince eklenebilir
78
- const viewStyle = useMemo(() => {
79
- const style = extractViewStyle(
80
- node as NodeData<ViewPropsGenerated['attributes']>,
81
- { appConfig, projectColors },
82
- );
83
- //NOTE: Embla için istisna
84
- style.display = 'block';
85
- return style;
86
- }, [node, appConfig, projectColors]);
78
+ const baseStyle = useExtractViewStyle(
79
+ node as NodeData<ViewPropsGenerated['attributes']>,
80
+ { appConfig, projectColors },
81
+ );
82
+ const viewStyle = useMemo(
83
+ () => ({
84
+ ...baseStyle,
85
+ // NOTE: Embla for web expects block layout here.
86
+ display: 'block',
87
+ }),
88
+ [baseStyle],
89
+ );
87
90
 
88
91
  return (
89
92
  <onboardContext.Provider value={{ emblaApi, selectedIndex }}>
@@ -2,7 +2,7 @@ import React, { useId, useMemo } from 'react';
2
2
  import type { PaywallBackgroundComponentProps } from './PaywallBackgroundProps.generated';
3
3
  import useNode from '../useNode';
4
4
  import { useRenderStore } from '../../store';
5
- import { extractViewStyle } from '../../utils/extractViewStyle';
5
+ import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
6
6
  import { useLogRender } from '../../utils/useLogRender';
7
7
  import { isNodeSelected, SELECTED_OUTLINE_STYLE } from '../../utils/selection';
8
8
  import { useMergedStyle } from '../../utils/useMergedStyle';
@@ -24,10 +24,7 @@ function PaywallBackground({ node }: PaywallBackgroundComponentProps) {
24
24
  }),
25
25
  );
26
26
 
27
- const baseStyle = useMemo(
28
- () => extractViewStyle(node, { appConfig, projectColors }),
29
- [node, appConfig, projectColors],
30
- );
27
+ const baseStyle = useExtractViewStyle(node, { appConfig, projectColors });
31
28
 
32
29
  const isSelected = isNodeSelected({ previewMode, current, node });
33
30
  const style = useMergedStyle(
@@ -2,7 +2,7 @@ import React, { useId, useMemo } from 'react';
2
2
  import type { PaywallCloseButtonComponentProps } from './PaywallCloseButtonProps.generated';
3
3
  import useNode from '../useNode';
4
4
  import { useRenderStore } from '../../store';
5
- import { extractTextStyle } from '../../utils/extractTextStyle';
5
+ import { useExtractTextStyle } from '../../hooks/useExtractTextStyle';
6
6
  import { useLogRender } from '../../utils/useLogRender';
7
7
  import { isNodeSelected, SELECTED_OUTLINE_STYLE } from '../../utils/selection';
8
8
  import { useMergedStyle } from '../../utils/useMergedStyle';
@@ -29,10 +29,10 @@ function PaywallCloseButton({ node }: PaywallCloseButtonComponentProps) {
29
29
  }),
30
30
  );
31
31
 
32
- const baseStyle = useMemo(
33
- () => extractTextStyle(node, { appConfig, projectColors }),
34
- [node, appConfig, projectColors],
35
- );
32
+ const baseStyle = useExtractTextStyle(node as any, {
33
+ appConfig,
34
+ projectColors,
35
+ });
36
36
 
37
37
  const isSelected = isNodeSelected({ previewMode, current, node });
38
38
  const style = useMergedStyle(
@@ -1,6 +1,6 @@
1
1
  import { useId, useMemo } from 'react';
2
2
  import type { Product } from '../../paywall/types/paywall-types';
3
- import { extractViewStyle } from '../../utils/extractViewStyle';
3
+ import { useExtractViewStyle } from '../../hooks/useExtractViewStyle';
4
4
  import type { NodeData } from '../../types/Node';
5
5
  import { useRenderStore } from '../../store';
6
6
  import { isNodeSelected, SELECTED_OUTLINE_STYLE } from '../../utils/selection';
@@ -32,10 +32,7 @@ export function PaywallOptionButton({
32
32
  }),
33
33
  );
34
34
 
35
- const baseStyle = useMemo(
36
- () => extractViewStyle(node, { appConfig, projectColors }),
37
- [node, appConfig, projectColors],
38
- );
35
+ const baseStyle = useExtractViewStyle(node, { appConfig, projectColors });
39
36
 
40
37
  const isSelected = isNodeSelected({ previewMode, current, node });
41
38