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

@spectrum-web-components/toast

Package Overview
Dependencies
Maintainers
0
Versions
288
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 0.49.0-beta.0 to 0.49.0-beta.1

14

package.json
{
"name": "@spectrum-web-components/toast",
"version": "0.49.0-beta.0",
"version": "0.49.0-beta.1",
"publishConfig": {

@@ -60,7 +60,7 @@ "access": "public"

"dependencies": {
"@spectrum-web-components/base": "^0.49.0-beta.0",
"@spectrum-web-components/button": "^0.49.0-beta.0",
"@spectrum-web-components/icon": "^0.49.0-beta.0",
"@spectrum-web-components/icons-workflow": "^0.49.0-beta.0",
"@spectrum-web-components/shared": "^0.49.0-beta.0"
"@spectrum-web-components/base": "^0.49.0-beta.1",
"@spectrum-web-components/button": "^0.49.0-beta.1",
"@spectrum-web-components/icon": "^0.49.0-beta.1",
"@spectrum-web-components/icons-workflow": "^0.49.0-beta.1",
"@spectrum-web-components/shared": "^0.49.0-beta.1"
},

@@ -76,3 +76,3 @@ "devDependencies": {

],
"gitHead": "1aa9165b6529e70339c9c632d47335a2c0894f0b"
"gitHead": "74ee2c5b1276e8e4f768566a1c3c4e263a7eb8b3"
}

@@ -42,3 +42,3 @@ ## Description

slot="action"
static="white"
static-color="white"
variant="secondary"

@@ -59,3 +59,3 @@ treatment="outline"

slot="action"
static="white"
static-color="white"
variant="secondary"

@@ -62,0 +62,0 @@ treatment="outline"

@@ -158,3 +158,3 @@ "use strict";

label="Close"
static="white"
static-color="white"
></sp-close-button>

@@ -161,0 +161,0 @@ </div>

@@ -25,3 +25,3 @@ "use strict";var c=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var r=(a,i,t,o)=>{for(var e=o>1?void 0:o?p(i,t):i,s=a.length-1,u;s>=0;s--)(u=a[s])&&(e=(o?u(i,t,e):u(e))||e);return o&&e&&c(i,t,e),e};import{html as n,SpectrumElement as d}from"@spectrum-web-components/base";import{property as l}from"@spectrum-web-components/base/src/decorators.js";import"@spectrum-web-components/button/sp-close-button.js";import"@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js";import"@spectrum-web-components/icons-workflow/icons/sp-icon-info.js";import"@spectrum-web-components/icons-workflow/icons/sp-icon-checkmark-circle.js";import{FocusVisiblePolyfillMixin as h}from"@spectrum-web-components/shared/src/focus-visible.js";import m from"./toast.css.js";export const toastVariants=["negative","positive","info","error","warning"];export class Toast extends h(d){constructor(){super(...arguments);this.open=!1;this._timeout=null;this._variant="";this.countdownStart=0;this.nextCount=-1;this.doCountdown=t=>{this.countdownStart||(this.countdownStart=performance.now()),t-this.countdownStart>this._timeout?(this.shouldClose(),this.countdownStart=0):this.countdown()};this.countdown=()=>{cancelAnimationFrame(this.nextCount),this.nextCount=requestAnimationFrame(this.doCountdown)};this.holdCountdown=()=>{this.stopCountdown(),this.addEventListener("focusout",this.resumeCountdown)};this.resumeCountdown=()=>{this.removeEventListener("focusout",this.holdCountdown),this.countdown()}}static get styles(){return[m]}set timeout(t){const e=typeof t!==null&&t>0?Math.max(6e3,t):null,s=this.timeout;e&&this.countdownStart&&(this.countdownStart=performance.now()),this._timeout=e,this.requestUpdate("timeout",s)}get timeout(){return this._timeout}set variant(t){if(t===this.variant)return;const o=this.variant;toastVariants.includes(t)?(this.setAttribute("variant",t),this._variant=t):(this.removeAttribute("variant"),this._variant=""),this.requestUpdate("variant",o)}get variant(){return this._variant}renderIcon(t){switch(t){case"info":return n`

label="Close"
static="white"
static-color="white"
></sp-close-button>

@@ -28,0 +28,0 @@ </div>

@@ -20,3 +20,3 @@ "use strict";

slot="action"
static="white"
static-color="white"
variant="secondary"

@@ -23,0 +23,0 @@ treatment="outline"

@@ -19,14 +19,10 @@ "use strict";

testForLitDevWarnings(
async () => await fixture(
html`
<sp-toast open>Help text.</sp-toast>
`
)
async () => await fixture(html`
<sp-toast open>Help text.</sp-toast>
`)
);
it("loads", async () => {
const el = await fixture(
html`
<sp-toast open>Help text.</sp-toast>
`
);
const el = await fixture(html`
<sp-toast open>Help text.</sp-toast>
`);
await elementUpdated(el);

@@ -37,9 +33,7 @@ await expect(el).to.be.accessible();

it(`loads - [variant="${variant}"]`, async () => {
const el = await fixture(
html`
<sp-toast variant=${variant} open>
This toast is of the \`${variant}\` variant.
</sp-toast>
`
);
const el = await fixture(html`
<sp-toast variant=${variant} open>
This toast is of the \`${variant}\` variant.
</sp-toast>
`);
await elementUpdated(el);

@@ -50,7 +44,5 @@ await expect(el).to.be.accessible();

it("loads - timeout", async () => {
const el = await fixture(
html`
<sp-toast timeout="100">Help text.</sp-toast>
`
);
const el = await fixture(html`
<sp-toast timeout="100">Help text.</sp-toast>
`);
await elementUpdated(el);

@@ -65,7 +57,5 @@ expect(el.open).to.be.false;

it("`timeout` updates `countdownStart`", async () => {
const el = await fixture(
html`
<sp-toast timeout="100">Help text.</sp-toast>
`
);
const el = await fixture(html`
<sp-toast timeout="100">Help text.</sp-toast>
`);
await elementUpdated(el);

@@ -93,7 +83,5 @@ expect(el.open).to.be.false;

it("stops timeout on `focusin`", async () => {
const el = await fixture(
html`
<sp-toast timeout="100">Help text.</sp-toast>
`
);
const el = await fixture(html`
<sp-toast timeout="100">Help text.</sp-toast>
`);
await elementUpdated(el);

@@ -120,7 +108,5 @@ const testableEl = el;

it("closes", async () => {
const el = await fixture(
html`
<sp-toast open>Help text.</sp-toast>
`
);
const el = await fixture(html`
<sp-toast open>Help text.</sp-toast>
`);
await elementUpdated(el);

@@ -138,9 +124,7 @@ expect(el.open).to.be.true;

const handleClose = (event) => event.preventDefault();
const el = await fixture(
html`
<sp-toast open timeout="100" @close=${handleClose}>
Help text.
</sp-toast>
`
);
const el = await fixture(html`
<sp-toast open timeout="100" @close=${handleClose}>
Help text.
</sp-toast>
`);
await elementUpdated(el);

@@ -162,9 +146,7 @@ expect(el.open).to.be.true;

};
const el = await fixture(
html`
<sp-toast open timeout="100" @close=${handleClose}>
Help text.
</sp-toast>
`
);
const el = await fixture(html`
<sp-toast open timeout="100" @close=${handleClose}>
Help text.
</sp-toast>
`);
await elementUpdated(el);

@@ -187,9 +169,7 @@ expect(el.open).to.be.true;

it("validates variants", async () => {
const el = await fixture(
html`
<sp-toast variant="invalid" open>
This toast validates variants.
</sp-toast>
`
);
const el = await fixture(html`
<sp-toast variant="invalid" open>
This toast validates variants.
</sp-toast>
`);
await elementUpdated(el);

@@ -205,9 +185,7 @@ expect(el.variant).to.equal("");

it("maintains [variant] when disconnected/connected", async () => {
const el = await fixture(
html`
<sp-toast variant="positive" open>
This toast maintains variants.
</sp-toast>
`
);
const el = await fixture(html`
<sp-toast variant="positive" open>
This toast maintains variants.
</sp-toast>
`);
await elementUpdated(el);

@@ -223,15 +201,13 @@ expect(el.variant).to.equal("positive");

const closeSpy = spy();
const el = await fixture(
html`
<sp-toast
variant="positive"
open
@close=${() => {
closeSpy();
}}
>
This toast maintains variants.
</sp-toast>
`
);
const el = await fixture(html`
<sp-toast
variant="positive"
open
@close=${() => {
closeSpy();
}}
>
This toast maintains variants.
</sp-toast>
`);
await elementUpdated(el);

@@ -250,8 +226,6 @@ expect(el.open).to.be.true;

});
it('sp close button renders with static="white"', async () => {
const el = await fixture(
html`
<sp-toast open>Help text.</sp-toast>
`
);
it('sp close button renders with static-color="white"', async () => {
const el = await fixture(html`
<sp-toast open>Help text.</sp-toast>
`);
const renderRoot = el.shadowRoot ? el.shadowRoot : el;

@@ -262,5 +236,5 @@ const closeButton = renderRoot.querySelector(

expect(closeButton).to.exist;
expect(closeButton.getAttribute("static")).to.equal("white");
expect(closeButton.getAttribute("static-color")).to.equal("white");
});
});
//# sourceMappingURL=toast.test.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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