@beabee/beabee-common 1.10.9 → 1.10.10
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/cjs/data/callouts.js +2 -0
- package/dist/cjs/data/index.js +15 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/utils/callouts.js +47 -0
- package/dist/esm/data/callouts.js +1 -0
- package/dist/esm/data/index.js +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/utils/callouts.js +42 -0
- package/dist/types/data/callouts.d.ts +31 -0
- package/dist/types/data/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/utils/callouts.d.ts +4 -0
- package/package.json +1 -1
package/dist/cjs/data/index.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
exports.RoleTypes = exports.PaymentStatus = exports.PaymentMethod = exports.NewsletterStatus = exports.MembershipStatus = exports.ItemStatus = exports.ContributionType = exports.ContributionPeriod = void 0;
|
|
4
18
|
var ContributionPeriod;
|
|
@@ -50,3 +64,4 @@ var PaymentStatus;
|
|
|
50
64
|
PaymentStatus["Cancelled"] = "cancelled";
|
|
51
65
|
})(PaymentStatus = exports.PaymentStatus || (exports.PaymentStatus = {}));
|
|
52
66
|
exports.RoleTypes = ["member", "admin", "superadmin"];
|
|
67
|
+
__exportStar(require("./callouts"), exports);
|
package/dist/cjs/index.js
CHANGED
|
@@ -17,5 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./search"), exports);
|
|
18
18
|
__exportStar(require("./data"), exports);
|
|
19
19
|
__exportStar(require("./error"), exports);
|
|
20
|
+
__exportStar(require("./utils/callouts"), exports);
|
|
20
21
|
__exportStar(require("./utils/date"), exports);
|
|
21
22
|
__exportStar(require("./utils/rules"), exports);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertComponentsToFilters = exports.flattenComponents = void 0;
|
|
4
|
+
function flattenComponents(components) {
|
|
5
|
+
return components.flatMap((component) => [
|
|
6
|
+
component,
|
|
7
|
+
...flattenComponents(component.components || []),
|
|
8
|
+
]);
|
|
9
|
+
}
|
|
10
|
+
exports.flattenComponents = flattenComponents;
|
|
11
|
+
function convertValuesToOptions(values) {
|
|
12
|
+
return values.map(({ value, label }) => value);
|
|
13
|
+
}
|
|
14
|
+
function convertComponentToFilter(component) {
|
|
15
|
+
const baseItem = {
|
|
16
|
+
// label: component.label || component.key,
|
|
17
|
+
nullable: true,
|
|
18
|
+
};
|
|
19
|
+
switch (component.type) {
|
|
20
|
+
case "checkbox":
|
|
21
|
+
return { ...baseItem, type: "boolean", nullable: false };
|
|
22
|
+
case "number":
|
|
23
|
+
return { ...baseItem, type: "number" };
|
|
24
|
+
case "select":
|
|
25
|
+
return {
|
|
26
|
+
...baseItem,
|
|
27
|
+
type: "enum",
|
|
28
|
+
options: convertValuesToOptions(component.data.values),
|
|
29
|
+
};
|
|
30
|
+
case "selectboxes":
|
|
31
|
+
case "radio":
|
|
32
|
+
return {
|
|
33
|
+
...baseItem,
|
|
34
|
+
type: component.type === "radio" ? "enum" : "array",
|
|
35
|
+
options: convertValuesToOptions(component.values),
|
|
36
|
+
};
|
|
37
|
+
default:
|
|
38
|
+
return { ...baseItem, type: "text" };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function convertComponentsToFilters(components) {
|
|
42
|
+
const items = components.map((c) => {
|
|
43
|
+
return [`answers.${c.key}`, convertComponentToFilter(c)];
|
|
44
|
+
});
|
|
45
|
+
return Object.fromEntries(items);
|
|
46
|
+
}
|
|
47
|
+
exports.convertComponentsToFilters = convertComponentsToFilters;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/data/index.js
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export function flattenComponents(components) {
|
|
2
|
+
return components.flatMap((component) => [
|
|
3
|
+
component,
|
|
4
|
+
...flattenComponents(component.components || []),
|
|
5
|
+
]);
|
|
6
|
+
}
|
|
7
|
+
function convertValuesToOptions(values) {
|
|
8
|
+
return values.map(({ value, label }) => value);
|
|
9
|
+
}
|
|
10
|
+
function convertComponentToFilter(component) {
|
|
11
|
+
const baseItem = {
|
|
12
|
+
// label: component.label || component.key,
|
|
13
|
+
nullable: true,
|
|
14
|
+
};
|
|
15
|
+
switch (component.type) {
|
|
16
|
+
case "checkbox":
|
|
17
|
+
return { ...baseItem, type: "boolean", nullable: false };
|
|
18
|
+
case "number":
|
|
19
|
+
return { ...baseItem, type: "number" };
|
|
20
|
+
case "select":
|
|
21
|
+
return {
|
|
22
|
+
...baseItem,
|
|
23
|
+
type: "enum",
|
|
24
|
+
options: convertValuesToOptions(component.data.values),
|
|
25
|
+
};
|
|
26
|
+
case "selectboxes":
|
|
27
|
+
case "radio":
|
|
28
|
+
return {
|
|
29
|
+
...baseItem,
|
|
30
|
+
type: component.type === "radio" ? "enum" : "array",
|
|
31
|
+
options: convertValuesToOptions(component.values),
|
|
32
|
+
};
|
|
33
|
+
default:
|
|
34
|
+
return { ...baseItem, type: "text" };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export function convertComponentsToFilters(components) {
|
|
38
|
+
const items = components.map((c) => {
|
|
39
|
+
return [`answers.${c.key}`, convertComponentToFilter(c)];
|
|
40
|
+
});
|
|
41
|
+
return Object.fromEntries(items);
|
|
42
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
interface BaseCalloutComponentSchema {
|
|
2
|
+
key: string;
|
|
3
|
+
label?: string;
|
|
4
|
+
input?: boolean;
|
|
5
|
+
components?: CalloutComponentSchema[];
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
interface OtherCalloutComponentSchema extends BaseCalloutComponentSchema {
|
|
9
|
+
type: "button" | "checkbox" | "number" | "password" | "textfield" | "textarea";
|
|
10
|
+
}
|
|
11
|
+
interface SelectCalloutComponentSchema extends BaseCalloutComponentSchema {
|
|
12
|
+
type: "select";
|
|
13
|
+
data: {
|
|
14
|
+
values: {
|
|
15
|
+
label: string;
|
|
16
|
+
value: string;
|
|
17
|
+
}[];
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
interface RadioCalloutComponentSchema extends BaseCalloutComponentSchema {
|
|
21
|
+
type: "radio" | "selectboxes";
|
|
22
|
+
values: {
|
|
23
|
+
label: string;
|
|
24
|
+
value: string;
|
|
25
|
+
}[];
|
|
26
|
+
}
|
|
27
|
+
export type CalloutComponentSchema = SelectCalloutComponentSchema | RadioCalloutComponentSchema | OtherCalloutComponentSchema;
|
|
28
|
+
export interface CalloutFormSchema {
|
|
29
|
+
components: CalloutComponentSchema[];
|
|
30
|
+
}
|
|
31
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CalloutComponentSchema } from "../data/callouts";
|
|
2
|
+
import { Filters } from "../search";
|
|
3
|
+
export declare function flattenComponents(components: CalloutComponentSchema[]): CalloutComponentSchema[];
|
|
4
|
+
export declare function convertComponentsToFilters(components: CalloutComponentSchema[]): Filters;
|