@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
2 lines • 1.27 kB
JavaScript
const e=[`equals`,`notEquals`,`isEmpty`,`isNotEmpty`,`contains`,`notContains`],t=[`same`,`default`,`any`],n=(e,t)=>{if(e==null)return t==null;if(t==null)return!1;if(typeof e==`boolean`||typeof t==`boolean`){let n=r(e),i=r(t);return n===void 0||i===void 0?!1:n===i}return e===t},r=e=>{if(typeof e==`boolean`)return e;if(e===1)return!0;if(e===0)return!1},i=e=>!!(e==null||e===``||Array.isArray(e)&&e.length===0),a=(e,t)=>Array.isArray(e)?e.some(e=>n(e,t??null)):typeof e==`string`?typeof t==`string`?t.length>0&&e.includes(t):typeof t==`number`||typeof t==`boolean`?e.includes(String(t)):!1:!1,o=(e,t)=>{switch(e.operator){case`equals`:return n(t,e.value??null);case`notEquals`:return!n(t,e.value??null);case`isEmpty`:return i(t);case`isNotEmpty`:return!i(t);case`contains`:return a(t,e.value);case`notContains`:return!a(t,e.value);default:return!1}},s=(e,t)=>{if(!e)return!0;let n=(e.groups??[]).filter(e=>e.length>0);if(n.length===0)return!0;let r=n.some(e=>e.every(e=>{let n=t(e.field);return n.resolved?`values`in n?n.values.some(t=>o(e,t)):o(e,n.value):!1}));return(e.action??`show`)===`show`?r:!r};export{o as evaluateConditionRule,s as evaluateFieldCondition,e as fieldConditionOperators,t as fieldConditionTranslationScopes};
//# sourceMappingURL=index.mjs.map