@spectrum-web-components/underlay 0.42.3 → 0.42.5

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/underlay",
3
- "version": "0.42.3",
3
+ "version": "0.42.5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -57,10 +57,10 @@
57
57
  "lit-html"
58
58
  ],
59
59
  "dependencies": {
60
- "@spectrum-web-components/base": "^0.42.3"
60
+ "@spectrum-web-components/base": "^0.42.5"
61
61
  },
62
62
  "devDependencies": {
63
- "@spectrum-css/underlay": "^3.2.4"
63
+ "@spectrum-css/underlay": "^4.1.0"
64
64
  },
65
65
  "types": "./src/index.d.ts",
66
66
  "customElements": "custom-elements.json",
@@ -68,5 +68,5 @@
68
68
  "./sp-*.js",
69
69
  "./**/*.dev.js"
70
70
  ],
71
- "gitHead": "a03edce4f21f232f1705d8eb222e6e5436cad4c3"
71
+ "gitHead": "f29fd737947945de8cd6f5bc03fb389d386c9c3a"
72
72
  }
@@ -6,8 +6,7 @@ var __decorateClass = (decorators, target, key, kind) => {
6
6
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
7
7
  if (decorator = decorators[i])
8
8
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
9
- if (kind && result)
10
- __defProp(target, key, result);
9
+ if (kind && result) __defProp(target, key, result);
11
10
  return result;
12
11
  };
13
12
  import {
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["Underlay.ts"],
4
4
  "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport styles from './underlay.css.js';\n\n/**\n * @element sp-underlay\n *\n * @fires close - When the underlay is \"clicked\" and the consuming pattern should chose whether to close based on that interaction\n */\nexport class Underlay extends SpectrumElement {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n private canClick = false;\n\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n public override click(): void {\n this.dispatchEvent(new Event('close'));\n }\n\n protected handlePointerdown(): void {\n this.canClick = true;\n }\n\n protected handlePointerup(): void {\n if (this.canClick) {\n this.click();\n }\n this.canClick = false;\n }\n\n protected override render(): TemplateResult {\n return html``;\n }\n\n protected override firstUpdated(): void {\n this.addEventListener('pointerdown', this.handlePointerdown);\n this.addEventListener('pointerup', this.handlePointerup);\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;AAYA;AAAA,EAEI;AAAA,EACA;AAAA,OAEG;AACP,SAAS,gBAAgB;AAEzB,OAAO,YAAY;AAOZ,aAAM,iBAAiB,gBAAgB;AAAA,EAAvC;AAAA;AAKH,SAAQ,WAAW;AAGnB,SAAO,OAAO;AAAA;AAAA,EAPd,WAA2B,SAAyB;AAChD,WAAO,CAAC,MAAM;AAAA,EAClB;AAAA,EAOgB,QAAc;AAC1B,SAAK,cAAc,IAAI,MAAM,OAAO,CAAC;AAAA,EACzC;AAAA,EAEU,oBAA0B;AAChC,SAAK,WAAW;AAAA,EACpB;AAAA,EAEU,kBAAwB;AAC9B,QAAI,KAAK,UAAU;AACf,WAAK,MAAM;AAAA,IACf;AACA,SAAK,WAAW;AAAA,EACpB;AAAA,EAEmB,SAAyB;AACxC,WAAO;AAAA,EACX;AAAA,EAEmB,eAAqB;AACpC,SAAK,iBAAiB,eAAe,KAAK,iBAAiB;AAC3D,SAAK,iBAAiB,aAAa,KAAK,eAAe;AAAA,EAC3D;AACJ;AAzBW;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GAPjC,SAQF;",
5
+ "mappings": ";;;;;;;;;;;AAYA;AAAA,EAEI;AAAA,EACA;AAAA,OAEG;AACP,SAAS,gBAAgB;AAEzB,OAAO,YAAY;AAOZ,aAAM,iBAAiB,gBAAgB;AAAA,EAAvC;AAAA;AAKH,SAAQ,WAAW;AAGnB,SAAO,OAAO;AAAA;AAAA,EAPd,WAA2B,SAAyB;AAChD,WAAO,CAAC,MAAM;AAAA,EAClB;AAAA,EAOgB,QAAc;AAC1B,SAAK,cAAc,IAAI,MAAM,OAAO,CAAC;AAAA,EACzC;AAAA,EAEU,oBAA0B;AAChC,SAAK,WAAW;AAAA,EACpB;AAAA,EAEU,kBAAwB;AAC9B,QAAI,KAAK,UAAU;AACf,WAAK,MAAM;AAAA,IACf;AACA,SAAK,WAAW;AAAA,EACpB;AAAA,EAEmB,SAAyB;AACxC,WAAO;AAAA,EACX;AAAA,EAEmB,eAAqB;AACpC,SAAK,iBAAiB,eAAe,KAAK,iBAAiB;AAC3D,SAAK,iBAAiB,aAAa,KAAK,eAAe;AAAA,EAC3D;AACJ;AAzBW;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK,CAAC;AAAA,GAPjC,SAQF;",
6
6
  "names": []
7
7
  }
@@ -2,22 +2,31 @@
2
2
  import { elementUpdated, expect, fixture, html } from "@open-wc/testing";
3
3
  import "@spectrum-web-components/underlay/sp-underlay.js";
4
4
  import { testForLitDevWarnings } from "../../../test/testing-helpers.js";
5
+ import { spy } from "sinon";
5
6
  describe("Underlay", () => {
6
7
  testForLitDevWarnings(
7
- async () => await fixture(
8
- html`
9
- <sp-underlay></sp-underlay>
10
- `
11
- )
8
+ async () => await fixture(html`
9
+ <sp-underlay></sp-underlay>
10
+ `)
12
11
  );
13
12
  it("loads default underlay accessibly", async () => {
14
- const el = await fixture(
15
- html`
16
- <sp-underlay></sp-underlay>
17
- `
18
- );
13
+ const el = await fixture(html`
14
+ <sp-underlay></sp-underlay>
15
+ `);
19
16
  await elementUpdated(el);
20
17
  await expect(el).to.be.accessible();
21
18
  });
19
+ it("fires a close event when clicked", async () => {
20
+ const el = await fixture(html`
21
+ <sp-underlay></sp-underlay>
22
+ `);
23
+ await elementUpdated(el);
24
+ const closeSpy = spy();
25
+ el.addEventListener("close", () => closeSpy());
26
+ expect(closeSpy.callCount).to.equal(0);
27
+ el.dispatchEvent(new PointerEvent("pointerdown", { button: 0 }));
28
+ el.dispatchEvent(new PointerEvent("pointerup"));
29
+ expect(closeSpy.callCount).to.equal(1);
30
+ });
22
31
  });
23
32
  //# sourceMappingURL=underlay.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["underlay.test.ts"],
4
- "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { elementUpdated, expect, fixture, html } from '@open-wc/testing';\n\nimport '@spectrum-web-components/underlay/sp-underlay.js';\nimport { Underlay } from '@spectrum-web-components/underlay';\nimport { testForLitDevWarnings } from '../../../test/testing-helpers.js';\n\ndescribe('Underlay', () => {\n testForLitDevWarnings(\n async () =>\n await fixture<Underlay>(\n html`\n <sp-underlay></sp-underlay>\n `\n )\n );\n it('loads default underlay accessibly', async () => {\n const el = await fixture<Underlay>(\n html`\n <sp-underlay></sp-underlay>\n `\n );\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n});\n"],
5
- "mappings": ";AAYA,SAAS,gBAAgB,QAAQ,SAAS,YAAY;AAEtD,OAAO;AAEP,SAAS,6BAA6B;AAEtC,SAAS,YAAY,MAAM;AACvB;AAAA,IACI,YACI,MAAM;AAAA,MACF;AAAA;AAAA;AAAA,IAGJ;AAAA,EACR;AACA,KAAG,qCAAqC,YAAY;AAChD,UAAM,KAAK,MAAM;AAAA,MACb;AAAA;AAAA;AAAA,IAGJ;AAEA,UAAM,eAAe,EAAE;AAEvB,UAAM,OAAO,EAAE,EAAE,GAAG,GAAG,WAAW;AAAA,EACtC,CAAC;AACL,CAAC;",
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { elementUpdated, expect, fixture, html } from '@open-wc/testing';\n\nimport '@spectrum-web-components/underlay/sp-underlay.js';\nimport { Underlay } from '@spectrum-web-components/underlay';\nimport { testForLitDevWarnings } from '../../../test/testing-helpers.js';\nimport { spy } from 'sinon';\n\ndescribe('Underlay', () => {\n testForLitDevWarnings(\n async () =>\n await fixture<Underlay>(html`\n <sp-underlay></sp-underlay>\n `)\n );\n it('loads default underlay accessibly', async () => {\n const el = await fixture<Underlay>(html`\n <sp-underlay></sp-underlay>\n `);\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n\n it('fires a close event when clicked', async () => {\n const el = await fixture<Underlay>(html`\n <sp-underlay></sp-underlay>\n `);\n\n await elementUpdated(el);\n const closeSpy = spy();\n el.addEventListener('close', () => closeSpy());\n expect(closeSpy.callCount).to.equal(0);\n\n el.dispatchEvent(new PointerEvent('pointerdown', { button: 0 }));\n el.dispatchEvent(new PointerEvent('pointerup'));\n\n expect(closeSpy.callCount).to.equal(1);\n });\n});\n"],
5
+ "mappings": ";AAYA,SAAS,gBAAgB,QAAQ,SAAS,YAAY;AAEtD,OAAO;AAEP,SAAS,6BAA6B;AACtC,SAAS,WAAW;AAEpB,SAAS,YAAY,MAAM;AACvB;AAAA,IACI,YACI,MAAM,QAAkB;AAAA;AAAA,aAEvB;AAAA,EACT;AACA,KAAG,qCAAqC,YAAY;AAChD,UAAM,KAAK,MAAM,QAAkB;AAAA;AAAA,SAElC;AAED,UAAM,eAAe,EAAE;AAEvB,UAAM,OAAO,EAAE,EAAE,GAAG,GAAG,WAAW;AAAA,EACtC,CAAC;AAED,KAAG,oCAAoC,YAAY;AAC/C,UAAM,KAAK,MAAM,QAAkB;AAAA;AAAA,SAElC;AAED,UAAM,eAAe,EAAE;AACvB,UAAM,WAAW,IAAI;AACrB,OAAG,iBAAiB,SAAS,MAAM,SAAS,CAAC;AAC7C,WAAO,SAAS,SAAS,EAAE,GAAG,MAAM,CAAC;AAErC,OAAG,cAAc,IAAI,aAAa,eAAe,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC/D,OAAG,cAAc,IAAI,aAAa,WAAW,CAAC;AAE9C,WAAO,SAAS,SAAS,EAAE,GAAG,MAAM,CAAC;AAAA,EACzC,CAAC;AACL,CAAC;",
6
6
  "names": []
7
7
  }