New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@swing.xyz/design-system

Package Overview
Dependencies
Maintainers
0
Versions
287
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swing.xyz/design-system - npm Package Compare versions

Comparing version 0.55.0 to 0.55.1

2

dist/index.js
'use client'
"use strict";var Ae=Object.create;var K=Object.defineProperty,Me=Object.defineProperties,Be=Object.getOwnPropertyDescriptor,Fe=Object.getOwnPropertyDescriptors,je=Object.getOwnPropertyNames,G=Object.getOwnPropertySymbols,Le=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable;var ge=(t,e,i)=>e in t?K(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,m=(t,e)=>{for(var i in e||(e={}))te.call(e,i)&&ge(t,i,e[i]);if(G)for(var i of G(e))de.call(e,i)&&ge(t,i,e[i]);return t},M=(t,e)=>Me(t,Fe(e));var D=(t,e)=>{var i={};for(var r in t)te.call(t,r)&&e.indexOf(r)<0&&(i[r]=t[r]);if(t!=null&&G)for(var r of G(t))e.indexOf(r)<0&&de.call(t,r)&&(i[r]=t[r]);return i};var He=(t,e)=>{for(var i in e)K(t,i,{get:e[i],enumerable:!0})},we=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of je(e))!te.call(t,s)&&s!==i&&K(t,s,{get:()=>e[s],enumerable:!(r=Be(e,s))||r.enumerable});return t};var y=(t,e,i)=>(i=t!=null?Ae(Le(t)):{},we(e||!t||!t.__esModule?K(i,"default",{value:t,enumerable:!0}):i,t)),We=t=>we(K({},"__esModule",{value:!0}),t);var j=(t,e,i)=>new Promise((r,s)=>{var o=l=>{try{a(i.next(l))}catch(w){s(w)}},n=l=>{try{a(i.throw(l))}catch(w){s(w)}},a=l=>l.done?r(l.value):Promise.resolve(l.value).then(o,n);a((i=i.apply(t,e)).next())});var st={};He(st,{Avatar:()=>fe,AvatarFallback:()=>ve,AvatarImage:()=>ue,Badge:()=>be,Button:()=>Re,Callout:()=>qe,Dialog:()=>U,Icon:()=>S,Input:()=>J,SearchList:()=>le,Select:()=>it,useCopyToClipboard:()=>rt,useDebounce:()=>ae});module.exports=We(st);var Y=y(require("react")),A=y(require("@radix-ui/react-avatar"));var me=y(require("clsx")),pe=require("tailwind-merge"),W=(...t)=>(0,pe.twMerge)((0,me.default)(...t));var X=require("react/jsx-runtime"),fe=Y.forwardRef((r,i)=>{var s=r,{className:t}=s,e=D(s,["className"]);return(0,X.jsx)(A.Root,m({ref:i,className:W("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t)},e))});fe.displayName=A.Root.displayName;var ue=Y.forwardRef((r,i)=>{var s=r,{className:t}=s,e=D(s,["className"]);return(0,X.jsx)(A.Image,m({ref:i,className:W("aspect-square h-full w-full",t)},e))});ue.displayName=A.Image.displayName;var ve=Y.forwardRef((r,i)=>{var s=r,{className:t}=s,e=D(s,["className"]);return(0,X.jsx)(A.Fallback,m({ref:i,className:W("flex h-full w-full items-center justify-center rounded-full",t)},e))});ve.displayName=A.Fallback.displayName;var he=y(require("clsx")),_=require("react/jsx-runtime"),be=({children:t,className:e,intent:i="default",icon:r})=>(0,_.jsxs)("div",{className:(0,he.default)(e,"inline-flex items-center space-x-1 truncate rounded-lg px-2 py-0.5 text-xs",{"bg-primary text-white":i==="primary","bg-success text-white":i==="success","bg-danger text-white":i==="danger","bg-warning text-white":i==="warning","bg-info text-white":i==="info","bg-secondary text-muted":i==="default"}),children:[r,(0,_.jsx)("div",{className:"flex-1 truncate",children:t})]});be.displayName="Badge";var ye=require("react");var p=y(require("react"),1);var Oe=y(require("react"),1);function Ke(t,e){typeof t=="function"?t(e):t!=null&&(t.current=e)}function xe(...t){return e=>t.forEach(i=>Ke(i,e))}var O=require("react/jsx-runtime");var re=p.forwardRef((t,e)=>{let n=t,{children:i}=n,r=D(n,["children"]),s=p.Children.toArray(i),o=s.find(Ge);if(o){let a=o.props.children,l=s.map(w=>w===o?p.Children.count(a)>1?p.Children.only(null):p.isValidElement(a)?a.props.children:null:w);return(0,O.jsx)(ie,M(m({},r),{ref:e,children:p.isValidElement(a)?p.cloneElement(a,void 0,l):null}))}return(0,O.jsx)(ie,M(m({},r),{ref:e,children:i}))});re.displayName="Slot";var ie=p.forwardRef((t,e)=>{let s=t,{children:i}=s,r=D(s,["children"]);if(p.isValidElement(i)){let o=Xe(i);return p.cloneElement(i,M(m({},Ye(r,i.props)),{ref:e?xe(e,o):o}))}return p.Children.count(i)>1?p.Children.only(null):null});ie.displayName="SlotClone";var $e=({children:t})=>(0,O.jsx)(O.Fragment,{children:t});function Ge(t){return p.isValidElement(t)&&t.type===$e}function Ye(t,e){let i=m({},e);for(let r in e){let s=t[r],o=e[r];/^on[A-Z]/.test(r)?s&&o?i[r]=(...a)=>{o(...a),s(...a)}:s&&(i[r]=s):r==="style"?i[r]=m(m({},s),o):r==="className"&&(i[r]=[s,o].filter(Boolean).join(" "))}return m(m({},t),i)}function Xe(t){var r,s;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,i=e&&"isReactWarning"in e&&e.isReactWarning;return i?t.ref:(e=(s=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:s.get,i=e&&"isReactWarning"in e&&e.isReactWarning,i?t.props.ref:t.props.ref||t.ref)}var q=y(require("clsx"));var k=require("react/jsx-runtime"),Re=(0,ye.forwardRef)((w,l)=>{var h=w,{children:t,appearance:e="primary",className:i,disabled:r,dataTest:s,isLoading:o,asChild:n}=h,a=D(h,["children","appearance","className","disabled","dataTest","isLoading","asChild"]);let u=n?re:"button",T=r||o;return(0,k.jsx)(u,M(m({ref:l,"data-test":s},a),{disabled:T,className:(0,q.default)(i,"relative inline-flex h-12 items-center justify-center rounded-lg px-4 py-2 text-sm font-medium","focus-visible:ring-primary-500 pointer-events-auto focus:outline-none focus-visible:ring focus-visible:ring-opacity-75",{"bg-primary disabled:text-muted text-white enabled:hover:bg-opacity-90":e==="primary","bg-secondary text-secondary-foreground enabled:hover:bg-border":e==="default","bg-background text-foreground border border-solid":e==="outline","cursor-not-allowed bg-opacity-50":r,"cursor-wait bg-opacity-50":o,"cursor-pointer":!T}),children:n?t:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)("div",{className:"flex-shrink basis-0"}),(0,k.jsx)("div",{className:"flex-1",children:t}),(0,k.jsx)("div",{className:"flex h-full flex-shrink basis-0 items-center justify-end",children:o&&(0,k.jsxs)("svg",{className:"h-5 w-5 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[(0,k.jsx)("circle",{className:(0,q.default)("opacity-25",{"stroke-muted":e==="default","stroke-white":e==="primary"}),cx:"12",cy:"12",r:"10",strokeWidth:"4"}),(0,k.jsx)("path",{className:(0,q.default)("opacity-75",{"fill-muted":e==="default","fill-white":e==="primary"}),d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})]})}))});Re.displayName="Button";var F=require("@fortawesome/free-solid-svg-icons"),se=y(require("clsx"));var Ne=require("react");var L=require("react/jsx-runtime"),_e={xs:"h-3 w-3",sm:"h-4 w-4",default:"h-5 w-5",lg:"h-6 w-6"},S=(0,Ne.forwardRef)(function(e,i){let c=e,{icon:r,children:s,className:o,fixedWidth:n,spin:a,size:l}=c,w=D(c,["icon","children","className","fixedWidth","spin","size"]),{prefix:h,iconName:u,icon:T}=r,[P,E,I,z,N]=T,b=`${h}-${u}`,$=_e[l||"default"];return(0,L.jsxs)("svg",M(m({ref:i,viewBox:`0 0 ${String(P)} ${String(E)}`,xmlns:"http://www.w3.org/2000/svg",role:"img","aria-hidden":"true","data-fa":b,className:W(o,$,"svg-inline--fa fill-current",b,{"fa-spin":!!a,"fa-fw":!!n})},w),{children:[s,Array.isArray(N)?(0,L.jsxs)("g",{children:[(0,L.jsx)("path",{d:N[0]}),(0,L.jsx)("path",{d:N[1]})]}):(0,L.jsx)("path",{d:N})]}))});S.displayName="Icon";var B=require("react/jsx-runtime"),qe=({className:t,intent:e,title:i,description:r})=>(0,B.jsxs)("div",{className:(0,se.default)(t,"flex items-start space-x-4 rounded-xl px-4 py-2 text-base",{"bg-border":!e,"bg-blue-200":e==="info","bg-green-200":e==="success","bg-red-200":e==="danger","bg-amber-200":e==="warning"}),children:[(0,B.jsx)("div",{className:(0,se.default)("h-full py-1 text-lg",{"text-info":e==="info","text-success":e==="success","text-danger":e==="danger","text-warning":e==="warning"}),children:(0,B.jsx)(S,{className:"h-6 w-6",icon:Ue[e||"info"]})}),(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-lg font-bold",children:i}),(0,B.jsx)("div",{className:"text-sm",children:r})]})]}),Ue={info:F.faInfoCircle,success:F.faCircleCheck,danger:F.faExclamationCircle,warning:F.faTriangleExclamation};var ke=require("react"),Ce=require("@fortawesome/free-solid-svg-icons"),oe=require("@headlessui/react"),f=y(require("@radix-ui/react-dialog")),ne=y(require("clsx"));var v=require("react/jsx-runtime");function Ze(){return typeof window!="undefined"?window.document.getElementById("swing"):void 0}var U=({isOpen:t,onOpenChange:e,shouldCloseOnInteractOutside:i=!0,title:r,children:s,trigger:o,description:n})=>{var a;return(0,v.jsxs)(f.Root,{open:t,onOpenChange:e,modal:!1,children:[o&&(0,v.jsx)(f.Trigger,{asChild:!0,children:o}),(0,v.jsx)(f.Portal,{container:(a=Ze())==null?void 0:a.firstElementChild,children:(0,v.jsxs)(oe.Transition,{show:t,children:[(0,v.jsx)(f.Overlay,{forceMount:!0,className:"bg-background/80 data-[state=closed]:animate-out data-[state=closed]:fade-out data-[state=open]:fade-in fixed inset-0 z-40 rounded-xl transition-all duration-100"}),(0,v.jsx)(oe.Transition.Child,{as:ke.Fragment,enter:"ease-in duration-300",enterFrom:"opacity-0 translate-y-full",enterTo:"opacity-100 translate-y-0",leave:"ease-out duration-400",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 translate-y-full",children:(0,v.jsxs)(f.Content,{forceMount:!0,className:(0,ne.default)("fixed bottom-0 left-0 right-0 top-12 z-50 border-t","w-full overflow-hidden rounded-xl","bg-background focus:outline-none focus-visible:ring focus-visible:ring-blue-500 focus-visible:ring-opacity-75","flex flex-col"),onInteractOutside:i?void 0:l=>{l.preventDefault()},children:[(0,v.jsxs)(f.Title,{className:"text-foreground relative flex px-4 py-3 text-base font-bold",children:[(0,v.jsx)("div",{className:"flex-1",children:r}),(0,v.jsx)(f.Close,{className:(0,ne.default)("text-muted text-base","inline-flex items-center justify-center rounded-full p-1","focus:outline-none focus-visible:ring focus-visible:ring-blue-500 focus-visible:ring-opacity-75"),"data-test":"dialog-close",tabIndex:-1,children:(0,v.jsx)(S,{size:"sm",icon:Ce.faClose})})]}),n&&(0,v.jsx)(f.Description,{className:"text-muted mt-2 text-sm font-normal"}),t&&(0,v.jsx)("div",{className:"h-full flex-1 overflow-hidden",children:s})]})})]})})]})};U.displayName="Dialog";var Te=require("react"),Z=y(require("clsx")),C=require("react/jsx-runtime"),J=(0,Te.forwardRef)(function({value:e,onChange:i,onBlur:r,onKeyDown:s,subtext:o,readOnly:n,placeholder:a,className:l,dataTest:w,type:h,min:u,lang:T,error:P,autoFocus:E,isLoading:I,icon:z},N){return(0,C.jsxs)("div",{className:(0,Z.default)(l,"relative rounded-xl border-2",{"focus-within:ring-0":n,"focus-within:ring focus-within:ring-blue-500":!P,"ring ring-rose-500 focus-within:ring focus-within:ring-rose-500":!!P}),children:[z&&(0,C.jsx)("div",{className:"absolute inset-y-0 left-0",children:(0,C.jsx)("div",{className:"text-muted flex h-full items-center justify-center pl-4",children:z})}),(0,C.jsx)("input",{ref:N,type:h!=null?h:"text",className:(0,Z.default)("inline-block h-full w-full truncate rounded-xl bg-transparent px-7 outline-none",{"pl-12":!!z,"text-muted pr-12":I}),value:e,onChange:!I&&i?b=>{i(b.currentTarget.value)}:void 0,onBlur:r?b=>{r(b.currentTarget.value)}:void 0,onKeyDown:s?b=>{s(b)}:void 0,placeholder:a,readOnly:n,disabled:n,"data-test":w,min:u,lang:T,autoFocus:E}),(P||o)&&(0,C.jsx)("div",{className:(0,Z.default)("absolute bottom-2 left-7 truncate text-[10px] text-xs",{"text-danger":!!P,"text-muted":!!o}),children:P||o}),I&&(0,C.jsx)("div",{className:"absolute inset-y-0 right-0",children:(0,C.jsx)("div",{className:"text-muted flex h-full items-center justify-center pr-4",children:(0,C.jsxs)("svg",{className:"h-5 w-5 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[(0,C.jsx)("circle",{className:"stroke-muted opacity-25",cx:"12",cy:"12",r:"10",strokeWidth:"4"}),(0,C.jsx)("path",{className:"fill-muted opacity-75",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})})]})});J.displayName="Input";var g=require("react"),ee=require("@fortawesome/free-solid-svg-icons"),Pe=require("@tanstack/react-virtual"),Ie=y(require("clsx")),V=require("jotai");var Q=require("react");function ae(t,e){let[i,r]=(0,Q.useState)(t);return(0,Q.useEffect)(()=>{let s=setTimeout(()=>{r(t)},e||500);return()=>{clearTimeout(s)}},[t,e]),i}var d=require("react/jsx-runtime"),ze=(0,V.atom)(""),De=(0,V.atom)(-1);function le({value:t,items:e,isLoading:i,searchPlaceholder:r,onChange:s,onSearch:o,renderItem:n}){return(0,d.jsxs)(d.Fragment,{children:[o&&(0,d.jsx)(Je,{placeholder:r}),(0,d.jsx)(tt,{value:t,items:e,onSearch:o,onChange:s,renderItem:n}),i&&(0,d.jsx)("div",{className:"bg-background absolute inset-0 z-10 flex h-full w-full items-center justify-center bg-opacity-70",children:(0,d.jsx)(S,{className:"text-muted",icon:ee.faCircleNotch,size:"lg",spin:!0})})]})}var Je=({placeholder:t})=>{let e=(0,g.useRef)(null),[i,r]=(0,g.useState)(""),s=ae(i,200),o=(0,V.useSetAtom)(ze),n=(0,V.useSetAtom)(De);(0,g.useEffect)(()=>{var l;return(l=e.current)==null||l.focus(),o(""),()=>{o(""),n(-1)}},[o,n]),(0,g.useEffect)(()=>{o(s)},[s,o]);let a=(0,g.useCallback)(l=>{l.code==="ArrowDown"&&n(0)},[n]);return(0,d.jsx)("div",{className:"relative z-10 mx-4 mt-2",children:(0,d.jsx)(J,{ref:e,className:"h-12 bg-transparent",dataTest:"select-search-input",placeholder:t||"Search...",value:i,onChange:l=>{r(l),n(-1)},onKeyDown:a,autoFocus:!0,icon:(0,d.jsx)(S,{icon:ee.faMagnifyingGlass})})})};function Qe({value:t,items:e,onChange:i,onSearch:r,renderItem:s}){var $;let o=(0,V.useAtomValue)(ze),[n,a]=(0,V.useAtom)(De),l=(0,g.useRef)([]),w=(0,g.useRef)(null),h=(0,g.useMemo)(()=>!!r,[r]),u=(0,g.useMemo)(()=>r&&o?e.filter(c=>r(c,o)):e,[e,o,r]),T=typeof t!="undefined"?u.indexOf(t):-1,[P,E]=(0,g.useState)(null),I=(0,Pe.useVirtualizer)({count:u.length,getScrollElement:()=>w.current,estimateSize:()=>60,overscan:5,getItemKey:c=>`${String(e[c])}-${String(c)}`}),z=(0,g.useCallback)(c=>j(this,null,function*(){let x=i(c);x instanceof Promise&&(E(c),yield x,E(null)),a(-1)}),[i,a]),N=(0,g.useCallback)(c=>{if(c.code==="ArrowUp")a(n?n-1:u.length-1);else if(c.code==="ArrowDown")a(n===u.length-1?0:n+1);else if(c.code==="Enter"){let x=u[n];x&&z(x)}},[a,z,n,u]);(0,g.useEffect)(()=>{var c;(c=l.current[n])==null||c.focus()},[n]),(0,g.useEffect)(()=>{h||a(T)},[T,a,h]);let b=I.getVirtualItems();return(0,d.jsx)("div",{className:"flex-1 px-4",ref:w,style:{height:400,overflow:"auto"},children:(0,d.jsx)("div",{className:"relative w-full",style:{height:`${String(I.getTotalSize()||0)}px`},children:(0,d.jsx)("div",{className:"pb-4",style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${String((($=b[0])==null?void 0:$.start)||0)}px)`},children:I.getVirtualItems().map(c=>{let x=u[c.index];return(0,d.jsx)("div",{"data-index":c.index,ref:I.measureElement,"data-test":"select-item",children:(0,d.jsx)("div",{tabIndex:0,onClick:()=>j(this,null,function*(){typeof x!="undefined"&&(yield z(x))}),onKeyDown:N,ref:ce=>{ce&&(l.current[c.index]=ce)},className:(0,Ie.default)("bg-background hover:bg-accent mt-2.5 cursor-pointer space-x-2 rounded-xl border px-3 outline-none focus:ring focus:ring-blue-500",{"bg-secondary":t===x}),children:(0,d.jsx)("div",{className:"flex items-center justify-start text-sm",children:typeof x!="undefined"?s(x,t===x,{isLoading:P===x}):null})})},c.key)})})})})}var et=g.memo,tt=et(Qe);var H=require("react"),Se=require("@fortawesome/free-solid-svg-icons"),Ee=y(require("clsx"));var R=require("react/jsx-runtime");function it({isOpen:t,onOpenChange:e,className:i,title:r,value:s,items:o,isLoading:n,onChange:a,onSearch:l,renderTrigger:w,trigger:h,renderItem:u,children:T}){let[P,E]=(0,H.useState)(!1),I=(0,H.useCallback)(b=>j(this,null,function*(){yield a(b),E(!1)}),[a]),z=(0,H.useCallback)(b=>{b.preventDefault(),o.length&&E(!0)},[o]),N;return h?N=(0,H.cloneElement)(h,{onClick:z}):w&&(N=(0,R.jsxs)("button",{className:(0,Ee.default)("bg-background relative flex h-16 items-center space-x-2 rounded-xl border-2 px-4 py-3 text-left outline-none focus:ring focus:ring-blue-500",i),onClick:z,children:[(0,R.jsx)("div",{className:"flex-1 truncate",children:w(s)}),!n&&o.length>0&&(0,R.jsx)(S,{className:"text-muted",icon:Se.faCaretDown,size:"sm"}),n&&(0,R.jsx)("div",{className:"absolute inset-y-0 right-0",children:(0,R.jsx)("div",{className:"text-muted flex h-full items-center justify-center pr-4",children:(0,R.jsxs)("svg",{className:"h-5 w-5 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[(0,R.jsx)("circle",{className:"stroke-muted opacity-25",cx:"12",cy:"12",r:"10",strokeWidth:"4"}),(0,R.jsx)("path",{className:"fill-muted opacity-75",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})})]})),(0,R.jsx)(U,{title:r,isOpen:t!=null?t:P,onOpenChange:e!=null?e:E,trigger:N,children:(0,R.jsxs)("div",{className:"relative flex h-full flex-col",children:[(0,R.jsx)(le,{value:s,items:o,renderItem:u,onSearch:l,onChange:I,isLoading:n}),T]})})}var Ve=require("react");function rt(){let[t,e]=(0,Ve.useState)(null);return[t,r=>j(this,null,function*(){if(!("clipboard"in navigator))return console.warn("Clipboard not supported"),!1;try{return yield navigator.clipboard.writeText(r),e(r),!0}catch(s){return console.warn("Copy failed",s),e(null),!1}})]}
"use strict";var Ae=Object.create;var K=Object.defineProperty,Me=Object.defineProperties,Be=Object.getOwnPropertyDescriptor,Fe=Object.getOwnPropertyDescriptors,je=Object.getOwnPropertyNames,G=Object.getOwnPropertySymbols,Le=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable;var ge=(t,e,i)=>e in t?K(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,m=(t,e)=>{for(var i in e||(e={}))te.call(e,i)&&ge(t,i,e[i]);if(G)for(var i of G(e))de.call(e,i)&&ge(t,i,e[i]);return t},M=(t,e)=>Me(t,Fe(e));var D=(t,e)=>{var i={};for(var r in t)te.call(t,r)&&e.indexOf(r)<0&&(i[r]=t[r]);if(t!=null&&G)for(var r of G(t))e.indexOf(r)<0&&de.call(t,r)&&(i[r]=t[r]);return i};var He=(t,e)=>{for(var i in e)K(t,i,{get:e[i],enumerable:!0})},we=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of je(e))!te.call(t,o)&&o!==i&&K(t,o,{get:()=>e[o],enumerable:!(r=Be(e,o))||r.enumerable});return t};var y=(t,e,i)=>(i=t!=null?Ae(Le(t)):{},we(e||!t||!t.__esModule?K(i,"default",{value:t,enumerable:!0}):i,t)),We=t=>we(K({},"__esModule",{value:!0}),t);var j=(t,e,i)=>new Promise((r,o)=>{var n=l=>{try{s(i.next(l))}catch(w){o(w)}},a=l=>{try{s(i.throw(l))}catch(w){o(w)}},s=l=>l.done?r(l.value):Promise.resolve(l.value).then(n,a);s((i=i.apply(t,e)).next())});var ot={};He(ot,{Avatar:()=>fe,AvatarFallback:()=>ve,AvatarImage:()=>ue,Badge:()=>be,Button:()=>Re,Callout:()=>qe,Dialog:()=>U,Icon:()=>S,Input:()=>J,SearchList:()=>le,Select:()=>it,useCopyToClipboard:()=>rt,useDebounce:()=>se});module.exports=We(ot);var Y=y(require("react")),A=y(require("@radix-ui/react-avatar"));var me=y(require("clsx")),pe=require("tailwind-merge"),W=(...t)=>(0,pe.twMerge)((0,me.default)(...t));var X=require("react/jsx-runtime"),fe=Y.forwardRef((r,i)=>{var o=r,{className:t}=o,e=D(o,["className"]);return(0,X.jsx)(A.Root,m({ref:i,className:W("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t)},e))});fe.displayName=A.Root.displayName;var ue=Y.forwardRef((r,i)=>{var o=r,{className:t}=o,e=D(o,["className"]);return(0,X.jsx)(A.Image,m({ref:i,className:W("aspect-square h-full w-full",t)},e))});ue.displayName=A.Image.displayName;var ve=Y.forwardRef((r,i)=>{var o=r,{className:t}=o,e=D(o,["className"]);return(0,X.jsx)(A.Fallback,m({ref:i,className:W("flex h-full w-full items-center justify-center rounded-full",t)},e))});ve.displayName=A.Fallback.displayName;var he=y(require("clsx")),_=require("react/jsx-runtime"),be=({children:t,className:e,intent:i="default",icon:r})=>(0,_.jsxs)("div",{className:(0,he.default)(e,"inline-flex items-center space-x-1 truncate rounded-lg px-2 py-0.5 text-xs",{"bg-primary text-white":i==="primary","bg-success text-white":i==="success","bg-danger text-white":i==="danger","bg-warning text-white":i==="warning","bg-info text-white":i==="info","bg-secondary text-muted":i==="default"}),children:[r,(0,_.jsx)("div",{className:"flex-1 truncate",children:t})]});be.displayName="Badge";var ye=require("react");var p=y(require("react"),1);var Oe=y(require("react"),1);function Ke(t,e){typeof t=="function"?t(e):t!=null&&(t.current=e)}function xe(...t){return e=>t.forEach(i=>Ke(i,e))}var O=require("react/jsx-runtime");var re=p.forwardRef((t,e)=>{let a=t,{children:i}=a,r=D(a,["children"]),o=p.Children.toArray(i),n=o.find(Ge);if(n){let s=n.props.children,l=o.map(w=>w===n?p.Children.count(s)>1?p.Children.only(null):p.isValidElement(s)?s.props.children:null:w);return(0,O.jsx)(ie,M(m({},r),{ref:e,children:p.isValidElement(s)?p.cloneElement(s,void 0,l):null}))}return(0,O.jsx)(ie,M(m({},r),{ref:e,children:i}))});re.displayName="Slot";var ie=p.forwardRef((t,e)=>{let o=t,{children:i}=o,r=D(o,["children"]);if(p.isValidElement(i)){let n=Xe(i);return p.cloneElement(i,M(m({},Ye(r,i.props)),{ref:e?xe(e,n):n}))}return p.Children.count(i)>1?p.Children.only(null):null});ie.displayName="SlotClone";var $e=({children:t})=>(0,O.jsx)(O.Fragment,{children:t});function Ge(t){return p.isValidElement(t)&&t.type===$e}function Ye(t,e){let i=m({},e);for(let r in e){let o=t[r],n=e[r];/^on[A-Z]/.test(r)?o&&n?i[r]=(...s)=>{n(...s),o(...s)}:o&&(i[r]=o):r==="style"?i[r]=m(m({},o),n):r==="className"&&(i[r]=[o,n].filter(Boolean).join(" "))}return m(m({},t),i)}function Xe(t){var r,o;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,i=e&&"isReactWarning"in e&&e.isReactWarning;return i?t.ref:(e=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,i=e&&"isReactWarning"in e&&e.isReactWarning,i?t.props.ref:t.props.ref||t.ref)}var q=y(require("clsx"));var k=require("react/jsx-runtime"),Re=(0,ye.forwardRef)((w,l)=>{var h=w,{children:t,appearance:e="primary",className:i,disabled:r,dataTest:o,isLoading:n,asChild:a}=h,s=D(h,["children","appearance","className","disabled","dataTest","isLoading","asChild"]);let u=a?re:"button",T=r||n;return(0,k.jsx)(u,M(m({ref:l,"data-test":o},s),{disabled:T,className:(0,q.default)(i,"relative inline-flex h-12 items-center justify-center rounded-lg px-4 py-2 text-sm font-medium","focus-visible:ring-primary-500 pointer-events-auto focus:outline-none focus-visible:ring focus-visible:ring-opacity-75",{"bg-primary disabled:text-muted text-white enabled:hover:bg-opacity-90":e==="primary","bg-secondary text-secondary-foreground enabled:hover:bg-border":e==="default","bg-background text-foreground border border-solid":e==="outline","cursor-not-allowed bg-opacity-50":r,"cursor-wait bg-opacity-50":n,"cursor-pointer":!T}),children:a?t:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)("div",{className:"flex-shrink basis-0"}),(0,k.jsx)("div",{className:"flex-1",children:t}),(0,k.jsx)("div",{className:"flex h-full flex-shrink basis-0 items-center justify-end",children:n&&(0,k.jsxs)("svg",{className:"h-5 w-5 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[(0,k.jsx)("circle",{className:(0,q.default)("opacity-25",{"stroke-muted":e==="default","stroke-white":e==="primary"}),cx:"12",cy:"12",r:"10",strokeWidth:"4"}),(0,k.jsx)("path",{className:(0,q.default)("opacity-75",{"fill-muted":e==="default","fill-white":e==="primary"}),d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})]})}))});Re.displayName="Button";var F=require("@fortawesome/free-solid-svg-icons"),oe=y(require("clsx"));var Ne=require("react");var L=require("react/jsx-runtime"),_e={xs:"h-3 w-3",sm:"h-4 w-4",default:"h-5 w-5",lg:"h-6 w-6"},S=(0,Ne.forwardRef)(function(e,i){let c=e,{icon:r,children:o,className:n,fixedWidth:a,spin:s,size:l}=c,w=D(c,["icon","children","className","fixedWidth","spin","size"]),{prefix:h,iconName:u,icon:T}=r,[P,E,I,z,N]=T,b=`${h}-${u}`,$=_e[l||"default"];return(0,L.jsxs)("svg",M(m({ref:i,viewBox:`0 0 ${String(P)} ${String(E)}`,xmlns:"http://www.w3.org/2000/svg",role:"img","aria-hidden":"true","data-fa":b,className:W(n,$,"svg-inline--fa fill-current",b,{"fa-spin":!!s,"fa-fw":!!a})},w),{children:[o,Array.isArray(N)?(0,L.jsxs)("g",{children:[(0,L.jsx)("path",{d:N[0]}),(0,L.jsx)("path",{d:N[1]})]}):(0,L.jsx)("path",{d:N})]}))});S.displayName="Icon";var B=require("react/jsx-runtime"),qe=({className:t,intent:e,title:i,description:r})=>(0,B.jsxs)("div",{className:(0,oe.default)(t,"flex items-start space-x-4 rounded-xl px-4 py-2 text-base",{"bg-border":!e,"bg-blue-200":e==="info","bg-green-200":e==="success","bg-red-200":e==="danger","bg-amber-200":e==="warning"}),children:[(0,B.jsx)("div",{className:(0,oe.default)("h-full py-1 text-lg",{"text-info":e==="info","text-success":e==="success","text-danger":e==="danger","text-warning":e==="warning"}),children:(0,B.jsx)(S,{className:"h-6 w-6",icon:Ue[e||"info"]})}),(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:"text-lg font-bold",children:i}),(0,B.jsx)("div",{className:"text-sm",children:r})]})]}),Ue={info:F.faInfoCircle,success:F.faCircleCheck,danger:F.faExclamationCircle,warning:F.faTriangleExclamation};var ke=require("react"),Ce=require("@fortawesome/free-solid-svg-icons"),ne=require("@headlessui/react"),f=y(require("@radix-ui/react-dialog")),ae=y(require("clsx"));var v=require("react/jsx-runtime");function Ze(){return typeof window!="undefined"?window.document.getElementById("swing"):void 0}var U=({isOpen:t,onOpenChange:e,shouldCloseOnInteractOutside:i=!0,title:r,children:o,trigger:n,description:a})=>{var s;return(0,v.jsxs)(f.Root,{open:t,onOpenChange:e,modal:!1,children:[n&&(0,v.jsx)(f.Trigger,{asChild:!0,children:n}),(0,v.jsx)(f.Portal,{container:(s=Ze())==null?void 0:s.firstElementChild,children:(0,v.jsxs)(ne.Transition,{show:t,children:[(0,v.jsx)(f.Overlay,{forceMount:!0,className:"bg-background/80 data-[state=closed]:animate-out data-[state=closed]:fade-out data-[state=open]:fade-in fixed inset-0 z-40 rounded-xl transition-all duration-100"}),(0,v.jsx)(ne.Transition.Child,{as:ke.Fragment,enter:"ease-in duration-300",enterFrom:"opacity-0 translate-y-full",enterTo:"opacity-100 translate-y-0",leave:"ease-out duration-400",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 translate-y-full",children:(0,v.jsxs)(f.Content,{forceMount:!0,className:(0,ae.default)("fixed bottom-0 left-0 right-0 top-12 z-50 border-t","w-full overflow-hidden rounded-xl","bg-background focus:outline-none focus-visible:ring focus-visible:ring-blue-500 focus-visible:ring-opacity-75","flex flex-col"),onInteractOutside:i?void 0:l=>{l.preventDefault()},children:[(0,v.jsxs)(f.Title,{className:"text-foreground relative flex px-4 py-3 text-base font-bold",children:[(0,v.jsx)("div",{className:"flex-1",children:r}),(0,v.jsx)(f.Close,{className:(0,ae.default)("text-muted text-base","inline-flex items-center justify-center rounded-full p-1","focus:outline-none focus-visible:ring focus-visible:ring-blue-500 focus-visible:ring-opacity-75"),"data-test":"dialog-close",tabIndex:-1,children:(0,v.jsx)(S,{size:"sm",icon:Ce.faClose})})]}),a&&(0,v.jsx)(f.Description,{className:"text-muted mt-2 text-sm font-normal"}),t&&(0,v.jsx)("div",{className:"h-full flex-1 overflow-hidden",children:o})]})})]})})]})};U.displayName="Dialog";var Te=require("react"),Z=y(require("clsx")),C=require("react/jsx-runtime"),J=(0,Te.forwardRef)(function({value:e,onChange:i,onBlur:r,onKeyDown:o,subtext:n,readOnly:a,placeholder:s,className:l,dataTest:w,type:h,min:u,lang:T,error:P,autoFocus:E,isLoading:I,icon:z},N){return(0,C.jsxs)("div",{className:(0,Z.default)(l,"relative rounded-xl border-2",{"focus-within:ring-0":a,"focus-within:ring focus-within:ring-blue-500":!P,"ring ring-rose-500 focus-within:ring focus-within:ring-rose-500":!!P}),children:[z&&(0,C.jsx)("div",{className:"absolute inset-y-0 left-0",children:(0,C.jsx)("div",{className:"text-muted flex h-full items-center justify-center pl-4",children:z})}),(0,C.jsx)("input",{ref:N,type:h!=null?h:"text",className:(0,Z.default)("inline-block h-full w-full truncate rounded-xl bg-transparent px-7 outline-none",{"pl-12":!!z,"text-muted pr-12":I}),value:e,onChange:!I&&i?b=>{i(b.currentTarget.value)}:void 0,onBlur:r?b=>{r(b.currentTarget.value)}:void 0,onKeyDown:o?b=>{o(b)}:void 0,placeholder:s,readOnly:a,disabled:a,"data-test":w,min:u,lang:T,autoFocus:E}),(P||n)&&(0,C.jsx)("div",{className:(0,Z.default)("absolute bottom-2 left-7 truncate text-[10px] text-xs",{"text-danger":!!P,"text-muted":!!n}),children:P||n}),I&&(0,C.jsx)("div",{className:"absolute inset-y-0 right-0",children:(0,C.jsx)("div",{className:"text-muted flex h-full items-center justify-center pr-4",children:(0,C.jsxs)("svg",{className:"h-5 w-5 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[(0,C.jsx)("circle",{className:"stroke-muted opacity-25",cx:"12",cy:"12",r:"10",strokeWidth:"4"}),(0,C.jsx)("path",{className:"fill-muted opacity-75",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})})]})});J.displayName="Input";var g=require("react"),ee=require("@fortawesome/free-solid-svg-icons"),Pe=require("@tanstack/react-virtual"),Ie=y(require("clsx")),V=require("jotai");var Q=require("react");function se(t,e){let[i,r]=(0,Q.useState)(t);return(0,Q.useEffect)(()=>{let o=setTimeout(()=>{r(t)},e||500);return()=>{clearTimeout(o)}},[t,e]),i}var d=require("react/jsx-runtime"),ze=(0,V.atom)(""),De=(0,V.atom)(-1);function le({value:t,items:e,isLoading:i,searchPlaceholder:r,onChange:o,onSearch:n,renderItem:a}){return(0,d.jsxs)(d.Fragment,{children:[n&&(0,d.jsx)(Je,{placeholder:r}),(0,d.jsx)(tt,{value:t,items:e,onSearch:n,onChange:o,renderItem:a}),i&&(0,d.jsx)("div",{className:"bg-background absolute inset-0 z-10 flex h-full w-full items-center justify-center bg-opacity-70",children:(0,d.jsx)(S,{className:"text-muted",icon:ee.faCircleNotch,size:"lg",spin:!0})})]})}var Je=({placeholder:t})=>{let e=(0,g.useRef)(null),[i,r]=(0,g.useState)(""),o=se(i,200),n=(0,V.useSetAtom)(ze),a=(0,V.useSetAtom)(De);(0,g.useEffect)(()=>{var l;return(l=e.current)==null||l.focus(),n(""),()=>{n(""),a(-1)}},[n,a]),(0,g.useEffect)(()=>{n(o)},[o,n]);let s=(0,g.useCallback)(l=>{l.code==="ArrowDown"&&a(0)},[a]);return(0,d.jsx)("div",{className:"relative z-10 mx-4 mt-2",children:(0,d.jsx)(J,{ref:e,className:"h-12 bg-transparent",dataTest:"select-search-input",placeholder:t||"Search...",value:i,onChange:l=>{r(l),a(-1)},onKeyDown:s,autoFocus:!0,icon:(0,d.jsx)(S,{icon:ee.faMagnifyingGlass})})})};function Qe({value:t,items:e,onChange:i,onSearch:r,renderItem:o}){var $;let n=(0,V.useAtomValue)(ze),[a,s]=(0,V.useAtom)(De),l=(0,g.useRef)([]),w=(0,g.useRef)(null),h=(0,g.useMemo)(()=>!!r,[r]),u=(0,g.useMemo)(()=>r&&n?e.filter(c=>r(c,n)):e,[e,n,r]),T=typeof t!="undefined"?u.indexOf(t):-1,[P,E]=(0,g.useState)(null),I=(0,Pe.useVirtualizer)({count:u.length,getScrollElement:()=>w.current,estimateSize:()=>60,overscan:5,getItemKey:c=>`${String(e[c])}-${String(c)}`}),z=(0,g.useCallback)(c=>j(this,null,function*(){let x=i(c);x instanceof Promise&&(E(c),yield x,E(null)),s(-1)}),[i,s]),N=(0,g.useCallback)(c=>{if(c.code==="ArrowUp")s(a?a-1:u.length-1);else if(c.code==="ArrowDown")s(a===u.length-1?0:a+1);else if(c.code==="Enter"){let x=u[a];x&&z(x)}},[s,z,a,u]);(0,g.useEffect)(()=>{var c;(c=l.current[a])==null||c.focus()},[a]),(0,g.useEffect)(()=>{h||s(T)},[T,s,h]);let b=I.getVirtualItems();return(0,d.jsx)("div",{className:"flex-1 px-4",ref:w,style:{height:400,overflow:"auto"},children:(0,d.jsx)("div",{className:"relative w-full",style:{height:`${String(I.getTotalSize()||0)}px`},children:(0,d.jsx)("div",{className:"pb-4",style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${String((($=b[0])==null?void 0:$.start)||0)}px)`},children:I.getVirtualItems().map(c=>{let x=u[c.index];return(0,d.jsx)("div",{"data-index":c.index,ref:I.measureElement,"data-test":"select-item",children:(0,d.jsx)("div",{tabIndex:0,onClick:()=>j(this,null,function*(){typeof x!="undefined"&&(yield z(x))}),onKeyDown:N,ref:ce=>{ce&&(l.current[c.index]=ce)},className:(0,Ie.default)("bg-background hover:bg-accent mt-2.5 cursor-pointer space-x-2 rounded-xl border px-3 outline-none focus:ring focus:ring-blue-500",{"bg-secondary":t===x}),children:(0,d.jsx)("div",{className:"flex items-center justify-start text-sm",children:typeof x!="undefined"?o(x,t===x,{isLoading:P===x}):null})})},c.key)})})})})}var et=g.memo,tt=et(Qe);var H=require("react"),Se=require("@fortawesome/free-solid-svg-icons"),Ee=y(require("clsx"));var R=require("react/jsx-runtime");function it({isOpen:t,onOpenChange:e,className:i,title:r,value:o,items:n,isLoading:a,onChange:s,onSearch:l,renderTrigger:w,trigger:h,renderItem:u,children:T}){let[P,E]=(0,H.useState)(!1),I=(0,H.useCallback)(b=>j(this,null,function*(){yield s(b),E(!1)}),[s]),z=(0,H.useCallback)(b=>{b.preventDefault(),n.length&&E(!0)},[n]),N;return h?N=(0,H.cloneElement)(h,{onClick:z}):w&&(N=(0,R.jsxs)("button",{className:(0,Ee.default)("bg-background relative flex h-16 items-center space-x-2 rounded-xl border-2 px-4 py-3 text-left outline-none focus:ring focus:ring-blue-500",i),onClick:z,children:[(0,R.jsx)("div",{className:"flex-1 truncate",children:w(o)}),!a&&n.length>0&&(0,R.jsx)(S,{className:"text-muted",icon:Se.faCaretDown,size:"sm"}),a&&(0,R.jsx)("div",{className:"absolute inset-y-0 right-0",children:(0,R.jsx)("div",{className:"text-muted flex h-full items-center justify-center pr-4",children:(0,R.jsxs)("svg",{className:"h-5 w-5 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[(0,R.jsx)("circle",{className:"stroke-muted opacity-25",cx:"12",cy:"12",r:"10",strokeWidth:"4"}),(0,R.jsx)("path",{className:"fill-muted opacity-75",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})})]})),(0,R.jsx)(U,{title:r,isOpen:t!=null?t:P,onOpenChange:e!=null?e:E,trigger:N,children:(0,R.jsxs)("div",{className:"relative flex h-full flex-col",children:[(0,R.jsx)(le,{value:o,items:n,renderItem:u,onSearch:l,onChange:I,isLoading:a}),T]})})}var Ve=require("react");function rt(){let[t,e]=(0,Ve.useState)(null);return[t,r=>j(this,null,function*(){if(!("clipboard"in navigator))return console.warn("Clipboard not supported"),!1;try{return yield navigator.clipboard.writeText(r),e(r),!0}catch(o){return console.warn("Copy failed",o),e(null),!1}})]}
//# sourceMappingURL=index.js.map
{
"name": "@swing.xyz/design-system",
"version": "0.55.0",
"version": "0.55.1",
"publishConfig": {

@@ -10,3 +10,3 @@ "access": "public"

"type": "git",
"url": "https://github.com/polkaswitch/examples.git"
"url": "https://github.com/swing-xyz/swing.xyz.git"
},

@@ -76,11 +76,11 @@ "author": {

"dependencies": {
"@fortawesome/fontawesome-common-types": "^6.5.2",
"@fortawesome/free-solid-svg-icons": "^6.5.2",
"@fortawesome/fontawesome-common-types": "^6.6.0",
"@fortawesome/free-solid-svg-icons": "^6.6.0",
"@headlessui/react": "^1.7.19",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5",
"@tanstack/react-virtual": "^3.5.0",
"@radix-ui/react-avatar": "^1.1.0",
"@radix-ui/react-dialog": "^1.1.1",
"@tanstack/react-virtual": "^3.8.3",
"clsx": "^2.1.1",
"jotai": "^2.8.0",
"tailwind-merge": "^2.3.0"
"jotai": "^2.9.1",
"tailwind-merge": "^2.4.0"
},

@@ -92,12 +92,12 @@ "devDependencies": {

"@testing-library/react": "14.3.1",
"@vitejs/plugin-react": "^4.2.1",
"@vitejs/plugin-react": "^4.3.1",
"autoprefixer": "10.4.19",
"happy-dom": "^14.10.2",
"postcss": "^8.4.38",
"happy-dom": "^14.12.3",
"postcss": "^8.4.40",
"react": "18.3.1",
"react-dom": "18.3.1",
"tailwindcss": "^3.4.3",
"tsup": "^8.0.2",
"typescript": "^5.4.5",
"vite": "^5.2.11",
"tailwindcss": "^3.4.7",
"tsup": "^8.2.3",
"typescript": "^5.5.4",
"vite": "^5.3.5",
"vite-tsconfig-paths": "^4.3.2",

@@ -104,0 +104,0 @@ "vitest": "^1.6.0"

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