From 0cfd196fe335667aef067479e027eef05755e28c Mon Sep 17 00:00:00 2001 From: Matthew Haines-Young Date: Mon, 5 Jun 2023 16:51:41 +0100 Subject: [PATCH 1/2] Ignore dist --- .gitignore | 1 + dist/index.js | 2 -- dist/index.js.LICENSE.txt | 5 ----- 3 files changed, 1 insertion(+), 7 deletions(-) delete mode 100644 dist/index.js delete mode 100644 dist/index.js.LICENSE.txt diff --git a/.gitignore b/.gitignore index d7ca3f6..6850d5a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,6 @@ /dist/index.asset.php /node_modules/ /vendor/ +/dist/ !.gitkeep diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index ac2b6d3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! For license information please see index.js.LICENSE.txt */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["@humanmade/block-editor-components"]=t():e["@humanmade/block-editor-components"]=t()}(self,(()=>(()=>{var e={184:(e,t)=>{var n;!function(){"use strict";var o={}.hasOwnProperty;function r(){for(var e=[],t=0;t{"use strict";var o=n(414);function r(){}function l(){}l.resetWarningCache=r,e.exports=function(){function e(e,t,n,r,l,i){if(i!==o){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:l,resetWarningCache:r};return n.PropTypes=n,n}},697:(e,t,n)=>{e.exports=n(703)()},414:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var l=t[o]={exports:{}};return e[o](l,l.exports,n),l.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{"use strict";n.r(o),n.d(o,{ConditionalComponent:()=>r,FetchAllTermSelectControl:()=>f,FileControls:()=>b,GenericServerSideEdit:()=>h,ImageControl:()=>T,InnerBlockSlider:()=>F,LinkToolbar:()=>L,PlainTextWithLimit:()=>D,PostTitleControl:()=>q,PostTypeCheck:()=>U,RichTextWithLimit:()=>H,createOptionFromPost:()=>le,createOptionFromTerm:()=>ie,createOptionsFromPosts:()=>ae,createOptionsFromPostsWithHierarchy:()=>ce,createOptionsFromTerms:()=>se,createOptionsFromTermsWithHierarchy:()=>ue,findBlockByName:()=>Z,findInvalidBlock:()=>ee,findInvalidBlocks:()=>te,findValidBlock:()=>ne,findValidBlocks:()=>oe,getImageDataForSize:()=>y,useActiveBlockStyle:()=>V,useBlockStyles:()=>G,useDisallowedBlocks:()=>Q,useMeta:()=>Y,useRenderAppenderWithBlockLimit:()=>J,useSelectBlock:()=>K,useSetAttribute:()=>X,withActiveVariation:()=>pe});const e=window.wp.element,t=window.React;function r(t){const{children:n=null,ComponentFalse:o=(()=>null),ComponentTrue:r=(()=>n),predicate:l,...i}=t,a=l(i)?r:o;return(0,e.createElement)(a,i)}function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var t;return null===(t=e("core").getTaxonomy(i))||void 0===t?void 0:t.rest_base}),[i]);return(0,t.useEffect)((()=>{h&&(async()=>{try{const e=await a()({path:(0,d.addQueryArgs)(`/wp/v2/${h}`,{_fields:"id,name",context:"view",per_page:-1})});if(null==e||!e.length)return void k(r?[r]:[]);k([...o?[o]:[],...se(e)])}catch(t){var e;b(null!==(e=t.message)&&void 0!==e?e:(0,u.__)("Unknown error.","block-editor-components"))}})()}),[h,o,r]),v?(0,e.createElement)(c.Notice,{isDismissible:!1,status:"error"},(0,e.createElement)("p",null,v)):g?(0,e.createElement)(c.SelectControl,l({},f,{options:g})):(0,e.createElement)(c.Spinner,null)},v=window.wp.blockEditor;function b(t){const{value:n,onChange:o,...r}=t;return(0,e.createElement)(v.MediaUploadCheck,null,(0,e.createElement)(v.MediaUpload,l({title:(0,u.__)("Select or Upload File","block-editor-components")},r,{multiple:!1,render:t=>{let{open:r}=t;return(0,e.createElement)(c.ToolbarGroup,null,(0,e.createElement)(c.ToolbarButton,{icon:"admin-links",label:n?(0,u.__)("Edit file","block-editor-components"):(0,u.__)("Select file","block-editor-components"),onClick:r}),n&&(0,e.createElement)(c.ToolbarButton,{icon:"editor-unlink",label:(0,u.__)("Deselect file","block-editor-components"),onClick:()=>o(null)}))},value:n,onSelect:o})))}const g=window.wp.serverSideRender;var k=n.n(g);const h=function(t){let{attributes:n,context:o,name:r,inspectorControls:l}=t;return(0,e.createElement)(e.Fragment,null,l,(0,e.createElement)("div",(0,v.useBlockProps)(),(0,e.createElement)(c.Disabled,null,(0,e.createElement)(k(),{attributes:n,block:r,EmptyResponsePlaceholder:()=>(0,e.createElement)("div",{className:`wp-block-${r.replace("/","-")}`},r," ",(0,u.__)("Block rendered as empty.")),urlQueryArgs:"object"==typeof o&&Object.hasOwn(o,"postId")?{post_id:o.postId}:{}}))))};function y(e,t){var n,o;const r=null!==(n=null==e?void 0:e.sizes)&&void 0!==n?n:null==e||null===(o=e.media_details)||void 0===o?void 0:o.sizes,l=null==r?void 0:r[t];return l?{src:l.url||l.source_url,width:l.width,height:l.height}:null}const E=["image"],S=(0,u.__)("Select Image","block-editor-components"),w=(0,u.__)("Select Image","block-editor-components"),_=(0,u.__)("Remove image","block-editor-components"),B=(0,u.__)("Replace Image","block-editor-components");function T(t){const{buttonText:n=S,className:o,help:r,id:l,label:i,modalTitle:a=w,removeButtonText:u=_,replaceButtonText:d=B,size:p,value:m,onChange:f}=t,b=(0,s.useSelect)((e=>{const t=e("core").getMedia(m,{context:"view"});return t?t.alt_text:""}),[m]),g=(0,s.useSelect)((e=>{const t=e("core").getMedia(m,{context:"view"});if(t){if(p){const e=y(t,p);if(e)return e.src}return t.source_url}}),[p,m]);return(0,e.createElement)(c.BaseControl,{className:o,help:r,id:l,label:i},(0,e.createElement)(v.MediaUploadCheck,null,(0,e.createElement)(v.MediaUpload,{allowedTypes:E,render:t=>{let{open:o}=t;return(0,e.createElement)("div",null,m?g?(0,e.createElement)(c.Button,{isLink:!0,onClick:o},(0,e.createElement)("img",{alt:b,src:g})):(0,e.createElement)(c.Spinner,null):null,(0,e.createElement)(c.Button,{isSecondary:!0,onClick:o},m?d:n))},title:a,onSelect:f})),(0,e.createElement)("br",null),m?(0,e.createElement)(c.Button,{isDestructive:!0,isLink:!0,onClick:()=>f(null)},u):null)}var C=n(697),x=n.n(C);const P=window.wp.blocks;function I(n){let{className:o,allowedBlocks:r,template:l,currentItemIndex:i,parentBlockId:a,renderAppender:c,captureToolbars:s}=n;const u=(0,t.useRef)(),d=(0,v.useInnerBlocksProps)({id:`inner-block-display-single-${a}`,className:o},{__experimentalCaptureToolbars:s,allowedBlocks:r,orientation:"horizontal",renderAppender:c,template:l,templateLock:!1});return(0,t.useEffect)((()=>{u.current&&(u.current.innerHTML=`#inner-block-display-single-${a} > *:not(:nth-child(${i+1}) ) { display: none; }`)}),[i,u,a]),(0,e.createElement)(e.Fragment,null,(0,e.createElement)("style",{ref:u}),(0,e.createElement)("div",d))}I.defaultProps={currentItemIndex:0,renderAppender:!1,captureToolbars:!0},I.propTypes={parentBlockId:x().string.isRequired,allowedBlocks:x().arrayOf(x().string).isRequired,template:x().array,className:x().string,currentItemIndex:x().number,renderAppender:x().oneOfType([x().bool,x().element])};const O=I;var R=n(184),N=n.n(R);function A(t){let{totalPages:n,currentPage:o,setCurrentPage:r,prevEnabled:l,nextEnabled:i,addSlide:a=(()=>{}),addSlideEnabled:s=!1}=t;return(0,e.createElement)("div",{className:"inner-block-slider__navigation"},(0,e.createElement)(c.IconButton,{disabled:!l,icon:"arrow-left-alt2",isSecondary:!0,isSmall:!0,onClick:()=>{l&&r(o-1)}}),[...Array(n).keys()].map((t=>(0,e.createElement)(c.Button,{key:t+1,"aria-label":`Slide ${t+1}`,className:N()("components-button","is-not-small",{"is-primary":o===t+1,"is-secondary":o!==t+1}),type:"button",onClick:()=>{r(t+1)}},t+1))),(0,e.createElement)(c.IconButton,{disabled:!i,icon:"arrow-right-alt2",isSecondary:!0,isSmall:!0,onClick:()=>{i&&r(o+1)}}),(0,e.createElement)(c.IconButton,{disabled:!s,icon:"plus-alt2",isSecondary:!0,isSmall:!0,onClick:()=>a()}))}A.propTypes={totalPages:x().number.isRequired,currentPage:x().number.isRequired,setCurrentPage:x().func.isRequired,prevEnabled:x().bool.isRequired,nextEnabled:x().bool.isRequired,addSlide:x().func,addSlideEnabled:x().bool};const M=A,j=n=>{let{parentBlockId:o,allowedBlock:r,template:l,slideLimit:i}=n;const a=l||[[r]],c=(0,s.useSelect)((e=>e("core/block-editor").getBlock(o).innerBlocks)),[u,d]=(0,t.useState)(0),p=(0,t.useRef)(c.length),{insertBlock:m}=(0,s.useDispatch)("core/block-editor");return(0,t.useEffect)((()=>{(c.length>p.current||c.lengthc.length)&&d(c.length-1),p.current=c.length}),[c.length,u,p]),(0,e.createElement)("div",{className:"inner-block-slider"},(0,e.createElement)(O,{allowedBlocks:[r],className:"slides",currentItemIndex:u,parentBlockId:o,template:a}),(0,e.createElement)(M,{addSlide:()=>{const e=(0,P.createBlock)(r);m(e,void 0,o)},addSlideEnabled:c.length1,setCurrentPage:e=>d(e-1),totalPages:c.length}))};j.defaultProps={slideLimit:10,template:null},j.propTypes={parentBlockId:x().string.isRequired,allowedBlock:x().string.isRequired,template:x().array};const F=j;function L(n){const{onChange:o,opensInNewTab:r,url:l}=n,[i,a]=(0,t.useState)(!1),s=(0,t.useMemo)((()=>[{icon:"admin-links",title:(0,u.__)("Link","block-editor-components"),isActive:(null==l?void 0:l.length)>0,onClick:()=>a(!i)}]),[a,i,l]),d=(0,t.useMemo)((()=>({url:l,opensInNewTab:r})),[r,l]);return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(c.ToolbarGroup,{controls:s}),i&&(0,e.createElement)(c.Popover,null,(0,e.createElement)(v.__experimentalLinkControl,{forceIsEditingLink:i,opensInNewTab:r,value:d,onChange:o})))}function D(n){var o;const{className:r,limit:i=0,onChange:a,...c}=n,[s,u]=(0,t.useState)(i&&(null===(o=n.value)||void 0===o?void 0:o.length)>i);return(0,e.createElement)(v.PlainText,l({className:`${r} limit-text ${s?"invalid":""}`.trim(),onChange:e=>{i&&e.length>i?s||u(!0):(s&&u(!1),a(e))}},c))}const $=/[\r\n]+/g;function q(n){const{editPost:o}=(0,s.useDispatch)("core/editor"),r=(0,s.useSelect)((e=>e("core/editor").getEditedPostAttribute("title")),[]),i=(0,t.useCallback)((e=>o({title:e.replace($," ")})),[o]);return(0,e.createElement)(v.RichText,l({},n,{allowedFormats:[],value:r,onChange:i}))}function U(e){var t;const{postType:n}=e;return(0,s.useSelect)((e=>e("core/editor").getCurrentPostType()),[])===n?e.children:null!==(t=e.fallback)&&void 0!==t?t:null}const W=window.wp.dom;function H(n){var o;const{className:r,limit:i=0,onChange:a,...c}=n,s=(0,t.useRef)(),[u,d]=(0,t.useState)(i&&(null===(o=n.value)||void 0===o?void 0:o.length)>i),[p,m]=(0,t.useState)(!1);return(0,e.createElement)(v.RichText,l({ref:s,className:`${r} limit-text ${u?"invalid":""}`.trim(),onChange:e=>{if(i&&(0,W.__unstableStripHTML)(e).length>i)return m(!1),s.current.innerHTML=n.value,(e=>{const t=document.createRange();t.selectNodeContents(e),t.collapse(!1);const n=window.getSelection();n.removeAllRanges(),n.addRange(t)})(s.current),void(u||d(!0));p&&u&&d(!1),m(!0),a(e)}},c))}const z=/^is-style-/;function V(e){const{blockName:n,className:o}=(0,s.useSelect)((t=>{var n,o,r;const l=t("core/block-editor").getBlock(e);return{blockName:null!==(n=null==l?void 0:l.name)&&void 0!==n?n:"",className:null!==(o=null==l||null===(r=l.attributes)||void 0===r?void 0:r.className)&&void 0!==o?o:""}}),[e]),{blockStyles:r,defaultStyle:l}=G(n),i=(0,t.useMemo)((()=>r.map((e=>{let{name:t}=e;return t}))),[r]),a=(0,t.useMemo)((()=>function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").trim().replace(/\s+/," ").split(" ").map((e=>z.test(e)?e.replace(z,""):"")).filter(Boolean)}(o)),[o]);return(0,t.useMemo)((()=>{var e;return null!==(e=a.find((e=>i.includes(e))))&&void 0!==e?e:l}),[i,a,l])}function G(e){const n=(0,s.useSelect)((t=>t("core/blocks").getBlockStyles(e)),[e]);return(0,t.useMemo)((()=>{var e,t;return{blockStyles:n,defaultStyle:null!==(e=null===(t=n.find((e=>{let{isDefault:t}=e;return t})))||void 0===t?void 0:t.name)&&void 0!==e?e:""}}),[n])}function Q(e){return(0,t.useMemo)((()=>{const t=(0,P.getBlockTypes)();return null!=t&&t.length?t.filter((t=>{let{name:n,parent:o}=t;return!o&&!e.includes(n)})).map((e=>{let{name:t}=e;return t})):[]}),[e])}function Y(e,n){var o;const{editPost:r}=(0,s.useDispatch)("core/editor"),l=(0,s.useSelect)((e=>e("core/editor").getEditedPostAttribute("meta"))),i=(0,t.useCallback)((t=>r({meta:{[e]:t}})),[r,e]);return[null!==(o=null==l?void 0:l[e])&&void 0!==o?o:n,i]}function J(e,t,n){return(0,s.useSelect)((o=>{const{innerBlocks:r}=o("core/block-editor").getBlock(e);return(null==r?void 0:r.length){const n=document.getElementById(`block-${t}`);n&&(e(t),setTimeout((()=>n.scrollIntoView({behavior:"smooth"})),200))}),[e])}function X(e,n,o){return(0,t.useCallback)((function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o;return n({[e]:t})}),[e,o,n])}function Z(e){const{getBlocks:t}=(0,s.select)("core/block-editor");return t().find((t=>{let{name:n}=t;return n===e}))}function ee(e,t){return e.find((e=>!t(e)))}function te(e,t){return e.filter((e=>!t(e)))}function ne(e,t){return e.find((e=>t(e)))}function oe(e,t){return e.filter((e=>t(e)))}const re=window.wp.htmlEntities;function le(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const{id:n,title:o}=e;return{label:t+(0,re.decodeEntities)(o.rendered||(0,u.sprintf)((0,u.__)("#%d (no title)","block-editor-components"),n)),value:n}}function ie(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const{id:n,name:o}=e;return{label:t+(0,re.decodeEntities)(o||(0,u.sprintf)((0,u.__)("#%d (no name)","block-editor-components"),n)),value:n}}function ae(e){return e.map((e=>le(e)))}function ce(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"\u2014 ",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return e.map((e=>{let{children:o=[],...r}=e;return[le(r,t.repeat(n)),...ce(o,t,n+1)]})).flat()}function se(e){return e.map((e=>ie(e)))}function ue(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"\u2014 ",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return e.map((e=>{let{children:o=[],...r}=e;return[ie(r,t.repeat(n)),...ue(o,t,n+1)]})).flat()}function de(e){return(t,n)=>e.every((e=>t[e]===n[e]))}function pe(e){var t;if(null!==(t=e.variations)&&void 0!==t&&t.length){for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r(e.isActive=t,e)))}return e}})(),o})())); \ No newline at end of file diff --git a/dist/index.js.LICENSE.txt b/dist/index.js.LICENSE.txt deleted file mode 100644 index 827f273..0000000 --- a/dist/index.js.LICENSE.txt +++ /dev/null @@ -1,5 +0,0 @@ -/*! - Copyright (c) 2018 Jed Watson. - Licensed under the MIT License (MIT), see - http://jedwatson.github.io/classnames -*/ From 5c3dc57ea900527aa6504182e680524eca53c212 Mon Sep 17 00:00:00 2001 From: Matthew Haines-Young Date: Mon, 5 Jun 2023 17:03:25 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Don=E2=80=99t=20force=20add=20built=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 395d78d..ef09866 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "start": "webpack watch --mode development", "lint": "eslint .", "test": "jest", - "version": "npm run build && git add -f dist/" + "version": "npm run build" }, "devDependencies": { "@babel/plugin-proposal-class-properties": "^7.18.6",