| 1 |
( function () { |
| 2 |
var el = wp.element.createElement; |
| 3 |
var Fragment = wp.element.Fragment; |
| 4 |
var useState = wp.element.useState; |
| 5 |
var __ = wp.i18n.__; |
| 6 |
var registerBlockType = wp.blocks.registerBlockType; |
| 7 |
var InspectorControls = wp.blockEditor.InspectorControls; |
| 8 |
var RichText = wp.blockEditor.RichText; |
| 9 |
var useBlockProps = wp.blockEditor.useBlockProps; |
| 10 |
var PanelBody = wp.components.PanelBody; |
| 11 |
var Button = wp.components.Button; |
| 12 |
var ToggleControl = wp.components.ToggleControl; |
| 13 |
var RangeControl = wp.components.RangeControl; |
| 14 |
var SelectControl = wp.components.SelectControl; |
| 15 |
var TextControl = wp.components.TextControl; |
| 16 |
var ColorPicker = wp.components.ColorPicker; |
| 17 |
var Popover = wp.components.Popover; |
| 18 |
var IP = function () { return window.bkbgIconPicker; }; |
| 19 |
|
| 20 |
function getTypographyControl() { |
| 21 |
return (typeof window.bkbgTypographyControl !== 'undefined') ? window.bkbgTypographyControl : null; |
| 22 |
} |
| 23 |
function getTypoCssVars() { |
| 24 |
return (typeof window.bkbgTypoCssVars !== 'undefined') ? window.bkbgTypoCssVars : function () { return {}; }; |
| 25 |
} |
| 26 |
function _tv(typoObj, prefix) { return getTypoCssVars()(typoObj || {}, prefix); } |
| 27 |
|
| 28 |
var LAYOUT_OPTIONS = [ |
| 29 |
{ label: __('Info left, form right', 'blockenberg'), value: 'info-left' }, |
| 30 |
{ label: __('Info right, form left', 'blockenberg'), value: 'info-right' }, |
| 31 |
{ label: __('Stacked (info top)', 'blockenberg'), value: 'stacked' }, |
| 32 |
]; |
| 33 |
|
| 34 |
function makeId() { return 'cs' + Math.random().toString(36).substr(2, 6); } |
| 35 |
|
| 36 |
function buildWrapStyle(a) { |
| 37 |
return Object.assign({ |
| 38 |
'--bkbg-cs-accent': a.accentColor, |
| 39 |
'--bkbg-cs-title-color': a.titleColor, |
| 40 |
'--bkbg-cs-subtitle-color':a.subtitleColor, |
| 41 |
'--bkbg-cs-card-bg': a.cardBg, |
| 42 |
'--bkbg-cs-icon-bg': a.cardIconBg, |
| 43 |
'--bkbg-cs-lbl-color': a.cardLabelColor, |
| 44 |
'--bkbg-cs-val-color': a.cardValueColor, |
| 45 |
'--bkbg-cs-form-bg': a.formBg, |
| 46 |
'--bkbg-cs-field-bg': a.fieldBg, |
| 47 |
'--bkbg-cs-field-border': a.fieldBorderColor, |
| 48 |
'--bkbg-cs-btn-bg': a.btnBg, |
| 49 |
'--bkbg-cs-btn-color': a.btnColor, |
| 50 |
'--bkbg-cs-card-radius': a.cardRadius + 'px', |
| 51 |
'--bkbg-cs-form-radius': a.formRadius + 'px', |
| 52 |
'--bkbg-cs-field-radius': a.fieldRadius + 'px', |
| 53 |
'--bkbg-cs-btn-radius': a.btnRadius + 'px', |
| 54 |
'--bkbg-cs-title-size': a.titleSize + 'px', |
| 55 |
'--bkbg-cs-subtitle-size': a.subtitleSize + 'px', |
| 56 |
'--bkbg-cs-icon-size': a.iconSize + 'px', |
| 57 |
paddingTop: a.paddingTop + 'px', |
| 58 |
paddingBottom: a.paddingBottom + 'px', |
| 59 |
backgroundColor: a.bgColor || undefined, |
| 60 |
}, _tv(a.typoTitle, '--bkcs-title-'), _tv(a.typoSubtitle, '--bkcs-sub-')); |
| 61 |
} |
| 62 |
|
| 63 |
function renderColorControl(key, label, value, onChange, openKey, setOpenKey) { |
| 64 |
var isOpen = openKey === key; |
| 65 |
return el('div', { key: key, style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '4px 0', gap: '8px' } }, |
| 66 |
el('span', { style: { fontSize: '12px', color: '#1e1e1e', flex: 1, lineHeight: 1.4 } }, label), |
| 67 |
el('div', { style: { position: 'relative', flexShrink: 0 } }, |
| 68 |
el('button', { type: 'button', title: value || 'default', onClick: function () { setOpenKey(isOpen ? null : key); }, |
| 69 |
style: { width: '28px', height: '28px', borderRadius: '4px', border: isOpen ? '2px solid #007cba' : '2px solid #ddd', cursor: 'pointer', padding: 0, background: value || '#cccccc' } |
| 70 |
}), |
| 71 |
isOpen && el(Popover, { position: 'bottom left', onClose: function () { setOpenKey(null); } }, |
| 72 |
el('div', { style: { padding: '8px' } }, |
| 73 |
el(ColorPicker, { color: value, enableAlpha: true, onChange: onChange }) |
| 74 |
) |
| 75 |
) |
| 76 |
) |
| 77 |
); |
| 78 |
} |
| 79 |
|
| 80 |
/* ── Info card ──────────────────────────────────────────────────────── */ |
| 81 |
function InfoCard(props) { |
| 82 |
var card = props.card; |
| 83 |
var a = props.a; |
| 84 |
return el('div', { className: 'bkbg-cs-info-card', style: { display: 'flex', alignItems: 'flex-start', gap: '14px', background: 'var(--bkbg-cs-card-bg)', borderRadius: 'var(--bkbg-cs-card-radius)', padding: '16px 20px' } }, |
| 85 |
el('div', { style: { width: a.iconSize + 'px', height: a.iconSize + 'px', borderRadius: '50%', background: 'var(--bkbg-cs-icon-bg)', display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: Math.round(a.iconSize * 0.55) + 'px', flexShrink: 0 } }, |
| 86 |
(card.iconType || 'custom-char') !== 'custom-char' ? IP().buildEditorIcon(card.iconType, card.icon, card.iconDashicon, card.iconImageUrl, card.iconDashiconColor) : card.icon |
| 87 |
), |
| 88 |
el('div', null, |
| 89 |
el('p', { style: { fontSize: '11px', fontWeight: 700, textTransform: 'uppercase', letterSpacing: '0.07em', color: 'var(--bkbg-cs-lbl-color)', margin: '0 0 3px' } }, card.label), |
| 90 |
el('p', { style: { fontSize: '14px', color: 'var(--bkbg-cs-val-color)', margin: 0, lineHeight: 1.5 } }, card.value) |
| 91 |
) |
| 92 |
); |
| 93 |
} |
| 94 |
|
| 95 |
/* ── Contact form preview ────────────────────────────────────────────── */ |
| 96 |
function FormPreview(props) { |
| 97 |
var a = props.a; |
| 98 |
var fieldStyle = { width: '100%', background: 'var(--bkbg-cs-field-bg)', border: '1.5px solid var(--bkbg-cs-field-border)', borderRadius: 'var(--bkbg-cs-field-radius)', padding: '10px 14px', fontSize: a.fieldSize + 'px', color: '#6b7280', boxSizing: 'border-box', display: 'block', fontFamily: 'inherit', outline: 'none' }; |
| 99 |
var labelStyle = { fontSize: a.labelSize + 'px', fontWeight: 600, color: 'var(--bkbg-cs-lbl-color)', display: 'block', marginBottom: '6px' }; |
| 100 |
var rowStyle = { marginBottom: '16px' }; |
| 101 |
|
| 102 |
return el('div', { className: 'bkbg-cs-form-preview', style: { background: 'var(--bkbg-cs-form-bg)', borderRadius: 'var(--bkbg-cs-form-radius)', padding: '32px' } }, |
| 103 |
el('div', { style: { display: 'grid', gridTemplateColumns: a.showName ? '1fr 1fr' : '1fr', gap: '0 16px' } }, |
| 104 |
a.showName && el('div', { style: rowStyle }, |
| 105 |
el('label', { style: labelStyle }, a.labelName), |
| 106 |
el('input', { type: 'text', placeholder: a.labelName, style: fieldStyle, readOnly: true }) |
| 107 |
), |
| 108 |
el('div', { style: rowStyle }, |
| 109 |
el('label', { style: labelStyle }, a.labelEmail), |
| 110 |
el('input', { type: 'email', placeholder: a.labelEmail, style: fieldStyle, readOnly: true }) |
| 111 |
) |
| 112 |
), |
| 113 |
a.showPhone && el('div', { style: rowStyle }, |
| 114 |
el('label', { style: labelStyle }, a.labelPhone), |
| 115 |
el('input', { type: 'tel', placeholder: a.labelPhone, style: Object.assign({}, fieldStyle), readOnly: true }) |
| 116 |
), |
| 117 |
a.showSubject && el('div', { style: rowStyle }, |
| 118 |
el('label', { style: labelStyle }, a.labelSubject), |
| 119 |
el('input', { type: 'text', placeholder: a.labelSubject, style: Object.assign({}, fieldStyle), readOnly: true }) |
| 120 |
), |
| 121 |
el('div', { style: rowStyle }, |
| 122 |
el('label', { style: labelStyle }, a.labelMessage), |
| 123 |
el('textarea', { rows: 4, placeholder: a.labelMessage, style: Object.assign({}, fieldStyle, { resize: 'vertical' }), readOnly: true }) |
| 124 |
), |
| 125 |
el('button', { type: 'button', style: { background: 'var(--bkbg-cs-btn-bg)', color: 'var(--bkbg-cs-btn-color)', border: 'none', borderRadius: 'var(--bkbg-cs-btn-radius)', padding: '13px 32px', fontSize: '15px', fontWeight: 700, cursor: 'pointer', width: '100%' } }, a.submitLabel) |
| 126 |
); |
| 127 |
} |
| 128 |
|
| 129 |
registerBlockType('blockenberg/contact-section', { |
| 130 |
title: __('Contact Section', 'blockenberg'), |
| 131 |
icon: 'email-alt', |
| 132 |
category: 'bkbg-business', |
| 133 |
|
| 134 |
edit: function (props) { |
| 135 |
var a = props.attributes; |
| 136 |
var setAttributes = props.setAttributes; |
| 137 |
var openColorKeyState = useState(null); |
| 138 |
var openColorKey = openColorKeyState[0]; |
| 139 |
var setOpenColorKey = openColorKeyState[1]; |
| 140 |
var blockProps = useBlockProps({ style: buildWrapStyle(a) }); |
| 141 |
|
| 142 |
function cc(key, label, attrKey) { |
| 143 |
return renderColorControl(key, label, a[attrKey], function (val) { |
| 144 |
var upd = {}; upd[attrKey] = val; setAttributes(upd); |
| 145 |
}, openColorKey, setOpenColorKey); |
| 146 |
} |
| 147 |
function updateCard(id, key, val) { |
| 148 |
setAttributes({ infoCards: a.infoCards.map(function (c) { if (c.id !== id) return c; var u = Object.assign({}, c); u[key] = val; return u; }) }); |
| 149 |
} |
| 150 |
function addCard() { |
| 151 |
setAttributes({ infoCards: a.infoCards.concat([{ id: makeId(), icon: '📌', iconType: 'custom-char', iconDashicon: '', iconImageUrl: '', label: 'New Contact', value: 'Details here' }]) }); |
| 152 |
} |
| 153 |
function removeCard(id) { |
| 154 |
if (a.infoCards.length <= 1) return; |
| 155 |
setAttributes({ infoCards: a.infoCards.filter(function (c) { return c.id !== id; }) }); |
| 156 |
} |
| 157 |
|
| 158 |
var isLeft = a.layout === 'info-left'; |
| 159 |
var isStacked = a.layout === 'stacked'; |
| 160 |
|
| 161 |
var infoCol = a.showInfoCards ? el('div', { className: 'bkbg-cs-info-col', style: { display: 'flex', flexDirection: 'column', gap: a.cardGap + 'px', flex: '0 0 auto', minWidth: '280px' } }, |
| 162 |
a.showTitle && el('div', null, |
| 163 |
el(RichText, { tagName: 'h2', value: a.sectionTitle, onChange: function (v) { setAttributes({ sectionTitle: v }); }, placeholder: __('Contact title…', 'blockenberg'), className: 'bkbg-cs-title', style: { color: a.titleColor, margin: '0 0 10px' } }), |
| 164 |
el(RichText, { tagName: 'p', value: a.sectionSubtitle, onChange: function (v) { setAttributes({ sectionSubtitle: v }); }, placeholder: __('Subtitle…', 'blockenberg'), className: 'bkbg-cs-subtitle', style: { color: a.subtitleColor, margin: 0 } }) |
| 165 |
), |
| 166 |
a.infoCards.map(function (card) { return el(InfoCard, { key: card.id, card: card, a: a }); }), |
| 167 |
a.showMap && a.mapEmbedUrl && el('div', { style: { borderRadius: a.cardRadius + 'px', overflow: 'hidden', marginTop: '8px' } }, |
| 168 |
el('iframe', { src: a.mapEmbedUrl, width: '100%', height: a.mapHeight, style: { border: 0, display: 'block' }, loading: 'lazy' }) |
| 169 |
) |
| 170 |
) : null; |
| 171 |
|
| 172 |
var formCol = a.showForm ? el('div', { className: 'bkbg-cs-form-col', style: { flex: '1 1 0', minWidth: 0 } }, |
| 173 |
el(FormPreview, { a: a }) |
| 174 |
) : null; |
| 175 |
|
| 176 |
var inner = isStacked |
| 177 |
? el('div', { style: { display: 'flex', flexDirection: 'column', gap: '32px' } }, infoCol, formCol) |
| 178 |
: el('div', { style: { display: 'flex', flexDirection: isLeft ? 'row' : 'row-reverse', gap: '40px', alignItems: 'flex-start', flexWrap: 'wrap' } }, infoCol, formCol); |
| 179 |
|
| 180 |
return el(Fragment, null, |
| 181 |
el(InspectorControls, null, |
| 182 |
el(PanelBody, { title: __('Layout', 'blockenberg'), initialOpen: true }, |
| 183 |
el(SelectControl, { label: __('Layout', 'blockenberg'), value: a.layout, options: LAYOUT_OPTIONS, onChange: function (v) { setAttributes({ layout: v }); } }), |
| 184 |
el(ToggleControl, { label: __('Show title & subtitle', 'blockenberg'), checked: a.showTitle, onChange: function (v) { setAttributes({ showTitle: v }); }, __nextHasNoMarginBottom: true }), |
| 185 |
el(ToggleControl, { label: __('Show info cards', 'blockenberg'), checked: a.showInfoCards, onChange: function (v) { setAttributes({ showInfoCards: v }); }, __nextHasNoMarginBottom: true }), |
| 186 |
el(ToggleControl, { label: __('Show contact form', 'blockenberg'), checked: a.showForm, onChange: function (v) { setAttributes({ showForm: v }); }, __nextHasNoMarginBottom: true }), |
| 187 |
el(ToggleControl, { label: __('Show embedded map', 'blockenberg'), checked: a.showMap, onChange: function (v) { setAttributes({ showMap: v }); }, __nextHasNoMarginBottom: true }), |
| 188 |
a.showMap && el(TextControl, { label: __('Map embed URL', 'blockenberg'), value: a.mapEmbedUrl, help: __('Google Maps embed URL (share → embed)', 'blockenberg'), onChange: function (v) { setAttributes({ mapEmbedUrl: v }); } }), |
| 189 |
a.showMap && el(RangeControl, { label: __('Map height (px)', 'blockenberg'), value: a.mapHeight, min: 160, max: 480, onChange: function (v) { setAttributes({ mapHeight: v }); } }) |
| 190 |
), |
| 191 |
el(PanelBody, { title: __('Form Fields', 'blockenberg'), initialOpen: false }, |
| 192 |
el(ToggleControl, { label: __('Name field', 'blockenberg'), checked: a.showName, onChange: function (v) { setAttributes({ showName: v }); }, __nextHasNoMarginBottom: true }), |
| 193 |
el(ToggleControl, { label: __('Phone field', 'blockenberg'), checked: a.showPhone, onChange: function (v) { setAttributes({ showPhone: v }); }, __nextHasNoMarginBottom: true }), |
| 194 |
el(ToggleControl, { label: __('Subject field', 'blockenberg'), checked: a.showSubject, onChange: function (v) { setAttributes({ showSubject: v }); }, __nextHasNoMarginBottom: true }), |
| 195 |
el(TextControl, { label: __('Submit button label', 'blockenberg'), value: a.submitLabel, onChange: function (v) { setAttributes({ submitLabel: v }); } }), |
| 196 |
el(TextControl, { label: __('Recipient email', 'blockenberg'), value: a.recipientEmail, type: 'email', placeholder: 'hello@example.com', onChange: function (v) { setAttributes({ recipientEmail: v }); } }), |
| 197 |
el(TextControl, { label: __('Success message', 'blockenberg'), value: a.successMessage, onChange: function (v) { setAttributes({ successMessage: v }); } }) |
| 198 |
), |
| 199 |
el(PanelBody, { title: __('Typography', 'blockenberg'), initialOpen: false }, |
| 200 |
(function () { |
| 201 |
var TC = getTypographyControl(); |
| 202 |
if (!TC) return el('p', { style: { color: '#999', fontSize: '12px', padding: '8px 0' } }, __('Typography control loading…', 'blockenberg')); |
| 203 |
return el(Fragment, {}, |
| 204 |
el(TC, { |
| 205 |
label: __('Title', 'blockenberg'), |
| 206 |
value: a.typoTitle || {}, |
| 207 |
onChange: function (v) { setAttributes({ typoTitle: v }); } |
| 208 |
}), |
| 209 |
el(TC, { |
| 210 |
label: __('Subtitle', 'blockenberg'), |
| 211 |
value: a.typoSubtitle || {}, |
| 212 |
onChange: function (v) { setAttributes({ typoSubtitle: v }); } |
| 213 |
}) |
| 214 |
); |
| 215 |
})(), |
| 216 |
el(RangeControl, { label: __('Icon size (px)', 'blockenberg'), value: a.iconSize, min: 28, max: 64, onChange: function (v) { setAttributes({ iconSize: v }); } }), |
| 217 |
el(RangeControl, { label: __('Field size (px)', 'blockenberg'), value: a.fieldSize, min: 12, max: 18, onChange: function (v) { setAttributes({ fieldSize: v }); } }), |
| 218 |
el(RangeControl, { label: __('Label size (px)', 'blockenberg'), value: a.labelSize, min: 10, max: 16, onChange: function (v) { setAttributes({ labelSize: v }); } }) |
| 219 |
), |
| 220 |
el(PanelBody, { title: __('Radii', 'blockenberg'), initialOpen: false }, |
| 221 |
el(RangeControl, { label: __('Card radius (px)', 'blockenberg'), value: a.cardRadius, min: 0, max: 32, onChange: function (v) { setAttributes({ cardRadius: v }); } }), |
| 222 |
el(RangeControl, { label: __('Card gap (px)', 'blockenberg'), value: a.cardGap, min: 8, max: 32, onChange: function (v) { setAttributes({ cardGap: v }); } }), |
| 223 |
el(RangeControl, { label: __('Form radius (px)', 'blockenberg'), value: a.formRadius, min: 0, max: 32, onChange: function (v) { setAttributes({ formRadius: v }); } }), |
| 224 |
el(RangeControl, { label: __('Field radius (px)', 'blockenberg'), value: a.fieldRadius, min: 0, max: 20, onChange: function (v) { setAttributes({ fieldRadius: v }); } }), |
| 225 |
el(RangeControl, { label: __('Button radius (px)', 'blockenberg'), value: a.btnRadius, min: 0, max: 99, onChange: function (v) { setAttributes({ btnRadius: v }); } }) |
| 226 |
), |
| 227 |
el(PanelBody, { title: __('Colors', 'blockenberg'), initialOpen: false }, |
| 228 |
cc('accentColor', __('Accent', 'blockenberg'), 'accentColor'), |
| 229 |
cc('titleColor', __('Title', 'blockenberg'), 'titleColor'), |
| 230 |
cc('subtitleColor', __('Subtitle', 'blockenberg'), 'subtitleColor'), |
| 231 |
cc('cardBg', __('Info card background','blockenberg'), 'cardBg'), |
| 232 |
cc('cardIconBg', __('Icon background', 'blockenberg'), 'cardIconBg'), |
| 233 |
cc('cardLabelColor', __('Info label', 'blockenberg'), 'cardLabelColor'), |
| 234 |
cc('cardValueColor', __('Info value', 'blockenberg'), 'cardValueColor'), |
| 235 |
cc('formBg', __('Form background', 'blockenberg'), 'formBg'), |
| 236 |
cc('fieldBg', __('Field background', 'blockenberg'), 'fieldBg'), |
| 237 |
cc('fieldBorderColor',__('Field border', 'blockenberg'), 'fieldBorderColor'), |
| 238 |
cc('btnBg', __('Button background', 'blockenberg'), 'btnBg'), |
| 239 |
cc('btnColor', __('Button text', 'blockenberg'), 'btnColor'), |
| 240 |
cc('bgColor', __('Section background', 'blockenberg'), 'bgColor') |
| 241 |
), |
| 242 |
el(PanelBody, { title: __('Spacing', 'blockenberg'), initialOpen: false }, |
| 243 |
el(RangeControl, { label: __('Padding top (px)', 'blockenberg'), value: a.paddingTop, min: 0, max: 200, onChange: function (v) { setAttributes({ paddingTop: v }); } }), |
| 244 |
el(RangeControl, { label: __('Padding bottom (px)', 'blockenberg'), value: a.paddingBottom, min: 0, max: 200, onChange: function (v) { setAttributes({ paddingBottom: v }); } }) |
| 245 |
), |
| 246 |
el(PanelBody, { title: __('Info Cards', 'blockenberg'), initialOpen: false }, |
| 247 |
a.infoCards.map(function (card) { |
| 248 |
return el(PanelBody, { key: card.id, title: card.label || __('Card', 'blockenberg'), initialOpen: false }, |
| 249 |
el(IP().IconPickerControl, { |
| 250 |
iconType: card.iconType, customChar: card.icon, dashicon: card.iconDashicon, imageUrl: card.iconImageUrl, |
| 251 |
onChangeType: function (v) { updateCard(card.id, 'iconType', v); }, |
| 252 |
onChangeChar: function (v) { updateCard(card.id, 'icon', v); }, |
| 253 |
onChangeDashicon: function (v) { updateCard(card.id, 'iconDashicon', v); }, |
| 254 |
onChangeImageUrl: function (v) { updateCard(card.id, 'iconImageUrl', v); } |
| 255 |
}), |
| 256 |
el(TextControl, { label: __('Label', 'blockenberg'), value: card.label, onChange: function (v) { updateCard(card.id, 'label', v); } }), |
| 257 |
el(TextControl, { label: __('Value', 'blockenberg'), value: card.value, onChange: function (v) { updateCard(card.id, 'value', v); } }), |
| 258 |
a.infoCards.length > 1 && el(Button, { onClick: function () { removeCard(card.id); }, variant: 'tertiary', isDestructive: true, size: 'compact' }, __('Remove', 'blockenberg')) |
| 259 |
); |
| 260 |
}), |
| 261 |
el(Button, { onClick: addCard, variant: 'primary', style: { marginTop: '8px' } }, __('+ Add Card', 'blockenberg')) |
| 262 |
) |
| 263 |
), |
| 264 |
|
| 265 |
el('div', blockProps, inner) |
| 266 |
); |
| 267 |
}, |
| 268 |
|
| 269 |
save: function (props) { |
| 270 |
var a = props.attributes; |
| 271 |
var isLeft = a.layout === 'info-left'; |
| 272 |
var isStacked = a.layout === 'stacked'; |
| 273 |
|
| 274 |
var infoCol = a.showInfoCards ? el('div', { className: 'bkbg-cs-info-col' }, |
| 275 |
a.showTitle && el('div', { className: 'bkbg-cs-header' }, |
| 276 |
el(RichText.Content, { tagName: 'h2', value: a.sectionTitle, className: 'bkbg-cs-title', style: { color: a.titleColor } }), |
| 277 |
el(RichText.Content, { tagName: 'p', value: a.sectionSubtitle, className: 'bkbg-cs-subtitle', style: { color: a.subtitleColor } }) |
| 278 |
), |
| 279 |
a.infoCards.map(function (card) { |
| 280 |
return el('div', { key: card.id, className: 'bkbg-cs-info-card' }, |
| 281 |
el('div', { className: 'bkbg-cs-info-icon', style: { width: a.iconSize + 'px', height: a.iconSize + 'px', fontSize: Math.round(a.iconSize * 0.55) + 'px' } }, |
| 282 |
(card.iconType || 'custom-char') !== 'custom-char' ? IP().buildSaveIcon(card.iconType, card.icon, card.iconDashicon, card.iconImageUrl, card.iconDashiconColor) : card.icon |
| 283 |
), |
| 284 |
el('div', { className: 'bkbg-cs-info-text' }, |
| 285 |
el('p', { className: 'bkbg-cs-info-label' }, card.label), |
| 286 |
el('p', { className: 'bkbg-cs-info-value' }, card.value) |
| 287 |
) |
| 288 |
); |
| 289 |
}), |
| 290 |
a.showMap && a.mapEmbedUrl && el('div', { className: 'bkbg-cs-map', style: { borderRadius: a.cardRadius + 'px', overflow: 'hidden' } }, |
| 291 |
el('iframe', { src: a.mapEmbedUrl, width: '100%', height: a.mapHeight, style: { border: 0, display: 'block' }, loading: 'lazy', title: __('Map', 'blockenberg') }) |
| 292 |
) |
| 293 |
) : null; |
| 294 |
|
| 295 |
var formCol = a.showForm ? el('div', { className: 'bkbg-cs-form-col' }, |
| 296 |
el('form', { className: 'bkbg-cs-form', 'data-recipient': a.recipientEmail, 'data-success': a.successMessage, style: { background: 'var(--bkbg-cs-form-bg)', borderRadius: 'var(--bkbg-cs-form-radius)', padding: '32px' } }, |
| 297 |
el('div', { className: 'bkbg-cs-form-row' }, |
| 298 |
a.showName && el('div', { className: 'bkbg-cs-field' }, |
| 299 |
el('label', null, a.labelName), |
| 300 |
el('input', { type: 'text', name: 'contact_name', placeholder: a.labelName, required: true }) |
| 301 |
), |
| 302 |
el('div', { className: 'bkbg-cs-field' }, |
| 303 |
el('label', null, a.labelEmail), |
| 304 |
el('input', { type: 'email', name: 'contact_email', placeholder: a.labelEmail, required: true }) |
| 305 |
) |
| 306 |
), |
| 307 |
a.showPhone && el('div', { className: 'bkbg-cs-field' }, |
| 308 |
el('label', null, a.labelPhone), |
| 309 |
el('input', { type: 'tel', name: 'contact_phone', placeholder: a.labelPhone }) |
| 310 |
), |
| 311 |
a.showSubject && el('div', { className: 'bkbg-cs-field' }, |
| 312 |
el('label', null, a.labelSubject), |
| 313 |
el('input', { type: 'text', name: 'contact_subject', placeholder: a.labelSubject }) |
| 314 |
), |
| 315 |
el('div', { className: 'bkbg-cs-field' }, |
| 316 |
el('label', null, a.labelMessage), |
| 317 |
el('textarea', { name: 'contact_message', rows: 5, placeholder: a.labelMessage, required: true }) |
| 318 |
), |
| 319 |
el('button', { type: 'submit', className: 'bkbg-cs-submit' }, a.submitLabel), |
| 320 |
el('div', { className: 'bkbg-cs-form-msg', 'aria-live': 'polite' }) |
| 321 |
) |
| 322 |
) : null; |
| 323 |
|
| 324 |
var innerClass = isStacked ? 'bkbg-cs-inner bkbg-cs--stacked' : 'bkbg-cs-inner bkbg-cs--' + (isLeft ? 'info-left' : 'info-right'); |
| 325 |
|
| 326 |
return el('div', wp.blockEditor.useBlockProps.save({ className: 'bkbg-cs-wrapper', style: buildWrapStyle(a) }), |
| 327 |
el('div', { className: innerClass }, infoCol, formCol) |
| 328 |
); |
| 329 |
} |
| 330 |
}); |
| 331 |
}() ); |
| 332 |
|