Socket
Socket
Sign inDemoInstall

react-ghosta

Package Overview
Dependencies
11
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.2 to 1.2.3

3

dist/index.d.ts

@@ -73,5 +73,4 @@ import { VariantProps } from 'class-variance-authority';

};
type GhostaOptions = {
type GhostaOptions = Partial<{
id: number;
} & Partial<{
title: string;

@@ -78,0 +77,0 @@ description: string;

@@ -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 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};
var Z=Object.defineProperty;var q=(t,e)=>{for(var o in e)Z(t,o,{get:e[o],enumerable:!0})};import*as h 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:d,classNames:s,showBackdrop:n=!0,preventClose:u,onClose:r})=>{let[c,m]=p.useState(e),S=()=>{u||(m(!1),V=setTimeout(r,250))};return p.useEffect(()=>{m(e)},[e]),p.useEffect(()=>()=>clearTimeout(V),[]),e?p.createElement(_.Provider,{value:{id:t,isVisible:e,alignment:o,size:i,children:l,colors:d,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(d),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 g 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}=g.useContext(_);return!t&&!e&&!o&&!i?g.createElement("div",{className:"ghosta__nocontent"}):g.createElement("div",{className:x("ghosta__content",w({alignment:l}),a==null?void 0:a.panelBody)},o?g.createElement("div",{className:x("ghosta__content__icon",a==null?void 0:a.icon)},o):null,t?g.createElement(ot.Title,{className:x("ghosta__content__title",a==null?void 0:a.title)},t):null,e?g.createElement("div",{className:x("ghosta__content__desc",a==null?void 0:a.description)},e):null,i?g.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:d,...s})=>C.createElement("button",{className:it("ghosta__button",j({variant:t,size:e,classNames:l}),a&&"ghosta__button--filled",i),...s},o,d?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({}),d=(n,u)=>{a(r=>({...r,[n]:u}))},s=async(n,u)=>{var c,m;let r={popupId:i,onClose:e};if(B(n.onClick))try{d(u,!0),await((c=n.onClick)==null?void 0:c.call(n,r))}finally{n.preventClose||e==null||e(),d(u,!1)}else n.preventClose||e==null||e(),(m=n.onClick)==null||m.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]=h.useState([]),a=r=>{l(c=>c.concat({...r,id:b()}))},d=r=>{l(c=>c.filter(m=>m.id!==r))},s=()=>{l([])},n=h.useRef({id:b(),fire:a,close:d,closeAll:s});if(h.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)=>{let m=r.id;return r.preventClose===void 0&&(r.preventClose=c<u-1),h.createElement(H,{key:m,isVisible:!0,onClose:()=>d(m),...r,id:m,colors:Object.assign({},e,r.colors),classNames:Object.assign({},t,r.classNames),animationOptions:o},h.createElement(L,{title:r.headerTitle,description:r.headerDescription}),h.createElement(z,{title:r.title,description:r.description,icon:r.icon,content:r.content}),h.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.2",
"version": "1.2.3",
"type": "module",

@@ -11,2 +11,3 @@ "description": "React popup alerts. Lightweight, customizable and beautiful by default.",

"build": "rm -rf dist && tsup",
"push": "npm publish",
"size": "size-limit",

@@ -41,8 +42,8 @@ "prettier": "prettier src --write",

{
"path": "dist/index.js",
"limit": "30 KB"
"path": "dist/index.cjs",
"limit": "40 KB"
},
{
"path": "dist/index.es.js",
"limit": "30 KB"
"path": "dist/index.js",
"limit": "20 KB"
}

@@ -49,0 +50,0 @@ ],

@@ -9,3 +9,4 @@ <p>

<img src="https://badgen.net/npm/v/react-ghosta" alt="NPM Version" />
<img src="https://badgen.net/bundlephobia/minzip/react-ghosta" alt="minzipped size"/>
<img src="https://badgen.net/npm/dm/react-ghosta" alt="Monthly Downloads"/>
<img src="https://badgen.net/npm/license/react-ghosta" alt="License"/>
</div>

@@ -12,0 +13,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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc