码桶
发现社区成员的开源项目
index-VbOLTMR0.js2.1 KB
import{Y as v,ac as E,R as r,a5 as O,T as x}from"./index-GWuvg2UH.js";const N={PREFIX:`${v}-empty`};var M=function(i,a){var s={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&a.indexOf(e)<0&&(s[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(i);t<e.length;t++)a.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(i,e[t])&&(s[e[t]]=i[e[t]]);return s};const o=N.PREFIX;class S extends E{constructor(a){super(a),this.observe=s=>{for(const e of s)e.type==="attributes"&&e.attributeName==="theme-mode"&&this.updateMode()},this.updateMode=()=>{const s=this.body.getAttribute("theme-mode");s!==this.state.mode&&this.setState({mode:s})},this.state={mode:null}}componentDidMount(){if(this.props.darkModeImage){this.body=window.document.body,this.updateMode();const a={attributes:!0,childList:!1,subtree:!1};this.observer=new MutationObserver(this.observe),this.observer.observe(this.body,a)}}componentWillUnmount(){this.observer&&this.observer.disconnect()}render(){const a=this.props,{className:s,image:e,description:t,style:u,title:c,imageStyle:h,children:d,layout:m,darkModeImage:p}=a,y=M(a,["className","image","description","style","title","imageStyle","children","layout","darkModeImage"]),f=typeof t=="string"?t:"empty",n=this.state.mode==="dark"&&p?p:e;let l=null;typeof n=="string"?l=r.createElement("img",{alt:f,src:n}):n&&"id"in n?l=r.createElement("svg",{"aria-hidden":"true"},r.createElement("use",{xlinkHref:`#${n.id}`})):l=n;const g=O(s,o,{[`${o}-${m}`]:m}),b=l?{heading:4}:{heading:6,style:{fontWeight:400}};return r.createElement("div",Object.assign({className:g,style:u},this.getDataAttr(y)),r.createElement("div",{className:`${o}-image`,style:h,"x-semi-prop":"image,darkModeImage"},l),r.createElement("div",{className:`${o}-content`},c?r.createElement(x.Title,Object.assign({},b,{className:`${o}-title`,"x-semi-prop":"title"}),c):null,t?r.createElement("div",{className:`${o}-description`,"x-semi-prop":"description"},t):null,d?r.createElement("div",{className:`${o}-footer`,"x-semi-prop":"children"},d):null))}}S.defaultProps={layout:"vertical"};export{S as E};