editor.js
1 lines
| 1 | (()=>{"use strict";const e=window.React,t=window.wp.components,l=window.wp.i18n,r=window.jfb.actions,a=window.jfb.components;var i=function(){const e=Array.prototype.slice.call(arguments).filter(Boolean),t={},l=[];e.forEach(e=>{(e?e.split(" "):[]).forEach(e=>{if(e.startsWith("atm_")){const[,l]=e.split("_");t[l]=e}else l.push(e)})});const r=[];for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&r.push(t[e]);return r.push(...l),r.join(" ")};const o=function({settings:o,onChangeSettingObj:s}){const{hasError:n,setShowError:d}=(0,r.useActionValidatorProvider)({isSupported:e=>"role_can_register"===e?.property});return(0,e.createElement)(a.RowControl,null,({id:r})=>(0,e.createElement)(e.Fragment,null,(0,e.createElement)(a.RequiredLabel,{htmlFor:r},(0,l.__)("Who can add new user?","jet-form-builder")),(0,e.createElement)(t.Flex,{className:i(a.RowControlEndStyle,n&&a.ControlWithErrorStyle),direction:"column"},n&&(0,e.createElement)(a.IconText,null,(0,l.__)("Please fill this required field","jet-form-builder")),(0,e.createElement)(a.StyledSelectControl,{id:r,value:o.role_can_register,options:JetFBRegisterAction.allUserRoles,onChange:e=>s({role_can_register:e}),onBlur:()=>d(!0)}))))},s=window.jfb.blocksToActions,n=[{value:"login",label:(0,l.__)("User Login","jet-form-builder"),help:(0,l.__)("Choose the form field that will be used to get the user login. The value of this field will be stored as the user login in the database.","jet-form-builder"),required:!0},{value:"email",label:(0,l.__)("Email","jet-form-builder"),help:(0,l.__)("Choose the form field that will be used to get the user email. The value of this field will be stored as the user email in the database. You can use the same field in the User Login setting if you want the login and email to be the same.","jet-form-builder"),required:!0},{value:"password",label:(0,l.__)("Password","jet-form-builder"),help:(0,l.__)("Choose the form field that will be used to get the user password. The value of this field will be stored in the database in a hashed format.","jet-form-builder"),required:!0},{value:"confirm_password",label:(0,l.__)("Confirm Password","jet-form-builder"),help:(0,l.__)("Choose the form field that will be used to confirm the user password. This field is required to ensure the user has entered the correct password.","jet-form-builder"),required:!0},{value:"first_name",label:(0,l.__)("First Name","jet-form-builder"),help:(0,l.__)("(Optional) Choose the form field that will be used to get the user's first name. The value of this field will be stored in the database as the First Name in the user profile.","jet-form-builder")},{value:"last_name",label:(0,l.__)("Last Name","jet-form-builder"),help:(0,l.__)("(Optional) Choose the form field that will be used to get the user's last name. The value of this field will be stored in the WordPress database as the last name in the user profile.","jet-form-builder")},{value:"user_url",label:(0,l.__)("User URL","jet-form-builder"),help:(0,l.__)("(Optional) Choose the form field that will be used to get the user’s website. The value of this field will be stored in the WordPress database as the website in the Contacts section of the user profile.","jet-form-builder")}],d=function({getMapField:t,setMapField:i}){const o=(0,s.useFields)({withInner:!1,placeholder:"--"});return(0,e.createElement)("div",{className:a.TableListStyle.Wrap},(0,e.createElement)(a.Label,{className:a.TableListStyle.Label},(0,l.__)("Fields map","jet-form-builder")),(0,e.createElement)(a.Help,{className:a.TableListStyle.WhiteSpaceNormal},"Map your form fields to standard user’s fields. This links the form input to user profile data, so values are saved in the user’s account."),(0,e.createElement)(r.TableListContainer,null,(0,e.createElement)(r.TableListHead,{columns:[(0,l.__)("User Meta Fields","jet-form-builder"),(0,l.__)("Form Fields","jet-form-builder")]}),n.map(l=>(0,e.createElement)(r.TableListRow,{key:l.value,tag:l.value,label:l.label,help:l.help,isRequired:l.required},({setShowError:r,htmlId:s})=>(0,e.createElement)(a.StyledSelectControl,{id:s,onBlur:()=>r(!0),options:o,formFields:o,value:t({name:l.value}),onChange:e=>i({nameField:l.value,value:e})})))))},u=function({settings:t,onChangeSettingObj:r}){return(0,e.createElement)(a.RowControl,null,({id:i})=>(0,e.createElement)(e.Fragment,null,(0,e.createElement)(a.Label,{htmlFor:i},(0,l.__)("User Role","jet-form-builder")),(0,e.createElement)(a.StyledSelectControl,{multiple:!0,id:i,value:t.user_role,options:JetFBRegisterAction.userRoles,onChange:e=>r({user_role:e}),help:(0,l.__)("Hold Ctrl (Windows) or Command (Mac) to select multiple roles.","jet-form-builder")})))},m=function({getMapField:t,setMapField:i}){const o=(0,s.useFields)({withInner:!1});return(0,e.createElement)("div",{createId:!1,className:a.TableListStyle.Wrap},(0,e.createElement)(a.Label,{className:a.TableListStyle.Label},(0,l.__)("User Meta","jet-form-builder")),(0,e.createElement)(a.Help,{className:a.TableListStyle.WhiteSpaceNormal},(0,l.__)('Map form fields to custom user meta fields (e.g., "Phone") not included in WordPress by default.',"jet-form-builder")),(0,e.createElement)(a.Help,{className:a.TableListStyle.WhiteSpaceNormal},(0,l.__)("Other settings of the target meta field may affect whether the value is saved as an array.","jet-form-builder")),(0,e.createElement)(r.TableListContainer,null,(0,e.createElement)(r.TableListHead,{columns:[(0,l.__)("Form Fields","jet-form-builder"),(0,l.__)("User Meta Fields","jet-form-builder")]}),o.map(l=>(0,e.createElement)(r.TableListRow,{key:l.value,tag:l.value,label:l.label},({htmlId:o})=>(0,e.createElement)("div",{className:"jet-margin-bottom-wrapper"},(0,e.createElement)(a.StyledTextControl,{placeholder:"User meta field/key",id:o,value:t({source:"meta_fields_map",name:l.value}),onChange:e=>i({nameField:l.value,value:e,source:"meta_fields_map"})}),(0,e.createElement)(r.SingleValueAsArrayToggle,{fieldName:l.value,getMapField:t,setMapField:i}))))))},c=function({settings:t,onChangeSettingObj:r}){const i=(0,s.useFields)({withInner:!1,placeholder:"--"});return(0,e.createElement)(a.RowControl,null,({id:o})=>(0,e.createElement)(e.Fragment,null,(0,e.createElement)(a.Label,{htmlFor:o},(0,l.__)('"Remember me" field:',"jet-form-builder")),(0,e.createElement)(a.StyledSelectControl,{id:o,value:t.remember_me_field,options:i,onChange:e=>r({remember_me_field:e})})))},h=window.wp.primitives,f=(0,e.createElement)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,e.createElement)(h.Path,{fillRule:"evenodd",d:"M7.25 16.437a6.5 6.5 0 1 1 9.5 0V16A2.75 2.75 0 0 0 14 13.25h-4A2.75 2.75 0 0 0 7.25 16v.437Zm1.5 1.193a6.47 6.47 0 0 0 3.25.87 6.47 6.47 0 0 0 3.25-.87V16c0-.69-.56-1.25-1.25-1.25h-4c-.69 0-1.25.56-1.25 1.25v1.63ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm10-2a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z",clipRule:"evenodd"})),b={type:"register_user",label:(0,l.__)("Register User","jet-form-builder"),edit:function(i){const{settings:s,onChangeSettingObj:n,getMapField:h,setMapField:f}=i;return(0,e.createElement)(a.StyledFlexControl,{direction:"column"},(0,e.createElement)(t.ToggleControl,{className:a.ClearBaseControlStyle,label:(0,l.__)("Allow creating new users by existing users","jet-form-builder"),checked:s.allow_register,onChange:e=>n({allow_register:e}),help:(0,l.__)("If this option is enabled, logged-in users with the selected role will be able to add new users using this form. If disabled, only non-logged-in users will be able to register themselves.","jet-form-builder")}),s.allow_register&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)(a.WideLine,null),(0,e.createElement)(o,{settings:s,onChangeSettingObj:n})),(0,e.createElement)(a.WideLine,null),(0,e.createElement)(d,{getMapField:h,setMapField:f}),(0,e.createElement)(a.WideLine,null),(0,e.createElement)(u,{settings:s,onChangeSettingObj:n}),(0,e.createElement)(a.WideLine,null),(0,e.createElement)(t.ToggleControl,{className:a.ClearBaseControlStyle,label:(0,l.__)("Log In User after Register:","jet-form-builder"),checked:s.log_in,onChange:e=>n({log_in:e}),help:(0,l.__)('To use the "Remember me" option, first add a checkbox, radio button, or switcher field to your form with a value of 1, and label it "Remember me" or similar. Then, select it here.',"jet-form-builder")}),s.log_in&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)(a.WideLine,null),(0,e.createElement)(c,{settings:s,onChangeSettingObj:n})),(0,e.createElement)(a.WideLine,null),(0,e.createElement)(t.ToggleControl,{className:a.ClearBaseControlStyle,label:(0,l.__)("Add User ID to form data:","jet-form-builder"),checked:s.add_user_id,onChange:e=>n({add_user_id:e}),help:(0,l.__)('Registered user ID will be added to form data. Current user ID will be added to form data only if "Allow creating new users by existing users" option was disabled.',"jet-form-builder")}),(0,e.createElement)(a.WideLine,null),(0,e.createElement)(m,{getMapField:h,setMapField:f}),(0,e.createElement)(a.WideLine,null),(0,e.createElement)(r.ActionMessages,{...i}))},icon:f,docHref:"https://jetformbuilder.com/features/register-user/",category:"user",validators:[({settings:e})=>!!e.allow_register&&!e?.role_can_register&&{type:"empty",property:"role_can_register"},({settings:e})=>{const t=[];for(const l of n){if(!l.required)continue;const r=e?.fields_map?.[l.value];r||t.push({type:"empty",property:"field_"+l.value})}return t}]};function _(){r.BaseComputedField.call(this),this.isSupported=function(e){return"register_user"===e.type&&e.selfSettings.add_user_id},this.getName=function(){return"user_id"},this.getHelp=function(){return(0,l.__)("A computed field from the <b>Register User</b> action.","jet-form-builder")}}_.prototype=Object.create(r.BaseComputedField.prototype);const p=_;(0,r.registerAction)(b),(0,r.addComputedField)(p)})(); |