@beabee/beabee-common 1.18.0-alpha.7 → 1.18.0-alpha.9
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.
|
@@ -10,7 +10,7 @@ function convertValuesToOptions(values) {
|
|
|
10
10
|
}
|
|
11
11
|
function convertComponentToFilter(component) {
|
|
12
12
|
const baseItem = {
|
|
13
|
-
label: component.label || component.
|
|
13
|
+
label: component.label || component.fullKey,
|
|
14
14
|
nullable: true,
|
|
15
15
|
};
|
|
16
16
|
switch (component.type) {
|
|
@@ -69,20 +69,14 @@ function getCalloutComponents(formSchema) {
|
|
|
69
69
|
return formSchema.slides.flatMap((slide) => flattenComponents(slide.components).map((component) => ({
|
|
70
70
|
...component,
|
|
71
71
|
slideId: slide.id,
|
|
72
|
+
fullKey: `${slide.id}.${component.key}`,
|
|
72
73
|
})));
|
|
73
74
|
}
|
|
74
75
|
exports.getCalloutComponents = getCalloutComponents;
|
|
75
76
|
function getCalloutFilters(formSchema) {
|
|
76
|
-
const items = formSchema
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
.map((c) => {
|
|
80
|
-
return [
|
|
81
|
-
`answers.${slide.id}.${c.key}`,
|
|
82
|
-
convertComponentToFilter(c),
|
|
83
|
-
];
|
|
84
|
-
});
|
|
85
|
-
});
|
|
77
|
+
const items = getCalloutComponents(formSchema)
|
|
78
|
+
.filter((c) => c.input)
|
|
79
|
+
.map((c) => [`answers.${c.fullKey}`, convertComponentToFilter(c)]);
|
|
86
80
|
return Object.fromEntries(items);
|
|
87
81
|
}
|
|
88
82
|
exports.getCalloutFilters = getCalloutFilters;
|
|
@@ -7,7 +7,7 @@ function convertValuesToOptions(values) {
|
|
|
7
7
|
}
|
|
8
8
|
function convertComponentToFilter(component) {
|
|
9
9
|
const baseItem = {
|
|
10
|
-
label: component.label || component.
|
|
10
|
+
label: component.label || component.fullKey,
|
|
11
11
|
nullable: true,
|
|
12
12
|
};
|
|
13
13
|
switch (component.type) {
|
|
@@ -64,19 +64,13 @@ export function getCalloutComponents(formSchema) {
|
|
|
64
64
|
return formSchema.slides.flatMap((slide) => flattenComponents(slide.components).map((component) => ({
|
|
65
65
|
...component,
|
|
66
66
|
slideId: slide.id,
|
|
67
|
+
fullKey: `${slide.id}.${component.key}`,
|
|
67
68
|
})));
|
|
68
69
|
}
|
|
69
70
|
export function getCalloutFilters(formSchema) {
|
|
70
|
-
const items = formSchema
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
.map((c) => {
|
|
74
|
-
return [
|
|
75
|
-
`answers.${slide.id}.${c.key}`,
|
|
76
|
-
convertComponentToFilter(c),
|
|
77
|
-
];
|
|
78
|
-
});
|
|
79
|
-
});
|
|
71
|
+
const items = getCalloutComponents(formSchema)
|
|
72
|
+
.filter((c) => c.input)
|
|
73
|
+
.map((c) => [`answers.${c.fullKey}`, convertComponentToFilter(c)]);
|
|
80
74
|
return Object.fromEntries(items);
|
|
81
75
|
}
|
|
82
76
|
export function isAddressAnswer(answer) {
|
|
@@ -66,4 +66,4 @@ export type CalloutResponseAnswer = string | boolean | number | null | undefined
|
|
|
66
66
|
/**
|
|
67
67
|
* Answers are grouped by slide key: {[slideId]: {[componentKey]: answer | answer[]}}
|
|
68
68
|
*/
|
|
69
|
-
export type CalloutResponseAnswers = Record<string, Record<string, CalloutResponseAnswer | CalloutResponseAnswer[]
|
|
69
|
+
export type CalloutResponseAnswers = Record<string, Record<string, CalloutResponseAnswer | CalloutResponseAnswer[]> | undefined>;
|
|
@@ -5,6 +5,7 @@ export declare function flattenComponents(components: CalloutComponentSchema[]):
|
|
|
5
5
|
export declare function filterComponents(components: CalloutComponentSchema[], filterFn: (component: CalloutComponentSchema) => boolean): CalloutComponentSchema[];
|
|
6
6
|
export declare function getCalloutComponents(formSchema: CalloutFormSchema): (CalloutComponentSchema & {
|
|
7
7
|
slideId: string;
|
|
8
|
+
fullKey: string;
|
|
8
9
|
})[];
|
|
9
10
|
export declare function getCalloutFilters(formSchema: CalloutFormSchema): Record<string, FilterArgs & {
|
|
10
11
|
label: string;
|