UNPKG

@progress/sitefinity-nextjs-sdk

Version:

Provides OOB widgets developed using the Next.js framework, which includes an abstraction layer for Sitefinity communication. Additionally, it offers an expanded API, typings, and tools for further development and integration.

36 lines (35 loc) 1.52 kB
export class ConditionEvaluator { name; conditionEvaluator; settings; constructor(name, conditionEvaluator, settings) { this.name = name; this.conditionEvaluator = conditionEvaluator; this.settings = settings; } canProcess(name) { return name === this.name; } ; process(currentValue, ruleValue, inputType) { if (!this.settings.InputTypeParsers || this.settings.InputTypeParsers.length === 0) { return false; } let inputTypeParser; for (let inputValueIndex = 0; inputValueIndex < this.settings.InputTypeParsers.length; inputValueIndex++) { if (inputValueIndex === 0 || this.settings.InputTypeParsers[inputValueIndex].canParse(inputType)) { inputTypeParser = this.settings.InputTypeParsers[inputValueIndex]; } } let ruleValueParsers; for (let ruleValueIndex = 0; ruleValueIndex < this.settings.RuleValueParsers.length; ruleValueIndex++) { if (ruleValueIndex === 0 || this.settings.RuleValueParsers[ruleValueIndex].canParse(inputType)) { ruleValueParsers = this.settings.RuleValueParsers[ruleValueIndex]; } } let parsedCurrentValue = inputTypeParser ? inputTypeParser.parse(currentValue) : currentValue; let parsedRuleValue = ruleValueParsers ? ruleValueParsers.parse(ruleValue) : ruleValue; return this.conditionEvaluator(parsedCurrentValue, parsedRuleValue); } ; }