@teipublisher/pb-components 2.17.0 → 2.18.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.
@@ -642,6 +642,12 @@
642
642
  "type": "boolean",
643
643
  "default": "false"
644
644
  },
645
+ {
646
+ "name": "group",
647
+ "description": "A list of space- or comma-separated group names, whose members will be\nallowed to add or edit entries in the local register (if enabled).",
648
+ "type": "string",
649
+ "default": "\"\\\"tei\\\"\""
650
+ },
645
651
  {
646
652
  "name": "subscribe",
647
653
  "description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
@@ -698,6 +704,13 @@
698
704
  "type": "boolean",
699
705
  "default": "false"
700
706
  },
707
+ {
708
+ "name": "group",
709
+ "attribute": "group",
710
+ "description": "A list of space- or comma-separated group names, whose members will be\nallowed to add or edit entries in the local register (if enabled).",
711
+ "type": "string",
712
+ "default": "\"\\\"tei\\\"\""
713
+ },
701
714
  {
702
715
  "name": "subscribe",
703
716
  "attribute": "subscribe",
@@ -5504,7 +5517,7 @@
5504
5517
  },
5505
5518
  {
5506
5519
  "name": "geo-coding",
5507
- "description": "Enables geocoding: an additional control will allow users to search for a place.\nReverse geocoding is also possible: single clicking on the map will request information\nabout the current location.\n\nIn both cases, a `pb-geocode` event will be emitted containing additional information\nabout the place in the event details (see demo).\n\nFor lookups the free OSM/Nominatim service is used.",
5520
+ "description": "Enables geocoding: an additional control will allow users to search for a place.\nReverse geocoding is also possible: clicking on the map while pressing ctrl or cmd \nwill request information about the current location.\n\nIn both cases, a `pb-geocode` event will be emitted containing additional information\nabout the place in the event details (see demo).\n\nFor lookups the free OSM/Nominatim service is used.",
5508
5521
  "type": "boolean",
5509
5522
  "default": "false"
5510
5523
  },
@@ -5624,7 +5637,7 @@
5624
5637
  {
5625
5638
  "name": "geoCoding",
5626
5639
  "attribute": "geo-coding",
5627
- "description": "Enables geocoding: an additional control will allow users to search for a place.\nReverse geocoding is also possible: single clicking on the map will request information\nabout the current location.\n\nIn both cases, a `pb-geocode` event will be emitted containing additional information\nabout the place in the event details (see demo).\n\nFor lookups the free OSM/Nominatim service is used.",
5640
+ "description": "Enables geocoding: an additional control will allow users to search for a place.\nReverse geocoding is also possible: clicking on the map while pressing ctrl or cmd \nwill request information about the current location.\n\nIn both cases, a `pb-geocode` event will be emitted containing additional information\nabout the place in the event details (see demo).\n\nFor lookups the free OSM/Nominatim service is used.",
5628
5641
  "type": "boolean",
5629
5642
  "default": "false"
5630
5643
  },
@@ -9465,7 +9478,8 @@
9465
9478
  {
9466
9479
  "name": "login",
9467
9480
  "description": "Id of the pb-login element to connect to",
9468
- "type": "string"
9481
+ "type": "string",
9482
+ "deprecatedMessage": "no longer used"
9469
9483
  },
9470
9484
  {
9471
9485
  "name": "group",
@@ -9514,7 +9528,8 @@
9514
9528
  "name": "login",
9515
9529
  "attribute": "login",
9516
9530
  "description": "Id of the pb-login element to connect to",
9517
- "type": "string"
9531
+ "type": "string",
9532
+ "deprecatedMessage": "no longer used"
9518
9533
  },
9519
9534
  {
9520
9535
  "name": "group",
@@ -1,7 +1,7 @@
1
- import{L as e,p as t,r as i,h as o,c as s}from"./pb-mixin-d61c06b6.js";import{g as a}from"./pb-i18n-375ccc5c.js";import"./es-global-bridge-4240f389.js";const r=["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=>{r.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 d 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}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.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",e)}),t.bindTooltip(e.label),this.setMarkerIcon(t),this._markerLayer.addLayer(t)}),this._fitBounds()}),this.subscribeTo("pb-update",e=>{this._markerLayer.clearLayers();e.detail.root.querySelectorAll("pb-geolocation").forEach(e=>{const t=L.latLng(e.latitude,e.longitude),i=L.marker(t).addTo(this._markerLayer);e.label&&i.bindTooltip(e.label),e.popup&&i.bindPopup(e.popup),i.addEventListener("click",()=>{this.emitTo("pb-leaflet-marker-click",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.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.element)}),e.detail.label&&t.bindTooltip(e.detail.label),e.detail.popup&&t.bindPopup(e.detail.popup),this.setMarkerIcon(t),t.addTo(this._markerLayer),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)}async 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");await window.ESGlobalBridge.instance.load("leaflet",e),await window.ESGlobalBridge.instance.load("plugin",t),this.geoCoding&&await window.ESGlobalBridge.instance.load("geocoding",o),window.addEventListener(`es-bridge-${this.geocoding?"geoCoding":"plugin"}-loaded`,this._initMap.bind(this),{once:!0})}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}
1
+ import{L as t,p as e,r as i,h as o,c as s}from"./pb-mixin-d61c06b6.js";import{g as a}from"./pb-i18n-375ccc5c.js";import"./es-global-bridge-4240f389.js";const r=["type","url","label","base","show"];class n extends t{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 t={};return Object.keys(n.properties).forEach(e=>{r.indexOf(e)<0&&this[e]&&(t[e]=this[e])}),console.log("<pb-leaflet-map-layer> Options: %o",t),t}async data(){return new Promise(t=>{fetch(this.url).then(t=>t.json()).then(e=>t(e))})}}function l(t,e){try{return t.split(/\s*,\s*/).map(t=>parseInt(t,10))}catch(e){return console.error("<pb-map-icon> Invalid size specified: "+t),null}}customElements.define("pb-map-layer",n);class c extends t{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 t={};return Object.keys(c.properties).forEach(e=>{this[e]&&(t[e]=this[e])}),console.log("<pb-map-icon> Options: %o",t),t}}customElements.define("pb-map-icon",c);class h extends(e(t)){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}connectedCallback(){super.connectedCallback(),this._layers=this.querySelectorAll("pb-map-layer"),this._markers=this.querySelectorAll("pb-map-icon"),this.subscribeTo("pb-update-map",t=>{this._markerLayer.clearLayers(),t.detail.forEach(t=>{const e=L.marker([t.latitude,t.longitude]);t.label&&e.bindTooltip(t.label),e.addEventListener("click",()=>{this.emitTo("pb-leaflet-marker-click",t)}),e.bindTooltip(t.label),this.setMarkerIcon(e),this._markerLayer.addLayer(e)}),this._fitBounds()}),this.subscribeTo("pb-update",t=>{this._markerLayer.clearLayers();t.detail.root.querySelectorAll("pb-geolocation").forEach(t=>{const e=L.latLng(t.latitude,t.longitude),i=L.marker(e).addTo(this._markerLayer);t.label&&i.bindTooltip(t.label),t.popup&&i.bindPopup(t.popup),i.addEventListener("click",()=>{this.emitTo("pb-leaflet-marker-click",t)}),this.setMarkerIcon(i)}),this._fitBounds()}),this.subscribeTo("pb-geolocation",t=>{if(t.detail.coordinates){if(this.latitude=t.detail.coordinates.latitude,this.longitude=t.detail.coordinates.longitude,t.detail.clear&&this._markerLayer.clearLayers(),this._hasMarker(this.latitude,this.longitude))console.log("<pb-leaflet-map> Marker already added to map");else{const e=L.marker([this.latitude,this.longitude]);e.addEventListener("click",()=>{this.emitTo("pb-leaflet-marker-click",t.detail.element)}),t.detail.label&&e.bindTooltip(t.detail.label),t.detail.popup&&e.bindPopup(t.detail.popup),this.setMarkerIcon(e),e.addTo(this._markerLayer),t.detail.fitBounds&&this._fitBounds(),console.log("<pb-leaflet-map> added marker")}this.toggle&&(this.disabled=!1);const e=t.detail.event;this._locationChanged(this.latitude,this.longitude,t.detail.zoom,e)}})}get map(){return this._map}setMarkerIcon(t){this._icons&&this._icons.default&&t.setIcon(this._icons.default)}firstUpdated(){if(this.toggle||(this.disabled=!1),void 0!==window.L)return void this._initMap();window.ESGlobalBridge.requestAvailability();const t=i("../lib/leaflet-src.js"),e=i("../lib/leaflet.markercluster-src.js"),o=i("../lib/Control.Geocoder.min.js");window.ESGlobalBridge.instance.load("leaflet",t).then(()=>{window.ESGlobalBridge.instance.load("plugin",e).then(()=>{this.geoCoding?window.ESGlobalBridge.instance.load("geocoding",o).then(this._initMap.bind(this)):this._initMap()})})}render(){const t=i(this.cssPath);return o`
2
+ <link rel="Stylesheet" href="${t}/leaflet.css">
3
+ <link rel="Stylesheet" href="${t}/MarkerCluster.Default.css">
4
+ ${this.geoCoding?o`<link rel="Stylesheet" href="${t}/Control.Geocoder.css">`:null}
5
5
  <div id="map" style="height: 100%; width: 100%"></div>
6
6
  `}static get styles(){return s`
7
7
  :host {
@@ -22,4 +22,4 @@ import{L as e,p as t,r as i,h as o,c as s}from"./pb-mixin-d61c06b6.js";import{g
22
22
  text-decoration: none;
23
23
  cursor: pointer;
24
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){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.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;const e=L.Control.Geocoder.nominatim({geocodingQueryParams:{"accept-language":"en"}}),t=L.Control.geocoder({defaultMarkGeocode:!1,geocoder:e,placeholder:a("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=>{e.reverse(t.latlng,this._map.options.crs.scale(this._map.getZoom()),e=>{const t=e[0],i={coordinates:{longitude:t.center.lng,latitude:t.center.lat},name:t.name,label:t.html,properties:t.properties};this.emitTo("pb-geocode",i)})})}_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="http://www.openstreetmap.org/copyright">OpenStreetMap</a> <strong><a href="https://www.mapbox.com/map-feedback/" target="_blank">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:!1});this._layers.forEach(t=>{let i;switch(t.type){case"geojson":t.data().then(o=>{i=L.geoJSON([o]),this._addLayer(t,i,e)});break;default: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.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._map){const s=L.latLng([e,t]);this._markerLayer.eachLayer(e=>{e.getLatLng().equals(s)?(i&&!this.noScroll?(e.openTooltip(),this._map.setView(s,i)):this.cluster?this._markerLayer.zoomToShowLayer(e,()=>e.openTooltip()):(e.openTooltip(),this._map.setView(s,this.zoom)),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){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",d);export{d as PbLeafletMap};
25
+ `}_initMap(){if(this._map)return;L.Icon.Default.imagePath=i(this.imagesPath);const t=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:t}),this._configureLayers(),this._configureMarkers(),this.cluster){const t={};this.disableClusteringAt&&(t.disableClusteringAtZoom=this.disableClusteringAt),this._markerLayer=L.markerClusterGroup(t)}else this._markerLayer=L.layerGroup();if(this._markerLayer.addTo(this._map),this.signalReady(),L.control.scale().addTo(this._map),this.toggle){let t;L.Control.CloseButton=L.Control.extend({options:{position:"topright"},onAdd:e=>(t=L.DomUtil.create("div"),t.className="close",t.innerHTML="X",L.DomEvent.on(t,"click",this._hide.bind(this)),t),onRemove:e=>{L.DomEvent.off(t,"click",this._hide.bind(this))}}),L.control.closeButton=t=>new L.Control.CloseButton(t),L.control.closeButton({position:"topright"}).addTo(this._map)}this._configureGeoCoding()}_configureGeoCoding(){if(!this.geoCoding)return;const t=L.Control.Geocoder.nominatim({geocodingQueryParams:{"accept-language":"en"}}),e=L.Control.geocoder({defaultMarkGeocode:!1,geocoder:t,placeholder:a("search.search"),suggestMinLength:3});e.on("markgeocode",t=>{const{geocode:e}=t,i={coordinates:{longitude:e.center.lng,latitude:e.center.lat},name:e.name,label:e.html,properties:e.properties};this.emitTo("pb-geocode",i)}),e.addTo(this._map),this._map.on("click",e=>{(e.originalEvent.ctrlKey||e.originalEvent.metaKey)&&(e.originalEvent.stopPropagation(),t.reverse(e.latlng,this._map.options.crs.scale(this._map.getZoom()),t=>{const i=t[0],o={coordinates:{longitude:e.latlng.lng,latitude:e.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(t=>{t.iconUrl&&(this._icons[t.name]=L.icon(t.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="http://www.openstreetmap.org/copyright">OpenStreetMap</a> <strong><a href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a></strong>',maxZoom:18,zoomOffset:-1,tileSize:512,accessToken:this.accessToken}).addTo(this._map);const t=L.control.layers(null,null,{collapsed:!1});this._layers.forEach(e=>{let i;switch(e.type){case"geojson":e.data().then(o=>{i=L.geoJSON([o]),this._addLayer(e,i,t)});break;default:i=L.tileLayer(e.url,e.options),this._addLayer(e,i,t)}}),this._layers.length>1&&t.addTo(this._map),this._layers=null}_addLayer(t,e,i){t.show&&e.addTo(this._map),t.label&&(t.base?i.addBaseLayer(e,t.label):i.addOverlay(e,t.label))}_fitBounds(){if(!this.fitMarkers)return;const t=L.latLngBounds();let e=0;this._markerLayer.eachLayer(i=>{t.extend(i.getLatLng()),e+=1}),0===e?this._map.fitWorld():1===e?this._map.fitBounds(t,{maxZoom:this.zoom}):this._map.fitBounds(t)}_locationChanged(t,e,i,o){if(this._map){const s=L.latLng([t,e]);this._markerLayer.eachLayer(t=>{t.getLatLng().equals(s)?(i&&!this.noScroll?(t.openTooltip(),this._map.setView(s,i)):this.cluster?this._markerLayer.zoomToShowLayer(t,()=>t.openTooltip()):(t.openTooltip(),i?this._map.setView(s,i):this._map.panTo(s)),o&&this._icons&&this._icons.active&&t.setIcon(this._icons.active)):this._icons&&this._icons.default&&t.getIcon()!==this._icons.default&&t.setIcon(this._icons.default)})}}_hasMarker(t,e){const i=L.latLng([t,e]);let o=null;return this._markerLayer.eachLayer(t=>{t instanceof L.Marker&&t.getLatLng().equals(i)&&(o=t)}),o}_hide(){this.disabled=!0}}customElements.define("pb-leaflet-map",h);export{h as PbLeafletMap};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teipublisher/pb-components",
3
- "version": "2.17.0",
3
+ "version": "2.18.1",
4
4
  "description": "Collection of webcomponents underlying TEI Publisher",
5
5
  "repository": "https://github.com/eeditiones/tei-publisher-components.git",
6
6
  "main": "index.html",
package/pb-elements.json CHANGED
@@ -642,6 +642,12 @@
642
642
  "type": "boolean",
643
643
  "default": "false"
644
644
  },
645
+ {
646
+ "name": "group",
647
+ "description": "A list of space- or comma-separated group names, whose members will be\nallowed to add or edit entries in the local register (if enabled).",
648
+ "type": "string",
649
+ "default": "\"\\\"tei\\\"\""
650
+ },
645
651
  {
646
652
  "name": "subscribe",
647
653
  "description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
@@ -698,6 +704,13 @@
698
704
  "type": "boolean",
699
705
  "default": "false"
700
706
  },
707
+ {
708
+ "name": "group",
709
+ "attribute": "group",
710
+ "description": "A list of space- or comma-separated group names, whose members will be\nallowed to add or edit entries in the local register (if enabled).",
711
+ "type": "string",
712
+ "default": "\"\\\"tei\\\"\""
713
+ },
701
714
  {
702
715
  "name": "subscribe",
703
716
  "attribute": "subscribe",
@@ -5504,7 +5517,7 @@
5504
5517
  },
5505
5518
  {
5506
5519
  "name": "geo-coding",
5507
- "description": "Enables geocoding: an additional control will allow users to search for a place.\nReverse geocoding is also possible: single clicking on the map will request information\nabout the current location.\n\nIn both cases, a `pb-geocode` event will be emitted containing additional information\nabout the place in the event details (see demo).\n\nFor lookups the free OSM/Nominatim service is used.",
5520
+ "description": "Enables geocoding: an additional control will allow users to search for a place.\nReverse geocoding is also possible: clicking on the map while pressing ctrl or cmd \nwill request information about the current location.\n\nIn both cases, a `pb-geocode` event will be emitted containing additional information\nabout the place in the event details (see demo).\n\nFor lookups the free OSM/Nominatim service is used.",
5508
5521
  "type": "boolean",
5509
5522
  "default": "false"
5510
5523
  },
@@ -5624,7 +5637,7 @@
5624
5637
  {
5625
5638
  "name": "geoCoding",
5626
5639
  "attribute": "geo-coding",
5627
- "description": "Enables geocoding: an additional control will allow users to search for a place.\nReverse geocoding is also possible: single clicking on the map will request information\nabout the current location.\n\nIn both cases, a `pb-geocode` event will be emitted containing additional information\nabout the place in the event details (see demo).\n\nFor lookups the free OSM/Nominatim service is used.",
5640
+ "description": "Enables geocoding: an additional control will allow users to search for a place.\nReverse geocoding is also possible: clicking on the map while pressing ctrl or cmd \nwill request information about the current location.\n\nIn both cases, a `pb-geocode` event will be emitted containing additional information\nabout the place in the event details (see demo).\n\nFor lookups the free OSM/Nominatim service is used.",
5628
5641
  "type": "boolean",
5629
5642
  "default": "false"
5630
5643
  },
@@ -9465,7 +9478,8 @@
9465
9478
  {
9466
9479
  "name": "login",
9467
9480
  "description": "Id of the pb-login element to connect to",
9468
- "type": "string"
9481
+ "type": "string",
9482
+ "deprecatedMessage": "no longer used"
9469
9483
  },
9470
9484
  {
9471
9485
  "name": "group",
@@ -9514,7 +9528,8 @@
9514
9528
  "name": "login",
9515
9529
  "attribute": "login",
9516
9530
  "description": "Id of the pb-login element to connect to",
9517
- "type": "string"
9531
+ "type": "string",
9532
+ "deprecatedMessage": "no longer used"
9518
9533
  },
9519
9534
  {
9520
9535
  "name": "group",
@@ -3,6 +3,7 @@ import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
3
3
  import { pbMixin, waitOnce } from './pb-mixin.js';
4
4
  import { translate } from "./pb-i18n.js";
5
5
  import { createConnectors } from "./authority/connectors.js";
6
+ import "./pb-restricted.js";
6
7
  import '@polymer/paper-input/paper-input';
7
8
  import '@polymer/paper-icon-button';
8
9
 
@@ -41,6 +42,15 @@ export class PbAuthorityLookup extends pbMixin(LitElement) {
41
42
  stopwords: {
42
43
  type: String
43
44
  },
45
+ /**
46
+ * A list of space- or comma-separated group names, whose members will be
47
+ * allowed to add or edit entries in the local register (if enabled).
48
+ *
49
+ * @default "tei"
50
+ */
51
+ group: {
52
+ type: String
53
+ },
44
54
  _results: {
45
55
  type: Array,
46
56
  },
@@ -55,6 +65,7 @@ export class PbAuthorityLookup extends pbMixin(LitElement) {
55
65
  this.sortByLabel = false;
56
66
  this._results = [];
57
67
  this._authorities = {};
68
+ this.group = 'tei';
58
69
  }
59
70
 
60
71
  connectedCallback() {
@@ -92,8 +103,11 @@ export class PbAuthorityLookup extends pbMixin(LitElement) {
92
103
  <iron-icon icon="icons:search" slot="prefix"></iron-icon>
93
104
  ${
94
105
  this._authorities[this.type] && this._authorities[this.type].editable ?
95
- html`<paper-icon-button icon="icons:add" @click="${this._addEntity}" title="${translate('annotations.add-entity')}" slot="suffix"></paper-icon-button>` :
96
- null
106
+ html`
107
+ <pb-restricted group="${this.group}" slot="suffix">
108
+ <paper-icon-button icon="icons:add" @click="${this._addEntity}" title="${translate('annotations.add-entity')}"></paper-icon-button>
109
+ </pb-restricted>
110
+ ` : null
97
111
  }
98
112
  </paper-input>
99
113
  <slot name="authform"></slot>
@@ -144,13 +158,16 @@ export class PbAuthorityLookup extends pbMixin(LitElement) {
144
158
 
145
159
  ${
146
160
  this._authorities[this.type] && this._authorities[this.type].editable ?
147
- html`<div class="icons">
148
- <paper-icon-button
149
- icon="editor:mode-edit"
150
- @click="${() => this._editEntity(item)}"
151
- title="${translate('annotations.edit-entity')}"
152
- ></paper-icon-button>
153
- </div>` : null
161
+ html`
162
+ <pb-restricted group="${this.group}">
163
+ <div class="icons">
164
+ <paper-icon-button
165
+ icon="editor:mode-edit"
166
+ @click="${() => this._editEntity(item)}"
167
+ title="${translate('annotations.edit-entity')}"
168
+ ></paper-icon-button>
169
+ </div>
170
+ </pb-restricted>` : null
154
171
  }
155
172
  ${item.details ? html`<div class="details" part="details">${item.details}</div>` : null}
156
173
 
@@ -260,6 +277,11 @@ export class PbAuthorityLookup extends pbMixin(LitElement) {
260
277
  flex-direction: column;
261
278
  }
262
279
 
280
+ header {
281
+ display: flex;
282
+ align-items: center;
283
+ }
284
+
263
285
  .link {
264
286
  flex-grow: 2;
265
287
  }
@@ -100,8 +100,8 @@ export class PbLeafletMap extends pbMixin(LitElement) {
100
100
  },
101
101
  /**
102
102
  * Enables geocoding: an additional control will allow users to search for a place.
103
- * Reverse geocoding is also possible: single clicking on the map will request information
104
- * about the current location.
103
+ * Reverse geocoding is also possible: clicking on the map while pressing ctrl or cmd
104
+ * will request information about the current location.
105
105
  *
106
106
  * In both cases, a `pb-geocode` event will be emitted containing additional information
107
107
  * about the place in the event details (see demo).
@@ -260,7 +260,7 @@ export class PbLeafletMap extends pbMixin(LitElement) {
260
260
  }
261
261
  }
262
262
 
263
- async firstUpdated() {
263
+ firstUpdated() {
264
264
  if (!this.toggle) {
265
265
  this.disabled = false;
266
266
  }
@@ -274,17 +274,18 @@ export class PbLeafletMap extends pbMixin(LitElement) {
274
274
  const leafletPath = resolveURL('../lib/leaflet-src.js');
275
275
  const pluginPath = resolveURL('../lib/leaflet.markercluster-src.js');
276
276
  const geoCodingPath = resolveURL('../lib/Control.Geocoder.min.js');
277
- await window.ESGlobalBridge.instance.load("leaflet", leafletPath);
278
- await window.ESGlobalBridge.instance.load("plugin", pluginPath);
279
- if (this.geoCoding) {
280
- await window.ESGlobalBridge.instance.load("geocoding", geoCodingPath);
281
- }
282
-
283
- window.addEventListener(
284
- `es-bridge-${this.geocoding ? 'geoCoding' : 'plugin'}-loaded`,
285
- this._initMap.bind(this),
286
- { once: true }
287
- );
277
+ window.ESGlobalBridge.instance.load("leaflet", leafletPath)
278
+ .then(() => {
279
+ window.ESGlobalBridge.instance.load("plugin", pluginPath)
280
+ .then(() => {
281
+ if (this.geoCoding) {
282
+ window.ESGlobalBridge.instance.load("geocoding", geoCodingPath)
283
+ .then(this._initMap.bind(this));
284
+ } else {
285
+ this._initMap();
286
+ }
287
+ });
288
+ });
288
289
  }
289
290
 
290
291
  render() {
@@ -325,7 +326,7 @@ export class PbLeafletMap extends pbMixin(LitElement) {
325
326
  return;
326
327
  }
327
328
 
328
- L.Icon.Default.imagePath = resolveURL(this.imagesPath);
329
+ L.Icon.Default.imagePath = resolveURL(this.imagesPath);
329
330
 
330
331
  const crs = L.CRS[this.crs] || L.CRS.EPSG3857;
331
332
  this._map = L.map(this.shadowRoot.getElementById('map'), {
@@ -406,19 +407,22 @@ export class PbLeafletMap extends pbMixin(LitElement) {
406
407
  control.addTo(this._map);
407
408
 
408
409
  this._map.on('click', (e) => {
409
- geocoder.reverse(e.latlng, this._map.options.crs.scale(this._map.getZoom()), (results) => {
410
- const geocode = results[0];
411
- const options = {
412
- coordinates: {
413
- longitude: geocode.center.lng,
414
- latitude: geocode.center.lat,
415
- },
416
- name: geocode.name,
417
- label: geocode.html,
418
- properties: geocode.properties
419
- };
420
- this.emitTo('pb-geocode', options);
421
- });
410
+ if (e.originalEvent.ctrlKey || e.originalEvent.metaKey) {
411
+ e.originalEvent.stopPropagation();
412
+ geocoder.reverse(e.latlng, this._map.options.crs.scale(this._map.getZoom()), (results) => {
413
+ const geocode = results[0];
414
+ const options = {
415
+ coordinates: {
416
+ longitude: e.latlng.lng,
417
+ latitude: e.latlng.lat,
418
+ },
419
+ name: geocode.name,
420
+ label: geocode.html,
421
+ properties: geocode.properties
422
+ };
423
+ this.emitTo('pb-geocode', options);
424
+ });
425
+ }
422
426
  });
423
427
  }
424
428
 
@@ -516,7 +520,11 @@ export class PbLeafletMap extends pbMixin(LitElement) {
516
520
  );
517
521
  } else {
518
522
  layer.openTooltip();
519
- this._map.setView(coords, this.zoom);
523
+ if (zoom) {
524
+ this._map.setView(coords, zoom);
525
+ } else {
526
+ this._map.panTo(coords);
527
+ }
520
528
  }
521
529
  if (setActive && this._icons && this._icons.active) {
522
530
  layer.setIcon(this._icons.active);
package/src/pb-login.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { LitElement, html, css } from 'lit-element';
2
2
  import { pbMixin, waitOnce } from './pb-mixin.js';
3
3
  import { translate } from "./pb-i18n.js";
4
+ import { registry } from "./urls.js";
4
5
  import '@polymer/iron-ajax';
5
6
  import '@polymer/paper-dialog';
6
7
  import '@polymer/paper-dialog-scrollable';
@@ -250,6 +251,15 @@ export class PbLogin extends pbMixin(LitElement) {
250
251
  }
251
252
  }
252
253
  this.emitTo('pb-login', resp);
254
+
255
+ if (this.loggedIn) {
256
+ registry.currentUser = {
257
+ user: this.user,
258
+ groups: this.groups
259
+ }
260
+ } else {
261
+ registry.currentUser = null;
262
+ }
253
263
  }
254
264
 
255
265
  _handleError() {
@@ -266,6 +276,7 @@ export class PbLogin extends pbMixin(LitElement) {
266
276
  this._loginDialog.open();
267
277
  }
268
278
 
279
+ registry.currentUser = null;
269
280
  this.emitTo('pb-login', resp);
270
281
  }
271
282
 
@@ -1,6 +1,41 @@
1
1
  import { LitElement, html, css } from 'lit-element';
2
2
  import { pbMixin } from './pb-mixin.js';
3
+ import { registry } from './urls.js';
3
4
 
5
+ /**
6
+ *
7
+ * @param {Array<String>} arr array containg string values (name of groups)
8
+ * @param {String} val value to check if it's in the array
9
+ * @returns true if the checked values is in the array
10
+ */
11
+ function _isItemInArray(arr, val) {
12
+ return arr.some((arrVal) => val === arrVal);
13
+ }
14
+
15
+ /**
16
+ *
17
+ * @param {object} user user name returned by login function;
18
+ * @param {object} groups contains groups (an array) the logged user is a member of
19
+ * @param {string} targetGroups string containing (optionally) space separated list of target groups
20
+ * @returns true if user is member of one of the target groups
21
+ */
22
+ export function isLoggedIn(user, groups, targetGroups) {
23
+ if (user == null) {
24
+ return false;
25
+ }
26
+ if (targetGroups) {
27
+ if (!groups) {
28
+ return false;
29
+ }
30
+ const groupArray = targetGroups.split(/[\s+,]+/);
31
+ let exists = false;
32
+ groupArray.forEach(async (oneItem) => {
33
+ exists = _isItemInArray(groups, oneItem) || exists;
34
+ });
35
+ return exists;
36
+ }
37
+ return true;
38
+ }
4
39
 
5
40
  /**
6
41
  * Show content if the user is logged in. Optionally requires the user
@@ -18,7 +53,9 @@ export class PbRestricted extends pbMixin(LitElement) {
18
53
  static get properties() {
19
54
  return {
20
55
  ...super.properties,
21
- /** Id of the pb-login element to connect to */
56
+ /** Id of the pb-login element to connect to
57
+ * @deprecated no longer used
58
+ */
22
59
  login: {
23
60
  type: String
24
61
  },
@@ -50,15 +87,10 @@ export class PbRestricted extends pbMixin(LitElement) {
50
87
  this.classList.add('fallback');
51
88
  }
52
89
 
53
- const login = document.getElementById(this.login);
54
- if (!login) {
55
- console.error('<pb-restricted> connected pb-login element not found!');
56
- return;
57
- }
58
90
  this.subscribeTo('pb-login', (ev) => {
59
91
  this.show = this._loggedIn(ev.detail.user, ev.detail.groups);
60
92
  }, []);
61
- this.show = login.loggedIn && this._loggedIn(login.user, login.groups);
93
+ this.show = registry.currentUser && this._loggedIn(registry.currentUser.user, registry.currentUser.groups);
62
94
  }
63
95
 
64
96
  render() {
@@ -74,43 +106,13 @@ export class PbRestricted extends pbMixin(LitElement) {
74
106
  }
75
107
 
76
108
  :host(.fallback), :host([show]) {
77
- display: block;
109
+ display: inherit;
78
110
  }
79
111
  `;
80
112
  }
81
113
 
82
- /**
83
- *
84
- * @param {Array<String>} arr array containg string values (name of groups)
85
- * @param {String} val value to check if it's in the array
86
- * @returns true if the checked values is in the array
87
- */
88
- _isItemInArray(arr, val) {
89
- return arr.some((arrVal) => val === arrVal);
90
- }
91
-
92
- /**
93
- *
94
- * @param {object} user user name returned by login function;
95
- * @param {object} groups contains groups (an array) the logged user is a member of
96
- * @returns true if user is member of one of defined groups
97
- */
98
114
  _loggedIn(user, groups) {
99
- if (user == null) {
100
- return false;
101
- }
102
- if (this.group) {
103
- if (!groups) {
104
- return false;
105
- }
106
- let groupArray = this.group.split(/[\s+,]+/);
107
- let exists = false;
108
- groupArray.forEach(async (oneItem) => {
109
- exists = this._isItemInArray(groups, oneItem) || exists;
110
- });
111
- return exists;
112
- }
113
- return true;
115
+ return isLoggedIn(user, groups, this.group);
114
116
  }
115
117
  }
116
118
  customElements.define('pb-restricted', PbRestricted);
@@ -556,11 +556,14 @@ class PbViewAnnotate extends PbView {
556
556
  console.log('<pb-view-annotate> selection: %o', range);
557
557
 
558
558
  if (changed) {
559
- this._inHandler = true;
560
559
  setTimeout(() => {
561
- selection.removeAllRanges();
562
- selection.addRange(range);
563
- this.inHandler = false;
560
+ this._inHandler = true;
561
+ try {
562
+ selection.removeAllRanges();
563
+ selection.addRange(range);
564
+ } finally {
565
+ this.inHandler = false;
566
+ }
564
567
  }, 100);
565
568
  }
566
569
  this.emitTo('pb-selection-changed', { hasContent: true, range, selected: selection.toString()});
package/src/urls.js CHANGED
@@ -69,6 +69,12 @@ class Registry {
69
69
 
70
70
  this.urlIgnore = new Set();
71
71
  this.pathParams = new Set();
72
+
73
+ /**
74
+ * Information about the user currently logged in or null. If a user is logged in
75
+ * this will be an object with two properties: `user` and `groups`.
76
+ */
77
+ this.currentUser = null;
72
78
  }
73
79
 
74
80
  configure(usePath = true, idHash = false, rootPath = '', urlPattern, ignoredParams) {