field-image-select
3 months ago
field-rating
6 months ago
form-progress-indicator
3 months ago
form-step-navigation
1 month ago
images
9 months ago
input-range
3 months ago
187.js
5 days ago
712.js
5 days ago
712.js.LICENSE.txt
5 days ago
913.css
5 days ago
913.js
5 days ago
913.rtl.css
5 days ago
93.css
2 weeks ago
93.js
5 days ago
93.rtl.css
2 weeks ago
ai-form-plugin.asset.php
5 days ago
ai-form-plugin.js
5 days ago
block.json
5 days ago
editor.asset.php
5 days ago
editor.css
5 days ago
editor.js
5 days ago
editor.rtl.css
5 days ago
view.asset.php
5 days ago
view.js
5 days ago
913.js
7 lines
| 1 | "use strict";(globalThis.webpackChunk_automattic_jetpack_forms_blocks=globalThis.webpackChunk_automattic_jetpack_forms_blocks||[]).push([[913],{21276(){},21913(e,t,o){o.r(t),o.d(t,{default:()=>k});var a=o(94715),n=o(56427),i=o(47143),s=o(86087),l=o(27723),r=o(15210),c=o(28755),d=o(39968),u=o(21220),p=o(13022),m=o(6888),f=o(73340),_=o(97806),h=o(1578),j=(o(21276),o(10790));const __=l.__,g=({rule:e,subject:t})=>{const{toggleBlockHighlight:o}=(0,i.useDispatch)(a.store),n=t?.clientId,l=(0,s.useCallback)(e=>n&&o(n,e),[n,o]);return(0,s.useEffect)(()=>()=>l(!1),[l]),(0,j.jsx)("li",{className:"jetpack-contact-form__conditional-logic-summary-item",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onFocus:()=>l(!0),onBlur:()=>l(!1),children:(0,j.jsx)(d.E,{variant:"body-sm",children:(0,_.IO)(e,t)})})},k=({clientId:e,attributes:t,setAttributes:o})=>{const[i,l]=(0,s.useState)(!1),k=(0,s.useMemo)(()=>(0,m.m3)(t.conditionalLogic),[t.conditionalLogic]),b=(0,f.A)(e),T=(0,m.Mg)(k),S=(0,s.useCallback)(e=>o({conditionalLogic:e}),[o]),E=(0,s.useCallback)(e=>S({...k,action:e}),[k,S]),C=(0,s.useCallback)(e=>S((0,m.fs)(k,T.rules,e)),[T.rules,k,S]),N=(0,s.useCallback)(e=>S((0,m.fs)(k,e,T.logicalOperator)),[T.logicalOperator,k,S]),x=(0,s.useCallback)(()=>l(!0),[]),A=(0,s.useCallback)(()=>l(!1),[]),I=(0,m.Vd)(k)>0,O=(0,_.l5)(T,b);return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(a.BlockControls,{__experimentalShareWithChildBlocks:!0,children:(0,j.jsx)(n.ToolbarGroup,{children:(0,j.jsx)(n.ToolbarButton,{icon:(0,m.qu)(k)?c.A:r.A,title:O.length?(0,_.Of)(k,T,b):__("Add conditional logic","jetpack-forms"),onClick:x,className:(0,p.A)("jetpack-contact-form__conditional-logic-toolbar",{"is-pressed":I})})})}),(0,j.jsxs)(a.InspectorControls,{children:[(0,j.jsx)(n.PanelBody,{title:__("Conditional logic","jetpack-forms"),initialOpen:!1,className:"jetpack-contact-form__panel jetpack-contact-form__conditional-logic",children:(0,j.jsxs)(u.B,{direction:"column",gap:"md",children:[O.length?(0,j.jsxs)(u.B,{direction:"column",gap:"xs",children:[(0,j.jsx)(d.E,{variant:"body-sm",className:"jetpack-contact-form__conditional-logic-summary-text",children:(0,_.Bi)(k,T)}),(0,j.jsx)("ul",{className:"jetpack-contact-form__conditional-logic-summary-list",children:O.map(({rule:e,subject:t},o)=>(0,j.jsx)(g,{rule:e,subject:t},o))})]}):(0,j.jsx)(d.E,{variant:"body-sm",className:"jetpack-contact-form__conditional-logic-summary-text",children:__("Show or hide this field based on the answer to another field.","jetpack-forms")}),(0,j.jsx)(n.Button,{variant:"secondary",onClick:x,__next40pxDefaultSize:!0,className:"jetpack-contact-form__conditional-logic-edit",children:I?__("Edit conditions","jetpack-forms"):__("Add conditions","jetpack-forms",0)})]})}),(0,j.jsx)(h.A,{isOpen:i,onClose:A,logic:k,group:T,fields:b,ownFieldId:t.id,onActionChange:E,onMatchChange:C,onRulesChange:N})]})]})}},1578(e,t,o){o.d(t,{A:()=>u});var a=o(56427),n=o(27723),i=o(21220),s=o(39968),l=o(37050),r=o(10790);const __=n.__,c=[{value:"show",label:__("Show this field","jetpack-forms")},{value:"hide",label:__("Hide this field","jetpack-forms")}],d=[{value:"any",label:__("if any","jetpack-forms")},{value:"all",label:__("if all","jetpack-forms")}],u=({isOpen:e,onClose:t,logic:o,group:n,fields:u,ownFieldId:p,onActionChange:m,onMatchChange:f,onRulesChange:_})=>e?(0,r.jsx)(a.Modal,{title:__("Conditional logic","jetpack-forms"),onRequestClose:t,size:"large",className:"jetpack-contact-form__conditional-logic-modal",children:(0,r.jsxs)(i.B,{direction:"column",gap:"md",children:[(0,r.jsxs)(i.B,{direction:"row",align:"center",gap:"sm",className:"jetpack-contact-form__conditional-logic-sentence",children:[(0,r.jsx)(a.SelectControl,{label:__("Action","jetpack-forms"),hideLabelFromVision:!0,value:o.action,options:c,onChange:m,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),(0,r.jsx)(a.SelectControl,{label:__("When","jetpack-forms"),hideLabelFromVision:!0,value:n.logicalOperator,options:d,onChange:f,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})]}),(0,r.jsx)(s.E,{variant:"body-sm",className:"jetpack-contact-form__conditional-logic-hint",children:"hide"===o.action?__("This field is visible by default, until the following conditions are met:","jetpack-forms"):__("This field is hidden by default, until the following conditions are met:","jetpack-forms",0)}),(0,r.jsx)(l.A,{rules:n.rules,fields:u,ownFieldId:p,onChange:_})]})}):null},37050(e,t,o){o.d(t,{A:()=>x});var a=o(56427),n=o(86087),i=o(27723),s=o(53758),l=o(88901),r=o(60167),c=o(57839),d=o(21220),u=o(33180),p=o(72326),m=o(13022),f=o(6888),_=o(73340),h=o(13537),j=o(26103),g=o(35723),k=o(90445),b=o(10790);const __=i.__,T={number:"number",date:"date",time:"time"},S=e=>e.id||`clientId:${e.clientId}`,E=({rule:e,subject:t,onChange:o})=>{if(!(0,j.vA)(e.operator))return null;const n=(0,j.mv)(t?.typeKey||"string");if("none"===n)return null;const i=e.value??"",s=__("Value","jetpack-forms");if("options"===n){const e=t?.options||[];return e.length?(0,b.jsx)(a.SelectControl,{label:s,hideLabelFromVision:!0,value:i,options:[{value:"",label:__("Select an option…","jetpack-forms")},...e],onChange:o,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}):(0,b.jsx)(a.Notice,{status:"warning",isDismissible:!1,children:__("This field has no options yet. Add one to compare against it.","jetpack-forms")})}const l=T[n]||"text";return(0,b.jsx)(a.TextControl,{label:s,hideLabelFromVision:!0,placeholder:__("Value","jetpack-forms"),type:l,value:i,onChange:o,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})},C=({rule:e,index:t,fields:o,ownFieldId:r,shouldFocus:p,onChange:f,onRemove:T})=>{const C=(0,n.useRef)(null);(0,n.useEffect)(()=>{p&&C.current?.focus()},[p]);const N=(0,_.V)(),x=o.find(t=>t.id&&t.id===e.field),A=e.field&&!x,I=(0,n.useCallback)(a=>{const n=o.find(e=>S(e)===a);if(!n)return void f(t,{field:"",operator:j.we.IS,value:""});const i=[...o.map(e=>e.id),r].filter(Boolean),s=N(n,i),l=(0,j.qP)(n.typeKey).includes(e.operator)?e.operator:(e=>{const t=(0,j.qP)(e);return t.length?t[0]:j.we.IS})(n.typeKey);f(t,{field:s,operator:l,value:""})},[N,o,r,t,f,e.operator]),O=(0,n.useCallback)(e=>f(t,{operator:e}),[t,f]),y=(0,n.useCallback)(e=>f(t,{value:e}),[t,f]),v=(0,n.useCallback)(()=>T(t),[t,T]),w=(0,j.qP)(x?.typeKey||"string"),B=(0,k._A)(e,x),M=__("This condition is active.","jetpack-forms");let L=__("Choose a field to compare against.","jetpack-forms");A?L=__("The field this condition refers to no longer exists.","jetpack-forms"):(0,k.Cc)(e)&&(L=__("Give this condition a value.","jetpack-forms"));const F=o.reduce((e,t)=>{const o=t.step?(0,i.sprintf)(/* translators: %d: step number in a multi-step form */ |
| 2 | __("Step %d","jetpack-forms"),t.step):__("Fields","jetpack-forms");return e[o]=e[o]||[],e[o].push(t),e},{});return(0,b.jsxs)(d.B,{direction:"column",gap:"xs",className:"jetpack-contact-form__conditional-logic-rule",children:[A&&(0,b.jsx)(a.Notice,{status:"warning",isDismissible:!1,children:__("The referenced field no longer exists. Pick another field or remove this condition.","jetpack-forms")}),(0,b.jsxs)(d.B,{direction:"row",align:"center",gap:"sm",className:"jetpack-contact-form__conditional-logic-rule-row",children:[(0,b.jsx)(a.Tooltip,{text:B?M:L,children:(0,b.jsx)("span",{className:(0,m.A)("jetpack-contact-form__conditional-logic-rule-status",{"is-active":B}),role:"img","aria-label":B?M:L,children:(0,b.jsx)(a.Icon,{icon:B?l.A:s.A,size:20})})}),(0,b.jsxs)(a.SelectControl,{ref:C,label:__("Field","jetpack-forms"),hideLabelFromVision:!0,value:e.field||"",onChange:I,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,children:[(0,b.jsx)("option",{value:"",children:__("Select a field…","jetpack-forms")}),Object.keys(F).map(e=>(0,b.jsx)("optgroup",{label:e,children:F[e].map(e=>(0,b.jsx)("option",{value:S(e),children:(0,h.C)(e)},e.clientId))},e))]}),(0,b.jsx)(a.SelectControl,{label:__("Operator","jetpack-forms"),hideLabelFromVision:!0,value:e.operator,options:w.map(e=>({value:e,label:(0,g.B)(e)})),onChange:O,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),(0,b.jsx)(E,{rule:e,subject:x,onChange:y}),(0,b.jsx)(u.K,{size:"small",variant:"minimal",tone:"neutral",icon:c.A,onClick:v,label:(0,i.sprintf)(/* translators: %d: condition number, starting at 1 */ |
| 3 | __("Remove condition %d","jetpack-forms"),t+1)})]})]})},N={type:f.Th,field:"",operator:j.we.IS,value:""},x=({rules:e,onChange:t,fields:o,ownFieldId:i})=>{const s=(0,n.useMemo)(()=>Array.isArray(e)?e:[],[e]),l=(0,n.useMemo)(()=>s.length?s:[N],[s]),[c,u]=(0,n.useState)(null),m=(0,n.useCallback)((e,o)=>{s.length?t(s.map((t,a)=>a===e?{...t,...o}:t)):t([{...N,...o}])},[t,s]),f=(0,n.useCallback)(e=>{t(s.filter((t,o)=>o!==e))},[t,s]),_=(0,n.useCallback)(()=>{u(s.length),t([...s,{...N}])},[t,s]);return o.length?(0,b.jsxs)(d.B,{direction:"column",gap:"md",className:"jetpack-contact-form__conditional-logic-control",children:[l.map((e,t)=>(0,b.jsx)(C,{rule:e,index:t,fields:o,ownFieldId:i,shouldFocus:t===c,onChange:m,onRemove:f},t)),(0,b.jsx)(p.$,{variant:"outline",tone:"neutral",icon:r.A,onClick:_,className:"jetpack-contact-form__conditional-logic-add",children:__("Add condition","jetpack-forms")})]}):(0,b.jsx)(a.Notice,{status:"warning",isDismissible:!1,children:__("Add another field to this form to use as a condition.","jetpack-forms")})}},47088(e,t,o){o.d(t,{r:()=>s});const a=["jetpack/option","jetpack/input-image-option"],n=e=>{const t=new Set,o=[];return e.forEach(e=>{if("string"!=typeof e)return;const a=e.trim();""===a||t.has(a)||(t.add(a),o.push({value:a,label:a}))}),o},i=(e,t)=>{Array.isArray(e)&&e.forEach(e=>{e&&(e.name&&a.includes(e.name)?t.push(e.attributes?.label):i(e.innerBlocks,t))})},s=e=>{if(!e)return[];if("jetpack/field-rating"===e.name){const t=Number(e.attributes?.max),o=Number.isFinite(t)&&t>0?Math.floor(t):5;return Array.from({length:o},(e,t)=>({value:String(t+1),label:String(t+1)}))}if("jetpack/field-select"===e.name){const t=e.attributes?.options;return Array.isArray(t)?n(t):[]}const t=[];return i(e.innerBlocks,t),n(t)}},26103(e,t,o){o.d(t,{mv:()=>r,qP:()=>l,vA:()=>c,we:()=>a});const a={IS:"is",IS_NOT:"is_not",CONTAINS:"contains",DOES_NOT_CONTAIN:"does_not_contain",IS_EMPTY:"is_empty",IS_NOT_EMPTY:"is_not_empty",EQUALS:"equals",NOT_EQUALS:"not_equals",GREATER_THAN:"greater_than",LESS_THAN:"less_than",GTE:"gte",LTE:"lte",BEFORE:"before",AFTER:"after",IS_CHECKED:"is_checked",IS_NOT_CHECKED:"is_not_checked"},n=new Set([a.IS_EMPTY,a.IS_NOT_EMPTY,a.IS_CHECKED,a.IS_NOT_CHECKED]),i={string:[a.IS,a.IS_NOT,a.CONTAINS,a.DOES_NOT_CONTAIN,a.IS_EMPTY,a.IS_NOT_EMPTY],choice:[a.IS,a.IS_NOT,a.IS_EMPTY,a.IS_NOT_EMPTY],multichoice:[a.CONTAINS,a.DOES_NOT_CONTAIN,a.IS_EMPTY,a.IS_NOT_EMPTY],rating:[a.EQUALS,a.NOT_EQUALS,a.GREATER_THAN,a.LESS_THAN,a.GTE,a.LTE,a.IS_EMPTY,a.IS_NOT_EMPTY],number:[a.EQUALS,a.NOT_EQUALS,a.GREATER_THAN,a.LESS_THAN,a.GTE,a.LTE,a.IS_EMPTY,a.IS_NOT_EMPTY],date:[a.IS,a.IS_NOT,a.BEFORE,a.AFTER],time:[a.IS,a.IS_NOT,a.BEFORE,a.AFTER],boolean:[a.IS_CHECKED,a.IS_NOT_CHECKED],hidden:[a.IS,a.IS_NOT,a.CONTAINS],file:[a.IS_EMPTY,a.IS_NOT_EMPTY]},s={string:"text",choice:"options",multichoice:"options",number:"number",rating:"options",date:"date",time:"time",boolean:"none",hidden:"text",file:"none"},l=e=>i[e]??[],r=e=>s[e]??"text",c=e=>!n.has(e)},35723(e,t,o){o.d(t,{B:()=>s});var a=o(27723),n=o(26103);const __=a.__,i={[n.we.IS]:__("is","jetpack-forms"),[n.we.IS_NOT]:__("is not","jetpack-forms"),[n.we.CONTAINS]:__("contains","jetpack-forms"),[n.we.DOES_NOT_CONTAIN]:__("does not contain","jetpack-forms"),[n.we.IS_EMPTY]:__("is empty","jetpack-forms"),[n.we.IS_NOT_EMPTY]:__("is not empty","jetpack-forms"),[n.we.EQUALS]:__("equals","jetpack-forms"),[n.we.NOT_EQUALS]:__("does not equal","jetpack-forms"),[n.we.GREATER_THAN]:__("is greater than","jetpack-forms"),[n.we.LESS_THAN]:__("is less than","jetpack-forms"),[n.we.GTE]:__("is at least","jetpack-forms"),[n.we.LTE]:__("is at most","jetpack-forms"),[n.we.BEFORE]:__("is before","jetpack-forms"),[n.we.AFTER]:__("is after","jetpack-forms"),[n.we.IS_CHECKED]:__("is checked","jetpack-forms"),[n.we.IS_NOT_CHECKED]:__("is not checked","jetpack-forms")},s=e=>i[e]??e},6888(e,t,o){o.d(t,{Mg:()=>s,Th:()=>n,Vd:()=>r,fs:()=>l,m3:()=>i,qu:()=>c});const a={enabled:!1,action:"show",logicalOperator:"any",groups:[]},n="fieldValue",i=e=>{const t={...a,...e||{}},o=Array.isArray(t.groups)?t.groups:[];return{...t,groups:o.map(e=>({logicalOperator:"all"===e?.logicalOperator?"all":"any",rules:Array.isArray(e?.rules)?e.rules:[]}))}},s=e=>e.groups[0]||((e="any")=>({logicalOperator:e,rules:[]}))(),l=(e,t,o)=>{const[,...a]=e.groups,n=t.length?[{logicalOperator:o,rules:t},...a]:a;return{...e,groups:n,enabled:n.some(e=>e.rules.length>0)}},r=e=>e.groups.reduce((e,t)=>e+t.rules.length,0),c=e=>r(e)>0&&"show"===e.action},73340(e,t,o){o.d(t,{A:()=>f,V:()=>m});var a=o(94715),n=o(74997),i=o(47143),s=o(86087),l=o(27723),r=o(13549),c=o(1799),d=o(47088);const __=l.__,u=e=>{const t=(e.innerBlocks||[]).find(e=>"jetpack/label"===e.name),o=t?.attributes?.label;return o&&o.trim()?o.trim():e.attributes?.id||__("Untitled field","jetpack-forms")},p=(e,t,o,a)=>{if(!Array.isArray(e))return;let i=o;e.forEach(e=>{if(!e)return;"jetpack/form-step"===e.name&&(i=(i||0)+1);const o=(0,c.x)(e.name);o&&e.clientId!==t?a.push({clientId:e.clientId,id:e.attributes?.id||"",label:u(e),typeLabel:(0,n.getBlockType)(e.name)?.title||"",typeKey:o,options:(0,d.r)(e),step:i}):p(e.innerBlocks,t,i,a)})},m=()=>{const{updateBlockAttributes:e}=(0,i.useDispatch)(a.store);return(0,s.useCallback)((t,o=[])=>{if(!t)return"";if(t.id)return t.id;const a=(0,r.C)((t.label||"").trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9_-]/g,"")||"field",o);return e(t.clientId,{id:a}),a},[e])},f=e=>(0,i.useSelect)(t=>{const{getBlock:o,getBlockParentsByBlockName:a,getBlockRootClientId:n}=t("core/block-editor"),i=a(e,"jetpack/contact-form"),s=i?.[i.length-1]||n(e);if(!s)return[];const l=o(s),r=[];return p(l?.innerBlocks||[],e,null,r),r},[e])},13537(e,t,o){o.d(t,{C:()=>n});var a=o(27723);const __=a.__,n=e=>{const t=e?.label||"";return e?.typeLabel?(0,a.sprintf)(/* translators: 1: form field label, 2: the field's type, e.g. "Dropdown field" */ |
| 4 | __("%1$s (%2$s)","jetpack-forms"),t,e.typeLabel):t}},90445(e,t,o){o.d(t,{Cc:()=>n,_A:()=>i});var a=o(26103);const n=e=>Boolean(e?.field),i=(e,t)=>!!(n(e)&&t&&e.operator)&&(!(0,a.vA)(e.operator)||""!==String(e.value??"").trim())},97806(e,t,o){o.d(t,{Bi:()=>r,IO:()=>c,Of:()=>u,l5:()=>d});var a=o(27723),n=o(13537),i=o(26103),s=o(35723),l=o(90445);const __=a.__,r=(e,t)=>{const o="all"===t.logicalOperator;return"hide"===e.action?o?__("This field is hidden only if:","jetpack-forms"):__("This field is hidden if any of these are true:","jetpack-forms",0):o?__("This field is shown only if:","jetpack-forms"):__("This field is shown if any of these are true:","jetpack-forms",0)},c=(e,t)=>{const o=(0,n.C)(t),l=(0,s.B)(e.operator);return(0,i.vA)(e.operator)?(0,a.sprintf)(/* translators: 1: form field label, 2: comparison, e.g. "is", 3: the value compared against */ |
| 5 | __("%1$s %2$s “%3$s”","jetpack-forms"),o,l,String(e.value??"")):(0,a.sprintf)(/* translators: 1: form field label, 2: comparison, e.g. "is not empty" */ |
| 6 | __("%1$s %2$s","jetpack-forms"),o,l)},d=(e,t)=>e.rules.map(e=>({rule:e,subject:t.find(t=>t.id&&t.id===e.field)})).filter(({rule:e,subject:t})=>(0,l._A)(e,t)),u=(e,t,o)=>{const n=d(t,o);return n.length?(0,a.sprintf)(/* translators: 1: heading ending in a colon, 2: the conditions, separated by semicolons */ |
| 7 | __("%1$s %2$s","jetpack-forms"),r(e,t),n.map(({rule:e,subject:t})=>c(e,t)).join("; ")):""}}}]); |