graphdb-workbench
Version:
The web application for GraphDB APIs
1 lines • 7.65 kB
JavaScript
"use strict";var index=require("./index-jdsA9lN2.js"),htmlUtil=require("./html-util-e108SpX7.js"),translation_service=require("./translation.service-CC6jY4U-.js"),ontoTooltipPlacement=require("./onto-tooltip-placement-CTomd-7A.js");require("@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){index.registerInstance(this,e),this.handleClose=e=>{this.config.onClose(e)}}componentDidLoad(){this.documentOverflow=htmlUtil.HtmlUtil.hideDocumentBodyOverflow(),this.hostElement.addEventListener("keydown",this.preventLeavingDialog.bind(this)),this.closeButton.focus()}disconnectedCallback(){this.hostElement.removeEventListener("keydown",this.preventLeavingDialog.bind(this)),htmlUtil.HtmlUtil.setDocumentBodyOverflow(this.documentOverflow)}render(){return index.h(index.Host,{key:"eeffeaac1aa5b80b89d0d176d89dc44291fd0cbb",tabindex:"-1"},index.h("div",{key:"2ba8415fa038ad2666cc0b340a3ceba6f0919bc6",class:`dialog-overlay ${this.config.modalClass?this.config.modalClass:""}`},index.h("dialog",{key:"39b9fc94944e12e8dcae98a65e74593dc173b336",class:"dialog"},index.h("header",{key:"183327aad084ff6fd619d204a537871cace84684",class:"dialog-header"},index.h("h3",{key:"ae4c514e0f75e46d5787d284154392de808100ca",class:"dialog-title"},this.config.dialogTitle)),index.h("main",{key:"dc991f0ef3baa22f42f683528a4ca67ab8d5e7f4",class:"dialog-body"},index.h("slot",{key:"ddc1c5176d976f5a518fed1d2faa138d0bc5082a",name:"body"})),index.h("footer",{key:"b3cb9449b54583a7b5489b7d56fa084e456b4d75",class:"dialog-footer"},index.h("slot",{key:"b3bc85bdfe12da62019be2e542737e5b6f7db4f6",name:"footer"}),index.h("button",{key:"c58a84d33d8d07ae67a9988adaa320166371cc5b",class:"onto-btn onto-btn-primary",onClick:this.handleClose,ref:e=>this.closeButton=e},index.h("translate-label",{key:"b593b5e113baa66e6878a2e885a46bc6581bf27f",labelKey:"common.button.close"}))))))}preventLeavingDialog(e){htmlUtil.HtmlUtil.preventLeavingDialog(this.hostElement,e)}get hostElement(){return index.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 i=0;i<e.length;i++)if(!ObjectUtil.deepEqual(e[i],t[i]))return!1;return!0}if(!Array.isArray(e)&&!Array.isArray(t)){const i=Object.keys(e),o=Object.keys(t);if(i.length!==o.length)return!1;for(const o of i)if(!(o in t)||!ObjectUtil.deepEqual(e[o],t[o]))return!1;return!0}return!1}return!1}static deepCopy(e){if("object"!=typeof e||null==e||"function"==typeof e)return e;if(ObjectUtil.hasCopyMethod(e))return e.copy();const t=ObjectUtil.copyBuiltInType(e);return null!==t?t:ObjectUtil.copyPlainObject(e)}static copyBuiltInType(e){return Array.isArray(e)?e.map(e=>ObjectUtil.deepCopy(e)):e instanceof Date?new Date(e.getTime()):e instanceof RegExp?new RegExp(e.source,e.flags):e instanceof Map?new Map(Array.from(e.entries()).map(([e,t])=>[ObjectUtil.deepCopy(e),ObjectUtil.deepCopy(t)])):e instanceof Set?new Set(Array.from(e.values()).map(e=>ObjectUtil.deepCopy(e))):null}static copyPlainObject(e){const t=Object.create(Object.getPrototypeOf(e));for(const i of Object.keys(e))t[i]=ObjectUtil.deepCopy(e[i]);return t}static hasCopyMethod(e){return"object"==typeof e&&null!==e&&Object.prototype.hasOwnProperty.call(e,"copy")&&"function"==typeof e.copy}}ObjectUtil.isNullOrUndefined=e=>null==e;class Model{copy(){return ObjectUtil.deepCopy(this)}}class ModelList extends Model{constructor(e=[]){super(),this.items=e}size(){return this.items.length}getItems(){return this.items}getFirstItem(){return this.items[0]}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;vertical-align:text-bottom}.toggle-switch input:empty~label:before{display:block;content:" ";width:2.2em;height:1.25em;background-color:var(--gw-toggleswitch-background);border-radius:10em;transition:all 100ms ease-in}.toggle-switch input:empty~label:after{position:absolute;display:block;top:0.08em;left:0.1em;content:" ";width:0.9em;height:0.9em;background-color:var(--gw-toggleswitch-handle-background);border:1px solid var(--gw-toggleswitch-background);border-radius:50%;transition:all 100ms ease-in}.toggle-switch input:checked~label:before{background-color:var(--gw-toggleswitch-checked-background)}.toggle-switch input:checked~label:after{left:1em;background-color:var(--gw-toggleswitch-handle-checked-background);border:1px solid var(--gw-toggleswitch-checked-background)}',OntoToggleSwitch=class{constructor(e){index.registerInstance(this,e),this.toggleChanged=index.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(translation_service.TranslationService.onTranslate(this.tooltipTranslationKey,[],e=>{this.tooltipLabel=e}))}disconnectedCallback(){this.subscriptions.unsubscribeAll()}connectedCallback(){this.subscribeToLanguageChange()}render(){return index.h("section",{key:"d9d7433b0d5d86830bc124483a3982f255ea3851"},this.labelKey&&index.h("label",{key:"30e1f9c5a47b7a17f614ed2c31c191e4364f0552"},index.h("strong",{key:"e573b14579f77efd38636093143519451042e386"},index.h("translate-label",{key:"1653cbf17a0cd2f57e9011ed7bf3acc589ae9bde",labelKey:this.labelKey})," ")),index.h("button",{key:"3ff359d2c065db8653f12233d69934483c00b0d8",class:"toggle-switch",onClick:this.toggle,"tooltip-append-to":"parent","tooltip-content":this.tooltipLabel,"tooltip-placement":ontoTooltipPlacement.OntoTooltipPlacement.TOP},index.h("input",{key:"c36ab591c99d5030ab4528774bd8226ecacb855e",type:"checkbox",checked:this.checked}),index.h("label",{key:"86c93d3ccebd7f1324b6d39192472464580f1120"})))}};OntoToggleSwitch.style=ontoToggleSwitchCss,exports.onto_dialog=OntoDialog,exports.onto_toggle_switch=OntoToggleSwitch;