UNPKG

graphdb-workbench

Version:
1 lines 6.76 kB
import{r as registerInstance,h,a as Host,g as getElement,c as createEvent}from"./index-I_gcXFWK.js";import{H as HtmlUtil}from"./html-util-C8DO915D.js";import{T as TranslationService}from"./translation.service-nljGIprK.js";import{O as OntoTooltipPlacement}from"./onto-tooltip-placement-D_J2-9CG.js";import"@ontotext/workbench-api";const ontoDialogCss=".dialog-overlay{position:fixed;top:0;bottom:0;left:0;right:0;display:flex;align-items:center;justify-content:center;z-index:9998;margin-left:-10px;background-color:rgba(0, 0, 0, 0.5);font-family:var(--main-font), sans-serif;font-weight:var(--main-font-weight);color:var(--gw-secondary-base, var(--base-text-color))}.dialog{z-index:1001;max-width:60vw;max-height:90vh;font-family:inherit;font-weight:inherit;display:flex;flex-direction:column;position:relative;justify-content:space-between;border:none;color:var(--gw-dialog-color);background-color:var(--gw-dialog-background);box-shadow:0 5px 15px rgba(0, 0, 0, 0.5)}.dialog .dialog-header{display:flex;justify-content:space-between;padding:15px;font-size:20px}.dialog .dialog-header .dialog-title{margin:0.5rem 0;font-weight:400}.dialog .dialog-body{padding:0 15px 15px;overflow:auto}.dialog .dialog-footer{display:flex;justify-content:flex-end;padding:15px}",OntoDialog=class{constructor(e){registerInstance(this,e),this.handleClose=e=>{this.config.onClose(e)}}componentDidLoad(){this.documentOverflow=HtmlUtil.hideDocumentBodyOverflow(),this.hostElement.addEventListener("keydown",this.preventLeavingDialog.bind(this)),this.closeButton.focus()}disconnectedCallback(){this.hostElement.removeEventListener("keydown",this.preventLeavingDialog.bind(this)),HtmlUtil.setDocumentBodyOverflow(this.documentOverflow)}render(){return h(Host,{key:"eeffeaac1aa5b80b89d0d176d89dc44291fd0cbb",tabindex:"-1"},h("div",{key:"2ba8415fa038ad2666cc0b340a3ceba6f0919bc6",class:`dialog-overlay ${this.config.modalClass?this.config.modalClass:""}`},h("dialog",{key:"39b9fc94944e12e8dcae98a65e74593dc173b336",class:"dialog"},h("header",{key:"183327aad084ff6fd619d204a537871cace84684",class:"dialog-header"},h("h3",{key:"ae4c514e0f75e46d5787d284154392de808100ca",class:"dialog-title"},this.config.dialogTitle)),h("main",{key:"dc991f0ef3baa22f42f683528a4ca67ab8d5e7f4",class:"dialog-body"},h("slot",{key:"ddc1c5176d976f5a518fed1d2faa138d0bc5082a",name:"body"})),h("footer",{key:"b3cb9449b54583a7b5489b7d56fa084e456b4d75",class:"dialog-footer"},h("slot",{key:"b3bc85bdfe12da62019be2e542737e5b6f7db4f6",name:"footer"}),h("button",{key:"c58a84d33d8d07ae67a9988adaa320166371cc5b",class:"onto-btn onto-btn-primary",onClick:this.handleClose,ref:e=>this.closeButton=e},h("translate-label",{key:"b593b5e113baa66e6878a2e885a46bc6581bf27f",labelKey:"common.button.close"}))))))}preventLeavingDialog(e){HtmlUtil.preventLeavingDialog(this.hostElement,e)}get hostElement(){return getElement(this)}};OntoDialog.style=ontoDialogCss;class ObjectUtil{static deepEqual(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if("object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(!ObjectUtil.deepEqual(e[o],t[o]))return!1;return!0}if(!Array.isArray(e)&&!Array.isArray(t)){const o=Object.keys(e),i=Object.keys(t);if(o.length!==i.length)return!1;for(const i of o)if(!(i in t)||!ObjectUtil.deepEqual(e[i],t[i]))return!1;return!0}return!1}return!1}static deepCopy(e){if("object"!=typeof e||null==e||"function"==typeof e)return e;if(Array.isArray(e))return e.map(e=>ObjectUtil.deepCopy(e));const t=Object.create(Object.getPrototypeOf(e));for(const o of Object.keys(e))t[o]=ObjectUtil.deepCopy(e[o]);return t}static hasCopyMethod(e){return"object"==typeof e&&null!==e&&Object.prototype.hasOwnProperty.call(e,"copy")&&"function"==typeof e.copy}}class Model{copy(){return ObjectUtil.deepCopy(this)}}class ModelList extends Model{constructor(e=[]){super(),this.items=e}getItems(){return this.items}sort(e){this.items.sort(e)}filter(e){return this.items.filter(e)}find(e){return this.items.find(e)}isEmpty(){return 0===this.items.length}addToStart(e){this.items.unshift(e)}addItems(e){this.items.push(...e)}remove(e){const t=this.items.indexOf(e);-1!==t&&this.items.splice(t,1)}}class SubscriptionList extends ModelList{constructor(e){super(e)}add(e){this.items.push(e)}addAll(e){this.items.push(...e)}unsubscribeAll(){this.items.forEach(e=>e()),this.items=[]}}const ontoToggleSwitchCss='.toggle-switch{all:unset;clear:both;margin:0 5px;width:36px}.toggle-switch:focus{outline:none;box-shadow:none}.toggle-switch:focus-visible{outline:none;box-shadow:none}.toggle-switch input:empty{display:none}.toggle-switch input:empty~label{position:relative;cursor:pointer;user-select:none;margin:0.05em 0.6em -0.05em 0}.toggle-switch input:empty~label:before{display:block;content:" ";width:2.2em;height:0.8em;background-color:rgba(181, 181, 181, 0.5);border-radius:10em;transition:all 100ms ease-in}.toggle-switch input:empty~label:after{position:absolute;display:block;top:-0.2em;left:-0.3em;content:" ";width:1.25em;height:1.25em;background-color:#888888;border-radius:50%;transition:all 100ms ease-in}.toggle-switch input:checked~label:before{background-color:var(--gw-secondary-light, --base-text-color)}.toggle-switch input:checked~label:after{left:1.3em;background-color:var(--gw-secondary-base, --base-text-color)}',OntoToggleSwitch=class{constructor(e){registerInstance(this,e),this.toggleChanged=createEvent(this,"toggleChanged"),this.subscriptions=new SubscriptionList,this.checked=!1,this.toggle=()=>{this.checked=!this.checked,this.toggleChanged.emit({checked:this.checked,context:this.context})}}subscribeToLanguageChange(){this.tooltipTranslationKey&&this.subscriptions.add(TranslationService.onTranslate(this.tooltipTranslationKey,[],e=>{this.tooltipLabel=e}))}disconnectedCallback(){this.subscriptions.unsubscribeAll()}connectedCallback(){this.subscribeToLanguageChange()}render(){return h("section",{key:"d9d7433b0d5d86830bc124483a3982f255ea3851"},this.labelKey&&h("label",{key:"30e1f9c5a47b7a17f614ed2c31c191e4364f0552"},h("strong",{key:"e573b14579f77efd38636093143519451042e386"},h("translate-label",{key:"1653cbf17a0cd2f57e9011ed7bf3acc589ae9bde",labelKey:this.labelKey})," ")),h("button",{key:"3ff359d2c065db8653f12233d69934483c00b0d8",class:"toggle-switch",onClick:this.toggle,"tooltip-append-to":"parent","tooltip-content":this.tooltipLabel,"tooltip-placement":OntoTooltipPlacement.TOP},h("input",{key:"c36ab591c99d5030ab4528774bd8226ecacb855e",type:"checkbox",checked:this.checked}),h("label",{key:"86c93d3ccebd7f1324b6d39192472464580f1120"})))}};OntoToggleSwitch.style=ontoToggleSwitchCss;export{OntoDialog as onto_dialog,OntoToggleSwitch as onto_toggle_switch};