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

react-ghosta

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-ghosta - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

2

dist/index.js

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

var Z=Object.defineProperty;var q=(t,e)=>{for(var o in e)Z(t,o,{get:e[o],enumerable:!0})};import*as m from"react";var g={ghosta:null,register(t){!this.ghosta&&"id"in t&&(this.ghosta=t)},unregister(t){this.ghosta&&this.ghosta.id===t&&(this.ghosta=null)},get(){return this.ghosta}};function b(t=1,e=9999){return Math.floor(Math.random()*(e-t)+t)}function A(t){return Object.entries(t||{}).reduce((e,[o,i])=>(e[`--ba-${Q(o)}`]=i,e),{})}function Q(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function B(t){return t.constructor.name==="AsyncFunction"?!0:t()instanceof Promise}import*as p from"react";import{Dialog as I,Transition as k}from"@headlessui/react";import{cx as x}from"class-variance-authority";import E from"react";var U=({...t})=>E.createElement("svg",{width:"24px",height:"24px",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2","aria-hidden":"true",...t},E.createElement("path",{d:"M18 6L6 18M6 6l12 12"})),T=U;import{cva as M}from"class-variance-authority";var O=M("",{variants:{size:{sm:"ghosta--sm",md:"ghosta--md",lg:"ghosta--lg"},alignment:{left:"ghosta__text--left",center:"ghosta__text--center",right:"ghosta__text--right"}},defaultVariants:{alignment:"center",size:"md"}}),w=M("",{variants:{alignment:{left:"ghosta__align--start",center:"ghosta__align--center",right:"ghosta__align--end"}},defaultVariants:{alignment:"center"}});var _=p.createContext({}),V,N=({id:t,isVisible:e,alignment:o,size:i,children:l,showCloseButton:a,colors:h,classNames:s,showBackdrop:n=!0,preventClose:u,onClose:r})=>{let[c,f]=p.useState(e),S=()=>{u||(f(!1),V=setTimeout(r,250))};return p.useEffect(()=>{f(e)},[e]),p.useEffect(()=>()=>clearTimeout(V),[]),e?p.createElement(_.Provider,{value:{id:t,isVisible:e,alignment:o,size:i,children:l,colors:h,classNames:s,onClose:S}},p.createElement(k,{as:I,show:c,onClose:S,className:x("ghosta ghosta--root",O({size:i,alignment:o})),style:A(h),appear:!0,unmount:!0},n&&p.createElement(k.Child,{as:"div",className:x("ghosta__backdrop",s==null?void 0:s.backdrop),"aria-hidden":"true",enter:"ghosta__backdrop--enter",enterFrom:"ghosta__backdrop--enterFrom",enterTo:"ghosta__backdrop--enterTo",leave:"ghosta__backdrop--leave",leaveFrom:"ghosta__backdrop--leaveFrom",leaveTo:"ghosta__backdrop--leaveTo"}),p.createElement("div",{className:"ghosta__scroll-container"},p.createElement(k.Child,{as:I.Panel,className:x("ghosta__panel",s==null?void 0:s.panel,c?"ghosta__panel--entered":"ghosta__panel--leaved"),enter:"ghosta__panel--enter",enterFrom:"ghosta__panel--enterFrom",enterTo:"ghosta__panel--enterTo",leave:"ghosta__panel--leave",leaveFrom:"ghosta__panel--leaveFrom",leaveTo:"ghosta__panel--leaveTo"},a?p.createElement("button",{className:x("ghosta__close-button",s==null?void 0:s.closeButton),"aria-label":"Close",onClick:S},p.createElement(T,null)):null,l)))):null},H=N;import*as G from"react";import{cx as F}from"class-variance-authority";var tt=({title:t,description:e})=>{let{classNames:o}=G.useContext(_);return!t||!e?null:G.createElement("div",{className:F("ghosta__header",o==null?void 0:o.panelHeader)},t?G.createElement("div",{className:F("ghosta__header__title",o==null?void 0:o.title)},t):null,e?G.createElement("div",{className:F("ghosta__header__desc",o==null?void 0:o.description)},e):null)},L=tt;import*as d from"react";import{Dialog as ot}from"@headlessui/react";import{cx as y}from"class-variance-authority";var et=({title:t,description:e,icon:o,content:i})=>{let{alignment:l,classNames:a}=d.useContext(_);return!t&&!e&&!o&&!i?d.createElement("div",{className:"ghosta__nocontent"}):d.createElement("div",{className:y("ghosta__content",w({alignment:l}),a==null?void 0:a.panelBody)},o?d.createElement("div",{className:y("ghosta__content__icon",a==null?void 0:a.icon)},o):null,t?d.createElement(ot.Title,{className:y("ghosta__content__title",a==null?void 0:a.title)},t):null,e?d.createElement("div",{className:y("ghosta__content__desc",a==null?void 0:a.description)},e):null,i?d.createElement("div",{className:"ghosta__content__content"},i):null)},z=et;import*as v from"react";import{cx as pt}from"class-variance-authority";import*as C from"react";import{cx as it}from"class-variance-authority";import*as P from"react";var rt=t=>P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"currentColor",...t},P.createElement("style",null,"@keyframes spinner_MGfb{93.75%,to{opacity:.2}}.spinner_S1WN{animation:spinner_MGfb .8s linear infinite;animation-delay:-.8s}"),P.createElement("circle",{cx:4,cy:12,r:3,className:"spinner_S1WN"}),P.createElement("circle",{cx:12,cy:12,r:3,className:"spinner_S1WN",style:{animationDelay:"-.65s"}}),P.createElement("circle",{cx:20,cy:12,r:3,className:"spinner_S1WN",style:{animationDelay:"-.5s"}})),D=rt;import{cva as W,cx as nt}from"class-variance-authority";var at=W("",{variants:{variant:{default:"ghosta__button--default",primary:"ghosta__button--primary",success:"ghosta__button--success",danger:"ghosta__button--danger"},size:{sm:"ghosta__button--sm",md:"ghosta__button--md",lg:"ghosta__button--lg"}},defaultVariants:{variant:"default",size:"lg"}}),j=({variant:t,size:e,classNames:o})=>nt(at({variant:t,size:e}),W(o==null?void 0:o.base,{variants:{variant:{...o==null?void 0:o.variants},size:{...o==null?void 0:o.sizes}}})({variant:t,size:e}));var st=({variant:t,size:e,children:o,className:i,classNames:l,isFilled:a,isLoading:h,...s})=>C.createElement("button",{className:it("ghosta__button",j({variant:t,size:e,classNames:l}),a&&"ghosta__button--filled",i),...s},o,h?C.createElement("span",{className:"ghosta__button__spinner"},C.createElement(D,null)):null),X=st;var lt=({buttons:t})=>{let{onClose:e,classNames:o,id:i}=v.useContext(_),[l,a]=v.useState({}),h=(n,u)=>{a(r=>({...r,[n]:u}))},s=async(n,u)=>{var c,f;let r={popupId:i,onClose:e};if(B(n.onClick))try{h(u,!0),await((c=n.onClick)==null?void 0:c.call(n,r))}finally{n.preventClose||e==null||e(),h(u,!1)}else n.preventClose||e==null||e(),(f=n.onClick)==null||f.call(n,r)};return t!=null&&t.length?v.createElement("div",{className:pt("ghosta__footer",o==null?void 0:o.panelFooter)},t==null?void 0:t.map((n,u)=>v.createElement(X,{key:u,variant:n.variant,size:n.size,isFilled:n.isFilled,isLoading:l[u],classNames:o==null?void 0:o.button,onClick:()=>s(n,u)},n.title))):null},$=lt;var ut=({classNames:t,colors:e,animationOptions:o})=>{let[i,l]=m.useState([]),a=r=>{l(c=>c.concat({...r,id:b()}))},h=r=>{l(c=>c.filter(f=>f.id!==r))},s=()=>{l([])},n=m.useRef({id:b(),fire:a,close:h,closeAll:s});if(m.useEffect(()=>{if(!n.current)return;let r=n.current.id;return g.register(n.current),()=>{g.unregister(r)}},[]),!i.length)return null;let u=i.length;return i.map((r,c)=>(r.preventClose===void 0&&(r.preventClose=c<u-1),m.createElement(H,{key:r.id,isVisible:!0,onClose:()=>h(r.id),...r,colors:Object.assign({},e,r.colors),classNames:Object.assign({},t,r.classNames),animationOptions:o},m.createElement(L,{title:r.headerTitle,description:r.headerDescription}),m.createElement(z,{title:r.title,description:r.description,icon:r.icon,content:r.content}),m.createElement($,{buttons:r.buttons}))))},ct=ut;var Y={};q(Y,{closeAll:()=>K,fire:()=>J});var R={REGISTER:"You should add <Ghosta /> top of your app to regitster"};var J=t=>{let e=g.get();if(!e)return console.warn(R.REGISTER);e.fire(t)};var K=()=>{let t=g.get();if(!t)return console.warn(R.REGISTER);t.closeAll()};export{ct as Ghosta,Y as ghosta};
var Z=Object.defineProperty;var q=(t,e)=>{for(var o in e)Z(t,o,{get:e[o],enumerable:!0})};import*as m from"react";var f={ghosta:null,register(t){!this.ghosta&&"id"in t&&(this.ghosta=t)},unregister(t){this.ghosta&&this.ghosta.id===t&&(this.ghosta=null)},get(){return this.ghosta}};function b(t=1,e=9999){return Math.floor(Math.random()*(e-t)+t)}function A(t){return Object.entries(t||{}).reduce((e,[o,i])=>(e[`--ba-${Q(o)}`]=i,e),{})}function Q(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function B(t){var o;return typeof t!="function"?!1:((o=t==null?void 0:t.constructor)==null?void 0:o.name)==="AsyncFunction"?!0:t()instanceof Promise}import*as p from"react";import{Dialog as I,Transition as k}from"@headlessui/react";import{cx as P}from"class-variance-authority";import E from"react";var U=({...t})=>E.createElement("svg",{width:"24px",height:"24px",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2","aria-hidden":"true",...t},E.createElement("path",{d:"M18 6L6 18M6 6l12 12"})),T=U;import{cva as M}from"class-variance-authority";var O=M("",{variants:{size:{sm:"ghosta--sm",md:"ghosta--md",lg:"ghosta--lg"},alignment:{left:"ghosta__text--left",center:"ghosta__text--center",right:"ghosta__text--right"}},defaultVariants:{alignment:"center",size:"md"}}),w=M("",{variants:{alignment:{left:"ghosta__align--start",center:"ghosta__align--center",right:"ghosta__align--end"}},defaultVariants:{alignment:"center"}});var _=p.createContext({}),V,N=({id:t,isVisible:e,alignment:o,size:i,children:l,showCloseButton:a,colors:h,classNames:s,showBackdrop:n=!0,preventClose:u,onClose:r})=>{let[c,g]=p.useState(e),S=()=>{u||(g(!1),V=setTimeout(r,250))};return p.useEffect(()=>{g(e)},[e]),p.useEffect(()=>()=>clearTimeout(V),[]),e?p.createElement(_.Provider,{value:{id:t,isVisible:e,alignment:o,size:i,children:l,colors:h,classNames:s,onClose:S}},p.createElement(k,{as:I,show:c,onClose:S,className:P("ghosta ghosta--root",O({size:i,alignment:o})),style:A(h),appear:!0,unmount:!0},n&&p.createElement(k.Child,{as:"div",className:P("ghosta__backdrop",s==null?void 0:s.backdrop),"aria-hidden":"true",enter:"ghosta__backdrop--enter",enterFrom:"ghosta__backdrop--enterFrom",enterTo:"ghosta__backdrop--enterTo",leave:"ghosta__backdrop--leave",leaveFrom:"ghosta__backdrop--leaveFrom",leaveTo:"ghosta__backdrop--leaveTo"}),p.createElement("div",{className:"ghosta__scroll-container"},p.createElement(k.Child,{as:I.Panel,className:P("ghosta__panel",s==null?void 0:s.panel,c?"ghosta__panel--entered":"ghosta__panel--leaved"),enter:"ghosta__panel--enter",enterFrom:"ghosta__panel--enterFrom",enterTo:"ghosta__panel--enterTo",leave:"ghosta__panel--leave",leaveFrom:"ghosta__panel--leaveFrom",leaveTo:"ghosta__panel--leaveTo"},a?p.createElement("button",{className:P("ghosta__close-button",s==null?void 0:s.closeButton),"aria-label":"Close",onClick:S},p.createElement(T,null)):null,l)))):null},H=N;import*as y from"react";import{cx as F}from"class-variance-authority";var tt=({title:t,description:e})=>{let{classNames:o}=y.useContext(_);return!t||!e?null:y.createElement("div",{className:F("ghosta__header",o==null?void 0:o.panelHeader)},t?y.createElement("div",{className:F("ghosta__header__title",o==null?void 0:o.title)},t):null,e?y.createElement("div",{className:F("ghosta__header__desc",o==null?void 0:o.description)},e):null)},L=tt;import*as d from"react";import{Dialog as ot}from"@headlessui/react";import{cx as x}from"class-variance-authority";var et=({title:t,description:e,icon:o,content:i})=>{let{alignment:l,classNames:a}=d.useContext(_);return!t&&!e&&!o&&!i?d.createElement("div",{className:"ghosta__nocontent"}):d.createElement("div",{className:x("ghosta__content",w({alignment:l}),a==null?void 0:a.panelBody)},o?d.createElement("div",{className:x("ghosta__content__icon",a==null?void 0:a.icon)},o):null,t?d.createElement(ot.Title,{className:x("ghosta__content__title",a==null?void 0:a.title)},t):null,e?d.createElement("div",{className:x("ghosta__content__desc",a==null?void 0:a.description)},e):null,i?d.createElement("div",{className:"ghosta__content__content"},i):null)},z=et;import*as v from"react";import{cx as pt}from"class-variance-authority";import*as C from"react";import{cx as it}from"class-variance-authority";import*as G from"react";var rt=t=>G.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"currentColor",...t},G.createElement("style",null,"@keyframes spinner_MGfb{93.75%,to{opacity:.2}}.spinner_S1WN{animation:spinner_MGfb .8s linear infinite;animation-delay:-.8s}"),G.createElement("circle",{cx:4,cy:12,r:3,className:"spinner_S1WN"}),G.createElement("circle",{cx:12,cy:12,r:3,className:"spinner_S1WN",style:{animationDelay:"-.65s"}}),G.createElement("circle",{cx:20,cy:12,r:3,className:"spinner_S1WN",style:{animationDelay:"-.5s"}})),D=rt;import{cva as W,cx as nt}from"class-variance-authority";var at=W("",{variants:{variant:{default:"ghosta__button--default",primary:"ghosta__button--primary",success:"ghosta__button--success",danger:"ghosta__button--danger"},size:{sm:"ghosta__button--sm",md:"ghosta__button--md",lg:"ghosta__button--lg"}},defaultVariants:{variant:"default",size:"lg"}}),j=({variant:t,size:e,classNames:o})=>nt(at({variant:t,size:e}),W(o==null?void 0:o.base,{variants:{variant:{...o==null?void 0:o.variants},size:{...o==null?void 0:o.sizes}}})({variant:t,size:e}));var st=({variant:t,size:e,children:o,className:i,classNames:l,isFilled:a,isLoading:h,...s})=>C.createElement("button",{className:it("ghosta__button",j({variant:t,size:e,classNames:l}),a&&"ghosta__button--filled",i),...s},o,h?C.createElement("span",{className:"ghosta__button__spinner"},C.createElement(D,null)):null),X=st;var lt=({buttons:t})=>{let{onClose:e,classNames:o,id:i}=v.useContext(_),[l,a]=v.useState({}),h=(n,u)=>{a(r=>({...r,[n]:u}))},s=async(n,u)=>{var c,g;let r={popupId:i,onClose:e};if(B(n.onClick))try{h(u,!0),await((c=n.onClick)==null?void 0:c.call(n,r))}finally{n.preventClose||e==null||e(),h(u,!1)}else n.preventClose||e==null||e(),(g=n.onClick)==null||g.call(n,r)};return t!=null&&t.length?v.createElement("div",{className:pt("ghosta__footer",o==null?void 0:o.panelFooter)},t==null?void 0:t.map((n,u)=>v.createElement(X,{key:u,variant:n.variant,size:n.size,isFilled:n.isFilled,isLoading:l[u],classNames:o==null?void 0:o.button,onClick:()=>s(n,u)},n.title))):null},$=lt;var ut=({classNames:t,colors:e,animationOptions:o})=>{let[i,l]=m.useState([]),a=r=>{l(c=>c.concat({...r,id:b()}))},h=r=>{l(c=>c.filter(g=>g.id!==r))},s=()=>{l([])},n=m.useRef({id:b(),fire:a,close:h,closeAll:s});if(m.useEffect(()=>{if(!n.current)return;let r=n.current.id;return f.register(n.current),()=>{f.unregister(r)}},[]),!i.length)return null;let u=i.length;return i.map((r,c)=>(r.preventClose===void 0&&(r.preventClose=c<u-1),m.createElement(H,{key:r.id,isVisible:!0,onClose:()=>h(r.id),...r,colors:Object.assign({},e,r.colors),classNames:Object.assign({},t,r.classNames),animationOptions:o},m.createElement(L,{title:r.headerTitle,description:r.headerDescription}),m.createElement(z,{title:r.title,description:r.description,icon:r.icon,content:r.content}),m.createElement($,{buttons:r.buttons}))))},ct=ut;var Y={};q(Y,{closeAll:()=>K,fire:()=>J});var R={REGISTER:"You should add <Ghosta /> top of your app to regitster"};var J=t=>{let e=f.get();if(!e)return console.warn(R.REGISTER);e.fire(t)};var K=()=>{let t=f.get();if(!t)return console.warn(R.REGISTER);t.closeAll()};export{ct as Ghosta,Y as ghosta};
//# sourceMappingURL=index.js.map
{
"name": "react-ghosta",
"version": "1.2.1",
"version": "1.2.2",
"type": "module",

@@ -5,0 +5,0 @@ "description": "React popup alerts. Lightweight, customizable and beautiful by default.",

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