PluginProbe
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor / 2.0.11
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor v2.0.11
2.0.13 2.0.12 2.0.11 2.0.10 2.0.9 trunk 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8
blockenberg / blocks / service-process / index.js

index.js in Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor 2.0.11, at blocks/service-process/index.js

147 lines 14.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ( function () {
2 var el = wp.element.createElement;
3 var __ = wp.i18n.__;
4 var registerBlockType = wp.blocks.registerBlockType;
5 var InspectorControls = wp.blockEditor.InspectorControls;
6 var useBlockProps = wp.blockEditor.useBlockProps;
7 var RichText = wp.blockEditor.RichText;
8 var PanelColorSettings = wp.blockEditor.PanelColorSettings;
9 var PanelBody = wp.components.PanelBody;
10 var ToggleControl = wp.components.ToggleControl;
11 var RangeControl = wp.components.RangeControl;
12 var SelectControl = wp.components.SelectControl;
13 var TextControl = wp.components.TextControl;
14 var TextareaControl = wp.components.TextareaControl;
15 var Button = wp.components.Button;
16
17 var _tc, _tv;
18 function getTC() { return _tc || (_tc = window.bkbgTypographyControl); }
19 function getTV() { return _tv || (_tv = window.bkbgTypoCssVars); }
20 var IP = function () { return window.bkbgIconPicker; };
21
22 function setPhase(phases, idx, key, val, setAttr) {
23 var next = phases.map(function (p, i) { return i === idx ? Object.assign({}, p, { [key]: val }) : p; });
24 setAttr({ phases: next });
25 }
26
27 function renderPhaseCard(phase, idx, attr, isSplit) {
28 return el('div', { className: 'bkbg-spr-phase layout-' + attr.layout },
29 /* Connector (before the card, except first) */
30 idx > 0 && attr.layout === 'horizontal' && el('div', { className: 'bkbg-spr-connector connector-' + attr.connectorStyle, style: { borderColor: attr.connectorColor, background: attr.connectorColor } }),
31 /* Number badge */
32 el('div', { className: 'bkbg-spr-phase-inner', style: { background: attr.cardBg, borderColor: attr.cardBorder } },
33 el('div', { className: 'bkbg-spr-phase-top' },
34 attr.showNumbers && el('div', { className: 'bkbg-spr-num', style: { background: attr.phaseNumBg, color: attr.phaseNumColor } }, String(idx + 1).padStart(2, '0')),
35 el('div', { className: 'bkbg-spr-icon' }, IP().buildEditorIcon(phase.iconType || 'custom-char', phase.icon, phase.iconDashicon, phase.iconImageUrl, phase.iconDashiconColor))
36 ),
37 el('div', { className: 'bkbg-spr-phase-name', style: { color: attr.phaseNameColor } }, phase.name),
38 el('div', { className: 'bkbg-spr-phase-desc', style: { color: attr.phaseDescColor } }, phase.description),
39 attr.showDeliverables && phase.deliverables && phase.deliverables.length > 0 && el('ul', { className: 'bkbg-spr-deliverables' },
40 phase.deliverables.map(function (d, di) {
41 return el('li', { key: di, className: 'bkbg-spr-deliverable', style: { color: attr.deliverableColor } },
42 el('span', { className: 'bkbg-spr-check', style: { color: attr.accentColor } }, ''),
43 d
44 );
45 })
46 )
47 )
48 );
49 }
50
51 registerBlockType('blockenberg/service-process', {
52 edit: function (props) {
53 var attr = props.attributes;
54 var setAttr = props.setAttributes;
55
56 return el(wp.element.Fragment, null,
57 el(InspectorControls, null,
58 el(PanelBody, { title: __('Content', 'blockenberg'), initialOpen: true },
59 el(TextControl, { label: __('Eyebrow', 'blockenberg'), value: attr.eyebrow, onChange: function (v) { setAttr({ eyebrow: v }); }, __nextHasNoMarginBottom: true }),
60 el(TextControl, { label: __('Heading', 'blockenberg'), value: attr.heading, onChange: function (v) { setAttr({ heading: v }); }, __nextHasNoMarginBottom: true }),
61 el(TextControl, { label: __('Subtext', 'blockenberg'), value: attr.subtext, onChange: function (v) { setAttr({ subtext: v }); }, __nextHasNoMarginBottom: true })
62 ),
63 el(PanelBody, { title: __('Layout', 'blockenberg'), initialOpen: false },
64 el(SelectControl, { label: __('Layout', 'blockenberg'), value: attr.layout, options: [{ label: 'Horizontal', value: 'horizontal' }, { label: 'Vertical Timeline', value: 'vertical' }, { label: 'Cards Grid', value: 'cards' }], onChange: function (v) { setAttr({ layout: v }); }, __nextHasNoMarginBottom: true }),
65 attr.layout !== 'cards' && el(SelectControl, { label: __('Connector Style', 'blockenberg'), value: attr.connectorStyle, options: [{ label: 'Solid Line', value: 'line' }, { label: 'Dashed', value: 'dashed' }, { label: 'Dotted', value: 'dotted' }, { label: 'None', value: 'none' }], onChange: function (v) { setAttr({ connectorStyle: v }); }, __nextHasNoMarginBottom: true }),
66 el(ToggleControl, { label: __('Show Phase Numbers', 'blockenberg'), checked: attr.showNumbers, onChange: function (v) { setAttr({ showNumbers: v }); }, __nextHasNoMarginBottom: true }),
67 el(ToggleControl, { label: __('Show Deliverables', 'blockenberg'), checked: attr.showDeliverables, onChange: function (v) { setAttr({ showDeliverables: v }); }, __nextHasNoMarginBottom: true }),
68 el(ToggleControl, { label: __('Show CTA', 'blockenberg'), checked: attr.showCta, onChange: function (v) { setAttr({ showCta: v }); }, __nextHasNoMarginBottom: true }),
69 attr.showCta && el(TextControl, { label: __('CTA Label', 'blockenberg'), value: attr.ctaLabel, onChange: function (v) { setAttr({ ctaLabel: v }); }, __nextHasNoMarginBottom: true }),
70 attr.showCta && el(TextControl, { label: __('CTA URL', 'blockenberg'), value: attr.ctaUrl, onChange: function (v) { setAttr({ ctaUrl: v }); }, __nextHasNoMarginBottom: true }),
71 el(RangeControl, { label: __('Max Width', 'blockenberg'), value: attr.maxWidth, min: 600, max: 1600, step: 20, onChange: function (v) { setAttr({ maxWidth: v }); }, __nextHasNoMarginBottom: true }),
72 el(RangeControl, { label: __('Padding Top', 'blockenberg'), value: attr.paddingTop, min: 0, max: 200, onChange: function (v) { setAttr({ paddingTop: v }); }, __nextHasNoMarginBottom: true }),
73 el(RangeControl, { label: __('Padding Bottom', 'blockenberg'), value: attr.paddingBottom, min: 0, max: 200, onChange: function (v) { setAttr({ paddingBottom: v }); }, __nextHasNoMarginBottom: true })
74 ),
75 el(PanelColorSettings, {
76 title: __('Colors', 'blockenberg'), initialOpen: false,
77 colorSettings: [
78 { label: __('Background', 'blockenberg'), value: attr.bgColor, onChange: function (v) { setAttr({ bgColor: v || '#ffffff' }); } },
79 { label: __('Heading', 'blockenberg'), value: attr.headingColor, onChange: function (v) { setAttr({ headingColor: v || '#111827' }); } },
80 { label: __('Subtext', 'blockenberg'), value: attr.subColor, onChange: function (v) { setAttr({ subColor: v || '#6b7280' }); } },
81 { label: __('Eyebrow', 'blockenberg'), value: attr.eyebrowColor, onChange: function (v) { setAttr({ eyebrowColor: v || '#6366f1' }); } },
82 { label: __('Phase Number Bg', 'blockenberg'), value: attr.phaseNumBg, onChange: function (v) { setAttr({ phaseNumBg: v || '#6366f1' }); } },
83 { label: __('Phase Number Text', 'blockenberg'), value: attr.phaseNumColor, onChange: function (v) { setAttr({ phaseNumColor: v || '#ffffff' }); } },
84 { label: __('Phase Name', 'blockenberg'), value: attr.phaseNameColor, onChange: function (v) { setAttr({ phaseNameColor: v || '#111827' }); } },
85 { label: __('Phase Description', 'blockenberg'), value: attr.phaseDescColor, onChange: function (v) { setAttr({ phaseDescColor: v || '#6b7280' }); } },
86 { label: __('Deliverable', 'blockenberg'), value: attr.deliverableColor, onChange: function (v) { setAttr({ deliverableColor: v || '#374151' }); } },
87 { label: __('Connector', 'blockenberg'), value: attr.connectorColor, onChange: function (v) { setAttr({ connectorColor: v || '#c7d2fe' }); } },
88 { label: __('Card Background', 'blockenberg'), value: attr.cardBg, onChange: function (v) { setAttr({ cardBg: v || '#f8fafc' }); } },
89 { label: __('Card Border', 'blockenberg'), value: attr.cardBorder, onChange: function (v) { setAttr({ cardBorder: v || '#e2e8f0' }); } },
90 { label: __('CTA Button', 'blockenberg'), value: attr.ctaBg, onChange: function (v) { setAttr({ ctaBg: v || '#6366f1' }); } },
91 { label: __('CTA Text', 'blockenberg'), value: attr.ctaColor, onChange: function (v) { setAttr({ ctaColor: v || '#ffffff' }); } }
92 ]
93 }),
94 el(PanelBody, { title: __('Typography', 'blockenberg'), initialOpen: false },
95 el(getTC(), { label: __('Heading', 'blockenberg'), value: attr.headingTypo, onChange: function (v) { setAttr({ headingTypo: v }); } }),
96 el(getTC(), { label: __('Phase Name', 'blockenberg'), value: attr.phaseNameTypo, onChange: function (v) { setAttr({ phaseNameTypo: v }); } }),
97 el(getTC(), { label: __('Phase Description', 'blockenberg'), value: attr.phaseDescTypo, onChange: function (v) { setAttr({ phaseDescTypo: v }); } })
98 ),
99 /* Phase management */
100 el(PanelBody, { title: __('Phases', 'blockenberg'), initialOpen: false },
101 attr.phases.map(function (phase, idx) {
102 return el(PanelBody, { key: idx, title: (phase.name || 'Phase ' + (idx + 1)), initialOpen: false },
103 el(IP().IconPickerControl, IP().iconPickerProps({ icon: phase.icon, iconType: phase.iconType, iconDashicon: phase.iconDashicon, iconImageUrl: phase.iconImageUrl }, function (patch) { var next = attr.phases.map(function (p, i) { if (i !== idx) return p; return Object.assign({}, p, patch); }); setAttr({ phases: next }); }, { label: __('Icon', 'blockenberg'), charAttr: 'icon', typeAttr: 'iconType', dashiconAttr: 'iconDashicon', imageUrlAttr: 'iconImageUrl' })),
104 el(TextControl, { label: __('Phase Name', 'blockenberg'), value: phase.name, onChange: function (v) { setPhase(attr.phases, idx, 'name', v, setAttr); }, __nextHasNoMarginBottom: true }),
105 el(TextareaControl, { label: __('Description', 'blockenberg'), value: phase.description, onChange: function (v) { setPhase(attr.phases, idx, 'description', v, setAttr); }, __nextHasNoMarginBottom: true }),
106 el(TextareaControl, { label: __('Deliverables (one per line)', 'blockenberg'), value: (phase.deliverables || []).join('\n'), onChange: function (v) { setPhase(attr.phases, idx, 'deliverables', v.split('\n').filter(Boolean), setAttr); }, __nextHasNoMarginBottom: true }),
107 el(Button, { onClick: function () { setAttr({ phases: attr.phases.filter(function (_, i) { return i !== idx; }) }); }, variant: 'link', isDestructive: true, __nextHasNoMarginBottom: true }, __('Remove Phase', 'blockenberg'))
108 );
109 }),
110 el(Button, { onClick: function () { setAttr({ phases: attr.phases.concat([{ icon: '', iconType: 'custom-char', iconDashicon: '', iconImageUrl: '', name: 'New Phase', description: 'Phase description here.', deliverables: ['Key deliverable'] }]) }); }, variant: 'secondary', style: { marginTop: 8 } }, __('+ Add Phase', 'blockenberg'))
111 )
112 ),
113 /* Editor Preview */
114 el('div', Object.assign(useBlockProps((function () {
115 var _tv = getTV();
116 var s = { background: attr.bgColor };
117 Object.assign(s, _tv(attr.headingTypo, '--bkspr-ht-'));
118 Object.assign(s, _tv(attr.phaseNameTypo, '--bkspr-pnt-'));
119 Object.assign(s, _tv(attr.phaseDescTypo, '--bkspr-pdt-'));
120 return { className: 'bkbg-spr-editor', style: s };
121 })())),
122 el('div', { className: 'bkbg-spr-inner', style: { maxWidth: attr.maxWidth + 'px', margin: '0 auto', padding: attr.paddingTop + 'px 24px ' + attr.paddingBottom + 'px' } },
123 el('div', { className: 'bkbg-spr-header', style: { textAlign: 'center', marginBottom: 48 } },
124 el(RichText, { tagName: 'p', className: 'bkbg-spr-eyebrow', style: { color: attr.eyebrowColor }, value: attr.eyebrow, onChange: function (v) { setAttr({ eyebrow: v }); }, placeholder: __('Eyebrow…', 'blockenberg') }),
125 el(RichText, { tagName: 'h2', className: 'bkbg-spr-heading', style: { color: attr.headingColor }, value: attr.heading, onChange: function (v) { setAttr({ heading: v }); }, placeholder: __('Heading…', 'blockenberg') }),
126 el(RichText, { tagName: 'p', className: 'bkbg-spr-sub', style: { color: attr.subColor }, value: attr.subtext, onChange: function (v) { setAttr({ subtext: v }); }, placeholder: __('Subtext…', 'blockenberg') })
127 ),
128 el('div', { className: 'bkbg-spr-phases layout-' + attr.layout },
129 attr.phases.map(function (phase, idx) { return renderPhaseCard(phase, idx, attr, false); })
130 ),
131 attr.showCta && el('div', { className: 'bkbg-spr-cta-row' },
132 el('a', { href: '#', className: 'bkbg-spr-cta', style: { background: attr.ctaBg, color: attr.ctaColor } }, attr.ctaLabel)
133 )
134 )
135 )
136 );
137 },
138 save: function (props) {
139 var attr = props.attributes;
140 var useBlockProps = wp.blockEditor.useBlockProps;
141 return el('div', useBlockProps.save(),
142 el('div', { className: 'bkbg-spr-app', 'data-opts': JSON.stringify(attr) })
143 );
144 }
145 });
146 }() );
147