@teipublisher/pb-components 2.26.0-next-3.11 → 2.26.0-next-3.13

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.
Files changed (133) hide show
  1. package/.github/workflows/main.yml +3 -3
  2. package/.github/workflows/node.js.yml +3 -3
  3. package/.github/workflows/release.js.yml +3 -3
  4. package/CHANGELOG.md +38 -0
  5. package/Dockerfile +78 -70
  6. package/css/components.css +5 -5
  7. package/dist/demo/components.css +2 -8
  8. package/dist/demo/pb-drawer2.html +1 -1
  9. package/dist/demo/pb-leaflet-map.html +1 -1
  10. package/dist/demo/pb-progress.html +2 -2
  11. package/dist/demo/pb-repeat.html +1 -3
  12. package/dist/demo/pb-view3.html +1 -1
  13. package/dist/{paper-icon-button-0fb125c4.js → paper-icon-button-72125e67.js} +1 -1
  14. package/dist/pb-code-editor.js +25 -20
  15. package/dist/pb-component-docs.js +58 -54
  16. package/dist/pb-components-bundle.js +1937 -1782
  17. package/dist/pb-edit-app.js +167 -107
  18. package/dist/pb-elements.json +45 -45
  19. package/dist/{pb-i18n-0611135a.js → pb-i18n-4cc00bfe.js} +1 -1
  20. package/dist/pb-leaflet-map.js +23 -23
  21. package/dist/pb-mei.js +56 -41
  22. package/dist/{pb-mixin-b1caa22e.js → pb-mixin-886ece32.js} +1 -1
  23. package/dist/pb-odd-editor.js +923 -756
  24. package/dist/pb-tify.js +2 -2
  25. package/dist/{vaadin-element-mixin-6633322b.js → vaadin-element-mixin-84fb7d82.js} +181 -143
  26. package/gh-pages.js +5 -3
  27. package/i18n/common/pl.json +2 -2
  28. package/lib/openseadragon.min.js +1 -1
  29. package/package.json +2 -2
  30. package/pb-elements.json +45 -45
  31. package/src/assets/components.css +5 -5
  32. package/src/authority/airtable.js +20 -21
  33. package/src/authority/anton.js +129 -129
  34. package/src/authority/custom.js +23 -21
  35. package/src/authority/geonames.js +38 -32
  36. package/src/authority/gnd.js +47 -42
  37. package/src/authority/kbga.js +137 -134
  38. package/src/authority/metagrid.js +44 -46
  39. package/src/authority/reconciliation.js +66 -67
  40. package/src/authority/registry.js +4 -4
  41. package/src/docs/pb-component-docs.js +2 -2
  42. package/src/docs/pb-component-view.js +5 -5
  43. package/src/docs/pb-components-list.js +2 -2
  44. package/src/docs/pb-demo-snippet.js +2 -2
  45. package/src/dts-client.js +299 -297
  46. package/src/dts-select-endpoint.js +90 -82
  47. package/src/parse-date-service.js +184 -135
  48. package/src/pb-ajax.js +150 -146
  49. package/src/pb-authority-lookup.js +183 -146
  50. package/src/pb-autocomplete.js +292 -280
  51. package/src/pb-blacklab-highlight.js +264 -259
  52. package/src/pb-blacklab-results.js +236 -221
  53. package/src/pb-browse-docs.js +540 -475
  54. package/src/pb-browse.js +68 -65
  55. package/src/pb-clipboard.js +79 -76
  56. package/src/pb-code-editor.js +110 -102
  57. package/src/pb-code-highlight.js +209 -204
  58. package/src/pb-codepen.js +79 -72
  59. package/src/pb-collapse.js +212 -207
  60. package/src/pb-combo-box.js +190 -190
  61. package/src/pb-components-bundle.js +1 -1
  62. package/src/pb-custom-form.js +151 -149
  63. package/src/pb-dialog.js +96 -60
  64. package/src/pb-document.js +89 -90
  65. package/src/pb-download.js +210 -198
  66. package/src/pb-drawer.js +145 -148
  67. package/src/pb-edit-app.js +301 -229
  68. package/src/pb-edit-xml.js +98 -96
  69. package/src/pb-events.js +114 -107
  70. package/src/pb-facs-link.js +104 -102
  71. package/src/pb-facsimile.js +411 -413
  72. package/src/pb-formula.js +151 -153
  73. package/src/pb-geolocation.js +129 -131
  74. package/src/pb-grid-action.js +53 -56
  75. package/src/pb-grid.js +231 -228
  76. package/src/pb-highlight.js +140 -140
  77. package/src/pb-hotkeys.js +40 -42
  78. package/src/pb-i18n.js +101 -104
  79. package/src/pb-image-strip.js +84 -78
  80. package/src/pb-lang.js +132 -128
  81. package/src/pb-leaflet-map.js +488 -485
  82. package/src/pb-link.js +126 -124
  83. package/src/pb-load.js +431 -426
  84. package/src/pb-login.js +291 -248
  85. package/src/pb-manage-odds.js +364 -318
  86. package/src/pb-map-icon.js +89 -89
  87. package/src/pb-map-layer.js +85 -85
  88. package/src/pb-markdown.js +90 -99
  89. package/src/pb-media-query.js +74 -72
  90. package/src/pb-mei.js +306 -295
  91. package/src/pb-message.js +144 -144
  92. package/src/pb-mixin.js +269 -264
  93. package/src/pb-navigation.js +80 -82
  94. package/src/pb-observable.js +38 -38
  95. package/src/pb-odd-editor.js +1053 -955
  96. package/src/pb-odd-elementspec-editor.js +348 -297
  97. package/src/pb-odd-model-editor.js +1061 -901
  98. package/src/pb-odd-parameter-editor.js +200 -178
  99. package/src/pb-odd-rendition-editor.js +136 -124
  100. package/src/pb-page.js +431 -421
  101. package/src/pb-paginate.js +202 -190
  102. package/src/pb-panel.js +191 -179
  103. package/src/pb-popover-themes.js +7 -5
  104. package/src/pb-popover.js +296 -287
  105. package/src/pb-print-preview.js +127 -127
  106. package/src/pb-progress.js +51 -51
  107. package/src/pb-repeat.js +105 -104
  108. package/src/pb-restricted.js +84 -77
  109. package/src/pb-search.js +252 -241
  110. package/src/pb-select-feature.js +127 -120
  111. package/src/pb-select-odd.js +132 -124
  112. package/src/pb-select-template.js +89 -78
  113. package/src/pb-select.js +251 -227
  114. package/src/pb-split-list.js +179 -174
  115. package/src/pb-svg.js +80 -79
  116. package/src/pb-table-column.js +54 -54
  117. package/src/pb-table-grid.js +221 -203
  118. package/src/pb-tabs.js +61 -63
  119. package/src/pb-tify.js +154 -154
  120. package/src/pb-timeline.js +271 -229
  121. package/src/pb-toggle-feature.js +182 -175
  122. package/src/pb-upload.js +184 -174
  123. package/src/pb-version.js +30 -30
  124. package/src/pb-view-annotate.js +132 -98
  125. package/src/pb-view.js +1289 -1270
  126. package/src/pb-zoom.js +75 -59
  127. package/src/polymer-hack.js +1 -1
  128. package/src/search-result-service.js +256 -223
  129. package/src/seed-element.js +13 -20
  130. package/src/settings.js +4 -4
  131. package/src/theming.js +96 -96
  132. package/src/urls.js +289 -289
  133. package/src/utils.js +53 -51
@@ -1,4 +1,4 @@
1
- import{f as e,N as t,j as o,k as i,l as s,A as a,L as r,c as n,h as l,b as d,w as p,p as c}from"./pb-mixin-b1caa22e.js";import{E as h,T as u,D as m,p as g}from"./vaadin-element-mixin-6633322b.js";import{h as b,g as v,F as f,D as y,z as w,A as _,c as x,P as $}from"./paper-checkbox-4f410b1f.js";import{a as S}from"./paper-listbox-c2468542.js";import"./paper-icon-button-0fb125c4.js";import"./jinn-codemirror-da0e2d1f.js";import{t as E,g as C}from"./pb-i18n-0611135a.js";const k=(()=>{if("undefined"==typeof self)return!1;if("top"in self&&self!==top)try{top}catch(e){return!1}return"showOpenFilePicker"in self})();k?Promise.resolve().then((function(){return B})):Promise.resolve().then((function(){return z})),k?Promise.resolve().then((function(){return O})):Promise.resolve().then((function(){return L}));const A=k?Promise.resolve().then((function(){return T})):Promise.resolve().then((function(){return j}));async function P(...e){return(await A).default(...e)}const R=async e=>{const t=await e.getFile();return t.handle=e,t};var B={__proto__:null,default:async(e=[{}])=>{Array.isArray(e)||(e=[e]);const t=[];e.forEach((e,o)=>{t[o]={description:e.description||"Files",accept:{}},e.mimeTypes?e.mimeTypes.map(i=>{t[o].accept[i]=e.extensions||[]}):t[o].accept["*/*"]=e.extensions||[]});const o=await window.showOpenFilePicker({id:e[0].id,startIn:e[0].startIn,types:t,multiple:e[0].multiple||!1,excludeAcceptAllOption:e[0].excludeAcceptAllOption||!1}),i=await Promise.all(o.map(R));return e[0].multiple?i:i[0]}};function M(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return(M=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var o=this.s.return;return void 0===o?Promise.resolve({value:e,done:!0}):t(o.apply(this.s,arguments))},throw:function(e){var o=this.s.return;return void 0===o?Promise.reject(e):t(o.apply(this.s,arguments))}},new M(e)}const I=async(e,t,o=e.name,i)=>{const s=[],a=[];var r,n=!1,l=!1;try{for(var d,p=function(e){var t,o,i,s=2;for("undefined"!=typeof Symbol&&(o=Symbol.asyncIterator,i=Symbol.iterator);s--;){if(o&&null!=(t=e[o]))return t.call(e);if(i&&null!=(t=e[i]))return new M(t.call(e));o="@@asyncIterator",i="@@iterator"}throw new TypeError("Object is not async iterable")}(e.values());n=!(d=await p.next()).done;n=!1){const r=d.value,n=`${o}/${r.name}`;"file"===r.kind?a.push(r.getFile().then(t=>(t.directoryHandle=e,t.handle=r,Object.defineProperty(t,"webkitRelativePath",{configurable:!0,enumerable:!0,get:()=>n})))):"directory"!==r.kind||!t||i&&i(r)||s.push(I(r,t,n,i))}}catch(e){l=!0,r=e}finally{try{n&&null!=p.return&&await p.return()}finally{if(l)throw r}}return[...(await Promise.all(s)).flat(),...await Promise.all(a)]};var O={__proto__:null,default:async(e={})=>{e.recursive=e.recursive||!1,e.mode=e.mode||"read";const t=await window.showDirectoryPicker({id:e.id,startIn:e.startIn,mode:e.mode});return(await(await t.values()).next()).done?[t]:I(t,e.recursive,void 0,e.skipDirectory)}},T={__proto__:null,default:async(e,t=[{}],o=null,i=!1,s=null)=>{Array.isArray(t)||(t=[t]),t[0].fileName=t[0].fileName||"Untitled";const a=[];let r=null;if(e instanceof Blob&&e.type?r=e.type:e.headers&&e.headers.get("content-type")&&(r=e.headers.get("content-type")),t.forEach((e,t)=>{a[t]={description:e.description||"Files",accept:{}},e.mimeTypes?(0===t&&r&&e.mimeTypes.push(r),e.mimeTypes.map(o=>{a[t].accept[o]=e.extensions||[]})):r?a[t].accept[r]=e.extensions||[]:a[t].accept["*/*"]=e.extensions||[]}),o)try{await o.getFile()}catch(e){if(o=null,i)throw e}const n=o||await window.showSaveFilePicker({suggestedName:t[0].fileName,id:t[0].id,startIn:t[0].startIn,types:a,excludeAcceptAllOption:t[0].excludeAcceptAllOption||!1});!o&&s&&s(n);const l=await n.createWritable();if("stream"in e){const t=e.stream();return await t.pipeTo(l),n}return"body"in e?(await e.body.pipeTo(l),n):(await l.write(await e),await l.close(),n)}},z={__proto__:null,default:async(e=[{}])=>(Array.isArray(e)||(e=[e]),new Promise((t,o)=>{const i=document.createElement("input");i.type="file";const s=[...e.map(e=>e.mimeTypes||[]),...e.map(e=>e.extensions||[])].join();i.multiple=e[0].multiple||!1,i.accept=s||"",i.style.display="none",document.body.append(i);const a=e=>{"function"==typeof r&&r(),t(e)},r=e[0].legacySetup&&e[0].legacySetup(a,()=>r(o),i),n=()=>{window.removeEventListener("focus",n),i.remove()};i.addEventListener("click",()=>{window.addEventListener("focus",n)}),i.addEventListener("change",()=>{window.removeEventListener("focus",n),i.remove(),a(i.multiple?Array.from(i.files):i.files[0])}),"showPicker"in HTMLInputElement.prototype?i.showPicker():i.click()}))},L={__proto__:null,default:async(e=[{}])=>(Array.isArray(e)||(e=[e]),e[0].recursive=e[0].recursive||!1,new Promise((t,o)=>{const i=document.createElement("input");i.type="file",i.webkitdirectory=!0;const s=e=>{"function"==typeof a&&a(),t(e)},a=e[0].legacySetup&&e[0].legacySetup(s,()=>a(o),i);i.addEventListener("change",()=>{let t=Array.from(i.files);e[0].recursive?e[0].recursive&&e[0].skipDirectory&&(t=t.filter(t=>t.webkitRelativePath.split("/").every(t=>!e[0].skipDirectory({name:t,kind:"directory"})))):t=t.filter(e=>2===e.webkitRelativePath.split("/").length),s(t)}),"showPicker"in HTMLInputElement.prototype?i.showPicker():i.click()}))},j={__proto__:null,default:async(e,t={})=>{Array.isArray(t)&&(t=t[0]);const o=document.createElement("a");let i=e;"body"in e&&(i=await async function(e,t){const o=e.getReader(),i=new ReadableStream({start:e=>async function t(){return o.read().then(({done:o,value:i})=>{if(!o)return e.enqueue(i),t();e.close()})}()}),s=new Response(i),a=await s.blob();return o.releaseLock(),new Blob([a],{type:t})}(e.body,e.headers.get("content-type"))),o.download=t.fileName||"Untitled",o.href=URL.createObjectURL(await i);const s=()=>{"function"==typeof a&&a()},a=t.legacySetup&&t.legacySetup(s,()=>a(),o);return o.addEventListener("click",()=>{setTimeout(()=>URL.revokeObjectURL(o.href),3e4),s()}),o.click(),null}};
1
+ import{f as e,N as t,j as o,k as i,l as s,A as a,L as r,c as n,h as l,b as d,w as p,p as c}from"./pb-mixin-886ece32.js";import{E as h,T as u,D as m,p as g}from"./vaadin-element-mixin-84fb7d82.js";import{h as b,g as v,F as f,D as y,z as w,A as _,c as x,P as $}from"./paper-checkbox-4f410b1f.js";import{a as S}from"./paper-listbox-c2468542.js";import"./paper-icon-button-72125e67.js";import"./jinn-codemirror-da0e2d1f.js";import{t as E,g as C}from"./pb-i18n-4cc00bfe.js";const k=(()=>{if("undefined"==typeof self)return!1;if("top"in self&&self!==top)try{top}catch(e){return!1}return"showOpenFilePicker"in self})();k?Promise.resolve().then((function(){return O})):Promise.resolve().then((function(){return T})),k?Promise.resolve().then((function(){return I})):Promise.resolve().then((function(){return z}));const A=k?Promise.resolve().then((function(){return j})):Promise.resolve().then((function(){return L}));async function P(...e){return(await A).default(...e)}const R=async e=>{const t=await e.getFile();return t.handle=e,t};var O={__proto__:null,default:async(e=[{}])=>{Array.isArray(e)||(e=[e]);const t=[];e.forEach((e,o)=>{t[o]={description:e.description||"Files",accept:{}},e.mimeTypes?e.mimeTypes.map(i=>{t[o].accept[i]=e.extensions||[]}):t[o].accept["*/*"]=e.extensions||[]});const o=await window.showOpenFilePicker({id:e[0].id,startIn:e[0].startIn,types:t,multiple:e[0].multiple||!1,excludeAcceptAllOption:e[0].excludeAcceptAllOption||!1}),i=await Promise.all(o.map(R));return e[0].multiple?i:i[0]}};function B(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return(B=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var o=this.s.return;return void 0===o?Promise.resolve({value:e,done:!0}):t(o.apply(this.s,arguments))},throw:function(e){var o=this.s.return;return void 0===o?Promise.reject(e):t(o.apply(this.s,arguments))}},new B(e)}const M=async(e,t,o=e.name,i)=>{const s=[],a=[];var r,n=!1,l=!1;try{for(var d,p=function(e){var t,o,i,s=2;for("undefined"!=typeof Symbol&&(o=Symbol.asyncIterator,i=Symbol.iterator);s--;){if(o&&null!=(t=e[o]))return t.call(e);if(i&&null!=(t=e[i]))return new B(t.call(e));o="@@asyncIterator",i="@@iterator"}throw new TypeError("Object is not async iterable")}(e.values());n=!(d=await p.next()).done;n=!1){const r=d.value,n=`${o}/${r.name}`;"file"===r.kind?a.push(r.getFile().then(t=>(t.directoryHandle=e,t.handle=r,Object.defineProperty(t,"webkitRelativePath",{configurable:!0,enumerable:!0,get:()=>n})))):"directory"!==r.kind||!t||i&&i(r)||s.push(M(r,t,n,i))}}catch(e){l=!0,r=e}finally{try{n&&null!=p.return&&await p.return()}finally{if(l)throw r}}return[...(await Promise.all(s)).flat(),...await Promise.all(a)]};var I={__proto__:null,default:async(e={})=>{e.recursive=e.recursive||!1,e.mode=e.mode||"read";const t=await window.showDirectoryPicker({id:e.id,startIn:e.startIn,mode:e.mode});return(await(await t.values()).next()).done?[t]:M(t,e.recursive,void 0,e.skipDirectory)}},j={__proto__:null,default:async(e,t=[{}],o=null,i=!1,s=null)=>{Array.isArray(t)||(t=[t]),t[0].fileName=t[0].fileName||"Untitled";const a=[];let r=null;if(e instanceof Blob&&e.type?r=e.type:e.headers&&e.headers.get("content-type")&&(r=e.headers.get("content-type")),t.forEach((e,t)=>{a[t]={description:e.description||"Files",accept:{}},e.mimeTypes?(0===t&&r&&e.mimeTypes.push(r),e.mimeTypes.map(o=>{a[t].accept[o]=e.extensions||[]})):r?a[t].accept[r]=e.extensions||[]:a[t].accept["*/*"]=e.extensions||[]}),o)try{await o.getFile()}catch(e){if(o=null,i)throw e}const n=o||await window.showSaveFilePicker({suggestedName:t[0].fileName,id:t[0].id,startIn:t[0].startIn,types:a,excludeAcceptAllOption:t[0].excludeAcceptAllOption||!1});!o&&s&&s(n);const l=await n.createWritable();if("stream"in e){const t=e.stream();return await t.pipeTo(l),n}return"body"in e?(await e.body.pipeTo(l),n):(await l.write(await e),await l.close(),n)}},T={__proto__:null,default:async(e=[{}])=>(Array.isArray(e)||(e=[e]),new Promise((t,o)=>{const i=document.createElement("input");i.type="file";const s=[...e.map(e=>e.mimeTypes||[]),...e.map(e=>e.extensions||[])].join();i.multiple=e[0].multiple||!1,i.accept=s||"",i.style.display="none",document.body.append(i);const a=e=>{"function"==typeof r&&r(),t(e)},r=e[0].legacySetup&&e[0].legacySetup(a,()=>r(o),i),n=()=>{window.removeEventListener("focus",n),i.remove()};i.addEventListener("click",()=>{window.addEventListener("focus",n)}),i.addEventListener("change",()=>{window.removeEventListener("focus",n),i.remove(),a(i.multiple?Array.from(i.files):i.files[0])}),"showPicker"in HTMLInputElement.prototype?i.showPicker():i.click()}))},z={__proto__:null,default:async(e=[{}])=>(Array.isArray(e)||(e=[e]),e[0].recursive=e[0].recursive||!1,new Promise((t,o)=>{const i=document.createElement("input");i.type="file",i.webkitdirectory=!0;const s=e=>{"function"==typeof a&&a(),t(e)},a=e[0].legacySetup&&e[0].legacySetup(s,()=>a(o),i);i.addEventListener("change",()=>{let t=Array.from(i.files);e[0].recursive?e[0].recursive&&e[0].skipDirectory&&(t=t.filter(t=>t.webkitRelativePath.split("/").every(t=>!e[0].skipDirectory({name:t,kind:"directory"})))):t=t.filter(e=>2===e.webkitRelativePath.split("/").length),s(t)}),"showPicker"in HTMLInputElement.prototype?i.showPicker():i.click()}))},L={__proto__:null,default:async(e,t={})=>{Array.isArray(t)&&(t=t[0]);const o=document.createElement("a");let i=e;"body"in e&&(i=await async function(e,t){const o=e.getReader(),i=new ReadableStream({start:e=>async function t(){return o.read().then(({done:o,value:i})=>{if(!o)return e.enqueue(i),t();e.close()})}()}),s=new Response(i),a=await s.blob();return o.releaseLock(),new Blob([a],{type:t})}(e.body,e.headers.get("content-type"))),o.download=t.fileName||"Untitled",o.href=URL.createObjectURL(await i);const s=()=>{"function"==typeof a&&a()},a=t.legacySetup&&t.legacySetup(s,()=>a(),o);return o.addEventListener("click",()=>{setTimeout(()=>URL.revokeObjectURL(o.href),3e4),s()}),o.click(),null}};
2
2
  /**
3
3
  * @license
4
4
  * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
@@ -644,302 +644,328 @@ This program is available under Apache License Version 2.0, available at https:/
644
644
 
645
645
  </paper-autocomplete-suggestions>
646
646
  `,is:"paper-autocomplete",properties:{autoValidate:{type:Boolean,value:!1},invalid:{type:Boolean,notify:!0,value:!1},autocapitalize:String,errorMessage:{type:String},label:String,noLabelFloat:{type:Boolean,value:!1},alwaysFloatLabel:{type:Boolean,value:!1},placeholder:String,required:{type:Boolean,value:!1},readonly:{type:Boolean,value:!1},focused:{type:Boolean,value:!1,notify:!0},disabled:{type:Boolean,value:!1},source:{type:Array,observer:"_sourceChanged"},textProperty:{type:String,value:"text"},valueProperty:{type:String,value:"value"},value:{type:Object,notify:!0},text:{type:String,notify:!0,value:""},disableShowClear:{type:Boolean,value:!1},remoteSource:{type:Boolean,value:!1},eventNamespace:{type:String,value:"-"},minLength:{type:Number,value:1},pattern:String,allowedPattern:String,charCounter:{type:Boolean,value:!1},maxlength:{type:Number},name:String,queryFn:{type:Function},highlightFirst:{type:Boolean,value:!1},showResultsOnFocus:{type:Boolean,value:!1},_value:{value:void 0},_text:{value:void 0},_isClearButtonVisible:{type:Boolean,value:!1},_isSuggestionsOpened:{type:Boolean,value:!1},selectedOption:{type:Object,notify:!0}},observers:["_textObserver(text)"],_sourceChanged:function(e){var t=this.text;!Array.isArray(e)||0===e.length||null===t||t.length<this.minLength||this.$.autocompleteInput.focused&&this.$.paperAutocompleteSuggestions._handleSuggestions({target:{value:t}})},ready:function(){this._value=this.value,this.addEventListener("autocomplete"+this.eventNamespace+"selected",this._onAutocompleteSelected.bind(this))},_clear:function(){var e={text:this.text,value:this.value};this.value=null,this._value=null,this.text="",this._text="",this._fireEvent(e,"reset-blur"),this._hideClearButton(),this.$.autocompleteInput.focused||this.$.autocompleteInput.focus()},_fireEvent:function(e,t){var o=this._getId(),i="autocomplete"+this.eventNamespace+t;this.fire(i,{id:o,value:e[this.valueProperty]||e.value,text:e[this.textProperty]||e.text,target:this,option:e})},_textObserver:function(e){e&&e.trim()?this._showClearButton():this._hideClearButton()},_onAutocompleteSelected:function(e){var t=e.detail;this.value=t.value,this.text=t.text},_showClearButton:function(){this.disableShowClear||this._isClearButtonVisible||(this.$.clear.style.display="inline-block",this._isClearButtonVisible=!0)},_hideClearButton:function(){this._isClearButtonVisible&&(this.$.clear.style.display="none",this._isClearButtonVisible=!1)},_getId:function(){var e=this.getAttribute("id");return e||(e=this.dataset.id),e},getOption:function(){return{text:this.text,value:this.value}},setOption:function(e){this.text=e[this.textProperty]||e.text,this.value=e[this.valueProperty]||e.value,this._showClearButton()},disable:function(){this.disabled=!0},enable:function(){this.disabled=!1},suggestions:function(e){this.$.paperAutocompleteSuggestions.suggestions(e)},validate:function(){return this.$.autocompleteInput.validate()},clear:function(){this._value="",this._text="",this._clear()},reset:function(){this._clear()},hideSuggestions:function(){this._hideClearButton(),this.$.paperAutocompleteSuggestions.hideSuggestions()},onSelectHandler:function(e){this.$.paperAutocompleteSuggestions._onSelect(e)}});class oe extends r{static get styles(){return n`
647
- :host {
648
- display: block;
649
- }
650
- .wrapper{
651
- display:grid;
652
- grid-template-columns:150px auto 50px;
653
- grid-column-gap:20px;
654
- grid-row-gap:20px;
655
- margin-bottom:10px;
656
- }
657
-
658
- .editor label {
659
- margin-bottom:5px;
660
- font-size: 12px;
661
- font-weight: 400;
662
- color: var(--paper-grey-500);
663
- }
664
-
665
- paper-dropdown-menu{
666
- }
667
-
668
- paper-icon-button{
669
- align-self:center;
670
- }
671
- `}render(){return l`
672
- <div class="wrapper">
673
- <paper-dropdown-menu label="Scope">
674
- <paper-listbox id="scopeList" slot="dropdown-content" selected="${this.scope}" attr-for-selected="value"
675
- @iron-select="${this._listchanged}">
676
- ${this.scopes.map(e=>l`
677
- <paper-item value="${e}">${e}</paper-item>
678
- `)}
679
- </paper-listbox>
680
- </paper-dropdown-menu>
681
- <div class="editor">
682
- <label>Rendition</label>
683
- <jinn-codemirror
684
- id="editor"
685
- label="Rendition"
686
- code="${this.css||""}"
687
- mode="css"
688
- @update="${this._handleCodeChange}"></jinn-codemirror>
689
- </div>
690
- <paper-icon-button @click="${this._remove}" icon="delete" title="delete this rendition"></paper-icon-button>
647
+ :host {
648
+ display: block;
649
+ }
650
+ .wrapper {
651
+ display: grid;
652
+ grid-template-columns: 150px auto 50px;
653
+ grid-column-gap: 20px;
654
+ grid-row-gap: 20px;
655
+ margin-bottom: 10px;
656
+ }
657
+
658
+ .editor label {
659
+ margin-bottom: 5px;
660
+ font-size: 12px;
661
+ font-weight: 400;
662
+ color: var(--paper-grey-500);
663
+ }
664
+
665
+ paper-dropdown-menu {
666
+ }
667
+
668
+ paper-icon-button {
669
+ align-self: center;
670
+ }
671
+ `}render(){return l`
672
+ <div class="wrapper">
673
+ <paper-dropdown-menu label="Scope">
674
+ <paper-listbox
675
+ id="scopeList"
676
+ slot="dropdown-content"
677
+ selected="${this.scope}"
678
+ attr-for-selected="value"
679
+ @iron-select="${this._listchanged}"
680
+ >
681
+ ${this.scopes.map(e=>l` <paper-item value="${e}">${e}</paper-item> `)}
682
+ </paper-listbox>
683
+ </paper-dropdown-menu>
684
+ <div class="editor">
685
+ <label>Rendition</label>
686
+ <jinn-codemirror
687
+ id="editor"
688
+ label="Rendition"
689
+ code="${this.css||""}"
690
+ mode="css"
691
+ @update="${this._handleCodeChange}"
692
+ ></jinn-codemirror>
691
693
  </div>
694
+ <paper-icon-button
695
+ @click="${this._remove}"
696
+ icon="delete"
697
+ title="delete this rendition"
698
+ ></paper-icon-button>
699
+ </div>
700
+
701
+ <slot></slot>
702
+ `}static get properties(){return{scopes:{type:Array},css:{type:String,reflect:!0},scope:{type:String,reflect:!0},selected:{type:String}}}constructor(){super(),this.scopes=["","before","after"],this.css="",this.scope="",this.selected="",this._initialized=!1}connectedCallback(){super.connectedCallback(),this.css=this.css.trim(),this.dispatchEvent(new CustomEvent("rendition-connected",{composed:!0,bubbles:!0,detail:{target:this}}))}firstUpdated(e){this.refreshEditor(),this._initialized=!0}refreshEditor(){console.log("refreshEditor"),this.shadowRoot.getElementById("editor")}_remove(e){e.preventDefault(),this.dispatchEvent(new CustomEvent("remove-rendition",{}))}_handleCodeChange(){this.css=this.shadowRoot.getElementById("editor").value,this.dispatchEvent(new CustomEvent("rendition-changed",{composed:!0,bubbles:!0,detail:{name:this.name,css:this.css,scope:this.scope}}))}_listchanged(e){const t=this.shadowRoot.getElementById("scopeList");this.scope=t.selected}}customElements.define("pb-odd-rendition-editor",oe);class ie extends r{static get styles(){return n`
703
+ :host {
704
+ display: block;
705
+ }
706
+ .wrapper {
707
+ display: grid;
708
+ grid-template-columns: 150px auto 50px 50px;
709
+ grid-column-gap: 20px;
710
+ grid-row-gap: 20px;
711
+ margin-bottom: 10px;
712
+ }
713
+ paper-dropdown-menu {
714
+ align-self: start;
715
+ }
716
+ paper-icon-button,
717
+ paper-checkbox {
718
+ align-self: center;
719
+ margin-top: 16px;
720
+ }
721
+
722
+ .editor label {
723
+ margin-bottom: 5px;
724
+ font-size: 12px;
725
+ font-weight: 400;
726
+ color: var(--paper-grey-500);
727
+ }
728
+ `}render(){return l`
729
+ <div class="wrapper">
730
+ <paper-autocomplete
731
+ id="combo"
732
+ text="${this.name}"
733
+ placeholder="${E("odd.editor.model.param-name-placeholder")}"
734
+ label="Name"
735
+ .source="${this._currentParameters}"
736
+ ></paper-autocomplete>
737
+
738
+ <div class="editor">
739
+ <label>Parameter</label>
740
+ <jinn-codemirror
741
+ id="editor"
742
+ mode="xquery"
743
+ code="${this.value}"
744
+ linter="${this.endpoint}/${d(this.apiVersion,"1.0.0")?"modules/editor.xql":"api/lint"}"
745
+ ></jinn-codemirror>
746
+ </div>
747
+ <paper-checkbox id="set" ?checked="${this.setParam}" @change="${this._handleCodeChange}"
748
+ >${E("odd.editor.model.set-param")}</paper-checkbox
749
+ >
750
+ <paper-icon-button
751
+ @click="${this._delete}"
752
+ icon="delete"
753
+ title="delete this parameter"
754
+ ></paper-icon-button>
755
+ </div>
756
+ `}static get properties(){return{name:{type:String,reflect:!0},value:{type:String,reflect:!0},behaviour:{type:String},parameters:{type:Object},setParam:{type:Boolean,attribute:"set"},_currentParameters:{type:Array},endpoint:{type:String},apiVersion:{type:String}}}constructor(){super(),this.name="",this.value="",this.setParam=!1,this.behaviour="",this.currentParameters=[],this.parameters={"":[],alternate:["default","alternate","persistent"],anchor:["content","id"],block:["content"],body:["content"],break:["content","type","label"],cell:["content"],cit:["content","source"],document:["content"],figure:["content","title"],graphic:["content","url","width","height","scale","title"],heading:["content","level"],inline:["content"],link:["content","uri","target"],list:["content","type"],listItem:["content","n"],metadata:["content"],note:["content","place","label"],omit:[],paragraph:["content"],row:["content"],section:["content"],table:["content"],text:["content"],title:["content"],webcomponent:["content","name"]},this.selected="",this.endpoint=""}connectedCallback(){super.connectedCallback(),this.value=this.value.trim(),this.dispatchEvent(new CustomEvent("parameter-connected",{composed:!0,bubbles:!0,detail:{target:this}}))}attributeChangedCallback(e,t,o){super.attributeChangedCallback(e,t,o),"behaviour"===e&&(this._currentParameters=this.parameters[o])}firstUpdated(e){this.selected=this.parameters[this.behaviour]||[],this.requestUpdate(),this.shadowRoot.getElementById("combo").addEventListener("focused-changed",this._handleCodeChange.bind(this)),this.shadowRoot.getElementById("editor").addEventListener("update",this._handleCodeChange.bind(this))}refreshEditor(){this.shadowRoot.getElementById("editor")}_delete(e){console.log("parameter delete ",e),e.preventDefault(),this.dispatchEvent(new CustomEvent("parameter-remove",{}))}_handleCodeChange(e){console.log("_handleCodeChange ",e),this.value=this.shadowRoot.getElementById("editor").content||"",console.log("value %s",this.value),this.name=this.shadowRoot.getElementById("combo").text,this.setParam=this.shadowRoot.getElementById("set").checked,this.dispatchEvent(new CustomEvent("parameter-changed",{composed:!0,bubbles:!0,detail:{name:this.name,value:this.value,set:this.setParam}}))}}customElements.define("pb-odd-parameter-editor",ie);class se extends r{static get styles(){return n`
757
+ :host {
758
+ display: flex;
759
+ flex-direction: column;
760
+ }
761
+ h1,
762
+ h2,
763
+ h3,
764
+ h4,
765
+ h5,
766
+ h6 {
767
+ font-family: 'Oswald', Verdana, 'Helvetica', sans-serif;
768
+ font-weight: 400 !important;
769
+ }
692
770
 
771
+ form {
772
+ margin-bottom: 8px;
773
+ }
693
774
 
775
+ paper-input,
776
+ paper-autocomplete {
777
+ margin-bottom: 16px;
778
+ }
694
779
 
695
- <slot></slot>
696
-
697
- `}static get properties(){return{scopes:{type:Array},css:{type:String,reflect:!0},scope:{type:String,reflect:!0},selected:{type:String}}}constructor(){super(),this.scopes=["","before","after"],this.css="",this.scope="",this.selected="",this._initialized=!1}connectedCallback(){super.connectedCallback(),this.css=this.css.trim(),this.dispatchEvent(new CustomEvent("rendition-connected",{composed:!0,bubbles:!0,detail:{target:this}}))}firstUpdated(e){this.refreshEditor(),this._initialized=!0}refreshEditor(){console.log("refreshEditor");this.shadowRoot.getElementById("editor")}_remove(e){e.preventDefault(),this.dispatchEvent(new CustomEvent("remove-rendition",{}))}_handleCodeChange(){this.css=this.shadowRoot.getElementById("editor").value,this.dispatchEvent(new CustomEvent("rendition-changed",{composed:!0,bubbles:!0,detail:{name:this.name,css:this.css,scope:this.scope}}))}_listchanged(e){const t=this.shadowRoot.getElementById("scopeList");this.scope=t.selected}}customElements.define("pb-odd-rendition-editor",oe);class ie extends r{static get styles(){return n`
698
- :host {
699
- display: block;
700
- }
701
- .wrapper{
702
- display:grid;
703
- grid-template-columns:150px auto 50px 50px;
704
- grid-column-gap:20px;
705
- grid-row-gap:20px;
706
- margin-bottom:10px;
707
- }
708
- paper-dropdown-menu{
709
- align-self:start;
710
- }
711
- paper-icon-button, paper-checkbox {
712
- align-self: center;
713
- margin-top: 16px;
714
- }
715
-
716
- .editor label {
717
- margin-bottom:5px;
718
- font-size: 12px;
719
- font-weight: 400;
720
- color: var(--paper-grey-500);
721
- }
722
- `}render(){return l`
723
- <div class="wrapper">
724
-
725
- <paper-autocomplete id="combo" text="${this.name}" placeholder="${E("odd.editor.model.param-name-placeholder")}" label="Name"
726
- .source="${this._currentParameters}"></paper-autocomplete>
727
-
728
- <div class="editor">
729
- <label>Parameter</label>
730
- <jinn-codemirror id="editor"
731
- mode="xquery"
732
- code="${this.value}"
733
- linter="${this.endpoint}/${d(this.apiVersion,"1.0.0")?"modules/editor.xql":"api/lint"}"></jinn-codemirror>
734
- </div>
735
- <paper-checkbox id="set" ?checked="${this.setParam}" @change="${this._handleCodeChange}">${E("odd.editor.model.set-param")}</paper-checkbox>
736
- <paper-icon-button @click="${this._delete}" icon="delete" title="delete this parameter"></paper-icon-button>
737
- </div>
780
+ .models {
781
+ margin-left: 20px;
782
+ margin-top: 10px;
783
+ }
784
+
785
+ .btn,
786
+ .btn-group {
787
+ margin-top: 0;
788
+ margin-bottom: 0;
789
+ }
790
+
791
+ header {
792
+ // background-color: #d1dae0;
793
+ background: var(--paper-grey-300);
794
+ margin: 0;
795
+ }
796
+
797
+ header div {
798
+ display: flex;
799
+ flex-direction: row;
800
+ justify-content: space-between;
801
+ align-items: center;
802
+ }
803
+
804
+ header h4 {
805
+ padding: 4px 8px;
806
+ margin: 0;
807
+ display: grid;
808
+ grid-template-columns: 40px 40% auto;
809
+ }
810
+ h4 .btn-group {
811
+ text-align: right;
812
+ display: none;
813
+ }
814
+
815
+ #toggle,
816
+ .modelType {
817
+ align-self: center;
818
+ }
819
+
820
+ header div.info {
821
+ padding: 0 16px 4px;
822
+ margin: 0;
823
+ font-size: 85%;
824
+ display: block;
825
+ margin: 0 0 0 32px;
826
+ }
827
+ header div.info * {
828
+ display: block;
829
+ line-height: 1.2;
830
+ }
831
+
832
+ header .outputDisplay {
833
+ text-transform: uppercase;
834
+ }
835
+ header .description {
836
+ font-style: italic;
837
+ }
838
+
839
+ header .predicate {
840
+ color: #ff5722;
841
+ }
842
+
843
+ .predicate label,
844
+ .template label {
845
+ display: block;
846
+ font-size: 12px;
847
+ font-weight: 300;
848
+ color: rgb(115, 115, 115);
849
+ }
850
+
851
+ .model-collapse {
852
+ color: #000000;
853
+ cursor: pointer;
854
+ }
855
+
856
+ .model-collapse:hover {
857
+ text-decoration: none;
858
+ }
859
+
860
+ .behaviour {
861
+ color: #ff5722;
862
+ }
863
+
864
+ .behaviour:before {
865
+ content: ' [';
866
+ }
867
+
868
+ .behaviour:after {
869
+ content: ']';
870
+ }
871
+
872
+ .behaviourWrapper {
873
+ display: grid;
874
+ grid-template-columns: 140px 40px 140px auto;
875
+ }
876
+ .behaviourWrapper > * {
877
+ display: inline;
878
+ align-self: stretch;
879
+ }
880
+
881
+ .group {
882
+ margin: 0;
883
+ font-size: 16px;
884
+ font-weight: bold;
885
+ }
886
+
887
+ .group .title {
888
+ /*text-decoration: underline;*/
889
+ }
890
+
891
+ .renditions,
892
+ .parameters {
893
+ padding-left: 16px;
894
+ border-left: 3px solid #e0e0e0;
895
+ margin-bottom: 20px;
896
+ }
897
+
898
+ .renditions .group {
899
+ display: flex;
900
+ flex-direction: row;
901
+ justify-content: space-between;
902
+ align-items: center;
903
+ }
904
+
905
+ .predicate .form-control {
906
+ width: 100%;
907
+ }
908
+
909
+ .source {
910
+ text-decoration: none;
911
+ margin-bottom: 8px;
912
+ }
913
+
914
+ .selectOutput {
915
+ margin-right: 10px;
916
+ }
917
+
918
+ :host([currentselection]) > form > header {
919
+ @apply --shadow-elevation-4dp;
920
+ border-left: 3px solid var(--paper-blue-500);
921
+ }
922
+
923
+ paper-menu-button paper-icon-button {
924
+ margin-left: -10px;
925
+ }
926
+
927
+ /* need to play it save for FF */
928
+ :host([currentselection]) > form > header > h4 > .btn-group {
929
+ display: inline-block;
930
+ }
931
+ details {
932
+ display: block;
933
+ }
934
+
935
+ details summary {
936
+ display: none;
937
+ }
938
+
939
+ .renditions {
940
+ margin-top: 10px;
941
+ }
942
+
943
+ .details {
944
+ padding: 0px 50px 20px 20px;
945
+ background: var(--paper-grey-200);
946
+ }
947
+
948
+ details:not([open]) {
949
+ padding: 0;
950
+ }
951
+
952
+ .editor label {
953
+ margin-bottom: 5px;
954
+ font-size: 12px;
955
+ font-weight: 400;
956
+ color: var(--paper-grey-500);
957
+ }
738
958
 
739
-
740
- `}static get properties(){return{name:{type:String,reflect:!0},value:{type:String,reflect:!0},behaviour:{type:String},parameters:{type:Object},setParam:{type:Boolean,attribute:"set"},_currentParameters:{type:Array},endpoint:{type:String},apiVersion:{type:String}}}constructor(){super(),this.name="",this.value="",this.setParam=!1,this.behaviour="",this.currentParameters=[],this.parameters={"":[],alternate:["default","alternate","persistent"],anchor:["content","id"],block:["content"],body:["content"],break:["content","type","label"],cell:["content"],cit:["content","source"],document:["content"],figure:["content","title"],graphic:["content","url","width","height","scale","title"],heading:["content","level"],inline:["content"],link:["content","uri","target"],list:["content","type"],listItem:["content","n"],metadata:["content"],note:["content","place","label"],omit:[],paragraph:["content"],row:["content"],section:["content"],table:["content"],text:["content"],title:["content"],webcomponent:["content","name"]},this.selected="",this.endpoint=""}connectedCallback(){super.connectedCallback(),this.value=this.value.trim(),this.dispatchEvent(new CustomEvent("parameter-connected",{composed:!0,bubbles:!0,detail:{target:this}}))}attributeChangedCallback(e,t,o){super.attributeChangedCallback(e,t,o),"behaviour"===e&&(this._currentParameters=this.parameters[o])}firstUpdated(e){this.selected=this.parameters[this.behaviour]||[],this.requestUpdate(),this.shadowRoot.getElementById("combo").addEventListener("focused-changed",this._handleCodeChange.bind(this)),this.shadowRoot.getElementById("editor").addEventListener("update",this._handleCodeChange.bind(this))}refreshEditor(){this.shadowRoot.getElementById("editor")}_delete(e){console.log("parameter delete ",e),e.preventDefault(),this.dispatchEvent(new CustomEvent("parameter-remove",{}))}_handleCodeChange(e){console.log("_handleCodeChange ",e),this.value=this.shadowRoot.getElementById("editor").content||"",console.log("value %s",this.value),this.name=this.shadowRoot.getElementById("combo").text,this.setParam=this.shadowRoot.getElementById("set").checked,this.dispatchEvent(new CustomEvent("parameter-changed",{composed:!0,bubbles:!0,detail:{name:this.name,value:this.value,set:this.setParam}}))}}customElements.define("pb-odd-parameter-editor",ie);class se extends r{static get styles(){return n`
741
- :host {
742
- display: flex;
743
- flex-direction:column;
744
- }
745
- h1, h2, h3, h4, h5, h6 {
746
- font-family: "Oswald", Verdana, "Helvetica", sans-serif;
747
- font-weight: 400 !important;
748
- }
749
-
750
- form {
751
- margin-bottom: 8px;
752
- }
753
-
754
- paper-input, paper-autocomplete {
755
- margin-bottom: 16px;
756
- }
757
-
758
- .models {
759
- margin-left:20px;
760
- margin-top:10px;
761
- }
762
-
763
- .btn, .btn-group {
764
- margin-top: 0;
765
- margin-bottom: 0;
766
- }
767
-
768
- header {
769
- // background-color: #d1dae0;
770
- background:var(--paper-grey-300);
771
- margin:0;
772
- }
773
-
774
- header div {
775
- display: flex;
776
- flex-direction: row;
777
- justify-content: space-between;
778
- align-items: center;
779
- }
780
-
781
- header h4 {
782
- padding: 4px 8px;
783
- margin: 0;
784
- display: grid;
785
- grid-template-columns: 40px 40% auto;
786
- }
787
- h4 .btn-group{
788
- text-align: right;
789
- display: none;
790
- }
791
-
792
- #toggle, .modelType{
793
- align-self:center;
794
- }
795
-
796
- header div.info {
797
- padding: 0 16px 4px;
798
- margin: 0;
799
- font-size: 85%;
800
- display: block;
801
- margin:0 0 0 32px;
802
- }
803
- header div.info *{
804
- display: block;
805
- line-height: 1.2;
806
- }
807
-
808
- header .outputDisplay{
809
- text-transform: uppercase ;
810
- }
811
- header .description{
812
- font-style: italic;
813
- }
814
-
815
- header .predicate {
816
- color: #ff5722;
817
- }
818
-
819
- .predicate label, .template label {
820
- display: block;
821
- font-size: 12px;
822
- font-weight: 300;
823
- color: rgb(115, 115, 115);
824
- }
825
-
826
- .model-collapse {
827
- color: #000000;
828
- cursor: pointer;
829
- }
830
-
831
- .model-collapse:hover {
832
- text-decoration: none;
833
- }
834
-
835
- .behaviour {
836
- color: #ff5722;
837
- }
838
-
839
- .behaviour:before {
840
- content: ' [';
841
- }
842
-
843
- .behaviour:after {
844
- content: ']';
845
- }
846
-
847
- .behaviourWrapper{
848
- display:grid;
849
- grid-template-columns: 140px 40px 140px auto;
850
- }
851
- .behaviourWrapper > *{
852
- display:inline;
853
- align-self:stretch;
854
- }
855
-
856
- .group {
857
- margin: 0;
858
- font-size: 16px;
859
- font-weight: bold;
860
- }
861
-
862
- .group .title {
863
- /*text-decoration: underline;*/
864
- }
865
-
866
- .renditions, .parameters {
867
- padding-left: 16px;
868
- border-left: 3px solid #e0e0e0;
869
- margin-bottom:20px;
870
- }
871
-
872
- .renditions .group {
873
- display: flex;
874
- flex-direction: row;
875
- justify-content: space-between;
876
- align-items: center;
877
- }
878
-
879
- .predicate .form-control {
880
- width: 100%;
881
- }
882
-
883
- .source {
884
- text-decoration: none;
885
- margin-bottom: 8px;
886
- }
887
-
888
- .selectOutput {
889
- margin-right: 10px;
890
- }
891
-
892
- :host([currentselection]) > form > header{
893
- @apply --shadow-elevation-4dp;
894
- border-left:3px solid var(--paper-blue-500);
895
- }
896
-
897
- paper-menu-button paper-icon-button{
898
- margin-left:-10px;
899
- }
900
-
901
- /* need to play it save for FF */
902
- :host([currentselection]) > form > header > h4 > .btn-group{
903
- display: inline-block;
904
- }
905
- details {
906
- display: block;
907
- }
908
-
909
- details summary {
910
- display: none;
911
- }
912
-
913
- .renditions{
914
- margin-top:10px;
915
- }
916
-
917
- .details{
918
- padding:0px 50px 20px 20px;
919
- background:var(--paper-grey-200);
920
- }
921
-
922
- details:not([open]) {
923
- padding: 0;
924
- }
925
-
926
- .editor label {
927
- margin-bottom:5px;
928
- font-size: 12px;
929
- font-weight: 400;
930
- color: var(--paper-grey-500);
931
- }
932
-
933
- .horizontal {
934
- display: flex;
935
- flex-wrap: wrap;
936
- justify-content: space-between;
937
- }
938
-
939
- #mode {
940
- min-width: 18em;
941
- }
942
- `}static get properties(){return{behaviour:{type:String},predicate:{type:String,reflect:!0,converter:(e,t)=>"null"===e.toLowerCase()?"":e},type:{type:String,reflect:!0},template:{type:String,reflect:!0,converter:(e,t)=>"null"===e.toLowerCase()?"":e},output:{type:String,reflect:!0,converter:(e,t)=>"null"===e.toLowerCase()?"":e},css:{type:String,converter:(e,t)=>"null"===e.toLowerCase()?"":e},mode:{type:String},model:{type:Object},models:{type:Array},parameters:{type:Array},renditions:{type:Array},desc:{type:String,converter:(e,t)=>"null"===e.toLowerCase()?"":e},sourcerend:{type:String},show:{type:Boolean,reflect:!0},outputs:{type:Array},behaviours:{type:Array},icon:{type:String},open:{type:String},hasCustomBehaviour:{type:Boolean},endpoint:{type:String},apiVersion:{type:String}}}constructor(){super(),this.behaviour="inline",this.predicate="",this.type="",this.template="",this.output="",this.css="",this.mode="",this.model={},this.model.models=[],this.parameters=[],this.renditions=[],this.desc="",this.sourcerend="",this.show=!1,this.outputs=["","web","print","epub","fo","latex","plain"],this.parentModel=[],this.behaviours=["alternate","anchor","block","body","break","cell","cit","document","figure","graphic","heading","inline","link","list","listItem","metadata","note","omit","paragraph","pass-through","row","section","table","text","title","webcomponent"],this.icon="expand-more",this.hasCustomBehaviour=!1}render(){let e;switch(this.output){case"web":case"epub":e="html";break;case"latex":e="tex";break;case"plain":e="default";break;case"fo":case"print":e="xml";break;default:e="html"}return l`
959
+ .horizontal {
960
+ display: flex;
961
+ flex-wrap: wrap;
962
+ justify-content: space-between;
963
+ }
964
+
965
+ #mode {
966
+ min-width: 18em;
967
+ }
968
+ `}static get properties(){return{behaviour:{type:String},predicate:{type:String,reflect:!0,converter:(e,t)=>"null"===e.toLowerCase()?"":e},type:{type:String,reflect:!0},template:{type:String,reflect:!0,converter:(e,t)=>"null"===e.toLowerCase()?"":e},output:{type:String,reflect:!0,converter:(e,t)=>"null"===e.toLowerCase()?"":e},css:{type:String,converter:(e,t)=>"null"===e.toLowerCase()?"":e},mode:{type:String},model:{type:Object},models:{type:Array},parameters:{type:Array},renditions:{type:Array},desc:{type:String,converter:(e,t)=>"null"===e.toLowerCase()?"":e},sourcerend:{type:String},show:{type:Boolean,reflect:!0},outputs:{type:Array},behaviours:{type:Array},icon:{type:String},open:{type:String},hasCustomBehaviour:{type:Boolean},endpoint:{type:String},apiVersion:{type:String}}}constructor(){super(),this.behaviour="inline",this.predicate="",this.type="",this.template="",this.output="",this.css="",this.mode="",this.model={},this.model.models=[],this.parameters=[],this.renditions=[],this.desc="",this.sourcerend="",this.show=!1,this.outputs=["","web","print","epub","fo","latex","plain"],this.parentModel=[],this.behaviours=["alternate","anchor","block","body","break","cell","cit","document","figure","graphic","heading","inline","link","list","listItem","metadata","note","omit","paragraph","pass-through","row","section","table","text","title","webcomponent"],this.icon="expand-more",this.hasCustomBehaviour=!1}render(){let e;switch(this.output){case"web":case"epub":e="html";break;case"latex":e="tex";break;case"plain":e="default";break;case"fo":case"print":e="xml";break;default:e="html"}return l`
943
969
  <form>
944
970
  <header>
945
971
  <h4>
@@ -959,20 +985,27 @@ This program is available under Apache License Version 2.0, available at https:/
959
985
  <paper-icon-button @click="${this._paste}" icon="content-paste"></paper-icon-button>
960
986
 
961
987
  ${this._isGroupOrSequence()?l`
962
- <paper-menu-button horizontal-align="right">
963
- <paper-icon-button icon="add" slot="dropdown-trigger"></paper-icon-button>
964
- <paper-listbox id="modelType" slot="dropdown-content" @iron-select="${this._addNested}"
965
- attr-for-selected="value">
966
- ${"modelSequence"===this.type?l`
967
- <paper-item value="model">model</paper-item>
988
+ <paper-menu-button horizontal-align="right">
989
+ <paper-icon-button
990
+ icon="add"
991
+ slot="dropdown-trigger"
992
+ ></paper-icon-button>
993
+ <paper-listbox
994
+ id="modelType"
995
+ slot="dropdown-content"
996
+ @iron-select="${this._addNested}"
997
+ attr-for-selected="value"
998
+ >
999
+ ${"modelSequence"===this.type?l` <paper-item value="model">model</paper-item> `:""}
1000
+ ${"modelGrp"===this.type?l`
1001
+ <paper-item value="modelSequence"
1002
+ >modelSequence</paper-item
1003
+ >
1004
+ <paper-item value="model">model</paper-item>
968
1005
  `:""}
969
- ${"modelGrp"===this.type?l`
970
- <paper-item value="modelSequence">modelSequence</paper-item>
971
- <paper-item value="model">model</paper-item>
972
- `:""}
973
- </paper-listbox>
974
- </paper-menu-button>
975
- `:""}
1006
+ </paper-listbox>
1007
+ </paper-menu-button>
1008
+ `:""}
976
1009
  </span>
977
1010
  </h4>
978
1011
  <div class="info">
@@ -988,9 +1021,7 @@ This program is available under Apache License Version 2.0, available at https:/
988
1021
  <paper-listbox id="output" slot="dropdown-content" attr-for-selected="value"
989
1022
  selected="${this.output}" @iron-select="${this._selectOutput}">
990
1023
 
991
- ${this.outputs.map(e=>l`
992
- <paper-item value="${e}">${e}</paper-item>
993
- `)}
1024
+ ${this.outputs.map(e=>l` <paper-item value="${e}">${e}</paper-item> `)}
994
1025
 
995
1026
  </paper-listbox>
996
1027
  </paper-dropdown-menu>
@@ -1014,479 +1045,615 @@ This program is available under Apache License Version 2.0, available at https:/
1014
1045
 
1015
1046
  ${this._isModel()?l`
1016
1047
  <div>
1017
- <div class="behaviourWrapper">
1018
- <paper-dropdown-menu label="behaviour" id="behaviourMenu" ?disabled="${this.hasCustomBehaviour}">
1019
- <paper-listbox id="behaviour" slot="dropdown-content" attr-for-selected="value"
1020
- selected="${this.behaviour}" @iron-select="${this._selectBehaviour}">
1021
- ${this.behaviours.map(e=>l`
1022
- <paper-item value="${e}">${e}</paper-item>
1023
- `)}
1024
- </paper-listbox>
1025
- </paper-dropdown-menu>
1026
- <span style="align-self:center;justify-self: center;"> ${E("odd.editor.model.link-with-or")} </span>
1027
- <paper-input id="custombehaviour" label="" @input="${this._handleCustomBehaviour}" placeHolder="${E("odd.editor.model.custom-behaviour-placeholder")}"></paper-input>
1028
- <span></span>
1029
- </div>
1030
-
1031
-
1032
-
1033
- <paper-input id="css" .value="${this.css}"
1034
- placeholder="${E("odd.editor.model.css-class-placeholder")}"
1035
- label="CSS Class"
1036
- @change="${this._inputCss}"></paper-input>
1037
-
1038
- <div class="editor">
1039
- <label>Template</label>
1040
- <jinn-codemirror id="template"
1041
- code="${this.template}"
1042
- mode="${e}"
1043
- placeholder="${E("odd.editor.model.template-placeholder")}"
1044
- @update="${this._updateTemplate}">
1045
- <div slot="toolbar">
1046
- <paper-button data-mode="xml" data-command="selectElement" data-key="mod-e mod-s"
1047
- title="Select element around current cursor position">&lt;|></paper-button>
1048
- <paper-button data-mode="xml" data-command="encloseWith" data-key="mod-e mod-e"
1049
- title="Enclose selection in new element">&lt;...&gt;</paper-button>
1050
- <paper-button data-mode="xml" data-command="removeEnclosing" title="Remove enclosing tags"
1051
- data-key="mod-e mod-r" class="sep">&lt;X></paper-button>
1052
- <paper-button data-mode="html" data-command="selectElement" data-key="mod-e mod-s"
1053
- title="Select element around current cursor position">&lt;|></paper-button>
1054
- <paper-button data-mode="html" data-command="encloseWith" data-key="mod-e mod-e"
1055
- title="Enclose selection in new element">&lt;...&gt;</paper-button>
1056
- <paper-button data-mode="html" data-command="removeEnclosing" title="Remove enclosing tags"
1057
- data-key="mod-e mod-r" class="sep">&lt;X></paper-button>
1058
- <paper-button data-key="mod-e mod-p" data-command="snippet" data-params="[[\${_}]]" title="Insert template variable">[[...]]</paper-button>
1059
- </div>
1060
- </jinn-codemirror>
1061
- </div>
1048
+ <div class="behaviourWrapper">
1049
+ <paper-dropdown-menu
1050
+ label="behaviour"
1051
+ id="behaviourMenu"
1052
+ ?disabled="${this.hasCustomBehaviour}"
1053
+ >
1054
+ <paper-listbox
1055
+ id="behaviour"
1056
+ slot="dropdown-content"
1057
+ attr-for-selected="value"
1058
+ selected="${this.behaviour}"
1059
+ @iron-select="${this._selectBehaviour}"
1060
+ >
1061
+ ${this.behaviours.map(e=>l` <paper-item value="${e}">${e}</paper-item> `)}
1062
+ </paper-listbox>
1063
+ </paper-dropdown-menu>
1064
+ <span style="align-self:center;justify-self: center;">
1065
+ ${E("odd.editor.model.link-with-or")}
1066
+ </span>
1067
+ <paper-input
1068
+ id="custombehaviour"
1069
+ label=""
1070
+ @input="${this._handleCustomBehaviour}"
1071
+ placeHolder="${E("odd.editor.model.custom-behaviour-placeholder")}"
1072
+ ></paper-input>
1073
+ <span></span>
1074
+ </div>
1075
+
1076
+ <paper-input
1077
+ id="css"
1078
+ .value="${this.css}"
1079
+ placeholder="${E("odd.editor.model.css-class-placeholder")}"
1080
+ label="CSS Class"
1081
+ @change="${this._inputCss}"
1082
+ ></paper-input>
1083
+
1084
+ <div class="editor">
1085
+ <label>Template</label>
1086
+ <jinn-codemirror
1087
+ id="template"
1088
+ code="${this.template}"
1089
+ mode="${e}"
1090
+ placeholder="${E("odd.editor.model.template-placeholder")}"
1091
+ @update="${this._updateTemplate}"
1092
+ >
1093
+ <div slot="toolbar">
1094
+ <paper-button
1095
+ data-mode="xml"
1096
+ data-command="selectElement"
1097
+ data-key="mod-e mod-s"
1098
+ title="Select element around current cursor position"
1099
+ >&lt;|></paper-button
1100
+ >
1101
+ <paper-button
1102
+ data-mode="xml"
1103
+ data-command="encloseWith"
1104
+ data-key="mod-e mod-e"
1105
+ title="Enclose selection in new element"
1106
+ >&lt;...&gt;</paper-button
1107
+ >
1108
+ <paper-button
1109
+ data-mode="xml"
1110
+ data-command="removeEnclosing"
1111
+ title="Remove enclosing tags"
1112
+ data-key="mod-e mod-r"
1113
+ class="sep"
1114
+ >&lt;X></paper-button
1115
+ >
1116
+ <paper-button
1117
+ data-mode="html"
1118
+ data-command="selectElement"
1119
+ data-key="mod-e mod-s"
1120
+ title="Select element around current cursor position"
1121
+ >&lt;|></paper-button
1122
+ >
1123
+ <paper-button
1124
+ data-mode="html"
1125
+ data-command="encloseWith"
1126
+ data-key="mod-e mod-e"
1127
+ title="Enclose selection in new element"
1128
+ >&lt;...&gt;</paper-button
1129
+ >
1130
+ <paper-button
1131
+ data-mode="html"
1132
+ data-command="removeEnclosing"
1133
+ title="Remove enclosing tags"
1134
+ data-key="mod-e mod-r"
1135
+ class="sep"
1136
+ >&lt;X></paper-button
1137
+ >
1138
+ <paper-button
1139
+ data-key="mod-e mod-p"
1140
+ data-command="snippet"
1141
+ data-params="[[\${_}]]"
1142
+ title="Insert template variable"
1143
+ >[[...]]</paper-button
1144
+ >
1145
+ </div>
1146
+ </jinn-codemirror>
1147
+ </div>
1062
1148
  </div>
1063
1149
 
1064
1150
  <div class="parameters">
1065
- <div class="group">
1066
- <span class="title">Parameters</span>
1067
- <paper-icon-button icon="add"
1068
- @click="${this._addParameter}"></paper-icon-button>
1069
- </div>
1070
- ${W(this.parameters,e=>e.name,(e,t)=>l`
1151
+ <div class="group">
1152
+ <span class="title">Parameters</span>
1153
+ <paper-icon-button
1154
+ icon="add"
1155
+ @click="${this._addParameter}"
1156
+ ></paper-icon-button>
1157
+ </div>
1158
+ ${W(this.parameters,e=>e.name,(e,t)=>l`
1071
1159
  <pb-odd-parameter-editor
1072
- behaviour="${this.behaviour}"
1073
- name="${e.name}"
1074
- value="${e.value}"
1075
- ?set="${e.set}"
1076
- endpoint="${this.endpoint}"
1077
- apiVersion="${this.apiVersion}"
1078
- @parameter-remove="${e=>this._removeParam(e,t)}"
1079
- @parameter-changed="${e=>this._updateParam(e,t)}"
1080
- ></pb-odd-parameter-editor>
1081
- `)}
1160
+ behaviour="${this.behaviour}"
1161
+ name="${e.name}"
1162
+ value="${e.value}"
1163
+ ?set="${e.set}"
1164
+ endpoint="${this.endpoint}"
1165
+ apiVersion="${this.apiVersion}"
1166
+ @parameter-remove="${e=>this._removeParam(e,t)}"
1167
+ @parameter-changed="${e=>this._updateParam(e,t)}"
1168
+ ></pb-odd-parameter-editor>
1169
+ `)}
1082
1170
  </div>
1083
1171
 
1084
1172
  <div class="renditions">
1085
- <div class="group">
1086
- <div>
1087
- <span class="title">Renditions</span>
1088
- <paper-icon-button icon="add" @click="${this._addRendition}"></paper-icon-button>
1089
- </div>
1090
- <div class="source">
1091
- <paper-checkbox ?checked="${this.sourcerend}" id="sourcerend">Use source rendition</paper-checkbox>
1092
- </div>
1173
+ <div class="group">
1174
+ <div>
1175
+ <span class="title">Renditions</span>
1176
+ <paper-icon-button
1177
+ icon="add"
1178
+ @click="${this._addRendition}"
1179
+ ></paper-icon-button>
1093
1180
  </div>
1094
-
1095
- ${W(this.renditions,e=>e.name,(e,t)=>l`
1096
- <pb-odd-rendition-editor scope="${e.scope}"
1097
- css="${e.css}"
1098
- @remove-rendition="${e=>this._removeRendition(e,t)}"
1099
- @rendition-changed="${e=>this._updateRendition(e,t)}"
1100
- ></pb-odd-rendition-editor>
1101
- `)}
1102
-
1181
+ <div class="source">
1182
+ <paper-checkbox ?checked="${this.sourcerend}" id="sourcerend"
1183
+ >Use source rendition</paper-checkbox
1184
+ >
1185
+ </div>
1186
+ </div>
1187
+
1188
+ ${W(this.renditions,e=>e.name,(e,t)=>l`
1189
+ <pb-odd-rendition-editor
1190
+ scope="${e.scope}"
1191
+ css="${e.css}"
1192
+ @remove-rendition="${e=>this._removeRendition(e,t)}"
1193
+ @rendition-changed="${e=>this._updateRendition(e,t)}"
1194
+ ></pb-odd-rendition-editor>
1195
+ `)}
1103
1196
  </div>
1104
- `:""}
1197
+ `:""}
1105
1198
  </details>
1106
1199
 
1107
1200
  <div class="models">
1108
1201
  ${W(this.model.models,(e,t)=>l`
1109
- <pb-odd-model-editor
1110
- behaviour="${e.behaviour||"inline"}"
1111
- predicate="${e.predicate}"
1112
- type="${e.type}"
1113
- output="${e.output}"
1114
- css="${e.css}"
1115
- mode="${e.mode}"
1116
- .model="${e}"
1117
- .parameters="${e.parameters}"
1118
- desc="${e.desc}"
1119
- sourcerend="${e.sourcerend}"
1120
- .renditions="${e.renditions}"
1121
- .template="${e.template}"
1122
- .show="${e.show}"
1123
- endpoint="${this.endpoint}"
1124
- apiVersion="${this.apiVersion}"
1125
- @model-remove="${this._removeModel}"
1126
- @model-move-down="${this._moveModelDown}"
1127
- @model-move-up="${this._moveModelUp}"
1128
- @model-changed="${this.handleModelChanged}"
1129
- @click="${e=>this.setCurrentSelection(e,t)}"
1130
- hasParent
1202
+ <pb-odd-model-editor
1203
+ behaviour="${e.behaviour||"inline"}"
1204
+ predicate="${e.predicate}"
1205
+ type="${e.type}"
1206
+ output="${e.output}"
1207
+ css="${e.css}"
1208
+ mode="${e.mode}"
1209
+ .model="${e}"
1210
+ .parameters="${e.parameters}"
1211
+ desc="${e.desc}"
1212
+ sourcerend="${e.sourcerend}"
1213
+ .renditions="${e.renditions}"
1214
+ .template="${e.template}"
1215
+ .show="${e.show}"
1216
+ endpoint="${this.endpoint}"
1217
+ apiVersion="${this.apiVersion}"
1218
+ @model-remove="${this._removeModel}"
1219
+ @model-move-down="${this._moveModelDown}"
1220
+ @model-move-up="${this._moveModelUp}"
1221
+ @model-changed="${this.handleModelChanged}"
1222
+ @click="${e=>this.setCurrentSelection(e,t)}"
1223
+ hasParent
1131
1224
  ></pb-odd-model-editor>
1132
- `)}
1225
+ `)}
1133
1226
 
1134
1227
  </div>
1135
1228
  </form>
1136
1229
  <pb-message id="dialog"></pb-message>
1137
- `}firstUpdated(){super.firstUpdated(),this.hasCustomBehaviour=this.behaviours.indexOf(this.behaviour)<0,this.hasCustomBehaviour&&(this.shadowRoot.getElementById("custombehaviour").value=this.behaviour)}updated(e){e.has("show")&&this.show&&this.refreshEditors()}refreshEditors(){if(console.log("refreshEditors"),this._isGroupOrSequence())return console.log("asfdfa");const e=this.shadowRoot.querySelectorAll("pb-odd-model-editor");for(let t=0;t<e.length;t++)e[t].refreshEditors();const t=this.shadowRoot.querySelectorAll("pb-odd-rendition-editor");for(let e=0;e<t.length;e++)t[e].refreshEditor();const o=this.shadowRoot.querySelectorAll("pb-odd-parameter-editor");for(let e=0;e<o.length;e++)o[e].refreshEditor()}toggle(e){this.show=!this.show,this.toggleButtonIcon();const t=this.model,o=Object.assign({},t,{show:this.show});this.model=o,this.refreshEditors(),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:t,newModel:o}}))}toggleButtonIcon(){this.show?this.icon="expand-less":this.icon="expand-more"}_isModel(){return"model"===this.type}_isGroupOrSequence(){return"model"!==this.type}static _templateMode(e){switch(e){case"latex":return"latex";case"web":default:return"xml"}}_changeSelection(e){if(e.detail.target==this)return;e.preventDefault(),e.stopPropagation(),null!=this.currentSelection&&this.currentSelection.removeAttribute("currentselection");const t=e.detail.target;t.setAttribute("currentselection","true"),this.currentSelection=t}_requestRemoval(e){e.preventDefault(),this.dispatchEvent(new CustomEvent("model-remove"))}_moveDown(e){e.preventDefault(),e.stopPropagation(),this.dispatchEvent(new CustomEvent("model-move-down",{composed:!0,bubbles:!0,detail:{model:this}}))}_moveUp(e){e.preventDefault(),e.stopPropagation(),this.dispatchEvent(new CustomEvent("model-move-up"))}_addNested(e){const t={behaviour:"inline",css:"",desc:"",predicate:"",type:e instanceof Event?e.detail.item.getAttribute("value"):e,output:"",sourcerend:!1,models:[],mode:"",parameters:[],renditions:[],template:"",show:!0},o=this.model,i=Array.from(this.model.models);i.unshift(t),this.model=Object.assign({},o,{models:i});this.shadowRoot.querySelector("#modelType").select(""),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:o,newModel:this.model}}))}addModel(e){"model"===e.type?(this.model.models.unshift(e),this.requestUpdate()):console.error("only models can be added to modelSequence or modelGrp")}_removeModel(e){console.log("_removeModel ",e),e.stopPropagation();const{model:t}=e.target,o=this.model.models.indexOf(t);this.shadowRoot.getElementById("dialog").confirm(C("odd.editor.model.delete-model-label"),C("odd.editor.model.delete-model-message")).then(()=>{const e=this.model,t=Array.from(this.model.models);t.splice(o,1),this.model=Object.assign({},e,{models:t}),this.models=t,this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:e,newModel:this.model}}))},()=>null)}_moveModelDown(e){console.log("MODEL._moveModelDown ",e),e.stopPropagation();const{model:t}=e.target,o=this.model.models.indexOf(t);if(o===this.model.models.length)return;const i=this.model,s=Array.from(this.model.models);s.splice(o,1),s.splice(o+1,0,t),this.model=Object.assign({},i,{models:s});const a=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o+1];this._setCurrentSelection(o+1,a),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:i,newModel:this.model}})),this.requestUpdate()}_moveModelUp(e){e.stopPropagation();const{model:t}=e.target,o=this.model.models.indexOf(t);if(0===o)return;const i=this.model,s=Array.from(this.model.models);s.splice(o,1),s.splice(o-1,0,t),this.model=Object.assign({},i,{models:s});const a=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o-1];this._setCurrentSelection(o-1,a),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:i,newModel:this.model}}))}handleModelChanged(e){console.log("handleModelChanged ",e,this),e.stopPropagation();const t=this.model,o=this.model.models.indexOf(e.detail.oldModel),i=Array.from(this.model.models);i.splice(o,1,e.detail.newModel),this.model=Object.assign({},t,{models:i}),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:t,newModel:this.model}}))}setCurrentSelection(e,t){e.preventDefault(),e.stopPropagation(),this._setCurrentSelection(t,e.target)}_setCurrentSelection(e,t){const o=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[e];o&&(o.hasAttribute("currentselection")||(this.dispatchEvent(new CustomEvent("current-changed",{composed:!0,bubbles:!0,detail:{target:t}})),this.requestUpdate()))}_inputDesc(e){this.desc=e.composedPath()[0].value,this._fireModelChanged("desc",this.desc)}_selectOutput(e){this.output=e.composedPath()[0].selected,this._fireModelChanged("output",this.output)}_updatePredicate(){this.predicate=this.shadowRoot.getElementById("predicate").value,console.log("_updatePredicate ",this.predicate),this._fireModelChanged("predicate",this.predicate)}_selectBehaviour(e){this.behaviour=e.composedPath()[0].selected,this._fireModelChanged("behaviour",this.behaviour)}_inputCss(e){this.css=e.composedPath()[0].value,this._fireModelChanged("css",this.css)}_inputMode(e){this.mode=e.composedPath()[0].value,this._fireModelChanged("mode",this.mode)}_updateTemplate(e){this.template=this.shadowRoot.getElementById("template").content,this._fireModelChanged("template",this.template)}_addParameter(e){this.parameters.push({name:"",value:""}),this._fireModelChanged("parameters",this.parameters)}_updateParam(e,t){this.parameters[t].name=e.detail.name,this.parameters[t].value=e.detail.value,this.parameters[t].set=e.detail.set,this._fireModelChanged("parameters",this.parameters)}_removeParam(e,t){this.parameters.splice(t,1),this._fireModelChanged("parameters",this.parameters)}_addRendition(e){this.renditions.push({scope:"",css:""}),this._fireModelChanged("renditions",this.renditions)}_updateRendition(e,t){this.renditions[t].css=e.detail.css,this.renditions[t].scope=e.detail.scope,this._fireModelChanged("renditions",this.renditions)}_removeRendition(e,t){this.renditions.splice(t,1),this._fireModelChanged("renditions",this.renditions)}_fireModelChanged(e,t){const o=this.model;this.model=Object.assign({},this.model,{[e]:t}),console.log("model changed for %s: %o - %o",e,t,this.model),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:o,newModel:this.model}})),this.requestUpdate()}_copy(e){e.preventDefault(),e.stopPropagation(),console.log("odd-model.copy ",e),console.log("odd-model.copy data",this.model),this.dispatchEvent(new CustomEvent("odd-copy",{composed:!0,bubbles:!0,detail:{model:this.model}}))}_paste(e){console.log("model _paste ",e),this.dispatchEvent(new CustomEvent("odd-paste",{composed:!0,bubbles:!0,detail:{target:this}}))}_handleCustomBehaviour(e){this.behaviour=e.composedPath()[0].value,this._fireModelChanged("behaviour",this.behaviour),""===this.behaviour?(this.behaviour="inline",this.hasCustomBehaviour=!1):this.hasCustomBehaviour=!0,this.requestUpdate()}}customElements.define("pb-odd-model-editor",se);class ae extends r{static get styles(){return n`
1138
- :host {
1139
- display: block;
1140
- padding: 4px 10px;
1141
- height: auto;
1142
- }
1143
-
1144
- h1, h2, h3, h4, h5, h6 {
1145
- font-family: "Oswald", Verdana, "Helvetica", sans-serif;
1146
- font-weight: 400 !important;
1147
- }
1148
-
1149
-
1150
- input {
1151
- vertical-align: middle;
1152
- }
1153
-
1154
- .ident {
1155
- display: inline-block;
1156
- font-size:26px;
1157
- position:relative;
1158
- }
1159
- .mode{
1160
- font-size:10px;
1161
- display:inline-block;
1162
- text-transform:uppercase;
1163
- border-radius:12px;
1164
- color:var(--paper-grey-700);
1165
- background:var(--paper-grey-300);
1166
- padding:2px 6px;
1167
- border:thin solid var(--paper-grey-500);
1168
- margin-left:6px;
1169
- position:absolute;
1170
- top:8px;
1171
- }
1172
-
1173
- :host([currentselection]){
1174
- box-shadow: 0 6px 10px 0 rgba(0, 0, 0, 0.14),
1175
- 0 1px 18px 0 rgba(0, 0, 0, 0.12),
1176
- 0 3px 5px -1px rgba(0, 0, 0, 0.4);
1177
-
1178
- }
1179
-
1180
- :host([currentSelection]) > h3, :host([currentSelection]) > header{
1181
- border-left:thin solid var(--paper-blue-500);
1182
- }
1183
-
1184
-
1185
- h3{
1186
- display:grid;
1187
- grid-template-columns:260px auto 160px;
1188
- align-items:center;
1189
- }
1190
- h3 .controls{
1191
- text-align: right;
1192
- margin-right: 10px;
1193
- }
1194
-
1195
- h3 .ident{
1196
- align-self: center;
1197
- }
1198
-
1199
- paper-menu-button paper-icon-button{
1200
- margin-left:-10px;
1201
- }
1202
-
1203
- /*todo: this does not take effect*/
1204
- details.models{
1205
- --details-transition-duration:0.4s;
1206
- }
1207
-
1208
- .models{
1209
- padding:10px;
1210
- }
1211
- `}static get properties(){return{ident:{type:String},mode:{type:String},models:{type:Array},endpoint:{type:String},apiVersion:{type:String}}}constructor(){super(),this.ident="",this.mode="",this.models=[],this.icon="expand-more"}render(){return l`
1212
- <h3>
1213
- <span class="ident">${this.ident}<span class="mode">mode: ${this.mode}</span></span>
1214
- <span class="spacer"></span>
1215
-
1216
- <span class="controls">
1217
- <paper-icon-button @click="${this._remove}" icon="delete"></paper-icon-button>
1218
- <paper-icon-button @click="${this._paste}" icon="content-paste"></paper-icon-button>
1219
- <paper-menu-button horizontal-align="right">
1220
- <paper-icon-button icon="add" slot="dropdown-trigger"></paper-icon-button>
1221
- <paper-listbox id="addModel" slot="dropdown-content" @iron-select="${this._addModel}"
1222
- attr-for-selected="value">
1223
- <paper-item value="model">model</paper-item>
1224
- <paper-item value="modelSequence">modelSequence</paper-item>
1225
- <paper-item value="modelGrp">modelGrp</paper-item>
1226
- </paper-listbox>
1227
- </paper-menu-button>
1230
+ `}firstUpdated(){super.firstUpdated(),this.hasCustomBehaviour=this.behaviours.indexOf(this.behaviour)<0,this.hasCustomBehaviour&&(this.shadowRoot.getElementById("custombehaviour").value=this.behaviour)}updated(e){e.has("show")&&this.show&&this.refreshEditors()}refreshEditors(){if(console.log("refreshEditors"),this._isGroupOrSequence())return console.log("asfdfa");const e=this.shadowRoot.querySelectorAll("pb-odd-model-editor");for(let t=0;t<e.length;t++)e[t].refreshEditors();const t=this.shadowRoot.querySelectorAll("pb-odd-rendition-editor");for(let e=0;e<t.length;e++)t[e].refreshEditor();const o=this.shadowRoot.querySelectorAll("pb-odd-parameter-editor");for(let e=0;e<o.length;e++)o[e].refreshEditor()}toggle(e){this.show=!this.show,this.toggleButtonIcon();const t=this.model,o=Object.assign(Object.assign({},t),{},{show:this.show});this.model=o,this.refreshEditors(),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:t,newModel:o}}))}toggleButtonIcon(){this.show?this.icon="expand-less":this.icon="expand-more"}_isModel(){return"model"===this.type}_isGroupOrSequence(){return"model"!==this.type}static _templateMode(e){switch(e){case"latex":return"latex";case"web":default:return"xml"}}_changeSelection(e){if(e.detail.target==this)return;e.preventDefault(),e.stopPropagation(),null!=this.currentSelection&&this.currentSelection.removeAttribute("currentselection");const t=e.detail.target;t.setAttribute("currentselection","true"),this.currentSelection=t}_requestRemoval(e){e.preventDefault(),this.dispatchEvent(new CustomEvent("model-remove"))}_moveDown(e){e.preventDefault(),e.stopPropagation(),this.dispatchEvent(new CustomEvent("model-move-down",{composed:!0,bubbles:!0,detail:{model:this}}))}_moveUp(e){e.preventDefault(),e.stopPropagation(),this.dispatchEvent(new CustomEvent("model-move-up"))}_addNested(e){const t={behaviour:"inline",css:"",desc:"",predicate:"",type:e instanceof Event?e.detail.item.getAttribute("value"):e,output:"",sourcerend:!1,models:[],mode:"",parameters:[],renditions:[],template:"",show:!0},o=this.model,i=Array.from(this.model.models);i.unshift(t),this.model=Object.assign(Object.assign({},o),{},{models:i});this.shadowRoot.querySelector("#modelType").select(""),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:o,newModel:this.model}}))}addModel(e){"model"===e.type?(this.model.models.unshift(e),this.requestUpdate()):console.error("only models can be added to modelSequence or modelGrp")}_removeModel(e){console.log("_removeModel ",e),e.stopPropagation();const{model:t}=e.target,o=this.model.models.indexOf(t);this.shadowRoot.getElementById("dialog").confirm(C("odd.editor.model.delete-model-label"),C("odd.editor.model.delete-model-message")).then(()=>{const e=this.model,t=Array.from(this.model.models);t.splice(o,1),this.model=Object.assign(Object.assign({},e),{},{models:t}),this.models=t,this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:e,newModel:this.model}}))},()=>null)}_moveModelDown(e){console.log("MODEL._moveModelDown ",e),e.stopPropagation();const{model:t}=e.target,o=this.model.models.indexOf(t);if(o===this.model.models.length)return;const i=this.model,s=Array.from(this.model.models);s.splice(o,1),s.splice(o+1,0,t),this.model=Object.assign(Object.assign({},i),{},{models:s});const a=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o+1];this._setCurrentSelection(o+1,a),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:i,newModel:this.model}})),this.requestUpdate()}_moveModelUp(e){e.stopPropagation();const{model:t}=e.target,o=this.model.models.indexOf(t);if(0===o)return;const i=this.model,s=Array.from(this.model.models);s.splice(o,1),s.splice(o-1,0,t),this.model=Object.assign(Object.assign({},i),{},{models:s});const a=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o-1];this._setCurrentSelection(o-1,a),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:i,newModel:this.model}}))}handleModelChanged(e){console.log("handleModelChanged ",e,this),e.stopPropagation();const t=this.model,o=this.model.models.indexOf(e.detail.oldModel),i=Array.from(this.model.models);i.splice(o,1,e.detail.newModel),this.model=Object.assign(Object.assign({},t),{},{models:i}),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:t,newModel:this.model}}))}setCurrentSelection(e,t){e.preventDefault(),e.stopPropagation(),this._setCurrentSelection(t,e.target)}_setCurrentSelection(e,t){const o=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[e];o&&(o.hasAttribute("currentselection")||(this.dispatchEvent(new CustomEvent("current-changed",{composed:!0,bubbles:!0,detail:{target:t}})),this.requestUpdate()))}_inputDesc(e){this.desc=e.composedPath()[0].value,this._fireModelChanged("desc",this.desc)}_selectOutput(e){this.output=e.composedPath()[0].selected,this._fireModelChanged("output",this.output)}_updatePredicate(){this.predicate=this.shadowRoot.getElementById("predicate").value,console.log("_updatePredicate ",this.predicate),this._fireModelChanged("predicate",this.predicate)}_selectBehaviour(e){this.behaviour=e.composedPath()[0].selected,this._fireModelChanged("behaviour",this.behaviour)}_inputCss(e){this.css=e.composedPath()[0].value,this._fireModelChanged("css",this.css)}_inputMode(e){this.mode=e.composedPath()[0].value,this._fireModelChanged("mode",this.mode)}_updateTemplate(e){this.template=this.shadowRoot.getElementById("template").content,this._fireModelChanged("template",this.template)}_addParameter(e){this.parameters.push({name:"",value:""}),this._fireModelChanged("parameters",this.parameters)}_updateParam(e,t){this.parameters[t].name=e.detail.name,this.parameters[t].value=e.detail.value,this.parameters[t].set=e.detail.set,this._fireModelChanged("parameters",this.parameters)}_removeParam(e,t){this.parameters.splice(t,1),this._fireModelChanged("parameters",this.parameters)}_addRendition(e){this.renditions.push({scope:"",css:""}),this._fireModelChanged("renditions",this.renditions)}_updateRendition(e,t){this.renditions[t].css=e.detail.css,this.renditions[t].scope=e.detail.scope,this._fireModelChanged("renditions",this.renditions)}_removeRendition(e,t){this.renditions.splice(t,1),this._fireModelChanged("renditions",this.renditions)}_fireModelChanged(e,t){const o=this.model;this.model=Object.assign(Object.assign({},this.model),{},{[e]:t}),console.log("model changed for %s: %o - %o",e,t,this.model),this.dispatchEvent(new CustomEvent("model-changed",{composed:!0,bubbles:!0,detail:{oldModel:o,newModel:this.model}})),this.requestUpdate()}_copy(e){e.preventDefault(),e.stopPropagation(),console.log("odd-model.copy ",e),console.log("odd-model.copy data",this.model),this.dispatchEvent(new CustomEvent("odd-copy",{composed:!0,bubbles:!0,detail:{model:this.model}}))}_paste(e){console.log("model _paste ",e),this.dispatchEvent(new CustomEvent("odd-paste",{composed:!0,bubbles:!0,detail:{target:this}}))}_handleCustomBehaviour(e){this.behaviour=e.composedPath()[0].value,this._fireModelChanged("behaviour",this.behaviour),""===this.behaviour?(this.behaviour="inline",this.hasCustomBehaviour=!1):this.hasCustomBehaviour=!0,this.requestUpdate()}}customElements.define("pb-odd-model-editor",se);class ae extends r{static get styles(){return n`
1231
+ :host {
1232
+ display: block;
1233
+ padding: 4px 10px;
1234
+ height: auto;
1235
+ }
1228
1236
 
1237
+ h1,
1238
+ h2,
1239
+ h3,
1240
+ h4,
1241
+ h5,
1242
+ h6 {
1243
+ font-family: 'Oswald', Verdana, 'Helvetica', sans-serif;
1244
+ font-weight: 400 !important;
1245
+ }
1229
1246
 
1230
- </span>
1231
- </h3>
1247
+ input {
1248
+ vertical-align: middle;
1249
+ }
1232
1250
 
1233
- <div>
1234
- ${W(this.models,(e,t)=>l`
1251
+ .ident {
1252
+ display: inline-block;
1253
+ font-size: 26px;
1254
+ position: relative;
1255
+ }
1256
+ .mode {
1257
+ font-size: 10px;
1258
+ display: inline-block;
1259
+ text-transform: uppercase;
1260
+ border-radius: 12px;
1261
+ color: var(--paper-grey-700);
1262
+ background: var(--paper-grey-300);
1263
+ padding: 2px 6px;
1264
+ border: thin solid var(--paper-grey-500);
1265
+ margin-left: 6px;
1266
+ position: absolute;
1267
+ top: 8px;
1268
+ }
1269
+
1270
+ :host([currentselection]) {
1271
+ box-shadow: 0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12),
1272
+ 0 3px 5px -1px rgba(0, 0, 0, 0.4);
1273
+ }
1274
+
1275
+ :host([currentSelection]) > h3,
1276
+ :host([currentSelection]) > header {
1277
+ border-left: thin solid var(--paper-blue-500);
1278
+ }
1279
+
1280
+ h3 {
1281
+ display: grid;
1282
+ grid-template-columns: 260px auto 160px;
1283
+ align-items: center;
1284
+ }
1285
+ h3 .controls {
1286
+ text-align: right;
1287
+ margin-right: 10px;
1288
+ }
1289
+
1290
+ h3 .ident {
1291
+ align-self: center;
1292
+ }
1293
+
1294
+ paper-menu-button paper-icon-button {
1295
+ margin-left: -10px;
1296
+ }
1297
+
1298
+ /*todo: this does not take effect*/
1299
+ details.models {
1300
+ --details-transition-duration: 0.4s;
1301
+ }
1302
+
1303
+ .models {
1304
+ padding: 10px;
1305
+ }
1306
+ `}static get properties(){return{ident:{type:String},mode:{type:String},models:{type:Array},endpoint:{type:String},apiVersion:{type:String}}}constructor(){super(),this.ident="",this.mode="",this.models=[],this.icon="expand-more"}render(){return l`
1307
+ <h3>
1308
+ <span class="ident">${this.ident}<span class="mode">mode: ${this.mode}</span></span>
1309
+ <span class="spacer"></span>
1310
+
1311
+ <span class="controls">
1312
+ <paper-icon-button @click="${this._remove}" icon="delete"></paper-icon-button>
1313
+ <paper-icon-button @click="${this._paste}" icon="content-paste"></paper-icon-button>
1314
+ <paper-menu-button horizontal-align="right">
1315
+ <paper-icon-button icon="add" slot="dropdown-trigger"></paper-icon-button>
1316
+ <paper-listbox
1317
+ id="addModel"
1318
+ slot="dropdown-content"
1319
+ @iron-select="${this._addModel}"
1320
+ attr-for-selected="value"
1321
+ >
1322
+ <paper-item value="model">model</paper-item>
1323
+ <paper-item value="modelSequence">modelSequence</paper-item>
1324
+ <paper-item value="modelGrp">modelGrp</paper-item>
1325
+ </paper-listbox>
1326
+ </paper-menu-button>
1327
+ </span>
1328
+ </h3>
1329
+
1330
+ <div>
1331
+ ${W(this.models,(e,t)=>l`
1235
1332
  <pb-odd-model-editor
1236
- behaviour="${e.behaviour||""}"
1237
- predicate="${e.predicate}"
1238
- type="${e.type}"
1239
- output="${e.output}"
1240
- css="${e.css}"
1241
- mode="${e.mode}"
1242
- .model="${e}"
1243
- .parameters="${e.parameters}"
1244
- desc="${e.desc}"
1245
- .sourcerend="${e.sourcerend}"
1246
- .renditions="${e.renditions}"
1247
- .template="${e.template}"
1248
- .show="${e.show}"
1249
- .endpoint="${this.endpoint}"
1250
- .apiVersion="${this.apiVersion}"
1251
- @model-remove="${this._removeModel}"
1252
- @model-move-down="${this._moveModelDown}"
1253
- @model-move-up="${this._moveModelUp}"
1254
- @model-changed="${this.handleModelChanged}"
1255
- @click="${e=>this.setCurrentSelection(e,t)}"
1256
- ></pb-odd-model-editor>
1257
- `)}
1258
- </div>
1259
- <pb-message id="dialog"></pb-message>
1260
- `}addModel(e){this.models.unshift(e),this.requestUpdate()}_addModel(e){console.log("ELEMENTSPEC._addModel ",e);const t=this.shadowRoot.getElementById("addModel"),o={behaviour:"inline",css:"",mode:"",predicate:"",desc:"",type:t.selected,output:"",template:"",sourcerend:!1,models:[],parameters:[],renditions:[],show:!0},i=Array.from(this.models);i.unshift(o),this.models=i,this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}})),t.selected="",this.requestUpdate()}_remove(e){this.dispatchEvent(new CustomEvent("element-spec-removed",{composed:!0,bubbles:!0,detail:{target:this}}))}_paste(e){console.log("_paste ",e),this.dispatchEvent(new CustomEvent("odd-paste",{composed:!0,bubbles:!0,detail:{target:this}}))}setCurrentSelection(e,t){e.preventDefault(),e.stopPropagation(),this._setCurrentSelection(t,e.target)}_setCurrentSelection(e,t){const o=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[e];o&&(o.hasAttribute("currentselection")||(this.dispatchEvent(new CustomEvent("current-changed",{composed:!0,bubbles:!0,detail:{target:t}})),this.requestUpdate()))}_removeModel(e){console.log("_removeModel ",e),e.stopPropagation();const{model:t}=e.target,o=this.models.indexOf(t);this.shadowRoot.getElementById("dialog").confirm(C("odd.editor.model.delete-model-label"),C("odd.editor.model.delete-model-message")).then(()=>{const e=Array.from(this.models);e.splice(o,1),this.models=e,this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}}))},()=>null)}_moveModelDown(e){console.log("ELEMENTSPEC._moveModelDown ",e),e.stopPropagation();const{model:t}=e.target,o=this.models.indexOf(t);if(o===this.models.length)return;const i=Array.from(this.models);i.splice(o,1),i.splice(o+1,0,t),this.models=i;const s=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o+1];s&&(this._setCurrentSelection(o+1,s),this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}})))}_moveModelUp(e){e.stopPropagation();const{model:t}=e.target,o=this.models.indexOf(t);if(0===o)return;const i=Array.from(this.models);i.splice(o,1),i.splice(o-1,0,t),this.models=i;const s=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o-1];this._setCurrentSelection(o-1,s),this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}}))}handleModelChanged(e){e.stopPropagation();const t=this.models.indexOf(e.detail.oldModel),o=Array.from(this.models);o.splice(t,1,e.detail.newModel),this.models=o,this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}})),this.requestUpdate()}}customElements.define("pb-odd-elementspec-editor",ae);class re extends(g(c(r))){static get styles(){return n`
1261
- :host {
1262
- display: flex;
1263
- /*margin: 30px 20px;*/
1264
- margin:0;
1265
- padding:0;
1266
- height:auto;
1267
- }
1268
-
1269
- #layout {
1270
- width: 100%;
1271
- display: grid;
1272
- grid-template-columns: auto 1fr;
1273
- grid-template-rows: auto 1fr;
1274
- }
1275
-
1276
- #drawer {
1277
- grid-column: 1 / 1;
1278
- min-width: 320px;
1279
- }
1280
-
1281
- #navlist {
1282
- grid-column: 1 / 1;
1283
- grid-row: 2 / 2;
1284
- overflow: auto;
1285
- height: 100%;
1286
- }
1287
-
1288
- .specs {
1289
- grid-column: 2 / 2;
1290
- grid-row: 1 / span 2;
1291
- overflow: auto;
1292
- }
1293
-
1294
- section{
1295
- padding:20px;
1296
- }
1297
-
1298
- h3, h4 {
1299
- font-family: var(--pb-heading-font-family);
1300
- font-weight: var(--pb-heading-font-weight);
1301
- line-height: var(--pb-heading-line-height);
1302
- }
1303
-
1304
- /* ported over but not checked yet */
1305
-
1306
- .specs {
1307
- padding:6px;
1308
- }
1309
-
1310
- .metadata {
1311
- display: block;
1312
- }
1313
-
1314
- .metadata div {
1315
- padding: 0 16px 16px;
1316
- }
1317
-
1318
- .metadata paper-input {
1319
- margin-bottom: 10px;
1320
- }
1321
-
1322
- .metadata .extCssEdit {
1323
- display: flex;
1324
- align-items: center;
1325
- padding: 0;
1326
- }
1327
- .metadata .extCssEdit paper-input {
1328
- flex: 2;
1329
- }
1330
- .metadata .extCssEdit pb-edit-xml {
1331
- width: 40px;
1332
- }
1333
-
1334
- #jump-to {
1335
- margin-top: 1em;
1336
- }
1337
-
1338
- odd-model {
1339
- border-bottom: 1px solid #E0E0E0;
1340
- }
1341
- odd-model h4 {
1342
- margin-top: 15px;
1343
- padding-top: 5px;
1344
- border-top: 1px solid #E0E0E0;
1345
- }
1346
- .renditions {
1347
- margin-top: 10px;
1348
- }
1349
- .icons{
1350
- display:inline-block;
1351
- white-space: nowrap;
1352
- }
1353
-
1354
- details {
1355
- --details-transition-duration:0.8s;
1356
- }
1357
- details[open] {
1358
- padding: 0;
1359
- }
1360
-
1361
- pb-message#errorMsg{
1362
- background: var(--paper-red-500);
1363
- color:white;
1364
- }
1365
- .card-content{
1366
- height:100%;
1367
- overflow:auto;
1368
- }
1369
-
1370
- paper-tab{
1371
- width:100px;
1372
- }
1373
-
1374
- .editingView {
1375
- width:100%;
1376
- }
1377
-
1378
- vaadin-tabs{
1379
- margin-top:10px;
1380
- }
1381
-
1382
- vaadin-tab{
1383
- background:var(--paper-grey-200);
1384
- padding:0 6px;
1385
- border:thin solid var(--paper-grey-300);
1386
- border-bottom:none;
1387
- }
1388
- vaadin-tab[selected]{
1389
- background:white;
1390
- border-top-right-radius:20px;
1391
- box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14),
1392
- 0 1px 5px 0 rgba(0, 0, 0, 0.12),
1393
- 0 3px 1px -2px rgba(0, 0, 0, 0.2);
1394
-
1395
- }
1396
-
1397
- `}static get properties(){return Object.assign(Object.assign({},super.properties),{},{ident:{type:String},mode:{type:String},models:{type:Array},odd:{type:String,reflect:!0},elementSpecs:{type:Array},source:{type:String},title:{type:String},titleShort:{type:String,reflect:!0,attribute:"title-short"},description:{type:String},namespace:{type:String},rootPath:{type:String,attribute:"root-path"},loading:{type:Boolean},indentString:{type:String},outputPrefix:{type:String,attribute:"output-prefix"},outputRoot:{type:String,attribute:"output-root"},currentSelection:{type:Object},useNamespace:{type:Boolean},loggedIn:{type:Boolean},tabs:{type:Array},tabIndex:{type:Number,reflect:!0}})}constructor(){super(),this.ident="",this.mode="",this.models=()=>[],this.odd="",this.elementSpecs=[],this.source="",this.title="",this.titleShort="",this.description="",this.namespace="",this.rootPath="",this.loading=!1,this.indentString=" ",this.outputPrefix="",this.outputRoot="",this.currentSelection={},this.useNamespace=!1,this.loggedIn=!0,this.tabs=[],this.tabIndex=void 0,this.selectedNavIndex=0,this.cssFile="",this.hotkeys={save:"ctrl+shift+s,command+shift+s"},this._hasChanges=!1}render(){return l`
1398
- <iron-ajax id="loadContent"
1399
- handle-as="json" content-type="application/x-www-form-urlencoded"
1400
- with-credentials
1401
- method="GET"></iron-ajax>
1402
-
1403
- <iron-ajax id="saveOdd"
1404
- handle-as="json"
1405
- with-credentials></iron-ajax>
1406
-
1407
- <div id="layout">
1408
- <div id="drawer">
1409
- <slot id="slot"></slot>
1410
- <h3>
1411
- <span>${this.odd}</span>
1412
-
1413
- <span class="icons">
1414
- <pb-edit-xml id="editSource"><paper-icon-button icon="code" title="${E("odd.editor.odd-source")}"></paper-icon-button></pb-edit-xml>
1415
- <paper-icon-button @click="${()=>this.save(!0)}" icon="icons:cloud-download" title="${E(k?"odd.editor.save-as":"odd.editor.download")}"></paper-icon-button>
1416
- <paper-icon-button @click="${this._reload}" icon="refresh" title="${E("odd.editor.reload")}"></paper-icon-button>
1417
- <paper-icon-button @click="${()=>this.save(!1)}" icon="save" title="${E("odd.editor.save")} ${this.display("save")}"
1418
- ?disabled="${!this.loggedIn}"></paper-icon-button>
1419
- </span>
1420
- </h3>
1421
- <div id="new-element" class="input-group">
1422
- <paper-input id="identNew" label="${E("odd.editor.add-element")}" always-float-label="always-float-label">
1423
- <paper-icon-button slot="suffix" @click="${this.addElementSpec}" icon="add" tabindex="-1"></paper-icon-button>
1424
- </paper-input>
1425
- </div>
1426
-
1427
- <div id="jump-to">
1428
- <paper-autocomplete id="jumpTo" label="${E("odd.editor.jump-to")}" always-float-label="always-float-label"></paper-autocomplete>
1429
- </div>
1430
-
1431
- <h3>${E("odd.editor.specs")}</h3>
1432
- </div>
1433
- <div id="navlist">
1434
- ${W(this.elementSpecs,e=>e.ident,(e,t)=>l`
1435
- <paper-item id="es_${e.ident}"
1436
- index="${t}"
1437
- @click="${e=>this._openElementSpec(e,t)}">${e.ident}</paper-item>
1438
- `)}
1439
- </div>
1440
- <section class="specs" id="specs">
1441
-
1442
- <paper-card class="metadata">
1443
- <pb-collapse id="meta">
1444
- <h4 slot="collapse-trigger" class="panel-title">
1445
- ${this._computedTitle()}
1446
- </h4>
1447
- <div slot="collapse-content">
1448
- <paper-input id="title" name="title" value="${this.title}" label="${E("odd.editor.title")}"
1449
- placeholder="[${E("odd.editor.title-placeholder")}]"
1450
- @change="${this._inputTitle}"></paper-input>
1451
- <paper-input id="titleShort" name="short-title" .value="${this.titleShort}" label="${E("odd.editor.title-short")}"
1452
- placeholder="[${E("odd.editor.title-short-placeholder")}]"
1453
- @change="${e=>this.titleShort=e.composedPath()[0].value}"></paper-input>
1454
- <paper-input id="description" name="description" .value="${G(this.description)}" label="${E("odd.editor.description-label")}"
1455
- placeholder="[${E("odd.editor.description-placeholder")}]"
1456
- @change="${e=>this.description=e.composedPath()[0].value}"></paper-input>
1457
- <paper-input id="source" name="source" ?value="${this.source}" label="${E("odd.editor.source-label")}"
1458
- placeholder="[${E("odd.editor.source-placeholder")}]"
1459
- @change="${e=>this.source=e.composedPath()[0].value}"></paper-input>
1460
- <paper-checkbox id="useNamespace" @change="${this.setUseNamespace}">${E("odd.editor.use-namespace")}</paper-checkbox>
1461
- <paper-input id="namespace" name="namespace" value="${this.namespace}" label="Namespace" ?disabled="${!this.useNamespace}"
1462
- placeholder="[${E("odd.editor.namespace-placeholder")}]"
1463
- @change="${e=>this.namespace=e.composedPath()[0].value}"></paper-input>
1464
- <div class="extCssEdit">
1465
- <paper-input name="cssFile" value="${this.cssFile}" label="External CSS File"
1466
- placeholder="[External CSS file with additional class definitions]"
1467
- @change="${this._cssFileChanged}"></paper-input>
1468
- <pb-edit-xml id="editCSS"><paper-icon-button icon="create" title="${E("odd.editor.css-source")}"></paper-icon-button></pb-edit-xml>
1469
- </div>
1470
- </div>
1471
- </pb-collapse>
1472
- </paper-card>
1333
+ behaviour="${e.behaviour||""}"
1334
+ predicate="${e.predicate}"
1335
+ type="${e.type}"
1336
+ output="${e.output}"
1337
+ css="${e.css}"
1338
+ mode="${e.mode}"
1339
+ .model="${e}"
1340
+ .parameters="${e.parameters}"
1341
+ desc="${e.desc}"
1342
+ .sourcerend="${e.sourcerend}"
1343
+ .renditions="${e.renditions}"
1344
+ .template="${e.template}"
1345
+ .show="${e.show}"
1346
+ .endpoint="${this.endpoint}"
1347
+ .apiVersion="${this.apiVersion}"
1348
+ @model-remove="${this._removeModel}"
1349
+ @model-move-down="${this._moveModelDown}"
1350
+ @model-move-up="${this._moveModelUp}"
1351
+ @model-changed="${this.handleModelChanged}"
1352
+ @click="${e=>this.setCurrentSelection(e,t)}"
1353
+ ></pb-odd-model-editor>
1354
+ `)}
1355
+ </div>
1356
+ <pb-message id="dialog"></pb-message>
1357
+ `}addModel(e){this.models.unshift(e),this.requestUpdate()}_addModel(e){console.log("ELEMENTSPEC._addModel ",e);const t=this.shadowRoot.getElementById("addModel"),o={behaviour:"inline",css:"",mode:"",predicate:"",desc:"",type:t.selected,output:"",template:"",sourcerend:!1,models:[],parameters:[],renditions:[],show:!0},i=Array.from(this.models);i.unshift(o),this.models=i,this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}})),t.selected="",this.requestUpdate()}_remove(e){this.dispatchEvent(new CustomEvent("element-spec-removed",{composed:!0,bubbles:!0,detail:{target:this}}))}_paste(e){console.log("_paste ",e),this.dispatchEvent(new CustomEvent("odd-paste",{composed:!0,bubbles:!0,detail:{target:this}}))}setCurrentSelection(e,t){e.preventDefault(),e.stopPropagation(),this._setCurrentSelection(t,e.target)}_setCurrentSelection(e,t){const o=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[e];o&&(o.hasAttribute("currentselection")||(this.dispatchEvent(new CustomEvent("current-changed",{composed:!0,bubbles:!0,detail:{target:t}})),this.requestUpdate()))}_removeModel(e){console.log("_removeModel ",e),e.stopPropagation();const{model:t}=e.target,o=this.models.indexOf(t);this.shadowRoot.getElementById("dialog").confirm(C("odd.editor.model.delete-model-label"),C("odd.editor.model.delete-model-message")).then(()=>{const e=Array.from(this.models);e.splice(o,1),this.models=e,this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}}))},()=>null)}_moveModelDown(e){console.log("ELEMENTSPEC._moveModelDown ",e),e.stopPropagation();const{model:t}=e.target,o=this.models.indexOf(t);if(o===this.models.length)return;const i=Array.from(this.models);i.splice(o,1),i.splice(o+1,0,t),this.models=i;const s=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o+1];s&&(this._setCurrentSelection(o+1,s),this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}})))}_moveModelUp(e){e.stopPropagation();const{model:t}=e.target,o=this.models.indexOf(t);if(0===o)return;const i=Array.from(this.models);i.splice(o,1),i.splice(o-1,0,t),this.models=i;const s=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o-1];this._setCurrentSelection(o-1,s),this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}}))}handleModelChanged(e){e.stopPropagation();const t=this.models.indexOf(e.detail.oldModel),o=Array.from(this.models);o.splice(t,1,e.detail.newModel),this.models=o,this.dispatchEvent(new CustomEvent("element-spec-changed",{composed:!0,bubbles:!0,detail:{action:"models",ident:this.ident,models:this.models}})),this.requestUpdate()}}customElements.define("pb-odd-elementspec-editor",ae);class re extends(g(c(r))){static get styles(){return n`
1358
+ :host {
1359
+ display: flex;
1360
+ /*margin: 30px 20px;*/
1361
+ margin: 0;
1362
+ padding: 0;
1363
+ height: auto;
1364
+ }
1473
1365
 
1474
- <!-- todo: import elementspec to make it function -->
1366
+ #layout {
1367
+ width: 100%;
1368
+ display: grid;
1369
+ grid-template-columns: auto 1fr;
1370
+ grid-template-rows: auto 1fr;
1371
+ }
1475
1372
 
1476
- <div class="editingView">
1477
- <vaadin-tabs id="tabs" selected="${this.tabIndex}">
1478
- ${W(this.tabs,e=>e.id,(e,t)=>l`
1479
- <vaadin-tab name="${e}" @click="${t=>this._selectTab(t,e)}"><span style="padding-right:20px;">${e}</span><paper-icon-button icon="close" @click="${e=>this._closeTabHandler(e,t)}"></paper-icon-button></vaadin-tab>
1480
- `)}
1481
- </vaadin-tabs>
1373
+ #drawer {
1374
+ grid-column: 1 / 1;
1375
+ min-width: 320px;
1376
+ }
1482
1377
 
1483
- <div id="currentElement"></div>
1484
- </div>
1485
- </section>
1378
+ #navlist {
1379
+ grid-column: 1 / 1;
1380
+ grid-row: 2 / 2;
1381
+ overflow: auto;
1382
+ height: 100%;
1383
+ }
1486
1384
 
1487
- </div>
1385
+ .specs {
1386
+ grid-column: 2 / 2;
1387
+ grid-row: 1 / span 2;
1388
+ overflow: auto;
1389
+ }
1390
+
1391
+ section {
1392
+ padding: 20px;
1393
+ }
1394
+
1395
+ h3,
1396
+ h4 {
1397
+ font-family: var(--pb-heading-font-family);
1398
+ font-weight: var(--pb-heading-font-weight);
1399
+ line-height: var(--pb-heading-line-height);
1400
+ }
1488
1401
 
1402
+ /* ported over but not checked yet */
1489
1403
 
1490
- <pb-message id="dialog" hidden></pb-message>
1491
- <pb-message id="errorMsg"></pb-message>
1492
- `}firstUpdated(e){this.shadowRoot.getElementById("useNamespace").checked=this.useNamespace,this.jumpCtrl=this.shadowRoot.getElementById("jumpTo"),this.jumpCtrl.addEventListener("autocomplete-selected",this.jumpTo.bind(this));const t=this.querySelector("odd-selector");this.odd&&t&&(t.selected=this.odd,t.addEventListener("odd-selected",e=>{confirm("Any unsaved changes will be lost. Continue?")&&(this.odd=e.detail.odd,window.history.pushState({},"","?odd="+this.odd)),t.selected=this.odd})),this.addEventListener("current-changed",this._changeSelection),this.addEventListener("odd-copy",e=>this._copy(e)),this.addEventListener("odd-paste",e=>this._paste(e)),this.addEventListener("element-spec-removed",this.removeElementSpec.bind(this)),window.addEventListener("beforeunload",()=>"Any unsaved changes will be lost. Continue?"),this.subscribeTo("pb-login",e=>{this.loggedIn=null!=e.detail.user}),this.focus(),this.loadContent=this.shadowRoot.getElementById("loadContent"),this.rootPath=this.getAttribute("root-path"),p("pb-page-ready",()=>{this.load(),this.inited=!0}),this.registerHotkey("save",()=>this.save(!1))}setUseNamespace(){this.useNamespace=this.shadowRoot.getElementById("useNamespace").checked}async load(){if(this.loading)return;if(this.loading=!0,""===this.rootPath||""===this.odd)return;this.elementSpecs=[],document.dispatchEvent(new CustomEvent("pb-start-update"));this.shadowRoot.getElementById("editSource").setPath(this.rootPath+"/"+this.odd);const e={odd:this.odd,root:this.rootPath};this.loadContent.params=e,this.loadContent.url=`${this.getEndpoint()}/${this.lessThanApiVersion("1.0.0")?"modules/editor.xql":"api/odd/"+this.odd}`;const t=this.loadContent.generateRequest();this._hasChanges=!1,t.completes.then(e=>this.handleOdd(e))}handleOdd(e){const t=e.response;if(this.loggedIn=t.canWrite,this.source=t.source,this.title=t.title,this.titleShort=t.titleShort,this.description=t.description,this.cssFile=null==t.cssFile?"":t.cssFile,this.namespace=null!=t.namespace?t.namespace:"",this.useNamespace=null!=t.namespace,this.cssFile){this.shadowRoot.getElementById("editCSS").setPath(this.rootPath+"/"+this.cssFile)}this.elementSpecs=t.elementSpecs.map(e=>this.mapElementSpec(e)),this._updateAutoComplete(),this.requestUpdate(),this.loading=!1,document.dispatchEvent(new CustomEvent("pb-end-update")),document.title=this.titleShort||this.title}_updateAutoComplete(){this.shadowRoot.getElementById("jumpTo").source=this.elementSpecs.map(this._specMapper)}_cssFileChanged(e){if(this.cssFile=e.composedPath()[0].value,this.cssFile){this.shadowRoot.getElementById("editCSS").setPath(this.rootPath+"/"+this.cssFile)}}_navlistActiveChanged(e,t){this.selectedNavIndex=t,this.requestUpdate()}_returnTabs(){return this.tabs}_selectTab(e,t){const o=this.elementSpecs.find(e=>e.ident===t);this._updateElementspec(o)}_openElementSpec(e,t){console.log("_openElementSpec ",e,t);const o=this.elementSpecs[t];this._updateElementspec(o);const i=o.ident;if(this.tabs.indexOf(i)>=0)return this.tabIndex=this.tabs.indexOf(i),void this.requestUpdate();this.tabs.push(i),this.tabIndex=this.tabs.length-1,this.requestUpdate()}_updateElementspec(e){const t=this.shadowRoot.getElementById("currentElement");t.innerHTML="";const o=new ae;o.addEventListener("element-spec-changed",this.handleElementSpecChanged.bind(this)),o.ident=e.ident,o.models=e.models,o.mode=e.mode,o.endpoint=this._endpoint,o.apiVersion=this._apiVersion,o.hotkeys=this.hotkeys,t.appendChild(o)}_closeTabHandler(e,t){return console.log("_closeTabHandler ",t),e.preventDefault(),e.stopPropagation(),this._closeTab(t),!1}_closeTab(e){if(this.tabs.splice(e,1),0===this.tabs.length)this.shadowRoot.getElementById("currentElement").innerHTML="",this.tabIndex=0,this.tabs=[];else if(this.tabIndex>0&&this.tabIndex>=e){this.tabIndex-=1;const e=this.tabs[this.tabIndex];this._selectTab(null,e)}}attributeChangedCallback(e,t,o){super.attributeChangedCallback(e,t,o),"odd"==e&&t!==o&&this.inited&&this.load()}static get replaceCharMap(){return{'"':"&quot;","&":"&amp;","<":"&lt;",">":"&gt;"}}static get replaceCharRegexp(){return/"|&|<|>/g}static replaceChars(e){return re.replaceCharMap[e]}jumpTo(e){const t="#es_"+this.shadowRoot.getElementById("jumpTo").text,o=this.shadowRoot.querySelector(t);o&&(this.jumpCtrl.clear(),o.click())}_computedTitle(){return this.odd?this.title||this.titleShort||this.odd||"Loading ...":""}_copy(e){this.clipboard=e.detail.model;const t=JSON.parse(JSON.stringify(e.detail.model));this.clipboard=t}_paste(e){if(console.log("_paste ",e),console.log("_paste clipboard",this.clipboard),this.clipboard=={}||null==this.clipboard)return;const t=e.detail.target;t.addModel(this.clipboard),t.render()}_specMapper(e){return{text:e.ident,value:e.ident}}_specObserver(e){const t=this.elementSpecs.map(this._specMapper);this.jumpCtrl.source=t}mapElementSpec(e){return Object.assign({},e,{models:e.models.map(e=>this.addShowToModel(e))})}addShowToModel(e){if(e.models){const t=e.models.map(e=>this.addShowToModel(e));return Object.assign({},e,{models:t,show:!1})}return Object.assign({},e,{show:!1})}addElementSpec(e){const t=this.shadowRoot.getElementById("identNew").value;if(!t||0===t.length)return;if(this.elementSpecs.find(e=>e.ident===t)){console.log("<pb-odd-editor> element spec to be added already exists: %s",t);const e="#es_"+t,o=this.shadowRoot.querySelector(e);if(!o)return;return void o.click()}const o={action:"find",odd:this.odd,root:this.rootPath,ident:t},i={root:this.rootPath,ident:t},s=this.lessThanApiVersion("1.0.0")?o:i;this.loadContent.params=s,this.loadContent.url=`${this.getEndpoint()}/${this.lessThanApiVersion("1.0.0")?"modules/editor.xql":"api/odd/"+this.odd}`,this.loadContent.generateRequest().completes.then(this._handleElementSpecResponse.bind(this))}_handleElementSpecResponse(e){const t=this.shadowRoot.getElementById("identNew"),o=e.response,i=t.value,s={ident:i,mode:"not-found"===o.status?"add":"change",models:o.models||[]};this.elementSpecs.unshift(s),t.value="",this.tabs.push(i),this.tabIndex=this.tabs.length-1,this.elementSpecs.sort((e,t)=>e.ident.localeCompare(t.ident)),this.requestUpdate().then(()=>{const e=this.shadowRoot.querySelectorAll("paper-item"),t=this.elementSpecs.indexOf(s);this._updateAutoComplete(),e[t].click(),e[t].focus()})}removeElementSpec(e){const t=e.detail.target.ident;this.shadowRoot.getElementById("dialog").confirm(C("browse.delete"),C("odd.editor.delete-spec",{ident:t})).then(()=>{const e=this.elementSpecs.findIndex(e=>e.ident===t);this.elementSpecs.splice(e,1),this.requestUpdate();const o=this.shadowRoot.querySelector("vaadin-tab[selected]").getAttribute("name"),i=this.tabs.indexOf(o);this._closeTab(i)},()=>null)}serializeOdd(){const e=this.useNamespace?` ns="${this.namespace}"`:"",t=this.source?` source="${this.source}"`:"",o=this.description?` <desc>${this.description}</desc>`:"";return`<schemaSpec xmlns="http://www.tei-c.org/ns/1.0" xmlns:pb="http://teipublisher.com/1.0"${e}${t}>\n${`${this.indentString}<title>${this.title}${o}</title>\n`}${this.titleShort?`${this.indentString}<title type="short">${this.titleShort}</title>\n`:""}${this.cssFile?`${this.indentString}<rendition source="${this.cssFile}"/>\n`:""}\n${this.elementSpecs.map(e=>this.serializeElementSpec(this.indentString,e)).join("")}</schemaSpec>\n`}serializeElementSpec(e,t){const o=t.mode?` mode="${t.mode}"`:"",i=e+this.indentString,s=t.models.map(e=>this.serializeModel(i,e)).join("");return`${e}<elementSpec ident="${t.ident}"${o}>\n${s}${e}</elementSpec>\n`}serializeModel(e,t){if("model"===t.type&&!t.behaviour)return"";const o=e+this.indentString,i=[this.serializeAttribute("output",t.output),this.serializeAttribute("predicate",t.predicate),"model"===t.type?this.serializeAttribute("behaviour",t.behaviour):"",this.serializeAttribute("cssClass",t.css),this.serializeAttribute("useSourceRendition",t.sourcerend),this.serializeAttribute("pb:mode",t.mode)].join(""),s=t.desc?o+"<desc>"+t.desc+"</desc>\n":"",a=t.models.map(e=>this.serializeModel(o,e)).join(""),r=t.parameters.map(e=>this.serializeParameter(o,e)).join(""),n=t.renditions.map(e=>this.serializeRendition(o,e)).join(""),l=`${s}${a}${r}${re.serializeTemplate(o,t.template)}${n}`,d=l.length>0?`>\n${l}${e}</${t.type}`:"/";return`${e}<${t.type}${i}${d}>\n`}serializeParameter(e,t){if(!t.name)return"";const o=this.serializeAttribute("name",t.name),i=this.serializeAttribute("value",t.value);return t.set?`${e}<pb:set-param xmlns=""${o}${i}/>\n`:`${e}<param${o}${i}/>\n`}serializeRendition(e,t){return`${e}<outputRendition xml:space="preserve" ${t.scope&&"null"!==t.scope?this.serializeAttribute("scope",t.scope):""}>\n${e}${re.escape(t.css)}\n${e}</outputRendition>\n`}static serializeTemplate(e,t){return t?`${e}<pb:template xml:space="preserve" xmlns="">${t}</pb:template>\n`:""}serializeAttribute(e,t){return t?` ${e}="${re.escape(t)}"`:""}static escape(e){return e?"string"==typeof e?e.replace(re.replaceCharRegexp,re.replaceChars):e:""}save(e=!1){document.dispatchEvent(new CustomEvent("pb-start-update"));const t=this.serializeOdd();this.shadowRoot.getElementById("dialog").show(C("odd.editor.save"),C("odd.editor.saving"));const o=this.shadowRoot.getElementById("saveOdd");o.url=`${this.getEndpoint()}/${this.lessThanApiVersion("1.0.0")?"modules/editor.xql":"api/odd/"+this.odd}`,this.lessThanApiVersion("1.0.0")?(o.contentType="application/x-www-form-urlencoded",o.method="POST",o.params=null,o.body={action:"save",root:this.rootPath,"output-prefix":this.outputPrefix,"output-root":this.outputRoot,odd:this.odd,data:t}):(o.contentType="application/xml",o.method="PUT",o.params={root:this.rootPath,"output-prefix":this.outputPrefix,"output-root":this.outputRoot},o.body=t);o.generateRequest().completes.then(t=>{this.handleSaveComplete(t,e)}).catch(this.handleSaveError.bind(this))}static _renderReport(e){return e.error?`\n <div class="list-group-item-danger">\n <h4 class="list-group-item-heading">${e.file}</h4>\n <h5 class="list-group-item-heading">Compilation error on line ${e.line}:</h5>\n <pre class="list-group-item-text">${e.error}</pre>\n <pre class="list-group-item-text">${e.message}</pre>\n </div>\n `:`\n <div class="list-group-item-success">\n <p class="list-group-item-text">Generated ${e.file}</p>\n </div>\n `}handleSaveComplete(e,t=!1){const o=e.response;if("denied"===o.status)return this.shadowRoot.getElementById("dialog").set(C("odd.editor.denied"),C("odd.editor.denied-message",{odd:this.odd})),void document.dispatchEvent(new CustomEvent("pb-end-update"));let i;if(this.lessThanApiVersion("1.0.0")){i=`<div class="list-group">${o.report.map(re._renderReport).join("")}</div>`}else{i=`<div class="list-group">${o.report}</div>`}if(this.shadowRoot.getElementById("dialog").set(C("odd.editor.saved"),i),this._hasChanges=!1,document.dispatchEvent(new CustomEvent("pb-end-update")),t){P(new Blob([o.source],{type:"application/xml"}),{fileName:this.odd,extensions:[".odd"]}).then(()=>console.log(`<pb-odd-editor> ${this.odd} exported`),()=>console.log("<pb-odd-editor> export aborted"))}}handleSaveError(e){this.shadowRoot.getElementById("dialog").set("Error",e.error),document.dispatchEvent(new CustomEvent("pb-end-update"))}_reload(){this.shadowRoot.getElementById("dialog").confirm(C("odd.editor.reload"),C("odd.editor.reload-confirm")).then(()=>{this.load(),this.tabs=[],this.tabIndex=0,this.shadowRoot.getElementById("currentElement").innerHTML=""},()=>null)}_setCurrentSelection(e){null!=this.currentSelection&&this.currentSelection.removeAttribute("currentselection"),this.currentSelection=e.target,this.currentSelection.setAttribute("currentselection","true")}_changeSelection(e){if(e.preventDefault(),e.stopPropagation(),e.detail.target===this)return;let t;this.currentSelection&&void 0!==this.currentSelection.tagName&&this.currentSelection.removeAttribute("currentselection"),t=e.detail.target?e.detail.target:e.target,t.setAttribute("currentselection","true"),this.currentSelection=t}_selectElementspec(e){this.currentElementSpec&&"PB-ODD-ELEMENTSPEC-EDITOR"===this.currentElementSpec.tagName&&this.currentElementSpec.removeAttribute("currentselection");const t=e.target;t.setAttribute("currentselection","true"),this.currentElementSpec=t}nsDisabled(){return!this.useNamespace}_handleLoadError(e){console.log("loading error occurred: ",e);const t=this.shadowRoot.getElementById("errorMsg");t.style.background="red";const o=this.shadowRoot.getElementById("loadContent").url;console.log("url ",o),t.show("Error: ","ODD file could not be loaded from "+o)}handleElementSpecChanged(e){this._hasChanges=!0;const t=this.elementSpecs.find(t=>t.ident===e.detail.ident),o=this.elementSpecs.indexOf(t),i=Object.assign({},t,{models:e.detail.models}),s=Array.from(this.elementSpecs);s.splice(o,1,i),this.elementSpecs=s}_inputTitle(e){this.title=e.composedPath()[0].value}}customElements.define("pb-odd-editor",re);export{re as PbOddEditor};
1404
+ .specs {
1405
+ padding: 6px;
1406
+ }
1407
+
1408
+ .metadata {
1409
+ display: block;
1410
+ }
1411
+
1412
+ .metadata div {
1413
+ padding: 0 16px 16px;
1414
+ }
1415
+
1416
+ .metadata paper-input {
1417
+ margin-bottom: 10px;
1418
+ }
1419
+
1420
+ .metadata .extCssEdit {
1421
+ display: flex;
1422
+ align-items: center;
1423
+ padding: 0;
1424
+ }
1425
+ .metadata .extCssEdit paper-input {
1426
+ flex: 2;
1427
+ }
1428
+ .metadata .extCssEdit pb-edit-xml {
1429
+ width: 40px;
1430
+ }
1431
+
1432
+ #jump-to {
1433
+ margin-top: 1em;
1434
+ }
1435
+
1436
+ odd-model {
1437
+ border-bottom: 1px solid #e0e0e0;
1438
+ }
1439
+ odd-model h4 {
1440
+ margin-top: 15px;
1441
+ padding-top: 5px;
1442
+ border-top: 1px solid #e0e0e0;
1443
+ }
1444
+ .renditions {
1445
+ margin-top: 10px;
1446
+ }
1447
+ .icons {
1448
+ display: inline-block;
1449
+ white-space: nowrap;
1450
+ }
1451
+
1452
+ details {
1453
+ --details-transition-duration: 0.8s;
1454
+ }
1455
+ details[open] {
1456
+ padding: 0;
1457
+ }
1458
+
1459
+ pb-message#errorMsg {
1460
+ background: var(--paper-red-500);
1461
+ color: white;
1462
+ }
1463
+ .card-content {
1464
+ height: 100%;
1465
+ overflow: auto;
1466
+ }
1467
+
1468
+ paper-tab {
1469
+ width: 100px;
1470
+ }
1471
+
1472
+ .editingView {
1473
+ width: 100%;
1474
+ }
1475
+
1476
+ vaadin-tabs {
1477
+ margin-top: 10px;
1478
+ }
1479
+
1480
+ vaadin-tab {
1481
+ background: var(--paper-grey-200);
1482
+ padding: 0 6px;
1483
+ border: thin solid var(--paper-grey-300);
1484
+ border-bottom: none;
1485
+ }
1486
+ vaadin-tab[selected] {
1487
+ background: white;
1488
+ border-top-right-radius: 20px;
1489
+ box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12),
1490
+ 0 3px 1px -2px rgba(0, 0, 0, 0.2);
1491
+ }
1492
+ `}static get properties(){return Object.assign(Object.assign({},super.properties),{},{ident:{type:String},mode:{type:String},models:{type:Array},odd:{type:String,reflect:!0},elementSpecs:{type:Array},source:{type:String},title:{type:String},titleShort:{type:String,reflect:!0,attribute:"title-short"},description:{type:String},namespace:{type:String},rootPath:{type:String,attribute:"root-path"},loading:{type:Boolean},indentString:{type:String},outputPrefix:{type:String,attribute:"output-prefix"},outputRoot:{type:String,attribute:"output-root"},currentSelection:{type:Object},useNamespace:{type:Boolean},loggedIn:{type:Boolean},tabs:{type:Array},tabIndex:{type:Number,reflect:!0}})}constructor(){super(),this.ident="",this.mode="",this.models=()=>[],this.odd="",this.elementSpecs=[],this.source="",this.title="",this.titleShort="",this.description="",this.namespace="",this.rootPath="",this.loading=!1,this.indentString=" ",this.outputPrefix="",this.outputRoot="",this.currentSelection={},this.useNamespace=!1,this.loggedIn=!0,this.tabs=[],this.tabIndex=void 0,this.selectedNavIndex=0,this.cssFile="",this.hotkeys={save:"ctrl+shift+s,command+shift+s"},this._hasChanges=!1}render(){return l`
1493
+ <iron-ajax
1494
+ id="loadContent"
1495
+ handle-as="json"
1496
+ content-type="application/x-www-form-urlencoded"
1497
+ with-credentials
1498
+ method="GET"
1499
+ ></iron-ajax>
1500
+
1501
+ <iron-ajax id="saveOdd" handle-as="json" with-credentials></iron-ajax>
1502
+
1503
+ <div id="layout">
1504
+ <div id="drawer">
1505
+ <slot id="slot"></slot>
1506
+ <h3>
1507
+ <span>${this.odd}</span>
1508
+
1509
+ <span class="icons">
1510
+ <pb-edit-xml id="editSource"
1511
+ ><paper-icon-button
1512
+ icon="code"
1513
+ title="${E("odd.editor.odd-source")}"
1514
+ ></paper-icon-button
1515
+ ></pb-edit-xml>
1516
+ <paper-icon-button
1517
+ @click="${()=>this.save(!0)}"
1518
+ icon="icons:cloud-download"
1519
+ title="${E(k?"odd.editor.save-as":"odd.editor.download")}"
1520
+ ></paper-icon-button>
1521
+ <paper-icon-button
1522
+ @click="${this._reload}"
1523
+ icon="refresh"
1524
+ title="${E("odd.editor.reload")}"
1525
+ ></paper-icon-button>
1526
+ <paper-icon-button
1527
+ @click="${()=>this.save(!1)}"
1528
+ icon="save"
1529
+ title="${E("odd.editor.save")} ${this.display("save")}"
1530
+ ?disabled="${!this.loggedIn}"
1531
+ ></paper-icon-button>
1532
+ </span>
1533
+ </h3>
1534
+ <div id="new-element" class="input-group">
1535
+ <paper-input
1536
+ id="identNew"
1537
+ label="${E("odd.editor.add-element")}"
1538
+ always-float-label="always-float-label"
1539
+ >
1540
+ <paper-icon-button
1541
+ slot="suffix"
1542
+ @click="${this.addElementSpec}"
1543
+ icon="add"
1544
+ tabindex="-1"
1545
+ ></paper-icon-button>
1546
+ </paper-input>
1547
+ </div>
1548
+
1549
+ <div id="jump-to">
1550
+ <paper-autocomplete
1551
+ id="jumpTo"
1552
+ label="${E("odd.editor.jump-to")}"
1553
+ always-float-label="always-float-label"
1554
+ ></paper-autocomplete>
1555
+ </div>
1556
+
1557
+ <h3>${E("odd.editor.specs")}</h3>
1558
+ </div>
1559
+ <div id="navlist">
1560
+ ${W(this.elementSpecs,e=>e.ident,(e,t)=>l`
1561
+ <paper-item
1562
+ id="es_${e.ident}"
1563
+ index="${t}"
1564
+ @click="${e=>this._openElementSpec(e,t)}"
1565
+ >${e.ident}</paper-item
1566
+ >
1567
+ `)}
1568
+ </div>
1569
+ <section class="specs" id="specs">
1570
+ <paper-card class="metadata">
1571
+ <pb-collapse id="meta">
1572
+ <h4 slot="collapse-trigger" class="panel-title">${this._computedTitle()}</h4>
1573
+ <div slot="collapse-content">
1574
+ <paper-input
1575
+ id="title"
1576
+ name="title"
1577
+ value="${this.title}"
1578
+ label="${E("odd.editor.title")}"
1579
+ placeholder="[${E("odd.editor.title-placeholder")}]"
1580
+ @change="${this._inputTitle}"
1581
+ ></paper-input>
1582
+ <paper-input
1583
+ id="titleShort"
1584
+ name="short-title"
1585
+ .value="${this.titleShort}"
1586
+ label="${E("odd.editor.title-short")}"
1587
+ placeholder="[${E("odd.editor.title-short-placeholder")}]"
1588
+ @change="${e=>this.titleShort=e.composedPath()[0].value}"
1589
+ ></paper-input>
1590
+ <paper-input
1591
+ id="description"
1592
+ name="description"
1593
+ .value="${G(this.description)}"
1594
+ label="${E("odd.editor.description-label")}"
1595
+ placeholder="[${E("odd.editor.description-placeholder")}]"
1596
+ @change="${e=>this.description=e.composedPath()[0].value}"
1597
+ ></paper-input>
1598
+ <paper-input
1599
+ id="source"
1600
+ name="source"
1601
+ ?value="${this.source}"
1602
+ label="${E("odd.editor.source-label")}"
1603
+ placeholder="[${E("odd.editor.source-placeholder")}]"
1604
+ @change="${e=>this.source=e.composedPath()[0].value}"
1605
+ ></paper-input>
1606
+ <paper-checkbox id="useNamespace" @change="${this.setUseNamespace}"
1607
+ >${E("odd.editor.use-namespace")}</paper-checkbox
1608
+ >
1609
+ <paper-input
1610
+ id="namespace"
1611
+ name="namespace"
1612
+ value="${this.namespace}"
1613
+ label="Namespace"
1614
+ ?disabled="${!this.useNamespace}"
1615
+ placeholder="[${E("odd.editor.namespace-placeholder")}]"
1616
+ @change="${e=>this.namespace=e.composedPath()[0].value}"
1617
+ ></paper-input>
1618
+ <div class="extCssEdit">
1619
+ <paper-input
1620
+ name="cssFile"
1621
+ value="${this.cssFile}"
1622
+ label="External CSS File"
1623
+ placeholder="[External CSS file with additional class definitions]"
1624
+ @change="${this._cssFileChanged}"
1625
+ ></paper-input>
1626
+ <pb-edit-xml id="editCSS"
1627
+ ><paper-icon-button
1628
+ icon="create"
1629
+ title="${E("odd.editor.css-source")}"
1630
+ ></paper-icon-button
1631
+ ></pb-edit-xml>
1632
+ </div>
1633
+ </div>
1634
+ </pb-collapse>
1635
+ </paper-card>
1636
+
1637
+ <!-- todo: import elementspec to make it function -->
1638
+
1639
+ <div class="editingView">
1640
+ <vaadin-tabs id="tabs" selected="${this.tabIndex}">
1641
+ ${W(this.tabs,e=>e.id,(e,t)=>l`
1642
+ <vaadin-tab name="${e}" @click="${t=>this._selectTab(t,e)}"
1643
+ ><span style="padding-right:20px;">${e}</span
1644
+ ><paper-icon-button
1645
+ icon="close"
1646
+ @click="${e=>this._closeTabHandler(e,t)}"
1647
+ ></paper-icon-button
1648
+ ></vaadin-tab>
1649
+ `)}
1650
+ </vaadin-tabs>
1651
+
1652
+ <div id="currentElement"></div>
1653
+ </div>
1654
+ </section>
1655
+ </div>
1656
+
1657
+ <pb-message id="dialog" hidden></pb-message>
1658
+ <pb-message id="errorMsg"></pb-message>
1659
+ `}firstUpdated(e){this.shadowRoot.getElementById("useNamespace").checked=this.useNamespace,this.jumpCtrl=this.shadowRoot.getElementById("jumpTo"),this.jumpCtrl.addEventListener("autocomplete-selected",this.jumpTo.bind(this));const t=this.querySelector("odd-selector");this.odd&&t&&(t.selected=this.odd,t.addEventListener("odd-selected",e=>{confirm("Any unsaved changes will be lost. Continue?")&&(this.odd=e.detail.odd,window.history.pushState({},"","?odd="+this.odd)),t.selected=this.odd})),this.addEventListener("current-changed",this._changeSelection),this.addEventListener("odd-copy",e=>this._copy(e)),this.addEventListener("odd-paste",e=>this._paste(e)),this.addEventListener("element-spec-removed",this.removeElementSpec.bind(this)),window.addEventListener("beforeunload",()=>"Any unsaved changes will be lost. Continue?"),this.subscribeTo("pb-login",e=>{this.loggedIn=null!=e.detail.user}),this.focus(),this.loadContent=this.shadowRoot.getElementById("loadContent"),this.rootPath=this.getAttribute("root-path"),p("pb-page-ready",()=>{this.load(),this.inited=!0}),this.registerHotkey("save",()=>this.save(!1))}setUseNamespace(){this.useNamespace=this.shadowRoot.getElementById("useNamespace").checked}async load(){if(this.loading)return;if(this.loading=!0,""===this.rootPath||""===this.odd)return;this.elementSpecs=[],document.dispatchEvent(new CustomEvent("pb-start-update"));this.shadowRoot.getElementById("editSource").setPath(`${this.rootPath}/${this.odd}`);const e={odd:this.odd,root:this.rootPath};this.loadContent.params=e,this.loadContent.url=`${this.getEndpoint()}/${this.lessThanApiVersion("1.0.0")?"modules/editor.xql":"api/odd/"+this.odd}`;const t=this.loadContent.generateRequest();this._hasChanges=!1,t.completes.then(e=>this.handleOdd(e))}handleOdd(e){const t=e.response;if(this.loggedIn=t.canWrite,this.source=t.source,this.title=t.title,this.titleShort=t.titleShort,this.description=t.description,this.cssFile=null==t.cssFile?"":t.cssFile,this.namespace=null!=t.namespace?t.namespace:"",this.useNamespace=null!=t.namespace,this.cssFile){this.shadowRoot.getElementById("editCSS").setPath(`${this.rootPath}/${this.cssFile}`)}this.elementSpecs=t.elementSpecs.map(e=>this.mapElementSpec(e)),this._updateAutoComplete(),this.requestUpdate(),this.loading=!1,document.dispatchEvent(new CustomEvent("pb-end-update")),document.title=this.titleShort||this.title}_updateAutoComplete(){this.shadowRoot.getElementById("jumpTo").source=this.elementSpecs.map(this._specMapper)}_cssFileChanged(e){if(this.cssFile=e.composedPath()[0].value,this.cssFile){this.shadowRoot.getElementById("editCSS").setPath(`${this.rootPath}/${this.cssFile}`)}}_navlistActiveChanged(e,t){this.selectedNavIndex=t,this.requestUpdate()}_returnTabs(){return this.tabs}_selectTab(e,t){const o=this.elementSpecs.find(e=>e.ident===t);this._updateElementspec(o)}_openElementSpec(e,t){console.log("_openElementSpec ",e,t);const o=this.elementSpecs[t];this._updateElementspec(o);const{ident:i}=o;if(this.tabs.indexOf(i)>=0)return this.tabIndex=this.tabs.indexOf(i),void this.requestUpdate();this.tabs.push(i),this.tabIndex=this.tabs.length-1,this.requestUpdate()}_updateElementspec(e){const t=this.shadowRoot.getElementById("currentElement");t.innerHTML="";const o=new ae;o.addEventListener("element-spec-changed",this.handleElementSpecChanged.bind(this)),o.ident=e.ident,o.models=e.models,o.mode=e.mode,o.endpoint=this._endpoint,o.apiVersion=this._apiVersion,o.hotkeys=this.hotkeys,t.appendChild(o)}_closeTabHandler(e,t){return console.log("_closeTabHandler ",t),e.preventDefault(),e.stopPropagation(),this._closeTab(t),!1}_closeTab(e){if(this.tabs.splice(e,1),0===this.tabs.length)this.shadowRoot.getElementById("currentElement").innerHTML="",this.tabIndex=0,this.tabs=[];else if(this.tabIndex>0&&this.tabIndex>=e){this.tabIndex-=1;const e=this.tabs[this.tabIndex];this._selectTab(null,e)}}attributeChangedCallback(e,t,o){super.attributeChangedCallback(e,t,o),"odd"==e&&t!==o&&this.inited&&this.load()}static get replaceCharMap(){return{'"':"&quot;","&":"&amp;","<":"&lt;",">":"&gt;"}}static get replaceCharRegexp(){return/"|&|<|>/g}static replaceChars(e){return re.replaceCharMap[e]}jumpTo(e){const t="#es_"+this.shadowRoot.getElementById("jumpTo").text,o=this.shadowRoot.querySelector(t);o&&(this.jumpCtrl.clear(),o.click())}_computedTitle(){return this.odd?this.title||this.titleShort||this.odd||"Loading ...":""}_copy(e){this.clipboard=e.detail.model;const t=JSON.parse(JSON.stringify(e.detail.model));this.clipboard=t}_paste(e){if(console.log("_paste ",e),console.log("_paste clipboard",this.clipboard),this.clipboard=={}||null==this.clipboard)return;const t=e.detail.target;t.addModel(this.clipboard),t.render()}_specMapper(e){return{text:e.ident,value:e.ident}}_specObserver(e){const t=this.elementSpecs.map(this._specMapper);this.jumpCtrl.source=t}mapElementSpec(e){return Object.assign(Object.assign({},e),{},{models:e.models.map(e=>this.addShowToModel(e))})}addShowToModel(e){if(e.models){const t=e.models.map(e=>this.addShowToModel(e));return Object.assign(Object.assign({},e),{},{models:t,show:!1})}return Object.assign(Object.assign({},e),{},{show:!1})}addElementSpec(e){const t=this.shadowRoot.getElementById("identNew").value;if(!t||0===t.length)return;if(this.elementSpecs.find(e=>e.ident===t)){console.log("<pb-odd-editor> element spec to be added already exists: %s",t);const e="#es_"+t,o=this.shadowRoot.querySelector(e);if(!o)return;return void o.click()}const o={action:"find",odd:this.odd,root:this.rootPath,ident:t},i={root:this.rootPath,ident:t},s=this.lessThanApiVersion("1.0.0")?o:i;this.loadContent.params=s,this.loadContent.url=`${this.getEndpoint()}/${this.lessThanApiVersion("1.0.0")?"modules/editor.xql":"api/odd/"+this.odd}`;this.loadContent.generateRequest().completes.then(this._handleElementSpecResponse.bind(this))}_handleElementSpecResponse(e){const t=this.shadowRoot.getElementById("identNew"),o=e.response,i=t.value,s={ident:i,mode:"not-found"===o.status?"add":"change",models:o.models||[]};this.elementSpecs.unshift(s),t.value="",this.tabs.push(i),this.tabIndex=this.tabs.length-1,this.elementSpecs.sort((e,t)=>e.ident.localeCompare(t.ident)),this.requestUpdate().then(()=>{const e=this.shadowRoot.querySelectorAll("paper-item"),t=this.elementSpecs.indexOf(s);this._updateAutoComplete(),e[t].click(),e[t].focus()})}removeElementSpec(e){const{ident:t}=e.detail.target;this.shadowRoot.getElementById("dialog").confirm(C("browse.delete"),C("odd.editor.delete-spec",{ident:t})).then(()=>{const e=this.elementSpecs.findIndex(e=>e.ident===t);this.elementSpecs.splice(e,1),this.requestUpdate();const o=this.shadowRoot.querySelector("vaadin-tab[selected]").getAttribute("name"),i=this.tabs.indexOf(o);this._closeTab(i)},()=>null)}serializeOdd(){const e=this.useNamespace?` ns="${this.namespace}"`:"",t=this.source?` source="${this.source}"`:"",o=this.description?` <desc>${this.description}</desc>`:"";return`<schemaSpec xmlns="http://www.tei-c.org/ns/1.0" xmlns:pb="http://teipublisher.com/1.0"${e}${t}>\n${`${this.indentString}<title>${this.title}${o}</title>\n`}${this.titleShort?`${this.indentString}<title type="short">${this.titleShort}</title>\n`:""}${this.cssFile?`${this.indentString}<rendition source="${this.cssFile}"/>\n`:""}\n${this.elementSpecs.map(e=>this.serializeElementSpec(this.indentString,e)).join("")}</schemaSpec>\n`}serializeElementSpec(e,t){const o=t.mode?` mode="${t.mode}"`:"",i=e+this.indentString,s=t.models.map(e=>this.serializeModel(i,e)).join("");return`${e}<elementSpec ident="${t.ident}"${o}>\n${s}${e}</elementSpec>\n`}serializeModel(e,t){if("model"===t.type&&!t.behaviour)return"";const o=e+this.indentString,i=[this.serializeAttribute("output",t.output),this.serializeAttribute("predicate",t.predicate),"model"===t.type?this.serializeAttribute("behaviour",t.behaviour):"",this.serializeAttribute("cssClass",t.css),this.serializeAttribute("useSourceRendition",t.sourcerend),this.serializeAttribute("pb:mode",t.mode)].join(""),s=t.desc?`${o}<desc>${t.desc}</desc>\n`:"",a=t.models.map(e=>this.serializeModel(o,e)).join(""),r=t.parameters.map(e=>this.serializeParameter(o,e)).join(""),n=t.renditions.map(e=>this.serializeRendition(o,e)).join(""),l=`${s}${a}${r}${re.serializeTemplate(o,t.template)}${n}`,d=l.length>0?`>\n${l}${e}</${t.type}`:"/";return`${e}<${t.type}${i}${d}>\n`}serializeParameter(e,t){if(!t.name)return"";const o=this.serializeAttribute("name",t.name),i=this.serializeAttribute("value",t.value);return t.set?`${e}<pb:set-param xmlns=""${o}${i}/>\n`:`${e}<param${o}${i}/>\n`}serializeRendition(e,t){return`${e}<outputRendition xml:space="preserve" ${t.scope&&"null"!==t.scope?this.serializeAttribute("scope",t.scope):""}>\n${e}${re.escape(t.css)}\n${e}</outputRendition>\n`}static serializeTemplate(e,t){return t?`${e}<pb:template xml:space="preserve" xmlns="">${t}</pb:template>\n`:""}serializeAttribute(e,t){return t?` ${e}="${re.escape(t)}"`:""}static escape(e){return e?"string"==typeof e?e.replace(re.replaceCharRegexp,re.replaceChars):e:""}save(e=!1){document.dispatchEvent(new CustomEvent("pb-start-update"));const t=this.serializeOdd();this.shadowRoot.getElementById("dialog").show(C("odd.editor.save"),C("odd.editor.saving"));const o=this.shadowRoot.getElementById("saveOdd");o.url=`${this.getEndpoint()}/${this.lessThanApiVersion("1.0.0")?"modules/editor.xql":"api/odd/"+this.odd}`,this.lessThanApiVersion("1.0.0")?(o.contentType="application/x-www-form-urlencoded",o.method="POST",o.params=null,o.body={action:"save",root:this.rootPath,"output-prefix":this.outputPrefix,"output-root":this.outputRoot,odd:this.odd,data:t}):(o.contentType="application/xml",o.method="PUT",o.params={root:this.rootPath,"output-prefix":this.outputPrefix,"output-root":this.outputRoot},o.body=t);o.generateRequest().completes.then(t=>{this.handleSaveComplete(t,e)}).catch(this.handleSaveError.bind(this))}static _renderReport(e){return e.error?`\n <div class="list-group-item-danger">\n <h4 class="list-group-item-heading">${e.file}</h4>\n <h5 class="list-group-item-heading">Compilation error on line ${e.line}:</h5>\n <pre class="list-group-item-text">${e.error}</pre>\n <pre class="list-group-item-text">${e.message}</pre>\n </div>\n `:`\n <div class="list-group-item-success">\n <p class="list-group-item-text">Generated ${e.file}</p>\n </div>\n `}handleSaveComplete(e,t=!1){const o=e.response;if("denied"===o.status)return this.shadowRoot.getElementById("dialog").set(C("odd.editor.denied"),C("odd.editor.denied-message",{odd:this.odd})),void document.dispatchEvent(new CustomEvent("pb-end-update"));let i;if(this.lessThanApiVersion("1.0.0")){i=`<div class="list-group">${o.report.map(re._renderReport).join("")}</div>`}else{const{report:e}=o;i=`<div class="list-group">${e}</div>`}if(this.shadowRoot.getElementById("dialog").set(C("odd.editor.saved"),i),this._hasChanges=!1,document.dispatchEvent(new CustomEvent("pb-end-update")),t){P(new Blob([o.source],{type:"application/xml"}),{fileName:this.odd,extensions:[".odd"]}).then(()=>console.log(`<pb-odd-editor> ${this.odd} exported`),()=>console.log("<pb-odd-editor> export aborted"))}}handleSaveError(e){this.shadowRoot.getElementById("dialog").set("Error",e.error),document.dispatchEvent(new CustomEvent("pb-end-update"))}_reload(){this.shadowRoot.getElementById("dialog").confirm(C("odd.editor.reload"),C("odd.editor.reload-confirm")).then(()=>{this.load(),this.tabs=[],this.tabIndex=0,this.shadowRoot.getElementById("currentElement").innerHTML=""},()=>null)}_setCurrentSelection(e){null!=this.currentSelection&&this.currentSelection.removeAttribute("currentselection"),this.currentSelection=e.target,this.currentSelection.setAttribute("currentselection","true")}_changeSelection(e){if(e.preventDefault(),e.stopPropagation(),e.detail.target===this)return;let t;this.currentSelection&&void 0!==this.currentSelection.tagName&&this.currentSelection.removeAttribute("currentselection"),t=e.detail.target?e.detail.target:e.target,t.setAttribute("currentselection","true"),this.currentSelection=t}_selectElementspec(e){this.currentElementSpec&&"PB-ODD-ELEMENTSPEC-EDITOR"===this.currentElementSpec.tagName&&this.currentElementSpec.removeAttribute("currentselection");const t=e.target;t.setAttribute("currentselection","true"),this.currentElementSpec=t}nsDisabled(){return!this.useNamespace}_handleLoadError(e){console.log("loading error occurred: ",e);const t=this.shadowRoot.getElementById("errorMsg");t.style.background="red";const{url:o}=this.shadowRoot.getElementById("loadContent");console.log("url ",o),t.show("Error: ","ODD file could not be loaded from "+o)}handleElementSpecChanged(e){this._hasChanges=!0;const t=this.elementSpecs.find(t=>t.ident===e.detail.ident),o=this.elementSpecs.indexOf(t),i=Object.assign(Object.assign({},t),{},{models:e.detail.models}),s=Array.from(this.elementSpecs);s.splice(o,1,i),this.elementSpecs=s}_inputTitle(e){this.title=e.composedPath()[0].value}}customElements.define("pb-odd-editor",re);export{re as PbOddEditor};