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

@radix-ui/react-announce

Package Overview
Dependencies
Maintainers
5
Versions
161
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@radix-ui/react-announce - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

3

dist/index.d.ts
import * as React from "react";
import { Primitive } from "@radix-ui/react-primitive";
import * as Polymorphic from "@radix-ui/react-polymorphic";
import { Merge } from "@radix-ui/utils";
type RegionType = 'polite' | 'assertive' | 'off';
type RegionRole = 'status' | 'alert' | 'log' | 'none';
type AriaRelevantOptions = 'additions' | 'removals' | 'text';
type AnnounceOwnProps = Merge<Polymorphic.OwnProps<typeof Primitive>, {
type AnnounceOwnProps = Polymorphic.Merge<Polymorphic.OwnProps<typeof Primitive>, {
/**

@@ -10,0 +9,0 @@ * Mirrors the `aria-atomic` DOM attribute for live regions. It is an optional attribute that

@@ -1,2 +0,2 @@

var e,t,r,n=require("@radix-ui/react-primitive").Primitive,i=require("@radix-ui/react-utils"),o=i.useComposedRefs,a=i.useLayoutEffect,u=require("@radix-ui/utils").getSelector,l=(e=require("react-dom"))&&e.__esModule?e.default:e,c=(t={},r=require("react"),Object.keys(r).forEach((function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})})),t);function f(){return(f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function s(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,i=!1,o=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{n||null==u.return||u.return()}finally{if(i)throw o}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return d(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function v(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var y={polite:"status",assertive:"alert",off:"none"},p=new Map,b=c.forwardRef((function(e,t){var r=e.selector,i=void 0===r?u("Announce"):r,d=e["aria-relevant"],b=e.children,h=e.type,g=void 0===h?"polite":h,A=e.role,O=void 0===A?y[g]:A,j=e.regionIdentifier,w=v(e,["selector","aria-relevant","children","type","role","regionIdentifier"]),S=["true",!0].includes(w["aria-atomic"]),x=c.useRef(document),E=c.useCallback((function(e){e&&(x.current=e.ownerDocument)}),[]),q=c.useRef(null),I=o(t,q,E),P=s(c.useState(),2),R=P[0],C=P[1],k=d?Array.isArray(d)?d.join(" "):d:void 0,M=c.useCallback((function(){var e=x.current,t={type:g,role:O,relevant:k,id:j,atomic:S},r=function(e){var t=e.type,r=e.relevant,n=e.role,i=e.atomic,o=e.id;return"[".concat(m(o),"]").concat([["aria-live",t],["aria-atomic",i],["aria-relevant",r],["role",n]].filter((function(e){return!!s(e,2)[1]})).map((function(e){var t=s(e,2),r=t[0],n=t[1];return"[".concat(r,"=").concat(n,"]")})).join(""))}(t);return e.querySelector(r)||function(e,t){var r=t.type,n=t.relevant,i=t.role,o=t.atomic,a=t.id,u=e.createElement("div");u.setAttribute(m(a),""),u.setAttribute("style","position: absolute; top: -1px; width: 1px; height: 1px; overflow: hidden;"),e.body.appendChild(u),u.setAttribute("aria-live",r),u.setAttribute("aria-atomic",String(o||!1)),u.setAttribute("role",i),n&&u.setAttribute("aria-relevant",n);return u}(e,t)}),[S,k,O,g,j]);return a((function(){C(M())}),[M]),c.useEffect((function(){var e=x.current;function t(){r.setAttribute("role",e.hidden?"none":O),r.setAttribute("aria-live",e.hidden?"off":g)}var r=M();if(p.get(r)){var n=p.get(r);p.set(r,n+1)}else e.addEventListener("visibilitychange",t),p.set(r,1);return function(){var n=p.get(r);p.set(r,n-1),1===n&&e.removeEventListener("visibilitychange",t)}}),[M,O,g]),c.createElement(c.Fragment,null,c.createElement(n,f({},w,{selector:i,ref:I}),b),R&&l.createPortal(c.createElement("div",null,b),R))}));function m(e){return"data-"+u("AnnounceRegion")+(e?"-".concat(e):"")}exports.Announce=b,b.displayName="Announce";var h=b;exports.Root=h;
var e,t,r,n=require("@radix-ui/react-use-layout-effect").useLayoutEffect,i=require("@radix-ui/react-primitive").Primitive,a=require("@radix-ui/react-compose-refs").useComposedRefs,o=(e=require("react-dom"))&&e.__esModule?e.default:e,u=(t={},r=require("react"),Object.keys(r).forEach((function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})})),t);function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function l(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,i=!1,a=void 0;try{for(var o,u=e[Symbol.iterator]();!(n=(o=u.next()).done)&&(r.push(o.value),!t||r.length!==t);n=!0);}catch(e){i=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(i)throw a}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return f(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return f(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function s(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var d={polite:"status",assertive:"alert",off:"none"},v=new Map,y=u.forwardRef((function(e,t){var r=e["aria-relevant"],f=e.children,y=e.type,b=void 0===y?"polite":y,m=e.role,h=void 0===m?d[b]:m,g=e.regionIdentifier,A=s(e,["aria-relevant","children","type","role","regionIdentifier"]),O=["true",!0].includes(A["aria-atomic"]),j=u.useRef(document),w=u.useCallback((function(e){e&&(j.current=e.ownerDocument)}),[]),x=u.useRef(null),E=a(t,x,w),S=l(u.useState(),2),q=S[0],I=S[1],P=r?Array.isArray(r)?r.join(" "):r:void 0,C=u.useCallback((function(){var e=j.current,t={type:b,role:h,relevant:P,id:g,atomic:O},r=function(e){var t=e.type,r=e.relevant,n=e.role,i=e.atomic,a=e.id;return"[".concat(p(a),"]").concat([["aria-live",t],["aria-atomic",i],["aria-relevant",r],["role",n]].filter((function(e){return!!l(e,2)[1]})).map((function(e){var t=l(e,2),r=t[0],n=t[1];return"[".concat(r,"=").concat(n,"]")})).join(""))}(t);return e.querySelector(r)||function(e,t){var r=t.type,n=t.relevant,i=t.role,a=t.atomic,o=t.id,u=e.createElement("div");u.setAttribute(p(o),""),u.setAttribute("style","position: absolute; top: -1px; width: 1px; height: 1px; overflow: hidden;"),e.body.appendChild(u),u.setAttribute("aria-live",r),u.setAttribute("aria-atomic",String(a||!1)),u.setAttribute("role",i),n&&u.setAttribute("aria-relevant",n);return u}(e,t)}),[O,P,h,b,g]);return n((function(){I(C())}),[C]),u.useEffect((function(){var e=j.current;function t(){r.setAttribute("role",e.hidden?"none":h),r.setAttribute("aria-live",e.hidden?"off":b)}var r=C();if(v.get(r)){var n=v.get(r);v.set(r,n+1)}else e.addEventListener("visibilitychange",t),v.set(r,1);return function(){var n=v.get(r);v.set(r,n-1),1===n&&e.removeEventListener("visibilitychange",t)}}),[C,h,b]),u.createElement(u.Fragment,null,u.createElement(i,c({},A,{ref:E}),f),q&&o.createPortal(u.createElement("div",null,f),q))}));function p(e){return"data-radix-announce-region"+(e?"-".concat(e):"")}exports.Announce=y,y.displayName="Announce";var b=y;exports.Root=b;
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import{Primitive as e}from"@radix-ui/react-primitive";import{useComposedRefs as t,useLayoutEffect as r}from"@radix-ui/react-utils";import{getSelector as n}from"@radix-ui/utils";import i from"react-dom";import*as o from"react";function a(){return(a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function c(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}const l={polite:"status",assertive:"alert",off:"none"},u=new Map,s="Announce";export const Announce=o.forwardRef(((p,d)=>{const{selector:m=n(s),"aria-relevant":v,children:b,type:y="polite",role:g=l[y],regionIdentifier:h}=p,A=c(p,["selector","aria-relevant","children","type","role","regionIdentifier"]),O=["true",!0].includes(A["aria-atomic"]),x=o.useRef(document),j=o.useCallback((e=>{e&&(x.current=e.ownerDocument)}),[]),w=o.useRef(null),E=t(d,w,j),[R,S]=o.useState(),P=v?Array.isArray(v)?v.join(" "):v:void 0,k=o.useCallback((()=>{const e=x.current,t={type:y,role:g,relevant:P,id:h,atomic:O},r=function({type:e,relevant:t,role:r,atomic:n,id:i}){return"[".concat(f(i),"]").concat([["aria-live",e],["aria-atomic",n],["aria-relevant",t],["role",r]].filter((([,e])=>!!e)).map((([e,t])=>"[".concat(e,"=").concat(t,"]"))).join(""))}(t);return e.querySelector(r)||function(e,{type:t,relevant:r,role:n,atomic:i,id:o}){const a=e.createElement("div");a.setAttribute(f(o),""),a.setAttribute("style","position: absolute; top: -1px; width: 1px; height: 1px; overflow: hidden;"),e.body.appendChild(a),a.setAttribute("aria-live",t),a.setAttribute("aria-atomic",String(i||!1)),a.setAttribute("role",n),r&&a.setAttribute("aria-relevant",r);return a}(e,t)}),[O,P,g,y,h]);return r((()=>{S(k())}),[k]),o.useEffect((()=>{const e=x.current;function t(){r.setAttribute("role",e.hidden?"none":g),r.setAttribute("aria-live",e.hidden?"off":y)}const r=k();if(u.get(r)){const e=u.get(r);u.set(r,e+1)}else e.addEventListener("visibilitychange",t),u.set(r,1);return function(){const n=u.get(r);u.set(r,n-1),1===n&&e.removeEventListener("visibilitychange",t)}}),[k,g,y]),o.createElement(o.Fragment,null,o.createElement(e,a({},A,{selector:m,ref:E}),b),R&&i.createPortal(o.createElement("div",null,b),R))}));function f(e){return"data-"+n(s+"Region")+(e?"-".concat(e):"")}Announce.displayName=s;export const Root=Announce;
import{useLayoutEffect as e}from"@radix-ui/react-use-layout-effect";import{Primitive as t}from"@radix-ui/react-primitive";import{useComposedRefs as r}from"@radix-ui/react-compose-refs";import n from"react-dom";import*as i from"react";function o(){return(o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}const a={polite:"status",assertive:"alert",off:"none"},c=new Map;export const Announce=i.forwardRef(((l,s)=>{const{"aria-relevant":f,children:d,type:p="polite",role:m=a[p],regionIdentifier:v,...b}=l,y=["true",!0].includes(b["aria-atomic"]),A=i.useRef(document),h=i.useCallback((e=>{e&&(A.current=e.ownerDocument)}),[]),g=i.useRef(null),x=r(s,g,h),[E,w]=i.useState(),j=f?Array.isArray(f)?f.join(" "):f:void 0,R=i.useCallback((()=>{const e=A.current,t={type:p,role:m,relevant:j,id:v,atomic:y},r=function({type:e,relevant:t,role:r,atomic:n,id:i}){return"[".concat(u(i),"]").concat([["aria-live",e],["aria-atomic",n],["aria-relevant",t],["role",r]].filter((([,e])=>!!e)).map((([e,t])=>"[".concat(e,"=").concat(t,"]"))).join(""))}(t);return e.querySelector(r)||function(e,{type:t,relevant:r,role:n,atomic:i,id:o}){const a=e.createElement("div");a.setAttribute(u(o),""),a.setAttribute("style","position: absolute; top: -1px; width: 1px; height: 1px; overflow: hidden;"),e.body.appendChild(a),a.setAttribute("aria-live",t),a.setAttribute("aria-atomic",String(i||!1)),a.setAttribute("role",n),r&&a.setAttribute("aria-relevant",r);return a}(e,t)}),[y,j,m,p,v]);return e((()=>{w(R())}),[R]),i.useEffect((()=>{const e=A.current;function t(){r.setAttribute("role",e.hidden?"none":m),r.setAttribute("aria-live",e.hidden?"off":p)}const r=R();if(c.get(r)){const e=c.get(r);c.set(r,e+1)}else e.addEventListener("visibilitychange",t),c.set(r,1);return function(){const n=c.get(r);c.set(r,n-1),1===n&&e.removeEventListener("visibilitychange",t)}}),[R,m,p]),i.createElement(i.Fragment,null,i.createElement(t,o({},b,{ref:x}),d),E&&n.createPortal(i.createElement("div",null,d),E))}));function u(e){return"data-radix-announce-region"+(e?"-".concat(e):"")}Announce.displayName="Announce";export const Root=Announce;
//# sourceMappingURL=index.module.js.map
{
"name": "@radix-ui/react-announce",
"version": "0.0.5",
"version": "0.0.6",
"license": "MIT",

@@ -19,6 +19,6 @@ "source": "src/index.ts",

"dependencies": {
"@radix-ui/react-polymorphic": "0.0.5",
"@radix-ui/react-primitive": "0.0.4",
"@radix-ui/react-utils": "0.0.5",
"@radix-ui/utils": "0.0.3"
"@radix-ui/react-compose-refs": "0.0.1",
"@radix-ui/react-polymorphic": "0.0.6",
"@radix-ui/react-primitive": "0.0.5",
"@radix-ui/react-use-layout-effect": "0.0.1"
},

@@ -25,0 +25,0 @@ "peerDependencies": {

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