@next-degree/pickle-shared-js 0.3.19 → 0.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -1
- package/dist/app/layout.cjs +70 -1
- package/dist/app/layout.cjs.map +1 -1
- package/dist/app/layout.css +1263 -1
- package/dist/app/layout.css.map +1 -1
- package/dist/app/layout.js +35 -1
- package/dist/app/layout.js.map +1 -1
- package/dist/app/page.cjs +774 -1
- package/dist/app/page.cjs.map +1 -1
- package/dist/app/page.js +743 -1
- package/dist/app/page.js.map +1 -1
- package/dist/assets/fonts/AmbitBold.cjs +2 -1
- package/dist/assets/fonts/AmbitBold.js +5 -1
- package/dist/assets/fonts/AmbitBoldItalic.cjs +2 -1
- package/dist/assets/fonts/AmbitBoldItalic.js +5 -1
- package/dist/assets/fonts/AmbitRegular.cjs +2 -1
- package/dist/assets/fonts/AmbitRegular.js +5 -1
- package/dist/components/demos/ComboboxDemo.cjs +759 -1
- package/dist/components/demos/ComboboxDemo.cjs.map +1 -1
- package/dist/components/demos/ComboboxDemo.js +731 -1
- package/dist/components/demos/ComboboxDemo.js.map +1 -1
- package/dist/components/demos/index.cjs +767 -1
- package/dist/components/demos/index.cjs.map +1 -1
- package/dist/components/demos/index.js +736 -1
- package/dist/components/demos/index.js.map +1 -1
- package/dist/components/primitives/command.cjs +223 -1
- package/dist/components/primitives/command.cjs.map +1 -1
- package/dist/components/primitives/command.js +181 -1
- package/dist/components/primitives/command.js.map +1 -1
- package/dist/components/primitives/dialog.cjs +137 -1
- package/dist/components/primitives/dialog.cjs.map +1 -1
- package/dist/components/primitives/dialog.js +92 -1
- package/dist/components/primitives/dialog.js.map +1 -1
- package/dist/components/primitives/popover.cjs +72 -1
- package/dist/components/primitives/popover.cjs.map +1 -1
- package/dist/components/primitives/popover.js +36 -1
- package/dist/components/primitives/popover.js.map +1 -1
- package/dist/components/primitives/separator.cjs +67 -1
- package/dist/components/primitives/separator.cjs.map +1 -1
- package/dist/components/primitives/separator.js +33 -1
- package/dist/components/primitives/separator.js.map +1 -1
- package/dist/components/ui/Badge.cjs +57 -1
- package/dist/components/ui/Badge.cjs.map +1 -1
- package/dist/components/ui/Badge.js +31 -1
- package/dist/components/ui/Badge.js.map +1 -1
- package/dist/components/ui/Button.cjs +145 -1
- package/dist/components/ui/Button.cjs.map +1 -1
- package/dist/components/ui/Button.js +118 -1
- package/dist/components/ui/Button.js.map +1 -1
- package/dist/components/ui/Checkbox.cjs +99 -1
- package/dist/components/ui/Checkbox.cjs.map +1 -1
- package/dist/components/ui/Checkbox.js +71 -1
- package/dist/components/ui/Checkbox.js.map +1 -1
- package/dist/components/ui/Chip.cjs +49 -1
- package/dist/components/ui/Chip.cjs.map +1 -1
- package/dist/components/ui/Chip.js +28 -1
- package/dist/components/ui/Chip.js.map +1 -1
- package/dist/components/ui/Combobox.cjs +564 -1
- package/dist/components/ui/Combobox.cjs.map +1 -1
- package/dist/components/ui/Combobox.js +532 -1
- package/dist/components/ui/Combobox.js.map +1 -1
- package/dist/components/ui/Label.cjs +50 -1
- package/dist/components/ui/Label.cjs.map +1 -1
- package/dist/components/ui/Label.js +27 -1
- package/dist/components/ui/Label.js.map +1 -1
- package/dist/components/ui/ListItem.cjs +151 -1
- package/dist/components/ui/ListItem.cjs.map +1 -1
- package/dist/components/ui/ListItem.js +120 -1
- package/dist/components/ui/ListItem.js.map +1 -1
- package/dist/components/ui/Select.cjs +246 -1
- package/dist/components/ui/Select.cjs.map +1 -1
- package/dist/components/ui/Select.js +221 -1
- package/dist/components/ui/Select.js.map +1 -1
- package/dist/index.cjs +855 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +817 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/utils.cjs +34 -1
- package/dist/lib/utils.cjs.map +1 -1
- package/dist/lib/utils.js +9 -1
- package/dist/lib/utils.js.map +1 -1
- package/dist/styles/globals.css +1263 -1
- package/dist/styles/globals.css.map +1 -1
- package/package.json +14 -17
package/dist/index.js
CHANGED
|
@@ -1,2 +1,818 @@
|
|
|
1
|
-
import*as m from"@radix-ui/react-select";import{CheckIcon as _e,ChevronDownIcon as He,X as Be}from"lucide-react";import{forwardRef as Ae,useEffect as Ge,useRef as Ke,useState as de}from"react";import{clsx as De}from"clsx";import{twMerge as Ee}from"tailwind-merge";function a(...e){return Ee(De(e))}import{jsx as Le}from"react/jsx-runtime";function Ie({text:e,className:t,...o}){return e?Le("label",{className:a("text-xs text-grey-80 peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...o,children:e}):null}var A=Ie;import{cva as Te}from"cva";import{twMerge as Ve}from"tailwind-merge";import{jsx as Me}from"react/jsx-runtime";var ze=({className:e,variant:t,size:o,...i})=>Me("div",{className:Ve(We({variant:t,size:o,className:e})),...i}),We=Te(["flex","items-center","rounded-3xl","border","w-fit"],{variants:{variant:{neutral:["text-grey-80","border-grey-10"],primary:["text-purple-100","border-purple-20"],danger:["text-pumpkin-100","border-pumpkin-20"],onboarding:["text-green-100","bg-green-10","cursor-pointer"],onboardingSelected:["text-white","bg-green-90","cursor-pointer"]},size:{small:["text-sm","leading-5","px-2","py-1","gap-1.5"],medium:["text-base","leading-6","px-3","py-2","gap-2"]}},defaultVariants:{variant:"neutral",size:"medium"}}),U=ze;import*as Y from"@radix-ui/react-separator";import*as pe from"react";import{jsx as Oe}from"react/jsx-runtime";var G=pe.forwardRef(({className:e,orientation:t="horizontal",decorative:o=!0,...i},s)=>Oe(Y.Root,{ref:s,decorative:o,orientation:t,className:a("shrink-0 bg-grey-10",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...i}));G.displayName=Y.Root.displayName;import{jsx as y,jsxs as z}from"react/jsx-runtime";var ce=Ae(({label:e,options:t,placeholder:o,multiselect:i,classNames:s,...f},x)=>{let{value:b,defaultValue:S,dir:E,className:P,onChange:O,...I}=f,[C,u]=de([]),[L,T]=de(!1),_=Ke(null);Ge(()=>{if(!b)return u([]);u(Array.isArray(b)?b:[b])},[b]);let $=()=>T(r=>!r),q=r=>r.key==="Escape"&&T(!1),D=(r,l)=>r.key==="Enter"&&V(l),J=C?.map(r=>t?.find(({value:l})=>l===r)).filter(Boolean);function H(){return i?C.map(r=>t?.find(l=>l.value===r)?.title).join(", "):t?.find(r=>r.value===C.join())?.title}function Q(r){(!i||r)&&T(r)}function V(r){let l=[];u(n=>(l=n.includes(r)?n.filter(g=>g!==r):[...n,r],i?l:[r])),O?.(i?l:r)}return z("div",{className:a("flex flex-col space-y-2",P),ref:_,children:[y(A,{text:e,className:s?.label}),z(m.Root,{open:L,value:C.join(","),onOpenChange:Q,onValueChange:i?void 0:V,defaultValue:typeof S=="string"?S:void 0,dir:E==="rtl"?"rtl":"ltr",...I,children:[z(m.Trigger,{ref:x,"data-testid":`${e.toLowerCase()}-select-element`,className:"group flex min-w-80 flex-row items-center justify-between gap-3 rounded-lg border border-grey-20 px-4 py-3 text-sm font-normal focus:outline-purple-100 disabled:bg-grey-5 data-[placeholder]:text-grey-50 data-[placeholder]:disabled:text-grey-40",children:[y("span",{className:"truncate",children:y(m.Value,{placeholder:o??"Select an option","aria-label":H(),children:H()})}),y(He,{className:"transform text-black group-data-[state=open]:rotate-180",size:"16"})]}),y(m.Portal,{container:_.current,children:y(m.Content,{hideWhenDetached:!0,className:"z-10 max-h-[var(--radix-select-content-available-height)] w-[var(--radix-select-trigger-width)] overflow-hidden rounded-md bg-white py-2 shadow-lg",position:"popper",sideOffset:4,onPointerDownOutside:$,onKeyDown:q,children:z(m.Viewport,{children:[i&&!!J?.length&&y(m.Group,{className:"mb-2 flex flex-row flex-wrap gap-1 px-2","data-testid":"selected-labels",children:J?.map(r=>r&&z(U,{size:"small",variant:"primary",children:[y("span",{children:r.title}),y(Be,{size:18,"data-testid":`chip-remove-${r.value}`,className:"cursor-pointer",onClick:()=>V(r.value)})]},r.title))}),y(G,{}),t?.map(({id:r,title:l,value:n})=>z(m.Item,{value:n,className:"group relative cursor-pointer px-4 py-2 text-left text-sm hover:bg-purple-50 focus:bg-purple-50 focus:outline-none data-[state=checked]:bg-purple-50 data-[state=checked]:pr-10 data-[state=checked]:text-purple-100","data-state":C.includes(n)?"checked":"unchecked",onKeyDown:g=>D(g,n),onClick:()=>V(n),children:[y(m.ItemText,{children:l}),y(_e,{className:"absolute inset-y-0 right-3 my-auto hidden w-6 text-purple-100 group-data-[state=checked]:block",size:16})]},r))]})})})]})]})});ce.displayName="Select";var Xe=ce;import*as X from"@radix-ui/react-checkbox";import{Check as Fe,Minus as $e}from"lucide-react";import{forwardRef as fe}from"react";import{jsx as K,jsxs as he}from"react/jsx-runtime";var ue=fe(({className:e,...t},o)=>K(X.Root,{ref:o,className:a("group","peer","h-5","w-5","shrink-0","rounded-md","border","border-grey-10","outline","outline-1","outline-offset-2","outline-transparent","hover:border-grey-20","focus:outline-purple-100","active:border-green-80","disabled:cursor-not-allowed","disabled:opacity-50","data-[state=checked]:bg-green-80","data-[state=indeterminate]:bg-green-80","data-[state=checked]:text-white","data-[state=indeterminate]:text-primary-foreground",t.disabled&&"data-[state=checked]:text-foreground bg-grey-20 data-[state=checked]:bg-grey-20",e),...t,children:he(X.Indicator,{className:"flex items-center justify-center text-current",children:[K(Fe,{className:"hidden h-4 w-4 group-data-[state=checked]:block"}),K($e,{className:"hidden h-4 w-4 group-data-[state=indeterminate]:block"})]})}));ue.displayName=X.Root.displayName;var ge=fe(({classNames:e,children:t,...o},i)=>{let{disabled:s}=o,f=o.id??`${o.name??o.value?.toString()}-checkbox`,x=s?"text-grey-40 pointer-events-none":"";return he("div",{className:a("flex space-x-2",e?.wrapper),children:[K(ue,{id:f,disabled:s,ref:i,...o}),K("label",{htmlFor:f,className:a(x,e?.label),children:t})]})});ge.displayName="Checkbox";var Z=ge;import{CheckIcon as Je}from"lucide-react";import{icons as ve}from"lucide-react";import{jsx as W,jsxs as ye}from"react/jsx-runtime";function qe({icon:e,hasCheckbox:t,isSelected:o,className:i,title:s,value:f,description:x,...b}){let E=e?(P=>{if(P in ve){let O=ve[P];return W(O,{size:14})}return null})(e):void 0;return ye("li",{className:a("group relative flex w-72 cursor-pointer flex-row items-center text-left text-sm",i),...b,"data-state":o?"checked":"unchecked",children:[E&&W("span",{className:"mr-2",children:E}),t&&W(Z,{id:f,checked:o,onClick:P=>P.preventDefault()}),ye("div",{children:[W("p",{children:s}),W("p",{className:"text-xs text-grey-80",children:x})]}),W(Je,{className:"absolute inset-y-0 right-0 my-auto hidden w-6 text-green-100 group-data-[state=checked]:block",size:16})]})}var j=qe;import{Slot as Qe}from"@radix-ui/react-slot";import{cva as Ue}from"cva";import{forwardRef as Ye}from"react";import{jsx as je}from"react/jsx-runtime";var xe=Ye(({className:e,variant:t,size:o,asChild:i=!1,...s},f)=>je(i?Qe:"button",{className:a(Ze({variant:t,size:o,className:e})),ref:f,...s}));xe.displayName="Button";var Ze=Ue(["flex","items-center","justify-center","gap-2","rounded-full","font-bold","outline-2","outline-offset-2","outline-dashed","outline-transparent"],{variants:{variant:{neutral:["bg-black","text-white","hover:bg-grey-90","active:bg-grey-80","focus:outline-purple-100","disabled:text-grey-40","disabled:bg-grey-10"],primary:["bg-pickle-100","text-black","hover:bg-pickle-80","active:bg-pickle-60","focus:outline-purple-100","disabled:text-grey-40","disabled:bg-grey-10"],secondary:["bg-green-80","text-white","hover:bg-green-90","active:bg-green-100","focus:outline-pickle-100","disabled:text-grey-40","disabled:bg-grey-10"],transparent:["text-white","hover:bg-green-80","active:bg-green-100","focus:outline-pickle-100","disabled:text-grey-40"],link:["leading-tight","text-black","underline","hover:text-purple-100","focus:text-black","focus:outline-purple-100","active:text-purple-80"]},size:{small:["h-10","text-sm","px-4","py-2"],medium:["h-12","text-base","px-6","py-3"],large:["h-14","text-lg","px-8","py-4"]}},defaultVariants:{variant:"neutral",size:"medium"},compoundVariants:[{variant:"link",size:"small",class:["h-3","text-xs","p-0"]},{variant:"link",size:"medium",class:["h-4","text-sm","p-0"]},{variant:"link",size:"large",class:["h-6","text-base","p-0"]}]});import{forwardRef as ft,useEffect as ut,useState as we}from"react";import{ChevronDownIcon as gt,CircleX as ht,icons as vt}from"lucide-react";import{cva as yt}from"cva";import{Command as c}from"cmdk";import{Search as nt}from"lucide-react";import*as w from"react";import*as p from"@radix-ui/react-dialog";import{X as et}from"lucide-react";import*as F from"react";import{jsx as N,jsxs as ee}from"react/jsx-runtime";var tt=p.Portal;var be=F.forwardRef(({className:e,...t},o)=>N(p.Overlay,{ref:o,className:a("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));be.displayName=p.Overlay.displayName;var Pe=F.forwardRef(({className:e,children:t,...o},i)=>ee(tt,{children:[N(be,{}),ee(p.Content,{ref:i,className:a("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-neutral-200 bg-white p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg dark:border-neutral-800 dark:bg-neutral-950",e),...o,children:[t,ee(p.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-neutral-950 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-neutral-100 data-[state=open]:text-neutral-500 dark:ring-offset-neutral-950 dark:focus:ring-neutral-300 dark:data-[state=open]:bg-neutral-800 dark:data-[state=open]:text-neutral-400",children:[N(et,{className:"h-4 w-4"}),N("span",{className:"sr-only",children:"Close"})]})]})]}));Pe.displayName=p.Content.displayName;var ot=({className:e,...t})=>N("div",{className:a("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});ot.displayName="DialogHeader";var at=({className:e,...t})=>N("div",{className:a("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});at.displayName="DialogFooter";var rt=F.forwardRef(({className:e,...t},o)=>N(p.Title,{ref:o,className:a("text-lg font-semibold leading-none tracking-tight",e),...t}));rt.displayName=p.Title.displayName;var it=F.forwardRef(({className:e,...t},o)=>N(p.Description,{ref:o,className:a("text-sm text-neutral-500 dark:text-neutral-400",e),...t}));it.displayName=p.Description.displayName;import{jsx as R,jsxs as mt}from"react/jsx-runtime";var te=w.forwardRef(({className:e,...t},o)=>R(c,{ref:o,className:a("flex h-full w-full flex-col overflow-hidden rounded-xl bg-white text-neutral-950",e),...t}));te.displayName=c.displayName;var oe=w.forwardRef(({className:e,...t},o)=>mt("div",{className:"m-1 flex items-center rounded-xl border px-3","cmdk-input-wrapper":"",children:[R(nt,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),R(c.Input,{ref:o,className:a("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-neutral-500 disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));oe.displayName=c.Input.displayName;var ae=w.forwardRef(({className:e,...t},o)=>R(c.List,{ref:o,className:a("overflow-y-auto overflow-x-hidden",e),...t}));ae.displayName=c.List.displayName;var re=w.forwardRef((e,t)=>R(c.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));re.displayName=c.Empty.displayName;var ie=w.forwardRef(({className:e,...t},o)=>R(c.Group,{ref:o,className:a("overflow-hidden p-1 text-neutral-950 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-neutral-500",e),...t}));ie.displayName=c.Group.displayName;var lt=w.forwardRef(({className:e,...t},o)=>R(c.Separator,{ref:o,className:a("-mx-1 h-px bg-neutral-200",e),...t}));lt.displayName=c.Separator.displayName;var ne=w.forwardRef(({className:e,...t},o)=>R(c.Item,{ref:o,className:a("relative flex cursor-pointer select-none items-center rounded-xl px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-neutral-100 data-[selected=true]:text-neutral-900 data-[disabled=true]:opacity-50",e),...t}));ne.displayName=c.Item.displayName;var st=({className:e,...t})=>R("span",{className:a("ml-auto text-xs tracking-widest text-neutral-500",e),...t});st.displayName="CommandShortcut";import*as Re from"react";import*as k from"@radix-ui/react-popover";import{jsx as Ce}from"react/jsx-runtime";var ke=k.Root,Ne=k.Trigger,le=Re.forwardRef(({className:e,align:t="center",sideOffset:o=4,...i},s)=>Ce(k.Portal,{children:Ce(k.Content,{ref:s,align:t,sideOffset:o,className:a("z-50 rounded-2xl border bg-white p-4 text-black shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...i})}));le.displayName=k.Content.displayName;import{cva as pt}from"cva";import{jsx as ct}from"react/jsx-runtime";var dt=pt("rounded-full px-2 py-0.5 text-xs font-semibold",{variants:{variant:{green:"bg-green-90 text-white",pickle:"bg-pickle-100 text-black",purple:"bg-purple-100 text-white"}},defaultVariants:{variant:"green"}});function se({className:e,variant:t,...o}){return ct("div",{className:a(dt({variant:t}),e),...o})}import{jsx as d,jsxs as M}from"react/jsx-runtime";var Se=ft((e,t)=>{let{value:o,label:i,options:s,classNames:f,multiselect:x,placeholder:b,variant:S="default",size:E,icon:P,className:O,onChange:I,children:C}=e,[u,L]=we([]),[T,_]=we(!1),$=P&&vt[P],q=s?.length<=5,D=S==="default",J=S==="chip",H=()=>_(!1);ut(()=>{L((x?o??[]:o?[o]:[]).map(n=>s.find(g=>g.value===n)).filter(n=>n!==void 0))},[o]);let Q=l=>{let n=s.find(g=>g.value===l);if(n){if(x)return L(g=>{let me=g.some(B=>B.value===l)?g.filter(B=>B!==n):[...g,n];return I?.(me.map(B=>B.value)),me});L([n]),I?.(n.value),H()}},V=()=>{L([]),I?.(x?[]:"")},r=()=>{let l=u.length>0?u.map(n=>n.title).join(", "):b;return D?l:i};return M("div",{className:a("flex flex-col gap-2",O),children:[D&&i&&d(A,{text:i,className:f?.label}),M("div",{className:"relative flex",children:[M(ke,{open:T,onOpenChange:_,children:[d(Ne,{asChild:!0,disabled:s.length===0,children:M("div",{ref:t,className:a(xt({variant:S,size:E}),u.length>0&&"pr-10",f?.trigger),"aria-expanded":T,children:[D&&$&&d($,{className:"h-4 w-4 shrink-0"}),J&&u.length>0&&d(se,{variant:"purple",children:u.length}),d("span",{className:a("w-full truncate leading-normal",D&&u.length==0&&"text-grey-40"),children:r()}),u.length==0&&d(gt,{className:"shrink-0 transform group-data-[state=open]:rotate-180",size:"16"})]})}),d(te,{children:M(le,{className:a("flex w-full max-w-xs flex-col overflow-hidden p-0","max-h-[--radix-popover-content-available-height]",f?.content),collisionPadding:8,sideOffset:4,align:"start",children:[!q&&d(oe,{placeholder:"Search..."}),M(ae,{children:[d(re,{children:"No results"}),d(ie,{children:s.map(({id:l,...n})=>d(ne,{value:n.title,onSelect:Q,children:d(j,{className:a(f?.items,"truncate py-1"),isSelected:u.some(g=>g.value===n.value),hasCheckbox:x,...n})},l))})]}),!!C&&d(G,{}),C&&C({close:H})]})})]}),D&&u.length>0&&d("button",{type:"button",className:"absolute inset-y-0 right-1 my-auto flex h-8 w-8 cursor-pointer items-center justify-center rounded-full hover:bg-pickle-20",onClick:V,children:d(ht,{className:"h-4 w-4 text-green-100"})})]})]})});Se.displayName="Combobox";var xt=yt("group relative cursor-pointer text-green-100 flex flex-row items-center justify-between gap-2 border border-grey-20 focus:outline-green-80 disabled:bg-grey-5",{variants:{variant:{default:["w-full","max-w-80","rounded-lg"],chip:["font-bold","rounded-3xl","data-[state=open]:bg-black","data-[state=open]:text-white"]},size:{small:["h-8","py-1","px-2","text-xs"],normal:["h-9","py-2","px-3","text-sm"],large:["h-10","py-3","px-4","text-base"]}},defaultVariants:{variant:"default",size:"normal"}});export{se as Badge,xe as Button,Z as Checkbox,U as Chip,Se as Combobox,A as Label,j as ListItem,Xe as Select,a as cn};
|
|
1
|
+
// src/components/ui/Select.tsx
|
|
2
|
+
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
3
|
+
import { CheckIcon, ChevronDownIcon, X } from "lucide-react";
|
|
4
|
+
import {
|
|
5
|
+
forwardRef as forwardRef2,
|
|
6
|
+
useEffect,
|
|
7
|
+
useRef,
|
|
8
|
+
useState
|
|
9
|
+
} from "react";
|
|
10
|
+
|
|
11
|
+
// src/lib/utils.ts
|
|
12
|
+
import { clsx } from "clsx";
|
|
13
|
+
import { twMerge } from "tailwind-merge";
|
|
14
|
+
function cn(...inputs) {
|
|
15
|
+
return twMerge(clsx(inputs));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// src/components/ui/Label.tsx
|
|
19
|
+
import { jsx } from "react/jsx-runtime";
|
|
20
|
+
function Label({ text, className, ...props }) {
|
|
21
|
+
if (!text) return null;
|
|
22
|
+
return /* @__PURE__ */ jsx(
|
|
23
|
+
"label",
|
|
24
|
+
{
|
|
25
|
+
className: cn(
|
|
26
|
+
"text-xs text-grey-80 peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
27
|
+
className
|
|
28
|
+
),
|
|
29
|
+
...props,
|
|
30
|
+
children: text
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
var Label_default = Label;
|
|
35
|
+
|
|
36
|
+
// src/components/ui/Chip.tsx
|
|
37
|
+
import { cva } from "cva";
|
|
38
|
+
import { twMerge as twMerge2 } from "tailwind-merge";
|
|
39
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
40
|
+
var Chip = ({ className, variant, size, ...props }) => /* @__PURE__ */ jsx2("div", { className: twMerge2(chipVariants({ variant, size, className })), ...props });
|
|
41
|
+
var chipVariants = cva(["flex", "items-center", "rounded-3xl", "border", "w-fit"], {
|
|
42
|
+
variants: {
|
|
43
|
+
variant: {
|
|
44
|
+
neutral: ["text-grey-80", "border-grey-10"],
|
|
45
|
+
primary: ["text-purple-100", "border-purple-20"],
|
|
46
|
+
danger: ["text-pumpkin-100", "border-pumpkin-20"],
|
|
47
|
+
onboarding: ["text-green-100", "bg-green-10", "cursor-pointer"],
|
|
48
|
+
onboardingSelected: ["text-white", "bg-green-90", "cursor-pointer"]
|
|
49
|
+
},
|
|
50
|
+
size: {
|
|
51
|
+
small: ["text-sm", "leading-5", "px-2", "py-1", "gap-1.5"],
|
|
52
|
+
medium: ["text-base", "leading-6", "px-3", "py-2", "gap-2"]
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
defaultVariants: {
|
|
56
|
+
variant: "neutral",
|
|
57
|
+
size: "medium"
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
var Chip_default = Chip;
|
|
61
|
+
|
|
62
|
+
// src/components/primitives/separator.tsx
|
|
63
|
+
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
|
64
|
+
import * as React from "react";
|
|
65
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
66
|
+
var Separator = React.forwardRef(({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ jsx3(
|
|
67
|
+
SeparatorPrimitive.Root,
|
|
68
|
+
{
|
|
69
|
+
ref,
|
|
70
|
+
decorative,
|
|
71
|
+
orientation,
|
|
72
|
+
className: cn(
|
|
73
|
+
"shrink-0 bg-grey-10",
|
|
74
|
+
orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
|
|
75
|
+
className
|
|
76
|
+
),
|
|
77
|
+
...props
|
|
78
|
+
}
|
|
79
|
+
));
|
|
80
|
+
Separator.displayName = SeparatorPrimitive.Root.displayName;
|
|
81
|
+
|
|
82
|
+
// src/components/ui/Select.tsx
|
|
83
|
+
import { jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
84
|
+
var Select = forwardRef2(
|
|
85
|
+
({ label, options, placeholder, multiselect, classNames, ...props }, ref) => {
|
|
86
|
+
const { value, defaultValue, dir, className, onChange, ...rest } = props;
|
|
87
|
+
const [selected, setSelected] = useState([]);
|
|
88
|
+
const [open, setOpen] = useState(false);
|
|
89
|
+
const containerRef = useRef(null);
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (!value) return setSelected([]);
|
|
92
|
+
setSelected(Array.isArray(value) ? value : [value]);
|
|
93
|
+
}, [value]);
|
|
94
|
+
const toggleOpen = () => setOpen((prev) => !prev);
|
|
95
|
+
const closeOnEscape = (event) => event.key === "Escape" && setOpen(false);
|
|
96
|
+
const setValueOnEnter = (event, value2) => event.key === "Enter" && handleChange(value2);
|
|
97
|
+
const chipLabels = selected?.map((s) => options?.find(({ value: value2 }) => value2 === s)).filter(Boolean);
|
|
98
|
+
function handleLabels() {
|
|
99
|
+
if (multiselect) {
|
|
100
|
+
return selected.map((o) => options?.find((option) => option.value === o)?.title).join(", ");
|
|
101
|
+
}
|
|
102
|
+
return options?.find((option) => option.value === selected.join())?.title;
|
|
103
|
+
}
|
|
104
|
+
function handleOnOpenChange(isOpen) {
|
|
105
|
+
if (!multiselect || isOpen) setOpen(isOpen);
|
|
106
|
+
}
|
|
107
|
+
function handleChange(newValue) {
|
|
108
|
+
let newSelected = [];
|
|
109
|
+
setSelected((prev) => {
|
|
110
|
+
newSelected = prev.includes(newValue) ? prev.filter((item) => item !== newValue) : [...prev, newValue];
|
|
111
|
+
return multiselect ? newSelected : [newValue];
|
|
112
|
+
});
|
|
113
|
+
onChange?.(multiselect ? newSelected : newValue);
|
|
114
|
+
}
|
|
115
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col space-y-2", className), ref: containerRef, children: [
|
|
116
|
+
/* @__PURE__ */ jsx4(Label_default, { text: label, className: classNames?.label }),
|
|
117
|
+
/* @__PURE__ */ jsxs(
|
|
118
|
+
SelectPrimitive.Root,
|
|
119
|
+
{
|
|
120
|
+
open,
|
|
121
|
+
value: selected.join(","),
|
|
122
|
+
onOpenChange: handleOnOpenChange,
|
|
123
|
+
onValueChange: multiselect ? void 0 : handleChange,
|
|
124
|
+
defaultValue: typeof defaultValue === "string" ? defaultValue : void 0,
|
|
125
|
+
dir: dir === "rtl" ? "rtl" : "ltr",
|
|
126
|
+
...rest,
|
|
127
|
+
children: [
|
|
128
|
+
/* @__PURE__ */ jsxs(
|
|
129
|
+
SelectPrimitive.Trigger,
|
|
130
|
+
{
|
|
131
|
+
ref,
|
|
132
|
+
"data-testid": `${label.toLowerCase()}-select-element`,
|
|
133
|
+
className: "group flex min-w-80 flex-row items-center justify-between gap-3 rounded-lg border border-grey-20 px-4 py-3 text-sm font-normal focus:outline-purple-100 disabled:bg-grey-5 data-[placeholder]:text-grey-50 data-[placeholder]:disabled:text-grey-40",
|
|
134
|
+
children: [
|
|
135
|
+
/* @__PURE__ */ jsx4("span", { className: "truncate", children: /* @__PURE__ */ jsx4(
|
|
136
|
+
SelectPrimitive.Value,
|
|
137
|
+
{
|
|
138
|
+
placeholder: placeholder ?? "Select an option",
|
|
139
|
+
"aria-label": handleLabels(),
|
|
140
|
+
children: handleLabels()
|
|
141
|
+
}
|
|
142
|
+
) }),
|
|
143
|
+
/* @__PURE__ */ jsx4(
|
|
144
|
+
ChevronDownIcon,
|
|
145
|
+
{
|
|
146
|
+
className: "transform text-black group-data-[state=open]:rotate-180",
|
|
147
|
+
size: "16"
|
|
148
|
+
}
|
|
149
|
+
)
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
),
|
|
153
|
+
/* @__PURE__ */ jsx4(SelectPrimitive.Portal, { container: containerRef.current, children: /* @__PURE__ */ jsx4(
|
|
154
|
+
SelectPrimitive.Content,
|
|
155
|
+
{
|
|
156
|
+
hideWhenDetached: true,
|
|
157
|
+
className: "z-10 max-h-[var(--radix-select-content-available-height)] w-[var(--radix-select-trigger-width)] overflow-hidden rounded-md bg-white py-2 shadow-lg",
|
|
158
|
+
position: "popper",
|
|
159
|
+
sideOffset: 4,
|
|
160
|
+
onPointerDownOutside: toggleOpen,
|
|
161
|
+
onKeyDown: closeOnEscape,
|
|
162
|
+
children: /* @__PURE__ */ jsxs(SelectPrimitive.Viewport, { children: [
|
|
163
|
+
multiselect && !!chipLabels?.length && /* @__PURE__ */ jsx4(
|
|
164
|
+
SelectPrimitive.Group,
|
|
165
|
+
{
|
|
166
|
+
className: "mb-2 flex flex-row flex-wrap gap-1 px-2",
|
|
167
|
+
"data-testid": "selected-labels",
|
|
168
|
+
children: chipLabels?.map(
|
|
169
|
+
(chip) => chip && /* @__PURE__ */ jsxs(Chip_default, { size: "small", variant: "primary", children: [
|
|
170
|
+
/* @__PURE__ */ jsx4("span", { children: chip.title }),
|
|
171
|
+
/* @__PURE__ */ jsx4(
|
|
172
|
+
X,
|
|
173
|
+
{
|
|
174
|
+
size: 18,
|
|
175
|
+
"data-testid": `chip-remove-${chip.value}`,
|
|
176
|
+
className: "cursor-pointer",
|
|
177
|
+
onClick: () => handleChange(chip.value)
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
] }, chip.title)
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
/* @__PURE__ */ jsx4(Separator, {}),
|
|
185
|
+
options?.map(({ id, title, value: value2 }) => /* @__PURE__ */ jsxs(
|
|
186
|
+
SelectPrimitive.Item,
|
|
187
|
+
{
|
|
188
|
+
value: value2,
|
|
189
|
+
className: "group relative cursor-pointer px-4 py-2 text-left text-sm hover:bg-purple-50 focus:bg-purple-50 focus:outline-none data-[state=checked]:bg-purple-50 data-[state=checked]:pr-10 data-[state=checked]:text-purple-100",
|
|
190
|
+
"data-state": selected.includes(value2) ? "checked" : "unchecked",
|
|
191
|
+
onKeyDown: (e) => setValueOnEnter(e, value2),
|
|
192
|
+
onClick: () => handleChange(value2),
|
|
193
|
+
children: [
|
|
194
|
+
/* @__PURE__ */ jsx4(SelectPrimitive.ItemText, { children: title }),
|
|
195
|
+
/* @__PURE__ */ jsx4(
|
|
196
|
+
CheckIcon,
|
|
197
|
+
{
|
|
198
|
+
className: "absolute inset-y-0 right-3 my-auto hidden w-6 text-purple-100 group-data-[state=checked]:block",
|
|
199
|
+
size: 16
|
|
200
|
+
}
|
|
201
|
+
)
|
|
202
|
+
]
|
|
203
|
+
},
|
|
204
|
+
id
|
|
205
|
+
))
|
|
206
|
+
] })
|
|
207
|
+
}
|
|
208
|
+
) })
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
)
|
|
212
|
+
] });
|
|
213
|
+
}
|
|
214
|
+
);
|
|
215
|
+
Select.displayName = "Select";
|
|
216
|
+
var Select_default = Select;
|
|
217
|
+
|
|
218
|
+
// src/components/ui/Checkbox.tsx
|
|
219
|
+
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
220
|
+
import { Check, Minus } from "lucide-react";
|
|
221
|
+
import {
|
|
222
|
+
forwardRef as forwardRef3
|
|
223
|
+
} from "react";
|
|
224
|
+
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
225
|
+
var CheckboxToggle = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */ jsx5(
|
|
226
|
+
CheckboxPrimitive.Root,
|
|
227
|
+
{
|
|
228
|
+
ref,
|
|
229
|
+
className: cn(
|
|
230
|
+
"group",
|
|
231
|
+
"peer",
|
|
232
|
+
"h-5",
|
|
233
|
+
"w-5",
|
|
234
|
+
"shrink-0",
|
|
235
|
+
"rounded-md",
|
|
236
|
+
"border",
|
|
237
|
+
"border-grey-10",
|
|
238
|
+
"outline",
|
|
239
|
+
"outline-1",
|
|
240
|
+
"outline-offset-2",
|
|
241
|
+
"outline-transparent",
|
|
242
|
+
"hover:border-grey-20",
|
|
243
|
+
"focus:outline-purple-100",
|
|
244
|
+
"active:border-green-80",
|
|
245
|
+
"disabled:cursor-not-allowed",
|
|
246
|
+
"disabled:opacity-50",
|
|
247
|
+
"data-[state=checked]:bg-green-80",
|
|
248
|
+
"data-[state=indeterminate]:bg-green-80",
|
|
249
|
+
"data-[state=checked]:text-white",
|
|
250
|
+
"data-[state=indeterminate]:text-primary-foreground",
|
|
251
|
+
props.disabled && "data-[state=checked]:text-foreground bg-grey-20 data-[state=checked]:bg-grey-20",
|
|
252
|
+
className
|
|
253
|
+
),
|
|
254
|
+
...props,
|
|
255
|
+
children: /* @__PURE__ */ jsxs2(CheckboxPrimitive.Indicator, { className: "flex items-center justify-center text-current", children: [
|
|
256
|
+
/* @__PURE__ */ jsx5(Check, { className: "hidden h-4 w-4 group-data-[state=checked]:block" }),
|
|
257
|
+
/* @__PURE__ */ jsx5(Minus, { className: "hidden h-4 w-4 group-data-[state=indeterminate]:block" })
|
|
258
|
+
] })
|
|
259
|
+
}
|
|
260
|
+
));
|
|
261
|
+
CheckboxToggle.displayName = CheckboxPrimitive.Root.displayName;
|
|
262
|
+
var Checkbox = forwardRef3(
|
|
263
|
+
({ classNames, children, ...props }, ref) => {
|
|
264
|
+
const { disabled } = props;
|
|
265
|
+
const id = props.id ?? `${props.name ?? props.value?.toString()}-checkbox`;
|
|
266
|
+
const labelClassName = disabled ? "text-grey-40 pointer-events-none" : "";
|
|
267
|
+
return /* @__PURE__ */ jsxs2("div", { className: cn("flex space-x-2", classNames?.wrapper), children: [
|
|
268
|
+
/* @__PURE__ */ jsx5(CheckboxToggle, { id, disabled, ref, ...props }),
|
|
269
|
+
/* @__PURE__ */ jsx5("label", { htmlFor: id, className: cn(labelClassName, classNames?.label), children })
|
|
270
|
+
] });
|
|
271
|
+
}
|
|
272
|
+
);
|
|
273
|
+
Checkbox.displayName = "Checkbox";
|
|
274
|
+
var Checkbox_default = Checkbox;
|
|
275
|
+
|
|
276
|
+
// src/components/ui/ListItem.tsx
|
|
277
|
+
import { CheckIcon as CheckIcon2 } from "lucide-react";
|
|
278
|
+
import { icons } from "lucide-react";
|
|
279
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
280
|
+
function ListItem({
|
|
281
|
+
icon,
|
|
282
|
+
hasCheckbox,
|
|
283
|
+
isSelected,
|
|
284
|
+
className,
|
|
285
|
+
title,
|
|
286
|
+
value,
|
|
287
|
+
description,
|
|
288
|
+
...props
|
|
289
|
+
}) {
|
|
290
|
+
const getIconIfValid = (icon2) => {
|
|
291
|
+
if (icon2 in icons) {
|
|
292
|
+
const IconComponent = icons[icon2];
|
|
293
|
+
return /* @__PURE__ */ jsx6(IconComponent, { size: 14 });
|
|
294
|
+
}
|
|
295
|
+
return null;
|
|
296
|
+
};
|
|
297
|
+
const optionIcon = icon ? getIconIfValid(icon) : void 0;
|
|
298
|
+
return /* @__PURE__ */ jsxs3(
|
|
299
|
+
"li",
|
|
300
|
+
{
|
|
301
|
+
className: cn(
|
|
302
|
+
"group relative flex w-72 cursor-pointer flex-row items-center text-left text-sm",
|
|
303
|
+
className
|
|
304
|
+
),
|
|
305
|
+
...props,
|
|
306
|
+
"data-state": isSelected ? "checked" : "unchecked",
|
|
307
|
+
children: [
|
|
308
|
+
optionIcon && /* @__PURE__ */ jsx6("span", { className: "mr-2", children: optionIcon }),
|
|
309
|
+
hasCheckbox && /* @__PURE__ */ jsx6(Checkbox_default, { id: value, checked: isSelected, onClick: (e) => e.preventDefault() }),
|
|
310
|
+
/* @__PURE__ */ jsxs3("div", { children: [
|
|
311
|
+
/* @__PURE__ */ jsx6("p", { children: title }),
|
|
312
|
+
/* @__PURE__ */ jsx6("p", { className: "text-xs text-grey-80", children: description })
|
|
313
|
+
] }),
|
|
314
|
+
/* @__PURE__ */ jsx6(
|
|
315
|
+
CheckIcon2,
|
|
316
|
+
{
|
|
317
|
+
className: "absolute inset-y-0 right-0 my-auto hidden w-6 text-green-100 group-data-[state=checked]:block",
|
|
318
|
+
size: 16
|
|
319
|
+
}
|
|
320
|
+
)
|
|
321
|
+
]
|
|
322
|
+
}
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
var ListItem_default = ListItem;
|
|
326
|
+
|
|
327
|
+
// src/components/ui/Button.tsx
|
|
328
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
329
|
+
import { cva as cva2 } from "cva";
|
|
330
|
+
import { forwardRef as forwardRef4 } from "react";
|
|
331
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
332
|
+
var Button = forwardRef4(
|
|
333
|
+
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
334
|
+
const Component = asChild ? Slot : "button";
|
|
335
|
+
return /* @__PURE__ */ jsx7(
|
|
336
|
+
Component,
|
|
337
|
+
{
|
|
338
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
339
|
+
ref,
|
|
340
|
+
...props
|
|
341
|
+
}
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
);
|
|
345
|
+
Button.displayName = "Button";
|
|
346
|
+
var buttonVariants = cva2(
|
|
347
|
+
[
|
|
348
|
+
"flex",
|
|
349
|
+
"items-center",
|
|
350
|
+
"justify-center",
|
|
351
|
+
"gap-2",
|
|
352
|
+
"rounded-full",
|
|
353
|
+
"font-bold",
|
|
354
|
+
"outline-2",
|
|
355
|
+
"outline-offset-2",
|
|
356
|
+
"outline-dashed",
|
|
357
|
+
"outline-transparent"
|
|
358
|
+
],
|
|
359
|
+
{
|
|
360
|
+
variants: {
|
|
361
|
+
variant: {
|
|
362
|
+
neutral: [
|
|
363
|
+
"bg-black",
|
|
364
|
+
"text-white",
|
|
365
|
+
"hover:bg-grey-90",
|
|
366
|
+
"active:bg-grey-80",
|
|
367
|
+
"focus:outline-purple-100",
|
|
368
|
+
"disabled:text-grey-40",
|
|
369
|
+
"disabled:bg-grey-10"
|
|
370
|
+
],
|
|
371
|
+
primary: [
|
|
372
|
+
"bg-pickle-100",
|
|
373
|
+
"text-black",
|
|
374
|
+
"hover:bg-pickle-80",
|
|
375
|
+
"active:bg-pickle-60",
|
|
376
|
+
"focus:outline-purple-100",
|
|
377
|
+
"disabled:text-grey-40",
|
|
378
|
+
"disabled:bg-grey-10"
|
|
379
|
+
],
|
|
380
|
+
secondary: [
|
|
381
|
+
"bg-green-80",
|
|
382
|
+
"text-white",
|
|
383
|
+
"hover:bg-green-90",
|
|
384
|
+
"active:bg-green-100",
|
|
385
|
+
"focus:outline-pickle-100",
|
|
386
|
+
"disabled:text-grey-40",
|
|
387
|
+
"disabled:bg-grey-10"
|
|
388
|
+
],
|
|
389
|
+
transparent: [
|
|
390
|
+
"text-white",
|
|
391
|
+
"hover:bg-green-80",
|
|
392
|
+
"active:bg-green-100",
|
|
393
|
+
"focus:outline-pickle-100",
|
|
394
|
+
"disabled:text-grey-40"
|
|
395
|
+
],
|
|
396
|
+
link: [
|
|
397
|
+
"leading-tight",
|
|
398
|
+
"text-black",
|
|
399
|
+
"underline",
|
|
400
|
+
"hover:text-purple-100",
|
|
401
|
+
"focus:text-black",
|
|
402
|
+
"focus:outline-purple-100",
|
|
403
|
+
"active:text-purple-80"
|
|
404
|
+
]
|
|
405
|
+
},
|
|
406
|
+
size: {
|
|
407
|
+
small: ["h-10", "text-sm", "px-4", "py-2"],
|
|
408
|
+
medium: ["h-12", "text-base", "px-6", "py-3"],
|
|
409
|
+
large: ["h-14", "text-lg", "px-8", "py-4"]
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
defaultVariants: {
|
|
413
|
+
variant: "neutral",
|
|
414
|
+
size: "medium"
|
|
415
|
+
},
|
|
416
|
+
compoundVariants: [
|
|
417
|
+
{
|
|
418
|
+
variant: "link",
|
|
419
|
+
size: "small",
|
|
420
|
+
class: ["h-3", "text-xs", "p-0"]
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
variant: "link",
|
|
424
|
+
size: "medium",
|
|
425
|
+
class: ["h-4", "text-sm", "p-0"]
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
variant: "link",
|
|
429
|
+
size: "large",
|
|
430
|
+
class: ["h-6", "text-base", "p-0"]
|
|
431
|
+
}
|
|
432
|
+
]
|
|
433
|
+
}
|
|
434
|
+
);
|
|
435
|
+
|
|
436
|
+
// src/components/ui/Combobox.tsx
|
|
437
|
+
import { forwardRef as forwardRef8, useEffect as useEffect2, useState as useState2 } from "react";
|
|
438
|
+
import { ChevronDownIcon as ChevronDownIcon2, CircleX, icons as icons2 } from "lucide-react";
|
|
439
|
+
import { cva as cva4 } from "cva";
|
|
440
|
+
|
|
441
|
+
// src/components/primitives/command.tsx
|
|
442
|
+
import { Command as CommandPrimitive } from "cmdk";
|
|
443
|
+
import { Search } from "lucide-react";
|
|
444
|
+
import * as React4 from "react";
|
|
445
|
+
|
|
446
|
+
// src/components/primitives/dialog.tsx
|
|
447
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
448
|
+
import { X as X2 } from "lucide-react";
|
|
449
|
+
import * as React3 from "react";
|
|
450
|
+
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
451
|
+
var DialogPortal = DialogPrimitive.Portal;
|
|
452
|
+
var DialogOverlay = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx8(
|
|
453
|
+
DialogPrimitive.Overlay,
|
|
454
|
+
{
|
|
455
|
+
ref,
|
|
456
|
+
className: cn(
|
|
457
|
+
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
458
|
+
className
|
|
459
|
+
),
|
|
460
|
+
...props
|
|
461
|
+
}
|
|
462
|
+
));
|
|
463
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
464
|
+
var DialogContent = React3.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs4(DialogPortal, { children: [
|
|
465
|
+
/* @__PURE__ */ jsx8(DialogOverlay, {}),
|
|
466
|
+
/* @__PURE__ */ jsxs4(
|
|
467
|
+
DialogPrimitive.Content,
|
|
468
|
+
{
|
|
469
|
+
ref,
|
|
470
|
+
className: cn(
|
|
471
|
+
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-neutral-200 bg-white p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg dark:border-neutral-800 dark:bg-neutral-950",
|
|
472
|
+
className
|
|
473
|
+
),
|
|
474
|
+
...props,
|
|
475
|
+
children: [
|
|
476
|
+
children,
|
|
477
|
+
/* @__PURE__ */ jsxs4(DialogPrimitive.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-neutral-950 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-neutral-100 data-[state=open]:text-neutral-500 dark:ring-offset-neutral-950 dark:focus:ring-neutral-300 dark:data-[state=open]:bg-neutral-800 dark:data-[state=open]:text-neutral-400", children: [
|
|
478
|
+
/* @__PURE__ */ jsx8(X2, { className: "h-4 w-4" }),
|
|
479
|
+
/* @__PURE__ */ jsx8("span", { className: "sr-only", children: "Close" })
|
|
480
|
+
] })
|
|
481
|
+
]
|
|
482
|
+
}
|
|
483
|
+
)
|
|
484
|
+
] }));
|
|
485
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
486
|
+
var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ jsx8("div", { className: cn("flex flex-col space-y-1.5 text-center sm:text-left", className), ...props });
|
|
487
|
+
DialogHeader.displayName = "DialogHeader";
|
|
488
|
+
var DialogFooter = ({ className, ...props }) => /* @__PURE__ */ jsx8(
|
|
489
|
+
"div",
|
|
490
|
+
{
|
|
491
|
+
className: cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className),
|
|
492
|
+
...props
|
|
493
|
+
}
|
|
494
|
+
);
|
|
495
|
+
DialogFooter.displayName = "DialogFooter";
|
|
496
|
+
var DialogTitle = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx8(
|
|
497
|
+
DialogPrimitive.Title,
|
|
498
|
+
{
|
|
499
|
+
ref,
|
|
500
|
+
className: cn("text-lg font-semibold leading-none tracking-tight", className),
|
|
501
|
+
...props
|
|
502
|
+
}
|
|
503
|
+
));
|
|
504
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
505
|
+
var DialogDescription = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx8(
|
|
506
|
+
DialogPrimitive.Description,
|
|
507
|
+
{
|
|
508
|
+
ref,
|
|
509
|
+
className: cn("text-sm text-neutral-500 dark:text-neutral-400", className),
|
|
510
|
+
...props
|
|
511
|
+
}
|
|
512
|
+
));
|
|
513
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
514
|
+
|
|
515
|
+
// src/components/primitives/command.tsx
|
|
516
|
+
import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
517
|
+
var Command = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx9(
|
|
518
|
+
CommandPrimitive,
|
|
519
|
+
{
|
|
520
|
+
ref,
|
|
521
|
+
className: cn(
|
|
522
|
+
"flex h-full w-full flex-col overflow-hidden rounded-xl bg-white text-neutral-950",
|
|
523
|
+
className
|
|
524
|
+
),
|
|
525
|
+
...props
|
|
526
|
+
}
|
|
527
|
+
));
|
|
528
|
+
Command.displayName = CommandPrimitive.displayName;
|
|
529
|
+
var CommandInput = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxs5("div", { className: "m-1 flex items-center rounded-xl border px-3", "cmdk-input-wrapper": "", children: [
|
|
530
|
+
/* @__PURE__ */ jsx9(Search, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
|
|
531
|
+
/* @__PURE__ */ jsx9(
|
|
532
|
+
CommandPrimitive.Input,
|
|
533
|
+
{
|
|
534
|
+
ref,
|
|
535
|
+
className: cn(
|
|
536
|
+
"flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-neutral-500 disabled:cursor-not-allowed disabled:opacity-50",
|
|
537
|
+
className
|
|
538
|
+
),
|
|
539
|
+
...props
|
|
540
|
+
}
|
|
541
|
+
)
|
|
542
|
+
] }));
|
|
543
|
+
CommandInput.displayName = CommandPrimitive.Input.displayName;
|
|
544
|
+
var CommandList = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx9(
|
|
545
|
+
CommandPrimitive.List,
|
|
546
|
+
{
|
|
547
|
+
ref,
|
|
548
|
+
className: cn("overflow-y-auto overflow-x-hidden", className),
|
|
549
|
+
...props
|
|
550
|
+
}
|
|
551
|
+
));
|
|
552
|
+
CommandList.displayName = CommandPrimitive.List.displayName;
|
|
553
|
+
var CommandEmpty = React4.forwardRef((props, ref) => /* @__PURE__ */ jsx9(CommandPrimitive.Empty, { ref, className: "py-6 text-center text-sm", ...props }));
|
|
554
|
+
CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
|
|
555
|
+
var CommandGroup = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx9(
|
|
556
|
+
CommandPrimitive.Group,
|
|
557
|
+
{
|
|
558
|
+
ref,
|
|
559
|
+
className: cn(
|
|
560
|
+
"overflow-hidden p-1 text-neutral-950 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-neutral-500",
|
|
561
|
+
className
|
|
562
|
+
),
|
|
563
|
+
...props
|
|
564
|
+
}
|
|
565
|
+
));
|
|
566
|
+
CommandGroup.displayName = CommandPrimitive.Group.displayName;
|
|
567
|
+
var CommandSeparator = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx9(
|
|
568
|
+
CommandPrimitive.Separator,
|
|
569
|
+
{
|
|
570
|
+
ref,
|
|
571
|
+
className: cn("-mx-1 h-px bg-neutral-200", className),
|
|
572
|
+
...props
|
|
573
|
+
}
|
|
574
|
+
));
|
|
575
|
+
CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
|
|
576
|
+
var CommandItem = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx9(
|
|
577
|
+
CommandPrimitive.Item,
|
|
578
|
+
{
|
|
579
|
+
ref,
|
|
580
|
+
className: cn(
|
|
581
|
+
"relative flex cursor-pointer select-none items-center rounded-xl px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-neutral-100 data-[selected=true]:text-neutral-900 data-[disabled=true]:opacity-50",
|
|
582
|
+
className
|
|
583
|
+
),
|
|
584
|
+
...props
|
|
585
|
+
}
|
|
586
|
+
));
|
|
587
|
+
CommandItem.displayName = CommandPrimitive.Item.displayName;
|
|
588
|
+
var CommandShortcut = ({ className, ...props }) => {
|
|
589
|
+
return /* @__PURE__ */ jsx9(
|
|
590
|
+
"span",
|
|
591
|
+
{
|
|
592
|
+
className: cn("ml-auto text-xs tracking-widest text-neutral-500", className),
|
|
593
|
+
...props
|
|
594
|
+
}
|
|
595
|
+
);
|
|
596
|
+
};
|
|
597
|
+
CommandShortcut.displayName = "CommandShortcut";
|
|
598
|
+
|
|
599
|
+
// src/components/primitives/popover.tsx
|
|
600
|
+
import * as React5 from "react";
|
|
601
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
602
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
603
|
+
var Popover = PopoverPrimitive.Root;
|
|
604
|
+
var PopoverTrigger = PopoverPrimitive.Trigger;
|
|
605
|
+
var PopoverContent = React5.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx10(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx10(
|
|
606
|
+
PopoverPrimitive.Content,
|
|
607
|
+
{
|
|
608
|
+
ref,
|
|
609
|
+
align,
|
|
610
|
+
sideOffset,
|
|
611
|
+
className: cn(
|
|
612
|
+
"z-50 rounded-2xl border bg-white p-4 text-black shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
613
|
+
className
|
|
614
|
+
),
|
|
615
|
+
...props
|
|
616
|
+
}
|
|
617
|
+
) }));
|
|
618
|
+
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
619
|
+
|
|
620
|
+
// src/components/ui/Badge.tsx
|
|
621
|
+
import { cva as cva3 } from "cva";
|
|
622
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
623
|
+
var badgeVariants = cva3("rounded-full px-2 py-0.5 text-xs font-semibold", {
|
|
624
|
+
variants: {
|
|
625
|
+
variant: {
|
|
626
|
+
green: "bg-green-90 text-white",
|
|
627
|
+
pickle: "bg-pickle-100 text-black",
|
|
628
|
+
purple: "bg-purple-100 text-white"
|
|
629
|
+
}
|
|
630
|
+
},
|
|
631
|
+
defaultVariants: {
|
|
632
|
+
variant: "green"
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
function Badge({ className, variant, ...props }) {
|
|
636
|
+
return /* @__PURE__ */ jsx11("div", { className: cn(badgeVariants({ variant }), className), ...props });
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
// src/components/ui/Combobox.tsx
|
|
640
|
+
import { jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
641
|
+
var Combobox = forwardRef8((props, ref) => {
|
|
642
|
+
const {
|
|
643
|
+
value,
|
|
644
|
+
label,
|
|
645
|
+
options,
|
|
646
|
+
classNames,
|
|
647
|
+
multiselect,
|
|
648
|
+
placeholder,
|
|
649
|
+
variant = "default",
|
|
650
|
+
size,
|
|
651
|
+
icon,
|
|
652
|
+
className,
|
|
653
|
+
onChange: handleChange,
|
|
654
|
+
children: footer
|
|
655
|
+
} = props;
|
|
656
|
+
const [selected, setSelected] = useState2([]);
|
|
657
|
+
const [open, setOpen] = useState2(false);
|
|
658
|
+
const IconComponent = icon && icons2[icon];
|
|
659
|
+
const hideSearchBox = options?.length <= 5;
|
|
660
|
+
const isDefault = variant === "default";
|
|
661
|
+
const isChip = variant === "chip";
|
|
662
|
+
const isEmpty = selected.length == 0;
|
|
663
|
+
const showChevron = isDefault ? isEmpty : true;
|
|
664
|
+
const close = () => setOpen(false);
|
|
665
|
+
useEffect2(() => {
|
|
666
|
+
const valueArray = multiselect ? value ?? [] : value ? [value] : [];
|
|
667
|
+
setSelected(
|
|
668
|
+
valueArray.map((v) => options.find((o) => o.value === v)).filter((v) => v !== void 0)
|
|
669
|
+
);
|
|
670
|
+
}, [value]);
|
|
671
|
+
const handleSelect = (value2) => {
|
|
672
|
+
const option = options.find((o) => o.value === value2);
|
|
673
|
+
if (!option) return;
|
|
674
|
+
if (multiselect) {
|
|
675
|
+
return setSelected((prev) => {
|
|
676
|
+
const newSelected = prev.some((o) => o.value === value2) ? prev.filter((v) => v !== option) : [...prev, option];
|
|
677
|
+
handleChange?.(newSelected.map((o) => o.value));
|
|
678
|
+
return newSelected;
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
setSelected([option]);
|
|
682
|
+
handleChange?.(option.value);
|
|
683
|
+
close();
|
|
684
|
+
};
|
|
685
|
+
const handleClear = () => {
|
|
686
|
+
setSelected([]);
|
|
687
|
+
multiselect ? handleChange?.([]) : handleChange?.("");
|
|
688
|
+
};
|
|
689
|
+
const handleDisplayValue = () => {
|
|
690
|
+
const defaultLabel = !isEmpty ? selected.map((s) => s.title).join(", ") : placeholder;
|
|
691
|
+
return isDefault ? defaultLabel : label;
|
|
692
|
+
};
|
|
693
|
+
return /* @__PURE__ */ jsxs6("div", { className: cn("flex flex-col gap-2", className), children: [
|
|
694
|
+
isDefault && label && /* @__PURE__ */ jsx12(Label_default, { text: label, className: classNames?.label }),
|
|
695
|
+
/* @__PURE__ */ jsxs6("div", { className: "relative flex", children: [
|
|
696
|
+
/* @__PURE__ */ jsxs6(Popover, { open, onOpenChange: setOpen, children: [
|
|
697
|
+
/* @__PURE__ */ jsx12(
|
|
698
|
+
PopoverTrigger,
|
|
699
|
+
{
|
|
700
|
+
asChild: true,
|
|
701
|
+
disabled: options.length === 0,
|
|
702
|
+
"data-testid": `${props.id ?? props.name}-combobox-trigger`,
|
|
703
|
+
children: /* @__PURE__ */ jsxs6(
|
|
704
|
+
"div",
|
|
705
|
+
{
|
|
706
|
+
ref,
|
|
707
|
+
className: cn(
|
|
708
|
+
triggerVariants({ variant, size }),
|
|
709
|
+
isDefault && !isEmpty && "pr-10",
|
|
710
|
+
classNames?.trigger
|
|
711
|
+
),
|
|
712
|
+
"aria-expanded": open,
|
|
713
|
+
children: [
|
|
714
|
+
isDefault && IconComponent && /* @__PURE__ */ jsx12(IconComponent, { className: "h-4 w-4 shrink-0" }),
|
|
715
|
+
isChip && !isEmpty && /* @__PURE__ */ jsx12(Badge, { variant: "purple", children: selected.length }),
|
|
716
|
+
/* @__PURE__ */ jsx12(
|
|
717
|
+
"span",
|
|
718
|
+
{
|
|
719
|
+
className: cn(
|
|
720
|
+
"w-full truncate leading-normal",
|
|
721
|
+
isDefault && isEmpty && "text-grey-40"
|
|
722
|
+
),
|
|
723
|
+
children: handleDisplayValue()
|
|
724
|
+
}
|
|
725
|
+
),
|
|
726
|
+
showChevron && /* @__PURE__ */ jsx12(
|
|
727
|
+
ChevronDownIcon2,
|
|
728
|
+
{
|
|
729
|
+
className: "shrink-0 transform group-data-[state=open]:rotate-180",
|
|
730
|
+
size: "16"
|
|
731
|
+
}
|
|
732
|
+
)
|
|
733
|
+
]
|
|
734
|
+
}
|
|
735
|
+
)
|
|
736
|
+
}
|
|
737
|
+
),
|
|
738
|
+
/* @__PURE__ */ jsx12(Command, { children: /* @__PURE__ */ jsxs6(
|
|
739
|
+
PopoverContent,
|
|
740
|
+
{
|
|
741
|
+
className: cn(
|
|
742
|
+
"flex w-full max-w-xs flex-col overflow-hidden p-0",
|
|
743
|
+
"max-h-[--radix-popover-content-available-height]",
|
|
744
|
+
classNames?.content
|
|
745
|
+
),
|
|
746
|
+
collisionPadding: 8,
|
|
747
|
+
sideOffset: 4,
|
|
748
|
+
align: "start",
|
|
749
|
+
children: [
|
|
750
|
+
!hideSearchBox && /* @__PURE__ */ jsx12(CommandInput, { placeholder: "Search..." }),
|
|
751
|
+
/* @__PURE__ */ jsxs6(CommandList, { children: [
|
|
752
|
+
/* @__PURE__ */ jsx12(CommandEmpty, { children: "No results" }),
|
|
753
|
+
/* @__PURE__ */ jsx12(CommandGroup, { children: options.map(({ id, ...option }) => /* @__PURE__ */ jsx12(CommandItem, { value: option.value, onSelect: handleSelect, children: /* @__PURE__ */ jsx12(
|
|
754
|
+
ListItem_default,
|
|
755
|
+
{
|
|
756
|
+
className: cn(classNames?.items, "truncate py-1"),
|
|
757
|
+
isSelected: selected.some((s) => s.value === option.value),
|
|
758
|
+
hasCheckbox: multiselect,
|
|
759
|
+
...option
|
|
760
|
+
}
|
|
761
|
+
) }, id)) })
|
|
762
|
+
] }),
|
|
763
|
+
!!footer && /* @__PURE__ */ jsx12(Separator, {}),
|
|
764
|
+
footer && footer({ close })
|
|
765
|
+
]
|
|
766
|
+
}
|
|
767
|
+
) })
|
|
768
|
+
] }),
|
|
769
|
+
isDefault && !isEmpty && /* @__PURE__ */ jsx12(
|
|
770
|
+
"button",
|
|
771
|
+
{
|
|
772
|
+
type: "button",
|
|
773
|
+
className: "absolute inset-y-0 right-1 my-auto flex h-8 w-8 cursor-pointer items-center justify-center rounded-full hover:bg-pickle-20",
|
|
774
|
+
onClick: handleClear,
|
|
775
|
+
children: /* @__PURE__ */ jsx12(CircleX, { className: "h-4 w-4 text-green-100" })
|
|
776
|
+
}
|
|
777
|
+
)
|
|
778
|
+
] })
|
|
779
|
+
] });
|
|
780
|
+
});
|
|
781
|
+
Combobox.displayName = "Combobox";
|
|
782
|
+
var triggerVariants = cva4(
|
|
783
|
+
"group relative cursor-pointer text-green-100 flex flex-row items-center justify-between gap-2 border border-grey-20 focus:outline-green-80 disabled:bg-grey-5",
|
|
784
|
+
{
|
|
785
|
+
variants: {
|
|
786
|
+
variant: {
|
|
787
|
+
default: ["w-full", "max-w-80", "rounded-lg"],
|
|
788
|
+
chip: [
|
|
789
|
+
"font-bold",
|
|
790
|
+
"rounded-3xl",
|
|
791
|
+
"data-[state=open]:bg-black",
|
|
792
|
+
"data-[state=open]:text-white"
|
|
793
|
+
]
|
|
794
|
+
},
|
|
795
|
+
size: {
|
|
796
|
+
small: ["h-8", "py-1", "px-2", "text-xs"],
|
|
797
|
+
normal: ["h-9", "py-2", "px-3", "text-sm"],
|
|
798
|
+
large: ["h-10", "py-3", "px-4", "text-base"]
|
|
799
|
+
}
|
|
800
|
+
},
|
|
801
|
+
defaultVariants: {
|
|
802
|
+
variant: "default",
|
|
803
|
+
size: "normal"
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
);
|
|
807
|
+
export {
|
|
808
|
+
Badge,
|
|
809
|
+
Button,
|
|
810
|
+
Checkbox_default as Checkbox,
|
|
811
|
+
Chip_default as Chip,
|
|
812
|
+
Combobox,
|
|
813
|
+
Label_default as Label,
|
|
814
|
+
ListItem_default as ListItem,
|
|
815
|
+
Select_default as Select,
|
|
816
|
+
cn
|
|
817
|
+
};
|
|
2
818
|
//# sourceMappingURL=index.js.map
|