@teipublisher/pb-components 2.26.1-next.3 → 3.0.0-next-4.2
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 +53 -0
- package/.github/workflows/node.js.yml +70 -21
- package/.releaserc.json +7 -2
- package/CHANGELOG.md +363 -11
- 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/.github/workflows/main.yml +0 -24
- package/.github/workflows/release.js.yml +0 -34
- 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-fe4a4883.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 -41
- package/src/polymer-hack.js +0 -6
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import{p as e,a as t,r as i,x as o,i as s}from"./pb-mixin-DHoWQheB.js";import"./es-global-bridge-D8ZcUcx_.js";class r extends(e(t)){static get properties(){return Object.assign(Object.assign({},super.properties),{},{showNavigationControl:{type:Boolean,attribute:"show-navigation-control"},showNavigator:{type:Boolean,attribute:"show-navigator"},showSequenceMode:{type:Boolean,attribute:"show-sequence-control"},showHomeControl:{type:Boolean,attribute:"show-home-control"},showFullPageControl:{type:Boolean,attribute:"show-full-page-control"},showDownloadButton:{type:Boolean,attribute:"show-download-control"},defaultZoomLevel:{type:Number,attribute:"default-zoom-level"},showRotationControl:{type:Boolean,attribute:"show-rotation-control"},constrainDuringPan:{type:Boolean,attribute:"contrain-during-pan"},visibilityRatio:{type:Number,attribute:"visibility-ratio"},referenceStrip:{type:Boolean,attribute:"reference-strip"},referenceStripSizeRatio:{type:Number,attribute:"reference-strip-size-ratio"},type:{type:String},baseUri:{type:String,attribute:"base-uri"},prefixUrl:{type:String,attribute:"prefix-url"},facsimiles:{type:Array},loaded:{type:Boolean,reflect:!0},crossOriginPolicy:{type:String,attribute:"cors"}})}constructor(){super(),this._facsimiles=[],this.baseUri="",this.crossOriginPolicy="anonymous",this.type="iiif",this.visibilityRatio=1,this.defaultZoomLevel=0,this.sequenceMode=!1,this.showHomeControl=!1,this.showNavigator=!1,this.showNavigationControl=!1,this.showFullPageControl=!1,this.showRotationControl=!1,this.showDownloadButton=!1,this.constrainDuringPan=!1,this.referenceStrip=!1,this.referenceStripSizeRatio=.2,this.prefixUrl="../images/openseadragon/",this.loaded=!1,this._facsimileObserverScheduled=!1}set facsimiles(e){this._facsimiles=e||[],this.loaded=this._facsimiles.length>0,this.emitTo("pb-facsimile-status",{status:"loading"})}connectedCallback(){super.connectedCallback(),this.subscribeTo("pb-start-update",this._clearAll.bind(this)),this.subscribeTo("pb-load-facsimile",e=>{const{element:t,order:i}=e.detail,o=this._facsimiles.map(e=>e.getOrder?e.getOrder():Number.POSITIVE_INFINITY).reduce((e,t,o)=>i<t?e:i===t?o:o+1,0);this._facsimiles.splice(o,0,t),this.loaded=this._facsimiles.length>0,this._scheduleFacsimileObserver()}),this.subscribeTo("pb-show-annotation",this._showAnnotationListener.bind(this))}firstUpdated(){try{const e=window.ESGlobalBridge.requestAvailability(),t=i("../lib/openseadragon.min.js");if(e.imports.openseadragon)return void this._initOpenSeadragon();window.addEventListener("es-bridge-openseadragon-loaded",this._initOpenSeadragon.bind(this),{once:!0}),e.load("openseadragon",t)}catch(e){console.error(e.message)}}render(){return o`
|
|
2
|
+
<slot name="before"></slot>
|
|
3
|
+
<!-- Openseadragon -->
|
|
4
|
+
|
|
5
|
+
<div id="viewer" part="image"></div>
|
|
6
|
+
<slot name="after"></slot>
|
|
7
|
+
${this.showDownloadButton?o`<a id="downloadBtn" title="Download">⇤</a>`:""}
|
|
8
|
+
`}static get styles(){return s`
|
|
9
|
+
:host {
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
position: relative;
|
|
13
|
+
background: transparent;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
#runtime-overlay {
|
|
17
|
+
border: var(--pb-facsimile-border, 4px solid rgba(0, 0, 128, 0.5));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#viewer {
|
|
21
|
+
flex: 1;
|
|
22
|
+
position: relative;
|
|
23
|
+
max-height: var(--pb-facsimile-height, auto);
|
|
24
|
+
width: 100%;
|
|
25
|
+
}
|
|
26
|
+
#downloadBtn {
|
|
27
|
+
position: absolute;
|
|
28
|
+
z-index: 100;
|
|
29
|
+
bottom: 0.25rem;
|
|
30
|
+
width: 1.35rem;
|
|
31
|
+
height: 1.35rem;
|
|
32
|
+
transform: rotate(-90deg);
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
border: thin solid #d7dde8;
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
justify-content: center;
|
|
38
|
+
border-radius: 0.75rem;
|
|
39
|
+
background-image: linear-gradient(to left, #fafafa 0%, #d7dde8 51%, #bbbbbb 100%);
|
|
40
|
+
font-size: 1.2rem;
|
|
41
|
+
box-shadow: -2px 1px 5px 0px rgba(0, 0, 0, 0.75);
|
|
42
|
+
}
|
|
43
|
+
#downloadBtn:hover {
|
|
44
|
+
background-image: radial-gradient(white, #efefef);
|
|
45
|
+
}
|
|
46
|
+
`}_initOpenSeadragon(){const e=i(this.prefixUrl+(this.prefixUrl.endsWith("/")?"":"/")),t={element:this.shadowRoot.getElementById("viewer"),prefixUrl:e,preserveViewport:!0,showZoomControl:!0,sequenceMode:this.showSequenceMode,showHomeControl:this.showHomeControl,showFullPageControl:this.showFullPageControl,showNavigator:this.showNavigator,showNavigationControl:this.showNavigationControl,showRotationControl:this.showRotationControl,autoHideControls:!1,visibilityRatio:1,minZoomLevel:1,defaultZoomLevel:this.defaultZoomLevel,constrainDuringPan:!0,crossOriginPolicy:this.crossOriginPolicy};this.referenceStrip&&(t.showReferenceStrip=!0,t.referenceStripSizeRatio=this.referenceStripSizeRatio),this.viewer=OpenSeadragon(t),this.showFullPageControl&&this._overrideFullscreenButton(),this.viewer.addHandler("open",()=>{this.resetZoom(),this.emitTo("pb-facsimile-status",{status:"loaded",facsimiles:this._facsimiles})}),this.viewer.addHandler("open-failed",e=>{console.error("<pb-facsimile> open failed: %s",e.message),this.loaded=!1,this.emitTo("pb-facsimile-status",{status:"fail"})});const o=this.shadowRoot.querySelector("#downloadBtn");this.showDownloadButton&&o.addEventListener("click",e=>{e.preventDefault();const t=this.viewer.drawer.canvas.toDataURL("image/png"),i=document.createElement("a");i.href=t,i.download="download",i.click()}),this.ownerPage=document.querySelector("pb-page"),this.ownerPage&&(this.pbPageDisplay=window.getComputedStyle(this.ownerPage).getPropertyValue("display"),this.viewer.addHandler("full-screen",e=>{e.fullScreen?this.ownerPage.style.display="none":(this.viewer.clearOverlays(),this.emitTo("pb-refresh"),this.ownerPage.style.display=this.pbPageDisplay)})),this._scheduleFacsimileObserver(),console.log("facsimile ready"),this.signalReady()}_scheduleFacsimileObserver(){this._facsimileObserverScheduled||(this._facsimileObserverScheduled=!0,setTimeout(()=>{this._facsimileObserverScheduled=!1,this._facsimileObserver()},0))}_facsimileObserver(){if(!this.viewer)return;if(0===this._facsimiles.length)return void this.viewer.close();const e=10,t=this._facsimiles.slice(0,e).map(e=>{const t=this.baseUri+(e.getImage?e.getImage():e);return"iiif"===this.type?`${t}/info.json`:{tileSource:{type:"image",url:t,buildPyramid:!1}}}),i=[],o=new Set;for(const e of t){const t=JSON.stringify(e);o.has(t)||(o.add(t),i.push(e))}this.viewer.open(i),this.viewer.goToPage(0)}_clearAll(){this.viewer&&(this.resetZoom(),this.viewer.clearOverlays(),this.facsimiles=[])}_showAnnotationListener(e){if(!this.viewer)return;const t="runtime-overlay";if(this.overlay)try{this.viewer.removeOverlay(this.overlay)}catch(e){}if(!e.detail.file||0===e.detail.file)return console.error("file missing",e.detail);if(e.detail.coordinates&&(!e.detail.coordinates[0]||4!==e.detail.coordinates.length))return console.error("coords incomplete or missing",e.detail);const i=e.detail.element?this._pageByElement(e.detail.element):this._pageIndexByUrl(e.detail.file);if(i<0)return console.error("page not found",e.detail);if(this.viewer.currentPage()!==i&&this.viewer.goToPage(i),e.detail.coordinates){const[i,o,s,r]=e.detail.coordinates,a=this.viewer.world.getItemAt(0);if(!a)return void console.error("No tiled image available yet for annotation.");const n=a.viewportToImageRectangle(a.getBounds(!0));n.containsPoint(new OpenSeadragon.Point(i,o))||this.viewer.viewport.fitBoundsWithConstraints(a.imageToViewportRectangle(i,o,n.width,n.height));const l=document.createElement("div");this.overlay=l,l.id=t;const d=a.imageToViewportRectangle(i,o,s,r);this.viewer.addOverlay({element:l,location:d})}}_pageByElement(e){return this._facsimiles.indexOf(e)}_pageIndexByUrl(e){return this._facsimiles.findIndex(t=>t.getImage()===e)}resetZoom(){this.viewer&&this.viewer.viewport.goHome()}_overrideFullscreenButton(){const e=this.viewer.buttonGroup.buttons.find(e=>"Toggle full page"===e.tooltip);if(!e)return;const t=async()=>{document.fullscreenElement?await document.exitFullscreen():await this.viewer.element.requestFullscreen()};e.onRelease=t;const i=e.raiseEvent;e.raiseEvent=(o,s)=>{"release"===o?t():i.call(e,o,s)}}}customElements.get("pb-facsimile")||customElements.define("pb-facsimile",r);export{r as PbFacsimile};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./pb-mixin-DHoWQheB.js";let t,n=0;const s=new Map;function i(e){t=e,n++,s.clear()}function r(e,n){return t?t(e,n):e}const c=(e,t)=>r(e,t);"undefined"!=typeof document&&document.addEventListener("pb-i18n-update",e=>{var i;const r=null===(i=e.detail)||void 0===i?void 0:i.t;r&&r!==t&&(t=r),n++,s.clear()});class o extends e{static get properties(){return Object.assign(Object.assign({},super.properties),{},{key:{type:String},options:{type:Object},_translated:{type:String}})}constructor(){super(),this.key="missing-key",this.options=null,this._translated=null,this._fallback="",this._onI18nUpdate=()=>this._recompute(),this._recomputeTimer=null}connectedCallback(){super.connectedCallback(),this._capturedFallback||(this._fallback=this.innerHTML,this._capturedFallback=!0),this.innerHTML="","undefined"!=typeof document&&document.addEventListener("pb-i18n-update",this._onI18nUpdate),this._scheduleRecompute()}disconnectedCallback(){"undefined"!=typeof document&&document.removeEventListener("pb-i18n-update",this._onI18nUpdate),this._recomputeTimer&&(clearTimeout(this._recomputeTimer),this._recomputeTimer=null),super.disconnectedCallback()}updated(e){(e.has("key")||e.has("options"))&&this._scheduleRecompute()}_scheduleRecompute(){this._recomputeTimer||(this._recomputeTimer=setTimeout(()=>{this._recomputeTimer=null,this._recompute()},20))}_recompute(){const e=this.options||{},t=`${n}::${this.key}::${JSON.stringify(e)}`;if(s.has(t))return void(this._translated=s.get(t));const i=r(this.key,e),c=i&&i!==this.key?i:null;s.set(t,c),this._translated=c}render(){return this._translated??this._fallback}createRenderRoot(){return this}}customElements.define("pb-i18n",o);export{r as g,i,c as t};
|
package/dist/pb-leaflet-map.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import{a as e,p as t,r as i,x as o,i as a}from"./pb-mixin-DHoWQheB.js";import"./es-global-bridge-D8ZcUcx_.js";import{g as r}from"./pb-i18n-C0NDma4h.js";const s=["type","url","label","base","show"];class n extends e{static get properties(){return{type:{type:String},url:{type:String},base:{type:Boolean},show:{type:Boolean},label:{type:String},attribution:{type:String},minZoom:{type:Number,attribute:"min-zoom"},maxZoom:{type:Number,attribute:"max-zoom"},zoomOffset:{type:Number,attribute:"zoom-offset"},opacity:{type:Number},tileSize:{type:Number},id:{type:String},accessToken:{type:String,attribute:"access-token"}}}constructor(){super(),this.type="tile",this.url=null}get options(){const e={};return Object.keys(n.properties).forEach(t=>{s.indexOf(t)<0&&this[t]&&(e[t]=this[t])}),console.log("<pb-leaflet-map-layer> Options: %o",e),e}async data(){return new Promise(e=>{fetch(this.url).then(e=>e.json()).then(t=>e(t))})}}function l(e,t){try{return e.split(/\s*,\s*/).map(e=>parseInt(e,10))}catch(t){return console.error(`<pb-map-icon> Invalid size specified: ${e}`),null}}customElements.define("pb-map-layer",n);class c extends e{static get properties(){return{name:{type:String},iconUrl:{type:String,attribute:"icon-url"},iconSize:{type:Array,converter:l,attribute:"icon-size"},iconAnchor:{type:Array,converter:l,attribute:"icon-anchor"},shadowUrl:{type:String,attribute:"shadow-url"},shadowSize:{type:Array,converter:l,attribute:"shadow-size"},shadowAnchor:{type:Array,converter:l,attribute:"shadow-anchor"},popupAncor:{type:Array,converter:l,attribute:"popup-anchor"}}}constructor(){super(),this.name="default",this.type="image",this.iconUrl=null}get options(){const e={};return Object.keys(c.properties).forEach(t=>{this[t]&&(e[t]=this[t])}),console.log("<pb-map-icon> Options: %o",e),e}}customElements.define("pb-map-icon",c);class p extends(t(e)){static get properties(){return Object.assign(Object.assign({},super.properties),{},{latitude:{type:Number},longitude:{type:Number},zoom:{type:Number},crs:{type:String},fitMarkers:{type:Boolean,attribute:"fit-markers"},cluster:{type:Boolean},disableClusteringAt:{type:Number,attribute:"disable-clustering-at"},noScroll:{type:Boolean,attribute:"no-scroll"},accessToken:{type:String,attribute:"access-token"},toggle:{type:Boolean},imagesPath:{type:String,attribute:"images-path"},cssPath:{type:String,attribute:"css-path"},geoCoding:{type:Boolean,attribute:"geo-coding"},_map:{type:Object}})}constructor(){super(),this.latitude=51.505,this.longitude=-.09,this.zoom=15,this.crs="EPSG3857",this.accessToken="",this.imagesPath="../images/leaflet/",this.cssPath="../css/leaflet",this.toggle=!1,this.noScroll=!1,this.disabled=!0,this.cluster=!1,this.fitMarkers=!1,this.disableClusteringAt=null,this._icons={},this.geoCoding=!1,this._mapReady=!1,this._markerLayer=null}connectedCallback(){super.connectedCallback(),this._layers=this.querySelectorAll("pb-map-layer"),this._markers=this.querySelectorAll("pb-map-icon"),this.subscribeTo("pb-update-map",e=>{this._markerLayer&&(this._markerLayer.clearLayers(),e.detail.forEach(e=>{const t=L.marker([e.latitude,e.longitude]);e.label&&t.bindTooltip(e.label),t.addEventListener("click",()=>{this.emitTo("pb-leaflet-marker-click",{element:e})}),t.bindTooltip(e.label),this.setMarkerIcon(t),this._markerLayer.addLayer(t)}),this._fitBounds())}),this.subscribeTo("pb-update",e=>{if(!this._markerLayer)return;this._markerLayer.clearLayers();e.detail.root.querySelectorAll("pb-geolocation").forEach(e=>{const t=L.latLng(e.latitude,e.longitude),i=L.marker(t);this._markerLayer.addLayer(i),e.label&&i.bindTooltip(e.label),e.popup&&i.bindPopup(e.popup),i.addEventListener("click",()=>{this.emitTo("pb-leaflet-marker-click",{element:e})}),this.setMarkerIcon(i)}),this._fitBounds()}),this.subscribeTo("pb-geolocation",e=>{if(e.detail.coordinates){if(this.latitude=e.detail.coordinates.latitude,this.longitude=e.detail.coordinates.longitude,e.detail.clear&&this._markerLayer&&"function"==typeof this._markerLayer.clearLayers&&this._markerLayer.clearLayers(),this._hasMarker(this.latitude,this.longitude))console.log("<pb-leaflet-map> Marker already added to map");else{const t=L.marker([this.latitude,this.longitude]);t.addEventListener("click",()=>{this.emitTo("pb-leaflet-marker-click",e.detail)}),e.detail.label&&t.bindTooltip(e.detail.label),e.detail.popup&&t.bindPopup(e.detail.popup),this.setMarkerIcon(t),this._markerLayer&&"function"==typeof this._markerLayer.addLayer&&this._markerLayer.addLayer(t),e.detail.fitBounds&&this._fitBounds(),console.log("<pb-leaflet-map> added marker")}this.toggle&&(this.disabled=!1);const t=e.detail.event;this._locationChanged(this.latitude,this.longitude,e.detail.zoom,t)}})}get map(){return this._map}setMarkerIcon(e){this._icons&&this._icons.default&&e.setIcon(this._icons.default)}firstUpdated(){if(this.toggle||(this.disabled=!1),void 0!==window.L)return void this._initMap();window.ESGlobalBridge.requestAvailability();const e=i("../lib/leaflet-src.js"),t=i("../lib/leaflet.markercluster-src.js"),o=i("../lib/Control.Geocoder.min.js"),a=()=>{this.geoCoding?fetch(o,{method:"HEAD"}).then(e=>{if(e.ok)return window.ESGlobalBridge.instance.load("geocoding",o);throw new Error(`Geocoding script not available at ${o} (${e.status})`)}).then(this._initMap.bind(this)).catch(e=>{console.warn("<pb-leaflet-map> Failed to load geocoding script, initializing map without geocoding:",e),this._initMap()}):this._initMap()};window.ESGlobalBridge.instance.load("leaflet",e).then(()=>{this.cluster?window.ESGlobalBridge.instance.load("plugin",t).then(a).catch(e=>{console.warn("<pb-leaflet-map> Failed to load marker cluster plugin, initializing without clustering:",e),a()}):a()}).catch(e=>{console.error("<pb-leaflet-map> Failed to load Leaflet library:",e)})}render(){const e=i(this.cssPath);return o`
|
|
2
|
+
<link rel="Stylesheet" href="${e}/leaflet.css" />
|
|
3
|
+
<link rel="Stylesheet" href="${e}/MarkerCluster.Default.css" />
|
|
4
|
+
${this.geoCoding?o`<link rel="Stylesheet" href="${e}/Control.Geocoder.css" />`:null}
|
|
5
|
+
<div id="map" style="height: 100%; width: 100%"></div>
|
|
6
|
+
`}static get styles(){return a`
|
|
7
|
+
:host {
|
|
8
|
+
display: block;
|
|
9
|
+
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
:host([disabled]) {
|
|
12
|
+
visibility: hidden;
|
|
13
|
+
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
.close {
|
|
16
|
+
border-radius: 4px;
|
|
17
|
+
background-color: #fff;
|
|
18
|
+
color: inherit;
|
|
19
|
+
padding: 8px;
|
|
20
|
+
font-size: 18px;
|
|
21
|
+
font-weight: bold;
|
|
22
|
+
text-decoration: none;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
}
|
|
25
|
+
`}_initMap(){if(this._map)return;L.Icon.Default.imagePath=i(this.imagesPath);const e=L.CRS[this.crs]||L.CRS.EPSG3857;if(this._map=L.map(this.shadowRoot.getElementById("map"),{zoom:this.zoom,center:L.latLng(this.latitude,this.longitude),crs:e}),this._configureLayers(),this._configureMarkers(),this.cluster&&"function"==typeof L.markerClusterGroup){const e={};this.disableClusteringAt&&(e.disableClusteringAtZoom=this.disableClusteringAt),this._markerLayer=L.markerClusterGroup(e)}else this._markerLayer=L.layerGroup();if(this._markerLayer.addTo(this._map),this._mapReady=!0,this.signalReady(),L.control.scale().addTo(this._map),this.toggle){let e;L.Control.CloseButton=L.Control.extend({options:{position:"topright"},onAdd:t=>(e=L.DomUtil.create("div"),e.className="close",e.innerHTML="X",L.DomEvent.on(e,"click",this._hide.bind(this)),e),onRemove:t=>{L.DomEvent.off(e,"click",this._hide.bind(this))}}),L.control.closeButton=e=>new L.Control.CloseButton(e),L.control.closeButton({position:"topright"}).addTo(this._map)}this._configureGeoCoding()}_configureGeoCoding(){if(!this.geoCoding)return;if(!L.Control||!L.Control.Geocoder)return void console.warn("<pb-leaflet-map> Geocoding library not properly loaded, skipping geocoding configuration");if(!L.Control.Geocoder.nominatim)return void console.warn("<pb-leaflet-map> Nominatim geocoder not available, skipping geocoding configuration");const e=L.Control.Geocoder.nominatim({geocodingQueryParams:{"accept-language":"en"}}),t=L.Control.geocoder({defaultMarkGeocode:!1,geocoder:e,placeholder:r("search.search"),suggestMinLength:3});t.on("markgeocode",e=>{const{geocode:t}=e,i={coordinates:{longitude:t.center.lng,latitude:t.center.lat},name:t.name,label:t.html,properties:t.properties};this.emitTo("pb-geocode",i)}),t.addTo(this._map),this._map.on("click",t=>{(t.originalEvent.ctrlKey||t.originalEvent.metaKey)&&(t.originalEvent.stopPropagation(),e.reverse(t.latlng,this._map.options.crs.scale(this._map.getZoom()),e=>{const i=e[0],o={coordinates:{longitude:t.latlng.lng,latitude:t.latlng.lat},name:i.name,label:i.html,properties:i.properties};this.emitTo("pb-geocode",o)}))})}_configureMarkers(){0!==this._markers.length&&(this._icons={},this._markers.forEach(e=>{e.iconUrl&&(this._icons[e.name]=L.icon(e.options))}))}_configureLayers(){if(0===this._layers.length)return void L.tileLayer("https://api.mapbox.com/styles/v1/mapbox/streets-v11/tiles/{z}/{x}/{y}?access_token={accessToken}",{attribution:'© <a href="https://www.mapbox.com/about/maps/">Mapbox</a> © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> <strong><a href="https://www.mapbox.com/map-feedback/" target="_blank" rel="noopener">Improve this map</a></strong>',maxZoom:18,zoomOffset:-1,tileSize:512,accessToken:this.accessToken}).addTo(this._map);const e=L.control.layers(null,null,{collapsed:!0});this._layers.forEach(t=>{let i;if("geojson"===t.type)t.data().then(o=>{i=L.geoJSON([o]),this._addLayer(t,i,e)});else i=L.tileLayer(t.url,t.options),this._addLayer(t,i,e)}),this._layers.length>1&&e.addTo(this._map),this._layers=null}_addLayer(e,t,i){e.show&&t.addTo(this._map),e.label&&(e.base?i.addBaseLayer(t,e.label):i.addOverlay(t,e.label))}_fitBounds(){if(!this._markerLayer)return;if(!this.fitMarkers)return;const e=L.latLngBounds();let t=0;this._markerLayer.eachLayer(i=>{e.extend(i.getLatLng()),t+=1}),0===t?this._map.fitWorld():1===t?this._map.fitBounds(e,{maxZoom:this.zoom}):this._map.fitBounds(e)}_locationChanged(e,t,i,o){if(this._markerLayer&&this._map){const a=L.latLng([e,t]);this._markerLayer.eachLayer(e=>{e.getLatLng().equals(a)?(i&&!this.noScroll?(e.openTooltip(),this._map.setView(a,i)):this.cluster?this._markerLayer.zoomToShowLayer(e,()=>e.openTooltip()):(e.openTooltip(),i?this._map.setView(a,i):this._map.panTo(a)),o&&this._icons&&this._icons.active&&e.setIcon(this._icons.active)):this._icons&&this._icons.default&&e.getIcon()!==this._icons.default&&e.setIcon(this._icons.default)})}}_hasMarker(e,t){if(!this._markerLayer)return null;const i=L.latLng([e,t]);let o=null;return this._markerLayer.eachLayer(e=>{e instanceof L.Marker&&e.getLatLng().equals(i)&&(o=e)}),o}_hide(){this.disabled=!0}}customElements.define("pb-leaflet-map",p);export{p as PbLeafletMap};
|