@teipublisher/pb-components 2.26.1-next.2 → 3.0.0-next-4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/docker-cypress.yml +54 -0
- package/.github/workflows/main.yml +6 -4
- package/.github/workflows/node.js.yml +56 -21
- package/.github/workflows/release.js.yml +19 -17
- package/.releaserc.json +1 -1
- package/CHANGELOG.md +351 -9
- package/Dockerfile +78 -70
- package/README.md +112 -4
- package/css/components.css +5 -5
- package/css/gridjs/mermaid.min.css +1 -1
- package/css/leaflet/Control.Geocoder.css +1 -126
- package/css/leaflet/images/layers.png +0 -0
- package/css/tify/tify.css +6 -5
- package/css/tom-select/tom-select.bootstrap4.min.css +1 -1
- package/css/tom-select/tom-select.bootstrap5.min.css +1 -1
- package/css/tom-select/tom-select.default.min.css +1 -1
- package/css/tom-select/tom-select.default.min.css.map +1 -0
- package/css/tom-select/tom-select.min.css +1 -1
- package/cypress.config.js +84 -0
- package/dist/api.html +1 -1
- package/dist/css/design-system.css +607 -0
- package/dist/demo/bundle-test.html +4 -3
- package/dist/demo/components.css +46 -1
- package/dist/demo/design-system.html +710 -0
- package/dist/demo/dts-client.html +2 -2
- package/dist/demo/pb-autocomplete.html +23 -11
- package/dist/demo/pb-autocomplete2.html +66 -55
- package/dist/demo/pb-autocomplete3.html +17 -8
- package/dist/demo/pb-blacklab-highlight.html +28 -11
- package/dist/demo/pb-blacklab-results.html +3 -2
- package/dist/demo/pb-browse-docs.html +24 -24
- package/dist/demo/pb-browse-docs2.html +3 -3
- package/dist/demo/pb-clipboard.html +32 -28
- package/dist/demo/pb-code-editor.html +6 -6
- package/dist/demo/pb-code-highlight.html +63 -63
- package/dist/demo/pb-codepen.html +1 -1
- package/dist/demo/pb-collapse.html +1 -1
- package/dist/demo/pb-collapse2.html +2 -2
- package/dist/demo/pb-combo-box.html +135 -130
- package/dist/demo/pb-custom-form.html +64 -55
- package/dist/demo/pb-dialog.html +12 -6
- package/dist/demo/pb-document.html +1 -1
- package/dist/demo/pb-download.html +68 -59
- package/dist/demo/pb-drawer.html +67 -46
- package/dist/demo/pb-drawer2.html +65 -58
- package/dist/demo/pb-edit-app.html +2 -2
- package/dist/demo/pb-edit-xml.html +1 -1
- package/dist/demo/pb-facsimile-2.html +26 -11
- package/dist/demo/pb-facsimile-3.html +25 -10
- package/dist/demo/pb-facsimile-dedup-test-2.html +48 -0
- package/dist/demo/pb-facsimile-dedup-test.html +48 -0
- package/dist/demo/pb-facsimile.html +4 -4
- package/dist/demo/pb-formula.html +1 -1
- package/dist/demo/pb-grid.html +22 -8
- package/dist/demo/pb-highlight.html +2 -2
- package/dist/demo/pb-i18n-simple.html +1 -0
- package/dist/demo/pb-i18n.html +15 -5
- package/dist/demo/pb-image-strip-standalone.html +2 -2
- package/dist/demo/pb-image-strip-view.html +2 -2
- package/dist/demo/pb-leaflet-map.html +3 -3
- package/dist/demo/pb-leaflet-map2.html +2 -2
- package/dist/demo/pb-leaflet-map3.html +3 -3
- package/dist/demo/pb-link.html +1 -1
- package/dist/demo/pb-load.html +2 -6
- package/dist/demo/pb-login.html +1 -3
- package/dist/demo/pb-manage-odds.html +9 -4
- package/dist/demo/pb-markdown.html +1 -1
- package/dist/demo/pb-media-query.html +2 -2
- package/dist/demo/pb-mei.html +2 -2
- package/dist/demo/pb-mei2.html +2 -2
- package/dist/demo/pb-message.html +2 -3
- package/dist/demo/pb-odd-editor.html +54 -52
- package/dist/demo/pb-page-header.html +27 -0
- package/dist/demo/pb-popover.html +1 -1
- package/dist/demo/pb-print-preview.html +2 -2
- package/dist/demo/pb-progress.html +4 -4
- package/dist/demo/pb-repeat.html +32 -36
- package/dist/demo/pb-search.html +16 -5
- package/dist/demo/pb-search2.html +4 -4
- package/dist/demo/pb-search3.html +3 -3
- package/dist/demo/pb-search4.html +3 -3
- package/dist/demo/pb-select-feature.html +4 -4
- package/dist/demo/pb-select-feature2.html +4 -4
- package/dist/demo/pb-select-feature3.html +2 -2
- package/dist/demo/pb-select-i18n.html +58 -53
- package/dist/demo/pb-select-odd.html +1 -1
- package/dist/demo/pb-select.html +190 -75
- package/dist/demo/pb-select2.html +91 -37
- package/dist/demo/pb-select3.html +109 -41
- package/dist/demo/pb-svg.html +1 -1
- package/dist/demo/pb-table-grid.html +26 -15
- package/dist/demo/pb-tabs.html +15 -7
- package/dist/demo/pb-tify.html +7 -7
- package/dist/demo/pb-timeline.html +1 -1
- package/dist/demo/pb-timeline2.html +1 -1
- package/dist/demo/pb-toggle-feature.html +26 -23
- package/dist/demo/pb-toggle-feature2.html +4 -4
- package/dist/demo/pb-toggle-feature3.html +2 -2
- package/dist/demo/pb-toggle-feature4.html +56 -54
- package/dist/demo/pb-version.html +2 -2
- package/dist/demo/pb-view.html +78 -40
- package/dist/demo/pb-view2.html +69 -46
- package/dist/demo/pb-view3.html +53 -48
- package/dist/demo/pb-view4.html +70 -49
- package/dist/demo/pb-zoom.html +2 -2
- package/dist/{es-global-bridge-d8ce175d.js → es-global-bridge-D8ZcUcx_.js} +0 -4
- package/dist/focus-mixin-VCsFap6b.js +768 -0
- package/dist/images/icons.svg +217 -0
- package/dist/jinn-codemirror-DETLdm08.js +1 -0
- package/dist/lib/openseadragon.min.js +80 -0
- package/dist/lib/openseadragon.min.js.map +1 -0
- package/dist/pb-code-editor.js +25 -20
- package/dist/pb-component-docs.js +414 -3225
- package/dist/pb-components-bundle.js +3046 -4402
- package/dist/pb-dialog-tklYGWfc.js +121 -0
- package/dist/pb-edit-app.js +208 -107
- package/dist/pb-elements.json +716 -249
- package/dist/pb-facsimile.js +46 -0
- package/dist/pb-i18n-C0NDma4h.js +1 -0
- package/dist/pb-leaflet-map.js +23 -23
- package/dist/pb-mei.js +152 -134
- package/dist/pb-mixin-DHoWQheB.js +1 -0
- package/dist/pb-odd-editor.js +1671 -1231
- package/dist/pb-tify.js +1 -27
- package/dist/unsafe-html-D5VGo9Oq.js +1 -0
- package/dist/urls-BEONu_g4.js +1 -0
- package/eslint.config.mjs +92 -0
- package/gh-pages.js +5 -3
- package/i18n/common/en.json +6 -0
- package/i18n/common/pl.json +2 -2
- package/images/icons.svg +217 -0
- package/index.html +0 -5
- package/lib/leaflet-src.js.map +1 -0
- package/lib/leaflet.markercluster-src.js.map +1 -0
- package/lib/openseadragon.min.js +6 -6
- package/package.json +56 -81
- package/pb-elements.json +716 -249
- package/rollup.config.mjs +312 -0
- package/src/assets/components.css +5 -5
- package/src/assets/design-system.css +607 -0
- package/src/authority/airtable.js +20 -21
- package/src/authority/anton.js +129 -129
- package/src/authority/custom.js +70 -27
- package/src/authority/geonames.js +38 -32
- package/src/authority/gnd.js +50 -42
- package/src/authority/kbga.js +136 -134
- package/src/authority/metagrid.js +44 -46
- package/src/authority/reconciliation.js +66 -68
- package/src/authority/registry.js +4 -4
- package/src/docs/demo-utils.js +91 -0
- package/src/docs/pb-component-docs.js +287 -147
- package/src/docs/pb-component-view.js +380 -273
- package/src/docs/pb-components-list.js +115 -51
- package/src/docs/pb-demo-snippet.js +199 -174
- package/src/dts-client.js +306 -303
- package/src/dts-select-endpoint.js +125 -85
- package/src/parse-date-service.js +184 -135
- package/src/pb-ajax.js +175 -173
- package/src/pb-authority-lookup.js +198 -158
- package/src/pb-autocomplete.js +731 -313
- package/src/pb-blacklab-highlight.js +266 -260
- package/src/pb-blacklab-results.js +230 -225
- package/src/pb-browse-docs.js +601 -484
- package/src/pb-browse.js +68 -65
- package/src/pb-clipboard.js +97 -76
- package/src/pb-code-editor.js +111 -103
- package/src/pb-code-highlight.js +234 -204
- package/src/pb-codepen.js +81 -73
- package/src/pb-collapse.js +265 -152
- package/src/pb-combo-box.js +191 -191
- package/src/pb-components-bundle.js +1 -7
- package/src/pb-components.js +2 -6
- package/src/pb-custom-form.js +230 -141
- package/src/pb-dialog.js +99 -63
- package/src/pb-document.js +118 -91
- package/src/pb-download.js +214 -198
- package/src/pb-drawer.js +146 -149
- package/src/pb-edit-app.js +471 -240
- package/src/pb-edit-xml.js +101 -98
- package/src/pb-events.js +126 -107
- package/src/pb-facs-link.js +130 -101
- package/src/pb-facsimile.js +494 -410
- package/src/pb-fetch.js +389 -0
- package/src/pb-formula.js +152 -154
- package/src/pb-geolocation.js +130 -132
- package/src/pb-grid-action.js +59 -56
- package/src/pb-grid.js +388 -228
- package/src/pb-highlight.js +142 -142
- package/src/pb-hotkeys.js +40 -42
- package/src/pb-i18n.js +115 -127
- package/src/pb-icon-button.js +108 -0
- package/src/pb-icon.js +283 -0
- package/src/pb-image-strip.js +85 -79
- package/src/pb-lang.js +142 -57
- package/src/pb-leaflet-map.js +551 -483
- package/src/pb-link.js +132 -126
- package/src/pb-load.js +495 -428
- package/src/pb-login.js +303 -248
- package/src/pb-manage-odds.js +384 -338
- package/src/pb-map-icon.js +90 -90
- package/src/pb-map-layer.js +86 -86
- package/src/pb-markdown.js +107 -110
- package/src/pb-media-query.js +75 -73
- package/src/pb-mei.js +523 -303
- package/src/pb-message.js +144 -98
- package/src/pb-mixin.js +268 -265
- package/src/pb-navigation.js +83 -96
- package/src/pb-observable.js +39 -39
- package/src/pb-odd-editor.js +1209 -948
- package/src/pb-odd-elementspec-editor.js +375 -310
- package/src/pb-odd-model-editor.js +1189 -941
- package/src/pb-odd-parameter-editor.js +269 -170
- package/src/pb-odd-rendition-editor.js +184 -131
- package/src/pb-page.js +451 -422
- package/src/pb-paginate.js +260 -178
- package/src/pb-panel.js +217 -183
- package/src/pb-popover-themes.js +16 -9
- package/src/pb-popover.js +297 -288
- package/src/pb-print-preview.js +128 -128
- package/src/pb-progress.js +52 -52
- package/src/pb-repeat.js +141 -108
- package/src/pb-restricted.js +85 -78
- package/src/pb-search.js +258 -230
- package/src/pb-select-feature.js +210 -126
- package/src/pb-select-odd.js +184 -118
- package/src/pb-select-template.js +113 -78
- package/src/pb-select.js +330 -229
- package/src/pb-split-list.js +181 -176
- package/src/pb-svg.js +81 -80
- package/src/pb-table-column.js +55 -55
- package/src/pb-table-grid.js +334 -205
- package/src/pb-tabs.js +238 -61
- package/src/pb-tify.js +3331 -126
- package/src/pb-timeline.js +394 -255
- package/src/pb-toggle-feature.js +196 -188
- package/src/pb-upload.js +201 -176
- package/src/pb-version.js +22 -34
- package/src/pb-view-annotate.js +138 -102
- package/src/pb-view.js +1722 -1272
- package/src/pb-zoom.js +144 -46
- package/src/search-result-service.js +256 -223
- package/src/seed-element.js +14 -22
- package/src/settings.js +4 -4
- package/src/theming.js +98 -91
- package/src/urls.js +403 -289
- package/src/utils.js +53 -51
- package/vite.config.js +86 -0
- package/css/pb-styles.css +0 -51
- package/dist/iron-form-3b8dcaa7.js +0 -210
- package/dist/jinn-codemirror-da0e2d1f.js +0 -1
- package/dist/paper-checkbox-515a5284.js +0 -1597
- package/dist/paper-icon-button-b1d31571.js +0 -398
- package/dist/paper-listbox-a3b7175c.js +0 -1265
- package/dist/pb-i18n-0611135a.js +0 -1
- package/dist/pb-mixin-b1caa22e.js +0 -158
- package/dist/polymer-hack.js +0 -1
- package/dist/vaadin-element-mixin-6e4cee3a.js +0 -527
- package/lib/Control.Geocoder.min.js +0 -2
- package/lib/Control.Geocoder.min.js.map +0 -1
- package/src/assets/pb-styles.css +0 -51
- package/src/pb-light-dom.js +0 -40
- package/src/polymer-hack.js +0 -6
package/dist/pb-odd-editor.js
CHANGED
|
@@ -1,1418 +1,1858 @@
|
|
|
1
|
-
import{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import{Z as e,T as t,a as o,i,x as s,c as n,E as a,p as r,w as l}from"./pb-mixin-DHoWQheB.js";import{e as d,i as c,t as p}from"./unsafe-html-D5VGo9Oq.js";import{r as h,i as m,A as u,F as b,E as g,T as v,C as f,P as y,h as _,a as w,d as x,K as $,n as E,q as S,v as k,j as C,x as A,y as R,p as I}from"./focus-mixin-VCsFap6b.js";import"./jinn-codemirror-DETLdm08.js";import{t as M,g as P}from"./pb-i18n-C0NDma4h.js";import"./pb-dialog-tklYGWfc.js";const O=(()=>{if("undefined"==typeof self)return!1;if("top"in self&&self!==top)try{top.window.document._=0}catch(e){return!1}return"showOpenFilePicker"in self})();O?Promise.resolve().then(function(){return q}):Promise.resolve().then(function(){return H}),O?Promise.resolve().then(function(){return U}):Promise.resolve().then(function(){return G});const z=O?Promise.resolve().then(function(){return V}):Promise.resolve().then(function(){return J});async function T(...e){return(await z).default(...e)}const j=async e=>{const t=await e.getFile();return t.handle=e,t};var B=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(j));return e[0].multiple?i:i[0]},q={__proto__:null,default:B};function N(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 N=function(e){this.s=e,this.n=e.next},N.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 N(e)}const L=async(e,t,o=e.name,i)=>{const s=[],n=[];var a,r=!1,l=!1;try{for(var d,c=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 N(t.call(e));o="@@asyncIterator",i="@@iterator"}throw new TypeError("Object is not async iterable")}(e.values());r=!(d=await c.next()).done;r=!1){const a=d.value,r=`${o}/${a.name}`;"file"===a.kind?n.push(a.getFile().then(t=>(t.directoryHandle=e,t.handle=a,Object.defineProperty(t,"webkitRelativePath",{configurable:!0,enumerable:!0,get:()=>r})))):"directory"!==a.kind||!t||i&&i(a)||s.push(L(a,t,r,i))}}catch(e){l=!0,a=e}finally{try{r&&null!=c.return&&await c.return()}finally{if(l)throw a}}return[...(await Promise.all(s)).flat(),...await Promise.all(n)]};var D=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]:L(t,e.recursive,void 0,e.skipDirectory)},U={__proto__:null,default:D},F=async(e,t=[{}],o=null,i=!1,s=null)=>{Array.isArray(t)||(t=[t]),t[0].fileName=t[0].fileName||"Untitled";const n=[];let a=null;if(e instanceof Blob&&e.type?a=e.type:e.headers&&e.headers.get("content-type")&&(a=e.headers.get("content-type")),t.forEach((e,t)=>{n[t]={description:e.description||"Files",accept:{}},e.mimeTypes?(0===t&&a&&e.mimeTypes.push(a),e.mimeTypes.map(o=>{n[t].accept[o]=e.extensions||[]})):a?n[t].accept[a]=e.extensions||[]:n[t].accept["*/*"]=e.extensions||[]}),o)try{await o.getFile()}catch(e){if(o=null,i)throw e}const r=o||await window.showSaveFilePicker({suggestedName:t[0].fileName,id:t[0].id,startIn:t[0].startIn,types:n,excludeAcceptAllOption:t[0].excludeAcceptAllOption||!1});!o&&s&&s(r);const l=await r.createWritable();if("stream"in e){const t=e.stream();return await t.pipeTo(l),r}return"body"in e?(await e.body.pipeTo(l),r):(await l.write(await e),await l.close(),r)},V={__proto__:null,default:F},K=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),i.addEventListener("cancel",()=>{i.remove(),o(new DOMException("The user aborted a request.","AbortError"))}),i.addEventListener("change",()=>{i.remove(),t(i.multiple?Array.from(i.files):i.files[0])}),"showPicker"in HTMLInputElement.prototype?i.showPicker():i.click()})),H={__proto__:null,default:K},W=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,i.style.display="none",document.body.append(i),i.addEventListener("cancel",()=>{i.remove(),o(new DOMException("The user aborted a request.","AbortError"))}),i.addEventListener("change",()=>{i.remove();let o=Array.from(i.files);e[0].recursive?e[0].recursive&&e[0].skipDirectory&&(o=o.filter(t=>t.webkitRelativePath.split("/").every(t=>!e[0].skipDirectory({name:t,kind:"directory"})))):o=o.filter(e=>2===e.webkitRelativePath.split("/").length),t(o)}),"showPicker"in HTMLInputElement.prototype?i.showPicker():i.click()})),G={__proto__:null,default:W},X=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),n=await s.blob();return o.releaseLock(),new Blob([n],{type:t})}(e.body,e.headers.get("content-type"))),o.download=t.fileName||"Untitled",o.href=URL.createObjectURL(await i);const s=()=>{"function"==typeof n&&n()},n=t.legacySetup&&t.legacySetup(s,()=>n(),o);return o.addEventListener("click",()=>{setTimeout(()=>URL.revokeObjectURL(o.href),3e4),s()}),o.click(),null},J={__proto__:null,default:X};const{I:Y}=e,Q=()=>document.createComment(""),Z=(e,t,o)=>{const i=e._$AA.parentNode,s=void 0===t?e._$AB:t._$AA;if(void 0===o){const t=i.insertBefore(Q(),s),n=i.insertBefore(Q(),s);o=new Y(t,n,e,e.options)}else{const t=o._$AB.nextSibling,r=o._$AM,l=r!==e;if(l){var n,a;let t;null!==(n=(a=o)._$AQ)&&void 0!==n&&n.call(a,e),o._$AM=e,void 0!==o._$AP&&(t=e._$AU)!==r._$AU&&o._$AP(t)}if(t!==s||l){let e=o._$AA;for(;e!==t;){const t=e.nextSibling;i.insertBefore(e,s),e=t}}}return o},ee=(e,t,o=e)=>(e._$AI(t,o),e),te={},oe=(e,t=te)=>e._$AH=t,ie=e=>e._$AH,se=e=>{e._$AR(),e._$AA.remove()},ne=(e,t,o)=>{const i=new Map;for(let s=t;s<=o;s++)i.set(e[s],s);return i},ae=d(class extends c{constructor(e){if(super(e),e.type!==p.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,o){let i;void 0===o?o=t:void 0!==t&&(i=t);const s=[],n=[];let a=0;for(const t of e)s[a]=i?i(t,a):a,n[a]=o(t,a),a++;return{values:n,keys:s}}render(e,t,o){return this.dt(e,t,o).values}update(e,[o,i,s]){const n=ie(e),{values:a,keys:r}=this.dt(o,i,s);if(!Array.isArray(n))return this.ut=r,a;const l=this.ut??=[],d=[];let c,p,h=0,m=n.length-1,u=0,b=a.length-1;for(;h<=m&&u<=b;)if(null===n[h])h++;else if(null===n[m])m--;else if(l[h]===r[u])d[u]=ee(n[h],a[u]),h++,u++;else if(l[m]===r[b])d[b]=ee(n[m],a[b]),m--,b--;else if(l[h]===r[b])d[b]=ee(n[h],a[b]),Z(e,d[b+1],n[h]),h++,b--;else if(l[m]===r[u])d[u]=ee(n[m],a[u]),Z(e,n[h],n[m]),m--,u++;else if(void 0===c&&(c=ne(r,u,b),p=ne(l,h,m)),c.has(l[h]))if(c.has(l[m])){const t=p.get(r[u]),o=void 0!==t?n[t]:null;if(null===o){const t=Z(e,n[h]);ee(t,a[u]),d[u]=t}else d[u]=ee(o,a[u]),Z(e,n[h],o),n[t]=null;u++}else se(n[m]),m--;else se(n[h]),h++;for(;u<=b;){const t=Z(e,d[b+1]);ee(t,a[u]),d[u++]=t}for(;h<=m;){const e=n[h++];null!==e&&se(e)}return this.ut=r,oe(e,d),t}});h("vaadin-tab",m`
|
|
2
|
+
:host {
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
padding: 0.5rem 0.75rem;
|
|
5
|
+
font-family: var(--lumo-font-family);
|
|
6
|
+
font-size: var(--lumo-font-size-m);
|
|
7
|
+
line-height: var(--lumo-line-height-xs);
|
|
8
|
+
font-weight: 500;
|
|
9
|
+
opacity: 1;
|
|
10
|
+
color: var(--lumo-secondary-text-color);
|
|
11
|
+
transition: 0.15s color, 0.2s transform;
|
|
12
|
+
flex-shrink: 0;
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
position: relative;
|
|
16
|
+
cursor: var(--lumo-clickable-cursor);
|
|
17
|
+
transform-origin: 50% 100%;
|
|
18
|
+
outline: none;
|
|
19
|
+
-webkit-font-smoothing: antialiased;
|
|
20
|
+
-moz-osx-font-smoothing: grayscale;
|
|
21
|
+
overflow: hidden;
|
|
22
|
+
min-width: var(--lumo-size-m);
|
|
23
|
+
-webkit-user-select: none;
|
|
24
|
+
-moz-user-select: none;
|
|
25
|
+
user-select: none;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
:host(:not([orientation='vertical'])) {
|
|
29
|
+
text-align: center;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
:host([orientation='vertical']) {
|
|
33
|
+
transform-origin: 0% 50%;
|
|
34
|
+
padding: 0.25rem 1rem;
|
|
35
|
+
min-height: var(--lumo-size-m);
|
|
36
|
+
min-width: 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
:host(:hover),
|
|
40
|
+
:host([focus-ring]) {
|
|
41
|
+
color: var(--lumo-body-text-color);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
:host([selected]) {
|
|
45
|
+
color: var(--lumo-primary-text-color);
|
|
46
|
+
transition: 0.6s color;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
:host([active]:not([selected])) {
|
|
50
|
+
color: var(--lumo-primary-text-color);
|
|
51
|
+
transition-duration: 0.1s;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
:host::before,
|
|
55
|
+
:host::after {
|
|
56
|
+
content: '';
|
|
57
|
+
position: absolute;
|
|
58
|
+
display: var(--_lumo-tab-marker-display, block);
|
|
59
|
+
bottom: 0;
|
|
60
|
+
left: 50%;
|
|
61
|
+
width: var(--lumo-size-s);
|
|
62
|
+
height: 2px;
|
|
63
|
+
background-color: var(--lumo-contrast-60pct);
|
|
64
|
+
border-radius: var(--lumo-border-radius-s) var(--lumo-border-radius-s) 0 0;
|
|
65
|
+
transform: translateX(-50%) scale(0);
|
|
66
|
+
transform-origin: 50% 100%;
|
|
67
|
+
transition: 0.14s transform cubic-bezier(0.12, 0.32, 0.54, 1);
|
|
68
|
+
will-change: transform;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:host([selected])::before,
|
|
72
|
+
:host([selected])::after {
|
|
73
|
+
background-color: var(--lumo-primary-color);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
:host([orientation='vertical'])::before,
|
|
77
|
+
:host([orientation='vertical'])::after {
|
|
78
|
+
left: 0;
|
|
79
|
+
bottom: 50%;
|
|
80
|
+
transform: translateY(50%) scale(0);
|
|
81
|
+
width: 2px;
|
|
82
|
+
height: var(--lumo-size-xs);
|
|
83
|
+
border-radius: 0 var(--lumo-border-radius-s) var(--lumo-border-radius-s) 0;
|
|
84
|
+
transform-origin: 100% 50%;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
:host::after {
|
|
88
|
+
box-shadow: 0 0 0 4px var(--lumo-primary-color);
|
|
89
|
+
opacity: 0.15;
|
|
90
|
+
transition: 0.15s 0.02s transform, 0.8s 0.17s opacity;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
:host([selected])::before,
|
|
94
|
+
:host([selected])::after {
|
|
95
|
+
transform: translateX(-50%) scale(1);
|
|
96
|
+
transition-timing-function: cubic-bezier(0.12, 0.32, 0.54, 1.5);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
:host([orientation='vertical'][selected])::before,
|
|
100
|
+
:host([orientation='vertical'][selected])::after {
|
|
101
|
+
transform: translateY(50%) scale(1);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
:host([selected]:not([active]))::after {
|
|
105
|
+
opacity: 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
:host(:not([orientation='vertical'])) ::slotted(a[href]) {
|
|
109
|
+
justify-content: center;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
:host ::slotted(a) {
|
|
113
|
+
display: flex;
|
|
114
|
+
width: 100%;
|
|
115
|
+
align-items: center;
|
|
116
|
+
height: 100%;
|
|
117
|
+
margin: -0.5rem -0.75rem;
|
|
118
|
+
padding: 0.5rem 0.75rem;
|
|
119
|
+
outline: none;
|
|
120
|
+
|
|
121
|
+
/*
|
|
122
|
+
Override the CSS inherited from \`lumo-color\` and \`lumo-typography\`.
|
|
123
|
+
Note: \`!important\` is needed because of the \`:slotted\` specificity.
|
|
124
|
+
*/
|
|
125
|
+
text-decoration: none !important;
|
|
126
|
+
color: inherit !important;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
:host ::slotted(vaadin-icon),
|
|
130
|
+
:host ::slotted(iron-icon) {
|
|
131
|
+
margin: 0 4px;
|
|
132
|
+
width: var(--lumo-icon-size-m);
|
|
133
|
+
height: var(--lumo-icon-size-m);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* Vaadin icons are based on a 16x16 grid (unlike Lumo and Material icons with 24x24), so they look too big by default */
|
|
137
|
+
:host ::slotted(vaadin-icon[icon^='vaadin:']),
|
|
138
|
+
:host ::slotted(iron-icon[icon^='vaadin:']) {
|
|
139
|
+
padding: 0.25rem;
|
|
140
|
+
box-sizing: border-box !important;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
:host(:not([dir='rtl'])) ::slotted(vaadin-icon:first-child),
|
|
144
|
+
:host(:not([dir='rtl'])) ::slotted(iron-icon:first-child) {
|
|
145
|
+
margin-left: 0;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
:host(:not([dir='rtl'])) ::slotted(vaadin-icon:last-child),
|
|
149
|
+
:host(:not([dir='rtl'])) ::slotted(iron-icon:last-child) {
|
|
150
|
+
margin-right: 0;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
:host([theme~='icon-on-top']) {
|
|
154
|
+
display: flex;
|
|
155
|
+
flex-direction: column;
|
|
156
|
+
align-items: center;
|
|
157
|
+
justify-content: space-around;
|
|
158
|
+
text-align: center;
|
|
159
|
+
padding-bottom: 0.5rem;
|
|
160
|
+
padding-top: 0.25rem;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
:host([theme~='icon-on-top']) ::slotted(a) {
|
|
164
|
+
flex-direction: column;
|
|
165
|
+
align-items: center;
|
|
166
|
+
margin-top: -0.25rem;
|
|
167
|
+
padding-top: 0.25rem;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
:host([theme~='icon-on-top']) ::slotted(vaadin-icon),
|
|
171
|
+
:host([theme~='icon-on-top']) ::slotted(iron-icon) {
|
|
172
|
+
margin: 0;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/* Disabled */
|
|
176
|
+
|
|
177
|
+
:host([disabled]) {
|
|
178
|
+
pointer-events: none;
|
|
179
|
+
opacity: 1;
|
|
180
|
+
color: var(--lumo-disabled-text-color);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/* Focus-ring */
|
|
184
|
+
|
|
185
|
+
:host([focus-ring]) {
|
|
186
|
+
box-shadow: inset 0 0 0 2px var(--lumo-primary-color-50pct);
|
|
187
|
+
border-radius: var(--lumo-border-radius-m);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/* RTL specific styles */
|
|
191
|
+
|
|
192
|
+
:host([dir='rtl'])::before,
|
|
193
|
+
:host([dir='rtl'])::after {
|
|
194
|
+
left: auto;
|
|
195
|
+
right: 50%;
|
|
196
|
+
transform: translateX(50%) scale(0);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
:host([dir='rtl'][selected]:not([orientation='vertical']))::before,
|
|
200
|
+
:host([dir='rtl'][selected]:not([orientation='vertical']))::after {
|
|
201
|
+
transform: translateX(50%) scale(1);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
:host([dir='rtl']) ::slotted(vaadin-icon:first-child),
|
|
205
|
+
:host([dir='rtl']) ::slotted(iron-icon:first-child) {
|
|
206
|
+
margin-right: 0;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
:host([dir='rtl']) ::slotted(vaadin-icon:last-child),
|
|
210
|
+
:host([dir='rtl']) ::slotted(iron-icon:last-child) {
|
|
211
|
+
margin-left: 0;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
:host([orientation='vertical'][dir='rtl']) {
|
|
215
|
+
transform-origin: 100% 50%;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
:host([dir='rtl'][orientation='vertical'])::before,
|
|
219
|
+
:host([dir='rtl'][orientation='vertical'])::after {
|
|
220
|
+
left: auto;
|
|
221
|
+
right: 0;
|
|
222
|
+
border-radius: var(--lumo-border-radius-s) 0 0 var(--lumo-border-radius-s);
|
|
223
|
+
transform-origin: 0% 50%;
|
|
224
|
+
}
|
|
225
|
+
`,{moduleId:"lumo-tab"});const re=e=>class extends(u(b(e))){static get properties(){return{_hasVaadinItemMixin:{value:!0},selected:{type:Boolean,value:!1,reflectToAttribute:!0,observer:"_selectedChanged"},_value:String}}get _activeKeys(){return["Enter"," "]}get value(){return void 0!==this._value?this._value:this.textContent.trim()}set value(e){this._value=e}ready(){super.ready();const e=this.getAttribute("value");null!==e&&(this.value=e)}focus(){this.disabled||(super.focus(),this._setFocused(!0))}_shouldSetActive(e){return!(this.disabled||"keydown"===e.type&&e.defaultPrevented)}_selectedChanged(e){this.setAttribute("aria-selected",e)}_disabledChanged(e){super._disabledChanged(e),e&&(this.selected=!1,this.blur())}_onKeyDown(e){super._onKeyDown(e),this._activeKeys.includes(e.key)&&!e.defaultPrevented&&(e.preventDefault(),this.click())}};class le extends(g(v(re(f(y))))){static get template(){return _`
|
|
226
|
+
<style>
|
|
227
|
+
:host {
|
|
228
|
+
display: block;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
:host([hidden]) {
|
|
232
|
+
display: none !important;
|
|
233
|
+
}
|
|
234
|
+
</style>
|
|
235
|
+
<slot></slot>
|
|
236
|
+
<slot name="tooltip"></slot>
|
|
237
|
+
`}static get is(){return"vaadin-tab"}ready(){super.ready(),this.setAttribute("role","tab"),this._tooltipController=new w(this),this.addController(this._tooltipController)}_onKeyUp(e){const t=this.hasAttribute("active");if(super._onKeyUp(e),t){const e=this.querySelector("a");e&&e.click()}}}customElements.define(le.is,le),h("vaadin-tabs",m`
|
|
238
|
+
:host {
|
|
239
|
+
-webkit-tap-highlight-color: transparent;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
:host(:not([orientation='vertical'])) {
|
|
243
|
+
box-shadow: inset 0 -1px 0 0 var(--lumo-contrast-10pct);
|
|
244
|
+
position: relative;
|
|
245
|
+
min-height: var(--lumo-size-l);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
:host([orientation='horizontal']) [part='tabs'] ::slotted(vaadin-tab:not([theme~='icon-on-top'])) {
|
|
249
|
+
justify-content: center;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
:host([orientation='vertical']) {
|
|
253
|
+
box-shadow: -1px 0 0 0 var(--lumo-contrast-10pct);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
:host([orientation='horizontal']) [part='tabs'] {
|
|
257
|
+
margin: 0 0.75rem;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
:host([orientation='vertical']) [part='tabs'] {
|
|
261
|
+
width: 100%;
|
|
262
|
+
margin: 0.5rem 0;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
[part='forward-button'],
|
|
266
|
+
[part='back-button'] {
|
|
267
|
+
position: absolute;
|
|
268
|
+
z-index: 1;
|
|
269
|
+
font-family: lumo-icons;
|
|
270
|
+
color: var(--lumo-tertiary-text-color);
|
|
271
|
+
font-size: var(--lumo-icon-size-m);
|
|
272
|
+
display: flex;
|
|
273
|
+
align-items: center;
|
|
274
|
+
justify-content: center;
|
|
275
|
+
width: 1.5em;
|
|
276
|
+
height: 100%;
|
|
277
|
+
transition: 0.2s opacity;
|
|
278
|
+
top: 0;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
[part='forward-button']:hover,
|
|
282
|
+
[part='back-button']:hover {
|
|
283
|
+
color: inherit;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
:host(:not([dir='rtl'])) [part='forward-button'] {
|
|
287
|
+
right: 0;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
[part='forward-button']::after {
|
|
291
|
+
content: var(--lumo-icons-angle-right);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
[part='back-button']::after {
|
|
295
|
+
content: var(--lumo-icons-angle-left);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/* Tabs overflow */
|
|
299
|
+
|
|
300
|
+
[part='tabs'] {
|
|
301
|
+
--_lumo-tabs-overflow-mask-image: none;
|
|
302
|
+
-webkit-mask-image: var(--_lumo-tabs-overflow-mask-image);
|
|
303
|
+
mask-image: var(--_lumo-tabs-overflow-mask-image);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/* Horizontal tabs overflow */
|
|
307
|
+
|
|
308
|
+
/* Both ends overflowing */
|
|
309
|
+
:host([overflow~='start'][overflow~='end']:not([orientation='vertical'])) [part='tabs'] {
|
|
310
|
+
--_lumo-tabs-overflow-mask-image: linear-gradient(
|
|
311
|
+
90deg,
|
|
312
|
+
transparent 2em,
|
|
313
|
+
#000 4em,
|
|
314
|
+
#000 calc(100% - 4em),
|
|
315
|
+
transparent calc(100% - 2em)
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/* End overflowing */
|
|
320
|
+
:host([overflow~='end']:not([orientation='vertical'])) [part='tabs'] {
|
|
321
|
+
--_lumo-tabs-overflow-mask-image: linear-gradient(90deg, #000 calc(100% - 4em), transparent calc(100% - 2em));
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/* Start overflowing */
|
|
325
|
+
:host([overflow~='start']:not([orientation='vertical'])) [part='tabs'] {
|
|
326
|
+
--_lumo-tabs-overflow-mask-image: linear-gradient(90deg, transparent 2em, #000 4em);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/* Vertical tabs overflow */
|
|
330
|
+
|
|
331
|
+
/* Both ends overflowing */
|
|
332
|
+
:host([overflow~='start'][overflow~='end'][orientation='vertical']) [part='tabs'] {
|
|
333
|
+
--_lumo-tabs-overflow-mask-image: linear-gradient(transparent, #000 2em, #000 calc(100% - 2em), transparent);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/* End overflowing */
|
|
337
|
+
:host([overflow~='end'][orientation='vertical']) [part='tabs'] {
|
|
338
|
+
--_lumo-tabs-overflow-mask-image: linear-gradient(#000 calc(100% - 2em), transparent);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/* Start overflowing */
|
|
342
|
+
:host([overflow~='start'][orientation='vertical']) [part='tabs'] {
|
|
343
|
+
--_lumo-tabs-overflow-mask-image: linear-gradient(transparent, #000 2em);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
:host [part='tabs'] ::slotted(:not(vaadin-tab)) {
|
|
347
|
+
margin-left: var(--lumo-space-m);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/* Centered */
|
|
351
|
+
|
|
352
|
+
:host([theme~='centered'][orientation='horizontal']) ::slotted(vaadin-tab:first-of-type) {
|
|
353
|
+
margin-inline-start: auto;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
:host([theme~='centered'][orientation='horizontal']) ::slotted(vaadin-tab:last-of-type) {
|
|
357
|
+
margin-inline-end: auto;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/* Small */
|
|
361
|
+
|
|
362
|
+
:host([theme~='small']),
|
|
363
|
+
:host([theme~='small']) [part='tabs'] {
|
|
364
|
+
min-height: var(--lumo-size-m);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
:host([theme~='small']) [part='tabs'] ::slotted(vaadin-tab) {
|
|
368
|
+
font-size: var(--lumo-font-size-s);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/* Minimal */
|
|
372
|
+
|
|
373
|
+
:host([theme~='minimal']) {
|
|
374
|
+
box-shadow: none;
|
|
375
|
+
--_lumo-tab-marker-display: none;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/* Hide-scroll-buttons */
|
|
379
|
+
|
|
380
|
+
:host([theme~='hide-scroll-buttons']) [part='back-button'],
|
|
381
|
+
:host([theme~='hide-scroll-buttons']) [part='forward-button'] {
|
|
382
|
+
display: none;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/* prettier-ignore */
|
|
386
|
+
:host([theme~='hide-scroll-buttons'][overflow~='start'][overflow~='end']:not([orientation='vertical'])) [part='tabs'] {
|
|
387
|
+
--_lumo-tabs-overflow-mask-image: linear-gradient(
|
|
388
|
+
90deg,
|
|
389
|
+
transparent,
|
|
390
|
+
#000 2em,
|
|
391
|
+
#000 calc(100% - 2em),
|
|
392
|
+
transparent 100%
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
:host([theme~='hide-scroll-buttons'][overflow~='end']:not([orientation='vertical'])) [part='tabs'] {
|
|
397
|
+
--_lumo-tabs-overflow-mask-image: linear-gradient(90deg, #000 calc(100% - 2em), transparent 100%);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
:host([theme~='hide-scroll-buttons'][overflow~='start']:not([orientation='vertical'])) [part='tabs'] {
|
|
401
|
+
--_lumo-tabs-overflow-mask-image: linear-gradient(90deg, transparent, #000 2em);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/* Equal-width tabs */
|
|
405
|
+
:host([theme~='equal-width-tabs']) {
|
|
406
|
+
flex: auto;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
:host([theme~='equal-width-tabs']) [part='tabs'] ::slotted(vaadin-tab) {
|
|
410
|
+
flex: 1 0 0%;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/* RTL specific styles */
|
|
414
|
+
|
|
415
|
+
:host([dir='rtl']) [part='forward-button']::after {
|
|
416
|
+
content: var(--lumo-icons-angle-left);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
:host([dir='rtl']) [part='back-button']::after {
|
|
420
|
+
content: var(--lumo-icons-angle-right);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
:host([orientation='vertical'][dir='rtl']) {
|
|
424
|
+
box-shadow: 1px 0 0 0 var(--lumo-contrast-10pct);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
:host([dir='rtl']) [part='forward-button'] {
|
|
428
|
+
left: 0;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
:host([dir='rtl']) [part='tabs'] ::slotted(:not(vaadin-tab)) {
|
|
432
|
+
margin-left: 0;
|
|
433
|
+
margin-right: var(--lumo-space-m);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/* Both ends overflowing */
|
|
437
|
+
:host([dir='rtl'][overflow~='start'][overflow~='end']:not([orientation='vertical'])) [part='tabs'] {
|
|
438
|
+
--_lumo-tabs-overflow-mask-image: linear-gradient(
|
|
439
|
+
-90deg,
|
|
440
|
+
transparent 2em,
|
|
441
|
+
#000 4em,
|
|
442
|
+
#000 calc(100% - 4em),
|
|
443
|
+
transparent calc(100% - 2em)
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/* End overflowing */
|
|
448
|
+
:host([dir='rtl'][overflow~='end']:not([orientation='vertical'])) [part='tabs'] {
|
|
449
|
+
--_lumo-tabs-overflow-mask-image: linear-gradient(-90deg, #000 calc(100% - 4em), transparent calc(100% - 2em));
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/* Start overflowing */
|
|
453
|
+
:host([dir='rtl'][overflow~='start']:not([orientation='vertical'])) [part='tabs'] {
|
|
454
|
+
--_lumo-tabs-overflow-mask-image: linear-gradient(-90deg, transparent 2em, #000 4em);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
:host([dir='rtl'][theme~='hide-scroll-buttons'][overflow~='start'][overflow~='end']:not([orientation='vertical']))
|
|
458
|
+
[part='tabs'] {
|
|
459
|
+
--_lumo-tabs-overflow-mask-image: linear-gradient(
|
|
460
|
+
-90deg,
|
|
461
|
+
transparent,
|
|
462
|
+
#000 2em,
|
|
463
|
+
#000 calc(100% - 2em),
|
|
464
|
+
transparent 100%
|
|
465
|
+
);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
:host([dir='rtl'][theme~='hide-scroll-buttons'][overflow~='end']:not([orientation='vertical'])) [part='tabs'] {
|
|
469
|
+
--_lumo-tabs-overflow-mask-image: linear-gradient(-90deg, #000 calc(100% - 2em), transparent 100%);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
:host([dir='rtl'][theme~='hide-scroll-buttons'][overflow~='start']:not([orientation='vertical'])) [part='tabs'] {
|
|
473
|
+
--_lumo-tabs-overflow-mask-image: linear-gradient(-90deg, transparent, #000 2em);
|
|
474
|
+
}
|
|
475
|
+
`,{moduleId:"lumo-tabs"});let de=!1,ce=[],pe=[];function he(){de=!0,requestAnimationFrame(function(){de=!1,me(ce),setTimeout(function(){ue(pe)})})}function me(e){for(;e.length;)be(e.shift())}function ue(e){for(let t=0,o=e.length;t<o;t++)be(e.shift())}function be(e){const t=e[0],o=e[1],i=e[2];try{o.apply(t,i)}catch(e){setTimeout(()=>{throw e})}}function ge(e,t,o){de||he(),pe.push([e,t,o])}const ve=new ResizeObserver(e=>{setTimeout(()=>{e.forEach(e=>{e.target.resizables?e.target.resizables.forEach(t=>{t._onResize(e.contentRect)}):e.target._onResize(e.contentRect)})})}),fe=x(e=>class extends e{connectedCallback(){if(super.connectedCallback(),ve.observe(this),this._observeParent){const e=this.parentNode instanceof ShadowRoot?this.parentNode.host:this.parentNode;e.resizables||(e.resizables=new Set,ve.observe(e)),e.resizables.add(this),this.__parent=e}}disconnectedCallback(){super.disconnectedCallback(),ve.unobserve(this);const e=this.__parent;if(this._observeParent&&e){const t=e.resizables;t&&(t.delete(this),0===t.size&&ve.unobserve(e)),this.__parent=null}}get _observeParent(){return!1}_onResize(e){}notifyResize(){console.warn("WARNING: Since Vaadin 23, notifyResize() is deprecated. The component uses a ResizeObserver internally and doesn't need to be explicitly notified of resizes.")}}),ye=e=>class extends($(e)){focus(){const e=this._getItems();if(Array.isArray(e)){const t=this._getAvailableIndex(e,0,null,e=>!E(e));t>=0&&e[t].focus()}}get focused(){return(this._getItems()||[]).find(S)}get _vertical(){return!0}_getItems(){return Array.from(this.children)}_onKeyDown(e){if(super._onKeyDown(e),e.metaKey||e.ctrlKey)return;const{key:t}=e,o=this._getItems()||[],i=o.indexOf(this.focused);let s,n;const a=!this._vertical&&"rtl"===this.getAttribute("dir")?-1:1;this.__isPrevKey(t)?(n=-a,s=i-a):this.__isNextKey(t)?(n=a,s=i+a):"Home"===t?(n=1,s=0):"End"===t&&(n=-1,s=o.length-1),s=this._getAvailableIndex(o,s,n,e=>!E(e)),s>=0&&(e.preventDefault(),this._focus(s,!0))}__isPrevKey(e){return this._vertical?"ArrowUp"===e:"ArrowLeft"===e}__isNextKey(e){return this._vertical?"ArrowDown"===e:"ArrowRight"===e}_focus(e,t=!1){const o=this._getItems();this._focusItem(o[e],t)}_focusItem(e){e&&(e.focus(),e.setAttribute("focus-ring",""))}_getAvailableIndex(e,t,o,i){const s=e.length;let n=t;for(let t=0;"number"==typeof n&&t<s;t+=1,n+=o||1){n<0?n=s-1:n>=s&&(n=0);const t=e[n];if(!t.hasAttribute("disabled")&&this.__isMatchingItem(t,i))return n}return-1}__isMatchingItem(e,t){return"function"!=typeof t||t(e)}},_e=e=>class extends(ye(e)){static get properties(){return{_hasVaadinListMixin:{value:!0},selected:{type:Number,reflectToAttribute:!0,notify:!0},orientation:{type:String,reflectToAttribute:!0,value:""},items:{type:Array,readOnly:!0,notify:!0},_searchBuf:{type:String,value:""}}}static get observers(){return["_enhanceItems(items, orientation, selected, disabled)"]}ready(){super.ready(),this.addEventListener("click",e=>this._onClick(e)),this._observer=new k(this,()=>{this._setItems(this._filterItems(k.getFlattenedNodes(this)))})}_getItems(){return this.items}_enhanceItems(e,t,o,i){if(!i&&e){this.setAttribute("aria-orientation",t||"vertical"),this.items.forEach(e=>{t?e.setAttribute("orientation",t):e.removeAttribute("orientation")}),this._setFocusable(o||0);const i=e[o];e.forEach(e=>{e.selected=e===i}),i&&!i.disabled&&this._scrollToItem(o)}}_filterItems(e){return e.filter(e=>e._hasVaadinItemMixin)}_onClick(e){if(e.metaKey||e.shiftKey||e.ctrlKey||e.defaultPrevented)return;const t=this._filterItems(e.composedPath())[0];let o;t&&!t.disabled&&(o=this.items.indexOf(t))>=0&&(this.selected=o)}_searchKey(e,t){this._searchReset=C.debounce(this._searchReset,A.after(500),()=>{this._searchBuf=""}),this._searchBuf+=t.toLowerCase(),this.items.some(e=>this.__isMatchingKey(e))||(this._searchBuf=t.toLowerCase());const o=1===this._searchBuf.length?e+1:e;return this._getAvailableIndex(this.items,o,1,e=>this.__isMatchingKey(e)&&"none"!==getComputedStyle(e).display)}__isMatchingKey(e){return e.textContent.replace(/[^\p{L}\p{Nd}]/gu,"").toLowerCase().startsWith(this._searchBuf)}get _isRTL(){return!this._vertical&&"rtl"===this.getAttribute("dir")}_onKeyDown(e){if(e.metaKey||e.ctrlKey)return;const t=e.key,o=this.items.indexOf(this.focused);if(/[\p{L}\p{Nd}]/u.test(t)&&1===t.length){const e=this._searchKey(o,t);return void(e>=0&&this._focus(e))}super._onKeyDown(e)}_isItemHidden(e){return"none"===getComputedStyle(e).display}_setFocusable(e){e=this._getAvailableIndex(this.items,e,1);const t=this.items[e];this.items.forEach(e=>{e.tabIndex=e===t?0:-1})}_focus(e){this.items.forEach((t,o)=>{t.focused=o===e}),this._setFocusable(e),this._scrollToItem(e),super._focus(e)}focus(){this._observer&&this._observer.flush();const e=this.querySelector('[tabindex="0"]')||(this.items?this.items[0]:null);this._focusItem(e)}get _scrollerElement(){return console.warn(`Please implement the '_scrollerElement' property in <${this.localName}>`),this}_scrollToItem(e){const t=this.items[e];if(!t)return;const o=this._vertical?["top","bottom"]:this._isRTL?["right","left"]:["left","right"],i=this._scrollerElement.getBoundingClientRect(),s=(this.items[e+1]||t).getBoundingClientRect(),n=(this.items[e-1]||t).getBoundingClientRect();let a=0;!this._isRTL&&s[o[1]]>=i[o[1]]||this._isRTL&&s[o[1]]<=i[o[1]]?a=s[o[1]]-i[o[1]]:(!this._isRTL&&n[o[0]]<=i[o[0]]||this._isRTL&&n[o[0]]>=i[o[0]])&&(a=n[o[0]]-i[o[0]]),this._scroll(a)}get _vertical(){return"horizontal"!==this.orientation}_scroll(e){if(this._vertical)this._scrollerElement.scrollTop+=e;else{const t=this.getAttribute("dir")||"ltr",o=R.detectScrollType(),i=R.getNormalizedScrollLeft(o,t,this._scrollerElement)+e;R.setNormalizedScrollLeft(o,t,this._scrollerElement,i)}}};class we extends(fe(g(_e(v(y))))){static get template(){return _`
|
|
476
|
+
<style>
|
|
477
|
+
:host {
|
|
478
|
+
display: flex;
|
|
479
|
+
align-items: center;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
:host([hidden]) {
|
|
483
|
+
display: none !important;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
:host([orientation='vertical']) {
|
|
487
|
+
display: block;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
:host([orientation='horizontal']) [part='tabs'] {
|
|
491
|
+
flex-grow: 1;
|
|
492
|
+
display: flex;
|
|
493
|
+
align-self: stretch;
|
|
494
|
+
overflow-x: auto;
|
|
495
|
+
-webkit-overflow-scrolling: touch;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/* This seems more future-proof than \`overflow: -moz-scrollbars-none\` which is marked obsolete
|
|
499
|
+
and is no longer guaranteed to work:
|
|
500
|
+
https://developer.mozilla.org/en-US/docs/Web/CSS/overflow#Mozilla_Extensions */
|
|
501
|
+
@-moz-document url-prefix() {
|
|
502
|
+
:host([orientation='horizontal']) [part='tabs'] {
|
|
503
|
+
overflow: hidden;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
:host([orientation='horizontal']) [part='tabs']::-webkit-scrollbar {
|
|
508
|
+
display: none;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
:host([orientation='vertical']) [part='tabs'] {
|
|
512
|
+
height: 100%;
|
|
513
|
+
overflow-y: auto;
|
|
514
|
+
-webkit-overflow-scrolling: touch;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
[part='back-button'],
|
|
518
|
+
[part='forward-button'] {
|
|
519
|
+
pointer-events: none;
|
|
520
|
+
opacity: 0;
|
|
521
|
+
cursor: default;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
:host([overflow~='start']) [part='back-button'],
|
|
525
|
+
:host([overflow~='end']) [part='forward-button'] {
|
|
526
|
+
pointer-events: auto;
|
|
527
|
+
opacity: 1;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
[part='back-button']::after {
|
|
531
|
+
content: '\\25C0';
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
[part='forward-button']::after {
|
|
535
|
+
content: '\\25B6';
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
:host([orientation='vertical']) [part='back-button'],
|
|
539
|
+
:host([orientation='vertical']) [part='forward-button'] {
|
|
540
|
+
display: none;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/* RTL specific styles */
|
|
544
|
+
|
|
545
|
+
:host([dir='rtl']) [part='back-button']::after {
|
|
546
|
+
content: '\\25B6';
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
:host([dir='rtl']) [part='forward-button']::after {
|
|
550
|
+
content: '\\25C0';
|
|
551
|
+
}
|
|
552
|
+
</style>
|
|
553
|
+
<div on-click="_scrollBack" part="back-button" aria-hidden="true"></div>
|
|
554
|
+
|
|
555
|
+
<div id="scroll" part="tabs">
|
|
556
|
+
<slot></slot>
|
|
557
|
+
</div>
|
|
558
|
+
|
|
559
|
+
<div on-click="_scrollForward" part="forward-button" aria-hidden="true"></div>
|
|
560
|
+
`}static get is(){return"vaadin-tabs"}static get properties(){return{orientation:{value:"horizontal",type:String},selected:{value:0,type:Number}}}static get observers(){return["__tabsItemsChanged(items, items.*)"]}constructor(){super(),this.__itemsResizeObserver=new ResizeObserver(()=>{setTimeout(()=>this._updateOverflow())})}ready(){super.ready(),this._scrollerElement.addEventListener("scroll",()=>this._updateOverflow()),this.setAttribute("role","tablist"),ge(this,()=>{this._updateOverflow()})}_onResize(){this._updateOverflow()}__tabsItemsChanged(e){this.__itemsResizeObserver.disconnect(),(e||[]).forEach(e=>{this.__itemsResizeObserver.observe(e)}),this._updateOverflow()}_scrollForward(){this._scroll(-this.__direction*this._scrollOffset)}_scrollBack(){this._scroll(this.__direction*this._scrollOffset)}get _scrollOffset(){return this._vertical?this._scrollerElement.offsetHeight:this._scrollerElement.offsetWidth}get _scrollerElement(){return this.$.scroll}get __direction(){return this._vertical||"rtl"!==this.getAttribute("dir")?-1:1}_updateOverflow(){const e=this._vertical?this._scrollerElement.scrollTop:this.__getNormalizedScrollLeft(this._scrollerElement),t=this._vertical?this._scrollerElement.scrollHeight:this._scrollerElement.scrollWidth;let o=Math.floor(e)>1?"start":"";Math.ceil(e)<Math.ceil(t-this._scrollOffset)&&(o+=" end"),1===this.__direction&&(o=o.replace(/start|end/gi,e=>"start"===e?"end":"start")),o?this.setAttribute("overflow",o.trim()):this.removeAttribute("overflow")}}customElements.define(we.is,we),console.warn('WARNING: Since Vaadin 23.2, "@vaadin/vaadin-tabs" is deprecated. Use "@vaadin/tabs" instead.');class xe extends o{static get styles(){return i`
|
|
17
561
|
:host {
|
|
18
|
-
|
|
19
|
-
padding: 0.5rem 0.75rem;
|
|
20
|
-
font-family: var(--lumo-font-family);
|
|
21
|
-
font-size: var(--lumo-font-size-m);
|
|
22
|
-
line-height: var(--lumo-line-height-xs);
|
|
23
|
-
font-weight: 500;
|
|
24
|
-
opacity: 1;
|
|
25
|
-
color: var(--lumo-contrast-60pct);
|
|
26
|
-
transition: 0.15s color, 0.2s transform;
|
|
27
|
-
flex-shrink: 0;
|
|
28
|
-
display: flex;
|
|
29
|
-
align-items: center;
|
|
30
|
-
position: relative;
|
|
31
|
-
cursor: pointer;
|
|
32
|
-
transform-origin: 50% 100%;
|
|
33
|
-
outline: none;
|
|
34
|
-
-webkit-font-smoothing: antialiased;
|
|
35
|
-
-moz-osx-font-smoothing: grayscale;
|
|
36
|
-
overflow: hidden;
|
|
37
|
-
min-width: var(--lumo-size-m);
|
|
38
|
-
-webkit-user-select: none;
|
|
39
|
-
-moz-user-select: none;
|
|
40
|
-
-ms-user-select: none;
|
|
41
|
-
user-select: none;
|
|
562
|
+
display: block;
|
|
42
563
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
564
|
+
.wrapper {
|
|
565
|
+
display: grid;
|
|
566
|
+
grid-template-columns: 150px auto 50px;
|
|
567
|
+
grid-column-gap: 20px;
|
|
568
|
+
grid-row-gap: 20px;
|
|
569
|
+
margin-bottom: 10px;
|
|
46
570
|
}
|
|
47
571
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
572
|
+
.editor label {
|
|
573
|
+
margin-bottom: 5px;
|
|
574
|
+
font-size: 12px;
|
|
575
|
+
font-weight: 400;
|
|
576
|
+
color: var(--paper-grey-500);
|
|
53
577
|
}
|
|
54
578
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
579
|
+
.pb-field {
|
|
580
|
+
display: flex;
|
|
581
|
+
flex-direction: column;
|
|
582
|
+
gap: 0.35rem;
|
|
58
583
|
}
|
|
59
584
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
585
|
+
.pb-field__label {
|
|
586
|
+
font-size: 0.8rem;
|
|
587
|
+
font-weight: 600;
|
|
588
|
+
text-transform: uppercase;
|
|
589
|
+
letter-spacing: 0.05em;
|
|
590
|
+
color: rgba(0, 0, 0, 0.6);
|
|
63
591
|
}
|
|
64
592
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
593
|
+
.pb-select {
|
|
594
|
+
height: var(--pb-input-height, 48px);
|
|
595
|
+
padding: 0.5rem 0.75rem;
|
|
596
|
+
border: 1px solid rgba(0, 0, 0, 0.16);
|
|
597
|
+
border-radius: 8px;
|
|
598
|
+
font: inherit;
|
|
599
|
+
color: inherit;
|
|
600
|
+
background: #fff;
|
|
601
|
+
appearance: none;
|
|
602
|
+
background-image: linear-gradient(45deg, transparent 50%, rgba(0, 0, 0, 0.4) 50%),
|
|
603
|
+
linear-gradient(135deg, rgba(0, 0, 0, 0.4) 50%, transparent 50%),
|
|
604
|
+
linear-gradient(to right, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.1));
|
|
605
|
+
background-position: calc(100% - 18px) calc(0.6em + 2px),
|
|
606
|
+
calc(100% - 13px) calc(0.6em + 2px), calc(100% - 2.5rem) 0.5em;
|
|
607
|
+
background-size: 5px 5px, 5px 5px, 1px 2.25em;
|
|
608
|
+
background-repeat: no-repeat;
|
|
609
|
+
transition: border-color 120ms ease, box-shadow 120ms ease;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
.pb-select:focus {
|
|
613
|
+
outline: none;
|
|
614
|
+
border-color: #1976d2;
|
|
615
|
+
box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.16);
|
|
68
616
|
}
|
|
69
617
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
content: "";
|
|
73
|
-
position: absolute;
|
|
74
|
-
display: var(--_lumo-tab-marker-display, block);
|
|
75
|
-
bottom: 0;
|
|
76
|
-
left: 50%;
|
|
77
|
-
width: var(--lumo-size-s);
|
|
78
|
-
height: 2px;
|
|
79
|
-
background-color: var(--lumo-contrast-60pct);
|
|
80
|
-
border-radius: var(--lumo-border-radius) var(--lumo-border-radius) 0 0;
|
|
81
|
-
transform: translateX(-50%) scale(0);
|
|
82
|
-
transform-origin: 50% 100%;
|
|
83
|
-
transition: 0.14s transform cubic-bezier(.12, .32, .54, 1);
|
|
84
|
-
will-change: transform;
|
|
618
|
+
pb-icon-button {
|
|
619
|
+
align-self: center;
|
|
85
620
|
}
|
|
621
|
+
`}render(){return s`
|
|
622
|
+
<div class="wrapper">
|
|
623
|
+
<div class="pb-field">
|
|
624
|
+
<span class="pb-field__label">Scope</span>
|
|
625
|
+
<select class="pb-select" .value=${this.scope||""} @change=${this._handleScopeChange}>
|
|
626
|
+
${this.scopes.map(e=>s`<option value="${e}">${this._displayScope(e)}</option>`)}
|
|
627
|
+
</select>
|
|
628
|
+
</div>
|
|
629
|
+
<div class="editor">
|
|
630
|
+
<label>Rendition</label>
|
|
631
|
+
<jinn-codemirror
|
|
632
|
+
id="editor"
|
|
633
|
+
label="Rendition"
|
|
634
|
+
code="${this.css||""}"
|
|
635
|
+
mode="css"
|
|
636
|
+
@update="${this._handleCodeChange}"
|
|
637
|
+
></jinn-codemirror>
|
|
638
|
+
</div>
|
|
639
|
+
<pb-icon-button
|
|
640
|
+
class="icon-button"
|
|
641
|
+
icon="delete"
|
|
642
|
+
title="delete this rendition"
|
|
643
|
+
@click="${this._remove}"
|
|
644
|
+
></pb-icon-button>
|
|
645
|
+
</div>
|
|
86
646
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
647
|
+
<slot></slot>
|
|
648
|
+
`}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="";const e=this.getAttribute("scope");this.scope=null!=e?e:"",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._emitChange()}_handleScopeChange(e){this.scope=e.target.value,this._emitChange()}_emitChange(){this.dispatchEvent(new CustomEvent("rendition-changed",{composed:!0,bubbles:!0,detail:{name:this.name,css:this.css,scope:this.scope}}))}_displayScope(e){return e||"(default)"}}customElements.define("pb-odd-rendition-editor",xe);class $e extends o{static get styles(){return i`
|
|
649
|
+
:host {
|
|
650
|
+
display: block;
|
|
90
651
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
width: 2px;
|
|
98
|
-
height: var(--lumo-size-xs);
|
|
99
|
-
border-radius: 0 var(--lumo-border-radius) var(--lumo-border-radius) 0;
|
|
100
|
-
transform-origin: 100% 50%;
|
|
652
|
+
.wrapper {
|
|
653
|
+
display: grid;
|
|
654
|
+
grid-template-columns: 150px auto 50px 50px;
|
|
655
|
+
grid-column-gap: 20px;
|
|
656
|
+
grid-row-gap: 20px;
|
|
657
|
+
margin-bottom: 10px;
|
|
101
658
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
opacity: 0.15;
|
|
106
|
-
transition: 0.15s 0.02s transform, 0.8s 0.17s opacity;
|
|
659
|
+
pb-icon-button {
|
|
660
|
+
align-self: center;
|
|
661
|
+
margin-top: 16px;
|
|
107
662
|
}
|
|
108
663
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
664
|
+
.pb-checkbox {
|
|
665
|
+
display: flex;
|
|
666
|
+
align-items: center;
|
|
667
|
+
gap: 0.5rem;
|
|
668
|
+
align-self: center;
|
|
669
|
+
margin-top: 16px;
|
|
670
|
+
font-size: 0.95rem;
|
|
671
|
+
color: rgba(0, 0, 0, 0.87);
|
|
113
672
|
}
|
|
114
673
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
674
|
+
.pb-checkbox input {
|
|
675
|
+
width: 16px;
|
|
676
|
+
height: 16px;
|
|
118
677
|
}
|
|
119
678
|
|
|
120
|
-
|
|
121
|
-
|
|
679
|
+
.pb-field {
|
|
680
|
+
display: flex;
|
|
681
|
+
flex-direction: column;
|
|
682
|
+
gap: 0.35rem;
|
|
122
683
|
}
|
|
123
684
|
|
|
124
|
-
|
|
125
|
-
|
|
685
|
+
.pb-field__label {
|
|
686
|
+
font-size: 0.8rem;
|
|
687
|
+
font-weight: 600;
|
|
688
|
+
text-transform: uppercase;
|
|
689
|
+
letter-spacing: 0.05em;
|
|
690
|
+
color: rgba(0, 0, 0, 0.6);
|
|
126
691
|
}
|
|
127
692
|
|
|
128
|
-
|
|
129
|
-
display: flex;
|
|
693
|
+
pb-autocomplete {
|
|
130
694
|
width: 100%;
|
|
131
|
-
|
|
132
|
-
height: 100%;
|
|
133
|
-
margin: -0.5rem -0.75rem;
|
|
134
|
-
padding: 0.5rem 0.75rem;
|
|
135
|
-
outline: none;
|
|
695
|
+
}
|
|
136
696
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
697
|
+
.editor label {
|
|
698
|
+
margin-bottom: 5px;
|
|
699
|
+
font-size: 12px;
|
|
700
|
+
font-weight: 400;
|
|
701
|
+
color: rgba(0, 0, 0, 0.6);
|
|
702
|
+
}
|
|
703
|
+
`}render(){return s`
|
|
704
|
+
<div class="wrapper">
|
|
705
|
+
<div class="pb-field">
|
|
706
|
+
<span class="pb-field__label"
|
|
707
|
+
>${M("odd.editor.model.param-name-placeholder")}</span
|
|
708
|
+
>
|
|
709
|
+
<pb-autocomplete
|
|
710
|
+
id="combo"
|
|
711
|
+
.suggestions=${this._currentParameters}
|
|
712
|
+
.value=${this.name||""}
|
|
713
|
+
placeholder="${M("odd.editor.model.param-name-placeholder")}"
|
|
714
|
+
@pb-autocomplete-input=${this._handleNameInput}
|
|
715
|
+
@pb-autocomplete-selected=${this._handleNameSelected}
|
|
716
|
+
></pb-autocomplete>
|
|
717
|
+
</div>
|
|
718
|
+
|
|
719
|
+
<div class="editor">
|
|
720
|
+
<label>Parameter</label>
|
|
721
|
+
<jinn-codemirror
|
|
722
|
+
id="editor"
|
|
723
|
+
mode="xquery"
|
|
724
|
+
code="${this.value}"
|
|
725
|
+
linter="${this.endpoint}/${n(this.apiVersion,"1.0.0")?"modules/editor.xql":"api/lint"}"
|
|
726
|
+
></jinn-codemirror>
|
|
727
|
+
</div>
|
|
728
|
+
<label class="pb-checkbox">
|
|
729
|
+
<input
|
|
730
|
+
id="set"
|
|
731
|
+
type="checkbox"
|
|
732
|
+
?checked=${this.setParam}
|
|
733
|
+
@change=${this._handleSetToggle}
|
|
734
|
+
/>
|
|
735
|
+
<span>${M("odd.editor.model.set-param")}</span>
|
|
736
|
+
</label>
|
|
737
|
+
<pb-icon-button
|
|
738
|
+
class="icon-button"
|
|
739
|
+
icon="delete"
|
|
740
|
+
title="delete this parameter"
|
|
741
|
+
@click="${this._delete}"
|
|
742
|
+
></pb-icon-button>
|
|
743
|
+
</div>
|
|
744
|
+
`}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="",this._currentParameters=[],this.behaviour&&this.parameters[this.behaviour]&&(this._currentParameters=this.parameters[this.behaviour])}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&&this.parameters[o]||[])}updated(e){if(super.updated(e),e.has("parameters")||e.has("behaviour")){var t;this._currentParameters=this.parameters&&this.parameters[this.behaviour]||[];const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("combo");e&&(e.suggestions=this._currentParameters)}}firstUpdated(e){this.selected=this.parameters[this.behaviour]||[],this.requestUpdate(),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){this._emitChange()}_handleNameInput(e){const{text:t,value:o}=e.detail||{};this.name=o??t??"",this._emitChange()}_handleNameSelected(e){const{text:t,value:o}=e.detail||{};this.name=o??t??"",this._emitChange()}_handleSetToggle(e){this.setParam=e.target.checked,this._emitChange()}_emitChange(){const e=this.shadowRoot.getElementById("editor");e&&(this.value=e.content||e.value||"");const t=this.shadowRoot.getElementById("combo");t&&!this.name&&(this.name=t.value||"");const o=this.shadowRoot.getElementById("set");o&&(this.setParam=o.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",$e);class Ee extends o{static get styles(){return i`
|
|
745
|
+
:host {
|
|
746
|
+
display: flex;
|
|
747
|
+
flex-direction: column;
|
|
748
|
+
}
|
|
749
|
+
h1,
|
|
750
|
+
h2,
|
|
751
|
+
h3,
|
|
752
|
+
h4,
|
|
753
|
+
h5,
|
|
754
|
+
h6 {
|
|
755
|
+
font-family: 'Oswald', Verdana, 'Helvetica', sans-serif;
|
|
756
|
+
font-weight: 400 !important;
|
|
143
757
|
}
|
|
144
758
|
|
|
145
|
-
|
|
146
|
-
margin:
|
|
147
|
-
width: var(--lumo-icon-size-m);
|
|
148
|
-
height: var(--lumo-icon-size-m);
|
|
759
|
+
form {
|
|
760
|
+
margin-bottom: 8px;
|
|
149
761
|
}
|
|
150
762
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
763
|
+
.pb-input,
|
|
764
|
+
.pb-select,
|
|
765
|
+
pb-autocomplete {
|
|
766
|
+
margin-bottom: 16px;
|
|
155
767
|
}
|
|
156
768
|
|
|
157
|
-
|
|
158
|
-
margin-left:
|
|
769
|
+
.models {
|
|
770
|
+
margin-left: 20px;
|
|
771
|
+
margin-top: 10px;
|
|
159
772
|
}
|
|
160
773
|
|
|
161
|
-
|
|
162
|
-
|
|
774
|
+
.btn,
|
|
775
|
+
.btn-group {
|
|
776
|
+
margin-top: 0;
|
|
777
|
+
margin-bottom: 0;
|
|
163
778
|
}
|
|
164
779
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
justify-content: space-around;
|
|
170
|
-
text-align: center;
|
|
171
|
-
padding-bottom: 0.5rem;
|
|
172
|
-
padding-top: 0.25rem;
|
|
780
|
+
header {
|
|
781
|
+
// background-color: #d1dae0;
|
|
782
|
+
background: var(--paper-grey-300);
|
|
783
|
+
margin: 0;
|
|
173
784
|
}
|
|
174
785
|
|
|
175
|
-
|
|
176
|
-
|
|
786
|
+
header div {
|
|
787
|
+
display: flex;
|
|
788
|
+
flex-direction: row;
|
|
789
|
+
justify-content: space-between;
|
|
177
790
|
align-items: center;
|
|
178
|
-
margin-top: -0.25rem;
|
|
179
|
-
padding-top: 0.25rem;
|
|
180
791
|
}
|
|
181
792
|
|
|
182
|
-
|
|
793
|
+
header h4 {
|
|
794
|
+
padding: 4px 8px;
|
|
183
795
|
margin: 0;
|
|
796
|
+
display: grid;
|
|
797
|
+
grid-template-columns: 40px 40% auto;
|
|
184
798
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
:host([disabled]) {
|
|
189
|
-
pointer-events: none;
|
|
190
|
-
opacity: 1;
|
|
191
|
-
color: var(--lumo-disabled-text-color);
|
|
799
|
+
h4 .btn-group {
|
|
800
|
+
text-align: right;
|
|
801
|
+
display: none;
|
|
192
802
|
}
|
|
193
803
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
box-shadow: inset 0 0 0 2px var(--lumo-primary-color-50pct);
|
|
198
|
-
border-radius: var(--lumo-border-radius);
|
|
804
|
+
#toggle,
|
|
805
|
+
.modelType {
|
|
806
|
+
align-self: center;
|
|
199
807
|
}
|
|
200
808
|
|
|
201
|
-
|
|
809
|
+
header div.info {
|
|
810
|
+
padding: 0 16px 4px;
|
|
811
|
+
margin: 0;
|
|
812
|
+
font-size: 85%;
|
|
813
|
+
display: block;
|
|
814
|
+
margin: 0 0 0 32px;
|
|
815
|
+
}
|
|
816
|
+
header div.info * {
|
|
817
|
+
display: block;
|
|
818
|
+
line-height: 1.2;
|
|
819
|
+
}
|
|
202
820
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
821
|
+
header .outputDisplay {
|
|
822
|
+
text-transform: uppercase;
|
|
823
|
+
}
|
|
824
|
+
header .description {
|
|
825
|
+
font-style: italic;
|
|
208
826
|
}
|
|
209
827
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
transform: translateX(50%) scale(1);
|
|
828
|
+
header .predicate {
|
|
829
|
+
color: #ff5722;
|
|
213
830
|
}
|
|
214
831
|
|
|
215
|
-
|
|
216
|
-
|
|
832
|
+
.predicate label,
|
|
833
|
+
.template label {
|
|
834
|
+
display: block;
|
|
835
|
+
font-size: 12px;
|
|
836
|
+
font-weight: 300;
|
|
837
|
+
color: rgb(115, 115, 115);
|
|
217
838
|
}
|
|
218
839
|
|
|
219
|
-
|
|
220
|
-
|
|
840
|
+
.model-collapse {
|
|
841
|
+
color: #000000;
|
|
842
|
+
cursor: pointer;
|
|
221
843
|
}
|
|
222
844
|
|
|
223
|
-
:
|
|
224
|
-
|
|
845
|
+
.model-collapse:hover {
|
|
846
|
+
text-decoration: none;
|
|
225
847
|
}
|
|
226
848
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
left: auto;
|
|
230
|
-
right: 0;
|
|
231
|
-
border-radius: var(--lumo-border-radius) 0 0 var(--lumo-border-radius);
|
|
232
|
-
transform-origin: 0% 50%;
|
|
849
|
+
.behaviour {
|
|
850
|
+
color: #ff5722;
|
|
233
851
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
@license
|
|
239
|
-
Copyright (c) 2017 Vaadin Ltd.
|
|
240
|
-
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
241
|
-
*/
|
|
242
|
-
const X=e=>class extends e{static get properties(){return{_hasVaadinItemMixin:{value:!0},disabled:{type:Boolean,value:!1,observer:"_disabledChanged",reflectToAttribute:!0},selected:{type:Boolean,value:!1,reflectToAttribute:!0,observer:"_selectedChanged"},_value:String}}get value(){return void 0!==this._value?this._value:this.textContent.trim()}set value(e){this._value=e}ready(){super.ready();const e=this.getAttribute("value");null!==e&&(this.value=e),this.addEventListener("focus",e=>this._setFocused(!0),!0),this.addEventListener("blur",e=>this._setFocused(!1),!0),this.addEventListener("mousedown",e=>{this._setActive(this._mousedown=!0);const t=()=>{this._setActive(this._mousedown=!1),document.removeEventListener("mouseup",t)};document.addEventListener("mouseup",t)}),this.addEventListener("keydown",e=>this._onKeydown(e)),this.addEventListener("keyup",e=>this._onKeyup(e))}disconnectedCallback(){super.disconnectedCallback(),this.hasAttribute("active")&&this._setFocused(!1)}_selectedChanged(e){this.setAttribute("aria-selected",e)}_disabledChanged(e){e?(this.selected=!1,this.setAttribute("aria-disabled","true"),this.blur()):this.removeAttribute("aria-disabled")}_setFocused(e){e?(this.setAttribute("focused",""),this._mousedown||this.setAttribute("focus-ring","")):(this.removeAttribute("focused"),this.removeAttribute("focus-ring"),this._setActive(!1))}_setActive(e){e?this.setAttribute("active",""):this.removeAttribute("active")}_onKeydown(e){/^( |SpaceBar|Enter)$/.test(e.key)&&!e.defaultPrevented&&(e.preventDefault(),this._setActive(!0))}_onKeyup(e){this.hasAttribute("active")&&(this._setActive(!1),this.click())}}
|
|
243
|
-
/**
|
|
244
|
-
@license
|
|
245
|
-
Copyright (c) 2017 Vaadin Ltd.
|
|
246
|
-
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
247
|
-
*/;class Z extends(h(m(X(v)))){static get template(){return g`
|
|
248
|
-
<slot></slot>
|
|
249
|
-
`}static get is(){return"vaadin-tab"}static get version(){return"3.2.0"}ready(){super.ready(),this.setAttribute("role","tab")}_onKeyup(e){const t=this.hasAttribute("active");if(super._onKeyup(e),t){const e=this.querySelector("a");e&&e.click()}}}customElements.define(Z.is,Z);const J=g`<dom-module id="lumo-tabs" theme-for="vaadin-tabs">
|
|
250
|
-
<template>
|
|
251
|
-
<style>
|
|
252
|
-
:host {
|
|
253
|
-
-webkit-tap-highlight-color: transparent;
|
|
852
|
+
|
|
853
|
+
.behaviour:before {
|
|
854
|
+
content: ' [';
|
|
254
855
|
}
|
|
255
856
|
|
|
256
|
-
:
|
|
257
|
-
|
|
258
|
-
position: relative;
|
|
259
|
-
min-height: var(--lumo-size-l);
|
|
857
|
+
.behaviour:after {
|
|
858
|
+
content: ']';
|
|
260
859
|
}
|
|
261
860
|
|
|
262
|
-
|
|
263
|
-
|
|
861
|
+
.behaviourWrapper {
|
|
862
|
+
display: grid;
|
|
863
|
+
grid-template-columns: 140px 40px 140px auto;
|
|
864
|
+
}
|
|
865
|
+
.behaviourWrapper > * {
|
|
866
|
+
display: inline;
|
|
867
|
+
align-self: stretch;
|
|
264
868
|
}
|
|
265
869
|
|
|
266
|
-
|
|
267
|
-
|
|
870
|
+
.group {
|
|
871
|
+
margin: 0;
|
|
872
|
+
font-size: 16px;
|
|
873
|
+
font-weight: bold;
|
|
268
874
|
}
|
|
269
875
|
|
|
270
|
-
|
|
271
|
-
|
|
876
|
+
.group .title {
|
|
877
|
+
/*text-decoration: underline;*/
|
|
272
878
|
}
|
|
273
879
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
880
|
+
.renditions,
|
|
881
|
+
.parameters {
|
|
882
|
+
padding-left: 16px;
|
|
883
|
+
border-left: 3px solid #e0e0e0;
|
|
884
|
+
margin-bottom: 20px;
|
|
277
885
|
}
|
|
278
886
|
|
|
279
|
-
|
|
280
|
-
[part="back-button"] {
|
|
281
|
-
position: absolute;
|
|
282
|
-
z-index: 1;
|
|
283
|
-
font-family: lumo-icons;
|
|
284
|
-
color: var(--lumo-tertiary-text-color);
|
|
285
|
-
font-size: var(--lumo-icon-size-m);
|
|
887
|
+
.renditions .group {
|
|
286
888
|
display: flex;
|
|
889
|
+
flex-direction: row;
|
|
890
|
+
justify-content: space-between;
|
|
287
891
|
align-items: center;
|
|
288
|
-
justify-content: center;
|
|
289
|
-
width: 1.5em;
|
|
290
|
-
height: 100%;
|
|
291
|
-
transition: 0.2s opacity;
|
|
292
|
-
top: 0;
|
|
293
892
|
}
|
|
294
893
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
color: inherit;
|
|
894
|
+
.predicate .form-control {
|
|
895
|
+
width: 100%;
|
|
298
896
|
}
|
|
299
897
|
|
|
300
|
-
|
|
301
|
-
|
|
898
|
+
.source {
|
|
899
|
+
text-decoration: none;
|
|
900
|
+
margin-bottom: 8px;
|
|
302
901
|
}
|
|
303
902
|
|
|
304
|
-
|
|
305
|
-
|
|
903
|
+
.selectOutput {
|
|
904
|
+
margin-right: 10px;
|
|
306
905
|
}
|
|
307
906
|
|
|
308
|
-
[
|
|
309
|
-
|
|
907
|
+
:host([currentselection]) > form > header {
|
|
908
|
+
@apply --shadow-elevation-4dp;
|
|
909
|
+
border-left: 3px solid var(--paper-blue-500);
|
|
310
910
|
}
|
|
311
911
|
|
|
312
|
-
|
|
912
|
+
.modelTypeMenu {
|
|
913
|
+
margin-left: 8px;
|
|
914
|
+
display: inline-flex;
|
|
915
|
+
align-items: center;
|
|
916
|
+
}
|
|
313
917
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
918
|
+
.sr-only {
|
|
919
|
+
position: absolute;
|
|
920
|
+
width: 1px;
|
|
921
|
+
height: 1px;
|
|
922
|
+
padding: 0;
|
|
923
|
+
margin: -1px;
|
|
924
|
+
overflow: hidden;
|
|
925
|
+
clip: rect(0, 0, 0, 0);
|
|
926
|
+
border: 0;
|
|
319
927
|
}
|
|
320
928
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
929
|
+
.pb-input,
|
|
930
|
+
.pb-select {
|
|
931
|
+
width: 100%;
|
|
932
|
+
height: var(--pb-input-height, 48px);
|
|
933
|
+
padding: 0.5rem 0.75rem;
|
|
934
|
+
border: 1px solid rgba(0, 0, 0, 0.16);
|
|
935
|
+
border-radius: 8px;
|
|
936
|
+
font: inherit;
|
|
937
|
+
color: inherit;
|
|
938
|
+
background: #fff;
|
|
939
|
+
transition: border-color 120ms ease, box-shadow 120ms ease;
|
|
329
940
|
}
|
|
330
941
|
|
|
331
|
-
|
|
942
|
+
.pb-input::placeholder {
|
|
943
|
+
color: rgba(0, 0, 0, 0.4);
|
|
944
|
+
}
|
|
332
945
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
946
|
+
.pb-select {
|
|
947
|
+
appearance: none;
|
|
948
|
+
background-image: linear-gradient(45deg, transparent 50%, rgba(0, 0, 0, 0.4) 50%),
|
|
949
|
+
linear-gradient(135deg, rgba(0, 0, 0, 0.4) 50%, transparent 50%),
|
|
950
|
+
linear-gradient(to right, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.1));
|
|
951
|
+
background-position: calc(100% - 18px) calc(0.6em + 2px),
|
|
952
|
+
calc(100% - 13px) calc(0.6em + 2px), calc(100% - 2.5rem) 0.5em;
|
|
953
|
+
background-size: 5px 5px, 5px 5px, 1px 2.25em;
|
|
954
|
+
background-repeat: no-repeat;
|
|
336
955
|
}
|
|
337
956
|
|
|
338
|
-
|
|
339
|
-
:
|
|
340
|
-
|
|
957
|
+
.pb-input:focus,
|
|
958
|
+
.pb-select:focus {
|
|
959
|
+
outline: none;
|
|
960
|
+
border-color: #1976d2;
|
|
961
|
+
box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.16);
|
|
341
962
|
}
|
|
342
963
|
|
|
343
|
-
/*
|
|
344
|
-
:host([
|
|
345
|
-
|
|
964
|
+
/* need to play it save for FF */
|
|
965
|
+
:host([currentselection]) > form > header > h4 > .btn-group {
|
|
966
|
+
display: inline-block;
|
|
967
|
+
}
|
|
968
|
+
details {
|
|
969
|
+
display: block;
|
|
346
970
|
}
|
|
347
971
|
|
|
348
|
-
|
|
972
|
+
details summary {
|
|
973
|
+
display: none;
|
|
974
|
+
}
|
|
349
975
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
--_lumo-tabs-overflow-mask-image: linear-gradient(transparent, #000 2em, #000 calc(100% - 2em), transparent);
|
|
976
|
+
.renditions {
|
|
977
|
+
margin-top: 10px;
|
|
353
978
|
}
|
|
354
979
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
980
|
+
.details {
|
|
981
|
+
padding: 0px 50px 20px 20px;
|
|
982
|
+
background: var(--paper-grey-200);
|
|
358
983
|
}
|
|
359
984
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
--_lumo-tabs-overflow-mask-image: linear-gradient(transparent, #000 2em);
|
|
985
|
+
details:not([open]) {
|
|
986
|
+
padding: 0;
|
|
363
987
|
}
|
|
364
988
|
|
|
365
|
-
|
|
366
|
-
margin-
|
|
989
|
+
.editor label {
|
|
990
|
+
margin-bottom: 5px;
|
|
991
|
+
font-size: 12px;
|
|
992
|
+
font-weight: 400;
|
|
993
|
+
color: var(--paper-grey-500);
|
|
367
994
|
}
|
|
368
995
|
|
|
369
|
-
|
|
996
|
+
.horizontal {
|
|
997
|
+
display: flex;
|
|
998
|
+
flex-wrap: wrap;
|
|
999
|
+
justify-content: space-between;
|
|
1000
|
+
}
|
|
370
1001
|
|
|
371
|
-
|
|
372
|
-
|
|
1002
|
+
#mode {
|
|
1003
|
+
min-width: 18em;
|
|
373
1004
|
}
|
|
1005
|
+
`}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":default:e="html";break;case"latex":e="tex";break;case"plain":e="default";break;case"fo":case"print":e="xml"}return s`
|
|
1006
|
+
<form>
|
|
1007
|
+
<header>
|
|
1008
|
+
<h4>
|
|
1009
|
+
<pb-icon-button id="toggle"
|
|
1010
|
+
icon="${this.icon}" @click="${this.toggle}"
|
|
1011
|
+
class="model-collapse"></pb-icon-button>
|
|
374
1012
|
|
|
375
|
-
|
|
1013
|
+
<span class="modelType">${this.type}<span class="behaviour" ?hidden="${this._isGroupOrSequence()}">${this.behaviour}</span></span>
|
|
376
1014
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
1015
|
+
<span class="btn-group">
|
|
1016
|
+
<pb-icon-button @click="${this._moveDown}" icon="arrow-downward"
|
|
1017
|
+
title="move down"></pb-icon-button>
|
|
1018
|
+
<pb-icon-button @click="${this._moveUp}" icon="arrow-upward"
|
|
1019
|
+
title="move up"></pb-icon-button>
|
|
1020
|
+
<pb-icon-button @click="${this._requestRemoval}" icon="delete" title="remove"></pb-icon-button>
|
|
1021
|
+
<pb-icon-button @click="${this._copy}" icon="content-copy" title="copy"></pb-icon-button>
|
|
1022
|
+
<pb-icon-button @click="${this._paste}" icon="content-paste"></pb-icon-button>
|
|
1023
|
+
|
|
1024
|
+
${this._isGroupOrSequence()?s`
|
|
1025
|
+
<label class="modelTypeMenu">
|
|
1026
|
+
<span class="sr-only">Add nested model</span>
|
|
1027
|
+
<select class="pb-select" @change=${this._handleAddNested}>
|
|
1028
|
+
<option value="">Add…</option>
|
|
1029
|
+
${"modelSequence"===this.type?s`<option value="model">model</option>`:a}
|
|
1030
|
+
${"modelGrp"===this.type?s`
|
|
1031
|
+
<option value="modelSequence">modelSequence</option>
|
|
1032
|
+
<option value="model">model</option>
|
|
1033
|
+
`:a}
|
|
1034
|
+
</select>
|
|
1035
|
+
</label>
|
|
1036
|
+
`:a}
|
|
1037
|
+
</span>
|
|
1038
|
+
</h4>
|
|
1039
|
+
<div class="info">
|
|
1040
|
+
<div class="outputDisplay">${this.output}</div>
|
|
1041
|
+
<div class="description">${this.desc}</div>
|
|
1042
|
+
<div class="predicate">${this.predicate}</div>
|
|
1043
|
+
</p>
|
|
1044
|
+
</header>
|
|
1045
|
+
<details ?open="${this.show}" class="details">
|
|
1046
|
+
<summary style="display: none;"></summary>
|
|
1047
|
+
<div class="horizontal">
|
|
1048
|
+
<label class="pb-field selectOutput">
|
|
1049
|
+
<span class="pb-field__label">${M("odd.editor.model.output")}</span>
|
|
1050
|
+
<select
|
|
1051
|
+
id="output"
|
|
1052
|
+
class="pb-select"
|
|
1053
|
+
.value=${this.output||""}
|
|
1054
|
+
@change=${this._selectOutput}
|
|
1055
|
+
>
|
|
1056
|
+
${this.outputs.map(e=>s`<option value="${e}">${e}</option>`)}
|
|
1057
|
+
</select>
|
|
1058
|
+
</label>
|
|
1059
|
+
<label class="pb-field">
|
|
1060
|
+
<span class="pb-field__label">${M("odd.editor.model.mode-placeholder")}</span>
|
|
1061
|
+
<input
|
|
1062
|
+
id="mode"
|
|
1063
|
+
class="pb-input"
|
|
1064
|
+
.value=${this.mode||""}
|
|
1065
|
+
placeholder="${M("odd.editor.model.mode-placeholder")}"
|
|
1066
|
+
@change=${this._inputMode}
|
|
1067
|
+
/>
|
|
1068
|
+
</label>
|
|
1069
|
+
</div>
|
|
1070
|
+
<label class="pb-field">
|
|
1071
|
+
<span class="pb-field__label">${M("odd.editor.model.description-placeholder")}</span>
|
|
1072
|
+
<input
|
|
1073
|
+
id="desc"
|
|
1074
|
+
class="pb-input"
|
|
1075
|
+
.value=${this.desc||""}
|
|
1076
|
+
placeholder="${M("odd.editor.model.description-placeholder")}"
|
|
1077
|
+
@change=${this._inputDesc}
|
|
1078
|
+
/>
|
|
1079
|
+
</label>
|
|
381
1080
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
1081
|
+
<div class="editor">
|
|
1082
|
+
<label>Predicate</label>
|
|
1083
|
+
<jinn-codemirror id="predicate"
|
|
1084
|
+
code="${this.predicate}"
|
|
1085
|
+
mode="xquery"
|
|
1086
|
+
linter="${this.endpoint}/${n(this.apiVersion,"1.0.0")<0?"modules/editor.xql":"api/lint"}"
|
|
1087
|
+
placeholder="${M("odd.editor.model.predicate-placeholder")}"
|
|
1088
|
+
@update="${this._updatePredicate}"></jinn-codemirror>
|
|
1089
|
+
</div>
|
|
385
1090
|
|
|
386
|
-
|
|
1091
|
+
${this._isModel()?s`
|
|
1092
|
+
<div>
|
|
1093
|
+
<div class="behaviourWrapper">
|
|
1094
|
+
<label class="pb-field">
|
|
1095
|
+
<span class="pb-field__label"
|
|
1096
|
+
>${M("odd.editor.model.behaviour")}</span
|
|
1097
|
+
>
|
|
1098
|
+
<select
|
|
1099
|
+
id="behaviour"
|
|
1100
|
+
class="pb-select"
|
|
1101
|
+
.value=${this.behaviour||""}
|
|
1102
|
+
?disabled=${this.hasCustomBehaviour}
|
|
1103
|
+
@change=${this._selectBehaviour}
|
|
1104
|
+
>
|
|
1105
|
+
${this.behaviours.map(e=>s`<option value="${e}">${e}</option>`)}
|
|
1106
|
+
</select>
|
|
1107
|
+
</label>
|
|
1108
|
+
<span style="align-self:center;justify-self: center;">
|
|
1109
|
+
${M("odd.editor.model.link-with-or")}
|
|
1110
|
+
</span>
|
|
1111
|
+
<label class="pb-field">
|
|
1112
|
+
<span class="pb-field__label"
|
|
1113
|
+
>${M("odd.editor.model.custom-behaviour-placeholder")}</span
|
|
1114
|
+
>
|
|
1115
|
+
<input
|
|
1116
|
+
id="custombehaviour"
|
|
1117
|
+
class="pb-input"
|
|
1118
|
+
@input=${this._handleCustomBehaviour}
|
|
1119
|
+
placeholder="${M("odd.editor.model.custom-behaviour-placeholder")}"
|
|
1120
|
+
/>
|
|
1121
|
+
</label>
|
|
1122
|
+
<span></span>
|
|
1123
|
+
</div>
|
|
1124
|
+
|
|
1125
|
+
<label class="pb-field">
|
|
1126
|
+
<span class="pb-field__label">CSS Class</span>
|
|
1127
|
+
<input
|
|
1128
|
+
id="css"
|
|
1129
|
+
class="pb-input"
|
|
1130
|
+
.value=${this.css||""}
|
|
1131
|
+
placeholder="${M("odd.editor.model.css-class-placeholder")}"
|
|
1132
|
+
@change=${this._inputCss}
|
|
1133
|
+
/>
|
|
1134
|
+
</label>
|
|
1135
|
+
|
|
1136
|
+
<div class="editor">
|
|
1137
|
+
<label>Template</label>
|
|
1138
|
+
<jinn-codemirror
|
|
1139
|
+
id="template"
|
|
1140
|
+
code="${this.template}"
|
|
1141
|
+
mode="${e}"
|
|
1142
|
+
placeholder="${M("odd.editor.model.template-placeholder")}"
|
|
1143
|
+
@update="${this._updateTemplate}"
|
|
1144
|
+
>
|
|
1145
|
+
<div slot="toolbar">
|
|
1146
|
+
<button
|
|
1147
|
+
type="button"
|
|
1148
|
+
class="pb-button pb-button--text"
|
|
1149
|
+
data-mode="xml"
|
|
1150
|
+
data-command="selectElement"
|
|
1151
|
+
data-key="mod-e mod-s"
|
|
1152
|
+
title="Select element around current cursor position"
|
|
1153
|
+
>
|
|
1154
|
+
<|>
|
|
1155
|
+
</button>
|
|
1156
|
+
<button
|
|
1157
|
+
type="button"
|
|
1158
|
+
class="pb-button pb-button--text"
|
|
1159
|
+
data-mode="xml"
|
|
1160
|
+
data-command="encloseWith"
|
|
1161
|
+
data-key="mod-e mod-e"
|
|
1162
|
+
title="Enclose selection in new element"
|
|
1163
|
+
>
|
|
1164
|
+
<...>
|
|
1165
|
+
</button>
|
|
1166
|
+
<button
|
|
1167
|
+
type="button"
|
|
1168
|
+
class="pb-button pb-button--text sep"
|
|
1169
|
+
data-mode="xml"
|
|
1170
|
+
data-command="removeEnclosing"
|
|
1171
|
+
title="Remove enclosing tags"
|
|
1172
|
+
data-key="mod-e mod-r"
|
|
1173
|
+
>
|
|
1174
|
+
<X>
|
|
1175
|
+
</button>
|
|
1176
|
+
<button
|
|
1177
|
+
type="button"
|
|
1178
|
+
class="pb-button pb-button--text"
|
|
1179
|
+
data-mode="html"
|
|
1180
|
+
data-command="selectElement"
|
|
1181
|
+
data-key="mod-e mod-s"
|
|
1182
|
+
title="Select element around current cursor position"
|
|
1183
|
+
>
|
|
1184
|
+
<|>
|
|
1185
|
+
</button>
|
|
1186
|
+
<button
|
|
1187
|
+
type="button"
|
|
1188
|
+
class="pb-button pb-button--text"
|
|
1189
|
+
data-mode="html"
|
|
1190
|
+
data-command="encloseWith"
|
|
1191
|
+
data-key="mod-e mod-e"
|
|
1192
|
+
title="Enclose selection in new element"
|
|
1193
|
+
>
|
|
1194
|
+
<...>
|
|
1195
|
+
</button>
|
|
1196
|
+
<button
|
|
1197
|
+
type="button"
|
|
1198
|
+
class="pb-button pb-button--text sep"
|
|
1199
|
+
data-mode="html"
|
|
1200
|
+
data-command="removeEnclosing"
|
|
1201
|
+
title="Remove enclosing tags"
|
|
1202
|
+
data-key="mod-e mod-r"
|
|
1203
|
+
>
|
|
1204
|
+
<X>
|
|
1205
|
+
</button>
|
|
1206
|
+
<button
|
|
1207
|
+
type="button"
|
|
1208
|
+
class="pb-button pb-button--text"
|
|
1209
|
+
data-key="mod-e mod-p"
|
|
1210
|
+
data-command="snippet"
|
|
1211
|
+
data-params="[[\${_}]]"
|
|
1212
|
+
title="Insert template variable"
|
|
1213
|
+
>
|
|
1214
|
+
[[...]]
|
|
1215
|
+
</button>
|
|
1216
|
+
</div>
|
|
1217
|
+
</jinn-codemirror>
|
|
1218
|
+
</div>
|
|
1219
|
+
</div>
|
|
387
1220
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
1221
|
+
<div class="parameters">
|
|
1222
|
+
<div class="group">
|
|
1223
|
+
<span class="title">Parameters</span>
|
|
1224
|
+
<pb-icon-button
|
|
1225
|
+
icon="add"
|
|
1226
|
+
@click="${this._addParameter}"
|
|
1227
|
+
></pb-icon-button>
|
|
1228
|
+
</div>
|
|
1229
|
+
${ae(this.parameters||[],e=>e.name,(e,t)=>s`
|
|
1230
|
+
<pb-odd-parameter-editor
|
|
1231
|
+
behaviour="${this.behaviour}"
|
|
1232
|
+
name="${e.name}"
|
|
1233
|
+
value="${e.value}"
|
|
1234
|
+
?set="${e.set}"
|
|
1235
|
+
endpoint="${this.endpoint}"
|
|
1236
|
+
apiVersion="${this.apiVersion}"
|
|
1237
|
+
@parameter-remove="${e=>this._removeParam(e,t)}"
|
|
1238
|
+
@parameter-changed="${e=>this._updateParam(e,t)}"
|
|
1239
|
+
></pb-odd-parameter-editor>
|
|
1240
|
+
`)}
|
|
1241
|
+
</div>
|
|
393
1242
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
1243
|
+
<div class="renditions">
|
|
1244
|
+
<div class="group">
|
|
1245
|
+
<div>
|
|
1246
|
+
<span class="title">Renditions</span>
|
|
1247
|
+
<pb-icon-button
|
|
1248
|
+
icon="add"
|
|
1249
|
+
@click="${this._addRendition}"
|
|
1250
|
+
></pb-icon-button>
|
|
1251
|
+
</div>
|
|
1252
|
+
<div class="source">
|
|
1253
|
+
<paper-checkbox ?checked="${this.sourcerend}" id="sourcerend"
|
|
1254
|
+
>Use source rendition</paper-checkbox
|
|
1255
|
+
>
|
|
1256
|
+
</div>
|
|
1257
|
+
</div>
|
|
1258
|
+
|
|
1259
|
+
${ae(this.renditions||[],e=>e.name,(e,t)=>s`
|
|
1260
|
+
<pb-odd-rendition-editor
|
|
1261
|
+
scope="${e.scope}"
|
|
1262
|
+
css="${e.css}"
|
|
1263
|
+
@remove-rendition="${e=>this._removeRendition(e,t)}"
|
|
1264
|
+
@rendition-changed="${e=>this._updateRendition(e,t)}"
|
|
1265
|
+
></pb-odd-rendition-editor>
|
|
1266
|
+
`)}
|
|
1267
|
+
</div>
|
|
1268
|
+
`:""}
|
|
1269
|
+
</details>
|
|
399
1270
|
|
|
400
|
-
|
|
1271
|
+
<div class="models">
|
|
1272
|
+
${ae(this.model&&this.model.models||[],(e,t)=>s`
|
|
1273
|
+
<pb-odd-model-editor
|
|
1274
|
+
behaviour="${e.behaviour||"inline"}"
|
|
1275
|
+
predicate="${e.predicate}"
|
|
1276
|
+
type="${e.type}"
|
|
1277
|
+
output="${e.output}"
|
|
1278
|
+
css="${e.css}"
|
|
1279
|
+
mode="${e.mode}"
|
|
1280
|
+
.model="${e}"
|
|
1281
|
+
.parameters="${e.parameters}"
|
|
1282
|
+
desc="${e.desc}"
|
|
1283
|
+
sourcerend="${e.sourcerend}"
|
|
1284
|
+
.renditions="${e.renditions}"
|
|
1285
|
+
.template="${e.template}"
|
|
1286
|
+
.show="${e.show}"
|
|
1287
|
+
endpoint="${this.endpoint}"
|
|
1288
|
+
apiVersion="${this.apiVersion}"
|
|
1289
|
+
@model-remove="${this._removeModel}"
|
|
1290
|
+
@model-move-down="${this._moveModelDown}"
|
|
1291
|
+
@model-move-up="${this._moveModelUp}"
|
|
1292
|
+
@model-changed="${this.handleModelChanged}"
|
|
1293
|
+
@click="${e=>this.setCurrentSelection(e,t)}"
|
|
1294
|
+
hasParent
|
|
1295
|
+
></pb-odd-model-editor>
|
|
1296
|
+
`)}
|
|
401
1297
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
1298
|
+
</div>
|
|
1299
|
+
</form>
|
|
1300
|
+
<pb-message id="dialog"></pb-message>
|
|
1301
|
+
`}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){return"latex"===e?"latex":"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}}))}_handleAddNested(e){const t=e.target.value;t&&(this._addNested(t),e.target.value="")}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(P("odd.editor.model.delete-model-label"),P("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 n=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o+1];this._setCurrentSelection(o+1,n),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 n=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o-1];this._setCurrentSelection(o-1,n),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.target.value,this._fireModelChanged("desc",this.desc)}_selectOutput(e){this.output=e.target.value,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.target.value,this._fireModelChanged("behaviour",this.behaviour)}_inputCss(e){this.css=e.target.value,this._fireModelChanged("css",this.css)}_inputMode(e){this.mode=e.target.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",Ee);class Se extends o{static get styles(){return i`
|
|
1302
|
+
:host {
|
|
1303
|
+
display: block;
|
|
1304
|
+
padding: 4px 10px;
|
|
1305
|
+
height: auto;
|
|
405
1306
|
}
|
|
406
1307
|
|
|
407
|
-
|
|
408
|
-
|
|
1308
|
+
h1,
|
|
1309
|
+
h2,
|
|
1310
|
+
h3,
|
|
1311
|
+
h4,
|
|
1312
|
+
h5,
|
|
1313
|
+
h6 {
|
|
1314
|
+
font-family: 'Oswald', Verdana, 'Helvetica', sans-serif;
|
|
1315
|
+
font-weight: 400 !important;
|
|
409
1316
|
}
|
|
410
1317
|
|
|
411
|
-
|
|
412
|
-
|
|
1318
|
+
input {
|
|
1319
|
+
vertical-align: middle;
|
|
413
1320
|
}
|
|
414
1321
|
|
|
415
|
-
|
|
416
|
-
|
|
1322
|
+
.ident {
|
|
1323
|
+
display: inline-block;
|
|
1324
|
+
font-size: 26px;
|
|
1325
|
+
position: relative;
|
|
417
1326
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
1327
|
+
.mode {
|
|
1328
|
+
font-size: 10px;
|
|
1329
|
+
display: inline-block;
|
|
1330
|
+
text-transform: uppercase;
|
|
1331
|
+
border-radius: 12px;
|
|
1332
|
+
color: #616161;
|
|
1333
|
+
background: var(--paper-grey-300);
|
|
1334
|
+
padding: 2px 6px;
|
|
1335
|
+
border: thin solid var(--paper-grey-500);
|
|
1336
|
+
margin-left: 6px;
|
|
1337
|
+
position: absolute;
|
|
1338
|
+
top: 8px;
|
|
422
1339
|
}
|
|
423
1340
|
|
|
424
|
-
:host([
|
|
425
|
-
|
|
1341
|
+
:host([currentselection]) {
|
|
1342
|
+
box-shadow: 0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12),
|
|
1343
|
+
0 3px 5px -1px rgba(0, 0, 0, 0.4);
|
|
426
1344
|
}
|
|
427
1345
|
|
|
428
|
-
|
|
1346
|
+
:host([currentSelection]) > h3,
|
|
1347
|
+
:host([currentSelection]) > header {
|
|
1348
|
+
border-left: thin solid var(--paper-blue-500);
|
|
1349
|
+
}
|
|
429
1350
|
|
|
430
|
-
|
|
431
|
-
|
|
1351
|
+
h3 {
|
|
1352
|
+
display: grid;
|
|
1353
|
+
grid-template-columns: 260px auto 160px;
|
|
1354
|
+
align-items: center;
|
|
1355
|
+
}
|
|
1356
|
+
h3 .controls {
|
|
1357
|
+
text-align: right;
|
|
1358
|
+
margin-right: 10px;
|
|
432
1359
|
}
|
|
433
1360
|
|
|
434
|
-
|
|
435
|
-
|
|
1361
|
+
h3 .ident {
|
|
1362
|
+
align-self: center;
|
|
436
1363
|
}
|
|
437
1364
|
|
|
438
|
-
|
|
439
|
-
|
|
1365
|
+
.controls__add {
|
|
1366
|
+
display: inline-flex;
|
|
1367
|
+
align-items: center;
|
|
1368
|
+
gap: 0.5rem;
|
|
1369
|
+
margin-left: 8px;
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
.controls__add select {
|
|
1373
|
+
height: 36px;
|
|
1374
|
+
border-radius: 8px;
|
|
1375
|
+
border: 1px solid rgba(0, 0, 0, 0.16);
|
|
1376
|
+
padding: 0.25rem 0.5rem;
|
|
1377
|
+
font: inherit;
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
/*todo: this does not take effect*/
|
|
1381
|
+
details.models {
|
|
1382
|
+
--details-transition-duration: 0.4s;
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
.models {
|
|
1386
|
+
padding: 10px;
|
|
1387
|
+
}
|
|
1388
|
+
`}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 s`
|
|
1389
|
+
<h3>
|
|
1390
|
+
<span class="ident">${this.ident}<span class="mode">mode: ${this.mode}</span></span>
|
|
1391
|
+
<span class="spacer"></span>
|
|
1392
|
+
|
|
1393
|
+
<span class="controls">
|
|
1394
|
+
<pb-icon-button
|
|
1395
|
+
class="icon-button"
|
|
1396
|
+
icon="delete"
|
|
1397
|
+
title="${this._label("odd.editor.remove","Remove element")}"
|
|
1398
|
+
@click="${this._remove}"
|
|
1399
|
+
></pb-icon-button>
|
|
1400
|
+
<pb-icon-button
|
|
1401
|
+
class="icon-button"
|
|
1402
|
+
icon="content-paste"
|
|
1403
|
+
title="${this._label("odd.editor.paste","Paste")}"
|
|
1404
|
+
@click="${this._paste}"
|
|
1405
|
+
></pb-icon-button>
|
|
1406
|
+
<label class="controls__add">
|
|
1407
|
+
<span class="sr-only">${this._label("odd.editor.add","Add model")}</span>
|
|
1408
|
+
<select id="addModel" @change=${this._handleAddModel}>
|
|
1409
|
+
<option value="">${this._label("odd.editor.add","Add model")}</option>
|
|
1410
|
+
<option value="model">model</option>
|
|
1411
|
+
<option value="modelSequence">modelSequence</option>
|
|
1412
|
+
<option value="modelGrp">modelGrp</option>
|
|
1413
|
+
</select>
|
|
1414
|
+
</label>
|
|
1415
|
+
</span>
|
|
1416
|
+
</h3>
|
|
1417
|
+
|
|
1418
|
+
<div>
|
|
1419
|
+
${ae(this.models||[],(e,t)=>s`
|
|
1420
|
+
<pb-odd-model-editor
|
|
1421
|
+
behaviour="${e.behaviour||""}"
|
|
1422
|
+
predicate="${e.predicate}"
|
|
1423
|
+
type="${e.type}"
|
|
1424
|
+
output="${e.output}"
|
|
1425
|
+
css="${e.css}"
|
|
1426
|
+
mode="${e.mode}"
|
|
1427
|
+
.model="${e}"
|
|
1428
|
+
.parameters="${e.parameters}"
|
|
1429
|
+
desc="${e.desc}"
|
|
1430
|
+
.sourcerend="${e.sourcerend}"
|
|
1431
|
+
.renditions="${e.renditions}"
|
|
1432
|
+
.template="${e.template}"
|
|
1433
|
+
.show="${e.show}"
|
|
1434
|
+
.endpoint="${this.endpoint}"
|
|
1435
|
+
.apiVersion="${this.apiVersion}"
|
|
1436
|
+
@model-remove="${this._removeModel}"
|
|
1437
|
+
@model-move-down="${this._moveModelDown}"
|
|
1438
|
+
@model-move-up="${this._moveModelUp}"
|
|
1439
|
+
@model-changed="${this.handleModelChanged}"
|
|
1440
|
+
@click="${e=>this.setCurrentSelection(e,t)}"
|
|
1441
|
+
></pb-odd-model-editor>
|
|
1442
|
+
`)}
|
|
1443
|
+
</div>
|
|
1444
|
+
<pb-message id="dialog"></pb-message>
|
|
1445
|
+
`}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(P("odd.editor.model.delete-model-label"),P("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}}))}_label(e,t){const o=M(e);return o&&o!==e?o:t}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",Se);class ke extends(I(r(o))){static get styles(){return i`
|
|
1446
|
+
:host {
|
|
1447
|
+
display: flex;
|
|
1448
|
+
/*margin: 30px 20px;*/
|
|
1449
|
+
margin: 0;
|
|
1450
|
+
padding: 0;
|
|
1451
|
+
height: auto;
|
|
440
1452
|
}
|
|
441
1453
|
|
|
442
|
-
|
|
443
|
-
|
|
1454
|
+
#layout {
|
|
1455
|
+
width: 100%;
|
|
1456
|
+
display: grid;
|
|
1457
|
+
grid-template-columns: auto 1fr;
|
|
1458
|
+
grid-template-rows: auto 1fr;
|
|
444
1459
|
}
|
|
445
1460
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
1461
|
+
#drawer {
|
|
1462
|
+
grid-column: 1 / 1;
|
|
1463
|
+
min-width: 320px;
|
|
449
1464
|
}
|
|
450
1465
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
1466
|
+
#navlist {
|
|
1467
|
+
grid-column: 1 / 1;
|
|
1468
|
+
grid-row: 2 / 2;
|
|
1469
|
+
overflow: auto;
|
|
1470
|
+
height: 100%;
|
|
454
1471
|
}
|
|
455
1472
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
1473
|
+
.nav-item {
|
|
1474
|
+
display: block;
|
|
1475
|
+
width: 100%;
|
|
1476
|
+
padding: 8px 16px;
|
|
1477
|
+
border: none;
|
|
1478
|
+
background: transparent;
|
|
1479
|
+
text-align: left;
|
|
1480
|
+
font: inherit;
|
|
1481
|
+
color: inherit;
|
|
1482
|
+
cursor: pointer;
|
|
1483
|
+
transition: background-color 120ms ease;
|
|
459
1484
|
}
|
|
460
1485
|
|
|
461
|
-
|
|
462
|
-
:
|
|
463
|
-
|
|
1486
|
+
.nav-item:hover,
|
|
1487
|
+
.nav-item:focus-visible {
|
|
1488
|
+
background: rgba(33, 150, 243, 0.12);
|
|
1489
|
+
outline: none;
|
|
464
1490
|
}
|
|
465
1491
|
|
|
466
|
-
|
|
467
|
-
|
|
1492
|
+
.nav-item--active {
|
|
1493
|
+
background: rgba(33, 150, 243, 0.2);
|
|
1494
|
+
font-weight: 600;
|
|
468
1495
|
}
|
|
469
1496
|
|
|
470
|
-
|
|
471
|
-
|
|
1497
|
+
.specs {
|
|
1498
|
+
grid-column: 2 / 2;
|
|
1499
|
+
grid-row: 1 / span 2;
|
|
1500
|
+
overflow: auto;
|
|
472
1501
|
}
|
|
473
1502
|
|
|
474
|
-
|
|
475
|
-
|
|
1503
|
+
section {
|
|
1504
|
+
padding: 20px;
|
|
476
1505
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
484
|
-
*/
|
|
485
|
-
const Y=e=>class extends e{static get properties(){return{_hasVaadinListMixin:{value:!0},selected:{type:Number,reflectToAttribute:!0,notify:!0},orientation:{type:String,reflectToAttribute:!0,value:""},items:{type:Array,readOnly:!0,notify:!0},_searchBuf:{type:String,value:""}}}static get observers(){return["_enhanceItems(items, orientation, selected, disabled)"]}ready(){super.ready(),this.addEventListener("keydown",e=>this._onKeydown(e)),this.addEventListener("click",e=>this._onClick(e)),this._observer=new f(this,e=>{this._setItems(this._filterItems(Array.from(this.children)))})}_enhanceItems(e,t,o,i){if(!i&&e){this.setAttribute("aria-orientation",t||"vertical"),this.items.forEach(e=>{t?e.setAttribute("orientation",t):e.removeAttribute("orientation"),e.updateStyles()}),this._setFocusable(o);const i=e[o];e.forEach(e=>e.selected=e===i),i&&!i.disabled&&this._scrollToItem(o)}}get focused(){return this.getRootNode().activeElement}_filterItems(e){return e.filter(e=>e._hasVaadinItemMixin)}_onClick(e){if(e.metaKey||e.shiftKey||e.ctrlKey||e.defaultPrevented)return;const t=this._filterItems(e.composedPath())[0];let o;t&&!t.disabled&&(o=this.items.indexOf(t))>=0&&(this.selected=o)}_searchKey(e,t){this._searchReset=y.debounce(this._searchReset,w.after(500),()=>this._searchBuf=""),this._searchBuf+=t.toLowerCase();const o=1,i=e=>!(e.disabled||this._isItemHidden(e))&&0===e.textContent.replace(/[^a-zA-Z0-9]/g,"").toLowerCase().indexOf(this._searchBuf);this.items.some(e=>0===e.textContent.replace(/[^a-zA-Z0-9]/g,"").toLowerCase().indexOf(this._searchBuf))||(this._searchBuf=t.toLowerCase());const s=1===this._searchBuf.length?e+1:e;return this._getAvailableIndex(s,o,i)}get _isRTL(){return!this._vertical&&"rtl"===this.getAttribute("dir")}_onKeydown(e){if(e.metaKey||e.ctrlKey)return;const t=e.key.replace(/^Arrow/,""),o=this.items.indexOf(this.focused);if(/[a-zA-Z0-9]/.test(t)&&1===t.length){const e=this._searchKey(o,t);return void(e>=0&&this._focus(e))}const i=e=>!(e.disabled||this._isItemHidden(e));let s,r;const a=this._isRTL?-1:1;this._vertical&&"Up"===t||!this._vertical&&"Left"===t?(r=-a,s=o-a):this._vertical&&"Down"===t||!this._vertical&&"Right"===t?(r=a,s=o+a):"Home"===t?(r=1,s=0):"End"===t&&(r=-1,s=this.items.length-1),s=this._getAvailableIndex(s,r,i),s>=0&&(this._focus(s),e.preventDefault())}_getAvailableIndex(e,t,o){const i=this.items.length;for(let s=0;"number"==typeof e&&s<i;s++,e+=t||1){e<0?e=i-1:e>=i&&(e=0);if(o(this.items[e]))return e}return-1}_isItemHidden(e){return"none"===getComputedStyle(e).display}_setFocusable(e){e=this._getAvailableIndex(e,1,e=>!e.disabled);const t=this.items[e]||this.items[0];this.items.forEach(e=>e.tabIndex=e===t?0:-1)}_focus(e){const t=this.items[e];this.items.forEach(e=>e.focused=e===t),this._setFocusable(e),this._scrollToItem(e),t.focus()}focus(){this._observer&&this._observer.flush();const e=this.querySelector('[tabindex="0"]')||(this.items?this.items[0]:null);e&&e.focus()}get _scrollerElement(){}_scrollToItem(e){const t=this.items[e];if(!t)return;const o=this._vertical?["top","bottom"]:this._isRTL?["right","left"]:["left","right"],i=this._scrollerElement.getBoundingClientRect(),s=(this.items[e+1]||t).getBoundingClientRect(),r=(this.items[e-1]||t).getBoundingClientRect();let a=0;!this._isRTL&&s[o[1]]>=i[o[1]]||this._isRTL&&s[o[1]]<=i[o[1]]?a=s[o[1]]-i[o[1]]:(!this._isRTL&&r[o[0]]<=i[o[0]]||this._isRTL&&r[o[0]]>=i[o[0]])&&(a=r[o[0]]-i[o[0]]),this._scroll(a)}get _vertical(){return"horizontal"!==this.orientation}_scroll(e){if(this._vertical)this._scrollerElement.scrollTop+=e;else{const t=u.detectScrollType(),o=u.getNormalizedScrollLeft(t,this.getAttribute("dir")||"ltr",this._scrollerElement)+e;u.setNormalizedScrollLeft(t,this.getAttribute("dir")||"ltr",this._scrollerElement,o)}}}
|
|
486
|
-
/**
|
|
487
|
-
@license
|
|
488
|
-
Copyright (c) 2017 Vaadin Ltd.
|
|
489
|
-
This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
490
|
-
*/,Q=/Apple.* Version\/(9|10)/.test(navigator.userAgent);class ee extends(h(Y(m(_([E],v))))){static get template(){return g`
|
|
491
|
-
<style>
|
|
492
|
-
:host {
|
|
493
|
-
display: flex;
|
|
494
|
-
align-items: center;
|
|
1506
|
+
|
|
1507
|
+
h3,
|
|
1508
|
+
h4 {
|
|
1509
|
+
font-family: var(--pb-heading-font-family);
|
|
1510
|
+
font-weight: var(--pb-heading-font-weight);
|
|
1511
|
+
line-height: var(--pb-heading-line-height);
|
|
495
1512
|
}
|
|
496
1513
|
|
|
497
|
-
|
|
498
|
-
|
|
1514
|
+
/* ported over but not checked yet */
|
|
1515
|
+
|
|
1516
|
+
.specs {
|
|
1517
|
+
padding: 6px;
|
|
499
1518
|
}
|
|
500
1519
|
|
|
501
|
-
|
|
1520
|
+
.metadata-card {
|
|
502
1521
|
display: block;
|
|
1522
|
+
margin-bottom: 16px;
|
|
1523
|
+
border: 1px solid rgba(0, 0, 0, 0.12);
|
|
1524
|
+
border-radius: 12px;
|
|
1525
|
+
background: #fff;
|
|
1526
|
+
overflow: hidden;
|
|
503
1527
|
}
|
|
504
1528
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
display: flex;
|
|
508
|
-
align-self: stretch;
|
|
509
|
-
overflow-x: auto;
|
|
510
|
-
-webkit-overflow-scrolling: touch;
|
|
511
|
-
-ms-overflow-style: none;
|
|
1529
|
+
.metadata-card div {
|
|
1530
|
+
padding: 0 16px 16px;
|
|
512
1531
|
}
|
|
513
1532
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
:
|
|
519
|
-
overflow: hidden;
|
|
520
|
-
}
|
|
1533
|
+
.pb-field {
|
|
1534
|
+
display: flex;
|
|
1535
|
+
flex-direction: column;
|
|
1536
|
+
gap: 0.35rem;
|
|
1537
|
+
margin-bottom: 10px;
|
|
521
1538
|
}
|
|
522
1539
|
|
|
523
|
-
|
|
524
|
-
|
|
1540
|
+
.pb-field__label {
|
|
1541
|
+
font-size: 0.8rem;
|
|
1542
|
+
font-weight: 600;
|
|
1543
|
+
text-transform: uppercase;
|
|
1544
|
+
letter-spacing: 0.05em;
|
|
1545
|
+
color: rgba(0, 0, 0, 0.6);
|
|
525
1546
|
}
|
|
526
1547
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
1548
|
+
.pb-input {
|
|
1549
|
+
width: 100%;
|
|
1550
|
+
height: var(--pb-input-height, 48px);
|
|
1551
|
+
padding: 0.5rem 0.75rem;
|
|
1552
|
+
border: 1px solid rgba(0, 0, 0, 0.16);
|
|
1553
|
+
border-radius: 8px;
|
|
1554
|
+
font: inherit;
|
|
1555
|
+
color: inherit;
|
|
1556
|
+
background: #fff;
|
|
1557
|
+
transition: border-color 120ms ease, box-shadow 120ms ease;
|
|
531
1558
|
}
|
|
532
1559
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
pointer-events: none;
|
|
536
|
-
opacity: 0;
|
|
537
|
-
cursor: default;
|
|
1560
|
+
.pb-input::placeholder {
|
|
1561
|
+
color: rgba(0, 0, 0, 0.4);
|
|
538
1562
|
}
|
|
539
1563
|
|
|
540
|
-
:
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
1564
|
+
.pb-input:focus {
|
|
1565
|
+
outline: none;
|
|
1566
|
+
border-color: #1976d2;
|
|
1567
|
+
box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.16);
|
|
544
1568
|
}
|
|
545
1569
|
|
|
546
|
-
|
|
547
|
-
|
|
1570
|
+
.pb-checkbox {
|
|
1571
|
+
display: flex;
|
|
1572
|
+
align-items: center;
|
|
1573
|
+
gap: 0.5rem;
|
|
1574
|
+
margin: 10px 0;
|
|
1575
|
+
font-size: 0.95rem;
|
|
548
1576
|
}
|
|
549
1577
|
|
|
550
|
-
|
|
551
|
-
|
|
1578
|
+
.pb-checkbox input {
|
|
1579
|
+
width: 16px;
|
|
1580
|
+
height: 16px;
|
|
552
1581
|
}
|
|
553
1582
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
1583
|
+
.pb-input-with-button {
|
|
1584
|
+
display: flex;
|
|
1585
|
+
align-items: center;
|
|
1586
|
+
gap: 0.5rem;
|
|
557
1587
|
}
|
|
558
1588
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
:host([dir="rtl"]) [part="back-button"]::after {
|
|
562
|
-
content: '▶';
|
|
1589
|
+
.pb-input-with-button pb-icon-button {
|
|
1590
|
+
margin: 0;
|
|
563
1591
|
}
|
|
564
1592
|
|
|
565
|
-
|
|
566
|
-
|
|
1593
|
+
.metadata-card .extCssEdit {
|
|
1594
|
+
display: flex;
|
|
1595
|
+
align-items: center;
|
|
1596
|
+
padding: 0;
|
|
1597
|
+
}
|
|
1598
|
+
.metadata-card .extCssEdit .pb-input {
|
|
1599
|
+
flex: 2;
|
|
1600
|
+
}
|
|
1601
|
+
.metadata-card .extCssEdit pb-edit-xml {
|
|
1602
|
+
width: 40px;
|
|
567
1603
|
}
|
|
568
|
-
</style>
|
|
569
|
-
<div on-click="_scrollBack" part="back-button"></div>
|
|
570
|
-
|
|
571
|
-
<div id="scroll" part="tabs">
|
|
572
|
-
<slot></slot>
|
|
573
|
-
</div>
|
|
574
|
-
|
|
575
|
-
<div on-click="_scrollForward" part="forward-button"></div>
|
|
576
|
-
`}static get is(){return"vaadin-tabs"}static get version(){return"3.2.0"}static get properties(){return{orientation:{value:"horizontal",type:String},selected:{value:0,type:Number}}}static get observers(){return["_updateOverflow(items.*, vertical)"]}ready(){super.ready(),this.addEventListener("iron-resize",()=>this._updateOverflow()),this._scrollerElement.addEventListener("scroll",()=>this._updateOverflow()),this.setAttribute("role","tablist"),x(this,()=>{this._updateOverflow()})}_scrollForward(){this._scroll(-this.__direction*this._scrollOffset)}_scrollBack(){this._scroll(this.__direction*this._scrollOffset)}get _scrollOffset(){return this._vertical?this._scrollerElement.offsetHeight:this._scrollerElement.offsetWidth}get _scrollerElement(){return this.$.scroll}get __direction(){return this._vertical||"rtl"!==this.getAttribute("dir")?-1:1}_updateOverflow(){const e=this._vertical?this._scrollerElement.scrollTop:this.__getNormalizedScrollLeft(this._scrollerElement);let t=this._vertical?this._scrollerElement.scrollHeight:this._scrollerElement.scrollWidth;t-=1;let o=e>0?"start":"";o+=e+this._scrollOffset<t?" end":"",1==this.__direction&&(o=o.replace(/start|end/gi,e=>"start"===e?"end":"start")),o?this.setAttribute("overflow",o.trim()):this.removeAttribute("overflow"),this._repaintShadowNodesHack()}_repaintShadowNodesHack(){if(Q&&this.root){const e="-webkit-backface-visibility";this.root.querySelectorAll("*").forEach(t=>{t.style[e]="visible",t.style[e]=""})}}}customElements.define(ee.is,ee);class te extends a{static get styles(){return n`
|
|
577
|
-
:host {
|
|
578
|
-
display: block;
|
|
579
|
-
}
|
|
580
|
-
.wrapper{
|
|
581
|
-
display:grid;
|
|
582
|
-
grid-template-columns:150px auto 50px;
|
|
583
|
-
grid-column-gap:20px;
|
|
584
|
-
grid-row-gap:20px;
|
|
585
|
-
margin-bottom:10px;
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
.editor label {
|
|
589
|
-
margin-bottom:5px;
|
|
590
|
-
font-size: 12px;
|
|
591
|
-
font-weight: 400;
|
|
592
|
-
color: var(--paper-grey-500);
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
paper-dropdown-menu{
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
paper-icon-button{
|
|
599
|
-
align-self:center;
|
|
600
|
-
}
|
|
601
|
-
`}render(){return l`
|
|
602
|
-
<div class="wrapper">
|
|
603
|
-
<paper-dropdown-menu label="Scope">
|
|
604
|
-
<paper-listbox id="scopeList" slot="dropdown-content" selected="${this.scope}" attr-for-selected="value"
|
|
605
|
-
@iron-select="${this._listchanged}">
|
|
606
|
-
${this.scopes.map(e=>l`
|
|
607
|
-
<paper-item value="${e}">${e}</paper-item>
|
|
608
|
-
`)}
|
|
609
|
-
</paper-listbox>
|
|
610
|
-
</paper-dropdown-menu>
|
|
611
|
-
<div class="editor">
|
|
612
|
-
<label>Rendition</label>
|
|
613
|
-
<jinn-codemirror
|
|
614
|
-
id="editor"
|
|
615
|
-
label="Rendition"
|
|
616
|
-
code="${this.css||""}"
|
|
617
|
-
mode="css"
|
|
618
|
-
@update="${this._handleCodeChange}"></jinn-codemirror>
|
|
619
|
-
</div>
|
|
620
|
-
<paper-icon-button @click="${this._remove}" icon="delete" title="delete this rendition"></paper-icon-button>
|
|
621
|
-
</div>
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
<slot></slot>
|
|
626
|
-
|
|
627
|
-
`}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",te);class oe extends a{static get styles(){return n`
|
|
628
|
-
:host {
|
|
629
|
-
display: block;
|
|
630
|
-
}
|
|
631
|
-
.wrapper{
|
|
632
|
-
display:grid;
|
|
633
|
-
grid-template-columns:150px auto 50px 50px;
|
|
634
|
-
grid-column-gap:20px;
|
|
635
|
-
grid-row-gap:20px;
|
|
636
|
-
margin-bottom:10px;
|
|
637
|
-
}
|
|
638
|
-
paper-dropdown-menu{
|
|
639
|
-
align-self:start;
|
|
640
|
-
}
|
|
641
|
-
paper-icon-button, paper-checkbox {
|
|
642
|
-
align-self: center;
|
|
643
|
-
margin-top: 16px;
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
.editor label {
|
|
647
|
-
margin-bottom:5px;
|
|
648
|
-
font-size: 12px;
|
|
649
|
-
font-weight: 400;
|
|
650
|
-
color: var(--paper-grey-500);
|
|
651
|
-
}
|
|
652
|
-
`}render(){return l`
|
|
653
|
-
<div class="wrapper">
|
|
654
|
-
|
|
655
|
-
<paper-autocomplete id="combo" text="${this.name}" placeholder="${$("odd.editor.model.param-name-placeholder")}" label="Name"
|
|
656
|
-
.source="${this._currentParameters}"></paper-autocomplete>
|
|
657
|
-
|
|
658
|
-
<div class="editor">
|
|
659
|
-
<label>Parameter</label>
|
|
660
|
-
<jinn-codemirror id="editor"
|
|
661
|
-
mode="xquery"
|
|
662
|
-
code="${this.value}"
|
|
663
|
-
linter="${this.endpoint}/${d(this.apiVersion,"1.0.0")?"modules/editor.xql":"api/lint"}"></jinn-codemirror>
|
|
664
|
-
</div>
|
|
665
|
-
<paper-checkbox id="set" ?checked="${this.setParam}" @change="${this._handleCodeChange}">${$("odd.editor.model.set-param")}</paper-checkbox>
|
|
666
|
-
<paper-icon-button @click="${this._delete}" icon="delete" title="delete this parameter"></paper-icon-button>
|
|
667
|
-
</div>
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
`}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",oe);class ie extends a{static get styles(){return n`
|
|
671
|
-
:host {
|
|
672
|
-
display: flex;
|
|
673
|
-
flex-direction:column;
|
|
674
|
-
}
|
|
675
|
-
h1, h2, h3, h4, h5, h6 {
|
|
676
|
-
font-family: "Oswald", Verdana, "Helvetica", sans-serif;
|
|
677
|
-
font-weight: 400 !important;
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
form {
|
|
681
|
-
margin-bottom: 8px;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
paper-input, paper-autocomplete {
|
|
685
|
-
margin-bottom: 16px;
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
.models {
|
|
689
|
-
margin-left:20px;
|
|
690
|
-
margin-top:10px;
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
.btn, .btn-group {
|
|
694
|
-
margin-top: 0;
|
|
695
|
-
margin-bottom: 0;
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
header {
|
|
699
|
-
// background-color: #d1dae0;
|
|
700
|
-
background:var(--paper-grey-300);
|
|
701
|
-
margin:0;
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
header div {
|
|
705
|
-
display: flex;
|
|
706
|
-
flex-direction: row;
|
|
707
|
-
justify-content: space-between;
|
|
708
|
-
align-items: center;
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
header h4 {
|
|
712
|
-
padding: 4px 8px;
|
|
713
|
-
margin: 0;
|
|
714
|
-
display: grid;
|
|
715
|
-
grid-template-columns: 40px 40% auto;
|
|
716
|
-
}
|
|
717
|
-
h4 .btn-group{
|
|
718
|
-
text-align: right;
|
|
719
|
-
display: none;
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
#toggle, .modelType{
|
|
723
|
-
align-self:center;
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
header div.info {
|
|
727
|
-
padding: 0 16px 4px;
|
|
728
|
-
margin: 0;
|
|
729
|
-
font-size: 85%;
|
|
730
|
-
display: block;
|
|
731
|
-
margin:0 0 0 32px;
|
|
732
|
-
}
|
|
733
|
-
header div.info *{
|
|
734
|
-
display: block;
|
|
735
|
-
line-height: 1.2;
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
header .outputDisplay{
|
|
739
|
-
text-transform: uppercase ;
|
|
740
|
-
}
|
|
741
|
-
header .description{
|
|
742
|
-
font-style: italic;
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
header .predicate {
|
|
746
|
-
color: #ff5722;
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
.predicate label, .template label {
|
|
750
|
-
display: block;
|
|
751
|
-
font-size: 12px;
|
|
752
|
-
font-weight: 300;
|
|
753
|
-
color: rgb(115, 115, 115);
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
.model-collapse {
|
|
757
|
-
color: #000000;
|
|
758
|
-
cursor: pointer;
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
.model-collapse:hover {
|
|
762
|
-
text-decoration: none;
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
.behaviour {
|
|
766
|
-
color: #ff5722;
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
.behaviour:before {
|
|
770
|
-
content: ' [';
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
.behaviour:after {
|
|
774
|
-
content: ']';
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
.behaviourWrapper{
|
|
778
|
-
display:grid;
|
|
779
|
-
grid-template-columns: 140px 40px 140px auto;
|
|
780
|
-
}
|
|
781
|
-
.behaviourWrapper > *{
|
|
782
|
-
display:inline;
|
|
783
|
-
align-self:stretch;
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
.group {
|
|
787
|
-
margin: 0;
|
|
788
|
-
font-size: 16px;
|
|
789
|
-
font-weight: bold;
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
.group .title {
|
|
793
|
-
/*text-decoration: underline;*/
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
.renditions, .parameters {
|
|
797
|
-
padding-left: 16px;
|
|
798
|
-
border-left: 3px solid #e0e0e0;
|
|
799
|
-
margin-bottom:20px;
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
.renditions .group {
|
|
803
|
-
display: flex;
|
|
804
|
-
flex-direction: row;
|
|
805
|
-
justify-content: space-between;
|
|
806
|
-
align-items: center;
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
.predicate .form-control {
|
|
810
|
-
width: 100%;
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
.source {
|
|
814
|
-
text-decoration: none;
|
|
815
|
-
margin-bottom: 8px;
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
.selectOutput {
|
|
819
|
-
margin-right: 10px;
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
:host([currentselection]) > form > header{
|
|
823
|
-
@apply --shadow-elevation-4dp;
|
|
824
|
-
border-left:3px solid var(--paper-blue-500);
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
paper-menu-button paper-icon-button{
|
|
828
|
-
margin-left:-10px;
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
/* need to play it save for FF */
|
|
832
|
-
:host([currentselection]) > form > header > h4 > .btn-group{
|
|
833
|
-
display: inline-block;
|
|
834
|
-
}
|
|
835
|
-
iron-collapse{
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
.renditions{
|
|
839
|
-
margin-top:10px;
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
.details{
|
|
843
|
-
padding:0px 50px 20px 20px;
|
|
844
|
-
background:var(--paper-grey-200);
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
.editor {
|
|
848
|
-
margin-bottom: 20px;
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
.editor label {
|
|
852
|
-
margin-bottom:5px;
|
|
853
|
-
font-size: 12px;
|
|
854
|
-
font-weight: 400;
|
|
855
|
-
color: var(--paper-grey-500);
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
.horizontal {
|
|
859
|
-
display: flex;
|
|
860
|
-
flex-wrap: wrap;
|
|
861
|
-
justify-content: space-between;
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
#mode {
|
|
865
|
-
min-width: 18em;
|
|
866
|
-
}
|
|
867
|
-
`}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`
|
|
868
|
-
<form>
|
|
869
|
-
<header>
|
|
870
|
-
<h4>
|
|
871
|
-
<paper-icon-button id="toggle"
|
|
872
|
-
icon="${this.icon}" @click="${this.toggle}"
|
|
873
|
-
class="model-collapse"></paper-icon-button>
|
|
874
|
-
|
|
875
|
-
<span class="modelType">${this.type}<span class="behaviour" ?hidden="${this._isGroupOrSequence()}">${this.behaviour}</span></span>
|
|
876
|
-
|
|
877
|
-
<span class="btn-group">
|
|
878
|
-
<paper-icon-button @click="${this._moveDown}" icon="arrow-downward"
|
|
879
|
-
title="move down"></paper-icon-button>
|
|
880
|
-
<paper-icon-button @click="${this._moveUp}" icon="arrow-upward"
|
|
881
|
-
title="move up"></paper-icon-button>
|
|
882
|
-
<paper-icon-button @click="${this._requestRemoval}" icon="delete" title="remove"></paper-icon-button>
|
|
883
|
-
<paper-icon-button @click="${this._copy}" icon="content-copy" title="copy"></paper-icon-button>
|
|
884
|
-
<paper-icon-button @click="${this._paste}" icon="content-paste"></paper-icon-button>
|
|
885
|
-
|
|
886
|
-
${this._isGroupOrSequence()?l`
|
|
887
|
-
<paper-menu-button horizontal-align="right">
|
|
888
|
-
<paper-icon-button icon="add" slot="dropdown-trigger"></paper-icon-button>
|
|
889
|
-
<paper-listbox id="modelType" slot="dropdown-content" @iron-select="${this._addNested}"
|
|
890
|
-
attr-for-selected="value">
|
|
891
|
-
${"modelSequence"===this.type?l`
|
|
892
|
-
<paper-item value="model">model</paper-item>
|
|
893
|
-
`:""}
|
|
894
|
-
${"modelGrp"===this.type?l`
|
|
895
|
-
<paper-item value="modelSequence">modelSequence</paper-item>
|
|
896
|
-
<paper-item value="model">model</paper-item>
|
|
897
|
-
`:""}
|
|
898
|
-
</paper-listbox>
|
|
899
|
-
</paper-menu-button>
|
|
900
|
-
`:""}
|
|
901
|
-
</span>
|
|
902
|
-
</h4>
|
|
903
|
-
<div class="info">
|
|
904
|
-
<div class="outputDisplay">${this.output}</div>
|
|
905
|
-
<div class="description">${this.desc}</div>
|
|
906
|
-
<div class="predicate">${this.predicate}</div>
|
|
907
|
-
</p>
|
|
908
|
-
</header>
|
|
909
|
-
<iron-collapse id="details" ?opened="${this.show}" class="details">
|
|
910
|
-
<div class="horizontal">
|
|
911
|
-
<paper-dropdown-menu class="selectOutput" label="Output">
|
|
912
|
-
<paper-listbox id="output" slot="dropdown-content" attr-for-selected="value"
|
|
913
|
-
selected="${this.output}" @iron-select="${this._selectOutput}">
|
|
914
|
-
|
|
915
|
-
${this.outputs.map(e=>l`
|
|
916
|
-
<paper-item value="${e}">${e}</paper-item>
|
|
917
|
-
`)}
|
|
918
|
-
|
|
919
|
-
</paper-listbox>
|
|
920
|
-
</paper-dropdown-menu>
|
|
921
|
-
<paper-input id="mode" .value="${this.mode}"
|
|
922
|
-
placeholder="${$("odd.editor.model.mode-placeholder")}"
|
|
923
|
-
label="Mode"
|
|
924
|
-
@change="${this._inputMode}"></paper-input>
|
|
925
|
-
</div>
|
|
926
|
-
<paper-input id="desc" .value="${this.desc}" placeholder="${$("odd.editor.model.description-placeholder")}"
|
|
927
|
-
label="Description" @change="${this._inputDesc}"></paper-input>
|
|
928
1604
|
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
code="${this.predicate}"
|
|
933
|
-
mode="xquery"
|
|
934
|
-
linter="${this.endpoint}/${d(this.apiVersion,"1.0.0")<0?"modules/editor.xql":"api/lint"}"
|
|
935
|
-
placeholder="${$("odd.editor.model.predicate-placeholder")}"
|
|
936
|
-
@update="${this._updatePredicate}"></jinn-codemirror>
|
|
937
|
-
</div>
|
|
938
|
-
|
|
939
|
-
${this._isModel()?l`
|
|
940
|
-
<div>
|
|
941
|
-
<div class="behaviourWrapper">
|
|
942
|
-
<paper-dropdown-menu label="behaviour" id="behaviourMenu" ?disabled="${this.hasCustomBehaviour}">
|
|
943
|
-
<paper-listbox id="behaviour" slot="dropdown-content" attr-for-selected="value"
|
|
944
|
-
selected="${this.behaviour}" @iron-select="${this._selectBehaviour}">
|
|
945
|
-
${this.behaviours.map(e=>l`
|
|
946
|
-
<paper-item value="${e}">${e}</paper-item>
|
|
947
|
-
`)}
|
|
948
|
-
</paper-listbox>
|
|
949
|
-
</paper-dropdown-menu>
|
|
950
|
-
<span style="align-self:center;justify-self: center;"> ${$("odd.editor.model.link-with-or")} </span>
|
|
951
|
-
<paper-input id="custombehaviour" label="" @input="${this._handleCustomBehaviour}" placeHolder="${$("odd.editor.model.custom-behaviour-placeholder")}"></paper-input>
|
|
952
|
-
<span></span>
|
|
953
|
-
</div>
|
|
1605
|
+
#jump-to {
|
|
1606
|
+
margin-top: 1em;
|
|
1607
|
+
}
|
|
954
1608
|
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
<paper-button data-mode="xml" data-command="selectElement" data-key="mod-e mod-s"
|
|
971
|
-
title="Select element around current cursor position"><|></paper-button>
|
|
972
|
-
<paper-button data-mode="xml" data-command="encloseWith" data-key="mod-e mod-e"
|
|
973
|
-
title="Enclose selection in new element"><...></paper-button>
|
|
974
|
-
<paper-button data-mode="xml" data-command="removeEnclosing" title="Remove enclosing tags"
|
|
975
|
-
data-key="mod-e mod-r" class="sep"><X></paper-button>
|
|
976
|
-
<paper-button data-mode="html" data-command="selectElement" data-key="mod-e mod-s"
|
|
977
|
-
title="Select element around current cursor position"><|></paper-button>
|
|
978
|
-
<paper-button data-mode="html" data-command="encloseWith" data-key="mod-e mod-e"
|
|
979
|
-
title="Enclose selection in new element"><...></paper-button>
|
|
980
|
-
<paper-button data-mode="html" data-command="removeEnclosing" title="Remove enclosing tags"
|
|
981
|
-
data-key="mod-e mod-r" class="sep"><X></paper-button>
|
|
982
|
-
<paper-button data-key="mod-e mod-p" data-command="snippet" data-params="[[\${_}]]" title="Insert template variable">[[...]]</paper-button>
|
|
983
|
-
</div>
|
|
984
|
-
</jinn-codemirror>
|
|
985
|
-
</div>
|
|
986
|
-
</div>
|
|
987
|
-
|
|
988
|
-
<div class="parameters">
|
|
989
|
-
<div class="group">
|
|
990
|
-
<span class="title">Parameters</span>
|
|
991
|
-
<paper-icon-button icon="add"
|
|
992
|
-
@click="${this._addParameter}"></paper-icon-button>
|
|
993
|
-
</div>
|
|
994
|
-
${H(this.parameters,e=>e.name,(e,t)=>l`
|
|
995
|
-
<pb-odd-parameter-editor
|
|
996
|
-
behaviour="${this.behaviour}"
|
|
997
|
-
name="${e.name}"
|
|
998
|
-
value="${e.value}"
|
|
999
|
-
?set="${e.set}"
|
|
1000
|
-
endpoint="${this.endpoint}"
|
|
1001
|
-
apiVersion="${this.apiVersion}"
|
|
1002
|
-
@parameter-remove="${e=>this._removeParam(e,t)}"
|
|
1003
|
-
@parameter-changed="${e=>this._updateParam(e,t)}"
|
|
1004
|
-
></pb-odd-parameter-editor>
|
|
1005
|
-
`)}
|
|
1006
|
-
</div>
|
|
1609
|
+
odd-model {
|
|
1610
|
+
border-bottom: 1px solid #e0e0e0;
|
|
1611
|
+
}
|
|
1612
|
+
odd-model h4 {
|
|
1613
|
+
margin-top: 15px;
|
|
1614
|
+
padding-top: 5px;
|
|
1615
|
+
border-top: 1px solid #e0e0e0;
|
|
1616
|
+
}
|
|
1617
|
+
.renditions {
|
|
1618
|
+
margin-top: 10px;
|
|
1619
|
+
}
|
|
1620
|
+
.icons {
|
|
1621
|
+
display: inline-block;
|
|
1622
|
+
white-space: nowrap;
|
|
1623
|
+
}
|
|
1007
1624
|
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
<div class="source">
|
|
1015
|
-
<paper-checkbox ?checked="${this.sourcerend}" id="sourcerend">Use source rendition</paper-checkbox>
|
|
1016
|
-
</div>
|
|
1017
|
-
</div>
|
|
1625
|
+
details {
|
|
1626
|
+
--details-transition-duration: 0.8s;
|
|
1627
|
+
}
|
|
1628
|
+
details[open] {
|
|
1629
|
+
padding: 0;
|
|
1630
|
+
}
|
|
1018
1631
|
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1632
|
+
pb-message#errorMsg {
|
|
1633
|
+
background: var(--paper-red-500);
|
|
1634
|
+
color: white;
|
|
1635
|
+
}
|
|
1636
|
+
.card-content {
|
|
1637
|
+
height: 100%;
|
|
1638
|
+
overflow: auto;
|
|
1639
|
+
}
|
|
1026
1640
|
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
<div class="models">
|
|
1032
|
-
${H(this.model.models,(e,t)=>l`
|
|
1033
|
-
<pb-odd-model-editor
|
|
1034
|
-
behaviour="${e.behaviour||"inline"}"
|
|
1035
|
-
predicate="${e.predicate}"
|
|
1036
|
-
type="${e.type}"
|
|
1037
|
-
output="${e.output}"
|
|
1038
|
-
css="${e.css}"
|
|
1039
|
-
mode="${e.mode}"
|
|
1040
|
-
.model="${e}"
|
|
1041
|
-
.parameters="${e.parameters}"
|
|
1042
|
-
desc="${e.desc}"
|
|
1043
|
-
sourcerend="${e.sourcerend}"
|
|
1044
|
-
.renditions="${e.renditions}"
|
|
1045
|
-
.template="${e.template}"
|
|
1046
|
-
.show="${e.show}"
|
|
1047
|
-
endpoint="${this.endpoint}"
|
|
1048
|
-
apiVersion="${this.apiVersion}"
|
|
1049
|
-
@model-remove="${this._removeModel}"
|
|
1050
|
-
@model-move-down="${this._moveModelDown}"
|
|
1051
|
-
@model-move-up="${this._moveModelUp}"
|
|
1052
|
-
@model-changed="${this.handleModelChanged}"
|
|
1053
|
-
@click="${e=>this.setCurrentSelection(e,t)}"
|
|
1054
|
-
hasParent
|
|
1055
|
-
></pb-odd-model-editor>
|
|
1056
|
-
`)}
|
|
1057
|
-
|
|
1058
|
-
</div>
|
|
1059
|
-
</form>
|
|
1060
|
-
<pb-message id="dialog"></pb-message>
|
|
1061
|
-
`}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(S("odd.editor.model.delete-model-label"),S("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 r=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o+1];this._setCurrentSelection(o+1,r),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 r=this.shadowRoot.querySelectorAll("pb-odd-model-editor")[o-1];this._setCurrentSelection(o-1,r),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",ie);class se extends a{static get styles(){return n`
|
|
1062
|
-
:host {
|
|
1063
|
-
display: block;
|
|
1064
|
-
padding: 4px 10px;
|
|
1065
|
-
height: auto;
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
h1, h2, h3, h4, h5, h6 {
|
|
1069
|
-
font-family: "Oswald", Verdana, "Helvetica", sans-serif;
|
|
1070
|
-
font-weight: 400 !important;
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
input {
|
|
1075
|
-
vertical-align: middle;
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
.ident {
|
|
1079
|
-
display: inline-block;
|
|
1080
|
-
font-size:26px;
|
|
1081
|
-
position:relative;
|
|
1082
|
-
}
|
|
1083
|
-
.mode{
|
|
1084
|
-
font-size:10px;
|
|
1085
|
-
display:inline-block;
|
|
1086
|
-
text-transform:uppercase;
|
|
1087
|
-
border-radius:12px;
|
|
1088
|
-
color:var(--paper-grey-700);
|
|
1089
|
-
background:var(--paper-grey-300);
|
|
1090
|
-
padding:2px 6px;
|
|
1091
|
-
border:thin solid var(--paper-grey-500);
|
|
1092
|
-
margin-left:6px;
|
|
1093
|
-
position:absolute;
|
|
1094
|
-
top:8px;
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
:host([currentselection]){
|
|
1098
|
-
box-shadow: 0 6px 10px 0 rgba(0, 0, 0, 0.14),
|
|
1099
|
-
0 1px 18px 0 rgba(0, 0, 0, 0.12),
|
|
1100
|
-
0 3px 5px -1px rgba(0, 0, 0, 0.4);
|
|
1101
|
-
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1104
|
-
:host([currentSelection]) > h3, :host([currentSelection]) > header{
|
|
1105
|
-
border-left:thin solid var(--paper-blue-500);
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
h3{
|
|
1110
|
-
display:grid;
|
|
1111
|
-
grid-template-columns:260px auto 160px;
|
|
1112
|
-
align-items:center;
|
|
1113
|
-
}
|
|
1114
|
-
h3 .controls{
|
|
1115
|
-
text-align: right;
|
|
1116
|
-
margin-right: 10px;
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
h3 .ident{
|
|
1120
|
-
align-self: center;
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
paper-menu-button paper-icon-button{
|
|
1124
|
-
margin-left:-10px;
|
|
1125
|
-
}
|
|
1126
|
-
|
|
1127
|
-
/*todo: this does not take effect*/
|
|
1128
|
-
iron-collapse.models{
|
|
1129
|
-
--iron-collapse-transition-duration:0.4s;
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
.models{
|
|
1133
|
-
padding:10px;
|
|
1134
|
-
}
|
|
1135
|
-
`}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`
|
|
1136
|
-
<h3>
|
|
1137
|
-
<span class="ident">${this.ident}<span class="mode">mode: ${this.mode}</span></span>
|
|
1138
|
-
<span class="spacer"></span>
|
|
1139
|
-
|
|
1140
|
-
<span class="controls">
|
|
1141
|
-
<paper-icon-button @click="${this._remove}" icon="delete"></paper-icon-button>
|
|
1142
|
-
<paper-icon-button @click="${this._paste}" icon="content-paste"></paper-icon-button>
|
|
1143
|
-
<paper-menu-button horizontal-align="right">
|
|
1144
|
-
<paper-icon-button icon="add" slot="dropdown-trigger"></paper-icon-button>
|
|
1145
|
-
<paper-listbox id="addModel" slot="dropdown-content" @iron-select="${this._addModel}"
|
|
1146
|
-
attr-for-selected="value">
|
|
1147
|
-
<paper-item value="model">model</paper-item>
|
|
1148
|
-
<paper-item value="modelSequence">modelSequence</paper-item>
|
|
1149
|
-
<paper-item value="modelGrp">modelGrp</paper-item>
|
|
1150
|
-
</paper-listbox>
|
|
1151
|
-
</paper-menu-button>
|
|
1641
|
+
.pb-tab {
|
|
1642
|
+
width: 100px;
|
|
1643
|
+
}
|
|
1152
1644
|
|
|
1645
|
+
.editingView {
|
|
1646
|
+
width: 100%;
|
|
1647
|
+
}
|
|
1153
1648
|
|
|
1649
|
+
vaadin-tabs {
|
|
1650
|
+
margin-top: 10px;
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
vaadin-tab {
|
|
1654
|
+
background: var(--paper-grey-200);
|
|
1655
|
+
padding: 0 6px;
|
|
1656
|
+
border: thin solid var(--paper-grey-300);
|
|
1657
|
+
border-bottom: none;
|
|
1658
|
+
}
|
|
1659
|
+
vaadin-tab[selected] {
|
|
1660
|
+
background: white;
|
|
1661
|
+
border-top-right-radius: 20px;
|
|
1662
|
+
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12),
|
|
1663
|
+
0 3px 1px -2px rgba(0, 0, 0, 0.2);
|
|
1664
|
+
}
|
|
1665
|
+
`}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}get tabs(){return this._tabs||(this._tabs=[]),this._tabs}set tabs(e){this._tabs=Array.isArray(e)?e:[]}get safeTabs(){const e=this._tabs||[];return Array.isArray(e)?e:[]}render(){return s`
|
|
1666
|
+
<pb-fetch
|
|
1667
|
+
id="loadContent"
|
|
1668
|
+
handle-as="json"
|
|
1669
|
+
content-type="application/x-www-form-urlencoded"
|
|
1670
|
+
with-credentials
|
|
1671
|
+
method="GET"
|
|
1672
|
+
></pb-fetch>
|
|
1673
|
+
|
|
1674
|
+
<pb-fetch id="saveOdd" handle-as="json" with-credentials></pb-fetch>
|
|
1675
|
+
|
|
1676
|
+
<div id="layout">
|
|
1677
|
+
<div id="drawer">
|
|
1678
|
+
<slot id="slot"></slot>
|
|
1679
|
+
<h3>
|
|
1680
|
+
<span>${this.odd}</span>
|
|
1681
|
+
|
|
1682
|
+
<span class="icons">
|
|
1683
|
+
<pb-edit-xml id="editSource"
|
|
1684
|
+
><pb-icon-button
|
|
1685
|
+
icon="code"
|
|
1686
|
+
title="${M("odd.editor.odd-source")}"
|
|
1687
|
+
></pb-icon-button
|
|
1688
|
+
></pb-edit-xml>
|
|
1689
|
+
<pb-icon-button
|
|
1690
|
+
@click="${()=>this.save(!0)}"
|
|
1691
|
+
icon="icons:cloud-download"
|
|
1692
|
+
title="${M(O?"odd.editor.save-as":"odd.editor.download")}"
|
|
1693
|
+
></pb-icon-button>
|
|
1694
|
+
<pb-icon-button
|
|
1695
|
+
@click="${this._reload}"
|
|
1696
|
+
icon="refresh"
|
|
1697
|
+
title="${M("odd.editor.reload")}"
|
|
1698
|
+
></pb-icon-button>
|
|
1699
|
+
<pb-icon-button
|
|
1700
|
+
@click="${()=>this.save(!1)}"
|
|
1701
|
+
icon="save"
|
|
1702
|
+
title="${M("odd.editor.save")} ${this.display("save")}"
|
|
1703
|
+
?disabled="${!this.loggedIn}"
|
|
1704
|
+
></pb-icon-button>
|
|
1154
1705
|
</span>
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1706
|
+
</h3>
|
|
1707
|
+
<div id="new-element" class="input-group">
|
|
1708
|
+
<label class="pb-field">
|
|
1709
|
+
<span class="pb-field__label">${M("odd.editor.add-element")}</span>
|
|
1710
|
+
<div class="pb-input-with-button">
|
|
1711
|
+
<input
|
|
1712
|
+
id="identNew"
|
|
1713
|
+
class="pb-input"
|
|
1714
|
+
name="ident-new"
|
|
1715
|
+
placeholder="${M("odd.editor.add-element")}"
|
|
1716
|
+
/>
|
|
1717
|
+
<pb-icon-button
|
|
1718
|
+
@click="${this.addElementSpec}"
|
|
1719
|
+
icon="add"
|
|
1720
|
+
tabindex="-1"
|
|
1721
|
+
></pb-icon-button>
|
|
1722
|
+
</div>
|
|
1723
|
+
</label>
|
|
1724
|
+
</div>
|
|
1725
|
+
|
|
1726
|
+
<div id="jump-to">
|
|
1727
|
+
<pb-autocomplete
|
|
1728
|
+
id="jumpTo"
|
|
1729
|
+
placeholder="${M("odd.editor.jump-to")}"
|
|
1730
|
+
></pb-autocomplete>
|
|
1731
|
+
</div>
|
|
1732
|
+
|
|
1733
|
+
<h3>${M("odd.editor.specs")}</h3>
|
|
1182
1734
|
</div>
|
|
1183
|
-
<
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
width: 100%;
|
|
1195
|
-
display: grid;
|
|
1196
|
-
grid-template-columns: auto 1fr;
|
|
1197
|
-
grid-template-rows: auto 1fr;
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
#drawer {
|
|
1201
|
-
grid-column: 1 / 1;
|
|
1202
|
-
min-width: 320px;
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
#navlist {
|
|
1206
|
-
grid-column: 1 / 1;
|
|
1207
|
-
grid-row: 2 / 2;
|
|
1208
|
-
overflow: auto;
|
|
1209
|
-
height: 100%;
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
.specs {
|
|
1213
|
-
grid-column: 2 / 2;
|
|
1214
|
-
grid-row: 1 / span 2;
|
|
1215
|
-
overflow: auto;
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1218
|
-
section{
|
|
1219
|
-
padding:20px;
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1222
|
-
h3, h4 {
|
|
1223
|
-
font-family: var(--pb-heading-font-family);
|
|
1224
|
-
font-weight: var(--pb-heading-font-weight);
|
|
1225
|
-
line-height: var(--pb-heading-line-height);
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
/* ported over but not checked yet */
|
|
1229
|
-
|
|
1230
|
-
.specs {
|
|
1231
|
-
padding:6px;
|
|
1232
|
-
}
|
|
1233
|
-
|
|
1234
|
-
.metadata {
|
|
1235
|
-
display: block;
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
|
-
.metadata div {
|
|
1239
|
-
padding: 0 16px 16px;
|
|
1240
|
-
}
|
|
1241
|
-
|
|
1242
|
-
.metadata paper-input {
|
|
1243
|
-
margin-bottom: 10px;
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
.metadata .extCssEdit {
|
|
1247
|
-
display: flex;
|
|
1248
|
-
align-items: center;
|
|
1249
|
-
padding: 0;
|
|
1250
|
-
}
|
|
1251
|
-
.metadata .extCssEdit paper-input {
|
|
1252
|
-
flex: 2;
|
|
1253
|
-
}
|
|
1254
|
-
.metadata .extCssEdit pb-edit-xml {
|
|
1255
|
-
width: 40px;
|
|
1256
|
-
}
|
|
1257
|
-
|
|
1258
|
-
#jump-to {
|
|
1259
|
-
margin-top: 1em;
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1262
|
-
odd-model {
|
|
1263
|
-
border-bottom: 1px solid #E0E0E0;
|
|
1264
|
-
}
|
|
1265
|
-
odd-model h4 {
|
|
1266
|
-
margin-top: 15px;
|
|
1267
|
-
padding-top: 5px;
|
|
1268
|
-
border-top: 1px solid #E0E0E0;
|
|
1269
|
-
}
|
|
1270
|
-
.renditions {
|
|
1271
|
-
margin-top: 10px;
|
|
1272
|
-
}
|
|
1273
|
-
.icons{
|
|
1274
|
-
display:inline-block;
|
|
1275
|
-
white-space: nowrap;
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
|
-
/* todo: this doesn't work - should refactor to have the complete trigger exposed here (move out of pb-collapse) */
|
|
1279
|
-
pb-collapse#meta ::slotted(.collapse-trigger){
|
|
1280
|
-
/*height:56px;*/
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
|
-
iron-collapse {
|
|
1284
|
-
--iron-collapse-transition-duration:0.8s;
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
pb-message#errorMsg{
|
|
1288
|
-
background: var(--paper-red-500);
|
|
1289
|
-
color:white;
|
|
1290
|
-
}
|
|
1291
|
-
.card-content{
|
|
1292
|
-
height:100%;
|
|
1293
|
-
overflow:auto;
|
|
1294
|
-
}
|
|
1295
|
-
|
|
1296
|
-
paper-tab{
|
|
1297
|
-
width:100px;
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
|
-
.editingView {
|
|
1301
|
-
width:100%;
|
|
1302
|
-
}
|
|
1303
|
-
|
|
1304
|
-
vaadin-tabs{
|
|
1305
|
-
margin-top:10px;
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
|
-
vaadin-tab{
|
|
1309
|
-
background:var(--paper-grey-200);
|
|
1310
|
-
padding:0 6px;
|
|
1311
|
-
border:thin solid var(--paper-grey-300);
|
|
1312
|
-
border-bottom:none;
|
|
1313
|
-
}
|
|
1314
|
-
vaadin-tab[selected]{
|
|
1315
|
-
background:white;
|
|
1316
|
-
border-top-right-radius:20px;
|
|
1317
|
-
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14),
|
|
1318
|
-
0 1px 5px 0 rgba(0, 0, 0, 0.12),
|
|
1319
|
-
0 3px 1px -2px rgba(0, 0, 0, 0.2);
|
|
1320
|
-
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
`}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`
|
|
1324
|
-
<iron-ajax id="loadContent"
|
|
1325
|
-
handle-as="json" content-type="application/x-www-form-urlencoded"
|
|
1326
|
-
with-credentials
|
|
1327
|
-
method="GET"></iron-ajax>
|
|
1328
|
-
|
|
1329
|
-
<iron-ajax id="saveOdd"
|
|
1330
|
-
handle-as="json"
|
|
1331
|
-
with-credentials></iron-ajax>
|
|
1332
|
-
|
|
1333
|
-
<div id="layout">
|
|
1334
|
-
<div id="drawer">
|
|
1335
|
-
<slot id="slot"></slot>
|
|
1336
|
-
<h3>
|
|
1337
|
-
<span>${this.odd}</span>
|
|
1338
|
-
|
|
1339
|
-
<span class="icons">
|
|
1340
|
-
<pb-edit-xml id="editSource"><paper-icon-button icon="code" title="${$("odd.editor.odd-source")}"></paper-icon-button></pb-edit-xml>
|
|
1341
|
-
<paper-icon-button @click="${()=>this.save(!0)}" icon="icons:cloud-download" title="${$(k?"odd.editor.save-as":"odd.editor.download")}"></paper-icon-button>
|
|
1342
|
-
<paper-icon-button @click="${this._reload}" icon="refresh" title="${$("odd.editor.reload")}"></paper-icon-button>
|
|
1343
|
-
<paper-icon-button @click="${()=>this.save(!1)}" icon="save" title="${$("odd.editor.save")} ${this.display("save")}"
|
|
1344
|
-
?disabled="${!this.loggedIn}"></paper-icon-button>
|
|
1345
|
-
</span>
|
|
1346
|
-
</h3>
|
|
1347
|
-
<div id="new-element" class="input-group">
|
|
1348
|
-
<paper-input id="identNew" label="${$("odd.editor.add-element")}" always-float-label="always-float-label">
|
|
1349
|
-
<paper-icon-button slot="suffix" @click="${this.addElementSpec}" icon="add" tabindex="-1"></paper-icon-button>
|
|
1350
|
-
</paper-input>
|
|
1351
|
-
</div>
|
|
1352
|
-
|
|
1353
|
-
<div id="jump-to">
|
|
1354
|
-
<paper-autocomplete id="jumpTo" label="${$("odd.editor.jump-to")}" always-float-label="always-float-label"></paper-autocomplete>
|
|
1355
|
-
</div>
|
|
1356
|
-
|
|
1357
|
-
<h3>${$("odd.editor.specs")}</h3>
|
|
1358
|
-
</div>
|
|
1359
|
-
<div id="navlist">
|
|
1360
|
-
${H(this.elementSpecs,e=>e.ident,(e,t)=>l`
|
|
1361
|
-
<paper-item id="es_${e.ident}"
|
|
1362
|
-
index="${t}"
|
|
1363
|
-
@click="${e=>this._openElementSpec(e,t)}">${e.ident}</paper-item>
|
|
1364
|
-
`)}
|
|
1365
|
-
</div>
|
|
1366
|
-
<section class="specs" id="specs">
|
|
1367
|
-
|
|
1368
|
-
<paper-card class="metadata">
|
|
1369
|
-
<pb-collapse id="meta">
|
|
1370
|
-
<h4 slot="collapse-trigger" class="panel-title">
|
|
1371
|
-
${this._computedTitle()}
|
|
1372
|
-
</h4>
|
|
1373
|
-
<div slot="collapse-content">
|
|
1374
|
-
<paper-input id="title" name="title" value="${this.title}" label="${$("odd.editor.title")}"
|
|
1375
|
-
placeholder="[${$("odd.editor.title-placeholder")}]"
|
|
1376
|
-
@change="${this._inputTitle}"></paper-input>
|
|
1377
|
-
<paper-input id="titleShort" name="short-title" .value="${this.titleShort}" label="${$("odd.editor.title-short")}"
|
|
1378
|
-
placeholder="[${$("odd.editor.title-short-placeholder")}]"
|
|
1379
|
-
@change="${e=>this.titleShort=e.composedPath()[0].value}"></paper-input>
|
|
1380
|
-
<paper-input id="description" name="description" .value="${W(this.description)}" label="${$("odd.editor.description-label")}"
|
|
1381
|
-
placeholder="[${$("odd.editor.description-placeholder")}]"
|
|
1382
|
-
@change="${e=>this.description=e.composedPath()[0].value}"></paper-input>
|
|
1383
|
-
<paper-input id="source" name="source" ?value="${this.source}" label="${$("odd.editor.source-label")}"
|
|
1384
|
-
placeholder="[${$("odd.editor.source-placeholder")}]"
|
|
1385
|
-
@change="${e=>this.source=e.composedPath()[0].value}"></paper-input>
|
|
1386
|
-
<paper-checkbox id="useNamespace" @change="${this.setUseNamespace}">${$("odd.editor.use-namespace")}</paper-checkbox>
|
|
1387
|
-
<paper-input id="namespace" name="namespace" value="${this.namespace}" label="Namespace" ?disabled="${!this.useNamespace}"
|
|
1388
|
-
placeholder="[${$("odd.editor.namespace-placeholder")}]"
|
|
1389
|
-
@change="${e=>this.namespace=e.composedPath()[0].value}"></paper-input>
|
|
1390
|
-
<div class="extCssEdit">
|
|
1391
|
-
<paper-input name="cssFile" value="${this.cssFile}" label="External CSS File"
|
|
1392
|
-
placeholder="[External CSS file with additional class definitions]"
|
|
1393
|
-
@change="${this._cssFileChanged}"></paper-input>
|
|
1394
|
-
<pb-edit-xml id="editCSS"><paper-icon-button icon="create" title="${$("odd.editor.css-source")}"></paper-icon-button></pb-edit-xml>
|
|
1395
|
-
</div>
|
|
1396
|
-
</div>
|
|
1397
|
-
</pb-collapse>
|
|
1398
|
-
</paper-card>
|
|
1399
|
-
|
|
1400
|
-
<!-- todo: import elementspec to make it function -->
|
|
1401
|
-
|
|
1402
|
-
<div class="editingView">
|
|
1403
|
-
<vaadin-tabs id="tabs" selected="${this.tabIndex}">
|
|
1404
|
-
${H(this.tabs,e=>e.id,(e,t)=>l`
|
|
1405
|
-
<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>
|
|
1406
|
-
`)}
|
|
1407
|
-
</vaadin-tabs>
|
|
1408
|
-
|
|
1409
|
-
<div id="currentElement"></div>
|
|
1410
|
-
</div>
|
|
1411
|
-
</section>
|
|
1412
|
-
|
|
1735
|
+
<div id="navlist">
|
|
1736
|
+
${ae(this.elementSpecs||[],e=>e.ident,(e,t)=>s`
|
|
1737
|
+
<button
|
|
1738
|
+
id="es_${e.ident}"
|
|
1739
|
+
type="button"
|
|
1740
|
+
class="nav-item ${this.selectedNavIndex===t?"nav-item--active":""}"
|
|
1741
|
+
@click="${e=>this._openElementSpec(e,t)}"
|
|
1742
|
+
>
|
|
1743
|
+
${e.ident}
|
|
1744
|
+
</button>
|
|
1745
|
+
`)}
|
|
1413
1746
|
</div>
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
`}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"),c("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 se;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{'"':""","&":"&","<":"<",">":">"}}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(S("browse.delete"),S("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":"",r=t.models.map(e=>this.serializeModel(o,e)).join(""),a=t.parameters.map(e=>this.serializeParameter(o,e)).join(""),n=t.renditions.map(e=>this.serializeRendition(o,e)).join(""),l=`${s}${r}${a}${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(S("odd.editor.save"),S("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(S("odd.editor.denied"),S("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(S("odd.editor.saved"),i),this._hasChanges=!1,document.dispatchEvent(new CustomEvent("pb-end-update")),t){A(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(S("odd.editor.reload"),S("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};
|
|
1747
|
+
<section class="specs" id="specs">
|
|
1748
|
+
<div class="metadata-card">
|
|
1749
|
+
<pb-collapse id="meta">
|
|
1750
|
+
<h4 slot="collapse-trigger" class="panel-title">${this._computedTitle()}</h4>
|
|
1751
|
+
<div slot="collapse-content">
|
|
1752
|
+
<label class="pb-field">
|
|
1753
|
+
<span class="pb-field__label">${M("odd.editor.title")}</span>
|
|
1754
|
+
<input
|
|
1755
|
+
id="title"
|
|
1756
|
+
class="pb-input"
|
|
1757
|
+
name="title"
|
|
1758
|
+
.value=${this.title||""}
|
|
1759
|
+
placeholder="[${M("odd.editor.title-placeholder")}]"
|
|
1760
|
+
@change=${this._inputTitle}
|
|
1761
|
+
/>
|
|
1762
|
+
</label>
|
|
1763
|
+
<label class="pb-field">
|
|
1764
|
+
<span class="pb-field__label">${M("odd.editor.title-short")}</span>
|
|
1765
|
+
<input
|
|
1766
|
+
id="titleShort"
|
|
1767
|
+
class="pb-input"
|
|
1768
|
+
name="short-title"
|
|
1769
|
+
.value=${this.titleShort||""}
|
|
1770
|
+
placeholder="[${M("odd.editor.title-short-placeholder")}]"
|
|
1771
|
+
@change=${e=>this.titleShort=e.target.value}
|
|
1772
|
+
/>
|
|
1773
|
+
</label>
|
|
1774
|
+
<label class="pb-field">
|
|
1775
|
+
<span class="pb-field__label">${M("odd.editor.description-label")}</span>
|
|
1776
|
+
<input
|
|
1777
|
+
id="description"
|
|
1778
|
+
class="pb-input"
|
|
1779
|
+
name="description"
|
|
1780
|
+
.value=${this.description||""}
|
|
1781
|
+
placeholder="[${M("odd.editor.description-placeholder")}]"
|
|
1782
|
+
@change=${e=>this.description=e.target.value}
|
|
1783
|
+
/>
|
|
1784
|
+
</label>
|
|
1785
|
+
<label class="pb-field">
|
|
1786
|
+
<span class="pb-field__label">${M("odd.editor.source-label")}</span>
|
|
1787
|
+
<input
|
|
1788
|
+
id="source"
|
|
1789
|
+
class="pb-input"
|
|
1790
|
+
name="source"
|
|
1791
|
+
.value=${this.source||""}
|
|
1792
|
+
placeholder="[${M("odd.editor.source-placeholder")}]"
|
|
1793
|
+
@change=${e=>this.source=e.target.value}
|
|
1794
|
+
/>
|
|
1795
|
+
</label>
|
|
1796
|
+
<label class="pb-checkbox">
|
|
1797
|
+
<input
|
|
1798
|
+
id="useNamespace"
|
|
1799
|
+
type="checkbox"
|
|
1800
|
+
?checked=${this.useNamespace}
|
|
1801
|
+
@change=${this.setUseNamespace}
|
|
1802
|
+
/>
|
|
1803
|
+
<span>${M("odd.editor.use-namespace")}</span>
|
|
1804
|
+
</label>
|
|
1805
|
+
<label class="pb-field">
|
|
1806
|
+
<span class="pb-field__label">Namespace</span>
|
|
1807
|
+
<input
|
|
1808
|
+
id="namespace"
|
|
1809
|
+
class="pb-input"
|
|
1810
|
+
name="namespace"
|
|
1811
|
+
.value=${this.namespace||""}
|
|
1812
|
+
?disabled=${!this.useNamespace}
|
|
1813
|
+
placeholder="[${M("odd.editor.namespace-placeholder")}]"
|
|
1814
|
+
@change=${e=>this.namespace=e.target.value}
|
|
1815
|
+
/>
|
|
1816
|
+
</label>
|
|
1817
|
+
<div class="extCssEdit">
|
|
1818
|
+
<input
|
|
1819
|
+
name="cssFile"
|
|
1820
|
+
class="pb-input"
|
|
1821
|
+
.value=${this.cssFile||""}
|
|
1822
|
+
placeholder="[External CSS file with additional class definitions]"
|
|
1823
|
+
@change=${this._cssFileChanged}
|
|
1824
|
+
/>
|
|
1825
|
+
<pb-edit-xml id="editCSS"
|
|
1826
|
+
><pb-icon-button
|
|
1827
|
+
icon="create"
|
|
1828
|
+
title="${M("odd.editor.css-source")}"
|
|
1829
|
+
></pb-icon-button
|
|
1830
|
+
></pb-edit-xml>
|
|
1831
|
+
</div>
|
|
1832
|
+
</div>
|
|
1833
|
+
</pb-collapse>
|
|
1834
|
+
</div>
|
|
1835
|
+
|
|
1836
|
+
<!-- todo: import elementspec to make it function -->
|
|
1837
|
+
|
|
1838
|
+
<div class="editingView">
|
|
1839
|
+
<vaadin-tabs id="tabs" selected="${this.tabIndex||0}">
|
|
1840
|
+
${ae(this.tabs||[],e=>e,(e,t)=>s`
|
|
1841
|
+
<vaadin-tab name="${e}" @click="${t=>this._selectTab(t,e)}"
|
|
1842
|
+
><span style="padding-right:20px;">${e}</span
|
|
1843
|
+
><pb-icon-button
|
|
1844
|
+
icon="close"
|
|
1845
|
+
@click="${e=>this._closeTabHandler(e,t)}"
|
|
1846
|
+
></pb-icon-button
|
|
1847
|
+
></vaadin-tab>
|
|
1848
|
+
`)}
|
|
1849
|
+
</vaadin-tabs>
|
|
1850
|
+
|
|
1851
|
+
<div id="currentElement"></div>
|
|
1852
|
+
</div>
|
|
1853
|
+
</section>
|
|
1854
|
+
</div>
|
|
1855
|
+
|
|
1856
|
+
<pb-message id="dialog" hidden></pb-message>
|
|
1857
|
+
<pb-message id="errorMsg"></pb-message>
|
|
1858
|
+
`}firstUpdated(e){this.shadowRoot.getElementById("useNamespace").checked=this.useNamespace,this.jumpCtrl=this.shadowRoot.getElementById("jumpTo"),this.jumpCtrl.addEventListener("pb-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"),l("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=[],this._tabs=[],this.tabIndex=0,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}`}`,this.loadContent.headers={Accept:"application/json"};const t=this.loadContent.generateRequest();if(this._hasChanges=!1,!t)return console.warn("pb-odd-editor: Failed to generate request - invalid URL"),this.loading=!1,void document.dispatchEvent(new CustomEvent("pb-end-update"));t.then(e=>this.handleOdd({response:e})).catch(e=>{console.warn("pb-odd-editor: Failed to load ODD data:",e),this.loading=!1,document.dispatchEvent(new CustomEvent("pb-end-update"))})}handleOdd(e){const t=e.response;if(t){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}`)}t.elementSpecs&&Array.isArray(t.elementSpecs)?this.elementSpecs=t.elementSpecs.map(e=>this.mapElementSpec(e)):(console.warn("pb-odd-editor: elementSpecs data is missing or invalid"),this.elementSpecs=[]),this._updateAutoComplete(),this.requestUpdate(),this.loading=!1,document.dispatchEvent(new CustomEvent("pb-end-update")),document.title=this.titleShort||this.title}else console.warn("pb-odd-editor: Failed to load ODD data")}_updateAutoComplete(){this.shadowRoot.getElementById("jumpTo").suggestions=this.elementSpecs.map(this._specMapper)}_cssFileChanged(e){if(this.cssFile=e.target.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),this.selectedNavIndex=t,this.requestUpdate();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 Se;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){const t=[...this.tabs];if(t.splice(e,1),0===t.length)this.shadowRoot.getElementById("currentElement").innerHTML="",this.tabIndex=0,this.tabs=[];else if(this.tabIndex>0&&this.tabIndex>=e){this.tabIndex-=1,this.tabs=t;const e=this.tabs[this.tabIndex];this._selectTab(null,e)}else this.tabs=t}attributeChangedCallback(e,t,o){super.attributeChangedCallback(e,t,o),"odd"==e&&t!==o&&this.inited&&this.load()}static get replaceCharMap(){return{'"':""","&":"&","<":"<",">":">"}}static get replaceCharRegexp(){return/"|&|<|>/g}static replaceChars(e){return ke.replaceCharMap[e]}jumpTo(e){var t,o,i;const s=((null==e||null===(t=e.detail)||void 0===t?void 0:t.value)||(null==e||null===(o=e.detail)||void 0===o?void 0:o.text)||(null===(i=this.jumpCtrl)||void 0===i?void 0:i.value)||"").trim();if(!s)return;const n=this.shadowRoot.querySelector(`#es_${s}`);n&&(this.jumpCtrl&&(this.jumpCtrl.value=""),n.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.suggestions=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().then(e=>this._handleElementSpecResponse({response:e}))}_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(".nav-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(P("browse.delete"),P("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>`:"",i=`${this.indentString}<title>${this.title}${o}</title>\n`,s=this.titleShort?`${this.indentString}<title type="short">${this.titleShort}</title>\n`:"",n=this.cssFile?`${this.indentString}<rendition source="${this.cssFile}"/>\n`:"",a=this.elementSpecs.map(e=>this.serializeElementSpec(this.indentString,e)).join("");return`<schemaSpec xmlns="http://www.tei-c.org/ns/1.0" xmlns:pb="http://teipublisher.com/1.0"${e}${t}>\n${i}${s}${n}\n${a}</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`:"",n=t.models.map(e=>this.serializeModel(o,e)).join(""),a=t.parameters.map(e=>this.serializeParameter(o,e)).join(""),r=t.renditions.map(e=>this.serializeRendition(o,e)).join(""),l=`${s}${n}${a}${ke.serializeTemplate(o,t.template)}${r}`,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}${ke.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}="${ke.escape(t)}"`:""}static escape(e){return e?"string"==typeof e?e.replace(ke.replaceCharRegexp,ke.replaceChars):e:""}save(e=!1){document.dispatchEvent(new CustomEvent("pb-start-update"));const t=this.serializeOdd();this.shadowRoot.getElementById("dialog").show(P("odd.editor.save"),P("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().then(t=>{this.handleSaveComplete({response: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(P("odd.editor.denied"),P("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(ke._renderReport).join("")}</div>`}else{const{report:e}=o;i=`<div class="list-group">${e}</div>`}if(this.shadowRoot.getElementById("dialog").set(P("odd.editor.saved"),i),this._hasChanges=!1,document.dispatchEvent(new CustomEvent("pb-end-update")),t){T(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(P("odd.editor.reload"),P("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.target.value}}customElements.define("pb-odd-editor",ke);export{ke as PbOddEditor};
|