@beabee/beabee-common 1.18.0-alpha.1 → 1.18.0-alpha.2

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,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.stringifyAnswer = exports.isFileUploadAnswer = exports.isAddressAnswer = exports.convertComponentsToFilters = exports.flattenComponents = exports.filterComponents = void 0;
3
+ exports.stringifyAnswer = exports.isFileUploadAnswer = exports.isAddressAnswer = exports.convertComponentsToFilters = exports.getCalloutComponents = exports.filterComponents = void 0;
4
4
  function isNestableComponent(component) {
5
5
  // Addresses have embedded components we don't want to include
6
- return "components" in component && component.type !== 'address';
6
+ return "components" in component && component.type !== "address";
7
7
  }
8
8
  function filterComponents(components, filterFn) {
9
9
  return components.filter(filterFn).map((component) => {
@@ -21,7 +21,10 @@ function flattenComponents(components) {
21
21
  ? [component, ...flattenComponents(component.components)]
22
22
  : [component]);
23
23
  }
24
- exports.flattenComponents = flattenComponents;
24
+ function getCalloutComponents(callout) {
25
+ return callout.slides.flatMap((slide) => flattenComponents(slide.components));
26
+ }
27
+ exports.getCalloutComponents = getCalloutComponents;
25
28
  function convertValuesToOptions(values) {
26
29
  return values.map(({ value, label }) => value);
27
30
  }
@@ -1,6 +1,6 @@
1
1
  function isNestableComponent(component) {
2
2
  // Addresses have embedded components we don't want to include
3
- return "components" in component && component.type !== 'address';
3
+ return "components" in component && component.type !== "address";
4
4
  }
5
5
  export function filterComponents(components, filterFn) {
6
6
  return components.filter(filterFn).map((component) => {
@@ -12,11 +12,14 @@ export function filterComponents(components, filterFn) {
12
12
  };
13
13
  });
14
14
  }
15
- export function flattenComponents(components) {
15
+ function flattenComponents(components) {
16
16
  return components.flatMap((component) => isNestableComponent(component)
17
17
  ? [component, ...flattenComponents(component.components)]
18
18
  : [component]);
19
19
  }
20
+ export function getCalloutComponents(callout) {
21
+ return callout.slides.flatMap((slide) => flattenComponents(slide.components));
22
+ }
20
23
  function convertValuesToOptions(values) {
21
24
  return values.map(({ value, label }) => value);
22
25
  }
@@ -1,8 +1,8 @@
1
- import { CalloutComponentSchema, CalloutResponseAnswer } from "../data/callouts";
1
+ import { CalloutComponentSchema, CalloutFormSchema, CalloutResponseAnswer } from "../data/callouts";
2
2
  import { FilterArgs } from "../search";
3
3
  import { CalloutResponseAnswerAddress, CalloutResponseAnswerFileUpload } from "../data/callouts";
4
4
  export declare function filterComponents(components: CalloutComponentSchema[], filterFn: (component: CalloutComponentSchema) => boolean): CalloutComponentSchema[];
5
- export declare function flattenComponents(components: CalloutComponentSchema[]): CalloutComponentSchema[];
5
+ export declare function getCalloutComponents(callout: CalloutFormSchema): CalloutComponentSchema[];
6
6
  export declare function convertComponentsToFilters(components: CalloutComponentSchema[]): Record<string, FilterArgs & {
7
7
  label: string;
8
8
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beabee/beabee-common",
3
- "version": "1.18.0-alpha.1",
3
+ "version": "1.18.0-alpha.2",
4
4
  "description": "",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",