2024-10-19 18:25:59 +08:00

2 lines
15 KiB
JavaScript

var e={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1};function t(e){var t=Object.create(null);return function(o){return void 0===t[o]&&(t[o]=e(o)),t[o]}}var o=/[A-Z]|^ms/g,n=/_EMO_([^_]+?)_([^]*?)_EMO_/g,i=function(e){return 45===e.charCodeAt(1)},l=function(e){return null!=e&&"boolean"!=typeof e},a=t((function(e){return i(e)?e:e.replace(o,"-$&").toLowerCase()})),s=function(t,o){switch(t){case"animation":case"animationName":if("string"==typeof o)return o.replace(n,(function(e,t,o){return d={name:t,styles:o,next:d},t}))}return 1===e[t]||i(t)||"number"!=typeof o||0===o?o:o+"px"};function r(e,t,o){if(null==o)return"";var n=o;if(void 0!==n.__emotion_styles)return n;switch(typeof o){case"boolean":return"";case"object":var i=o;if(1===i.anim)return d={name:i.name,styles:i.styles,next:d},i.name;var c=o;if(void 0!==c.styles){var u=c.next;if(void 0!==u)for(;void 0!==u;)d={name:u.name,styles:u.styles,next:d},u=u.next;return c.styles+";"}return function(e,t,o){var n="";if(Array.isArray(o))for(var i=0;i<o.length;i++)n+=r(e,t,o[i])+";";else for(var d in o){var c=o[d];if("object"!=typeof c){var u=c;l(u)&&(n+=a(d)+":"+s(d,u)+";")}else if(Array.isArray(c)&&"string"==typeof c[0]&&null==t)for(var f=0;f<c.length;f++)l(c[f])&&(n+=a(d)+":"+s(d,c[f])+";");else{var m=r(e,t,c);switch(d){case"animation":case"animationName":n+=a(d)+":"+m+";";break;default:n+=d+"{"+m+"}"}}}return n}(e,t,o)}return o}var d,c=/label:\s*([^\s;\n{]+)\s*(;|$)/g;function u(e,t,o){if(1===e.length&&"object"==typeof e[0]&&null!==e[0]&&void 0!==e[0].styles)return e[0];var n=!0,i="";d=void 0;var l=e[0];null==l||void 0===l.raw?(n=!1,i+=r(o,t,l)):i+=l[0];for(var a=1;a<e.length;a++){if(i+=r(o,t,e[a]),n)i+=l[a]}c.lastIndex=0;for(var s,u="";null!==(s=c.exec(i));)u+="-"+s[1];var f=function(e){for(var t,o=0,n=0,i=e.length;i>=4;++n,i-=4)t=1540483477*(65535&(t=255&e.charCodeAt(n)|(255&e.charCodeAt(++n))<<8|(255&e.charCodeAt(++n))<<16|(255&e.charCodeAt(++n))<<24))+(59797*(t>>>16)<<16),o=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&o)+(59797*(o>>>16)<<16);switch(i){case 3:o^=(255&e.charCodeAt(n+2))<<16;case 2:o^=(255&e.charCodeAt(n+1))<<8;case 1:o=1540483477*(65535&(o^=255&e.charCodeAt(n)))+(59797*(o>>>16)<<16)}return(((o=1540483477*(65535&(o^=o>>>13))+(59797*(o>>>16)<<16))^o>>>15)>>>0).toString(36)}(i)+u;return{name:f,styles:i,next:d}}const f=e=>{if(!e)return"";return u([e]).styles},m=e=>{if(!e)return"";return u(e).styles},h=(e,t)=>{if(!e)return;if(!t)return;const o=u([t]);e.style.cssText=o.styles};function p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var g,y,C,S={};var v=p(function(){if(C)return S;C=1;var e=S&&S.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(S,"__esModule",{value:!0}),S.default=function(e,o){var n=null;if(!e||"string"!=typeof e)return n;var i=(0,t.default)(e),l="function"==typeof o;return i.forEach((function(e){if("declaration"===e.type){var t=e.property,i=e.value;l?o(t,i,e):i&&((n=n||{})[t]=i)}})),n};var t=e(function(){if(y)return g;y=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,o=/^\s*/,n=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,s=/^\s+|\s+$/g,r="";function d(e){return e?e.replace(s,r):r}return g=function(s,c){if("string"!=typeof s)throw new TypeError("First argument must be a string");if(!s)return[];c=c||{};var u=1,f=1;function m(e){var o=e.match(t);o&&(u+=o.length);var n=e.lastIndexOf("\n");f=~n?e.length-n:f+e.length}function h(){var e={line:u,column:f};return function(t){return t.position=new p(e),C(),t}}function p(e){this.start=e,this.end={line:u,column:f},this.source=c.source}function g(e){var t=new Error(c.source+":"+u+":"+f+": "+e);if(t.reason=e,t.filename=c.source,t.line=u,t.column=f,t.source=s,!c.silent)throw t}function y(e){var t=e.exec(s);if(t){var o=t[0];return m(o),s=s.slice(o.length),t}}function C(){y(o)}function S(e){var t;for(e=e||[];t=v();)!1!==t&&e.push(t);return e}function v(){var e=h();if("/"==s.charAt(0)&&"*"==s.charAt(1)){for(var t=2;r!=s.charAt(t)&&("*"!=s.charAt(t)||"/"!=s.charAt(t+1));)++t;if(t+=2,r===s.charAt(t-1))return g("End of comment missing");var o=s.slice(2,t-2);return f+=2,m(o),s=s.slice(t),f+=2,e({type:"comment",comment:o})}}function x(){var t=h(),o=y(n);if(o){if(v(),!y(i))return g("property missing ':'");var s=y(l),c=t({type:"declaration",property:d(o[0].replace(e,r)),value:s?d(s[0].replace(e,r)):r});return y(a),c}}return p.prototype.content=s,C(),function(){var e,t=[];for(S(t);e=x();)!1!==e&&(t.push(e),S(t));return t}()}}());return S}()),x=v.default||v;const w=e=>e?"string"==typeof e?document.querySelector(e):e:null,E=(e,t,o)=>{e&&(t&&e.classList.add(t),o&&"string"==typeof o?e.style.cssText=o:o&&h(e,o))},b=(e,t,o,n)=>{if(!e)return;t&&e.classList.add(t);let i={...n};o&&"string"==typeof o?i={...n,...x(o)}:o&&"object"==typeof o&&(i={...n,...o}),h(e,i)};let k=e=>crypto.getRandomValues(new Uint8Array(e)),O=(e,t=21)=>((e,t,o)=>{let n=(2<<Math.log(e.length-1)/Math.LN2)-1,i=-~(1.6*n*t/e.length);return(l=t)=>{let a="";for(;;){let t=o(i),s=i;for(;s--;)if(a+=e[t[s]&n]||"",a.length===l)return a}}})(e,t,k);const T="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",N=O("0123456789abcdefghijklmnopqrstuvwxyz",6),F=O(T,12),D=(e=6)=>"b-"+N(e),L=(e=6)=>F(e);function A(e){const t=/\{\{\s*(.*?)\s*\}\}/g,o=[];let n;for(;null!==(n=t.exec(e));)o.push(n[1]);return o}const M=(e,t,o=!0)=>{const n=window.history;"string"==typeof e?n.pushState({key:"default",usr:t},"",e):n.pushState({key:"default",usr:t},"",e.pathname),o&&window.dispatchEvent(new Event("popstate"))},_={push:M},j=e=>null==e||"{}"===JSON.stringify(e),I=e=>{let t;const o=new Set,n=(e,n)=>{const i="function"==typeof e?e(t):e;if(!Object.is(i,t)){const e=t;t=(null!=n?n:"object"!=typeof i||null===i)?i:Object.assign({},t,i),o.forEach((o=>o(t,e)))}},i=()=>t,l={setState:n,getState:i,getInitialState:()=>a,subscribe:e=>(o.add(e),()=>o.delete(e))},a=t=e(n,i,l);return l},R=e=>e?I(e):I,H=R(((e,t)=>({modals:[],getModal:e=>t().modals.find((t=>t.id===e))}))),z={},G=e=>{const t=e.target;if(t){if(t.classList.contains("ui-modal-mask")){const o=H.getState().modals.find((e=>e.id===t.dataset.id));return o&&o.open&&o.onMaskClose(e),void e.preventDefault()}}else console.log("target is null")};class q{static rootClassName="#ui-modal-list";root;id;modalElement;Element;mask;maskClassName;maskStyle;maskClose;contentClassName;contentStyle;destroyOnClose;hideOnClose;open;isUse=!0;onClose;cacheFragment;defaultStyle;constructor(e){this.root=this.initRoot(e.root),(e=>{const t=e.id;z[t]&&e===z[t]||(z[t]&&z[t].removeEventListener("click",G),z[t]=null,e.addEventListener("click",G),z[t]=e)})(this.root),this.id=e.id||D(),this.mask=e.mask??!0,this.maskClassName=e.maskClassName,this.maskStyle=e.maskStyle,this.maskClose=e.maskClose??!0,this.contentClassName=e.contentClassName,this.contentStyle=e.contentStyle,this.destroyOnClose=e.destroyOnClose??!0,this.hideOnClose=e.hideOnClose??!0,this.destroyOnClose||this.hideOnClose||(this.destroyOnClose=!0,console.warn("destroyOnClose Or hideOnClose must one is true")),this.cacheFragment=new DocumentFragment,this.defaultStyle=e.defaultStyle||{},this.open=e.open??!0,this.onClose=e.onClose}initRoot(e){let t=w(e);if(!t){const e=document.querySelector("#ui-modal-list");return e?(t=e,t.classList.add("ui-modal-root"),t):(t=document.createElement("div"),t.id="ui-modal-list",t.classList.add("ui-modal-root"),document.body.appendChild(t),t)}return t.classList.add("ui-custom-modal","ui-modal-root"),t.id||(t.id="ui-modal"+D()),t}static render(...e){let[t,o,n]=e;const i=w(t);if(!i)return void console.warn("el is not exist",t);let l,a="";"string"==typeof o&&o?a=o:"object"==typeof o&&(a=o.id,n=o,o=o.id);const s=H.getState();if(a&&(l=H.getState().getModal(a)),!l){const e=new this({id:o,...n});l=e,H.setState({modals:[...s.modals,e]})}return l.renderEl(i),l}static create(e){let t,o=e.id;const n=H.getState();if(o&&(t=H.getState().getModal(o)),!t){const i=new this({...e,id:o});t=i,H.setState({modals:[...n.modals,i]})}return t}createMask(){const e=document.createElement("div");return e.classList.add("ui-modal-mask"),e.dataset.id=this.id,b(e,this.maskClassName,this.maskStyle,this.defaultStyle?.defaultMaskStyle),e}renderEl(e){const t=this.defaultStyle?.defaultContentStyle||{position:"absolute",padding:"20px",left:"50%",top:"20%",width:"600px",background:"#fff",borderRadius:"5px",boxShadow:"0 0 10px rgba(0,0,0,.1)",transform:"translate(-50%, -50%)",maxHeight:"80vh",overflow:"auto"},o=document.createDocumentFragment(),n=document.createElement("div");if(n.classList.add("ui-modal-wrapper"),n.id=this.id,n.dataset.mid=this.id,this.mask){const e=this.createMask();n.appendChild(e)}const i=document.createElement("div");return i.classList.add("ui-modal-content"),b(i,this.contentClassName,this.contentStyle,t),i.appendChild(e),n.appendChild(i),o.appendChild(n),this.modalElement=n,this.Element=e,this.appendRoot(o),this}appendRoot(e){this.root.appendChild(e),this.setOpen(this.open)}setOpen(e){this.open=e,this.destroyOnClose?e?this.root.appendChild(this.modalElement):this.cacheFragment.appendChild(this.modalElement):this.hideOnClose&&(e?this.modalElement.classList.remove("ui-modal-close"):this.modalElement.classList.add("ui-modal-close"))}unMount(){const e=document.createDocumentFragment();e.appendChild(this.Element),this.modalElement?.remove();const t=H.getState();return H.setState({modals:t.modals.filter((e=>e.id!==this.id))}),this.isUse=!1,this.cacheFragment=new DocumentFragment,e}reRender(e,t){if(e){if(this.modalElement?.remove?.(),this.modalElement=void 0,!this.Element)return;this.renderEl(this.Element)}}async onMaskClose(e){this.maskClose&&(this.setOpen(!1),this.onClose?.(e))}setDefaultStyle(e,t){this.defaultStyle[e]=t}}class W extends q{constructor(e){super(e)}}class P extends q{dialogTitle;dialogTitleClassName;dialogTitleStyle;dialogTitleEl;dialogTitleCloseIcon;dialogContentClassName;dialogContentStyle;dialogFooterShow;dialogFooterClassName;dialogFooterStyle;constructor(e){super(e),this.dialogTitle=e.dialogTitle,this.dialogTitleClassName=e.dialogTitleClassName,this.dialogTitleStyle=e.dialogTitleStyle,this.dialogTitleEl=e.dialogTitleEl,this.dialogTitleCloseIcon=e.dialogTitleCloseIcon,this.dialogContentClassName=e.dialogContentClassName,this.dialogContentStyle=e.dialogContentStyle,this.dialogFooterClassName=e.dialogFooterClassName,this.dialogFooterStyle=e.dialogFooterStyle,this.dialogFooterShow=e.dialogFooterShow??!1,this.setDefaultStyle("defaultContentStyle",{position:"absolute",padding:"0px",left:"50%",top:"20%",width:"600px",background:"#fff",borderRadius:"5px",boxShadow:"0 0 10px rgba(0,0,0,.1)",transform:"translate(-50%, -50%)",maxHeight:"80vh",overflow:"auto",...e?.defaultStyle?.defaultContentStyle}),this.setDefaultStyle("defaultDialogTitleStyle",{display:"flex",justifyContent:"space-between",alignItems:"center",position:"sticky",padding:"10px 20px",top:"0",fontSize:"16px",background:"#fff",marginTop:"-10px",borderBottom:"1px solid #f0f0f0",marginBottom:"5px",...e?.defaultStyle?.defaultDialogTitleStyle}),this.setDefaultStyle("defaultDialogContentStyle",{padding:"20px",...e?.defaultStyle?.defaultDialogContentStyle}),this.setDefaultStyle("defaultDialogFooterStyle",{display:"flex",justifyItems:"end",borderTop:"1px solid #f0f0f0",padding:"10px 20px",...e?.defaultStyle?.defaultDialogFooterStyle})}appendRoot(e){const t=document.createDocumentFragment();t.appendChild(this.Element);const o=e.querySelector(".ui-modal-content");o.classList.add("ui-modal-dialog");const n=document.createElement("div");if(n.classList.add("ui-modal-dialog-title"),b(n,this.dialogTitleClassName,this.dialogTitleStyle,this.defaultStyle.defaultDialogTitleStyle),this.dialogTitleEl?n.appendChild(this.dialogTitleEl):n.innerText=this.dialogTitle,this.dialogTitleCloseIcon){const e=document.createElement("span");e.className="ui-modal-dialog-close",e.innerHTML="&times;",e.style.cssText="\n cursor: pointer;\n font-size: 24px;\n margin: -5px 10px 0 0;\n ",e.onclick=e=>{this.setOpen(!1)},n.appendChild(e)}o.appendChild(n);const i=document.createElement("div");if(i.className="ui-modal-dialog-content",b(i,this.dialogContentClassName,this.dialogContentStyle,this.defaultStyle.defaultDialogContentStyle),i.appendChild(t),this.dialogFooterShow){const e=document.createElement("div");e.className="ui-modal-dialog-footer",b(e,this.dialogFooterClassName,this.dialogFooterStyle,this.defaultStyle.defaultDialogFooterStyle),o.appendChild(e)}o.appendChild(i),super.appendRoot(e)}renderEl(e){return super.renderEl(e)}renderFooter(e){const t=w(e);if(!t)return;const o=this.Element.querySelector(".ui-modal-dialog-footer");o&&(o.innerHTML="",o.appendChild(t))}renerContent(e){const t=w(e);if(!t)return;const o=this.Element.querySelector(".ui-modal-dialog-content");o&&(o.innerHTML="",o.appendChild(t))}}function U(e){if(null==e||"boolean"==typeof e)return console.warn("Invalid JSX element:",e),null;const{type:t,props:o}=e;if(t===Symbol.for("react.fragment")){const e=document.createDocumentFragment();if(o.children)if(Array.isArray(o.children))o.children.forEach((t=>{const o=U(t);o&&e.appendChild(o)}));else{const t=U(o.children);t&&e.appendChild(t)}return e}const n=document.createElement(t);return Object.keys(o).forEach((e=>{if("children"===e){if(Array.isArray(o.children))o.children.forEach((e=>{const t=U(e);t&&n.appendChild(t)}));else if("string"==typeof o.children)n.appendChild(document.createTextNode(o.children));else if("object"==typeof o.children&&null!==o.children){const e=U(o.children);e&&n.appendChild(e)}}else if(e.startsWith("on")){const t=e.slice(2).toLowerCase();n.addEventListener(t,o[e])}else"style"===e&&"object"==typeof o[e]?Object.assign(n.style,o[e]):"dangerouslySetInnerHTML"===e?o[e]&&"string"==typeof o[e].__html?n.innerHTML=o[e].__html:console.warn("Invalid dangerouslySetInnerHTML content:",o[e]):"ref"===e?console.warn("Ref prop is not supported in manual DOM creation"):"key"===e?console.warn("Key prop is not applicable in manual DOM creation"):n.setAttribute(e,o[e])})),n}export{W as BlankModal,P as DialogModal,q as Modal,T as alphabetLetterAll,U as createDOMElement,R as createStore,F as customNanoid,E as elAddCS,b as elAddCS2,A as extractKeysFromBraces,L as generate,D as generateId,N as generateId6,f as getCssText,m as getCssTextObjs,_ as history,j as isObjectNull,H as modalStore,h as obj2css,M as push,w as querySelector};