@spectrum-web-components/tray 0.3.13-devmode.0 → 0.4.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.
- package/package.json +7 -7
- package/sp-tray.js +1 -2
- package/sp-tray.js.map +1 -1
- package/src/Tray.js +2 -94
- package/src/Tray.js.map +1 -1
- package/src/index.js +1 -1
- package/src/index.js.map +1 -1
- package/src/spectrum-tray-wrapper.css.js +2 -4
- package/src/spectrum-tray-wrapper.css.js.map +1 -1
- package/src/spectrum-tray.css.js +2 -4
- package/src/spectrum-tray.css.js.map +1 -1
- package/src/tray.css.js +2 -4
- package/src/tray.css.js.map +1 -1
- package/stories/tray.stories.js +4 -36
- package/stories/tray.stories.js.map +1 -1
- package/test/benchmark/basic-test.js +1 -5
- package/test/benchmark/basic-test.js.map +1 -1
- package/test/tray.test-vrt.js +1 -3
- package/test/tray.test-vrt.js.map +1 -1
- package/test/tray.test.js +6 -56
- package/test/tray.test.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/tray",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -57,11 +57,11 @@
|
|
|
57
57
|
"lit-html"
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@spectrum-web-components/base": "^0.
|
|
61
|
-
"@spectrum-web-components/modal": "^0.
|
|
62
|
-
"@spectrum-web-components/reactive-controllers": "^0.
|
|
63
|
-
"@spectrum-web-components/shared": "^0.
|
|
64
|
-
"@spectrum-web-components/underlay": "^0.
|
|
60
|
+
"@spectrum-web-components/base": "^0.7.0",
|
|
61
|
+
"@spectrum-web-components/modal": "^0.7.0",
|
|
62
|
+
"@spectrum-web-components/reactive-controllers": "^0.3.0",
|
|
63
|
+
"@spectrum-web-components/shared": "^0.15.0",
|
|
64
|
+
"@spectrum-web-components/underlay": "^0.9.0",
|
|
65
65
|
"tslib": "^2.0.0"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"./sp-*.js",
|
|
74
74
|
"./**/*.dev.js"
|
|
75
75
|
],
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "05c81318844160db3f8156144106e643507fef97"
|
|
77
77
|
}
|
package/sp-tray.js
CHANGED
package/sp-tray.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["sp-tray.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 { Tray } from './src/Tray.js';\n\ncustomElements.define('sp-tray', Tray);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-tray': Tray;\n }\n}\n"],
|
|
5
|
-
"mappings": "AAYA
|
|
5
|
+
"mappings": "AAYA,qCAEA,eAAe,OAAO,UAAW,CAAI",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/Tray.js
CHANGED
|
@@ -1,83 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
-
if (decorator = decorators[i])
|
|
7
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
-
if (kind && result)
|
|
9
|
-
__defProp(target, key, result);
|
|
10
|
-
return result;
|
|
11
|
-
};
|
|
12
|
-
import {
|
|
13
|
-
html,
|
|
14
|
-
SpectrumElement
|
|
15
|
-
} from "@spectrum-web-components/base";
|
|
16
|
-
import {
|
|
17
|
-
property,
|
|
18
|
-
query
|
|
19
|
-
} from "@spectrum-web-components/base/src/decorators.js";
|
|
20
|
-
import "@spectrum-web-components/underlay/sp-underlay.js";
|
|
21
|
-
import { firstFocusableIn } from "@spectrum-web-components/shared/src/first-focusable-in.js";
|
|
22
|
-
import { MatchMediaController } from "@spectrum-web-components/reactive-controllers/src/MatchMedia.js";
|
|
23
|
-
import modalStyles from "@spectrum-web-components/modal/src/modal.css.js";
|
|
24
|
-
import styles from "./tray.css.js";
|
|
25
|
-
export class Tray extends SpectrumElement {
|
|
26
|
-
constructor() {
|
|
27
|
-
super(...arguments);
|
|
28
|
-
this.open = false;
|
|
29
|
-
this.prefersMotion = new MatchMediaController(this, "(prefers-reduced-motion: no-preference)");
|
|
30
|
-
this.transitionPromise = Promise.resolve();
|
|
31
|
-
}
|
|
32
|
-
static get styles() {
|
|
33
|
-
return [modalStyles, styles];
|
|
34
|
-
}
|
|
35
|
-
focus() {
|
|
36
|
-
const firstFocusable = firstFocusableIn(this);
|
|
37
|
-
if (firstFocusable) {
|
|
38
|
-
firstFocusable.focus();
|
|
39
|
-
} else if (this.children.length === 1) {
|
|
40
|
-
this.tray.focus();
|
|
41
|
-
} else {
|
|
42
|
-
super.focus();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
overlayWillCloseCallback() {
|
|
46
|
-
if (!this.open)
|
|
47
|
-
return false;
|
|
48
|
-
this.close();
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
close() {
|
|
52
|
-
this.open = false;
|
|
53
|
-
if (!this.prefersMotion.matches) {
|
|
54
|
-
this.dispatchClosed();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
dispatchClosed() {
|
|
58
|
-
this.dispatchEvent(new Event("close", {
|
|
59
|
-
bubbles: true
|
|
60
|
-
}));
|
|
61
|
-
}
|
|
62
|
-
handleUnderlayTransitionend() {
|
|
63
|
-
if (!this.open) {
|
|
64
|
-
this.dispatchClosed();
|
|
65
|
-
this.resolveTransitionPromise();
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
handleTrayTransitionend() {
|
|
69
|
-
if (this.open) {
|
|
70
|
-
this.resolveTransitionPromise();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
update(changes) {
|
|
74
|
-
if (changes.has("open") && changes.get("open") !== void 0 && this.prefersMotion.matches) {
|
|
75
|
-
this.transitionPromise = new Promise((res) => this.resolveTransitionPromise = res);
|
|
76
|
-
}
|
|
77
|
-
super.update(changes);
|
|
78
|
-
}
|
|
79
|
-
render() {
|
|
80
|
-
return html`
|
|
1
|
+
var a=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var l=(o,e,r,i)=>{for(var t=i>1?void 0:i?p(e,r):e,s=o.length-1,n;s>=0;s--)(n=o[s])&&(t=(i?n(e,r,t):n(t))||t);return i&&t&&a(e,r,t),t};import{html as d,SpectrumElement as c}from"@spectrum-web-components/base";import{property as h,query as m}from"@spectrum-web-components/base/src/decorators.js";import"@spectrum-web-components/underlay/sp-underlay.js";import{firstFocusableIn as u}from"@spectrum-web-components/shared/src/first-focusable-in.js";import{MatchMediaController as f}from"@spectrum-web-components/reactive-controllers/src/MatchMedia.js";import v from"@spectrum-web-components/modal/src/modal.css.js";import y from"./tray.css.js";export class Tray extends c{constructor(){super(...arguments);this.open=!1;this.prefersMotion=new f(this,"(prefers-reduced-motion: no-preference)");this.transitionPromise=Promise.resolve()}static get styles(){return[v,y]}focus(){const e=u(this);e?e.focus():this.children.length===1?this.tray.focus():super.focus()}overlayWillCloseCallback(){return this.open?(this.close(),!0):!1}close(){this.open=!1,this.prefersMotion.matches||this.dispatchClosed()}dispatchClosed(){this.dispatchEvent(new Event("close",{bubbles:!0}))}handleUnderlayTransitionend(){this.open||(this.dispatchClosed(),this.resolveTransitionPromise())}handleTrayTransitionend(){this.open&&this.resolveTransitionPromise()}update(e){e.has("open")&&e.get("open")!==void 0&&this.prefersMotion.matches&&(this.transitionPromise=new Promise(r=>this.resolveTransitionPromise=r)),super.update(e)}render(){return d`
|
|
81
2
|
<sp-underlay
|
|
82
3
|
?open=${this.open}
|
|
83
4
|
@click=${this.close}
|
|
@@ -90,18 +11,5 @@ export class Tray extends SpectrumElement {
|
|
|
90
11
|
>
|
|
91
12
|
<slot></slot>
|
|
92
13
|
</div>
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
async getUpdateComplete() {
|
|
96
|
-
const complete = await super.getUpdateComplete();
|
|
97
|
-
await this.transitionPromise;
|
|
98
|
-
return complete;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
__decorateClass([
|
|
102
|
-
property({ type: Boolean, reflect: true })
|
|
103
|
-
], Tray.prototype, "open", 2);
|
|
104
|
-
__decorateClass([
|
|
105
|
-
query(".tray")
|
|
106
|
-
], Tray.prototype, "tray", 2);
|
|
14
|
+
`}async getUpdateComplete(){const e=await super.getUpdateComplete();return await this.transitionPromise,e}}l([h({type:Boolean,reflect:!0})],Tray.prototype,"open",2),l([m(".tray")],Tray.prototype,"tray",2);
|
|
107
15
|
//# sourceMappingURL=Tray.js.map
|
package/src/Tray.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["Tray.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 PropertyValues,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport '@spectrum-web-components/underlay/sp-underlay.js';\nimport { firstFocusableIn } from '@spectrum-web-components/shared/src/first-focusable-in.js';\nimport { MatchMediaController } from '@spectrum-web-components/reactive-controllers/src/MatchMedia.js';\n\nimport modalStyles from '@spectrum-web-components/modal/src/modal.css.js';\nimport styles from './tray.css.js';\n\n/**\n * @element sp-tray\n *\n * @slot - content to display within the Tray\n *\n * @fires close - Announces that the Tray has been closed.\n */\nexport class Tray extends SpectrumElement {\n public static override get styles(): CSSResultArray {\n return [modalStyles, styles];\n }\n\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n protected prefersMotion = new MatchMediaController(\n this,\n '(prefers-reduced-motion: no-preference)'\n );\n\n private transitionPromise = Promise.resolve();\n\n private resolveTransitionPromise!: () => void;\n\n @query('.tray')\n private tray!: HTMLDivElement;\n\n public override focus(): void {\n const firstFocusable = firstFocusableIn(this);\n if (firstFocusable) {\n firstFocusable.focus();\n } else if (this.children.length === 1) {\n this.tray.focus();\n } else {\n super.focus();\n }\n }\n\n public overlayWillCloseCallback(): boolean {\n if (!this.open) return false;\n this.close();\n return true;\n }\n\n public close(): void {\n this.open = false;\n if (!this.prefersMotion.matches) {\n this.dispatchClosed();\n }\n }\n\n private dispatchClosed(): void {\n this.dispatchEvent(\n new Event('close', {\n bubbles: true,\n })\n );\n }\n\n protected handleUnderlayTransitionend(): void {\n if (!this.open) {\n this.dispatchClosed();\n this.resolveTransitionPromise();\n }\n }\n\n protected handleTrayTransitionend(): void {\n if (this.open) {\n this.resolveTransitionPromise();\n }\n }\n\n protected override update(changes: PropertyValues<this>): void {\n if (\n changes.has('open') &&\n changes.get('open') !== undefined &&\n this.prefersMotion.matches\n ) {\n this.transitionPromise = new Promise(\n (res) => (this.resolveTransitionPromise = res)\n );\n }\n super.update(changes);\n }\n\n protected override render(): TemplateResult {\n return html`\n <sp-underlay\n ?open=${this.open}\n @click=${this.close}\n @transitionend=${this.handleUnderlayTransitionend}\n ></sp-underlay>\n <div\n class=\"tray modal\"\n tabindex=\"-1\"\n @transitionend=${this.handleTrayTransitionend}\n >\n <slot></slot>\n </div>\n `;\n }\n\n /**\n * Bind the open/close transition into the update complete lifecycle so\n * that the overlay system can wait for it to be \"visibly ready\" before\n * attempting to throw focus into the content contained herein. Not\n * waiting for this can cause small amounts of page scroll to happen\n * while opening the Tray when focusable content is included: e.g. Menu\n * elements whose selected Menu Item is not the first Menu Item.\n */\n protected override async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this.transitionPromise;\n return complete;\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "wMAYA,0EAOA,sFAIA,yDACA,6FACA,uGAEA,+DACA,6BASO,aAAM,YAAa,EAAgB,CAAnC,kCAMI,UAAO,GAEJ,mBAAgB,GAAI,GAC1B,KACA,yCACJ,EAEQ,uBAAoB,QAAQ,QAAQ,YAZjB,SAAyB,CAChD,MAAO,CAAC,EAAa,CAAM,CAC/B,CAiBgB,OAAc,CAC1B,KAAM,GAAiB,EAAiB,IAAI,EAC5C,AAAI,EACA,EAAe,MAAM,EAClB,AAAI,KAAK,SAAS,SAAW,EAChC,KAAK,KAAK,MAAM,EAEhB,MAAM,MAAM,CAEpB,CAEO,0BAAoC,CACvC,MAAK,MAAK,KACV,MAAK,MAAM,EACJ,IAFgB,EAG3B,CAEO,OAAc,CACjB,KAAK,KAAO,GACP,KAAK,cAAc,SACpB,KAAK,eAAe,CAE5B,CAEQ,gBAAuB,CAC3B,KAAK,cACD,GAAI,OAAM,QAAS,CACf,QAAS,EACb,CAAC,CACL,CACJ,CAEU,6BAAoC,CAC1C,AAAK,KAAK,MACN,MAAK,eAAe,EACpB,KAAK,yBAAyB,EAEtC,CAEU,yBAAgC,CACtC,AAAI,KAAK,MACL,KAAK,yBAAyB,CAEtC,CAEmB,OAAO,EAAqC,CAC3D,AACI,EAAQ,IAAI,MAAM,GAClB,EAAQ,IAAI,MAAM,IAAM,QACxB,KAAK,cAAc,SAEnB,MAAK,kBAAoB,GAAI,SACzB,AAAC,GAAS,KAAK,yBAA2B,CAC9C,GAEJ,MAAM,OAAO,CAAO,CACxB,CAEmB,QAAyB,CACxC,MAAO;AAAA;AAAA,wBAES,KAAK;AAAA,yBACJ,KAAK;AAAA,iCACG,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA,iCAKL,KAAK;AAAA;AAAA;AAAA;AAAA,SAKlC,MAUyB,oBAAsC,CAC3D,KAAM,GAAY,KAAM,OAAM,kBAAkB,EAChD,YAAM,MAAK,kBACJ,CACX,CACJ,CAtGW,GADP,AAAC,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GACnC,AANJ,KAMI,oBAYC,GADR,AAAC,EAAM,OAAO,GACN,AAlBL,KAkBK",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export*from"./Tray.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["index.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\nexport * from './Tray.js';\n"],
|
|
5
|
-
"mappings": "AAYA
|
|
5
|
+
"mappings": "AAYA",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
const styles = css`
|
|
1
|
+
import{css as t}from"@spectrum-web-components/base";const r=t`
|
|
3
2
|
:host([dir=ltr]){left:0}:host([dir=rtl]){right:0}:host{bottom:0;display:flex;justify-content:center;position:fixed;width:100%;z-index:2}@media (max-width:375px){.spectrum-Tray{border-radius:var(--spectrum-tray-border-radius,0)}}
|
|
4
|
-
`;
|
|
5
|
-
export default styles;
|
|
3
|
+
`;export default r;
|
|
6
4
|
//# sourceMappingURL=spectrum-tray-wrapper.css.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["spectrum-tray-wrapper.css.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2022 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*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host([dir=ltr]){left:0}:host([dir=rtl]){right:0}:host{bottom:0;display:flex;justify-content:center;position:fixed;width:100%;z-index:2}@media (max-width:375px){.spectrum-Tray{border-radius:var(--spectrum-tray-border-radius,0)}}\n`;\nexport default styles;"],
|
|
5
|
-
"mappings": "AAWA
|
|
5
|
+
"mappings": "AAWA,oDACA,KAAM,GAAS;AAAA;AAAA,EAGf,cAAe",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/spectrum-tray.css.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
const styles = css`
|
|
1
|
+
import{css as a}from"@spectrum-web-components/base";const r=a`
|
|
3
2
|
.tray{opacity:0;pointer-events:none;transition:transform var(--spectrum-global-animation-duration-100,.13s) ease-in-out,opacity var(--spectrum-global-animation-duration-100,.13s) ease-in-out,visibility 0ms linear var(--spectrum-global-animation-duration-100,.13s);visibility:hidden}:host([open]) .tray{opacity:1;pointer-events:auto;transition-delay:0ms;visibility:visible}:host{--spectrum-dialog-confirm-exit-animation-delay:0ms;--spectrum-tray-margin-top:64px}:host([dir=ltr]) .spectrum-Tray-wrapper{left:0}:host([dir=rtl]) .spectrum-Tray-wrapper{right:0}.spectrum-Tray-wrapper{bottom:0;display:flex;justify-content:center;position:fixed;width:100%;z-index:2}.tray{border-radius:var(
|
|
4
3
|
--spectrum-tray-full-width-border-radius,var(--spectrum-alias-border-radius-regular)
|
|
5
4
|
) var(
|
|
@@ -24,6 +23,5 @@ var(--spectrum-global-animation-duration-100)
|
|
|
24
23
|
) cubic-bezier(0,0,.4,1) var(
|
|
25
24
|
--spectrum-dialog-confirm-entry-animation-delay,var(--spectrum-global-animation-duration-200)
|
|
26
25
|
)}@media (max-width:375px){.tray{border-radius:var(--spectrum-tray-border-radius,0)}}
|
|
27
|
-
`;
|
|
28
|
-
export default styles;
|
|
26
|
+
`;export default r;
|
|
29
27
|
//# sourceMappingURL=spectrum-tray.css.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["spectrum-tray.css.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2022 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*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n.tray{opacity:0;pointer-events:none;transition:transform var(--spectrum-global-animation-duration-100,.13s) ease-in-out,opacity var(--spectrum-global-animation-duration-100,.13s) ease-in-out,visibility 0ms linear var(--spectrum-global-animation-duration-100,.13s);visibility:hidden}:host([open]) .tray{opacity:1;pointer-events:auto;transition-delay:0ms;visibility:visible}:host{--spectrum-dialog-confirm-exit-animation-delay:0ms;--spectrum-tray-margin-top:64px}:host([dir=ltr]) .spectrum-Tray-wrapper{left:0}:host([dir=rtl]) .spectrum-Tray-wrapper{right:0}.spectrum-Tray-wrapper{bottom:0;display:flex;justify-content:center;position:fixed;width:100%;z-index:2}.tray{border-radius:var(\n--spectrum-tray-full-width-border-radius,var(--spectrum-alias-border-radius-regular)\n) var(\n--spectrum-tray-full-width-border-radius,var(--spectrum-alias-border-radius-regular)\n) var(--spectrum-tray-border-radius,0) var(--spectrum-tray-border-radius,0);max-height:calc(100vh - var(--spectrum-tray-margin-top));max-width:var(--spectrum-tray-max-width,375px);min-height:var(\n--spectrum-tray-min-height,var(--spectrum-global-dimension-static-size-800)\n);outline:none;overflow:auto;padding:var(--spectrum-tray-padding-y,0) var(\n--spectrum-tray-padding-x,var(--spectrum-global-dimension-static-size-100)\n);transform:translateY(100%);transition:opacity var(\n--spectrum-dialog-confirm-exit-animation-duration,var(--spectrum-global-animation-duration-100)\n) cubic-bezier(.5,0,1,1) var(--spectrum-dialog-confirm-exit-animation-delay,0ms),visibility 0ms linear calc(var(--spectrum-dialog-confirm-exit-animation-delay, 0ms) + var(\n--spectrum-dialog-confirm-exit-animation-duration,\nvar(--spectrum-global-animation-duration-100)\n)),transform var(\n--spectrum-dialog-confirm-exit-animation-duration,var(--spectrum-global-animation-duration-100)\n) cubic-bezier(.5,0,1,1) var(--spectrum-dialog-confirm-exit-animation-delay,0ms);width:var(--spectrum-tray-width,100%)}:host([open]) .tray{transform:translateY(0);transition:transform var(\n--spectrum-dialog-confirm-entry-animation-duration,var(--spectrum-global-animation-duration-500)\n) cubic-bezier(0,0,.4,1) var(\n--spectrum-dialog-confirm-entry-animation-delay,var(--spectrum-global-animation-duration-200)\n),opacity var(\n--spectrum-dialog-confirm-entry-animation-duration,var(--spectrum-global-animation-duration-500)\n) cubic-bezier(0,0,.4,1) var(\n--spectrum-dialog-confirm-entry-animation-delay,var(--spectrum-global-animation-duration-200)\n)}@media (max-width:375px){.tray{border-radius:var(--spectrum-tray-border-radius,0)}}\n`;\nexport default styles;"],
|
|
5
|
-
"mappings": "AAWA
|
|
5
|
+
"mappings": "AAWA,oDACA,KAAM,GAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA0Bf,cAAe",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/tray.css.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
const styles = css`
|
|
1
|
+
import{css as r}from"@spectrum-web-components/base";const a=r`
|
|
3
2
|
:host([dir=ltr]){left:0}:host([dir=rtl]){right:0}:host{bottom:0;display:flex;justify-content:center;position:fixed;width:100%;z-index:2}@media (max-width:375px){.spectrum-Tray{border-radius:var(--spectrum-tray-border-radius,0)}}.tray{opacity:0;pointer-events:none;transition:transform var(--spectrum-global-animation-duration-100,.13s) ease-in-out,opacity var(--spectrum-global-animation-duration-100,.13s) ease-in-out,visibility 0ms linear var(--spectrum-global-animation-duration-100,.13s);visibility:hidden}:host([open]) .tray{opacity:1;pointer-events:auto;transition-delay:0ms;visibility:visible}:host{--spectrum-dialog-confirm-exit-animation-delay:0ms;--spectrum-tray-margin-top:64px}:host([dir=ltr]) .spectrum-Tray-wrapper{left:0}:host([dir=rtl]) .spectrum-Tray-wrapper{right:0}.spectrum-Tray-wrapper{bottom:0;display:flex;justify-content:center;position:fixed;width:100%;z-index:2}.tray{border-radius:var(
|
|
4
3
|
--spectrum-tray-full-width-border-radius,var(--spectrum-alias-border-radius-regular)
|
|
5
4
|
) var(
|
|
@@ -24,6 +23,5 @@ var(--spectrum-global-animation-duration-100)
|
|
|
24
23
|
) cubic-bezier(0,0,.4,1) var(
|
|
25
24
|
--spectrum-dialog-confirm-entry-animation-delay,var(--spectrum-global-animation-duration-200)
|
|
26
25
|
)}@media (max-width:375px){.tray{border-radius:var(--spectrum-tray-border-radius,0)}}:host{align-items:flex-end;max-height:var(--swc-visual-viewport-height);position:fixed!important}sp-underlay{touch-action:none}.tray{display:inline-flex;overscroll-behavior:contain;padding:var(--spectrum-tray-padding-y,0) var(--spectrum-tray-padding-x,0)}::slotted(.visually-hidden){clip:rect(0,0,0,0);border:0;clip-path:inset(50%);height:1px;margin:0 -1px -1px 0;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}
|
|
27
|
-
`;
|
|
28
|
-
export default styles;
|
|
26
|
+
`;export default a;
|
|
29
27
|
//# sourceMappingURL=tray.css.js.map
|
package/src/tray.css.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["tray.css.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2022 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*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host([dir=ltr]){left:0}:host([dir=rtl]){right:0}:host{bottom:0;display:flex;justify-content:center;position:fixed;width:100%;z-index:2}@media (max-width:375px){.spectrum-Tray{border-radius:var(--spectrum-tray-border-radius,0)}}.tray{opacity:0;pointer-events:none;transition:transform var(--spectrum-global-animation-duration-100,.13s) ease-in-out,opacity var(--spectrum-global-animation-duration-100,.13s) ease-in-out,visibility 0ms linear var(--spectrum-global-animation-duration-100,.13s);visibility:hidden}:host([open]) .tray{opacity:1;pointer-events:auto;transition-delay:0ms;visibility:visible}:host{--spectrum-dialog-confirm-exit-animation-delay:0ms;--spectrum-tray-margin-top:64px}:host([dir=ltr]) .spectrum-Tray-wrapper{left:0}:host([dir=rtl]) .spectrum-Tray-wrapper{right:0}.spectrum-Tray-wrapper{bottom:0;display:flex;justify-content:center;position:fixed;width:100%;z-index:2}.tray{border-radius:var(\n--spectrum-tray-full-width-border-radius,var(--spectrum-alias-border-radius-regular)\n) var(\n--spectrum-tray-full-width-border-radius,var(--spectrum-alias-border-radius-regular)\n) var(--spectrum-tray-border-radius,0) var(--spectrum-tray-border-radius,0);max-height:calc(100vh - var(--spectrum-tray-margin-top));max-width:var(--spectrum-tray-max-width,375px);min-height:var(\n--spectrum-tray-min-height,var(--spectrum-global-dimension-static-size-800)\n);outline:none;overflow:auto;padding:var(--spectrum-tray-padding-y,0) var(\n--spectrum-tray-padding-x,var(--spectrum-global-dimension-static-size-100)\n);transform:translateY(100%);transition:opacity var(\n--spectrum-dialog-confirm-exit-animation-duration,var(--spectrum-global-animation-duration-100)\n) cubic-bezier(.5,0,1,1) var(--spectrum-dialog-confirm-exit-animation-delay,0ms),visibility 0ms linear calc(var(--spectrum-dialog-confirm-exit-animation-delay, 0ms) + var(\n--spectrum-dialog-confirm-exit-animation-duration,\nvar(--spectrum-global-animation-duration-100)\n)),transform var(\n--spectrum-dialog-confirm-exit-animation-duration,var(--spectrum-global-animation-duration-100)\n) cubic-bezier(.5,0,1,1) var(--spectrum-dialog-confirm-exit-animation-delay,0ms);width:var(--spectrum-tray-width,100%)}:host([open]) .tray{transform:translateY(0);transition:transform var(\n--spectrum-dialog-confirm-entry-animation-duration,var(--spectrum-global-animation-duration-500)\n) cubic-bezier(0,0,.4,1) var(\n--spectrum-dialog-confirm-entry-animation-delay,var(--spectrum-global-animation-duration-200)\n),opacity var(\n--spectrum-dialog-confirm-entry-animation-duration,var(--spectrum-global-animation-duration-500)\n) cubic-bezier(0,0,.4,1) var(\n--spectrum-dialog-confirm-entry-animation-delay,var(--spectrum-global-animation-duration-200)\n)}@media (max-width:375px){.tray{border-radius:var(--spectrum-tray-border-radius,0)}}:host{align-items:flex-end;max-height:var(--swc-visual-viewport-height);position:fixed!important}sp-underlay{touch-action:none}.tray{display:inline-flex;overscroll-behavior:contain;padding:var(--spectrum-tray-padding-y,0) var(--spectrum-tray-padding-x,0)}::slotted(.visually-hidden){clip:rect(0,0,0,0);border:0;clip-path:inset(50%);height:1px;margin:0 -1px -1px 0;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}\n`;\nexport default styles;"],
|
|
5
|
-
"mappings": "AAWA
|
|
5
|
+
"mappings": "AAWA,oDACA,KAAM,GAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA0Bf,cAAe",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/stories/tray.stories.js
CHANGED
|
@@ -1,43 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import "@spectrum-web-components/menu/sp-menu.js";
|
|
4
|
-
import "@spectrum-web-components/menu/sp-menu-item.js";
|
|
5
|
-
import "@spectrum-web-components/menu/sp-menu-divider.js";
|
|
6
|
-
import "@spectrum-web-components/tray/sp-tray.js";
|
|
7
|
-
export default {
|
|
8
|
-
title: "Tray",
|
|
9
|
-
component: "sp-tray",
|
|
10
|
-
args: {
|
|
11
|
-
open: true
|
|
12
|
-
},
|
|
13
|
-
argTypes: {
|
|
14
|
-
open: {
|
|
15
|
-
name: "open",
|
|
16
|
-
type: { name: "boolean", required: false },
|
|
17
|
-
description: "Whether the tray is open.",
|
|
18
|
-
table: {
|
|
19
|
-
type: { summary: "boolean" },
|
|
20
|
-
defaultValue: { summary: false }
|
|
21
|
-
},
|
|
22
|
-
control: {
|
|
23
|
-
type: "boolean"
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
export const Default = (args) => {
|
|
29
|
-
return html`
|
|
30
|
-
<sp-tray ?open=${args.open}>
|
|
1
|
+
import{html as t}from"@spectrum-web-components/base";import"@spectrum-web-components/dialog/sp-dialog.js";import"@spectrum-web-components/menu/sp-menu.js";import"@spectrum-web-components/menu/sp-menu-item.js";import"@spectrum-web-components/menu/sp-menu-divider.js";import"@spectrum-web-components/tray/sp-tray.js";export default{title:"Tray",component:"sp-tray",args:{open:!0},argTypes:{open:{name:"open",type:{name:"boolean",required:!1},description:"Whether the tray is open.",table:{type:{summary:"boolean"},defaultValue:{summary:!1}},control:{type:"boolean"}}}};export const Default=e=>t`
|
|
2
|
+
<sp-tray ?open=${e.open}>
|
|
31
3
|
<sp-dialog size="s">
|
|
32
4
|
<h2 slot="heading">New Messages</h2>
|
|
33
5
|
You have 5 new messages.
|
|
34
6
|
</sp-dialog>
|
|
35
7
|
</sp-tray>
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
export const menu = (args) => {
|
|
39
|
-
return html`
|
|
40
|
-
<sp-tray ?open=${args.open}>
|
|
8
|
+
`,menu=e=>t`
|
|
9
|
+
<sp-tray ?open=${e.open}>
|
|
41
10
|
<sp-menu style="width: 100%">
|
|
42
11
|
<sp-menu-item>Deselect</sp-menu-item>
|
|
43
12
|
<sp-menu-item selected>Select Inverse</sp-menu-item>
|
|
@@ -49,5 +18,4 @@ export const menu = (args) => {
|
|
|
49
18
|
</sp-menu>
|
|
50
19
|
</sp-tray>
|
|
51
20
|
`;
|
|
52
|
-
};
|
|
53
21
|
//# sourceMappingURL=tray.stories.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["tray.stories.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 { html, TemplateResult } from '@spectrum-web-components/base';\n\nimport '@spectrum-web-components/dialog/sp-dialog.js';\nimport '@spectrum-web-components/menu/sp-menu.js';\nimport '@spectrum-web-components/menu/sp-menu-item.js';\nimport '@spectrum-web-components/menu/sp-menu-divider.js';\nimport '@spectrum-web-components/tray/sp-tray.js';\n\nexport default {\n title: 'Tray',\n component: 'sp-tray',\n args: {\n open: true,\n },\n argTypes: {\n open: {\n name: 'open',\n type: { name: 'boolean', required: false },\n description: 'Whether the tray is open.',\n table: {\n type: { summary: 'boolean' },\n defaultValue: { summary: false },\n },\n control: {\n type: 'boolean',\n },\n },\n },\n};\n\ntype StoryArgs = {\n open?: boolean;\n};\n\nexport const Default = (args: StoryArgs): TemplateResult => {\n return html`\n <sp-tray ?open=${args.open}>\n <sp-dialog size=\"s\">\n <h2 slot=\"heading\">New Messages</h2>\n You have 5 new messages.\n </sp-dialog>\n </sp-tray>\n `;\n};\n\nexport const menu = (args: StoryArgs): TemplateResult => {\n return html`\n <sp-tray ?open=${args.open}>\n <sp-menu style=\"width: 100%\">\n <sp-menu-item>Deselect</sp-menu-item>\n <sp-menu-item selected>Select Inverse</sp-menu-item>\n <sp-menu-item>Feather...</sp-menu-item>\n <sp-menu-item>Select and Mask...</sp-menu-item>\n <sp-menu-divider></sp-menu-divider>\n <sp-menu-item>Save Selection</sp-menu-item>\n <sp-menu-item disabled>Make Work Path</sp-menu-item>\n </sp-menu>\n </sp-tray>\n `;\n};\n"],
|
|
5
|
-
"mappings": "AAYA
|
|
5
|
+
"mappings": "AAYA,qDAEA,qDACA,iDACA,sDACA,yDACA,iDAEA,cAAe,CACX,MAAO,OACP,UAAW,UACX,KAAM,CACF,KAAM,EACV,EACA,SAAU,CACN,KAAM,CACF,KAAM,OACN,KAAM,CAAE,KAAM,UAAW,SAAU,EAAM,EACzC,YAAa,4BACb,MAAO,CACH,KAAM,CAAE,QAAS,SAAU,EAC3B,aAAc,CAAE,QAAS,EAAM,CACnC,EACA,QAAS,CACL,KAAM,SACV,CACJ,CACJ,CACJ,EAMO,YAAM,SAAU,AAAC,GACb;AAAA,yBACc,EAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MASjB,KAAO,AAAC,GACV;AAAA,yBACc,EAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "@spectrum-web-components/tray/sp-tray.js";
|
|
3
|
-
import { html } from "lit";
|
|
4
|
-
import { measureFixtureCreation } from "../../../../test/benchmark/helpers.js";
|
|
5
|
-
measureFixtureCreation(html`
|
|
1
|
+
import"@spectrum-web-components/dialog/sp-dialog.js";import"@spectrum-web-components/tray/sp-tray.js";import{html as e}from"lit";import{measureFixtureCreation as s}from"../../../../test/benchmark/helpers.js";s(e`
|
|
6
2
|
<sp-tray open>
|
|
7
3
|
<sp-dialog size="s">
|
|
8
4
|
<h2 slot="heading">New Messages</h2>
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["basic-test.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 '@spectrum-web-components/dialog/sp-dialog.js';\nimport '@spectrum-web-components/tray/sp-tray.js';\nimport { html } from 'lit';\nimport { measureFixtureCreation } from '../../../../test/benchmark/helpers.js';\n\nmeasureFixtureCreation(html`\n <sp-tray open>\n <sp-dialog size=\"s\">\n <h2 slot=\"heading\">New Messages</h2>\n You have 5 new messages.\n </sp-dialog>\n </sp-tray>\n`);\n"],
|
|
5
|
-
"mappings": "AAYA
|
|
5
|
+
"mappings": "AAYA,qDACA,iDACA,2BACA,+EAEA,EAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAOtB",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/test/tray.test-vrt.js
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { regressVisuals } from "../../../test/visual/test.js";
|
|
3
|
-
regressVisuals("TrayStories", stories);
|
|
1
|
+
import*as r from"../stories/tray.stories.js";import{regressVisuals as s}from"../../../test/visual/test.js";s("TrayStories",r);
|
|
4
2
|
//# sourceMappingURL=tray.test-vrt.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["tray.test-vrt.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 * as stories from '../stories/tray.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\n\nregressVisuals('TrayStories', stories);\n"],
|
|
5
|
-
"mappings": "AAYA
|
|
5
|
+
"mappings": "AAYA,6CACA,8DAEA,EAAe,cAAe,CAAO",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/test/tray.test.js
CHANGED
|
@@ -1,70 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
elementUpdated,
|
|
3
|
-
expect,
|
|
4
|
-
fixture,
|
|
5
|
-
html,
|
|
6
|
-
nextFrame,
|
|
7
|
-
oneEvent
|
|
8
|
-
} from "@open-wc/testing";
|
|
9
|
-
import "@spectrum-web-components/tray/sp-tray.js";
|
|
10
|
-
import "@spectrum-web-components/theme/sp-theme.js";
|
|
11
|
-
import "@spectrum-web-components/theme/src/themes.js";
|
|
12
|
-
import { testForLitDevWarnings } from "../../../test/testing-helpers.js";
|
|
13
|
-
describe("Tray", () => {
|
|
14
|
-
testForLitDevWarnings(async () => await fixture(html`
|
|
1
|
+
import{elementUpdated as s,expect as a,fixture as o,html as r,nextFrame as i,oneEvent as n}from"@open-wc/testing";import"@spectrum-web-components/tray/sp-tray.js";import"@spectrum-web-components/theme/sp-theme.js";import"@spectrum-web-components/theme/src/themes.js";import{testForLitDevWarnings as l}from"../../../test/testing-helpers.js";describe("Tray",()=>{l(async()=>await o(r`
|
|
15
2
|
<sp-tray></sp-tray>
|
|
16
|
-
`))
|
|
17
|
-
it("loads default tray accessibly", async () => {
|
|
18
|
-
const el = await fixture(html`
|
|
3
|
+
`)),it("loads default tray accessibly",async()=>{const t=await o(r`
|
|
19
4
|
<sp-tray></sp-tray>
|
|
20
|
-
`);
|
|
21
|
-
await elementUpdated(el);
|
|
22
|
-
await expect(el).to.be.accessible();
|
|
23
|
-
});
|
|
24
|
-
it("focuses focusable light DOM element", async () => {
|
|
25
|
-
const el = await fixture(html`
|
|
5
|
+
`);await s(t),await a(t).to.be.accessible()}),it("focuses focusable light DOM element",async()=>{const t=await o(r`
|
|
26
6
|
<sp-tray open>
|
|
27
7
|
<div>
|
|
28
8
|
<a href="#">Test element</a>
|
|
29
9
|
</div>
|
|
30
10
|
</sp-tray>
|
|
31
|
-
`);
|
|
32
|
-
const anchor = el.querySelector("a");
|
|
33
|
-
await elementUpdated(el);
|
|
34
|
-
el.focus();
|
|
35
|
-
await elementUpdated(el);
|
|
36
|
-
expect(document.activeElement).to.equal(anchor);
|
|
37
|
-
});
|
|
38
|
-
it('focuses "tray"', async () => {
|
|
39
|
-
const el = await fixture(html`
|
|
11
|
+
`),e=t.querySelector("a");await s(t),t.focus(),await s(t),a(document.activeElement).to.equal(e)}),it('focuses "tray"',async()=>{const t=await o(r`
|
|
40
12
|
<sp-tray open>
|
|
41
13
|
<div></div>
|
|
42
14
|
</sp-tray>
|
|
43
|
-
`);
|
|
44
|
-
await elementUpdated(el);
|
|
45
|
-
el.focus();
|
|
46
|
-
await elementUpdated(el);
|
|
47
|
-
expect(document.activeElement).to.equal(el);
|
|
48
|
-
expect(el.shadowRoot.activeElement).to.equal(el.tray);
|
|
49
|
-
});
|
|
50
|
-
it("closes", async () => {
|
|
51
|
-
const test = await fixture(html`
|
|
15
|
+
`);await s(t),t.focus(),await s(t),a(document.activeElement).to.equal(t),a(t.shadowRoot.activeElement).to.equal(t.tray)}),it("closes",async()=>{const e=(await o(r`
|
|
52
16
|
<sp-theme theme="classic" scale="medium" color="dark">
|
|
53
17
|
<sp-tray></sp-tray>
|
|
54
18
|
</sp-theme>
|
|
55
|
-
`);
|
|
56
|
-
const el = test.querySelector("sp-tray");
|
|
57
|
-
await nextFrame();
|
|
58
|
-
await nextFrame();
|
|
59
|
-
expect(el.open).to.be.false;
|
|
60
|
-
el.open = true;
|
|
61
|
-
await elementUpdated(el);
|
|
62
|
-
expect(el.open).to.be.true;
|
|
63
|
-
const closed = oneEvent(el, "close");
|
|
64
|
-
const overlay = el.shadowRoot.querySelector("sp-underlay");
|
|
65
|
-
overlay.click();
|
|
66
|
-
await closed;
|
|
67
|
-
expect(el.open).to.be.false;
|
|
68
|
-
});
|
|
69
|
-
});
|
|
19
|
+
`)).querySelector("sp-tray");await i(),await i(),a(e.open).to.be.false,e.open=!0,await s(e),a(e.open).to.be.true;const c=n(e,"close");e.shadowRoot.querySelector("sp-underlay").click(),await c,a(e.open).to.be.false})});
|
|
70
20
|
//# sourceMappingURL=tray.test.js.map
|
package/test/tray.test.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["tray.test.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 elementUpdated,\n expect,\n fixture,\n html,\n nextFrame,\n oneEvent,\n} from '@open-wc/testing';\n\nimport '@spectrum-web-components/tray/sp-tray.js';\nimport { Tray } from '@spectrum-web-components/tray';\nimport '@spectrum-web-components/theme/sp-theme.js';\nimport '@spectrum-web-components/theme/src/themes.js';\nimport { testForLitDevWarnings } from '../../../test/testing-helpers.js';\n\ndescribe('Tray', () => {\n testForLitDevWarnings(\n async () =>\n await fixture<Tray>(\n html`\n <sp-tray></sp-tray>\n `\n )\n );\n it('loads default tray accessibly', async () => {\n const el = await fixture<Tray>(\n html`\n <sp-tray></sp-tray>\n `\n );\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('focuses focusable light DOM element', async () => {\n const el = await fixture<Tray>(\n html`\n <sp-tray open>\n <div>\n <a href=\"#\">Test element</a>\n </div>\n </sp-tray>\n `\n );\n const anchor = el.querySelector('a');\n await elementUpdated(el);\n\n el.focus();\n await elementUpdated(el);\n\n expect(document.activeElement).to.equal(anchor);\n });\n it('focuses \"tray\"', async () => {\n const el = await fixture<Tray>(\n html`\n <sp-tray open>\n <div></div>\n </sp-tray>\n `\n );\n await elementUpdated(el);\n\n el.focus();\n await elementUpdated(el);\n\n expect(document.activeElement).to.equal(el);\n expect(el.shadowRoot.activeElement).to.equal(\n (el as unknown as { tray: HTMLDivElement }).tray\n );\n });\n it('closes', async () => {\n const test = await fixture<HTMLElement>(\n html`\n <sp-theme theme=\"classic\" scale=\"medium\" color=\"dark\">\n <sp-tray></sp-tray>\n </sp-theme>\n `\n );\n\n const el = test.querySelector('sp-tray') as Tray;\n // Ensure closed styles are set before opening so that\n // the `transitionend` event will be met below.\n await nextFrame();\n await nextFrame();\n expect(el.open).to.be.false;\n\n el.open = true;\n await elementUpdated(el);\n\n expect(el.open).to.be.true;\n const closed = oneEvent(el, 'close');\n const overlay = el.shadowRoot.querySelector(\n 'sp-underlay'\n ) as HTMLElement;\n overlay.click();\n await closed;\n\n expect(el.open).to.be.false;\n });\n});\n"],
|
|
5
|
-
"mappings": "AAYA
|
|
5
|
+
"mappings": "AAYA,kHASA,iDAEA,mDACA,qDACA,yEAEA,SAAS,OAAQ,IAAM,CACnB,EACI,SACI,KAAM,GACF;AAAA;AAAA,iBAGJ,CACR,EACA,GAAG,gCAAiC,SAAY,CAC5C,KAAM,GAAK,KAAM,GACb;AAAA;AAAA,aAGJ,EAEA,KAAM,GAAe,CAAE,EAEvB,KAAM,GAAO,CAAE,EAAE,GAAG,GAAG,WAAW,CACtC,CAAC,EACD,GAAG,sCAAuC,SAAY,CAClD,KAAM,GAAK,KAAM,GACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAOJ,EACM,EAAS,EAAG,cAAc,GAAG,EACnC,KAAM,GAAe,CAAE,EAEvB,EAAG,MAAM,EACT,KAAM,GAAe,CAAE,EAEvB,EAAO,SAAS,aAAa,EAAE,GAAG,MAAM,CAAM,CAClD,CAAC,EACD,GAAG,iBAAkB,SAAY,CAC7B,KAAM,GAAK,KAAM,GACb;AAAA;AAAA;AAAA;AAAA,aAKJ,EACA,KAAM,GAAe,CAAE,EAEvB,EAAG,MAAM,EACT,KAAM,GAAe,CAAE,EAEvB,EAAO,SAAS,aAAa,EAAE,GAAG,MAAM,CAAE,EAC1C,EAAO,EAAG,WAAW,aAAa,EAAE,GAAG,MAClC,EAA2C,IAChD,CACJ,CAAC,EACD,GAAG,SAAU,SAAY,CASrB,KAAM,GAAK,AARE,MAAM,GACf;AAAA;AAAA;AAAA;AAAA,aAKJ,GAEgB,cAAc,SAAS,EAGvC,KAAM,GAAU,EAChB,KAAM,GAAU,EAChB,EAAO,EAAG,IAAI,EAAE,GAAG,GAAG,MAEtB,EAAG,KAAO,GACV,KAAM,GAAe,CAAE,EAEvB,EAAO,EAAG,IAAI,EAAE,GAAG,GAAG,KACtB,KAAM,GAAS,EAAS,EAAI,OAAO,EAInC,AAHgB,EAAG,WAAW,cAC1B,aACJ,EACQ,MAAM,EACd,KAAM,GAEN,EAAO,EAAG,IAAI,EAAE,GAAG,GAAG,KAC1B,CAAC,CACL,CAAC",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|