@eox/layercontrol 0.16.0 → 0.17.0

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.
@@ -3655,7 +3655,7 @@ const na = (e) => {
3655
3655
  var r;
3656
3656
  o.layer !== n && ((r = o.layer) != null && r.get("layerControlExclusive")) && (o.layer.setVisible(!1), o.requestUpdate());
3657
3657
  }), t.dispatchEvent(
3658
- new CustomEvent("changed", { bubbles: !0 })
3658
+ new CustomEvent("changed", { bubbles: !0, detail: n })
3659
3659
  ), t.requestUpdate();
3660
3660
  };
3661
3661
  var Ft, Ie, Je, bo, Ke, Qe;
@@ -4638,7 +4638,7 @@ class To extends et {
4638
4638
  }
4639
4639
  }
4640
4640
  zt = new WeakMap(), hn = new WeakSet(), Po = function(n) {
4641
- ha(n, this);
4641
+ ha(n, this), this.dispatchEvent(new CustomEvent("layerchange", { detail: n.detail }));
4642
4642
  }, pn = new WeakMap(), // Define static properties for the component
4643
4643
  H(To, "properties", {
4644
4644
  for: { type: String },
@@ -555,7 +555,7 @@ input::-moz-focus-inner, input::-moz-focus-outer {
555
555
  </details>
556
556
  `})}
557
557
  `)}
558
- `}}Je=new WeakMap,Ke=new WeakMap,L(fo,"properties",{layer:{attribute:!1},tools:{attribute:!1},unstyled:{type:Boolean},noShadow:{type:Boolean}}),customElements.define("eox-layercontrol-layer-tools",fo);const Qs=e=>{const t=()=>{const n=Es(e.layer,e.map,e.showLayerZoomState);let i=!1;!n&&e.currLayerVisibilityBasedOnZoom?(e.currLayerVisibilityBasedOnZoom=!1,i=!0):n&&!e.currLayerVisibilityBasedOnZoom&&(e.currLayerVisibilityBasedOnZoom=!0,i=!0),i&&(e.requestUpdate(),e.dispatchEvent(new CustomEvent("change:resolution",{bubbles:!0})))};io(e.layer,e.showLayerZoomState)&&(t(),e.map.getView().on("change:resolution",()=>t()))},ta=(e,t)=>{const n=t.layer;n.setVisible(e.target.checked),e.target.checked&&n.get("layerControlExclusive")&&t.parentNode.parentNode.querySelectorAll("li > eox-layercontrol-layer").forEach(o=>{var r;o.layer!==n&&((r=o.layer)!=null&&r.get("layerControlExclusive"))&&(o.layer.setVisible(!1),o.requestUpdate())}),t.dispatchEvent(new CustomEvent("changed",{bubbles:!0})),t.requestUpdate()};class go extends tt{constructor(){super();_(this,Yt);_(this,Qe);L(this,"currLayerVisibilityBasedOnZoom",!0);_(this,tn,"");_(this,en,`
558
+ `}}Je=new WeakMap,Ke=new WeakMap,L(fo,"properties",{layer:{attribute:!1},tools:{attribute:!1},unstyled:{type:Boolean},noShadow:{type:Boolean}}),customElements.define("eox-layercontrol-layer-tools",fo);const Qs=e=>{const t=()=>{const n=Es(e.layer,e.map,e.showLayerZoomState);let i=!1;!n&&e.currLayerVisibilityBasedOnZoom?(e.currLayerVisibilityBasedOnZoom=!1,i=!0):n&&!e.currLayerVisibilityBasedOnZoom&&(e.currLayerVisibilityBasedOnZoom=!0,i=!0),i&&(e.requestUpdate(),e.dispatchEvent(new CustomEvent("change:resolution",{bubbles:!0})))};io(e.layer,e.showLayerZoomState)&&(t(),e.map.getView().on("change:resolution",()=>t()))},ta=(e,t)=>{const n=t.layer;n.setVisible(e.target.checked),e.target.checked&&n.get("layerControlExclusive")&&t.parentNode.parentNode.querySelectorAll("li > eox-layercontrol-layer").forEach(o=>{var r;o.layer!==n&&((r=o.layer)!=null&&r.get("layerControlExclusive"))&&(o.layer.setVisible(!1),o.requestUpdate())}),t.dispatchEvent(new CustomEvent("changed",{bubbles:!0,detail:n})),t.requestUpdate()};class go extends tt{constructor(){super();_(this,Yt);_(this,Qe);L(this,"currLayerVisibilityBasedOnZoom",!0);_(this,tn,"");_(this,en,`
559
559
  ${po}
560
560
  eox-layercontrol-layer {
561
561
  width: 100%;
@@ -1044,4 +1044,4 @@ input::-moz-focus-inner, input::-moz-focus-outer {
1044
1044
  @changed=${()=>this.requestUpdate()}
1045
1045
  ></eox-layercontrol-optional-list>
1046
1046
  `)}
1047
- `}}Wt=new WeakMap,fn=new WeakSet,Oo=function(n){ua(n,this)},gn=new WeakMap,L(Qn,"properties",{for:{type:String},idProperty:{attribute:"id-property"},map:{attribute:!1,state:!0},titleProperty:{attribute:"title-property",type:String},showLayerZoomState:{attribute:"show-layer-zoom-state",type:Boolean},tools:{attribute:!1},addExternalLayers:{attribute:!1},unstyled:{type:Boolean},styleOverride:{type:String}}),customElements.define("eox-layercontrol",Qn),O.EOxLayerControl=Qn,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})});
1047
+ `}}Wt=new WeakMap,fn=new WeakSet,Oo=function(n){ua(n,this),this.dispatchEvent(new CustomEvent("layerchange",{detail:n.detail}))},gn=new WeakMap,L(Qn,"properties",{for:{type:String},idProperty:{attribute:"id-property"},map:{attribute:!1,state:!0},titleProperty:{attribute:"title-property",type:String},showLayerZoomState:{attribute:"show-layer-zoom-state",type:Boolean},tools:{attribute:!1},addExternalLayers:{attribute:!1},unstyled:{type:Boolean},styleOverride:{type:String}}),customElements.define("eox-layercontrol",Qn),O.EOxLayerControl=Qn,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "@eox/layercontrol",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "type": "module",
5
5
  "devDependencies": {
6
6
  "@eox/eslint-config": "^1.0.0",
7
+ "@eox/jsonform": "latest",
8
+ "@eox/map": "latest",
7
9
  "@types/sortablejs": "^1.15.1",
8
10
  "@typescript-eslint/eslint-plugin": "^7.0.1",
9
11
  "@typescript-eslint/parser": "^7.0.1",
@@ -0,0 +1,29 @@
1
+ const checkLayerChangedEvent = () => {
2
+ let mockLayer;
3
+
4
+ // Set up the mock map with an initial layer
5
+ cy.get("mock-map").and(($el) => {
6
+ const mockMap = $el[0];
7
+ mockMap.setLayers([{ properties: { title: "foo" } }]);
8
+ mockLayer = mockMap.map.getLayers().getArray()[0];
9
+ });
10
+
11
+ // Set up event listener
12
+ cy.get("eox-layercontrol").and(($el) => {
13
+ $el[0].addEventListener("layerchange", (evt) => {
14
+ if (evt.detail) {
15
+ // Verify if the `layerchange` event triggers with layer as `detail`
16
+ expect(evt.detail).to.eq(mockLayer);
17
+ }
18
+ });
19
+ });
20
+
21
+ // Change visibility of the layer by clicking the checkbox
22
+ cy.get("eox-layercontrol")
23
+ .shadow()
24
+ .within(() => {
25
+ cy.get(".layer").find("input").click();
26
+ });
27
+ };
28
+
29
+ export default checkLayerChangedEvent;
@@ -6,3 +6,4 @@ export { default as checkLayerRemovedFromGroup } from "./check-layer-removed-fro
6
6
  export { default as addLayerFromOptional } from "./add-layer-from-optional";
7
7
  export { default as checkLayerZoomState } from "./check-layer-zoom-state";
8
8
  export { default as addExternalLayers } from "./add-external-layer";
9
+ export { default as checkLayerChangedEvent } from "./check-layer-changed-event";
@@ -9,6 +9,7 @@ import {
9
9
  checkLayerRemovedFromRoot,
10
10
  checkLayerSizeAfterMultipleCalls,
11
11
  checkLayerZoomState,
12
+ checkLayerChangedEvent,
12
13
  } from "./cases/layer-update";
13
14
 
14
15
  describe("LayerControl", () => {
@@ -64,4 +65,8 @@ describe("LayerControl", () => {
64
65
  // Test case: Add new external layers (WMS/XYZ and JSON)
65
66
  it("Add new external WMS/XYZ and JSON Layer - addExternalLayers", () =>
66
67
  addExternalLayers());
68
+
69
+ // Test case: `layerchange` event
70
+ it("Checks if a `layerchange` event is dispatched", () =>
71
+ checkLayerChangedEvent());
67
72
  });