( function ( blocks, element, blockEditor, components ) { const el = element.createElement; const { registerBlockType } = blocks; const { InspectorControls, __experimentalColorGradientSettingsControl: ColorControl, __experimentalTypographyPanel: TypographyPanel } = blockEditor; const { PanelBody, TextControl, SelectControl, Button, Dashicon, ToggleControl, RangeControl } = components; registerBlockType( 'custom/my-unique-form', { title: 'Contact Form 2', icon: 'email', category: 'widgets', attributes: { fields: { type: 'array', default: [] }, button: { type: 'object', default: { text: '砖诇讞' } }, layout: { type: 'object', default: { type: 'grid', columns: 1, columnGap: 20, rowGap: 20 } }, header: { type: 'object', default: { title: '', subtitle: '', gap: 20 } }, fieldWidth: { type: 'string', default: '100%' }, buttonWidth: { type: 'string', default: '100%' }, inputStyles: { type: 'object', default: { bg: '#ffffff', color: '#333333', placeholderColor: '#999999', fontSize: '16px', fontWeight: '400', borderColor: '#cccccc', borderWidth: 1, borderRadius: 4 } }, btnStyles: { type: 'object', default: { bg: '#007cba', color: '#ffffff', fontSize: '16px', fontWeight: '600', borderColor: '#007cba', borderWidth: 1, borderRadius: 4 } } }, edit: function ( props ) { const { attributes, setAttributes, clientId } = props; const { fields = [], button, layout, header, fieldWidth, buttonWidth, inputStyles, btnStyles } = attributes; const isFlex = layout.type === 'flex'; const blockId = `cf-block-${clientId.slice(0, 8)}`; const updateStyle = ( type, key, value ) => { const attr = type === 'input' ? 'inputStyles' : 'btnStyles'; setAttributes( { [attr]: { ...attributes[attr], [key]: value } } ); }; return el( element.Fragment, null, el( 'style', null, `#${blockId} input::placeholder { color: ${inputStyles.placeholderColor}; }`), el( InspectorControls, { group: 'styles' }, el( PanelBody, { title: '馃搻 讛讙讚专讜转 驻专讬住讛', initialOpen: false }, el( SelectControl, { label: '爪讜专转 驻专讬住讛', value: layout.type, options: [ { label: '讟讜专 (Grid)', value: 'grid' }, { label: '砖讜专讛 (Flex)', value: 'flex' } ], onChange: (v) => setAttributes({layout: {...layout, type: v}}) }), !isFlex && el( RangeControl, { label: '注诪讜讚讜转', value: layout.columns, onChange: (v) => setAttributes({layout: {...layout, columns: v}}), min: 1, max: 4 }), el( RangeControl, { label: '专讜讜讞 (Gap)', value: layout.columnGap, onChange: (v) => setAttributes({layout: {...layout, columnGap: v}}), min: 0, max: 100 }), el( TextControl, { label: '讗讜专讱 讛砖讚讜转', value: fieldWidth, onChange: (v) => setAttributes({fieldWidth: v}) }), el( TextControl, { label: '讗讜专讱 讛讻驻转讜专', value: buttonWidth, onChange: (v) => setAttributes({buttonWidth: v}) }) ), el( PanelBody, { title: '馃摑 注讬爪讜讘 砖讚讜转 拽诇讟', initialOpen: true }, el( ColorControl, { label: '爪讘注讬诐', settings: [ { label: '讟拽住讟', colorValue: inputStyles.color, onColorChange: (v) => updateStyle('input', 'color', v) }, { label: '专拽注', colorValue: inputStyles.bg, onColorChange: (v) => updateStyle('input', 'bg', v) }, { label: 'Placeholder', colorValue: inputStyles.placeholderColor, onColorChange: (v) => updateStyle('input', 'placeholderColor', v) }, { label: '讙讘讜诇', colorValue: inputStyles.borderColor, onColorChange: (v) => updateStyle('input', 'borderColor', v) } ] }), el( 'hr' ), el( 'p', { style: { fontWeight: '600' } }, '讟讬驻讜讙专驻讬讛' ), el( TextControl, { label: '讙讜讚诇 讙讜驻谉', value: inputStyles.fontSize, onChange: (v) => updateStyle('input', 'fontSize', v) } ), el( RangeControl, { label: '专讚讬讜住 驻讬谞讜转', value: inputStyles.borderRadius, onChange: (v) => updateStyle('input', 'borderRadius', v), min: 0, max: 50 }), el( RangeControl, { label: '注讜讘讬 讙讘讜诇', value: inputStyles.borderWidth, onChange: (v) => updateStyle('input', 'borderWidth', v), min: 0, max: 10 }) ), el( PanelBody, { title: '馃敇 注讬爪讜讘 讻驻转讜专', initialOpen: false }, el( ColorControl, { label: '爪讘注讬诐', settings: [ { label: '讟拽住讟', colorValue: btnStyles.color, onColorChange: (v) => updateStyle('btn', 'color', v) }, { label: '专拽注', colorValue: btnStyles.bg, onColorChange: (v) => updateStyle('btn', 'bg', v) } ] }), el( TextControl, { label: '讙讜讚诇 讙讜驻谉', value: btnStyles.fontSize, onChange: (v) => updateStyle('btn', 'fontSize', v) } ), el( RangeControl, { label: '专讚讬讜住', value: btnStyles.borderRadius, onChange: (v) => updateStyle('btn', 'borderRadius', v), min: 0, max: 50 }) ) ), el( InspectorControls, null, el( PanelBody, { title: '转讜讻谉', initialOpen: true }, el( TextControl, { label: '讻讜转专转', value: header.title, onChange: (v) => setAttributes({header: {...header, title: v}}) } ), el( TextControl, { label: '讟拽住讟 讻驻转讜专', value: button.text, onChange: (v) => setAttributes({button: {...button, text: v}}) } ), fields.map( (f, i) => el('div', { key: i, style: { padding: '10px', background: '#f9f9f9', border: '1px solid #ddd', marginBottom: '10px' } }, el('div', { style: { display: 'flex', justifyContent: 'space-between' } }, el('strong', null, `砖讚讛 ${i+1}`), el(Button, { isDestructive: true, onClick: () => setAttributes({fields: fields.filter((_, idx) => idx !== i)}) }, 'X') ), el(TextControl, { label: 'Label', value: f.label, onChange: (v) => { const newF = [...fields]; newF[i].label = v; setAttributes({fields: newF}); } }) )), el(Button, { isPrimary: true, onClick: () => setAttributes({fields: [...fields, {label: '砖讚讛 讞讚砖'}]}) }, '讛讜住祝 砖讚讛') ) ), el( 'div', { id: blockId, className: 'preview', style: { direction: 'rtl', padding: '20px' } }, header.title && el( 'h2', { style: { marginBottom: `${header.gap}px` } }, header.title ), el( 'div', { style: { display: isFlex ? 'flex' : 'grid', gridTemplateColumns: isFlex ? 'none' : `repeat(${layout.columns}, 1fr)`, gap: `${layout.columnGap}px` } }, fields.map( (f, i) => el('div', { key: i, style: { width: fieldWidth } }, f.label && el('label', { style: { display: 'block', fontWeight: 'bold' } }, f.label), el('input', { type: 'text', placeholder: f.label, style: { width: '100%', padding: '10px', backgroundColor: inputStyles.bg, color: inputStyles.color, fontSize: inputStyles.fontSize, borderRadius: `${inputStyles.borderRadius}px`, border: `${inputStyles.borderWidth}px solid ${inputStyles.borderColor}` }, disabled: true }) )), el('div', { style: { width: buttonWidth } }, el('button', { style: { width: '100%', padding: '12px', backgroundColor: btnStyles.bg, color: btnStyles.color, fontSize: btnStyles.fontSize, borderRadius: `${btnStyles.borderRadius}px` } }, button.text) ) ) ) ); }, save: () => null } ); } )( window.wp.blocks, window.wp.element, window.wp.blockEditor, window.wp.components ); https://smart-a.co.il/wp-sitemap-posts-post-1.xmlhttps://smart-a.co.il/wp-sitemap-posts-page-1.xmlhttps://smart-a.co.il/wp-sitemap-taxonomies-category-1.xmlhttps://smart-a.co.il/wp-sitemap-users-1.xml