scrivito-neoletter-form-widgets
Version:
A set of Scrivito Neoletter Form Widgets
1 lines • 2.3 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("scrivito")):"function"==typeof define&&define.amd?define(["scrivito"],t):"object"==typeof exports?exports["scrivito-form-widgets"]=t(require("scrivito")):e["scrivito-form-widgets"]=t(e.scrivito)}(this,e=>(()=>{"use strict";var t={2311(t){t.exports=e}},o={};function r(e){var n=o[e];if(void 0!==n)return n.exports;var i=o[e]={exports:{}};return t[e](i,i.exports,r),i.exports}r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};r.r(n),r.d(n,{customFieldNameValidation:()=>m,getFormContainer:()=>s,insideFormContainerValidation:()=>a});var i=r(2311);function s(e){let t=e.container();for(;t instanceof i.Widget;){const e=t.objClass();if("FormStepContainerWidget"===e||"FormContainerWidget"===e)return t;t=t.container()}return null}function a(e){return s(e)?"":"Needs to be inside an Automations form."}function u(e){return!e.attributeDefinitions().type||"custom"===e.get("type")}function c(e){return u(e)?e.get("customFieldName"):"urlParam"==e.get("type")?e.get("urlParameterFieldName")||"":e.get("type")}const m=["customFieldName",(e,{widget:t})=>u(t)?((e,t)=>{if(!e.startsWith("custom_"))return'Custom field names must start with "custom_".';if(e.length<=7)return"Specify the custom field's name.";const o=e.slice(7);return/^[0-9]/.test(o)?'Custom field names must not start with a number after "custom_".':null===e.match(/^[A-Za-z_][A-Za-z0-9_]*$/)?'Custom field names may consist of the following characters: "a-z", "A-Z", "0-9", "_".':e.length>50?`Custom field names may be up to 50 characters long. This name is ${e.length} characters long.`:function(e){const t=c(e);if(null==(o=t)||(o instanceof Map||o instanceof Set?0===o.size:[Object,Array].includes((o||{}).constructor)&&!Object.entries(o||{}).length))return!0;var o;const r=s(e);return!r||!r.widgets().find(o=>c(o)===t&&o.id()!==e.id())}(t)?"":"Specify a unique custom field name. There is at least one other element with the same custom field name."})(e,t):""];return n})());