@developer_tribe/react-builder 0.1.23 → 0.1.24
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/getDefaults.d.ts +3 -0
- package/dist/build-components/Carousel/getDefaults.d.ts +3 -0
- package/dist/build-components/CarouselButtons/getDefaults.d.ts +3 -0
- package/dist/build-components/CarouselDots/getDefaults.d.ts +3 -0
- package/dist/build-components/CarouselItem/getDefaults.d.ts +3 -0
- package/dist/build-components/CarouselProvider/getDefaults.d.ts +3 -0
- package/dist/build-components/Image/getDefaults.d.ts +3 -0
- package/dist/build-components/Onboard/getDefaults.d.ts +3 -0
- package/dist/build-components/OnboardButton/getDefaults.d.ts +3 -0
- package/dist/build-components/OnboardButtons/getDefaults.d.ts +3 -0
- package/dist/build-components/OnboardDot/getDefaults.d.ts +3 -0
- package/dist/build-components/OnboardFooter/getDefaults.d.ts +3 -0
- package/dist/build-components/OnboardImage/getDefaults.d.ts +3 -0
- package/dist/build-components/OnboardItem/getDefaults.d.ts +3 -0
- package/dist/build-components/OnboardProvider/getDefaults.d.ts +3 -0
- package/dist/build-components/OnboardSubtitle/getDefaults.d.ts +3 -0
- package/dist/build-components/OnboardTitle/getDefaults.d.ts +3 -0
- package/dist/build-components/Text/getDefaults.d.ts +3 -0
- package/dist/build-components/View/getDefaults.d.ts +3 -0
- package/dist/build-components/getDefaults.d.ts +25 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/package.json +1 -1
- package/scripts/prebuild/build-components.js +4 -0
- package/scripts/prebuild/utils/createBuildComponentsRootGetDefaults.js +56 -0
- package/scripts/prebuild/utils/createGetDefaultsPerComponent.js +28 -0
- package/scripts/prebuild/utils/createRootGetDefaults.js +52 -0
- package/scripts/prebuild/utils/index.js +3 -0
- package/scripts/prebuild/utils/validateAllComponentsOrThrow.js +2 -1
- package/src/build-components/Button/getDefaults.ts +11 -0
- package/src/build-components/Carousel/getDefaults.ts +11 -0
- package/src/build-components/CarouselButtons/getDefaults.ts +13 -0
- package/src/build-components/CarouselDots/getDefaults.ts +13 -0
- package/src/build-components/CarouselItem/getDefaults.ts +13 -0
- package/src/build-components/CarouselProvider/getDefaults.ts +13 -0
- package/src/build-components/Image/getDefaults.ts +11 -0
- package/src/build-components/Onboard/getDefaults.ts +11 -0
- package/src/build-components/OnboardButton/getDefaults.ts +13 -0
- package/src/build-components/OnboardButtons/getDefaults.ts +13 -0
- package/src/build-components/OnboardDot/getDefaults.ts +13 -0
- package/src/build-components/OnboardFooter/OnboardFooter.tsx +157 -14
- package/src/build-components/OnboardFooter/getDefaults.ts +13 -0
- package/src/build-components/OnboardImage/getDefaults.ts +13 -0
- package/src/build-components/OnboardItem/getDefaults.ts +13 -0
- package/src/build-components/OnboardProvider/getDefaults.ts +13 -0
- package/src/build-components/OnboardSubtitle/getDefaults.ts +13 -0
- package/src/build-components/OnboardSubtitle/pattern.json +4 -0
- package/src/build-components/OnboardTitle/getDefaults.ts +13 -0
- package/src/build-components/OnboardTitle/pattern.json +4 -0
- package/src/build-components/Text/getDefaults.ts +11 -0
- package/src/build-components/View/getDefaults.ts +11 -0
- package/src/build-components/getDefaults.ts +115 -0
package/package.json
CHANGED
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
validateExistingComponentTsx,
|
|
14
14
|
createRenderNodeGenerated,
|
|
15
15
|
createBuildComponentsIndex,
|
|
16
|
+
createGetDefaultsPerComponent,
|
|
17
|
+
createBuildComponentsRootGetDefaults,
|
|
16
18
|
formatAllSourceFiles,
|
|
17
19
|
// lintNonGeneratedOrThrow,
|
|
18
20
|
} from './utils/index.js';
|
|
@@ -36,10 +38,12 @@ async function run() {
|
|
|
36
38
|
await ensurePropsTs(componentDir, componentName);
|
|
37
39
|
await createComponentTsx(componentDir, componentName);
|
|
38
40
|
await validateExistingComponentTsx(componentDir, componentName);
|
|
41
|
+
await createGetDefaultsPerComponent(componentDir, componentName);
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
await createRenderNodeGenerated(validated, paths);
|
|
42
45
|
await createBuildComponentsIndex(validated, paths);
|
|
46
|
+
await createBuildComponentsRootGetDefaults(validated, paths);
|
|
43
47
|
await formatAllSourceFiles(paths);
|
|
44
48
|
}
|
|
45
49
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { promises as fs } from 'fs';
|
|
3
|
+
import { formatWithPrettier } from './formatWithPrettier.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Creates src/build-components/getDefaults.ts aggregating all component getDefaults
|
|
7
|
+
* with signature: getDefaults<T>(type: T, node: NodeData<List<T>>)
|
|
8
|
+
*/
|
|
9
|
+
export async function createBuildComponentsRootGetDefaults(validated, paths) {
|
|
10
|
+
const { COMPONENTS_ROOT } = paths;
|
|
11
|
+
const targetPath = path.join(COMPONENTS_ROOT, 'getDefaults.ts');
|
|
12
|
+
|
|
13
|
+
const importLines = validated
|
|
14
|
+
.map(({ componentName }) => {
|
|
15
|
+
return `import { getDefaults as get${componentName}Defaults } from './${componentName}/getDefaults';`;
|
|
16
|
+
})
|
|
17
|
+
.join('\n');
|
|
18
|
+
|
|
19
|
+
const typeImports = `import type { ${validated
|
|
20
|
+
.map(({ componentName }) => `${componentName}PropsGenerated`)
|
|
21
|
+
.join(', ')} } from './index';`;
|
|
22
|
+
|
|
23
|
+
const nodeImport = `import type { NodeData } from '../types/Node';`;
|
|
24
|
+
|
|
25
|
+
const typesMap = validated
|
|
26
|
+
.map(({ componentName, patternJson }) => {
|
|
27
|
+
const type = patternJson?.pattern?.type;
|
|
28
|
+
return ` ${JSON.stringify(type)}: ${componentName}PropsGenerated['attributes']`;
|
|
29
|
+
})
|
|
30
|
+
.join(';\n');
|
|
31
|
+
|
|
32
|
+
const switchCases = validated
|
|
33
|
+
.map(({ componentName, patternJson }) => {
|
|
34
|
+
const type = patternJson?.pattern?.type;
|
|
35
|
+
return ` case ${JSON.stringify(type)}:\n return get${componentName}Defaults() as Partial<Types[T]>`;
|
|
36
|
+
})
|
|
37
|
+
.join('\n');
|
|
38
|
+
|
|
39
|
+
const fileContent =
|
|
40
|
+
`/* AUTO-GENERATED FILE - DO NOT EDIT */\n\n` +
|
|
41
|
+
`${importLines}\n` +
|
|
42
|
+
`${typeImports}\n` +
|
|
43
|
+
`${nodeImport}\n\n` +
|
|
44
|
+
`export type Types = {\n${typesMap}\n};\n\n` +
|
|
45
|
+
`export type List<T> = T extends keyof Types ? Types[T] : never;\n\n` +
|
|
46
|
+
`export function getDefaults<T extends keyof Types>(type: T, _node: NodeData<List<T>>): Partial<Types[T]> {\n` +
|
|
47
|
+
` switch (type as unknown as string) {\n` +
|
|
48
|
+
`${switchCases}\n` +
|
|
49
|
+
` default:\n` +
|
|
50
|
+
` return {};\n` +
|
|
51
|
+
` }\n` +
|
|
52
|
+
`}\n`;
|
|
53
|
+
|
|
54
|
+
const formatted = await formatWithPrettier(fileContent);
|
|
55
|
+
await fs.writeFile(targetPath, formatted, 'utf8');
|
|
56
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { promises as fs } from 'fs';
|
|
3
|
+
import { formatWithPrettier } from './formatWithPrettier.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Creates src/build-components/<Component>/getDefaults.ts
|
|
7
|
+
* This file returns the `default` block from the folder's pattern.json.
|
|
8
|
+
*/
|
|
9
|
+
export async function createGetDefaultsPerComponent(
|
|
10
|
+
componentDir,
|
|
11
|
+
componentName
|
|
12
|
+
) {
|
|
13
|
+
const targetPath = path.join(componentDir, 'getDefaults.ts');
|
|
14
|
+
|
|
15
|
+
const importPath = `./${componentName}Props.generated`;
|
|
16
|
+
|
|
17
|
+
const fileContent =
|
|
18
|
+
`/* AUTO-GENERATED FILE - DO NOT EDIT */\n\n` +
|
|
19
|
+
`import pattern from './pattern.json';\n` +
|
|
20
|
+
`import type { ${componentName}PropsGenerated } from '${importPath}';\n\n` +
|
|
21
|
+
`export type ${componentName}Defaults = Partial<${componentName}PropsGenerated['attributes']>;\n\n` +
|
|
22
|
+
`export function getDefaults(): ${componentName}Defaults {\n` +
|
|
23
|
+
` return ((pattern as unknown as { default?: unknown })?.default ?? {}) as ${componentName}Defaults;\n` +
|
|
24
|
+
`}\n`;
|
|
25
|
+
|
|
26
|
+
const formatted = await formatWithPrettier(fileContent);
|
|
27
|
+
await fs.writeFile(targetPath, formatted, 'utf8');
|
|
28
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { promises as fs } from 'fs';
|
|
3
|
+
import { formatWithPrettier } from './formatWithPrettier.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Creates src/getDefaults.ts aggregating all component getDefaults.
|
|
7
|
+
*/
|
|
8
|
+
export async function createRootGetDefaults(validated, paths) {
|
|
9
|
+
const { SRC_ROOT } = paths;
|
|
10
|
+
const targetPath = path.join(SRC_ROOT, 'getDefaults.ts');
|
|
11
|
+
|
|
12
|
+
// Build import lines for all components
|
|
13
|
+
const importLines = validated
|
|
14
|
+
.map(({ componentName }) => {
|
|
15
|
+
return `import { getDefaults as get${componentName}Defaults } from './build-components/${componentName}/getDefaults';`;
|
|
16
|
+
})
|
|
17
|
+
.join('\n');
|
|
18
|
+
|
|
19
|
+
const typeImports = `import type { ${validated
|
|
20
|
+
.map(({ componentName }) => `${componentName}PropsGenerated`)
|
|
21
|
+
.join(', ')} } from './build-components';`;
|
|
22
|
+
|
|
23
|
+
const typesMap = validated
|
|
24
|
+
.map(({ componentName, patternJson }) => {
|
|
25
|
+
const type = patternJson?.pattern?.type;
|
|
26
|
+
return ` ${JSON.stringify(type)}: ${componentName}PropsGenerated['attributes']`;
|
|
27
|
+
})
|
|
28
|
+
.join(';\n');
|
|
29
|
+
|
|
30
|
+
const switchCases = validated
|
|
31
|
+
.map(({ componentName, patternJson }) => {
|
|
32
|
+
const type = patternJson?.pattern?.type;
|
|
33
|
+
return ` case ${JSON.stringify(type)}:\n return get${componentName}Defaults() as Partial<Types[T]>`;
|
|
34
|
+
})
|
|
35
|
+
.join('\n');
|
|
36
|
+
|
|
37
|
+
const fileContent =
|
|
38
|
+
`/* AUTO-GENERATED FILE - DO NOT EDIT */\n\n` +
|
|
39
|
+
`${importLines}\n` +
|
|
40
|
+
`${typeImports}\n\n` +
|
|
41
|
+
`export type Types = {\n${typesMap}\n};\n\n` +
|
|
42
|
+
`export function getDefaults<T extends keyof Types>(type: T): Partial<Types[T]> {\n` +
|
|
43
|
+
` switch (type as unknown as string) {\n` +
|
|
44
|
+
`${switchCases}\n` +
|
|
45
|
+
` default:\n` +
|
|
46
|
+
` return {};\n` +
|
|
47
|
+
` }\n` +
|
|
48
|
+
`}\n`;
|
|
49
|
+
|
|
50
|
+
const formatted = await formatWithPrettier(fileContent);
|
|
51
|
+
await fs.writeFile(targetPath, formatted, 'utf8');
|
|
52
|
+
}
|
|
@@ -13,3 +13,6 @@ export { createRenderNodeGenerated } from './createRenderNodeGenerated.js';
|
|
|
13
13
|
export { createBuildComponentsIndex } from './createBuildComponentsIndex.js';
|
|
14
14
|
export { formatAllSourceFiles } from './formatAllSourceFiles.js';
|
|
15
15
|
export { validateExistingComponentTsx } from './validateExistingComponentTsx.js';
|
|
16
|
+
export { createGetDefaultsPerComponent } from './createGetDefaultsPerComponent.js';
|
|
17
|
+
export { createRootGetDefaults } from './createRootGetDefaults.js';
|
|
18
|
+
export { createBuildComponentsRootGetDefaults } from './createBuildComponentsRootGetDefaults.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
import pattern from './pattern.json';
|
|
4
|
+
import type { ButtonPropsGenerated } from './ButtonProps.generated';
|
|
5
|
+
|
|
6
|
+
export type ButtonDefaults = Partial<ButtonPropsGenerated['attributes']>;
|
|
7
|
+
|
|
8
|
+
export function getDefaults(): ButtonDefaults {
|
|
9
|
+
return ((pattern as unknown as { default?: unknown })?.default ??
|
|
10
|
+
{}) as ButtonDefaults;
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
import pattern from './pattern.json';
|
|
4
|
+
import type { CarouselPropsGenerated } from './CarouselProps.generated';
|
|
5
|
+
|
|
6
|
+
export type CarouselDefaults = Partial<CarouselPropsGenerated['attributes']>;
|
|
7
|
+
|
|
8
|
+
export function getDefaults(): CarouselDefaults {
|
|
9
|
+
return ((pattern as unknown as { default?: unknown })?.default ??
|
|
10
|
+
{}) as CarouselDefaults;
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
import pattern from './pattern.json';
|
|
4
|
+
import type { CarouselButtonsPropsGenerated } from './CarouselButtonsProps.generated';
|
|
5
|
+
|
|
6
|
+
export type CarouselButtonsDefaults = Partial<
|
|
7
|
+
CarouselButtonsPropsGenerated['attributes']
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
export function getDefaults(): CarouselButtonsDefaults {
|
|
11
|
+
return ((pattern as unknown as { default?: unknown })?.default ??
|
|
12
|
+
{}) as CarouselButtonsDefaults;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
import pattern from './pattern.json';
|
|
4
|
+
import type { CarouselDotsPropsGenerated } from './CarouselDotsProps.generated';
|
|
5
|
+
|
|
6
|
+
export type CarouselDotsDefaults = Partial<
|
|
7
|
+
CarouselDotsPropsGenerated['attributes']
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
export function getDefaults(): CarouselDotsDefaults {
|
|
11
|
+
return ((pattern as unknown as { default?: unknown })?.default ??
|
|
12
|
+
{}) as CarouselDotsDefaults;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
import pattern from './pattern.json';
|
|
4
|
+
import type { CarouselItemPropsGenerated } from './CarouselItemProps.generated';
|
|
5
|
+
|
|
6
|
+
export type CarouselItemDefaults = Partial<
|
|
7
|
+
CarouselItemPropsGenerated['attributes']
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
export function getDefaults(): CarouselItemDefaults {
|
|
11
|
+
return ((pattern as unknown as { default?: unknown })?.default ??
|
|
12
|
+
{}) as CarouselItemDefaults;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
import pattern from './pattern.json';
|
|
4
|
+
import type { CarouselProviderPropsGenerated } from './CarouselProviderProps.generated';
|
|
5
|
+
|
|
6
|
+
export type CarouselProviderDefaults = Partial<
|
|
7
|
+
CarouselProviderPropsGenerated['attributes']
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
export function getDefaults(): CarouselProviderDefaults {
|
|
11
|
+
return ((pattern as unknown as { default?: unknown })?.default ??
|
|
12
|
+
{}) as CarouselProviderDefaults;
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
import pattern from './pattern.json';
|
|
4
|
+
import type { ImagePropsGenerated } from './ImageProps.generated';
|
|
5
|
+
|
|
6
|
+
export type ImageDefaults = Partial<ImagePropsGenerated['attributes']>;
|
|
7
|
+
|
|
8
|
+
export function getDefaults(): ImageDefaults {
|
|
9
|
+
return ((pattern as unknown as { default?: unknown })?.default ??
|
|
10
|
+
{}) as ImageDefaults;
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
import pattern from './pattern.json';
|
|
4
|
+
import type { OnboardPropsGenerated } from './OnboardProps.generated';
|
|
5
|
+
|
|
6
|
+
export type OnboardDefaults = Partial<OnboardPropsGenerated['attributes']>;
|
|
7
|
+
|
|
8
|
+
export function getDefaults(): OnboardDefaults {
|
|
9
|
+
return ((pattern as unknown as { default?: unknown })?.default ??
|
|
10
|
+
{}) as OnboardDefaults;
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
import pattern from './pattern.json';
|
|
4
|
+
import type { OnboardButtonPropsGenerated } from './OnboardButtonProps.generated';
|
|
5
|
+
|
|
6
|
+
export type OnboardButtonDefaults = Partial<
|
|
7
|
+
OnboardButtonPropsGenerated['attributes']
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
export function getDefaults(): OnboardButtonDefaults {
|
|
11
|
+
return ((pattern as unknown as { default?: unknown })?.default ??
|
|
12
|
+
{}) as OnboardButtonDefaults;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
import pattern from './pattern.json';
|
|
4
|
+
import type { OnboardButtonsPropsGenerated } from './OnboardButtonsProps.generated';
|
|
5
|
+
|
|
6
|
+
export type OnboardButtonsDefaults = Partial<
|
|
7
|
+
OnboardButtonsPropsGenerated['attributes']
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
export function getDefaults(): OnboardButtonsDefaults {
|
|
11
|
+
return ((pattern as unknown as { default?: unknown })?.default ??
|
|
12
|
+
{}) as OnboardButtonsDefaults;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
import pattern from './pattern.json';
|
|
4
|
+
import type { OnboardDotPropsGenerated } from './OnboardDotProps.generated';
|
|
5
|
+
|
|
6
|
+
export type OnboardDotDefaults = Partial<
|
|
7
|
+
OnboardDotPropsGenerated['attributes']
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
export function getDefaults(): OnboardDotDefaults {
|
|
11
|
+
return ((pattern as unknown as { default?: unknown })?.default ??
|
|
12
|
+
{}) as OnboardDotDefaults;
|
|
13
|
+
}
|
|
@@ -2,8 +2,89 @@ import React, { useContext } from 'react';
|
|
|
2
2
|
import type { OnboardFooterComponentProps } from './OnboardFooterProps.generated';
|
|
3
3
|
import { mainNodeContext } from '../../RenderMainNode';
|
|
4
4
|
|
|
5
|
+
type Segment =
|
|
6
|
+
| { type: 'text'; value: string }
|
|
7
|
+
| {
|
|
8
|
+
type: 'match';
|
|
9
|
+
value: string;
|
|
10
|
+
color?: string;
|
|
11
|
+
page?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function escapeRegExp(str: string) {
|
|
15
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function buildSegments(
|
|
19
|
+
text: string,
|
|
20
|
+
patterns: { value: string; color?: string; page?: string }[],
|
|
21
|
+
): { segments: Segment[]; matchCount: number } {
|
|
22
|
+
type RawMatch = {
|
|
23
|
+
start: number;
|
|
24
|
+
end: number;
|
|
25
|
+
value: string;
|
|
26
|
+
color?: string;
|
|
27
|
+
page?: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const rawMatches: RawMatch[] = [];
|
|
31
|
+
|
|
32
|
+
for (const p of patterns) {
|
|
33
|
+
if (!p.value) continue;
|
|
34
|
+
const re = new RegExp(escapeRegExp(p.value), 'gi');
|
|
35
|
+
for (const m of text.matchAll(re)) {
|
|
36
|
+
if (m.index == null) continue;
|
|
37
|
+
const matched = m[0];
|
|
38
|
+
if (!matched) continue;
|
|
39
|
+
rawMatches.push({
|
|
40
|
+
start: m.index,
|
|
41
|
+
end: m.index + matched.length,
|
|
42
|
+
value: matched,
|
|
43
|
+
color: p.color,
|
|
44
|
+
page: p.page,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (rawMatches.length === 0) {
|
|
50
|
+
return { segments: [{ type: 'text', value: text }], matchCount: 0 };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
rawMatches.sort((a, b) => {
|
|
54
|
+
if (a.start !== b.start) return a.start - b.start;
|
|
55
|
+
const lenA = a.end - a.start;
|
|
56
|
+
const lenB = b.end - b.start;
|
|
57
|
+
return lenB - lenA;
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const kept: RawMatch[] = [];
|
|
61
|
+
let lastEnd = -1;
|
|
62
|
+
for (const m of rawMatches) {
|
|
63
|
+
if (m.start >= lastEnd) {
|
|
64
|
+
kept.push(m);
|
|
65
|
+
lastEnd = m.end;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const segments: Segment[] = [];
|
|
70
|
+
let cursor = 0;
|
|
71
|
+
for (const { start, end, value, color, page } of kept) {
|
|
72
|
+
if (start > cursor) {
|
|
73
|
+
segments.push({ type: 'text', value: text.slice(cursor, start) });
|
|
74
|
+
}
|
|
75
|
+
segments.push({ type: 'match', value, color, page });
|
|
76
|
+
cursor = end;
|
|
77
|
+
}
|
|
78
|
+
if (cursor < text.length) {
|
|
79
|
+
segments.push({ type: 'text', value: text.slice(cursor) });
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return { segments, matchCount: kept.length };
|
|
83
|
+
}
|
|
84
|
+
|
|
5
85
|
function OnboardFooter({ node }: OnboardFooterComponentProps) {
|
|
6
|
-
const { localication, defaultLanguage } =
|
|
86
|
+
const { localication, defaultLanguage, setWarning } =
|
|
87
|
+
useContext(mainNodeContext) ?? {};
|
|
7
88
|
const t = (key?: string) =>
|
|
8
89
|
key ? (localication?.[defaultLanguage ?? 'en']?.[key] ?? key) : '';
|
|
9
90
|
|
|
@@ -44,19 +125,81 @@ function OnboardFooter({ node }: OnboardFooterComponentProps) {
|
|
|
44
125
|
|
|
45
126
|
return (
|
|
46
127
|
<div className="primitive primitive-footer" style={style}>
|
|
47
|
-
{!!text &&
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
128
|
+
{!!text &&
|
|
129
|
+
(() => {
|
|
130
|
+
const firstText = t(node?.attributes?.linkedWordFirstLocalizationKey);
|
|
131
|
+
const secondText = t(
|
|
132
|
+
node?.attributes?.linkedWordSecondLocalizationKey,
|
|
133
|
+
);
|
|
134
|
+
const { segments, matchCount } = buildSegments(text, [
|
|
135
|
+
{
|
|
136
|
+
value: firstText,
|
|
137
|
+
color: node?.attributes?.linkedWordFirstColor,
|
|
138
|
+
page: (node?.attributes as any)?.linkedWordFirstPage,
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
value: secondText,
|
|
142
|
+
color: node?.attributes?.linkedWordSecondColor,
|
|
143
|
+
page: (node?.attributes as any)?.linkedWordSecondPage,
|
|
144
|
+
},
|
|
145
|
+
]);
|
|
146
|
+
|
|
147
|
+
const textColor = node?.attributes?.textColor;
|
|
148
|
+
|
|
149
|
+
const handleClick = (page?: string) => {
|
|
150
|
+
if (!page) return;
|
|
151
|
+
// Demo environment: surface intent via warning banner if available
|
|
152
|
+
if (setWarning) setWarning(`Navigate to page: ${page}`);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
return (
|
|
156
|
+
<>
|
|
157
|
+
<p style={{ color: textColor }}>
|
|
158
|
+
{segments.map((seg, i) =>
|
|
159
|
+
seg.type === 'text' ? (
|
|
160
|
+
<span key={i}>{seg.value}</span>
|
|
161
|
+
) : (
|
|
162
|
+
<span
|
|
163
|
+
key={i}
|
|
164
|
+
style={linkStyle(seg.color)}
|
|
165
|
+
onClick={() => handleClick(seg.page)}
|
|
166
|
+
>
|
|
167
|
+
{seg.value}
|
|
168
|
+
</span>
|
|
169
|
+
),
|
|
170
|
+
)}
|
|
171
|
+
</p>
|
|
172
|
+
{matchCount === 0 && (
|
|
173
|
+
<div style={{ display: 'flex', gap: 8 }}>
|
|
174
|
+
{node?.attributes?.linkedWordFirstLocalizationKey && (
|
|
175
|
+
<span
|
|
176
|
+
style={linkStyle(node?.attributes?.linkedWordFirstColor)}
|
|
177
|
+
onClick={() =>
|
|
178
|
+
handleClick(
|
|
179
|
+
(node?.attributes as any)?.linkedWordFirstPage,
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
>
|
|
183
|
+
{firstText}
|
|
184
|
+
</span>
|
|
185
|
+
)}
|
|
186
|
+
{node?.attributes?.linkedWordSecondLocalizationKey && (
|
|
187
|
+
<span
|
|
188
|
+
style={linkStyle(node?.attributes?.linkedWordSecondColor)}
|
|
189
|
+
onClick={() =>
|
|
190
|
+
handleClick(
|
|
191
|
+
(node?.attributes as any)?.linkedWordSecondPage,
|
|
192
|
+
)
|
|
193
|
+
}
|
|
194
|
+
>
|
|
195
|
+
{secondText}
|
|
196
|
+
</span>
|
|
197
|
+
)}
|
|
198
|
+
</div>
|
|
199
|
+
)}
|
|
200
|
+
</>
|
|
201
|
+
);
|
|
202
|
+
})()}
|
|
60
203
|
</div>
|
|
61
204
|
);
|
|
62
205
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
import pattern from './pattern.json';
|
|
4
|
+
import type { OnboardFooterPropsGenerated } from './OnboardFooterProps.generated';
|
|
5
|
+
|
|
6
|
+
export type OnboardFooterDefaults = Partial<
|
|
7
|
+
OnboardFooterPropsGenerated['attributes']
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
export function getDefaults(): OnboardFooterDefaults {
|
|
11
|
+
return ((pattern as unknown as { default?: unknown })?.default ??
|
|
12
|
+
{}) as OnboardFooterDefaults;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
import pattern from './pattern.json';
|
|
4
|
+
import type { OnboardImagePropsGenerated } from './OnboardImageProps.generated';
|
|
5
|
+
|
|
6
|
+
export type OnboardImageDefaults = Partial<
|
|
7
|
+
OnboardImagePropsGenerated['attributes']
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
export function getDefaults(): OnboardImageDefaults {
|
|
11
|
+
return ((pattern as unknown as { default?: unknown })?.default ??
|
|
12
|
+
{}) as OnboardImageDefaults;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
import pattern from './pattern.json';
|
|
4
|
+
import type { OnboardItemPropsGenerated } from './OnboardItemProps.generated';
|
|
5
|
+
|
|
6
|
+
export type OnboardItemDefaults = Partial<
|
|
7
|
+
OnboardItemPropsGenerated['attributes']
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
export function getDefaults(): OnboardItemDefaults {
|
|
11
|
+
return ((pattern as unknown as { default?: unknown })?.default ??
|
|
12
|
+
{}) as OnboardItemDefaults;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
import pattern from './pattern.json';
|
|
4
|
+
import type { OnboardProviderPropsGenerated } from './OnboardProviderProps.generated';
|
|
5
|
+
|
|
6
|
+
export type OnboardProviderDefaults = Partial<
|
|
7
|
+
OnboardProviderPropsGenerated['attributes']
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
export function getDefaults(): OnboardProviderDefaults {
|
|
11
|
+
return ((pattern as unknown as { default?: unknown })?.default ??
|
|
12
|
+
{}) as OnboardProviderDefaults;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
import pattern from './pattern.json';
|
|
4
|
+
import type { OnboardSubtitlePropsGenerated } from './OnboardSubtitleProps.generated';
|
|
5
|
+
|
|
6
|
+
export type OnboardSubtitleDefaults = Partial<
|
|
7
|
+
OnboardSubtitlePropsGenerated['attributes']
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
export function getDefaults(): OnboardSubtitleDefaults {
|
|
11
|
+
return ((pattern as unknown as { default?: unknown })?.default ??
|
|
12
|
+
{}) as OnboardSubtitleDefaults;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
import pattern from './pattern.json';
|
|
4
|
+
import type { OnboardTitlePropsGenerated } from './OnboardTitleProps.generated';
|
|
5
|
+
|
|
6
|
+
export type OnboardTitleDefaults = Partial<
|
|
7
|
+
OnboardTitlePropsGenerated['attributes']
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
export function getDefaults(): OnboardTitleDefaults {
|
|
11
|
+
return ((pattern as unknown as { default?: unknown })?.default ??
|
|
12
|
+
{}) as OnboardTitleDefaults;
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
import pattern from './pattern.json';
|
|
4
|
+
import type { TextPropsGenerated } from './TextProps.generated';
|
|
5
|
+
|
|
6
|
+
export type TextDefaults = Partial<TextPropsGenerated['attributes']>;
|
|
7
|
+
|
|
8
|
+
export function getDefaults(): TextDefaults {
|
|
9
|
+
return ((pattern as unknown as { default?: unknown })?.default ??
|
|
10
|
+
{}) as TextDefaults;
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
import pattern from './pattern.json';
|
|
4
|
+
import type { ViewPropsGenerated } from './ViewProps.generated';
|
|
5
|
+
|
|
6
|
+
export type ViewDefaults = Partial<ViewPropsGenerated['attributes']>;
|
|
7
|
+
|
|
8
|
+
export function getDefaults(): ViewDefaults {
|
|
9
|
+
return ((pattern as unknown as { default?: unknown })?.default ??
|
|
10
|
+
{}) as ViewDefaults;
|
|
11
|
+
}
|