Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@spectrum-web-components/tray

Package Overview
Dependencies
Maintainers
7
Versions
247
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spectrum-web-components/tray - npm Package Compare versions

Comparing version 0.2.4-express.12 to 0.3.0

src/spectrum-tray-wrapper.css.d.ts

93

custom-elements.json

@@ -48,2 +48,21 @@ {

"kind": "field",
"name": "prefersMotion",
"privacy": "protected",
"default": "new MatchMediaController(\n this,\n '(prefers-reduced-motion: no-preference)'\n )"
},
{
"kind": "field",
"name": "transitionPromise",
"privacy": "private"
},
{
"kind": "field",
"name": "resolveTransitionPromise",
"type": {
"text": "() => void"
},
"privacy": "private"
},
{
"kind": "field",
"name": "tray",

@@ -67,2 +86,12 @@ "type": {

"kind": "method",
"name": "overlayWillCloseCallback",
"privacy": "public",
"return": {
"type": {
"text": "boolean"
}
}
},
{
"kind": "method",
"name": "close",

@@ -75,2 +104,43 @@ "privacy": "public",

}
},
{
"kind": "method",
"name": "dispatchClosed",
"privacy": "private",
"return": {
"type": {
"text": "void"
}
}
},
{
"kind": "method",
"name": "handleUnderlayTransitionend",
"privacy": "protected",
"return": {
"type": {
"text": "void"
}
}
},
{
"kind": "method",
"name": "handleTrayTransitionend",
"privacy": "protected",
"return": {
"type": {
"text": "void"
}
}
},
{
"kind": "method",
"name": "getUpdateComplete",
"privacy": "protected",
"return": {
"type": {
"text": "Promise<boolean>"
}
},
"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."
}

@@ -133,2 +203,23 @@ ],

"kind": "javascript-module",
"path": "src/spectrum-tray-wrapper.css.ts",
"declarations": [
{
"kind": "variable",
"name": "styles",
"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`"
}
],
"exports": [
{
"kind": "js",
"name": "default",
"declaration": {
"name": "styles",
"module": "src/spectrum-tray-wrapper.css.ts"
}
}
]
},
{
"kind": "javascript-module",
"path": "src/spectrum-tray.css.ts",

@@ -160,3 +251,3 @@ "declarations": [

"name": "styles",
"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`"
"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`"
}

@@ -163,0 +254,0 @@ ],

10

package.json
{
"name": "@spectrum-web-components/tray",
"version": "0.2.4-express.12+27420d682",
"version": "0.3.0",
"publishConfig": {

@@ -48,9 +48,9 @@ "access": "public"

"@spectrum-web-components/base": "^0.5.1",
"@spectrum-web-components/modal": "^0.5.3-express.12+27420d682",
"@spectrum-web-components/modal": "^0.6.0",
"@spectrum-web-components/shared": "^0.13.3",
"@spectrum-web-components/underlay": "^0.8.3-express.12+27420d682",
"@spectrum-web-components/underlay": "^0.8.2",
"tslib": "^2.0.0"
},
"devDependencies": {
"@spectrum-css/tray": "^1.0.14"
"@spectrum-css/tray": "^1.0.13"
},

@@ -62,3 +62,3 @@ "types": "./src/index.d.ts",

],
"gitHead": "27420d682bb3b3f679875e1f4148c10df0bd738c"
"gitHead": "f23b15ec952d7450272a8275524c905e028b4ddc"
}

@@ -17,2 +17,15 @@ /*

{
name: 'tray-wrapper',
host: {
selector: '.spectrum-Tray-wrapper',
},
attributes: [
{
type: 'boolean',
selector: '.is-open',
name: 'open',
},
],
},
{
name: 'tray',

@@ -19,0 +32,0 @@ host: {

@@ -14,3 +14,3 @@ /*

const styles = css `
.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(
: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(
--spectrum-tray-full-width-border-radius,var(--spectrum-alias-border-radius-regular)

@@ -38,5 +38,5 @@ ) var(

--spectrum-dialog-confirm-entry-animation-delay,var(--spectrum-global-animation-duration-200)
)}@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)}
)}@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}
`;
export default styles;
//# sourceMappingURL=tray.css.js.map

@@ -1,3 +0,4 @@

import { CSSResultArray, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
import { CSSResultArray, PropertyValues, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
import '@spectrum-web-components/underlay/sp-underlay.js';
import { MatchMediaController } from '@spectrum-web-components/reactive-controllers/src/MatchMedia.js';
/**

@@ -13,6 +14,23 @@ * @element sp-tray

open: boolean;
protected prefersMotion: MatchMediaController;
private transitionPromise;
private resolveTransitionPromise;
private tray;
focus(): void;
overlayWillCloseCallback(): boolean;
close(): void;
private dispatchClosed;
protected handleUnderlayTransitionend(): void;
protected handleTrayTransitionend(): void;
protected update(changes: PropertyValues<this>): void;
protected render(): TemplateResult;
/**
* Bind the open/close transition into the update complete lifecycle so
* that the overlay system can wait for it to be "visibly ready" before
* attempting to throw focus into the content contained herein. Not
* waiting for this can cause small amounts of page scroll to happen
* while opening the Tray when focusable content is included: e.g. Menu
* elements whose selected Menu Item is not the first Menu Item.
*/
protected getUpdateComplete(): Promise<boolean>;
}

@@ -17,2 +17,3 @@ /*

import { firstFocusableIn } from '@spectrum-web-components/shared/src/first-focusable-in.js';
import { MatchMediaController } from '@spectrum-web-components/reactive-controllers/src/MatchMedia.js';
import modalStyles from '@spectrum-web-components/modal/src/modal.css.js';

@@ -31,2 +32,4 @@ import styles from './tray.css.js';

this.open = false;
this.prefersMotion = new MatchMediaController(this, '(prefers-reduced-motion: no-preference)');
this.transitionPromise = Promise.resolve();
}

@@ -48,4 +51,15 @@ static get styles() {

}
overlayWillCloseCallback() {
if (!this.open)
return false;
this.close();
return true;
}
close() {
this.open = false;
if (!this.prefersMotion.matches) {
this.dispatchClosed();
}
}
dispatchClosed() {
this.dispatchEvent(new Event('close', {

@@ -55,6 +69,33 @@ bubbles: true,

}
handleUnderlayTransitionend() {
if (!this.open) {
this.dispatchClosed();
this.resolveTransitionPromise();
}
}
handleTrayTransitionend() {
if (this.open) {
this.resolveTransitionPromise();
}
}
update(changes) {
if (changes.has('open') &&
changes.get('open') !== undefined &&
this.prefersMotion.matches) {
this.transitionPromise = new Promise((res) => (this.resolveTransitionPromise = res));
}
super.update(changes);
}
render() {
return html `
<sp-underlay ?open=${this.open} @click=${this.close}></sp-underlay>
<div class="tray modal" tabindex="-1">
<sp-underlay
?open=${this.open}
@click=${this.close}
@transitionend=${this.handleUnderlayTransitionend}
></sp-underlay>
<div
class="tray modal"
tabindex="-1"
@transitionend=${this.handleTrayTransitionend}
>
<slot></slot>

@@ -64,2 +105,15 @@ </div>

}
/**
* Bind the open/close transition into the update complete lifecycle so
* that the overlay system can wait for it to be "visibly ready" before
* attempting to throw focus into the content contained herein. Not
* waiting for this can cause small amounts of page scroll to happen
* while opening the Tray when focusable content is included: e.g. Menu
* elements whose selected Menu Item is not the first Menu Item.
*/
async getUpdateComplete() {
const complete = (await super.getUpdateComplete());
await this.transitionPromise;
return complete;
}
}

@@ -66,0 +120,0 @@ __decorate([

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc