visual-blueprint-builder/build/steps/write-file/index.js
GitHub Action defbf3f0f4 Add files
2025-10-02 15:51:11 +00:00

1 line
No EOL
2.6 KiB
JavaScript

(()=>{"use strict";const e=window.wp.i18n,t=window.wp.blocks,r=window.wp.primitives,l=window.ReactJSXRuntime,i=(0,l.jsxs)(r.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[(0,l.jsx)(r.Path,{d:"M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"}),(0,l.jsx)(r.Path,{d:"M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"})]}),o=window.wp.blockEditor,n=window.wp.components,a=JSON.parse('{"UU":"playground-step/write-file","DD":"Write File"}');(0,t.registerBlockType)(a.UU,{icon:i,edit:function({attributes:t,setAttributes:r,isSelected:p}){const{path:s,data:d}=t,u="string"==typeof d?"string":"url",_="string"==typeof d?d:"",c="object"==typeof d&&d?.url?d.url:"";return(0,l.jsx)("p",{...(0,o.useBlockProps)(),children:(0,l.jsx)(n.Placeholder,{preview:(0,l.jsxs)(n.__experimentalVStack,{style:{width:"100%"},children:[(0,l.jsxs)(n.__experimentalHStack,{justify:"left",align:"center",spacing:3,children:[(0,l.jsx)(n.Icon,{icon:i,size:28,className:"step-icon"}),(0,l.jsxs)(n.__experimentalVStack,{spacing:1,children:[(0,l.jsx)(n.__experimentalText,{upperCase:!0,size:12,weight:500,color:"#949494",children:a.DD}),!p&&(0,l.jsxs)(n.__experimentalText,{weight:600,children:[(0,e.__)("write file at","wp-playground-blueprint-editor")," ",s]})]})]}),p&&(0,l.jsxs)(n.__experimentalVStack,{spacing:3,children:[(0,l.jsx)(n.TextControl,{label:(0,e.__)("Path","wp-playground-blueprint-editor"),value:s||"",placeholder:(0,e.__)("The path of the file to write to","wp-playground-blueprint-editor"),onChange:e=>r({path:e})}),(0,l.jsxs)(n.__experimentalToggleGroupControl,{label:(0,e.__)("Data","wp-playground-blueprint-editor"),value:u,onChange:e=>{e!==u&&r("string"===e?{data:_||""}:{data:{resource:"url",url:c||""}})},__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,isBlock:!0,children:[(0,l.jsx)(n.__experimentalToggleGroupControlOption,{value:"string",label:(0,e.__)("Text","wp-playground-blueprint-editor")}),(0,l.jsx)(n.__experimentalToggleGroupControlOption,{value:"url",label:(0,e.__)("File URL","wp-playground-blueprint-editor")})]}),"string"===u?(0,l.jsx)(n.TextareaControl,{__nextHasNoMarginBottom:!0,label:(0,e.__)("Content","wp-playground-blueprint-editor"),hideLabelFromVision:!0,onChange:e=>r({data:e}),placeholder:(0,e.__)("The data to write","wp-playground-blueprint-editor"),value:_,rows:6}):(0,l.jsx)(n.TextControl,{label:(0,e.__)("File URL","wp-playground-blueprint-editor"),hideLabelFromVision:!0,value:c,placeholder:(0,e.__)("https://example.com/file.txt","wp-playground-blueprint-editor"),onChange:e=>{r({data:{resource:"url",url:e}})},type:"url"})]})]})})})}})})();