You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
44 KiB

9 months ago
(()=>{var e,t={843:(e,t,a)=>{"use strict";const i=window.wp.blocks;(0,window.wp.hooks.addFilter)("blockEditor.useSetting.before","MFB/blockEditor.useSetting.before",((e,t,a,i)=>"mfb/meta-field-block"!==i?e:!!["color.text","color.background","color.link"].includes(t)||e));const n=window.React,l=window.wp.i18n,o=window.wp.blockEditor,r=window.wp.components,s=["div","h1","h2","h3","h4","h5","h6","span","p","header","footer","section"],c={className:"mfb-tagname-dropdown"},d=({value:e})=>(0,n.createElement)("strong",{style:{fontFamily:"sans-serif",fontWeight:800,fontSize:"1.3em",textAlign:"center",letterSpacing:"-1px"}},e.toUpperCase());function p({value:e,onChange:t}){return(0,n.createElement)(r.ToolbarDropdownMenu,{popoverProps:c,label:(0,l.__)("Change tag name","display-a-meta-field-as-block"),text:(0,n.createElement)(d,{value:e}),icon:null,controls:s.map((a=>{{const i=a===e;return{key:a,title:(0,n.createElement)(d,{value:a}),label:a,isActive:i,onClick(){t(a)},role:"menuitemradio"}}}))})}var f=a(856),m=a.n(f),u=a(967),y=a.n(u);const g=({value:e,isLoading:t,fieldType:a,type:i,className:l,TagName:s="div",textAlign:c,prefix:d,suffix:p,prefixSettings:f,suffixSettings:u,displayLayout:g="",showOutline:h=!1})=>{const b="div"===s?"div":"span",_=d?(0,n.createElement)(b,{className:"prefix",style:{...f,...f?.gap?.top?{"--mfb--gap":(0,o.getSpacingPresetCssVar)(f.gap.top)}:{}},dangerouslySetInnerHTML:{__html:m().sanitize(d)}}):null,v=p?(0,n.createElement)(b,{className:"suffix",style:{...u,...u?.gap?.top?{"--mfb--gap":(0,o.getSpacingPresetCssVar)(u.gap.top)}:{}},dangerouslySetInnerHTML:{__html:m().sanitize(p)}}):null;return(0,n.createElement)(s,{...(0,o.useBlockProps)({className:y()(l,{[`is-${i}-field`]:i,[`is-${a}-field`]:a,[`has-text-align-${c}`]:c,[`is-display-${g}`]:g}),style:h?{minHeight:"1em",outline:"1px dashed"}:null})},_,t?(0,n.createElement)(r.Spinner,null):(0,n.createElement)(b,{className:"value",dangerouslySetInnerHTML:{__html:e?m().sanitize(e):e}}),v)},h=({fieldType:e,fieldTypeOptions:t,fieldTypeHelpMessages:a,setAttributes:i,fieldName:o,setFieldName:s,fieldNameHelp:c})=>{var d;return(0,n.createElement)(n.Fragment,null,(0,n.createElement)(r.SelectControl,{label:(0,l.__)("Field type","display-a-meta-field-as-block"),value:e,onChange:e=>i({fieldType:e}),options:t,help:null!==(d=a[e])&&void 0!==d?d:(0,l.__)("Choose a field type","display-a-meta-field-as-block")}),(0,n.createElement)(r.TextControl,{autoComplete:"off",label:(0,l.__)("Field name","display-a-meta-field-as-block"),value:o,onChange:s,help:c}))},b=({setAttributes:e,hideEmpty:t,hasEmptyMessage:a=!0,emptyMessage:i})=>(0,n.createElement)(n.Fragment,null,(0,n.createElement)(r.ToggleControl,{label:(0,l.__)("Hide block if the value is empty","display-a-meta-field-as-block"),checked:t,onChange:t=>e({hideEmpty:t})}),!t&&a&&(0,n.createElement)(r.TextControl,{label:(0,l.__)("Empty message","display-a-meta-field-as-block"),value:i,onChange:t=>e({emptyMessage:t}),help:(0,l.__)("Display this text if the value is empty.","display-a-meta-field-as-block")})),_=window.lodash,v=window.wp.element,k=e=>null==e?`${e}`:Object.prototype.toString.call(e).match(/\s([a-z]+)/i)[1].toLowerCase(),E=(0,l.__)("<code>This data type is not supported!</code>","display-a-meta-field-as-block"),x=(0,l.__)("<code>No value</code>","display-a-meta-field-as-block"),T=(0,l.__)("<code>No value</code>","display-a-meta-field-as-block"),S=[{label:(0,l.__)("Default 'meta'","display-a-meta-field-as-block"),value:"meta"},{label:(0,l.__)("ACF - Advanced Custom Fields","display-a-meta-field-as-block"),value:"acf"},{label:(0,l.__)("Dynamic field","display-a-meta-field-as-block"),value:"dynamic"},{label:(0,l.__)("Custom rest field","display-a-meta-field-as-block"),value:"rest_field"}],w={meta:(0,n.createElement)(v.Fragment,null,(0,l.__)("Fields are registered with ","display-a-meta-field-as-block"),(0,n.createElement)(r.ExternalLink,{href:"https://developer.wordpress.org/reference/functions/register_meta/"},"register_meta"),(0,l.__)(" and 'show_in_rest' setting is enable.","display-a-meta-field-as-block")),acf:(0,n.cr