PluginProbe
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor / 2.0.7
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor v2.0.7
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 / page-list / index.js

index.js in Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor 2.0.7, at blocks/page-list/index.js

427 lines 27.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /* ====================================================
2 Page List Block — editor (index.js)
3 Block: blockenberg/page-list
4 ==================================================== */
5 ( function () {
6 var el = wp.element.createElement;
7 var useState = wp.element.useState;
8 var Fragment = wp.element.Fragment;
9 var registerBlockType = wp.blocks.registerBlockType;
10 var InspectorControls = wp.blockEditor.InspectorControls;
11 var useBlockProps = wp.blockEditor.useBlockProps;
12 var PanelBody = wp.components.PanelBody;
13 var PanelColorSettings = wp.blockEditor.PanelColorSettings;
14 var RangeControl = wp.components.RangeControl;
15 var SelectControl = wp.components.SelectControl;
16 var ToggleControl = wp.components.ToggleControl;
17 var TextControl = wp.components.TextControl;
18 var Button = wp.components.Button;
19 var __ = wp.i18n.__;
20
21 var _tc, _tv;
22 function getTypoControl() { return _tc || (_tc = window.bkbgTypographyControl); }
23 function getTypoCssVars() { return _tv || (_tv = window.bkbgTypoCssVars); }
24 var IP = function () { return window.bkbgIconPicker; };
25
26 /* ── helpers ── */
27 function uid() {
28 return 'pgl-' + Math.random().toString(36).slice(2, 7);
29 }
30
31 function move(arr, from, to) {
32 var a = arr.slice();
33 a.splice(to, 0, a.splice(from, 1)[0]);
34 return a;
35 }
36
37 function buildWrapStyle(attrs) {
38 return {
39 '--bkbg-pgl-cols': attrs.columns,
40 '--bkbg-pgl-gap': attrs.gap + 'px',
41 '--bkbg-pgl-font': attrs.fontSize + 'px',
42 '--bkbg-pgl-weight': attrs.fontWeight,
43 '--bkbg-pgl-desc-font': attrs.descFontSize + 'px',
44 '--bkbg-pgl-icon-size': attrs.iconSize + 'px',
45 '--bkbg-pgl-radius': attrs.borderRadius + 'px',
46 '--bkbg-pgl-pad-v': attrs.itemPaddingV + 'px',
47 '--bkbg-pgl-pad-h': attrs.itemPaddingH + 'px',
48 '--bkbg-pgl-link-color': attrs.linkColor,
49 '--bkbg-pgl-link-hover': attrs.linkColorHover,
50 '--bkbg-pgl-bg': attrs.bgColor,
51 '--bkbg-pgl-bg-hover': attrs.bgColorHover,
52 '--bkbg-pgl-border': attrs.borderColor,
53 '--bkbg-pgl-icon-color': attrs.iconColor,
54 '--bkbg-pgl-desc-color': attrs.descColor,
55 '--bkbg-pgl-chev-color': attrs.chevronColor,
56 '--bkbg-pgl-accent': attrs.accentColor,
57 maxWidth: attrs.maxWidth,
58 };
59 }
60
61 /* ── single list item (editor) ── */
62 function EditorItem(props) {
63 var item = props.item;
64 var depth = props.depth;
65 var showIcons = props.showIcons;
66 var showDesc = props.showDescription;
67 var showChev = props.showChevron;
68 var layout = props.layout;
69
70 var chevron = el('span', { className: 'bkbg-pgl-chevron', 'aria-hidden': 'true' }, '');
71 var iconEl = showIcons ? el('span', { className: 'bkbg-pgl-icon' }, (item.iconType || 'custom-char') !== 'custom-char' ? IP().buildEditorIcon(item.iconType, item.icon, item.iconDashicon, item.iconImageUrl, item.iconDashiconColor) : (item.icon || '📄')) : null;
72 var descEl = showDesc && item.description ? el('span', { className: 'bkbg-pgl-desc' }, item.description) : null;
73
74 var label = el('span', { className: 'bkbg-pgl-label' }, item.title || __('Page title', 'blockenberg'));
75 var inner = el(
76 'span', { className: 'bkbg-pgl-link-inner' },
77 iconEl, el('span', { className: 'bkbg-pgl-text-wrap' }, label, descEl), showChev ? chevron : null
78 );
79 var link = el('a', { className: 'bkbg-pgl-link', href: item.url || '#', onClick: function(e){ e.preventDefault(); } }, inner);
80 var li = el('li', { className: 'bkbg-pgl-item' }, link);
81
82 if (depth >= 2 && item.children && item.children.length) {
83 var subItems = item.children.map(function(child) {
84 var cIcon = showIcons ? el('span', { className: 'bkbg-pgl-icon bkbg-pgl-icon--child' }, (child.iconType || 'custom-char') !== 'custom-char' ? IP().buildEditorIcon(child.iconType, child.icon, child.iconDashicon, child.iconImageUrl, child.iconDashiconColor) : (child.icon || '📄')) : null;
85 var cLabel = el('span', { className: 'bkbg-pgl-label' }, child.title || __('Sub-page', 'blockenberg'));
86 var cInner = el('span', { className: 'bkbg-pgl-link-inner' }, cIcon, el('span', { className: 'bkbg-pgl-text-wrap' }, cLabel));
87 return el('li', { key: child.id, className: 'bkbg-pgl-item bkbg-pgl-item--child' },
88 el('a', { className: 'bkbg-pgl-link bkbg-pgl-link--child', href: child.url || '#', onClick: function(e){ e.preventDefault(); } }, cInner)
89 );
90 });
91 return el(Fragment, null, li, el('ul', { className: 'bkbg-pgl-children' }, subItems));
92 }
93 return li;
94 }
95
96 /* ── editor for one item in inspector ── */
97 function ItemEditor(props) {
98 var item = props.item;
99 var onChange = props.onChange;
100 var onRemove = props.onRemove;
101
102 var childRows = (item.children || []).map(function(c, ci) {
103 return el('div', { key: c.id, style: { background: '#f8f9fa', borderRadius: '6px', padding: '8px', marginBottom: '4px' } },
104 el(TextControl, {
105 label: __('Sub-page title', 'blockenberg'),
106 value: c.title,
107 onChange: function(v) {
108 var newChildren = item.children.slice();
109 newChildren[ci] = Object.assign({}, c, { title: v });
110 onChange({ children: newChildren });
111 }
112 }),
113 el(TextControl, {
114 label: __('URL', 'blockenberg'),
115 value: c.url,
116 onChange: function(v) {
117 var newChildren = item.children.slice();
118 newChildren[ci] = Object.assign({}, c, { url: v });
119 onChange({ children: newChildren });
120 }
121 }),
122 el(IP().IconPickerControl, { iconType: c.iconType || 'custom-char', customChar: c.icon || '', dashicon: c.iconDashicon || '', imageUrl: c.iconImageUrl || '', onChangeType: function (v) {
123 var newChildren = item.children.slice();
124 newChildren[ci] = Object.assign({}, c, { iconType: v });
125 onChange({ children: newChildren });
126 }, onChangeChar: function (v) {
127 var newChildren = item.children.slice();
128 newChildren[ci] = Object.assign({}, c, { icon: v });
129 onChange({ children: newChildren });
130 }, onChangeDashicon: function (v) {
131 var newChildren = item.children.slice();
132 newChildren[ci] = Object.assign({}, c, { iconDashicon: v });
133 onChange({ children: newChildren });
134 }, onChangeImageUrl: function (v) {
135 var newChildren = item.children.slice();
136 newChildren[ci] = Object.assign({}, c, { iconImageUrl: v });
137 onChange({ children: newChildren });
138 } }),
139 el(Button, {
140 isDestructive: true,
141 variant: 'tertiary',
142 onClick: function() {
143 var newChildren = item.children.filter(function(_, i) { return i !== ci; });
144 onChange({ children: newChildren });
145 }
146 }, __('Remove sub-page', 'blockenberg'))
147 );
148 });
149
150 return el(Fragment, null,
151 el(TextControl, { label: __('Page Title', 'blockenberg'), value: item.title, onChange: function(v){ onChange({ title: v }); } }),
152 el(TextControl, { label: __('URL', 'blockenberg'), value: item.url, onChange: function(v){ onChange({ url: v }); } }),
153 el(IP().IconPickerControl, { iconType: item.iconType || 'custom-char', customChar: item.icon || '', dashicon: item.iconDashicon || '', imageUrl: item.iconImageUrl || '', onChangeType: function (v) { onChange({ iconType: v }); }, onChangeChar: function (v) { onChange({ icon: v }); }, onChangeDashicon: function (v) { onChange({ iconDashicon: v }); }, onChangeImageUrl: function (v) { onChange({ iconImageUrl: v }); } }),
154 el(TextControl, { label: __('Description', 'blockenberg'), value: item.description, onChange: function(v){ onChange({ description: v }); }, help: __('Short subtitle shown below the title.', 'blockenberg') }),
155 childRows.length ? el('div', { style: { marginTop: '8px' } }, el('strong', null, __('Sub-pages', 'blockenberg')), el('div', { style: { marginTop: '4px' } }, childRows)) : null,
156 el(Button, {
157 variant: 'secondary',
158 style: { marginTop: '6px', width: '100%' },
159 onClick: function() {
160 onChange({ children: (item.children || []).concat([{ id: uid(), title: 'Sub-page', url: '#', icon: '📄', iconType: 'custom-char', iconDashicon: '', iconImageUrl: '' }]) });
161 }
162 }, __('+ Add Sub-page', 'blockenberg')),
163 el('hr', { style: { margin: '12px 0' } }),
164 el(Button, { isDestructive: true, variant: 'tertiary', onClick: onRemove }, __('Remove page', 'blockenberg'))
165 );
166 }
167
168 /* ── REGISTER ── */
169 registerBlockType('blockenberg/page-list', {
170 edit: function (props) {
171 var attrs = props.attributes;
172 var setAttr = props.setAttributes;
173 var items = attrs.items;
174
175 var _useState = useState(null);
176 var activeId = _useState[0];
177 var setActiveId = _useState[1];
178
179 var blockProps = useBlockProps((function () {
180 var tv = getTypoCssVars();
181 var s = {
182 '--bkbg-pgl-cols': attrs.columns,
183 '--bkbg-pgl-gap': attrs.gap + 'px',
184 '--bkbg-pgl-icon-size': attrs.iconSize + 'px',
185 '--bkbg-pgl-radius': attrs.borderRadius + 'px',
186 '--bkbg-pgl-pad-v': attrs.itemPaddingV + 'px',
187 '--bkbg-pgl-pad-h': attrs.itemPaddingH + 'px',
188 '--bkbg-pgl-link-color': attrs.linkColor,
189 '--bkbg-pgl-link-hover': attrs.linkColorHover,
190 '--bkbg-pgl-bg': attrs.bgColor,
191 '--bkbg-pgl-bg-hover': attrs.bgColorHover,
192 '--bkbg-pgl-border': attrs.borderColor,
193 '--bkbg-pgl-icon-color': attrs.iconColor,
194 '--bkbg-pgl-desc-color': attrs.descColor,
195 '--bkbg-pgl-chev-color': attrs.chevronColor,
196 '--bkbg-pgl-accent': attrs.accentColor,
197 maxWidth: attrs.maxWidth,
198 };
199 Object.assign(s, tv(attrs.linkTypo, '--bkbg-pgl-lk-'));
200 Object.assign(s, tv(attrs.descTypo, '--bkbg-pgl-ds-'));
201 return { className: 'bkbg-pgl-wrap bkbg-editor-pgl bkbg-pgl-layout--' + attrs.layout, style: s };
202 })());
203
204 /* update single item by id */
205 function updateItem(id, patch) {
206 setAttr({ items: items.map(function(it) { return it.id === id ? Object.assign({}, it, patch) : it; }) });
207 }
208
209 /* Inspector */
210 var activeItem = items.find(function(it) { return it.id === activeId; });
211
212 var inspector = el(InspectorControls, null,
213 /* Items */
214 el(PanelBody, { title: __('Pages', 'blockenberg'), initialOpen: true },
215 items.map(function(item, idx) {
216 var isActive = activeId === item.id;
217 return el('div', { key: item.id },
218 el('div', {
219 style: {
220 display: 'flex', alignItems: 'center', gap: '6px',
221 background: isActive ? '#f3f0ff' : '#f8f9fa',
222 border: isActive ? '1px solid #6c3fb5' : '1px solid #e2e8f0',
223 borderRadius: '6px', padding: '6px 8px', marginBottom: '4px', cursor: 'pointer'
224 },
225 onClick: function() { setActiveId(isActive ? null : item.id); }
226 },
227 el('span', { style: { flex: 1, fontWeight: 500, fontSize: '13px' } }, (item.icon ? item.icon + ' ' : '') + (item.title || __('(untitled)', 'blockenberg'))),
228 el(Button, { icon: 'arrow-up', label: __('Move up', 'blockenberg'), isSmall: true, disabled: idx === 0,
229 onClick: function(e){ e.stopPropagation(); setAttr({ items: move(items, idx, idx - 1) }); } }),
230 el(Button, { icon: 'arrow-down', label: __('Move down', 'blockenberg'), isSmall: true, disabled: idx === items.length - 1,
231 onClick: function(e){ e.stopPropagation(); setAttr({ items: move(items, idx, idx + 1) }); } }),
232 el(Button, { icon: 'no-alt', label: __('Remove', 'blockenberg'), isSmall: true, isDestructive: true,
233 onClick: function(e){ e.stopPropagation(); setAttr({ items: items.filter(function(_, i){ return i !== idx; }) }); if (activeId === item.id) setActiveId(null); } })
234 ),
235 isActive ? el('div', { style: { padding: '8px', background: '#faf8ff', borderRadius: '0 0 6px 6px', border: '1px solid #6c3fb5', borderTop: 'none', marginBottom: '4px' } },
236 el(ItemEditor, {
237 item: item,
238 onChange: function(patch){ updateItem(item.id, patch); },
239 onRemove: function(){ setAttr({ items: items.filter(function(i){ return i.id !== item.id; }) }); setActiveId(null); }
240 })
241 ) : null
242 );
243 }),
244 el(Button, { variant: 'primary', style: { marginTop: '8px', width: '100%' },
245 onClick: function() { var n = { id: uid(), title: 'New Page', url: '#', icon: '📄', iconType: 'custom-char', iconDashicon: '', iconImageUrl: '', description: '', children: [] }; setAttr({ items: items.concat([n]) }); setActiveId(n.id); }
246 }, __('+ Add Page', 'blockenberg'))
247 ),
248
249 /* Layout */
250 el(PanelBody, { title: __('Layout', 'blockenberg'), initialOpen: false },
251 el(SelectControl, {
252 label: __('Style', 'blockenberg'),
253 value: attrs.layout,
254 options: [
255 { label: __('Plain', 'blockenberg'), value: 'plain' },
256 { label: __('Bordered', 'blockenberg'), value: 'bordered' },
257 { label: __('Pills', 'blockenberg'), value: 'pills' },
258 { label: __('Cards', 'blockenberg'), value: 'cards' },
259 { label: __('Sidebar', 'blockenberg'), value: 'sidebar' },
260 ],
261 onChange: function(v){ setAttr({ layout: v }); }
262 }),
263 el(RangeControl, { label: __('Columns', 'blockenberg'), value: attrs.columns, min: 1, max: 4, onChange: function(v){ setAttr({ columns: v }); } }),
264 el(SelectControl, {
265 label: __('Sub-page depth', 'blockenberg'),
266 value: String(attrs.depth),
267 options: [
268 { label: __('1 level (no sub-pages)', 'blockenberg'), value: '1' },
269 { label: __('2 levels (show sub-pages)', 'blockenberg'), value: '2' },
270 ],
271 onChange: function(v){ setAttr({ depth: parseInt(v) }); }
272 }),
273 el(ToggleControl, { label: __('Show icons', 'blockenberg'), checked: attrs.showIcons, onChange: function(v){ setAttr({ showIcons: v }); } }),
274 el(ToggleControl, { label: __('Show description', 'blockenberg'), checked: attrs.showDescription, onChange: function(v){ setAttr({ showDescription: v }); } }),
275 el(ToggleControl, { label: __('Show chevron', 'blockenberg'), checked: attrs.showChevron, onChange: function(v){ setAttr({ showChevron: v }); } }),
276 el(SelectControl, {
277 label: __('Link target', 'blockenberg'),
278 value: attrs.linkTarget,
279 options: [
280 { label: __('Same tab', 'blockenberg'), value: '_self' },
281 { label: __('New tab', 'blockenberg'), value: '_blank' },
282 ],
283 onChange: function(v){ setAttr({ linkTarget: v }); }
284 }),
285 el(TextControl, { label: __('Max Width', 'blockenberg'), value: attrs.maxWidth, onChange: function(v){ setAttr({ maxWidth: v }); } })
286 ),
287
288 /* Spacing & Shape */
289 el(PanelBody, { title: __('Spacing & Shape', 'blockenberg'), initialOpen: false },
290 el(RangeControl, { label: __('Item gap (px)', 'blockenberg'), value: attrs.gap, min: 0, max: 40, onChange: function(v){ setAttr({ gap: v }); } }),
291 el(RangeControl, { label: __('Padding vertical (px)', 'blockenberg'), value: attrs.itemPaddingV, min: 0, max: 40, onChange: function(v){ setAttr({ itemPaddingV: v }); } }),
292 el(RangeControl, { label: __('Padding horizontal (px)','blockenberg'), value: attrs.itemPaddingH, min: 0, max: 60, onChange: function(v){ setAttr({ itemPaddingH: v }); } }),
293 el(RangeControl, { label: __('Border radius (px)', 'blockenberg'), value: attrs.borderRadius, min: 0, max: 50, onChange: function(v){ setAttr({ borderRadius: v }); } })
294 ),
295
296 /* Typography */
297 el(PanelBody, { title: __('Typography', 'blockenberg'), initialOpen: false },
298 el(getTypoControl(), { label: __('Link', 'blockenberg'), value: attrs.linkTypo, onChange: function (v) { setAttr({ linkTypo: v }); } }),
299 el(getTypoControl(), { label: __('Description', 'blockenberg'), value: attrs.descTypo, onChange: function (v) { setAttr({ descTypo: v }); } }),
300 el(RangeControl, { label: __('Icon size (px)', 'blockenberg'), value: attrs.iconSize, min: 12, max: 48, onChange: function(v){ setAttr({ iconSize: v }); } })
301 ),
302
303 /* Colors */
304 el(PanelColorSettings, {
305 title: __('Colors', 'blockenberg'),
306 initialOpen: false,
307 colorSettings: [
308 { label: __('Link color', 'blockenberg'), value: attrs.linkColor, onChange: function(v){ setAttr({ linkColor: v || '' }); } },
309 { label: __('Link hover color', 'blockenberg'), value: attrs.linkColorHover, onChange: function(v){ setAttr({ linkColorHover: v || '' }); } },
310 { label: __('Background', 'blockenberg'), value: attrs.bgColor, onChange: function(v){ setAttr({ bgColor: v || '' }); } },
311 { label: __('Background hover', 'blockenberg'), value: attrs.bgColorHover, onChange: function(v){ setAttr({ bgColorHover: v || '' }); } },
312 { label: __('Border color', 'blockenberg'), value: attrs.borderColor, onChange: function(v){ setAttr({ borderColor: v || '' }); } },
313 { label: __('Icon color', 'blockenberg'), value: attrs.iconColor, onChange: function(v){ setAttr({ iconColor: v || '' }); } },
314 { label: __('Description color', 'blockenberg'), value: attrs.descColor, onChange: function(v){ setAttr({ descColor: v || '' }); } },
315 { label: __('Chevron color', 'blockenberg'), value: attrs.chevronColor, onChange: function(v){ setAttr({ chevronColor: v || '' }); } },
316 { label: __('Accent color', 'blockenberg'), value: attrs.accentColor, onChange: function(v){ setAttr({ accentColor: v || '' }); } },
317 ]
318 })
319 );
320
321 /* Preview */
322 var listItems = items.map(function(item) {
323 return el(EditorItem, Object.assign({ key: item.id }, { item: item, depth: attrs.depth, showIcons: attrs.showIcons, showDescription: attrs.showDescription, showChevron: attrs.showChevron, layout: attrs.layout }));
324 });
325
326 return el(Fragment, null,
327 inspector,
328 el('div', blockProps,
329 el('ul', { className: 'bkbg-pgl-list' }, listItems)
330 )
331 );
332 },
333
334 save: function (props) {
335 var a = props.attributes;
336 var tv = getTypoCssVars();
337 var s = {
338 '--bkbg-pgl-cols': a.columns,
339 '--bkbg-pgl-gap': a.gap + 'px',
340 '--bkbg-pgl-icon-size': a.iconSize + 'px',
341 '--bkbg-pgl-radius': a.borderRadius + 'px',
342 '--bkbg-pgl-pad-v': a.itemPaddingV + 'px',
343 '--bkbg-pgl-pad-h': a.itemPaddingH + 'px',
344 '--bkbg-pgl-link-color': a.linkColor,
345 '--bkbg-pgl-link-hover': a.linkColorHover,
346 '--bkbg-pgl-bg': a.bgColor,
347 '--bkbg-pgl-bg-hover': a.bgColorHover,
348 '--bkbg-pgl-border': a.borderColor,
349 '--bkbg-pgl-icon-color': a.iconColor,
350 '--bkbg-pgl-desc-color': a.descColor,
351 '--bkbg-pgl-chev-color': a.chevronColor,
352 '--bkbg-pgl-accent': a.accentColor,
353 maxWidth: a.maxWidth,
354 };
355 Object.assign(s, tv(a.linkTypo, '--bkbg-pgl-lk-'));
356 Object.assign(s, tv(a.descTypo, '--bkbg-pgl-ds-'));
357 var blockProps = wp.blockEditor.useBlockProps.save({ className: 'bkbg-pgl-wrap bkbg-pgl-layout--' + a.layout, style: s });
358
359 function saveChild(child) {
360 var cIcon = a.showIcons ? el('span', { className: 'bkbg-pgl-icon bkbg-pgl-icon--child' }, (child.iconType || 'custom-char') !== 'custom-char' ? IP().buildSaveIcon(child.iconType, child.icon, child.iconDashicon, child.iconImageUrl, child.iconDashiconColor) : child.icon) : null;
361 var cLabel = el('span', { className: 'bkbg-pgl-label' }, child.title);
362 var cInner = el('span', { className: 'bkbg-pgl-link-inner' }, cIcon, el('span', { className: 'bkbg-pgl-text-wrap' }, cLabel));
363 return el('li', { key: child.id, className: 'bkbg-pgl-item bkbg-pgl-item--child' },
364 el('a', { className: 'bkbg-pgl-link bkbg-pgl-link--child', href: child.url, target: a.linkTarget }, cInner)
365 );
366 }
367
368 function saveItem(item) {
369 var iconEl = a.showIcons ? el('span', { className: 'bkbg-pgl-icon' }, (item.iconType || 'custom-char') !== 'custom-char' ? IP().buildSaveIcon(item.iconType, item.icon, item.iconDashicon, item.iconImageUrl, item.iconDashiconColor) : item.icon) : null;
370 var descEl = a.showDescription && item.description ? el('span', { className: 'bkbg-pgl-desc' }, item.description) : null;
371 var chevron = a.showChevron ? el('span', { className: 'bkbg-pgl-chevron', 'aria-hidden': 'true' }, '') : null;
372 var label = el('span', { className: 'bkbg-pgl-label' }, item.title);
373 var textWrap = el('span', { className: 'bkbg-pgl-text-wrap' }, label, descEl);
374 var inner = el('span', { className: 'bkbg-pgl-link-inner' }, iconEl, textWrap, chevron);
375 var link = el('a', { className: 'bkbg-pgl-link', href: item.url, target: a.linkTarget }, inner);
376 var li = el('li', { className: 'bkbg-pgl-item' }, link);
377 if (a.depth >= 2 && item.children && item.children.length) {
378 var sub = el('ul', { className: 'bkbg-pgl-children' }, item.children.map(saveChild));
379 return el(wp.element.Fragment, { key: item.id }, li, sub);
380 }
381 return el('li', { key: item.id, className: 'bkbg-pgl-item' }, link);
382 }
383
384 return el('div', blockProps,
385 el('ul', { className: 'bkbg-pgl-list' }, a.items.map(saveItem))
386 );
387 },
388
389 deprecated: [{
390 save: function (props) {
391 var a = props.attributes;
392 var wrapStyle = buildWrapStyle(a);
393 var blockProps = wp.blockEditor.useBlockProps.save({ className: 'bkbg-pgl-wrap bkbg-pgl-layout--' + a.layout, style: wrapStyle });
394
395 function saveChild(child) {
396 var cIcon = a.showIcons ? el('span', { className: 'bkbg-pgl-icon bkbg-pgl-icon--child' }, child.icon) : null;
397 var cLabel = el('span', { className: 'bkbg-pgl-label' }, child.title);
398 var cInner = el('span', { className: 'bkbg-pgl-link-inner' }, cIcon, el('span', { className: 'bkbg-pgl-text-wrap' }, cLabel));
399 return el('li', { key: child.id, className: 'bkbg-pgl-item bkbg-pgl-item--child' },
400 el('a', { className: 'bkbg-pgl-link bkbg-pgl-link--child', href: child.url, target: a.linkTarget }, cInner)
401 );
402 }
403
404 function saveItem(item) {
405 var iconEl = a.showIcons ? el('span', { className: 'bkbg-pgl-icon' }, item.icon) : null;
406 var descEl = a.showDescription && item.description ? el('span', { className: 'bkbg-pgl-desc' }, item.description) : null;
407 var chevron = a.showChevron ? el('span', { className: 'bkbg-pgl-chevron', 'aria-hidden': 'true' }, '\u203A') : null;
408 var label = el('span', { className: 'bkbg-pgl-label' }, item.title);
409 var textWrap = el('span', { className: 'bkbg-pgl-text-wrap' }, label, descEl);
410 var inner = el('span', { className: 'bkbg-pgl-link-inner' }, iconEl, textWrap, chevron);
411 var link = el('a', { className: 'bkbg-pgl-link', href: item.url, target: a.linkTarget }, inner);
412 var li = el('li', { className: 'bkbg-pgl-item' }, link);
413 if (a.depth >= 2 && item.children && item.children.length) {
414 var sub = el('ul', { className: 'bkbg-pgl-children' }, item.children.map(saveChild));
415 return el(wp.element.Fragment, { key: item.id }, li, sub);
416 }
417 return el('li', { key: item.id, className: 'bkbg-pgl-item' }, link);
418 }
419
420 return el('div', blockProps,
421 el('ul', { className: 'bkbg-pgl-list' }, a.items.map(saveItem))
422 );
423 }
424 }]
425 });
426 }() );
427