@oneblink/sdk-core
Advanced tools
Comparing version 3.2.0 to 4.0.0-beta.1
@@ -60,4 +60,4 @@ import { FormTypes } from '@oneblink/types'; | ||
/** | ||
* Parse unknown data as valid options for a forms element. This will always | ||
* return an Array of valid options. | ||
* Parse unknown data as valid dynamic options for a forms element. This will | ||
* always return an Array of valid dynamic options. | ||
* | ||
@@ -67,3 +67,3 @@ * #### Example | ||
* ```js | ||
* const options = formElementsService.parseFormElementOptionsSet(data) | ||
* const options = formElementsService.parseDynamicFormElementOptions(data) | ||
* // "options" are valid for a form element | ||
@@ -75,3 +75,3 @@ * ``` | ||
*/ | ||
declare function parseFormElementOptionsSet(data: unknown): FormTypes.ChoiceElementOption[]; | ||
declare function parseDynamicFormElementOptions(data: unknown): FormTypes.DynamicChoiceElementOption[]; | ||
/** | ||
@@ -131,2 +131,2 @@ * Takes the nested definition structure and returns all form elements as 1d | ||
declare function determineIsInfoPage(form: FormTypes.Form): boolean; | ||
export { forEachFormElement, forEachFormElementWithOptions, findFormElement, parseFormElementOptionsSet, flattenFormElements, ElementWYSIWYGRegex, matchElementsTagRegex, determineIsInfoPage, }; | ||
export { forEachFormElement, forEachFormElementWithOptions, findFormElement, parseDynamicFormElementOptions, flattenFormElements, ElementWYSIWYGRegex, matchElementsTagRegex, determineIsInfoPage, }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.determineIsInfoPage = exports.matchElementsTagRegex = exports.ElementWYSIWYGRegex = exports.flattenFormElements = exports.parseFormElementOptionsSet = exports.findFormElement = exports.forEachFormElementWithOptions = exports.forEachFormElement = void 0; | ||
exports.determineIsInfoPage = exports.matchElementsTagRegex = exports.ElementWYSIWYGRegex = exports.flattenFormElements = exports.parseDynamicFormElementOptions = exports.findFormElement = exports.forEachFormElementWithOptions = exports.forEachFormElement = void 0; | ||
const _1 = require("."); | ||
@@ -99,4 +99,4 @@ /** | ||
/** | ||
* Parse unknown data as valid options for a forms element. This will always | ||
* return an Array of valid options. | ||
* Parse unknown data as valid dynamic options for a forms element. This will | ||
* always return an Array of valid dynamic options. | ||
* | ||
@@ -106,3 +106,3 @@ * #### Example | ||
* ```js | ||
* const options = formElementsService.parseFormElementOptionsSet(data) | ||
* const options = formElementsService.parseDynamicFormElementOptions(data) | ||
* // "options" are valid for a form element | ||
@@ -114,3 +114,3 @@ * ``` | ||
*/ | ||
function parseFormElementOptionsSet(data) { | ||
function parseDynamicFormElementOptions(data) { | ||
if (!Array.isArray(data)) { | ||
@@ -122,3 +122,2 @@ return []; | ||
options.push({ | ||
id: index.toString(), | ||
value: record, | ||
@@ -133,3 +132,2 @@ label: record, | ||
: index.toString(); | ||
const id = typeof option.id === 'string' && option.id ? option.id : value; | ||
const label = typeof option.label === 'string' && option.label | ||
@@ -141,8 +139,30 @@ ? option.label | ||
: undefined; | ||
const displayAlways = typeof option.displayAlways === 'boolean' | ||
? option.displayAlways | ||
: undefined; | ||
const attributes = Array.isArray(option.attributes) | ||
? option.attributes.reduce((memo, attribute) => { | ||
if (typeof attribute === 'object' && | ||
attribute && | ||
'value' in attribute && | ||
typeof attribute.value === 'string' && | ||
'label' in attribute && | ||
typeof attribute.label === 'string') { | ||
memo.push({ | ||
value: attribute.value, | ||
label: attribute.label, | ||
}); | ||
} | ||
return memo; | ||
}, []) | ||
: undefined; | ||
options.push({ | ||
...option, | ||
id, | ||
value, | ||
label, | ||
colour, | ||
attributes, | ||
displayAlways, | ||
options: Array.isArray(option.options) | ||
? parseDynamicFormElementOptions(option.options) | ||
: undefined, | ||
}); | ||
@@ -153,3 +173,3 @@ } | ||
} | ||
exports.parseFormElementOptionsSet = parseFormElementOptionsSet; | ||
exports.parseDynamicFormElementOptions = parseDynamicFormElementOptions; | ||
/** | ||
@@ -156,0 +176,0 @@ * Takes the nested definition structure and returns all form elements as 1d |
{ | ||
"name": "@oneblink/sdk-core", | ||
"description": "OneBlink SDK for JavaScript (works in Browsers and NodeJS)", | ||
"version": "3.2.0", | ||
"version": "4.0.0-beta.1", | ||
"author": "OneBlink <developers@oneblink.io> (https://oneblink.io)", | ||
@@ -6,0 +6,0 @@ "bugs": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
248229
2857
1