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.

44 lines (43 loc) 2.04 kB
export const addConditionEvaluators = (ruleSettings) => { ruleSettings.addConditionEvaluator('Equal', function (currentValue, ruleValue) { if (typeof currentValue === 'string') { return currentValue.search(new RegExp('^' + ruleValue + '$', 'i')) === 0; } return currentValue === ruleValue; }); ruleSettings.addConditionEvaluator('NotEqual', function (currentValue, ruleValue) { if (typeof currentValue === 'string') { return currentValue.search(new RegExp('^' + ruleValue + '$', 'i')) === -1; } return currentValue !== ruleValue; }); ruleSettings.addConditionEvaluator('Contains', function (currentValue, ruleValue) { return currentValue.search(new RegExp(ruleValue, 'i')) > -1; }); ruleSettings.addConditionEvaluator('NotContains', function (currentValue, ruleValue) { return currentValue.search(new RegExp(ruleValue, 'i')) === -1; }); const isFilledFunction = function (currentValue) { // Check if currentValue is NaN if (typeof currentValue === 'number' && currentValue !== currentValue) { return false; } return !!(currentValue && currentValue.toString().length > 0); }; ruleSettings.addConditionEvaluator('IsFilled', isFilledFunction); ruleSettings.addConditionEvaluator('IsNotFilled', function (currentValue) { return !isFilledFunction(currentValue); }); ruleSettings.addConditionEvaluator('FileSelected', function (currentValue) { return !!(currentValue && currentValue.length > 0); }); ruleSettings.addConditionEvaluator('FileNotSelected', function (currentValue) { return !currentValue || currentValue.length === 0; }); ruleSettings.addConditionEvaluator('IsGreaterThan', function (currentValue, ruleValue) { return currentValue > ruleValue; }); ruleSettings.addConditionEvaluator('IsLessThan', function (currentValue, ruleValue) { return currentValue < ruleValue; }); };