Files
bim_engine/dist/bim-engine-sdk.umd.js

9 lines
33 KiB
JavaScript
Raw Normal View History

(function(){"use strict";try{if(typeof document<"u"){var o=document.createElement("style");o.appendChild(document.createTextNode('.bim-engine-wrapper{position:relative;width:100%;height:100%;font-family:sans-serif;color:#333;padding:20px;background-color:#e16969;border-radius:8px;border:1px solid #e0e0e0;box-sizing:border-box}.bim-engine-opt-btn-container{position:absolute;bottom:20px;left:50%;transform:translate(-50%);z-index:100}.bim-btn-group-root{display:flex;gap:8px;z-index:1000;position:absolute;pointer-events:auto}.bim-btn-group-root.static{position:relative;inset:auto;transform:none}.bim-btn-group-root.dir-row{flex-direction:row;align-items:center}.bim-btn-group-root.dir-column{flex-direction:column;align-items:stretch}.bim-btn-group-section{display:flex;gap:4px;background-color:var(--bim-btn-group-section-bg, rgba(17, 17, 17, .88));border-radius:6px;padding:4px}.bim-btn-group-root.dir-row .bim-btn-group-section{flex-direction:row;align-items:center}.bim-btn-group-root.dir-column .bim-btn-group-section{flex-direction:column}.opt-btn-wrapper{position:relative}.opt-btn{display:flex;cursor:pointer;border-radius:4px;transition:background-color .2s,color .2s;color:var(--bim-btn-text-color, #ccc);background-color:var(--bim-btn-bg, transparent);padding:6px;align-items:center;position:relative;justify-content:center}.opt-btn:hover{background-color:var(--bim-btn-hover-bg, #444)}.opt-btn.active{background-color:var(--bim-btn-active-bg, rgba(255, 255, 255, .15));color:var(--bim-btn-text-active-color, #fff)}.opt-btn.active .opt-btn-icon{color:var(--bim-icon-active-color, #fff)}.opt-btn.disabled{opacity:.5;cursor:not-allowed}.opt-btn-icon{width:var(--bim-icon-size, 24px);height:var(--bim-icon-size, 24px);display:flex;align-items:center;justify-content:center;color:var(--bim-icon-color, #ccc);flex-shrink:0}.opt-btn-icon svg{width:100%;height:100%;fill:currentColor}.opt-btn-arrow{font-size:10px;opacity:.6;transition:transform .2s;display:inline-block;margin-left:4px}.opt-btn-arrow.rotated{transform:rotate(180deg)}.opt-btn-text-wrapper{display:flex;align-items:center;justify-content:center;pointer-events:none}.opt-btn-label{display:inline}.opt-btn.no-label .opt-btn-label{display:none}.opt-btn.align-vertical:not(.no-label){flex-direction:column;text-align:center}.opt-btn.align-vertical:not(.no-label) .opt-btn-text-wrapper{margin-top:4px}.opt-btn.align-vertical:not(.no-label) .opt-btn-label{font-size:12px;line-height:1.2}.opt-btn.align-horizontal:not(.no-label){flex-direction:row}.opt-btn.align-horizontal:not(.no-label) .opt-btn-text-wrapper{margin-left:8px}.opt-btn.align-horizontal:not(.no-label) .opt-btn-label{font-size:14px}.opt-btn.no-label .opt-btn-text-wrapper{width:0;height:0;margin:0;padding:0;overflow:visible;position:absolute;top:0;right:0}.opt-btn.no-label .opt-btn-arrow{position:absolute;top:2px;right:2px;margin:0;font-size:8px}.opt-btn-dropdown{position:absolute;background-color:var(--bim-toolbar-bg, rgba(17, 17, 17, .95));border-radius:4px;padding:4px;box-shadow:0 4px 12px #0003;z-index:1001;display:flex;flex-direction:column;border:1px solid rgba(255,255,255,.1);opacity:0;visibility:hidden;transform:translateY(-10px);transition:opacity .2s ease,transform .2s cubic-bezier(.2,0,.2,1),visibility .2s}@keyframes dropdown-fade-in{0%{opacity:0;transform:translateY(-8px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}.opt-btn-dropdown{animation:dropdown-fade-in .2s cubic-bezier(.2,0,.2,1) forwards;opacity:1;visibility:visible;transform:none}.opt-btn-dropdown-item{display:flex;align-items:center;padding:8px 12px;cursor:pointer;border-radius:4px;color:var(--bim-btn-text-color, #ccc);transition:background .2s;box-sizing:border-box}.opt-btn-dropdown-item:hover{background-color:var(--bim-btn-hover-bg, #444);color:#fff}.opt-btn-dropdown-item.align-horizontal{flex-direction:row}.opt-btn-dropdown-item.align-horizontal .opt-btn-icon{width:18px;height:18px;margin-right:8px}.opt-btn-dropdown-item.align-vertical{flex-direction:column;text-align:center}.opt-btn-dropdown-item.align-vertical .opt-btn-icon{width:24px;height:24p
(function(p,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(p=typeof globalThis<"u"?globalThis:p||self,m(p.LyzBimEngineSDK={}))})(this,(function(p){"use strict";const m={common:{title:"BimEngine",description:"这是一个使用 BIM-ENGINE。",openTestDialog:"打开测试弹窗",openInfoDialog:"打开信息弹窗 (封装版)"},toolbar:{home:"首页",info:"信息",location:"定位",setting:"设置",walk:"漫游",walkPerson:"人视",walkBird:"鸟瞰",walkMenu:"菜单"},dialog:{testTitle:"测试弹窗",testContent:'<div style="padding: 10px;">这是一个 <b>可拖拽</b> 且 <b>可缩放</b> 的弹窗。<br><br>你可以尝试拖动标题栏,或者拖动右下角改变大小。</div>'}},L={common:{title:"BimEngine",description:"This is a BIM-ENGINE demo.",openTestDialog:"Open Test Dialog",openInfoDialog:"Open Info Dialog (Wrapped)"},toolbar:{home:"Home",info:"Info",location:"Location",setting:"Settings",walk:"Walk",walkPerson:"Person",walkBird:"Bird Eye",walkMenu:"Menu"},dialog:{testTitle:"Test Dialog",testContent:'<div style="padding: 10px;">This is a <b>draggable</b> and <b>resizable</b> dialog.<br><br>Try dragging the title bar or resizing from the bottom-right corner.</div>'}};class B{currentLocale="zh-CN";messages={"zh-CN":m,"en-US":L};listeners=[];constructor(){}getLocale(){return this.currentLocale}setLocale(t){this.currentLocale!==t&&(this.currentLocale=t,this.notifyListeners())}t(t){if(!t)return"";const e=t.split(".");let o=this.messages[this.currentLocale];for(const i of e)if(o&&typeof o=="object"&&i in o)o=o[i];else return t;return o}subscribe(t){return this.listeners.push(t),()=>{this.listeners=this.listeners.filter(e=>e!==t)}}notifyListeners(){this.listeners.forEach(t=>t(this.currentLocale))}}const u=new B,g=a=>u.t(a),w={name:"dark",primary:"#0078d4",primaryHover:"#0063b1",background:"#f5f5f5",panelBackground:"rgba(30, 30, 30, 0.9)",textPrimary:"#ffffff",textSecondary:"#cccccc",border:"#444444",icon:"#cccccc",iconActive:"#ffffff",componentBackground:"transparent",componentHover:"#333333",componentActive:"rgba(255, 255, 255, 0.1)"},k={name:"light",primary:"#0078d4",primaryHover:"#106ebe",background:"#f5f5f5",panelBackground:"#ffffff",textPrimary:"#333333",textSecondary:"#666666",border:"#e0e0e0",icon:"#555555",iconActive:"#0078d4",componentBackground:"transparent",componentHover:"#f0f0f0",componentActive:"#e0e0e0"};class x{currentTheme=w;listeners=[];constructor(){}getTheme(){return this.currentTheme}setTheme(t){t==="light"?this.applyTheme(k):this.applyTheme(w)}setCustomTheme(t){this.applyTheme(t)}applyTheme(t){this.currentTheme=t,this.notifyListeners()}subscribe(t){return this.listeners.push(t),t(this.currentTheme),()=>{this.listeners=this.listeners.filter(e=>e!==t)}}notifyListeners(){this.listeners.forEach(t=>t(this.currentTheme))}}const d=new x;class v{container;options;groups=[];activeBtnIds=new Set;btnRefs=new Map;dropdownElement=null;hoverTimeout=null;customColors=new Set;unsubscribeLocale=null;unsubscribeTheme=null;DEFAULT_ICON='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect></svg>';constructor(t){const e=typeof t.container=="string"?document.getElementById(t.container):t.container;if(!e)throw new Error("Container not found");this.container=e,this.options={showLabel:!0,visibility:{},direction:"row",position:"static",align:"vertical",expand:"down",...t},["backgroundColor","btnBackgroundColor","btnHoverColor","btnActiveColor","iconColor","iconActiveColor","textColor","textActiveColor"].forEach(i=>{t[i]&&this.customColors.add(i)}),this.initContainer(),this.applyStyles()}initContainer(){this.container.innerHTML="",this.container.classList.add("bim-btn-group-root"),this.options.direction==="column"?this.container.classList.add("dir-column"):this.container.classList.add("dir-row"),this.options.className&&this.container.classList.add(this.options.className),this.updatePosition()}updatePosition(){const t=this.options.position,e=this.container.style;if
<li><strong>Name:</strong> Sample Project</li>
<li><strong>Version:</strong> 1.0.0</li>
<li><strong>Date:</strong> ${new Date().toLocaleDateString()}</li>
<li><strong>Status:</strong> <span style="color: green;">Active</span></li>
`;const n=document.createElement("button");n.textContent="Update Status",n.style.marginTop="10px",n.onclick=()=>{alert("Status updated!")},e.appendChild(o),e.appendChild(i),e.appendChild(n),super({container:t,title:"dialog.testTitle",content:e,width:320,height:"auto",position:"center",resizable:!0,draggable:!0,onClose:()=>{console.log("Info dialog closed")},onOpen:()=>{console.log("Info dialog opened")}})}}class S{container;activeDialogs=[];constructor(t){this.container=t}create(t){const e=new T({container:this.container,...t,onClose:()=>{this.activeDialogs=this.activeDialogs.filter(o=>o!==e),t.onClose&&t.onClose()}});return e.setTheme(d.getTheme()),this.activeDialogs.push(e),e}showInfoDialog(){new P(this.container)}updateTheme(t){this.activeDialogs.forEach(e=>{e.setTheme&&e.setTheme(t)})}}class z{container;wrapper=null;topLeftGroup=null;toolbar=null;buttonGroup=null;dialog=null;get localeManager(){return u}get themeManager(){return d}constructor(t,e){const o=typeof t=="string"?document.getElementById(t):t;if(!o)throw new Error("Container not found");this.container=o,e?.locale&&u.setLocale(e.locale),e?.theme&&(e.theme==="custom"?console.warn("Custom theme should be set via setCustomTheme()."):d.setTheme(e.theme)),this.init()}setLocale(t){u.setLocale(t)}getLocale(){return u.getLocale()}setTheme(t){d.setTheme(t)}setCustomTheme(t){d.setCustomTheme(t)}init(){this.container.innerHTML="",this.wrapper=document.createElement("div"),this.wrapper.className="bim-engine-wrapper",this.container.appendChild(this.wrapper),this.dialog=new S(this.wrapper),this.toolbar=new E(this.wrapper),this.buttonGroup=new M(this.wrapper),this.createTopLeftGroup(),this.updateTheme(d.getTheme()),this.topLeftGroup&&this.topLeftGroup.setColors({backgroundColor:"#ff00ff"}),d.subscribe(t=>{this.updateTheme(t)})}createTopLeftGroup(){this.buttonGroup&&(this.topLeftGroup=this.buttonGroup.create({position:"top-left",direction:"column",align:"vertical",backgroundColor:"#ff00ff",showLabel:!1}),this.topLeftGroup.addGroup("main"),this.topLeftGroup.addButton({id:"menu-btn",groupId:"main",type:"button",label:"Menu",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/></svg>',onClick:()=>{alert("点击按钮")}}),this.topLeftGroup.render())}updateTheme(t){this.wrapper&&(this.wrapper.style.backgroundColor=t.background,this.wrapper.style.color=t.textPrimary)}destroy(){this.toolbar?.destroy(),this.buttonGroup?.destroy(),this.dialog=null,this.container.innerHTML=""}}const D=Object.freeze(Object.defineProperty({__proto__:null,homeButton:{id:"home",groupId:"group-1",type:"button",label:"toolbar.home",icon:'<svg width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M4 21V9l8-6l8 6v12h-6v-7h-4v7z"/></svg>',keepActive:!0,onClick:a=>{console.log("首页按钮被点击:",a.id)}}},Symbol.toStringTag,{value:"Module"})),q=Object.freeze(Object.defineProperty({__proto__:null,locationButton:{id:"location",groupId:"group-1",type:"button",label:"toolbar.location",icon:'<svg width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M9 13h2v-2.75h2V13h2V8.25l-3-2l-3 2zm3 9q-4.025-3.425-6.012-6.362T4 10.2q0-3.75 2.413-5.975T12 2t5.588 2.225T20 10.2q0 2.5-1.987 5.438T12 22"/></svg>',keepActive:!1,onClick:a=>{console.log("定位按钮被点击:",a.id)}}},Symbol.toStringTag,{value:"Module"})),I=Object.freeze(Object.defineProperty({__proto__:null,walkMenuButton:{id:"walk",groupId:"group-1",type:"menu",label:"toolbar.walk",align:"vertical",icon:'<svg width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M9 22V8.775q-2.275-.6-3.637-2.512T4 2h2q0 2.075 1.338 3.538T10.75 7h2.5q.75 0 1.4.275t1.175.8L20.35 12.6l-1.4 1.4L15 10.05V22h-2v-6h-2v6zm3-16q-.825 0-1.412-.587T10 4t.588-1.412T12 2t1.413.588T14 4t-.587 1.413T12 6"/></svg>',keepActive:!0,onClick:a=>{console.log("漫游按钮被点击:",a.id)}}},Symbol.toStringTag,{value:"Module"})),H=Object.freeze(Object.defineProperty({__proto__:null,walkPersonButton:{id:"walk-person",groupId:"group-1",parentId:"walk",type:"b
2025-12-03 12:00:46 +08:00
//# sourceMappingURL=bim-engine-sdk.umd.js.map