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

@primer/live-region-element

Package Overview
Dependencies
Maintainers
11
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@primer/live-region-element - npm Package Compare versions

Comparing version 0.5.1 to 0.6.0

18

dist/esm/index.js

@@ -153,3 +153,3 @@ const Ordering = {

var _pending, _queue, _timeoutId, _performWork, performWork_fn, _updateContainerWithMessage, updateContainerWithMessage_fn;
const DEFAULT_THROTTLE_DELAY_MS = 500;
const DEFAULT_THROTTLE_DELAY_MS = 150;
class LiveRegionElement extends HTMLElement {

@@ -346,18 +346,6 @@ constructor() {

if (a.politeness === "assertive" && b.politeness !== "assertive") {
if (a.scheduled === b.scheduled) {
return Ordering.Less;
}
if (a.scheduled < b.scheduled) {
return Ordering.Less;
}
return Ordering.Greater;
return Ordering.Less;
}
if (a.politeness !== "assertive" && b.politeness === "assertive") {
if (a.scheduled === b.scheduled) {
return Ordering.Greater;
}
if (a.scheduled > b.scheduled) {
return Ordering.Greater;
}
return Ordering.Less;
return Ordering.Greater;
}

@@ -364,0 +352,0 @@ return Ordering.Equal;

13

dist/esm/live-region-element.d.ts

@@ -5,6 +5,2 @@ import { type Order } from './order';

/**
* A delay in milliseconds to wait before announcing a message.
*/
delayMs?: number;
/**
* The politeness level for a message.

@@ -19,3 +15,10 @@ *

*/
politeness?: Politeness;
politeness?: 'assertive';
/**
* A delay in milliseconds to wait before announcing a message.
*/
delayMs?: never;
} | {
politeness?: 'polite';
delayMs?: number;
};

@@ -22,0 +25,0 @@ type Message = {

@@ -155,3 +155,3 @@ import { HTMLElement, customElements } from '@lit-labs/ssr-dom-shim';

var _pending, _queue, _timeoutId, _performWork, performWork_fn, _updateContainerWithMessage, updateContainerWithMessage_fn;
const DEFAULT_THROTTLE_DELAY_MS = 500;
const DEFAULT_THROTTLE_DELAY_MS = 150;
class LiveRegionElement extends (globalThis.HTMLElement ?? HTMLElement) {

@@ -348,18 +348,6 @@ constructor() {

if (a.politeness === "assertive" && b.politeness !== "assertive") {
if (a.scheduled === b.scheduled) {
return Ordering.Less;
}
if (a.scheduled < b.scheduled) {
return Ordering.Less;
}
return Ordering.Greater;
return Ordering.Less;
}
if (a.politeness !== "assertive" && b.politeness === "assertive") {
if (a.scheduled === b.scheduled) {
return Ordering.Greater;
}
if (a.scheduled > b.scheduled) {
return Ordering.Greater;
}
return Ordering.Less;
return Ordering.Greater;
}

@@ -366,0 +354,0 @@ return Ordering.Equal;

{
"name": "@primer/live-region-element",
"version": "0.5.1",
"version": "0.6.0",
"type": "module",

@@ -5,0 +5,0 @@ "main": "./dist/esm/index.js",

@@ -50,20 +50,2 @@ # live-region-element

### Defining `live-region` as a custom element
The `@primer/live-region-element` package provides an entrypoint that you can use to define the `live-region` custom element.
```ts
import '@primer/live-region-element/define`
```
If you prefer to define the custom element directly, import `LiveRegionElement` directly from the package and use that to define the `live-region` element. For example:
```ts
import {LiveRegionElement} from '@primer/live-region-element'
if (!customElements.get('live-region')) {
customElements.define('live-region', LiveRegionElement)
}
```
### Declarative Shadow DOM

@@ -94,2 +76,53 @@

### Delaying announcements
Both `announce` and `announceFromElement` provide support for announcing
messages at a later point in time. In the example below, we are waiting five
seconds before announcing the message.
```ts
import {announce} from '@primer/live-region-element'
announce('Example message', {
delayMs: 5000,
})
```
### Canceling announcements
Any announcements made with `announce` and `announceFromElement` may be
cancelled. This may be useful if a delayed announcements has become outdated. To
cancel an announcement, call the return value of either method.
```ts
import {announce} from '@primer/live-region-element'
const cancel = announce('Example message', {
delayMs: 5000,
})
// At some point before five seconds, call:
cancel()
```
If you would like to clear all announcements, like when transitioning between
routes, you can call the `clear()` method on an existing `LiveRegionElement`.
```ts
const liveRegion = document.querySelector('live-region')
// Send example messages
liveRegion.announce('Example polite message', {
delayMs: 1000,
politeness: 'polite',
})
liveRegion.announce('Example polite message', {
delayMs: 1000,
politeness: 'polite',
})
// Clear all pending messages
liveRegion.clear()
```
## 🙌 Contributing

@@ -96,0 +129,0 @@

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