@beabee/beabee-common 1.10.23 → 1.12.0
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.stringifyAnswer = exports.convertComponentsToFilters = exports.flattenComponents = void 0;
|
|
4
4
|
function flattenComponents(components) {
|
|
5
5
|
return components.flatMap((component) => [
|
|
6
6
|
component,
|
|
@@ -13,7 +13,7 @@ function convertValuesToOptions(values) {
|
|
|
13
13
|
}
|
|
14
14
|
function convertComponentToFilter(component) {
|
|
15
15
|
const baseItem = {
|
|
16
|
-
|
|
16
|
+
label: component.label || component.key,
|
|
17
17
|
nullable: true,
|
|
18
18
|
};
|
|
19
19
|
switch (component.type) {
|
|
@@ -56,7 +56,7 @@ function getNiceAnswer(component, value) {
|
|
|
56
56
|
return value;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function stringifyAnswer(component, answer) {
|
|
60
60
|
if (!answer) {
|
|
61
61
|
return "";
|
|
62
62
|
}
|
|
@@ -73,13 +73,4 @@ function convertAnswer(component, answer) {
|
|
|
73
73
|
return answer.toString();
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
exports.
|
|
77
|
-
function convertAnswers(formSchema, answers) {
|
|
78
|
-
return Object.fromEntries(flattenComponents(formSchema.components)
|
|
79
|
-
.filter((component) => component.input)
|
|
80
|
-
.map((component) => [
|
|
81
|
-
component.label || component.key,
|
|
82
|
-
convertAnswer(component, answers[component.key]),
|
|
83
|
-
]));
|
|
84
|
-
}
|
|
85
|
-
exports.convertAnswers = convertAnswers;
|
|
76
|
+
exports.stringifyAnswer = stringifyAnswer;
|
|
@@ -9,7 +9,7 @@ function convertValuesToOptions(values) {
|
|
|
9
9
|
}
|
|
10
10
|
function convertComponentToFilter(component) {
|
|
11
11
|
const baseItem = {
|
|
12
|
-
|
|
12
|
+
label: component.label || component.key,
|
|
13
13
|
nullable: true,
|
|
14
14
|
};
|
|
15
15
|
switch (component.type) {
|
|
@@ -51,7 +51,7 @@ function getNiceAnswer(component, value) {
|
|
|
51
51
|
return value;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
export function
|
|
54
|
+
export function stringifyAnswer(component, answer) {
|
|
55
55
|
if (!answer) {
|
|
56
56
|
return "";
|
|
57
57
|
}
|
|
@@ -68,11 +68,3 @@ export function convertAnswer(component, answer) {
|
|
|
68
68
|
return answer.toString();
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
export function convertAnswers(formSchema, answers) {
|
|
72
|
-
return Object.fromEntries(flattenComponents(formSchema.components)
|
|
73
|
-
.filter((component) => component.input)
|
|
74
|
-
.map((component) => [
|
|
75
|
-
component.label || component.key,
|
|
76
|
-
convertAnswer(component, answers[component.key]),
|
|
77
|
-
]));
|
|
78
|
-
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { CalloutComponentSchema,
|
|
1
|
+
import { CalloutComponentSchema, CalloutResponseAnswer } from "../data/callouts";
|
|
2
2
|
import { Filters } from "../search";
|
|
3
3
|
export declare function flattenComponents(components: CalloutComponentSchema[]): CalloutComponentSchema[];
|
|
4
4
|
export declare function convertComponentsToFilters(components: CalloutComponentSchema[]): Filters;
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function convertAnswers(formSchema: CalloutFormSchema, answers: CalloutResponseAnswers): Record<string, string>;
|
|
5
|
+
export declare function stringifyAnswer(component: CalloutComponentSchema, answer: CalloutResponseAnswer): string;
|