@quandis/qbo4.configuration 4.0.1-CI-20241010-231112 → 4.0.1-CI-20241011-172926
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +19 -19
- package/src/qbo-template.js +1 -0
- package/src/qbo-template.js.map +1 -1
- package/src/qbo-template.ts +1 -0
- package/wwwroot/js/esm/qbo4.configuration.js +2 -1
- package/wwwroot/js/esm/qbo4.configuration.min.js +1 -1
- package/wwwroot/js/esm/qbo4.configuration.min.js.map +1 -1
- package/wwwroot/js/qbo4.configuration.js +2 -1
- package/wwwroot/js/qbo4.configuration.min.js +1 -1
- package/wwwroot/js/qbo4.configuration.min.js.map +1 -1
|
@@ -59,7 +59,7 @@ input.working {
|
|
|
59
59
|
<button type="submit" @click=${this.save} ?disabled="${this.editorCoding}">Save</button>
|
|
60
60
|
<button type="reset" @click=${this.cancel} ?disabled="${this.editorCoding}">Cancel</button>
|
|
61
61
|
</footer>
|
|
62
|
-
</dialog>`}cancel(){this.toggleEdit(!1)}async save(){try{if(null==this.editor)return;const t=new FormData;t.append("htmlTemplate",this.editor.state.doc.toString());const e=await fetch(`${this.templateEndpoint}/save/${this.prefix}/${this.editorType}`,{method:"POST",body:t});if(e.ok)return this.map?.set(this.editorType,this.testTemplate),this.type=this.editorType,void this.toggleEdit(!1);throw new Error(`Failed to save template: ${e.statusText}`)}catch(t){throw t}}async code(t){try{if(null==this.editor)return;this.editorCoding=!0;const e=t.target?.value,i=await fetch(`${this.templateEndpoint}/code`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({HtmlTemplate:this.editor.state.doc.toString(),Component:this.getComponent(),Prompt:e})});if(this.editorCoding=!1,i.ok){const t=await i.text();return void this.editor.dispatch({changes:{from:0,to:this.editor.state.doc.length,insert:t}})}throw new Error(`Failed to generate code: ${i.statusText}`)}catch(t){throw this.editorCoding=!1,t}}render(){let t=this.defaultTemplate;return this.type&&this.prefix&&!this.map?.has(this.type)&&(this.map=Gb.get(this.prefix)),this.type&&this.map?.has(this.type)&&(t=this.map.get(this.type)),this.editing?B`${this.edit()}${this.testTemplate(this)}`:t(this)}}return Ub([Ht({attribute:!1}),Bb("design:type",Object)],e.prototype,"editorError",void 0),Ub([Ht(),Bb("design:type",Object)],e.prototype,"type",void 0),Ub([Ht(),Bb("design:type",Object)],e.prototype,"editing",void 0),Ub([Ht({attribute:!1}),Bb("design:type",Function)],e.prototype,"defaultTemplate",void 0),Ub([Ht({attribute:!1}),Bb("design:type",Object)],e.prototype,"testTemplate",void 0),Ub([Ht(),Bb("design:type",Object)],e.prototype,"templateEndpoint",void 0),Ub([Ht(),Bb("design:type",Object)],e.prototype,"prefix",void 0),Ub([Ht({attribute:!1}),Bb("design:type",Object)],e.prototype,"map",void 0),Ub([Ht({attribute:!1}),Bb("design:type",Boolean)],e.prototype,"editorCoding",void 0),e},Fb=Hb(ht);"undefined"!=typeof window&&(window.qbo4=window.qbo4||{},window.qbo4.configuration=window.qbo4.configuration||{},window.qbo4.configuration.templates=Gb,window.qbo4.configuration.html=B);var Kb=function(t,e,i,r){var n,o=arguments.length,s=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,r);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(s=(o<3?n(s):o>3?n(e,i,s):n(e,i))||s);return o>3&&s&&Object.defineProperty(e,i,s),s},Jb=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)};let tv=class extends ht{constructor(){super(...arguments),this.dragging=!1,this.resizing=!1,this.offsetX=0,this.offsetY=0,this.startWidth=0,this.startHeight=0,this.editorError=null,this.editing=!1,this.storageKey="qbo-css",this.customcss="",this.editorCoding=!1,this.templateEndpoint="/configuration/css",this.editor=null,this.styleElement=null}static{this.styles=[Wb]}async connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.requestEdit.bind(this)),this.shadowRoot?.addEventListener("mousedown",this._onMouseDown.bind(this)),this.shadowRoot?.addEventListener("mousedown",this._onResizeMouseDown.bind(this),!0),window.addEventListener("mousemove",this._onMouseMove.bind(this)),window.addEventListener("mouseup",this._onMouseUp.bind(this)),this.customcss=localStorage.getItem(this.storageKey)??""}async disconnectedCallback(){this.removeEventListener("dblclick",this.requestEdit.bind(this)),this.shadowRoot?.removeEventListener("mousedown",this._onMouseDown.bind(this)),this.shadowRoot?.removeEventListener("mousedown",this._onResizeMouseDown.bind(this),!0),window.removeEventListener("mousemove",this._onMouseMove.bind(this)),window.removeEventListener("mouseup",this._onMouseUp.bind(this))}_onMouseDown(t){if(!t.target.closest(".qbo-code header"))return;this.dragging=!0;const e=this.shadowRoot?.querySelector(".qbo-code");e&&(this.offsetX=t.clientX-e.getBoundingClientRect().left,this.offsetY=t.clientY-e.getBoundingClientRect().top)}_onResizeMouseDown(t){if(!t.target.closest(".qbo-code .resize-handle"))return;this.resizing=!0;const e=this.shadowRoot?.querySelector(".qbo-code");e&&(this.startWidth=e.offsetWidth,this.startHeight=e.offsetHeight,this.offsetX=t.clientX,this.offsetY=t.clientY)}_onMouseMove(t){if(this.dragging){const e=this.shadowRoot?.querySelector(".qbo-code"),i=t.clientX-this.offsetX,r=t.clientY-this.offsetY;e&&(e.style.left=`${i}px`,e.style.top=`${r}px`)}else if(this.resizing){const e=this.shadowRoot?.querySelector(".qbo-code");e&&(e.style.width=`${this.startWidth+(t.clientX-this.offsetX)}px`,e.style.height=`${this.startHeight+(t.clientY-this.offsetY)}px`)}}_onMouseUp(){this.dragging=!1,this.resizing=!1}requestEdit(t){t.composedPath().some((t=>t instanceof Element&&t.classList.contains("qbo-code")))||!this.editing&&t.target.closest(".qbo-design")&&this.toggleEdit(!0)}toggleEdit(t){this.editing=t,this.editing||(this.editor?.destroy(),this.editor=null)}cancel(){this.setCss(this.customcss),this.toggleEdit(!1)}firstUpdated(t){super.firstUpdated(t);const e=document.createElement("style");e.type="text/css",e.appendChild(document.createTextNode(localStorage.getItem(this.storageKey)??"")),document.head.appendChild(e),this.styleElement=e}updated(t){super.update(t),this.editing&&(this.editor??=new Gs({doc:this.styleElement?.textContent??"",extensions:[Lb,zp(),ia.of([uf]),Gs.updateListener.of((t=>{this.setCss(t.state.doc.toString())}))],parent:this.shadowRoot?.querySelector("div.editor")}))}async code(t){try{if(null==this.editor)return;this.editorCoding=!0;const e=t.target?.value,i=await fetch(`${this.templateEndpoint}/code`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({CssTemplate:this.editor.state.doc.toString(),Prompt:e})});if(this.editorCoding=!1,i.ok){const t=await i.text();return void this.editor.dispatch({changes:{from:0,to:this.editor.state.doc.length,insert:t}})}throw new Error(`Failed to generate code: ${i.statusText}`)}catch(t){throw this.editorCoding=!1,t}}save(){this.toggleEdit(!1)}setCss(t){if(localStorage.setItem(this.storageKey,t),null!=this.styleElement)try{this.styleElement.textContent=t,this.editorError=void 0}catch(e){this.editorError=e,console.error(`Error rendering ${t}`,e)}}edit(){return B`
|
|
62
|
+
</dialog>`}cancel(){this.toggleEdit(!1)}async save(){try{if(null==this.editor)return;const t=new FormData;t.append("htmlTemplate",this.editor.state.doc.toString());const e=await fetch(`${this.templateEndpoint}/save/${this.prefix}/${this.editorType}`,{method:"POST",body:t});if(e.ok)return this.map?.set(this.editorType,this.testTemplate),this.type=this.editorType,void this.toggleEdit(!1);throw new Error(`Failed to save template: ${e.statusText}`)}catch(t){throw t}}async code(t){try{if(null==this.editor)return;this.editorCoding=!0;const e=t.target?.value,i=await fetch(`${this.templateEndpoint}/code`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({HtmlTemplate:this.editor.state.doc.toString(),Component:this.getComponent(),Prompt:e})});if(this.editorCoding=!1,i.ok){const t=await i.text();return void this.editor.dispatch({changes:{from:0,to:this.editor.state.doc.length,insert:t}})}throw new Error(`Failed to generate code: ${i.statusText}`)}catch(t){throw this.editorCoding=!1,t}}render(){let t=this.defaultTemplate;return this.type&&this.prefix&&!this.map?.has(this.type)&&(this.map=Gb.get(this.prefix)),this.type&&this.map?.has(this.type)&&(t=this.map.get(this.type)),this.editing?B`${this.edit()}${this.testTemplate(this)}`:t(this)}}return Ub([Ht({attribute:!1}),Bb("design:type",Object)],e.prototype,"editorError",void 0),Ub([Ht(),Bb("design:type",Object)],e.prototype,"type",void 0),Ub([Ht(),Bb("design:type",Object)],e.prototype,"editing",void 0),Ub([Ht({attribute:!1}),Bb("design:type",Function)],e.prototype,"defaultTemplate",void 0),Ub([Ht({attribute:!1}),Bb("design:type",Object)],e.prototype,"testTemplate",void 0),Ub([Ht(),Bb("design:type",Object)],e.prototype,"templateEndpoint",void 0),Ub([Ht(),Bb("design:type",Object)],e.prototype,"prefix",void 0),Ub([Ht({attribute:!1}),Bb("design:type",Object)],e.prototype,"map",void 0),Ub([Ht({attribute:!1}),Bb("design:type",Boolean)],e.prototype,"editorCoding",void 0),e},Fb=Hb(ht);"undefined"!=typeof window&&(window.qbo4=window.qbo4||{},window.qbo4.configuration=window.qbo4.configuration||{},window.qbo4.configuration.templates=Gb,window.qbo4.configuration.html=B,window.qbo4.configuration.version="1.0.1");var Kb=function(t,e,i,r){var n,o=arguments.length,s=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,r);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(s=(o<3?n(s):o>3?n(e,i,s):n(e,i))||s);return o>3&&s&&Object.defineProperty(e,i,s),s},Jb=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)};let tv=class extends ht{constructor(){super(...arguments),this.dragging=!1,this.resizing=!1,this.offsetX=0,this.offsetY=0,this.startWidth=0,this.startHeight=0,this.editorError=null,this.editing=!1,this.storageKey="qbo-css",this.customcss="",this.editorCoding=!1,this.templateEndpoint="/configuration/css",this.editor=null,this.styleElement=null}static{this.styles=[Wb]}async connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.requestEdit.bind(this)),this.shadowRoot?.addEventListener("mousedown",this._onMouseDown.bind(this)),this.shadowRoot?.addEventListener("mousedown",this._onResizeMouseDown.bind(this),!0),window.addEventListener("mousemove",this._onMouseMove.bind(this)),window.addEventListener("mouseup",this._onMouseUp.bind(this)),this.customcss=localStorage.getItem(this.storageKey)??""}async disconnectedCallback(){this.removeEventListener("dblclick",this.requestEdit.bind(this)),this.shadowRoot?.removeEventListener("mousedown",this._onMouseDown.bind(this)),this.shadowRoot?.removeEventListener("mousedown",this._onResizeMouseDown.bind(this),!0),window.removeEventListener("mousemove",this._onMouseMove.bind(this)),window.removeEventListener("mouseup",this._onMouseUp.bind(this))}_onMouseDown(t){if(!t.target.closest(".qbo-code header"))return;this.dragging=!0;const e=this.shadowRoot?.querySelector(".qbo-code");e&&(this.offsetX=t.clientX-e.getBoundingClientRect().left,this.offsetY=t.clientY-e.getBoundingClientRect().top)}_onResizeMouseDown(t){if(!t.target.closest(".qbo-code .resize-handle"))return;this.resizing=!0;const e=this.shadowRoot?.querySelector(".qbo-code");e&&(this.startWidth=e.offsetWidth,this.startHeight=e.offsetHeight,this.offsetX=t.clientX,this.offsetY=t.clientY)}_onMouseMove(t){if(this.dragging){const e=this.shadowRoot?.querySelector(".qbo-code"),i=t.clientX-this.offsetX,r=t.clientY-this.offsetY;e&&(e.style.left=`${i}px`,e.style.top=`${r}px`)}else if(this.resizing){const e=this.shadowRoot?.querySelector(".qbo-code");e&&(e.style.width=`${this.startWidth+(t.clientX-this.offsetX)}px`,e.style.height=`${this.startHeight+(t.clientY-this.offsetY)}px`)}}_onMouseUp(){this.dragging=!1,this.resizing=!1}requestEdit(t){t.composedPath().some((t=>t instanceof Element&&t.classList.contains("qbo-code")))||!this.editing&&t.target.closest(".qbo-design")&&this.toggleEdit(!0)}toggleEdit(t){this.editing=t,this.editing||(this.editor?.destroy(),this.editor=null)}cancel(){this.setCss(this.customcss),this.toggleEdit(!1)}firstUpdated(t){super.firstUpdated(t);const e=document.createElement("style");e.type="text/css",e.appendChild(document.createTextNode(localStorage.getItem(this.storageKey)??"")),document.head.appendChild(e),this.styleElement=e}updated(t){super.update(t),this.editing&&(this.editor??=new Gs({doc:this.styleElement?.textContent??"",extensions:[Lb,zp(),ia.of([uf]),Gs.updateListener.of((t=>{this.setCss(t.state.doc.toString())}))],parent:this.shadowRoot?.querySelector("div.editor")}))}async code(t){try{if(null==this.editor)return;this.editorCoding=!0;const e=t.target?.value,i=await fetch(`${this.templateEndpoint}/code`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({CssTemplate:this.editor.state.doc.toString(),Prompt:e})});if(this.editorCoding=!1,i.ok){const t=await i.text();return void this.editor.dispatch({changes:{from:0,to:this.editor.state.doc.length,insert:t}})}throw new Error(`Failed to generate code: ${i.statusText}`)}catch(t){throw this.editorCoding=!1,t}}save(){this.toggleEdit(!1)}setCss(t){if(localStorage.setItem(this.storageKey,t),null!=this.styleElement)try{this.styleElement.textContent=t,this.editorError=void 0}catch(e){this.editorError=e,console.error(`Error rendering ${t}`,e)}}edit(){return B`
|
|
63
63
|
<dialog class="qbo-code" open>
|
|
64
64
|
<header>
|
|
65
65
|
<h5>Edit Css</h5>
|