@developer_tribe/react-builder 0.1.0 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-components/Button/Button.d.ts +2 -2
- package/dist/build-components/Carousel/Carousel.d.ts +2 -2
- package/dist/build-components/CarouselButtons/CarouselButtons.d.ts +2 -2
- package/dist/build-components/CarouselDots/CarouselDots.d.ts +2 -2
- package/dist/build-components/CarouselItem/CarouselItem.d.ts +2 -2
- package/dist/build-components/CarouselProvider/CarouselProvider.d.ts +2 -2
- package/dist/build-components/Image/Image.d.ts +2 -2
- package/dist/build-components/Onboard/Onboard.d.ts +2 -2
- package/dist/build-components/OnboardBoardTitle/OnboardBoardTitle.d.ts +2 -2
- package/dist/build-components/OnboardButton/OnboardButton.d.ts +2 -2
- package/dist/build-components/OnboardButtons/OnboardButtons.d.ts +2 -2
- package/dist/build-components/OnboardExpandingDot/OnboardExpandingDot.d.ts +2 -2
- package/dist/build-components/OnboardFooter/OnboardFooter.d.ts +2 -2
- package/dist/build-components/OnboardImage/OnboardImage.d.ts +2 -2
- package/dist/build-components/OnboardItem/OnboardItem.d.ts +2 -2
- package/dist/build-components/OnboardProvider/OnboardProvider.d.ts +2 -2
- package/dist/build-components/OnboardSubtitle/OnboardSubtitle.d.ts +2 -2
- package/dist/build-components/RenderNode.generated.d.ts +1 -1
- package/dist/build-components/Text/Text.d.ts +2 -2
- package/dist/build-components/View/View.d.ts +2 -2
- package/dist/build-components/other.d.ts +3 -0
- package/dist/utils/generateRandomKeyForNode.d.ts +1 -0
- package/package.json +12 -5
- package/scripts/prebuild/build-components.js +528 -0
- package/scripts/prebuild/prebuild.js +11 -0
- package/scripts/public/bin.js +57 -0
- package/scripts/public/scripts/build/index.js +31 -0
- package/scripts/public/scripts/build/info.json +11 -0
- package/scripts/public/scripts/build/utils/checkFolderAndFilesValid.js +41 -0
- package/scripts/public/scripts/build/utils/checkPathExists.js +9 -0
- package/scripts/public/scripts/build/utils/createMissingFoldersAndFiles.js +54 -0
- package/scripts/public/scripts/build/utils/createRenderNodeGenerated.js +82 -0
- package/scripts/public/scripts/build/utils/getAllComponents.js +11 -0
- package/src/AttributesEditor.tsx +107 -0
- package/src/RenderMainNode.tsx +37 -0
- package/src/RenderPage.tsx +61 -0
- package/src/assets/devices.json +730 -0
- package/src/assets/samples/carousel-sample.json +108 -0
- package/src/assets/samples/getSamples.ts +28 -0
- package/src/assets/samples/simple-1.json +46 -0
- package/src/assets/samples/simple-2.json +233 -0
- package/src/assets/samples/vpn-onboard-1.json +799 -0
- package/src/assets/samples/vpn-onboard-2.json +790 -0
- package/src/assets/samples/vpn-onboard-3.json +803 -0
- package/src/assets/samples/vpn-onboard-4.json +804 -0
- package/src/build-components/Button/Button.tsx +13 -0
- package/src/build-components/Button/ButtonProps.generated.ts +21 -0
- package/src/build-components/Button/pattern.json +25 -0
- package/src/build-components/Carousel/Carousel.tsx +27 -0
- package/src/build-components/Carousel/CarouselProps.generated.ts +6 -0
- package/src/build-components/Carousel/pattern.json +9 -0
- package/src/build-components/CarouselButtons/CarouselButtons.tsx +47 -0
- package/src/build-components/CarouselButtons/CarouselButtonsProps.generated.ts +9 -0
- package/src/build-components/CarouselButtons/pattern.json +12 -0
- package/src/build-components/CarouselDots/CarouselDots.tsx +40 -0
- package/src/build-components/CarouselDots/CarouselDotsProps.generated.ts +14 -0
- package/src/build-components/CarouselDots/pattern.json +18 -0
- package/src/build-components/CarouselItem/CarouselItem.tsx +18 -0
- package/src/build-components/CarouselItem/CarouselItemProps.generated.ts +6 -0
- package/src/build-components/CarouselItem/pattern.json +9 -0
- package/src/build-components/CarouselProvider/CarouselProvider.tsx +26 -0
- package/src/build-components/CarouselProvider/CarouselProviderProps.generated.ts +6 -0
- package/src/build-components/CarouselProvider/pattern.json +9 -0
- package/src/build-components/Image/Image.tsx +35 -0
- package/src/build-components/Image/ImageProps.generated.ts +12 -0
- package/src/build-components/Image/pattern.json +15 -0
- package/src/build-components/Onboard/Onboard.tsx +14 -0
- package/src/build-components/Onboard/OnboardProps.generated.ts +6 -0
- package/src/build-components/Onboard/pattern.json +9 -0
- package/src/build-components/OnboardBoardTitle/OnboardBoardTitle.tsx +28 -0
- package/src/build-components/OnboardBoardTitle/OnboardBoardTitleProps.generated.ts +21 -0
- package/src/build-components/OnboardBoardTitle/pattern.json +25 -0
- package/src/build-components/OnboardButton/OnboardButton.tsx +59 -0
- package/src/build-components/OnboardButton/OnboardButtonProps.generated.ts +13 -0
- package/src/build-components/OnboardButton/pattern.json +16 -0
- package/src/build-components/OnboardButtons/OnboardButtons.tsx +76 -0
- package/src/build-components/OnboardButtons/OnboardButtonsProps.generated.ts +12 -0
- package/src/build-components/OnboardButtons/pattern.json +15 -0
- package/src/build-components/OnboardExpandingDot/OnboardExpandingDot.tsx +14 -0
- package/src/build-components/OnboardExpandingDot/OnboardExpandingDotProps.generated.ts +14 -0
- package/src/build-components/OnboardExpandingDot/pattern.json +18 -0
- package/src/build-components/OnboardFooter/OnboardFooter.tsx +13 -0
- package/src/build-components/OnboardFooter/OnboardFooterProps.generated.ts +24 -0
- package/src/build-components/OnboardFooter/pattern.json +28 -0
- package/src/build-components/OnboardImage/OnboardImage.tsx +14 -0
- package/src/build-components/OnboardImage/OnboardImageProps.generated.ts +12 -0
- package/src/build-components/OnboardImage/pattern.json +15 -0
- package/src/build-components/OnboardItem/OnboardItem.tsx +29 -0
- package/src/build-components/OnboardItem/OnboardItemProps.generated.ts +6 -0
- package/src/build-components/OnboardItem/pattern.json +9 -0
- package/src/build-components/OnboardProvider/OnboardProvider.tsx +65 -0
- package/src/build-components/OnboardProvider/OnboardProviderProps.generated.ts +6 -0
- package/src/build-components/OnboardProvider/pattern.json +9 -0
- package/src/build-components/OnboardSubtitle/OnboardSubtitle.tsx +28 -0
- package/src/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.ts +21 -0
- package/src/build-components/OnboardSubtitle/pattern.json +25 -0
- package/src/build-components/RenderNode.generated.tsx +97 -0
- package/src/build-components/Text/Text.tsx +23 -0
- package/src/build-components/Text/TextProps.generated.ts +21 -0
- package/src/build-components/Text/pattern.json +26 -0
- package/src/build-components/View/View.tsx +62 -0
- package/src/build-components/View/ViewProps.generated.ts +24 -0
- package/src/build-components/View/pattern.json +28 -0
- package/src/build-components/other.ts +6 -0
- package/src/index.ts +24 -0
- package/src/styles/index.scss +114 -0
- package/src/types/Device.ts +12 -0
- package/src/types/Node.ts +19 -0
- package/src/types/PreviewConfig.ts +19 -0
- package/src/types/Project.ts +11 -0
- package/src/types/TargetedScreenSize.ts +4 -0
- package/src/utils/analyseNode.ts +77 -0
- package/src/utils/generateRandomKeyForNode.ts +3 -0
- package/src/utils/getDevices.ts +6 -0
- package/src/utils/isCarousel.ts +36 -0
- package/src/utils/isOnboard.ts +54 -0
- package/src/utils/novaToJson.ts +253 -0
- package/src/utils/patterns.ts +63 -0
- package/dist/build-components/Button/ButtonProps.d.ts +0 -3
- package/dist/build-components/Carousel/CarouselProps.d.ts +0 -3
- package/dist/build-components/CarouselButtons/CarouselButtonsProps.d.ts +0 -3
- package/dist/build-components/CarouselDots/CarouselDotsProps.d.ts +0 -3
- package/dist/build-components/CarouselItem/CarouselItemProps.d.ts +0 -3
- package/dist/build-components/CarouselProvider/CarouselProviderProps.d.ts +0 -3
- package/dist/build-components/Image/ImageProps.d.ts +0 -3
- package/dist/build-components/Onboard/OnboardProps.d.ts +0 -3
- package/dist/build-components/OnboardBoardTitle/OnboardBoardTitleProps.d.ts +0 -3
- package/dist/build-components/OnboardButton/OnboardButtonProps.d.ts +0 -3
- package/dist/build-components/OnboardButtons/OnboardButtonsProps.d.ts +0 -3
- package/dist/build-components/OnboardExpandingDot/OnboardExpandingDotProps.d.ts +0 -3
- package/dist/build-components/OnboardFooter/OnboardFooterProps.d.ts +0 -3
- package/dist/build-components/OnboardImage/OnboardImageProps.d.ts +0 -3
- package/dist/build-components/OnboardItem/OnboardItemProps.d.ts +0 -3
- package/dist/build-components/OnboardProvider/OnboardProviderProps.d.ts +0 -3
- package/dist/build-components/OnboardSubtitle/OnboardSubtitleProps.d.ts +0 -3
- package/dist/build-components/Text/TextProps.d.ts +0 -3
- package/dist/build-components/View/ViewProps.d.ts +0 -3
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { Node, NodeData } from '../types/Node';
|
|
2
|
+
import { Project, ProjectBase } from '../types/Project';
|
|
3
|
+
|
|
4
|
+
export function novaToJson(nova: ProjectBase<unknown>): Node {
|
|
5
|
+
const layout = (nova.data as any).data?.layout;
|
|
6
|
+
console.info('layout', layout);
|
|
7
|
+
if (layout === 'onboard-layout') {
|
|
8
|
+
return onboardNovaToJson(nova);
|
|
9
|
+
}
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
//@eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
function onboardNovaToJson(nova: ProjectBase<unknown>): Node {
|
|
14
|
+
const attributes =
|
|
15
|
+
(nova?.data as any)?.data?.attributes ||
|
|
16
|
+
(nova?.data as any)?.attributes ||
|
|
17
|
+
{};
|
|
18
|
+
//@eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
+
const generalComponents = (attributes?.general_components || []) as any[];
|
|
20
|
+
//@eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
const pages = (attributes?.data || []) as any[];
|
|
22
|
+
|
|
23
|
+
const dotsNode = mapDotsFromGeneralComponents(generalComponents);
|
|
24
|
+
const footerNode = mapFooterFromGeneralComponents(generalComponents);
|
|
25
|
+
const { carouselNode, providerLevelButtons } = buildCarouselFromPages(pages);
|
|
26
|
+
|
|
27
|
+
const providerNode: NodeData = {
|
|
28
|
+
type: 'OnboardProvider',
|
|
29
|
+
children: [
|
|
30
|
+
carouselNode,
|
|
31
|
+
// Place dots above buttons in visual order
|
|
32
|
+
...(dotsNode ? [dotsNode] : []),
|
|
33
|
+
...(providerLevelButtons.length ? providerLevelButtons : []),
|
|
34
|
+
...(footerNode ? [footerNode] : []),
|
|
35
|
+
],
|
|
36
|
+
attributes: {
|
|
37
|
+
theme: (nova?.data as any)?.theme,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return providerNode;
|
|
42
|
+
}
|
|
43
|
+
//@eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
+
function buildCarouselFromPages(pages: any[]): {
|
|
45
|
+
carouselNode: NodeData;
|
|
46
|
+
providerLevelButtons: Node[];
|
|
47
|
+
} {
|
|
48
|
+
const simplePages = pages.filter(
|
|
49
|
+
(p) => p?.layout === 'simple-onboard-layout',
|
|
50
|
+
);
|
|
51
|
+
const pageKeyToIndex = new Map<string, number>();
|
|
52
|
+
//@eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
|
+
simplePages.forEach((p: any, idx: number) => {
|
|
54
|
+
const key = p?.attributes?.key;
|
|
55
|
+
if (typeof key === 'string') pageKeyToIndex.set(key, idx);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const providerLevelButtons: Node[] = [];
|
|
59
|
+
const items: Node[] = simplePages.map((page) =>
|
|
60
|
+
buildCarouselItem(page, pageKeyToIndex, providerLevelButtons),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const carouselNode: NodeData = {
|
|
64
|
+
type: 'Onboard',
|
|
65
|
+
children: items as unknown as Node,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return { carouselNode, providerLevelButtons };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function buildCarouselItem(
|
|
72
|
+
page: any,
|
|
73
|
+
pageKeyToIndex: Map<string, number>,
|
|
74
|
+
providerLevelButtons: Node[],
|
|
75
|
+
): NodeData {
|
|
76
|
+
//@eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
77
|
+
const components = (page?.attributes?.components || []) as any[];
|
|
78
|
+
const children: Node[] = [];
|
|
79
|
+
|
|
80
|
+
for (const comp of components) {
|
|
81
|
+
if (comp?.layout === 'title-layout') {
|
|
82
|
+
const title = comp?.attributes?.title_localization_key || '';
|
|
83
|
+
const color = comp?.attributes?.title_color || undefined;
|
|
84
|
+
children.push({
|
|
85
|
+
type: 'OnboardBoardTitle',
|
|
86
|
+
attributes: color ? { color } : undefined,
|
|
87
|
+
children: title,
|
|
88
|
+
});
|
|
89
|
+
} else if (comp?.layout === 'subtitle-layout') {
|
|
90
|
+
const subtitle = comp?.attributes?.subtitle_localization_key || '';
|
|
91
|
+
const color = comp?.attributes?.subtitle_color || undefined;
|
|
92
|
+
children.push({
|
|
93
|
+
type: 'OnboardSubtitle',
|
|
94
|
+
attributes: color ? { color } : undefined,
|
|
95
|
+
children: subtitle,
|
|
96
|
+
});
|
|
97
|
+
} else if (comp?.layout === 'image-layout') {
|
|
98
|
+
const src = comp?.attributes?.image || comp?.attributes?.src || '';
|
|
99
|
+
const rawHeight =
|
|
100
|
+
comp?.attributes?.height ??
|
|
101
|
+
comp?.attributes?.ios_height ??
|
|
102
|
+
comp?.attributes?.android_height;
|
|
103
|
+
const height =
|
|
104
|
+
typeof rawHeight === 'string'
|
|
105
|
+
? Number.parseInt(rawHeight, 10)
|
|
106
|
+
: typeof rawHeight === 'number'
|
|
107
|
+
? rawHeight
|
|
108
|
+
: undefined;
|
|
109
|
+
|
|
110
|
+
if (src) {
|
|
111
|
+
children.push({
|
|
112
|
+
type: 'OnboardImage',
|
|
113
|
+
attributes: {
|
|
114
|
+
src,
|
|
115
|
+
...(height ? { height } : {}),
|
|
116
|
+
resizeMode: 'contain',
|
|
117
|
+
},
|
|
118
|
+
children: undefined as unknown as Node,
|
|
119
|
+
} as unknown as NodeData);
|
|
120
|
+
}
|
|
121
|
+
} else if (comp?.layout === 'Buttons') {
|
|
122
|
+
const direction = comp?.attributes?.buttons_direction;
|
|
123
|
+
//@eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
124
|
+
const buttons = (comp?.attributes?.buttons || []) as any[];
|
|
125
|
+
//@eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
126
|
+
const buttonNodes: Node[] = [];
|
|
127
|
+
for (const btn of buttons) {
|
|
128
|
+
const attrs = btn?.attributes || {};
|
|
129
|
+
const labelKey = attrs?.button_text_localization_key || '';
|
|
130
|
+
const buttonTextColor = attrs?.button_text_color;
|
|
131
|
+
const buttonBackgroundColor = attrs?.button_background_color;
|
|
132
|
+
const flex = attrs?.flex ? Number(attrs.flex) : undefined;
|
|
133
|
+
|
|
134
|
+
// Find first Navigate event and map to target index
|
|
135
|
+
let targetIndex: number | undefined = undefined;
|
|
136
|
+
//@eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
137
|
+
const actions = (attrs?.actions || []) as any[];
|
|
138
|
+
const normalizedEvents: {
|
|
139
|
+
type: 'Permission' | 'Navigate';
|
|
140
|
+
permission?: string;
|
|
141
|
+
next_page_key?: string;
|
|
142
|
+
}[] = [];
|
|
143
|
+
for (const action of actions) {
|
|
144
|
+
//@eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
145
|
+
const events = (action?.attributes?.events || []) as any[];
|
|
146
|
+
for (const e of events) {
|
|
147
|
+
if (e?.layout === 'Permission') {
|
|
148
|
+
const permission = e?.attributes?.permission as
|
|
149
|
+
| string
|
|
150
|
+
| undefined;
|
|
151
|
+
normalizedEvents.push({ type: 'Permission', permission });
|
|
152
|
+
} else if (e?.layout === 'Navigate') {
|
|
153
|
+
const nextKey = e?.attributes?.next_page_key as
|
|
154
|
+
| string
|
|
155
|
+
| undefined;
|
|
156
|
+
normalizedEvents.push({
|
|
157
|
+
type: 'Navigate',
|
|
158
|
+
next_page_key: nextKey,
|
|
159
|
+
});
|
|
160
|
+
if (typeof nextKey === 'string' && pageKeyToIndex.has(nextKey)) {
|
|
161
|
+
targetIndex = pageKeyToIndex.get(nextKey)!;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
buttonNodes.push({
|
|
168
|
+
type: 'OnboardButton',
|
|
169
|
+
attributes: {
|
|
170
|
+
labelKey,
|
|
171
|
+
...(typeof buttonTextColor === 'string'
|
|
172
|
+
? { button_text_color: buttonTextColor }
|
|
173
|
+
: {}),
|
|
174
|
+
...(typeof buttonBackgroundColor === 'string'
|
|
175
|
+
? { button_background_color: buttonBackgroundColor }
|
|
176
|
+
: {}),
|
|
177
|
+
...(typeof flex === 'number' ? { flex } : {}),
|
|
178
|
+
...(typeof targetIndex === 'number' ? { targetIndex } : {}),
|
|
179
|
+
...(normalizedEvents.length ? { events: normalizedEvents } : {}),
|
|
180
|
+
},
|
|
181
|
+
children: undefined as unknown as Node,
|
|
182
|
+
} as unknown as NodeData);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (buttonNodes.length > 0) {
|
|
186
|
+
// Place buttons inside the page (OnboardItem) instead of provider level
|
|
187
|
+
children.push({
|
|
188
|
+
type: 'OnboardButtons',
|
|
189
|
+
attributes: {
|
|
190
|
+
...(direction ? { buttons_direction: direction } : {}),
|
|
191
|
+
},
|
|
192
|
+
children: buttonNodes as unknown as Node,
|
|
193
|
+
} as unknown as NodeData);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const pageKeyAttr = page?.attributes?.key;
|
|
199
|
+
const resolvedKey =
|
|
200
|
+
(typeof pageKeyAttr === 'string' && pageKeyAttr) ||
|
|
201
|
+
(typeof page?.key === 'string' ? page.key : undefined);
|
|
202
|
+
|
|
203
|
+
return {
|
|
204
|
+
type: 'OnboardItem',
|
|
205
|
+
...(resolvedKey ? { key: resolvedKey } : {}),
|
|
206
|
+
children,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function mapDotsFromGeneralComponents(generalComponents: any[]): Node | null {
|
|
211
|
+
const dots = generalComponents.find((gc) => gc?.layout === 'dots-layout');
|
|
212
|
+
if (!dots) return null;
|
|
213
|
+
const dotArray = dots?.attributes?.dot || [];
|
|
214
|
+
const dotType = dotArray?.[0]?.layout as
|
|
215
|
+
| 'expanding_dot'
|
|
216
|
+
| 'normal_dot'
|
|
217
|
+
| 'scaling_dot'
|
|
218
|
+
| 'sliding_border'
|
|
219
|
+
| 'sliding_dot'
|
|
220
|
+
| 'liquid_like';
|
|
221
|
+
return {
|
|
222
|
+
type: 'OnboardExpandingDot',
|
|
223
|
+
attributes: dotType ? { dotType } : undefined,
|
|
224
|
+
children: undefined as unknown as Node,
|
|
225
|
+
} as unknown as NodeData;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function mapFooterFromGeneralComponents(generalComponents: any[]): Node | null {
|
|
229
|
+
const footer = generalComponents.find((gc) => gc?.layout === 'footer-layout');
|
|
230
|
+
if (!footer) return null;
|
|
231
|
+
const texts = (footer?.attributes?.texts || []) as any[];
|
|
232
|
+
const children: Node[] = [];
|
|
233
|
+
|
|
234
|
+
for (const t of texts) {
|
|
235
|
+
if (t?.layout === 'Text') {
|
|
236
|
+
const textKey = t?.attributes?.text_localization_key || '';
|
|
237
|
+
const color = t?.attributes?.text_color || undefined;
|
|
238
|
+
children.push({
|
|
239
|
+
type: 'text',
|
|
240
|
+
attributes: color ? { color } : undefined,
|
|
241
|
+
children: textKey,
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (children.length === 0) return null;
|
|
247
|
+
|
|
248
|
+
return {
|
|
249
|
+
type: 'view',
|
|
250
|
+
attributes: { gap: 8 },
|
|
251
|
+
children,
|
|
252
|
+
} as NodeData;
|
|
253
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import imagePattern from '../build-components/Image/pattern.json';
|
|
2
|
+
import textPattern from '../build-components/Text/pattern.json';
|
|
3
|
+
import buttonPattern from '../build-components/Button/pattern.json';
|
|
4
|
+
import viewPattern from '../build-components/View/pattern.json';
|
|
5
|
+
import carouselPattern from '../build-components/Carousel/pattern.json';
|
|
6
|
+
import carouselButtonsPattern from '../build-components/CarouselButtons/pattern.json';
|
|
7
|
+
import carouselDotsPattern from '../build-components/CarouselDots/pattern.json';
|
|
8
|
+
import carouselItemPattern from '../build-components/CarouselItem/pattern.json';
|
|
9
|
+
import carouselProviderPattern from '../build-components/CarouselProvider/pattern.json';
|
|
10
|
+
import onboardPattern from '../build-components/Onboard/pattern.json';
|
|
11
|
+
import onboardProviderPattern from '../build-components/OnboardProvider/pattern.json';
|
|
12
|
+
import onboardItemPattern from '../build-components/OnboardItem/pattern.json';
|
|
13
|
+
import onboardImagePattern from '../build-components/OnboardImage/pattern.json';
|
|
14
|
+
import onboardButtonsPattern from '../build-components/OnboardButtons/pattern.json';
|
|
15
|
+
import onboardButtonPattern from '../build-components/OnboardButton/pattern.json';
|
|
16
|
+
import onboardBoardTitlePattern from '../build-components/OnboardBoardTitle/pattern.json';
|
|
17
|
+
import onboardSubtitlePattern from '../build-components/OnboardSubtitle/pattern.json';
|
|
18
|
+
import onboardFooterPattern from '../build-components/OnboardFooter/pattern.json';
|
|
19
|
+
import onboardExpandingDotPattern from '../build-components/OnboardExpandingDot/pattern.json';
|
|
20
|
+
|
|
21
|
+
type Pattern = {
|
|
22
|
+
schemaVersion: number;
|
|
23
|
+
allowUnknownAttributes: boolean;
|
|
24
|
+
pattern: {
|
|
25
|
+
type: string;
|
|
26
|
+
children: unknown;
|
|
27
|
+
attributes: Record<string, string | string[]>;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const patterns: Pattern[] = [
|
|
32
|
+
imagePattern as Pattern,
|
|
33
|
+
textPattern as Pattern,
|
|
34
|
+
buttonPattern as Pattern,
|
|
35
|
+
viewPattern as Pattern,
|
|
36
|
+
carouselPattern as Pattern,
|
|
37
|
+
carouselButtonsPattern as Pattern,
|
|
38
|
+
carouselDotsPattern as Pattern,
|
|
39
|
+
carouselItemPattern as Pattern,
|
|
40
|
+
carouselProviderPattern as Pattern,
|
|
41
|
+
onboardPattern as Pattern,
|
|
42
|
+
onboardProviderPattern as Pattern,
|
|
43
|
+
onboardItemPattern as Pattern,
|
|
44
|
+
onboardImagePattern as Pattern,
|
|
45
|
+
onboardButtonsPattern as Pattern,
|
|
46
|
+
onboardButtonPattern as Pattern,
|
|
47
|
+
onboardBoardTitlePattern as Pattern,
|
|
48
|
+
onboardSubtitlePattern as Pattern,
|
|
49
|
+
onboardFooterPattern as Pattern,
|
|
50
|
+
onboardExpandingDotPattern as Pattern,
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
export function getPatternByType(type?: string | null) {
|
|
54
|
+
if (!type) return undefined;
|
|
55
|
+
return patterns.find((p) => p.pattern.type === type);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function getAttributeSchema(
|
|
59
|
+
type?: string | null,
|
|
60
|
+
): Record<string, string | string[]> | undefined {
|
|
61
|
+
const p = getPatternByType(type);
|
|
62
|
+
return p?.pattern.attributes;
|
|
63
|
+
}
|