mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2025-04-05 19:42:07 +08:00
2 lines
1.4 KiB
JavaScript
2 lines
1.4 KiB
JavaScript
function B($){let t=".",m="__",d="--",b;{let e=$.blockPrefix;e&&(t=e),e=$.elementPrefix,e&&(m=e),e=$.modifierPrefix,e&&(d=e)}const c={install(e){b=e.c;const i=e.context;i.bem={},i.bem.b=null,i.bem.els=null}};function o(e){let i,n;return{before(l){i=l.bem.b,n=l.bem.els,l.bem.els=null},after(l){l.bem.b=i,l.bem.els=n},$({context:l,props:f}){return e=typeof e=="string"?e:e({context:l,props:f}),l.bem.b=e,`${(f==null?void 0:f.bPrefix)||t}${l.bem.b}`}}}function s(e){let i;return{before(n){i=n.bem.els},after(n){n.bem.els=i},$({context:n,props:l}){return e=typeof e=="string"?e:e({context:n,props:l}),n.bem.els=e.split(",").map(f=>f.trim()),n.bem.els.map(f=>`${(l==null?void 0:l.bPrefix)||t}${n.bem.b}${m}${f}`).join(", ")}}}function P(e){return{$({context:i,props:n}){e=typeof e=="string"?e:e({context:i,props:n});const l=e.split(",").map(u=>u.trim());function f(u){return l.map(M=>`&${(n==null?void 0:n.bPrefix)||t}${i.bem.b}${u!==void 0?`${m}${u}`:""}${d}${M}`).join(", ")}const r=i.bem.els;return r!==null?f(r[0]):f()}}}function _(e){return{$({context:i,props:n}){e=typeof e=="string"?e:e({context:i,props:n});const l=i.bem.els;return`&:not(${(n==null?void 0:n.bPrefix)||t}${i.bem.b}${l!==null&&l.length>0?`${m}${l[0]}`:""}${d}${e})`}}}return Object.assign(c,{cB:(...e)=>b(o(e[0]),e[1],e[2]),cE:(...e)=>b(s(e[0]),e[1],e[2]),cM:(...e)=>b(P(e[0]),e[1],e[2]),cNotM:(...e)=>b(_(e[0]),e[1],e[2])}),c}export{B as p};
|