@spectrum-web-components/tray 0.2.2 → 0.3.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/custom-elements.json +92 -1
- package/package.json +6 -6
- package/src/Tray.d.ts +19 -1
- package/src/Tray.js +56 -2
- package/src/Tray.js.map +1 -1
- package/src/spectrum-config.js +13 -0
- package/src/spectrum-tray-wrapper.css.d.ts +2 -0
- package/src/spectrum-tray-wrapper.css.js +17 -0
- package/src/spectrum-tray-wrapper.css.js.map +1 -0
- package/src/tray.css.js +2 -2
- package/src/tray.css.js.map +1 -1
package/custom-elements.json
CHANGED
|
@@ -43,6 +43,25 @@
|
|
|
43
43
|
"attribute": "open",
|
|
44
44
|
"reflects": true
|
|
45
45
|
},
|
|
46
|
+
{
|
|
47
|
+
"kind": "field",
|
|
48
|
+
"name": "prefersMotion",
|
|
49
|
+
"privacy": "protected",
|
|
50
|
+
"default": "new MatchMediaController(\n this,\n '(prefers-reduced-motion: no-preference)'\n )"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"kind": "field",
|
|
54
|
+
"name": "transitionPromise",
|
|
55
|
+
"privacy": "private"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"kind": "field",
|
|
59
|
+
"name": "resolveTransitionPromise",
|
|
60
|
+
"type": {
|
|
61
|
+
"text": "() => void"
|
|
62
|
+
},
|
|
63
|
+
"privacy": "private"
|
|
64
|
+
},
|
|
46
65
|
{
|
|
47
66
|
"kind": "field",
|
|
48
67
|
"name": "tray",
|
|
@@ -61,6 +80,16 @@
|
|
|
61
80
|
}
|
|
62
81
|
}
|
|
63
82
|
},
|
|
83
|
+
{
|
|
84
|
+
"kind": "method",
|
|
85
|
+
"name": "overlayWillCloseCallback",
|
|
86
|
+
"privacy": "public",
|
|
87
|
+
"return": {
|
|
88
|
+
"type": {
|
|
89
|
+
"text": "boolean"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
64
93
|
{
|
|
65
94
|
"kind": "method",
|
|
66
95
|
"name": "close",
|
|
@@ -70,6 +99,47 @@
|
|
|
70
99
|
"text": "void"
|
|
71
100
|
}
|
|
72
101
|
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"kind": "method",
|
|
105
|
+
"name": "dispatchClosed",
|
|
106
|
+
"privacy": "private",
|
|
107
|
+
"return": {
|
|
108
|
+
"type": {
|
|
109
|
+
"text": "void"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"kind": "method",
|
|
115
|
+
"name": "handleUnderlayTransitionend",
|
|
116
|
+
"privacy": "protected",
|
|
117
|
+
"return": {
|
|
118
|
+
"type": {
|
|
119
|
+
"text": "void"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"kind": "method",
|
|
125
|
+
"name": "handleTrayTransitionend",
|
|
126
|
+
"privacy": "protected",
|
|
127
|
+
"return": {
|
|
128
|
+
"type": {
|
|
129
|
+
"text": "void"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"kind": "method",
|
|
135
|
+
"name": "getUpdateComplete",
|
|
136
|
+
"privacy": "protected",
|
|
137
|
+
"return": {
|
|
138
|
+
"type": {
|
|
139
|
+
"text": "Promise<boolean>"
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
"description": "Bind the open/close transition into the update complete lifecycle so\nthat the overlay system can wait for it to be \"visibly ready\" before\nattempting to throw focus into the content contained herein. Not\nwaiting for this can cause small amounts of page scroll to happen\nwhile opening the Tray when focusable content is included: e.g. Menu\nelements whose selected Menu Item is not the first Menu Item."
|
|
73
143
|
}
|
|
74
144
|
],
|
|
75
145
|
"events": [
|
|
@@ -125,6 +195,27 @@
|
|
|
125
195
|
}
|
|
126
196
|
]
|
|
127
197
|
},
|
|
198
|
+
{
|
|
199
|
+
"kind": "javascript-module",
|
|
200
|
+
"path": "src/spectrum-tray-wrapper.css.ts",
|
|
201
|
+
"declarations": [
|
|
202
|
+
{
|
|
203
|
+
"kind": "variable",
|
|
204
|
+
"name": "styles",
|
|
205
|
+
"default": "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`"
|
|
206
|
+
}
|
|
207
|
+
],
|
|
208
|
+
"exports": [
|
|
209
|
+
{
|
|
210
|
+
"kind": "js",
|
|
211
|
+
"name": "default",
|
|
212
|
+
"declaration": {
|
|
213
|
+
"name": "styles",
|
|
214
|
+
"module": "src/spectrum-tray-wrapper.css.ts"
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
]
|
|
218
|
+
},
|
|
128
219
|
{
|
|
129
220
|
"kind": "javascript-module",
|
|
130
221
|
"path": "src/spectrum-tray.css.ts",
|
|
@@ -153,7 +244,7 @@
|
|
|
153
244
|
{
|
|
154
245
|
"kind": "variable",
|
|
155
246
|
"name": "styles",
|
|
156
|
-
"default": "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)}}:host{align-items:flex-end}.tray{padding:var(--spectrum-tray-padding-y,0) var(--spectrum-tray-padding-x,0)}\n`"
|
|
247
|
+
"default": "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;-webkit-clip-path:inset(50%);clip-path:inset(50%);height:1px;margin:0 -1px -1px 0;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}\n`"
|
|
157
248
|
}
|
|
158
249
|
],
|
|
159
250
|
"exports": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/tray",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -45,18 +45,18 @@
|
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@spectrum-web-components/base": "^0.5.1",
|
|
48
|
-
"@spectrum-web-components/modal": "^0.
|
|
49
|
-
"@spectrum-web-components/shared": "^0.13.
|
|
50
|
-
"@spectrum-web-components/underlay": "^0.8.
|
|
48
|
+
"@spectrum-web-components/modal": "^0.6.0",
|
|
49
|
+
"@spectrum-web-components/shared": "^0.13.3",
|
|
50
|
+
"@spectrum-web-components/underlay": "^0.8.2",
|
|
51
51
|
"tslib": "^2.0.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@spectrum-css/tray": "^1.0.
|
|
54
|
+
"@spectrum-css/tray": "^1.0.13"
|
|
55
55
|
},
|
|
56
56
|
"types": "./src/index.d.ts",
|
|
57
57
|
"customElements": "custom-elements.json",
|
|
58
58
|
"sideEffects": [
|
|
59
59
|
"./sp-*.js"
|
|
60
60
|
],
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "f23b15ec952d7450272a8275524c905e028b4ddc"
|
|
62
62
|
}
|
package/src/Tray.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { CSSResultArray, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
|
|
1
|
+
import { CSSResultArray, PropertyValues, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
|
|
2
2
|
import '@spectrum-web-components/underlay/sp-underlay.js';
|
|
3
|
+
import { MatchMediaController } from '@spectrum-web-components/reactive-controllers/src/MatchMedia.js';
|
|
3
4
|
/**
|
|
4
5
|
* @element sp-tray
|
|
5
6
|
*
|
|
@@ -10,8 +11,25 @@ import '@spectrum-web-components/underlay/sp-underlay.js';
|
|
|
10
11
|
export declare class Tray extends SpectrumElement {
|
|
11
12
|
static get styles(): CSSResultArray;
|
|
12
13
|
open: boolean;
|
|
14
|
+
protected prefersMotion: MatchMediaController;
|
|
15
|
+
private transitionPromise;
|
|
16
|
+
private resolveTransitionPromise;
|
|
13
17
|
private tray;
|
|
14
18
|
focus(): void;
|
|
19
|
+
overlayWillCloseCallback(): boolean;
|
|
15
20
|
close(): void;
|
|
21
|
+
private dispatchClosed;
|
|
22
|
+
protected handleUnderlayTransitionend(): void;
|
|
23
|
+
protected handleTrayTransitionend(): void;
|
|
24
|
+
protected update(changes: PropertyValues<this>): void;
|
|
16
25
|
protected render(): TemplateResult;
|
|
26
|
+
/**
|
|
27
|
+
* Bind the open/close transition into the update complete lifecycle so
|
|
28
|
+
* that the overlay system can wait for it to be "visibly ready" before
|
|
29
|
+
* attempting to throw focus into the content contained herein. Not
|
|
30
|
+
* waiting for this can cause small amounts of page scroll to happen
|
|
31
|
+
* while opening the Tray when focusable content is included: e.g. Menu
|
|
32
|
+
* elements whose selected Menu Item is not the first Menu Item.
|
|
33
|
+
*/
|
|
34
|
+
protected getUpdateComplete(): Promise<boolean>;
|
|
17
35
|
}
|
package/src/Tray.js
CHANGED
|
@@ -14,6 +14,7 @@ import { html, SpectrumElement, } from '@spectrum-web-components/base';
|
|
|
14
14
|
import { property, query, } from '@spectrum-web-components/base/src/decorators.js';
|
|
15
15
|
import '@spectrum-web-components/underlay/sp-underlay.js';
|
|
16
16
|
import { firstFocusableIn } from '@spectrum-web-components/shared/src/first-focusable-in.js';
|
|
17
|
+
import { MatchMediaController } from '@spectrum-web-components/reactive-controllers/src/MatchMedia.js';
|
|
17
18
|
import modalStyles from '@spectrum-web-components/modal/src/modal.css.js';
|
|
18
19
|
import styles from './tray.css.js';
|
|
19
20
|
/**
|
|
@@ -27,6 +28,8 @@ export class Tray extends SpectrumElement {
|
|
|
27
28
|
constructor() {
|
|
28
29
|
super(...arguments);
|
|
29
30
|
this.open = false;
|
|
31
|
+
this.prefersMotion = new MatchMediaController(this, '(prefers-reduced-motion: no-preference)');
|
|
32
|
+
this.transitionPromise = Promise.resolve();
|
|
30
33
|
}
|
|
31
34
|
static get styles() {
|
|
32
35
|
return [modalStyles, styles];
|
|
@@ -43,20 +46,71 @@ export class Tray extends SpectrumElement {
|
|
|
43
46
|
super.focus();
|
|
44
47
|
}
|
|
45
48
|
}
|
|
49
|
+
overlayWillCloseCallback() {
|
|
50
|
+
if (!this.open)
|
|
51
|
+
return false;
|
|
52
|
+
this.close();
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
46
55
|
close() {
|
|
47
56
|
this.open = false;
|
|
57
|
+
if (!this.prefersMotion.matches) {
|
|
58
|
+
this.dispatchClosed();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
dispatchClosed() {
|
|
48
62
|
this.dispatchEvent(new Event('close', {
|
|
49
63
|
bubbles: true,
|
|
50
64
|
}));
|
|
51
65
|
}
|
|
66
|
+
handleUnderlayTransitionend() {
|
|
67
|
+
if (!this.open) {
|
|
68
|
+
this.dispatchClosed();
|
|
69
|
+
this.resolveTransitionPromise();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
handleTrayTransitionend() {
|
|
73
|
+
if (this.open) {
|
|
74
|
+
this.resolveTransitionPromise();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
update(changes) {
|
|
78
|
+
if (changes.has('open') &&
|
|
79
|
+
changes.get('open') !== undefined &&
|
|
80
|
+
this.prefersMotion.matches) {
|
|
81
|
+
this.transitionPromise = new Promise((res) => (this.resolveTransitionPromise = res));
|
|
82
|
+
}
|
|
83
|
+
super.update(changes);
|
|
84
|
+
}
|
|
52
85
|
render() {
|
|
53
86
|
return html `
|
|
54
|
-
<sp-underlay
|
|
55
|
-
|
|
87
|
+
<sp-underlay
|
|
88
|
+
?open=${this.open}
|
|
89
|
+
@click=${this.close}
|
|
90
|
+
@transitionend=${this.handleUnderlayTransitionend}
|
|
91
|
+
></sp-underlay>
|
|
92
|
+
<div
|
|
93
|
+
class="tray modal"
|
|
94
|
+
tabindex="-1"
|
|
95
|
+
@transitionend=${this.handleTrayTransitionend}
|
|
96
|
+
>
|
|
56
97
|
<slot></slot>
|
|
57
98
|
</div>
|
|
58
99
|
`;
|
|
59
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Bind the open/close transition into the update complete lifecycle so
|
|
103
|
+
* that the overlay system can wait for it to be "visibly ready" before
|
|
104
|
+
* attempting to throw focus into the content contained herein. Not
|
|
105
|
+
* waiting for this can cause small amounts of page scroll to happen
|
|
106
|
+
* while opening the Tray when focusable content is included: e.g. Menu
|
|
107
|
+
* elements whose selected Menu Item is not the first Menu Item.
|
|
108
|
+
*/
|
|
109
|
+
async getUpdateComplete() {
|
|
110
|
+
const complete = (await super.getUpdateComplete());
|
|
111
|
+
await this.transitionPromise;
|
|
112
|
+
return complete;
|
|
113
|
+
}
|
|
60
114
|
}
|
|
61
115
|
__decorate([
|
|
62
116
|
property({ type: Boolean, reflect: true })
|
package/src/Tray.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tray.js","sourceRoot":"","sources":["Tray.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EAEH,IAAI,
|
|
1
|
+
{"version":3,"file":"Tray.js","sourceRoot":"","sources":["Tray.ts"],"names":[],"mappings":"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","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 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 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 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 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 async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this.transitionPromise;\n return complete;\n }\n}\n"]}
|
package/src/spectrum-config.js
CHANGED
|
@@ -13,6 +13,19 @@ governing permissions and limitations under the License.
|
|
|
13
13
|
const config = {
|
|
14
14
|
spectrum: 'tray',
|
|
15
15
|
components: [
|
|
16
|
+
{
|
|
17
|
+
name: 'tray-wrapper',
|
|
18
|
+
host: {
|
|
19
|
+
selector: '.spectrum-Tray-wrapper',
|
|
20
|
+
},
|
|
21
|
+
attributes: [
|
|
22
|
+
{
|
|
23
|
+
type: 'boolean',
|
|
24
|
+
selector: '.is-open',
|
|
25
|
+
name: 'open',
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
},
|
|
16
29
|
{
|
|
17
30
|
name: 'tray',
|
|
18
31
|
host: {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { css } from '@spectrum-web-components/base';
|
|
13
|
+
const styles = css `
|
|
14
|
+
: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)}}
|
|
15
|
+
`;
|
|
16
|
+
export default styles;
|
|
17
|
+
//# sourceMappingURL=spectrum-tray-wrapper.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spectrum-tray-wrapper.css.js","sourceRoot":"","sources":["spectrum-tray-wrapper.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;CAEjB,CAAC;AACF,eAAe,MAAM,CAAC","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*/\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;"]}
|
package/src/tray.css.js
CHANGED
|
@@ -11,7 +11,7 @@ governing permissions and limitations under the License.
|
|
|
11
11
|
*/
|
|
12
12
|
import { css } from '@spectrum-web-components/base';
|
|
13
13
|
const styles = css `
|
|
14
|
-
.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(
|
|
14
|
+
: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(
|
|
15
15
|
--spectrum-tray-full-width-border-radius,var(--spectrum-alias-border-radius-regular)
|
|
16
16
|
) var(
|
|
17
17
|
--spectrum-tray-full-width-border-radius,var(--spectrum-alias-border-radius-regular)
|
|
@@ -34,7 +34,7 @@ var(--spectrum-global-animation-duration-100)
|
|
|
34
34
|
--spectrum-dialog-confirm-entry-animation-duration,var(--spectrum-global-animation-duration-500)
|
|
35
35
|
) cubic-bezier(0,0,.4,1) var(
|
|
36
36
|
--spectrum-dialog-confirm-entry-animation-delay,var(--spectrum-global-animation-duration-200)
|
|
37
|
-
)}@media (max-width:375px){.tray{border-radius:var(--spectrum-tray-border-radius,0)}}:host{align-items:flex-end}.tray{padding:var(--spectrum-tray-padding-y,0) var(--spectrum-tray-padding-x,0)}
|
|
37
|
+
)}@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;-webkit-clip-path:inset(50%);clip-path:inset(50%);height:1px;margin:0 -1px -1px 0;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}
|
|
38
38
|
`;
|
|
39
39
|
export default styles;
|
|
40
40
|
//# sourceMappingURL=tray.css.js.map
|
package/src/tray.css.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tray.css.js","sourceRoot":"","sources":["tray.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;CAyBjB,CAAC;AACF,eAAe,MAAM,CAAC","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*/\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)}}:host{align-items:flex-end}.tray{padding:var(--spectrum-tray-padding-y,0) var(--spectrum-tray-padding-x,0)}\n`;\nexport default styles;"]}
|
|
1
|
+
{"version":3,"file":"tray.css.js","sourceRoot":"","sources":["tray.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;CAyBjB,CAAC;AACF,eAAe,MAAM,CAAC","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*/\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;-webkit-clip-path:inset(50%);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;"]}
|