From 3562b71e2952ea5ccbebd49efbde452a0c4b927e Mon Sep 17 00:00:00 2001 From: Brian DiChiara Date: Thu, 16 Jan 2025 13:55:15 -0600 Subject: [PATCH] Added build directory --- .gitignore | 5 +++++ build/index.asset.php | 2 +- build/index.js | 2 +- package-lock.json | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 968a157..6662046 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,11 @@ # Created by https://www.toptal.com/developers/gitignore/api/wordpress,phpstorm,macos,composer,windows,visualstudiocode # Edit at https://www.toptal.com/developers/gitignore?templates=wordpress,phpstorm,macos,composer,windows,visualstudiocode +### Viget Blocks Toolkit ### + +# Let's keep the build directory in the repo. +!build/ + ### Composer ### composer.phar vendor diff --git a/build/index.asset.php b/build/index.asset.php index aef39be..0ce4364 100644 --- a/build/index.asset.php +++ b/build/index.asset.php @@ -1 +1 @@ - array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-dom-ready', 'wp-edit-post', 'wp-edit-site', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '0b0af76a6c769d3fad35'); + array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-dom-ready', 'wp-edit-post', 'wp-edit-site', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '32a6ed106b36ac1be69b'); diff --git a/build/index.js b/build/index.js index 4ff2a1b..83ff29a 100644 --- a/build/index.js +++ b/build/index.js @@ -1 +1 @@ -(()=>{var e={942:(e,t)=>{var o;!function(){"use strict";var i={}.hasOwnProperty;function n(){for(var e="",t=0;t{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var i in t)o.o(t,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e=window.React;var t=o(942),i=o.n(t);const n=window.wp.i18n,l=window.wp.hooks,r=window.wp.blockEditor,a=window.wp.components,s=vgtbtIcons.json;(0,l.addFilter)("blocks.registerBlockType","viget-blocks-toolkit/add-attributes",(function(e){return vgtbtIcons.supportedBlocks.includes(e.name)?{...e,attributes:{...e.attributes,icon:{type:"string"},iconPositionLeft:{type:"boolean",default:!1}}}:e})),(0,l.addFilter)("editor.BlockEdit","viget-blocks-toolkit/add-inspector-controls",(function(t){return o=>{if(!vgtbtIcons.supportedBlocks.includes(o.name))return(0,e.createElement)(t,{...o});const{attributes:i,setAttributes:l}=o,{icon:c,iconPositionLeft:u}=i;return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(t,{...o}),(0,e.createElement)(r.InspectorControls,null,(0,e.createElement)(a.PanelBody,{title:(0,n.__)("Icon","viget-blocks-toolkit"),className:"button-icon-picker",initialOpen:!0},(0,e.createElement)(a.PanelRow,null,(0,e.createElement)(a.__experimentalGrid,{className:"button-icon-picker__grid",columns:"5",gap:"0"},s.map(((t,o)=>{var i;return(0,e.createElement)(a.Button,{key:o,label:t?.label,isPressed:c===t.value,className:"button-icon-picker__button button-icon-picker__icon-"+t.value,onClick:()=>l({icon:c===t.value?null:t.value,iconPositionLeft:u||t?.defaultLeft})},(0,e.createElement)("span",{dangerouslySetInnerHTML:{__html:null!==(i=t.icon)&&void 0!==i?i:t.value}}))})))),(0,e.createElement)(a.PanelRow,null,(0,e.createElement)(a.ToggleControl,{label:(0,n.__)("Show icon on left","viget-blocks-toolkit"),checked:u,onChange:()=>{l({iconPositionLeft:!u})}})))))}})),(0,l.addFilter)("editor.BlockListBlock","viget-blocks-toolkit/add-classes",(function(t){return o=>{const{name:n,attributes:l}=o;if(!vgtbtIcons.supportedBlocks.includes(n)||!l?.icon)return(0,e.createElement)(t,{...o});const r=i()(o?.className,{[`has-icon__${l?.icon}`]:l?.icon,"has-icon-position__left":l?.iconPositionLeft});return(0,e.createElement)(t,{...o,className:r})}}));const c=window.wp.domReady;var u=o.n(c);window.wp.editPost,window.wp.editSite;const b=window.wp.blocks,d=vgtbtStyles.unregister;u()((()=>{d.forEach((e=>{const t=Array.isArray(e[1])?e[1]:[e[1]];(0,b.unregisterBlockStyle)(e[0],t)}))}));const m=vgtbtVariations.unregister;u()((()=>{m.forEach((e=>{const[t,o]=e;(0,b.unregisterBlockVariation)(t,o)}))}));const p=window.wp.data;(0,l.addFilter)("editor.BlockEdit","acf-bt/media-position",(t=>o=>{if(!o.attributes||"object"!=typeof o.attributes)return(0,e.createElement)(t,{...o});const i=(0,b.getBlockSupport)(o.name,"mediaPosition",!1);if(!i?.transformations)return(0,e.createElement)(t,{...o});const{attributes:l,setAttributes:s,clientId:c}=o,u=(l.className||"").split(" "),d=l.mediaPosition||"left",{replaceInnerBlocks:m}=(0,p.useDispatch)("core/block-editor"),{getBlocks:k}=(0,p.useSelect)((e=>({getBlocks:e("core/block-editor").getBlocks}))),g=(e,t,o=null,i)=>{const n=i||d;let l={...e},r=[...e.innerBlocks];const a=(e,t)=>{let o={...e};return Object.entries(t).forEach((([e,t])=>{if("object"!=typeof t||t[n]){const i=t[n];void 0!==i&&(o[e]=i)}else o[e]=a(o[e]||{},t)})),o},s=((e,t)=>t.find((t=>Object.keys(t)[0]===e))?.[e])(e.name,t);if(s&&(s.attributes&&(l.attributes=a(l.attributes,s.attributes)),s.reverse&&(r=r.reverse()),s.innerBlocks))return r=r.map((e=>g(e,t,s.innerBlocks,n))),{...l,innerBlocks:r};if(o){const i=o.find((t=>Object.keys(t)[0]===e.name))?.[e.name];if(i){if(i.attributes){const e=a(l.attributes,i.attributes);l={...l,attributes:e}}if(i.innerBlocks)return r=r.map((e=>g(e,t,i.innerBlocks,n))),{...l,innerBlocks:r}}}return r=r.map((e=>g(e,t,null,n))),{...l,innerBlocks:r}},v=e=>{const t=u.filter((e=>!["has-media-on-the-left","has-media-on-the-right"].includes(e)));t.push(`has-media-on-the-${e}`);const o=k(c);if(!o?.length)return;const n=o.map((t=>g(t,i.transformations,null,e)));s({className:t.join(" ").trim(),mediaPosition:e}),m(c,n,!1)};return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(r.BlockControls,{group:"block"},(0,e.createElement)(a.ToolbarGroup,null,(0,e.createElement)(a.ToolbarButton,{icon:"align-pull-left",title:(0,n.__)("Show media on left"),onClick:()=>v("left"),isActive:"left"===d}),(0,e.createElement)(a.ToolbarButton,{icon:"align-pull-right",title:(0,n.__)("Show media on right"),onClick:()=>v("right"),isActive:"right"===d}))),(0,e.createElement)(t,{...o}))}));const k=window.wp.compose,g=window.wp.element,v=["core/rss"],f=(0,k.createHigherOrderComponent)((t=>o=>{if(v.includes(o.name)||!o.attributes)return(0,e.createElement)(t,{...o});const{attributes:i,setAttributes:l}=o,s=i.breakpointVisibility||{useCustom:!1,desktop:!1,tablet:!1,mobile:!1,customBreakpoint:{width:"768",unit:"px",action:"hide",mobileFirst:!1}},c=s.useCustom||s.desktop||s.tablet||s.mobile,[u,b]=(0,g.useState)(c),d=(e,t)=>{l({breakpointVisibility:{...s,[e]:t}})},m=(e,t)=>{l({breakpointVisibility:{...s,customBreakpoint:{...s.customBreakpoint,[e]:t}}})},p={...o,className:`${o.className||""} ${c?"has-breakpoint-visibility":""}`.trim(),"data-visibility":c?"true":"false"};return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(t,{...p}),(0,e.createElement)(r.InspectorControls,null,(0,e.createElement)(a.PanelBody,{title:(0,n.__)("Responsive","viget-blocks-toolkit"),opened:u,onToggle:()=>b(!u)},(0,e.createElement)(a.ToggleControl,{label:(0,n.__)("Hide on Desktop","viget-blocks-toolkit"),checked:s.desktop,onChange:e=>d("desktop",e),disabled:s.useCustom}),(0,e.createElement)(a.ToggleControl,{label:(0,n.__)("Hide on Tablet","viget-blocks-toolkit"),checked:s.tablet,onChange:e=>d("tablet",e),disabled:s.useCustom}),(0,e.createElement)(a.ToggleControl,{label:(0,n.__)("Hide on Mobile","viget-blocks-toolkit"),checked:s.mobile,onChange:e=>d("mobile",e),disabled:s.useCustom}),(0,e.createElement)("hr",null),(0,e.createElement)(a.ToggleControl,{label:(0,n.__)("Use Custom Breakpoint","viget-blocks-toolkit"),checked:s.useCustom,onChange:e=>d("useCustom",e)}),s.useCustom&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:"8px",alignItems:"start"}},(0,e.createElement)(a.__experimentalNumberControl,{label:(0,n.__)("Breakpoint Width","viget-blocks-toolkit"),value:s.customBreakpoint.width,onChange:e=>m("width",e),min:0,step:1}),(0,e.createElement)(a.SelectControl,{label:(0,n.__)("Unit","viget-blocks-toolkit"),value:s.customBreakpoint.unit,options:[{label:"px",value:"px"},{label:"%",value:"%"},{label:"rem",value:"rem"},{label:"vw",value:"vw"},{label:"vh",value:"vh"}],onChange:e=>m("unit",e)})),(0,e.createElement)(a.__experimentalToggleGroupControl,{label:(0,n.__)("Visibility Action","viget-blocks-toolkit"),value:s.customBreakpoint.action,onChange:e=>m("action",e),isBlock:!0},(0,e.createElement)(a.__experimentalToggleGroupControlOption,{value:"show",label:(0,n.__)("Show","viget-blocks-toolkit")}),(0,e.createElement)(a.__experimentalToggleGroupControlOption,{value:"hide",label:(0,n.__)("Hide","viget-blocks-toolkit")})),(0,e.createElement)(a.ToggleControl,{label:(0,n.__)("Mobile First","viget-blocks-toolkit"),help:(0,n.__)("When enabled, applies to screens smaller than breakpoint","viget-blocks-toolkit"),checked:s.customBreakpoint.mobileFirst,onChange:e=>m("mobileFirst",e)})))))}),"withBreakpointVisibility");(0,l.addFilter)("blocks.registerBlockType","viget-blocks-toolkit/breakpoint-visibility-attributes",(e=>(v.includes(e.name)||!e.attributes||(e.attributes.breakpointVisibility={type:"object",default:{useCustom:!1,desktop:!1,tablet:!1,mobile:!1,customBreakpoint:{width:"768",unit:"px",action:"hide",mobileFirst:!1}}}),e))),(0,l.addFilter)("editor.BlockEdit","viget-blocks-toolkit/with-breakpoint-visibility",f),(0,l.addFilter)("blocks.getSaveContent.extraProps","viget-blocks-toolkit/breakpoint-visibility-attributes",((e,t,o)=>{if(!o.breakpointVisibility)return e;const{useCustom:i,desktop:n,tablet:l,mobile:r}=o.breakpointVisibility;return i||(n&&(e["data-visibility-desktop"]="hide"),l&&(e["data-visibility-tablet"]="hide"),r&&(e["data-visibility-mobile"]="hide")),e}))})()})(); \ No newline at end of file +(()=>{var e={942:(e,t)=>{var o;!function(){"use strict";var i={}.hasOwnProperty;function n(){for(var e="",t=0;t{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var i in t)o.o(t,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e=window.React;var t=o(942),i=o.n(t);const n=window.wp.i18n,l=window.wp.hooks,r=window.wp.blockEditor,a=window.wp.components,s=vgtbtIcons.json;(0,l.addFilter)("blocks.registerBlockType","viget-blocks-toolkit/add-attributes",(function(e){return vgtbtIcons.supportedBlocks.includes(e.name)?{...e,attributes:{...e.attributes,icon:{type:"string"},iconPositionLeft:{type:"boolean",default:!1}}}:e})),(0,l.addFilter)("editor.BlockEdit","viget-blocks-toolkit/add-inspector-controls",(function(t){return o=>{if(!vgtbtIcons.supportedBlocks.includes(o.name))return(0,e.createElement)(t,{...o});const{attributes:i,setAttributes:l}=o,{icon:c,iconPositionLeft:u}=i;return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(t,{...o}),(0,e.createElement)(r.InspectorControls,null,(0,e.createElement)(a.PanelBody,{title:(0,n.__)("Icon","viget-blocks-toolkit"),className:"button-icon-picker",initialOpen:!0},(0,e.createElement)(a.PanelRow,null,(0,e.createElement)(a.__experimentalGrid,{className:"button-icon-picker__grid",columns:"5",gap:"0"},s.map(((t,o)=>{var i;return(0,e.createElement)(a.Button,{key:o,label:t?.label,isPressed:c===t.value,className:"button-icon-picker__button button-icon-picker__icon-"+t.value,onClick:()=>l({icon:c===t.value?null:t.value,iconPositionLeft:u||t?.defaultLeft})},(0,e.createElement)("span",{dangerouslySetInnerHTML:{__html:null!==(i=t.icon)&&void 0!==i?i:t.value}}))})))),(0,e.createElement)(a.PanelRow,null,(0,e.createElement)(a.ToggleControl,{label:(0,n.__)("Show icon on left","viget-blocks-toolkit"),checked:u,onChange:()=>{l({iconPositionLeft:!u})}})))))}})),(0,l.addFilter)("editor.BlockListBlock","viget-blocks-toolkit/add-classes",(function(t){return o=>{const{name:n,attributes:l}=o;if(!vgtbtIcons.supportedBlocks.includes(n)||!l?.icon)return(0,e.createElement)(t,{...o});const r=i()(o?.className,{[`has-icon__${l?.icon}`]:l?.icon,"has-icon-position__left":l?.iconPositionLeft});return(0,e.createElement)(t,{...o,className:r})}}));const c=window.wp.domReady;var u=o.n(c);window.wp.editPost,window.wp.editSite;const b=window.wp.blocks,d=vgtbtStyles.unregister;u()((()=>{d.forEach((e=>{const t=Array.isArray(e[1])?e[1]:[e[1]];(0,b.unregisterBlockStyle)(e[0],t)}))}));const m=vgtbtVariations.unregister;u()((()=>{m.forEach((e=>{const[t,o]=e;(0,b.unregisterBlockVariation)(t,o)}))}));const p=window.wp.data;(0,l.addFilter)("editor.BlockEdit","acf-bt/media-position",(t=>o=>{if(!o.attributes||"object"!=typeof o.attributes)return(0,e.createElement)(t,{...o});const i=(0,b.getBlockSupport)(o.name,"mediaPosition",!1);if(!i?.transformations)return(0,e.createElement)(t,{...o});const{attributes:l,setAttributes:s,clientId:c}=o,u=(l.className||"").split(" "),d=l.mediaPosition||"left",{replaceInnerBlocks:m}=(0,p.useDispatch)("core/block-editor"),{getBlocks:k}=(0,p.useSelect)((e=>({getBlocks:e("core/block-editor").getBlocks}))),g=(e,t,o=null,i)=>{const n=i||d;let l={...e},r=[...e.innerBlocks];const a=(e,t)=>{let o={...e};return Object.entries(t).forEach((([e,t])=>{if("object"!=typeof t||t[n]){const i=t[n];void 0!==i&&(o[e]=i)}else o[e]=a(o[e]||{},t)})),o},s=((e,t)=>t.find((t=>Object.keys(t)[0]===e))?.[e])(e.name,t);if(s&&(s.attributes&&(l.attributes=a(l.attributes,s.attributes)),s.reverse&&(r=r.reverse()),s.innerBlocks))return r=r.map((e=>g(e,t,s.innerBlocks,n))),{...l,innerBlocks:r};if(o){const i=o.find((t=>Object.keys(t)[0]===e.name))?.[e.name];if(i){if(i.attributes){const e=a(l.attributes,i.attributes);l={...l,attributes:e}}if(i.innerBlocks)return r=r.map((e=>g(e,t,i.innerBlocks,n))),{...l,innerBlocks:r}}}return r=r.map((e=>g(e,t,null,n))),{...l,innerBlocks:r}},v=e=>{const t=u.filter((e=>!["has-media-on-the-left","has-media-on-the-right"].includes(e)));t.push(`has-media-on-the-${e}`);const o=k(c);if(!o?.length)return;const n=o.map((t=>g(t,i.transformations,null,e)));s({className:t.join(" ").trim(),mediaPosition:e}),m(c,n,!1)};return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(r.BlockControls,{group:"block"},(0,e.createElement)(a.ToolbarGroup,null,(0,e.createElement)(a.ToolbarButton,{icon:"align-pull-left",title:(0,n.__)("Show media on left"),onClick:()=>v("left"),isActive:"left"===d}),(0,e.createElement)(a.ToolbarButton,{icon:"align-pull-right",title:(0,n.__)("Show media on right"),onClick:()=>v("right"),isActive:"right"===d}))),(0,e.createElement)(t,{...o}))}));const k=window.wp.compose,g=window.wp.element,v=["core/rss","gravityforms/form"],f=(0,k.createHigherOrderComponent)((t=>o=>{if(v.includes(o.name)||!o.attributes)return(0,e.createElement)(t,{...o});const{attributes:i,setAttributes:l}=o,s=i.breakpointVisibility||{useCustom:!1,desktop:!1,tablet:!1,mobile:!1,customBreakpoint:{width:"768",unit:"px",action:"hide",mobileFirst:!1}},c=s.useCustom||s.desktop||s.tablet||s.mobile,[u,b]=(0,g.useState)(c),d=(e,t)=>{l({breakpointVisibility:{...s,[e]:t}})},m=(e,t)=>{l({breakpointVisibility:{...s,customBreakpoint:{...s.customBreakpoint,[e]:t}}})},p={...o,className:`${o.className||""} ${c?"has-breakpoint-visibility":""}`.trim(),"data-visibility":c?"true":"false"};return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(t,{...p}),(0,e.createElement)(r.InspectorControls,null,(0,e.createElement)(a.PanelBody,{title:(0,n.__)("Responsive","viget-blocks-toolkit"),opened:u,onToggle:()=>b(!u)},(0,e.createElement)(a.ToggleControl,{label:(0,n.__)("Hide on Desktop","viget-blocks-toolkit"),checked:s.desktop,onChange:e=>d("desktop",e),disabled:s.useCustom}),(0,e.createElement)(a.ToggleControl,{label:(0,n.__)("Hide on Tablet","viget-blocks-toolkit"),checked:s.tablet,onChange:e=>d("tablet",e),disabled:s.useCustom}),(0,e.createElement)(a.ToggleControl,{label:(0,n.__)("Hide on Mobile","viget-blocks-toolkit"),checked:s.mobile,onChange:e=>d("mobile",e),disabled:s.useCustom}),(0,e.createElement)("hr",null),(0,e.createElement)(a.ToggleControl,{label:(0,n.__)("Use Custom Breakpoint","viget-blocks-toolkit"),checked:s.useCustom,onChange:e=>d("useCustom",e)}),s.useCustom&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:"8px",alignItems:"start"}},(0,e.createElement)(a.__experimentalNumberControl,{label:(0,n.__)("Breakpoint Width","viget-blocks-toolkit"),value:s.customBreakpoint.width,onChange:e=>m("width",e),min:0,step:1}),(0,e.createElement)(a.SelectControl,{label:(0,n.__)("Unit","viget-blocks-toolkit"),value:s.customBreakpoint.unit,options:[{label:"px",value:"px"},{label:"%",value:"%"},{label:"rem",value:"rem"},{label:"vw",value:"vw"},{label:"vh",value:"vh"}],onChange:e=>m("unit",e)})),(0,e.createElement)(a.__experimentalToggleGroupControl,{label:(0,n.__)("Visibility Action","viget-blocks-toolkit"),value:s.customBreakpoint.action,onChange:e=>m("action",e),isBlock:!0},(0,e.createElement)(a.__experimentalToggleGroupControlOption,{value:"show",label:(0,n.__)("Show","viget-blocks-toolkit")}),(0,e.createElement)(a.__experimentalToggleGroupControlOption,{value:"hide",label:(0,n.__)("Hide","viget-blocks-toolkit")})),(0,e.createElement)(a.ToggleControl,{label:(0,n.__)("Mobile First","viget-blocks-toolkit"),help:(0,n.__)("When enabled, applies to screens smaller than breakpoint","viget-blocks-toolkit"),checked:s.customBreakpoint.mobileFirst,onChange:e=>m("mobileFirst",e)})))))}),"withBreakpointVisibility");(0,l.addFilter)("blocks.registerBlockType","viget-blocks-toolkit/breakpoint-visibility-attributes",(e=>(v.includes(e.name)||!e.attributes||(e.attributes.breakpointVisibility={type:"object",default:{useCustom:!1,desktop:!1,tablet:!1,mobile:!1,customBreakpoint:{width:"768",unit:"px",action:"hide",mobileFirst:!1}}}),e))),(0,l.addFilter)("editor.BlockEdit","viget-blocks-toolkit/with-breakpoint-visibility",f),(0,l.addFilter)("blocks.getSaveContent.extraProps","viget-blocks-toolkit/breakpoint-visibility-attributes",((e,t,o)=>{if(!o.breakpointVisibility)return e;const{useCustom:i,desktop:n,tablet:l,mobile:r}=o.breakpointVisibility;return i||(n&&(e["data-visibility-desktop"]="hide"),l&&(e["data-visibility-tablet"]="hide"),r&&(e["data-visibility-mobile"]="hide")),e}))})()})(); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 7137633..bffd23d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "viget-blocks-toolkit", - "version": "1.0.5", + "version": "1.0.7", "license": "GPL-2.0-or-later", "dependencies": { "@wordpress/dom-ready": "^4.15.0",