2 lines
4.0 KiB
JavaScript
2 lines
4.0 KiB
JavaScript
/*! This file is auto-generated */
|
|
(()=>{"use strict";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{compileCSS:()=>m,getCSSRules:()=>f});const n=window.lodash,o="var:",r="|",a="--";function i(e,t,o,r){const a=(0,n.get)(e,o);return a?[{selector:t?.selector,key:r,value:l(a)}]:[]}function g(e,t,o,r,a=["top","right","bottom","left"]){const i=(0,n.get)(e,o);if(!i)return[];const g=[];if("string"==typeof i)g.push({selector:t?.selector,key:r.default,value:i});else{const e=a.reduce(((e,o)=>{const a=l((0,n.get)(i,[o]));return a&&e.push({selector:t?.selector,key:r?.individual.replace("%s",s(o)),value:a}),e}),[]);g.push(...e)}return g}function l(e){if("string"==typeof e&&e.startsWith(o)){return`var(--wp--${e.slice(o.length).split(r).map((e=>(0,n.kebabCase)(e))).join(a)})`}return e}function s(e){const[t,...n]=e;return t.toUpperCase()+n.join("")}function u(e){return(t,n)=>i(t,n,e,function(e){const[t,...n]=e;return t.toLowerCase()+n.map(s).join("")}(e))}function c(e){return(t,n)=>["color","style","width"].flatMap((o=>u(["border",e,o])(t,n)))}const d={name:"radius",generate:(e,t)=>g(e,t,["border","radius"],{default:"borderRadius",individual:"border%sRadius"},["topLeft","topRight","bottomLeft","bottomRight"])},p=[...[{name:"color",generate:u(["border","color"])},{name:"style",generate:u(["border","style"])},{name:"width",generate:u(["border","width"])},d,{name:"borderTop",generate:c("top")},{name:"borderRight",generate:c("right")},{name:"borderBottom",generate:c("bottom")},{name:"borderLeft",generate:c("left")}],...[{name:"text",generate:(e,t)=>i(e,t,["color","text"],"color")},{name:"gradient",generate:(e,t)=>i(e,t,["color","gradient"],"background")},{name:"background",generate:(e,t)=>i(e,t,["color","background"],"backgroundColor")}],...[{name:"minHeight",generate:(e,t)=>i(e,t,["dimensions","minHeight"],"minHeight")}],...[{name:"color",generate:(e,t,n=["outline","color"],o="outlineColor")=>i(e,t,n,o)},{name:"style",generate:(e,t,n=["outline","style"],o="outlineStyle")=>i(e,t,n,o)},{name:"offset",generate:(e,t,n=["outline","offset"],o="outlineOffset")=>i(e,t,n,o)},{name:"width",generate:(e,t,n=["outline","width"],o="outlineWidth")=>i(e,t,n,o)}],...[{name:"margin",generate:(e,t)=>g(e,t,["spacing","margin"],{default:"margin",individual:"margin%s"})},{name:"padding",generate:(e,t)=>g(e,t,["spacing","padding"],{default:"padding",individual:"padding%s"})}],...[{name:"fontFamily",generate:(e,t)=>i(e,t,["typography","fontFamily"],"fontFamily")},{name:"fontSize",generate:(e,t)=>i(e,t,["typography","fontSize"],"fontSize")},{name:"fontStyle",generate:(e,t)=>i(e,t,["typography","fontStyle"],"fontStyle")},{name:"fontWeight",generate:(e,t)=>i(e,t,["typography","fontWeight"],"fontWeight")},{name:"letterSpacing",generate:(e,t)=>i(e,t,["typography","letterSpacing"],"letterSpacing")},{name:"lineHeight",generate:(e,t)=>i(e,t,["typography","lineHeight"],"lineHeight")},{name:"textColumns",generate:(e,t)=>i(e,t,["typography","textColumns"],"columnCount")},{name:"textDecoration",generate:(e,t)=>i(e,t,["typography","textDecoration"],"textDecoration")},{name:"textTransform",generate:(e,t)=>i(e,t,["typography","textTransform"],"textTransform")}],...[{name:"shadow",generate:(e,t)=>i(e,t,["shadow"],"boxShadow")}]];function m(e,t={}){const o=f(e,t);if(!t?.selector){const e=[];return o.forEach((t=>{e.push(`${(0,n.kebabCase)(t.key)}: ${t.value};`)})),e.join(" ")}const r=o.reduce(((e,t)=>{const{selector:n}=t;return n?(e[n]||(e[n]=[]),e[n].push(t),e):e}),{});return Object.keys(r).reduce(((e,t)=>(e.push(`${t} { ${r[t].map((e=>`${(0,n.kebabCase)(e.key)}: ${e.value};`)).join(" ")} }`),e)),[]).join("\n")}function f(e,t={}){const n=[];return p.forEach((o=>{"function"==typeof o.generate&&n.push(...o.generate(e,t))})),n}(window.wp=window.wp||{}).styleEngine=t})(); |