PluginProbe
Getwid – Gutenberg Blocks / 3.0.1
Getwid – Gutenberg Blocks v3.0.1
3.0.2 3.0.1 3.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.2.0 trunk 1.8.7 1.9.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9
getwid / assets / blocks / circle-progress-bar / index.js

index.js in Getwid – Gutenberg Blocks 3.0.1, at assets/blocks/circle-progress-bar/index.js

1 lines 6.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (()=>{"use strict";var e={3165(){const e=window.wp.blocks,t=window.wp.i18n,r=window.GetwidComponents,i=window.wp.components,o=window.ReactJSXRuntime;function s(){return(0,o.jsx)(i.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,o.jsx)(i.Path,{d:"M12,22C6.49,22,2,17.51,2,12S6.49,2,12,2V0C5.37,0,0,5.37,0,12s5.37,12,12,12s12-5.37,12-12h-2C22,17.51,17.51,22,12,22z"})})}const n=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"textdomain":"getwid","name":"getwid/circle-progress-bar","description":"Shows progress in a circular indicator.","category":"getwid-blocks","title":"Circular Progress Bar","supports":{"align":["wide","full"]},"attributes":{"align":{"type":"string"},"wrapperAlign":{"type":"string"},"backgroundColor":{"type":"string","source":"attribute","selector":".wp-block-getwid-circle-progress-bar__wrapper","attribute":"data-background-color"},"textColor":{"type":"string","source":"attribute","selector":".wp-block-getwid-circle-progress-bar__wrapper","attribute":"data-text-color"},"fillAmount":{"type":"string","source":"attribute","selector":".wp-block-getwid-circle-progress-bar__wrapper","attribute":"data-fill-amount","default":"75"},"value":{"type":"string","source":"attribute","selector":".wp-block-getwid-circle-progress-bar__wrapper","attribute":"data-value"},"isAnimated":{"type":"string","source":"attribute","selector":".wp-block-getwid-circle-progress-bar__wrapper","attribute":"data-is-animated","default":"true"},"size":{"type":"string","source":"attribute","selector":".wp-block-getwid-circle-progress-bar__wrapper","attribute":"data-size","default":"200"},"thickness":{"type":"string","source":"attribute","selector":".wp-block-getwid-circle-progress-bar__wrapper","attribute":"data-thickness","default":"auto"}},"editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css","viewScript":["jquery","waypoints","file:./view.js"]}'),a=window.wp.blockEditor,l=window.wp.element;function c(e,t,r){const{backgroundColor:i,textColor:o,size:s,value:n}=t,a=e.getContext("2d");if(!a)return;const l=Number.parseFloat(s),c=l/2,u=Math.PI/180*-90,d=function(e){const t=Number.parseInt(e.thickness,10),r=Number.parseInt(e.size,10);return t||Number.parseInt(String(r/14),10)}(t);e.width=l,e.height=l,a.clearRect(0,0,l,l),a.beginPath(),a.arc(c,c,c-d/2,u,u+2*Math.PI),a.lineWidth=d,a.strokeStyle=i||"#eeeeee",a.stroke(),a.beginPath(),a.arc(c,c,c-d/2,u,u+2*Math.PI*(r/100)),a.lineWidth=d,a.strokeStyle=o||"#0000ee",a.stroke(),a.beginPath(),a.textAlign="center",a.font="16px serif",a.fillText(n||r+"%",c+6.5,c+5),a.stroke()}function u({attributes:e,setAttributes:s}){const{fillAmount:n,isAnimated:l,size:c,thickness:u,backgroundColor:d,textColor:p,value:g}=e,w=Number.parseInt(c,10),b=u||String(Math.round(w/14));return(0,o.jsx)(a.InspectorControls,{children:(0,o.jsxs)(i.PanelBody,{title:(0,t.__)("Settings","getwid"),initialOpen:!0,children:[(0,o.jsx)(i.RangeControl,{label:(0,t.__)("Progress","getwid"),value:Number.parseInt(n,10),onChange:e=>s({fillAmount:String(e??0)}),initialPosition:Number.parseInt(n,10),min:0,max:100,step:1}),(0,o.jsx)(i.RangeControl,{label:(0,t.__)("Size","getwid"),value:w,onChange:e=>{const t=e??50,r={size:String(t)};Number.parseInt(u,10)>w/2?s({...r,thickness:String(Math.floor(t/2))}):s(r)},initialPosition:w,min:50,max:600,step:1}),(0,o.jsx)(i.RangeControl,{label:(0,t.__)("Thickness","getwid"),value:Number.parseInt(b,10),onChange:e=>s({thickness:String(e??1)}),initialPosition:Number.parseInt(u,10),min:1,max:Math.floor(w/2),step:1}),(0,o.jsx)(i.TextControl,{label:(0,t.__)("Value","getwid"),value:g??"",onChange:e=>s({value:e})}),(0,o.jsx)(i.CheckboxControl,{label:(0,t.__)("Animate","getwid"),checked:"true"===l,onChange:e=>s({isAnimated:e?"true":"false"})}),(0,o.jsx)(r.CustomColorPalette,{colorSettings:[{title:(0,t.__)("Background Color","getwid"),colors:{customColor:d},changeColor:e=>s({backgroundColor:e})},{title:(0,t.__)("Bar Color","getwid"),colors:{customColor:p},changeColor:e=>s({textColor:e})}]})]})})}const d="wp-block-getwid-circle-progress-bar",p="wp-block-getwid-circle-progress-bar",g={to:[{type:"block",blocks:["getwid/counter"],transform:t=>(0,e.createBlock)("getwid/counter",{end:t.fillAmount})},{type:"block",blocks:["getwid/progress-bar"],transform:t=>(0,e.createBlock)("getwid/progress-bar",{fillAmount:t.fillAmount,isAnimated:"false"})}]};(0,e.registerBlockType)(n,{title:(0,t.__)("Circular Progress Bar","getwid"),icon:(0,o.jsx)(s,{}),transforms:g,edit:(0,r.MaybeBlockIsDisabled)("getwid/circle-progress-bar")||function(e){const{attributes:t,setAttributes:r}=e,{wrapperAlign:i}=t,s=(0,l.useRef)(null),n=(0,a.useBlockProps)();return(0,l.useEffect)(()=>{const e=s.current;if(e){if("true"===t.isAnimated){let r=0;const i=Number.parseInt(t.fillAmount,10),o=window.setInterval(()=>{c(e,t,r),r++,r>i&&window.clearInterval(o)},35);return()=>window.clearInterval(o)}c(e,t,Number.parseInt(t.fillAmount,10))}},[t]),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(a.BlockControls,{children:(0,o.jsx)(a.AlignmentToolbar,{value:i,onChange:e=>r({wrapperAlign:e})})}),(0,o.jsx)(u,{...e}),(0,o.jsx)("div",{...n,children:(0,o.jsx)("div",{className:`${d}__wrapper`,style:{textAlign:i||void 0},children:(0,o.jsx)("canvas",{ref:s,className:`${d}__canvas`})})})]})},save:function({attributes:e}){const{fillAmount:t,isAnimated:r,wrapperAlign:i,size:s,thickness:n,backgroundColor:l,textColor:c,value:u}=e,d=a.useBlockProps.save();return(0,o.jsx)("div",{...d,children:(0,o.jsx)("div",{className:`${p}__wrapper`,"data-background-color":l,"data-text-color":c,"data-fill-amount":t,"data-is-animated":r,"data-size":s,"data-thickness":n,"data-value":u,style:{textAlign:i||void 0},children:(0,o.jsx)("canvas",{className:`${p}__canvas`})})})}})}};const t={};function r(i){const o=t[i];if(void 0!==o)return o.exports;const s=t[i]={exports:{}};return e[i](s,s.exports,r),s.exports}r.m=e,(()=>{const e=[];r.O=(t,i,o,s)=>{if(i){s=s||0;for(var n=e.length;n>0&&e[n-1][2]>s;n--)e[n]=e[n-1];return void(e[n]=[i,o,s])}let a=1/0;for(n=0;n<e.length;n++){let[i,o,s]=e[n],c=!0;for(var l=0;l<i.length;l++)(!1&s||a>=s)&&Object.keys(r.O).every(e=>r.O[e](i[l]))?i.splice(l--,1):(c=!1,s<a&&(a=s));if(c){e.splice(n--,1);const r=o();void 0!==r&&(t=r)}}return t}})(),r.o=(e,t)=>Object.hasOwn(e,t),(()=>{const e={7324:0,7396:0};r.O.j=t=>0===e[t];const t=(t,i)=>{let[o,s,n]=i;var a,l,c=0;if(o.some(t=>0!==e[t])){for(a in s)r.o(s,a)&&(r.m[a]=s[a]);if(n)var u=n(r)}for(t&&t(i);c<o.length;c++)l=o[c],r.o(e,l)&&e[l]&&e[l][0](),e[l]=0;return r.O(u)},i=globalThis.webpackChunkgetwid||=[];i.forEach(t.bind(null,0)),i.push=t.bind(null,i.push.bind(i))})();let i=r.O(void 0,[7396],()=>r(3165));i=r.O(i)})();