@beabee/beabee-common 1.13.1 → 1.14.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,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.stringifyAnswer = exports.convertComponentsToFilters = exports.flattenComponents = void 0;
4
+ function isNestableComponent(component) {
5
+ return "components" in component;
6
+ }
4
7
  function flattenComponents(components) {
5
- return components.flatMap((component) => [
6
- component,
7
- ...flattenComponents(component.components || []),
8
- ]);
8
+ return components.flatMap((component) => isNestableComponent(component)
9
+ ? [component, ...flattenComponents(component.components)]
10
+ : [component]);
9
11
  }
10
12
  exports.flattenComponents = flattenComponents;
11
13
  function convertValuesToOptions(values) {
@@ -1,8 +1,10 @@
1
+ function isNestableComponent(component) {
2
+ return "components" in component;
3
+ }
1
4
  export function flattenComponents(components) {
2
- return components.flatMap((component) => [
3
- component,
4
- ...flattenComponents(component.components || []),
5
- ]);
5
+ return components.flatMap((component) => isNestableComponent(component)
6
+ ? [component, ...flattenComponents(component.components)]
7
+ : [component]);
6
8
  }
7
9
  function convertValuesToOptions(values) {
8
10
  return values.map(({ value, label }) => value);
@@ -1,15 +1,22 @@
1
1
  export interface BaseCalloutComponentSchema {
2
+ type: string;
2
3
  key: string;
3
- label?: string;
4
- input?: boolean;
5
- components?: CalloutComponentSchema[];
4
+ label: string;
5
+ input: boolean;
6
6
  [key: string]: unknown;
7
7
  }
8
- export interface OtherCalloutComponentSchema extends BaseCalloutComponentSchema {
8
+ export interface NestableCalloutComponentSchema extends BaseCalloutComponentSchema {
9
+ type: "panel" | "well" | "tabs";
10
+ input: false;
11
+ components: CalloutComponentSchema[];
12
+ }
13
+ export interface InputCalloutComponentSchema extends BaseCalloutComponentSchema {
9
14
  type: "address" | "button" | "checkbox" | "email" | "number" | "password" | "textfield" | "textarea";
15
+ input: true;
10
16
  }
11
17
  export interface SelectCalloutComponentSchema extends BaseCalloutComponentSchema {
12
18
  type: "select";
19
+ input: true;
13
20
  data: {
14
21
  values: {
15
22
  label: string;
@@ -19,13 +26,15 @@ export interface SelectCalloutComponentSchema extends BaseCalloutComponentSchema
19
26
  }
20
27
  export interface RadioCalloutComponentSchema extends BaseCalloutComponentSchema {
21
28
  type: "radio" | "selectboxes";
29
+ input: true;
22
30
  values: {
23
31
  label: string;
24
32
  value: string;
25
33
  }[];
26
34
  }
27
- export type CalloutComponentSchema = SelectCalloutComponentSchema | RadioCalloutComponentSchema | OtherCalloutComponentSchema;
35
+ export type CalloutComponentSchema = SelectCalloutComponentSchema | RadioCalloutComponentSchema | InputCalloutComponentSchema | NestableCalloutComponentSchema;
28
36
  export interface CalloutFormSchema {
37
+ display?: "form" | "wizard";
29
38
  components: CalloutComponentSchema[];
30
39
  }
31
40
  export type CalloutResponseAnswer = string | boolean | number | null | undefined | Record<string, boolean>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beabee/beabee-common",
3
- "version": "1.13.1",
3
+ "version": "1.14.0",
4
4
  "description": "",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",