@magiclabs/ui-components 1.23.2 → 1.23.4

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.
Files changed (32) hide show
  1. package/dist/cjs/components/feedback/toast-provider.js +1 -1
  2. package/dist/cjs/components/feedback/toast-provider.js.map +1 -1
  3. package/dist/cjs/components/inputs/phone-input.js +1 -1
  4. package/dist/cjs/components/inputs/phone-input.js.map +1 -1
  5. package/dist/cjs/components/inputs/text-input.js +1 -1
  6. package/dist/cjs/components/inputs/text-input.js.map +1 -1
  7. package/dist/cjs/components/list-items/navigation-button.js +1 -1
  8. package/dist/cjs/components/list-items/navigation-button.js.map +1 -1
  9. package/dist/cjs/components/list-items/token-list-item.js +1 -1
  10. package/dist/cjs/components/list-items/token-list-item.js.map +1 -1
  11. package/dist/cjs/components/primitives/dropdown-selector.js +1 -1
  12. package/dist/cjs/components/primitives/dropdown-selector.js.map +1 -1
  13. package/dist/cjs/components/primitives/text.js +1 -1
  14. package/dist/cjs/components/primitives/text.js.map +1 -1
  15. package/dist/es/components/feedback/toast-provider.js +1 -1
  16. package/dist/es/components/feedback/toast-provider.js.map +1 -1
  17. package/dist/es/components/inputs/phone-input.js +1 -1
  18. package/dist/es/components/inputs/phone-input.js.map +1 -1
  19. package/dist/es/components/inputs/text-input.js +1 -1
  20. package/dist/es/components/inputs/text-input.js.map +1 -1
  21. package/dist/es/components/list-items/navigation-button.js +1 -1
  22. package/dist/es/components/list-items/navigation-button.js.map +1 -1
  23. package/dist/es/components/list-items/token-list-item.js +1 -1
  24. package/dist/es/components/list-items/token-list-item.js.map +1 -1
  25. package/dist/es/components/primitives/dropdown-selector.js +1 -1
  26. package/dist/es/components/primitives/dropdown-selector.js.map +1 -1
  27. package/dist/es/components/primitives/text.js +1 -1
  28. package/dist/es/components/primitives/text.js.map +1 -1
  29. package/dist/panda.buildinfo.json +1 -1
  30. package/dist/types/components/primitives/text.d.ts +1 -1
  31. package/dist/types/components/primitives/text.d.ts.map +1 -1
  32. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"toast-provider.js","sources":["../../../../src/components/feedback/toast-provider.tsx"],"sourcesContent":["import { IcoDismiss } from '@components/icons';\nimport { Text } from '@components/primitives';\nimport Portal from '@components/primitives/portal';\nimport Animate from '@components/utils/animate';\nimport { ToastProps as BaseToastProps, ToastContext, ToastDefinition } from '@hooks/useToast';\nimport { toast as classes } from '@recipes/toast';\nimport { HStack, VStack } from '@styled/jsx';\nimport { PropsWithChildren, useCallback, useMemo, useReducer, useRef, useState } from 'react';\nimport { StatusIcon } from './status-icon';\n\nlet toastID = 0;\n\ninterface InternalToast extends ToastDefinition {\n removeToast: ToastContext['removeToast'];\n}\n\nexport interface ToastProps extends BaseToastProps {}\nexport interface ToastProviderProps extends PropsWithChildren {\n icon?: boolean;\n lifespan?: number;\n position?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right';\n}\n\nexport const Toast = (props: ToastProps | InternalToast) => {\n const { dismissible, lifespan, message = '', variant = 'branded' } = props;\n const toastClasses = classes({ variant });\n const dismissId = (props as InternalToast).id;\n const removeToast = (props as InternalToast).removeToast;\n const [show, setShow] = useState(true);\n\n if (lifespan) {\n setTimeout(() => {\n setShow(false);\n }, lifespan);\n }\n\n return (\n <Animate\n aria-live={['error'].includes(variant || '') ? 'assertive' : 'polite'}\n show={show}\n type=\"slide\"\n onHidden={() => {\n if (dismissId) {\n removeToast(dismissId);\n }\n }}\n >\n <HStack className={toastClasses.toast}>\n {props.icon && <StatusIcon className={toastClasses.icon} variant={variant} />}\n <Text color=\"text.quaternary\">{message}</Text>\n {dismissible && (\n <button className={toastClasses.dismiss} onClick={() => setShow(false)} aria-label=\"dismiss toast\">\n <IcoDismiss className={toastClasses.icon} />\n </button>\n )}\n </HStack>\n </Animate>\n );\n};\n\nexport const ToastProvider = ({\n icon: defaultIcon = false,\n lifespan: defaultLifespan = 0,\n position = 'top-right',\n children,\n}: ToastProviderProps) => {\n const toastsRef = useRef<ToastDefinition[]>([]);\n const forceUpdate = useReducer((x: number) => x + 1, 0)[1];\n\n const removeToast: ToastContext['removeToast'] = useCallback((id: number) => {\n toastsRef.current = toastsRef.current.filter(toast => toast.id !== id);\n forceUpdate();\n }, []);\n\n const createToast: ToastContext['createToast'] = useCallback(options => {\n const { icon = options.icon || defaultIcon, lifespan = options.lifespan || defaultLifespan, ...props } = options;\n const id = ++toastID;\n\n toastsRef.current.push({ icon, lifespan, id, ...props });\n forceUpdate();\n\n return id;\n }, []);\n\n const toastCtx = useMemo(() => ({ createToast, removeToast }), [createToast, removeToast]);\n const toasts = position?.startsWith('top') ? [...toastsRef.current] : [...toastsRef.current].reverse();\n const activeToasts = toasts.map(toast => {\n return <Toast key={toast.id} {...toast} removeToast={removeToast} />;\n });\n\n const providerClasses = classes({ position });\n\n return (\n <ToastContext.Provider value={toastCtx}>\n {children}\n <Portal>\n <div className={providerClasses.portal}>\n <VStack className={providerClasses.container}>{activeToasts}</VStack>\n </div>\n </Portal>\n </ToastContext.Provider>\n );\n};\n"],"names":["toastID","Toast","props","dismissible","lifespan","message","variant","toastClasses","classes","dismissId","removeToast","show","setShow","useState","_jsx","Animate","_jsxs","HStack","StatusIcon","Text","IcoDismiss","ToastProvider","defaultIcon","defaultLifespan","position","children","toastsRef","useRef","forceUpdate","useReducer","x","useCallback","id","toast","createToast","options","icon","toastCtx","useMemo","activeToasts","providerClasses","ToastContext","Portal","VStack"],"mappings":"uvBAUA,IAAIA,EAAU,EAaP,MAAMC,EAASC,GAAqC,CACzD,KAAM,CAAE,YAAAC,EAAa,SAAAC,EAAU,QAAAC,EAAU,GAAI,QAAAC,EAAU,SAAW,EAAGJ,EAC/DK,EAAeC,EAAQ,CAAE,QAAAF,CAAO,CAAE,EAClCG,EAAaP,EAAwB,GACrCQ,EAAeR,EAAwB,YACvC,CAACS,EAAMC,CAAO,EAAIC,EAAS,EAAI,EAErC,OAAIT,GACF,WAAW,IAAK,CACdQ,EA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EAAa,YAAAxB,CAAW,GAAK,CAACwB,EAAaxB,CAAW,CAAC,EAEnF6B,GADSf,GAAU,WAAW,KAAK,EAAI,CAAC,GAAGE,EAAU,OAAO,EAAI,CAAC,GAAGA,EAAU,OAAO,EAAE,WACjE,IAAIO,GACvBnB,EAACb,EAAyB,CAAA,GAAAgC,EAAO,YAAavB,CAAlC,EAAAuB,EAAM,EAAE,CAC5B,EAEKO,EAAkBhC,EAAQ,CAAE,SAAAgB,CAAQ,CAAE,EAE5C,OACER,EAACyB,EAAa,UAAS,MAAOJ,EAAQ,SAAA,CACnCZ,EACDX,EAAC4B,EAAM,CAAA,SACL5B,SAAK,UAAW0B,EAAgB,OAC9B,SAAA1B,EAAC6B,EAAM,CAAC,UAAWH,EAAgB,mBAAYD,CAAY,CAAA,GAEtD,CAAA,CAAA,CAAA,CAAA,CAGf"}
1
+ {"version":3,"file":"toast-provider.js","sources":["../../../../src/components/feedback/toast-provider.tsx"],"sourcesContent":["import { IcoDismiss } from '@components/icons';\nimport { Text } from '@components/primitives';\nimport Portal from '@components/primitives/portal';\nimport Animate from '@components/utils/animate';\nimport { ToastProps as BaseToastProps, ToastContext, ToastDefinition } from '@hooks/useToast';\nimport { toast as classes } from '@recipes/toast';\nimport { HStack, VStack } from '@styled/jsx';\nimport { PropsWithChildren, useCallback, useMemo, useReducer, useRef, useState } from 'react';\nimport { StatusIcon } from './status-icon';\n\nlet toastID = 0;\n\ninterface InternalToast extends ToastDefinition {\n removeToast: ToastContext['removeToast'];\n}\n\nexport interface ToastProps extends BaseToastProps {}\nexport interface ToastProviderProps extends PropsWithChildren {\n icon?: boolean;\n lifespan?: number;\n position?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right';\n}\n\nexport const Toast = (props: ToastProps | InternalToast) => {\n const { dismissible, lifespan, message = '', variant = 'branded' } = props;\n const toastClasses = classes({ variant });\n const dismissId = (props as InternalToast).id;\n const removeToast = (props as InternalToast).removeToast;\n const [show, setShow] = useState(true);\n\n if (lifespan) {\n setTimeout(() => {\n setShow(false);\n }, lifespan);\n }\n\n return (\n <Animate\n aria-live={['error'].includes(variant || '') ? 'assertive' : 'polite'}\n show={show}\n type=\"slide\"\n onHidden={() => {\n if (dismissId) {\n removeToast(dismissId);\n }\n }}\n >\n <HStack className={toastClasses.toast}>\n {props.icon && <StatusIcon className={toastClasses.icon} variant={variant} />}\n <Text fontColor=\"text.quaternary\">{message}</Text>\n {dismissible && (\n <button className={toastClasses.dismiss} onClick={() => setShow(false)} aria-label=\"dismiss toast\">\n <IcoDismiss className={toastClasses.icon} />\n </button>\n )}\n </HStack>\n </Animate>\n );\n};\n\nexport const ToastProvider = ({\n icon: defaultIcon = false,\n lifespan: defaultLifespan = 0,\n position = 'top-right',\n children,\n}: ToastProviderProps) => {\n const toastsRef = useRef<ToastDefinition[]>([]);\n const forceUpdate = useReducer((x: number) => x + 1, 0)[1];\n\n const removeToast: ToastContext['removeToast'] = useCallback((id: number) => {\n toastsRef.current = toastsRef.current.filter(toast => toast.id !== id);\n forceUpdate();\n }, []);\n\n const createToast: ToastContext['createToast'] = useCallback(options => {\n const { icon = options.icon || defaultIcon, lifespan = options.lifespan || defaultLifespan, ...props } = options;\n const id = ++toastID;\n\n toastsRef.current.push({ icon, lifespan, id, ...props });\n forceUpdate();\n\n return id;\n }, []);\n\n const toastCtx = useMemo(() => ({ createToast, removeToast }), [createToast, removeToast]);\n const toasts = position?.startsWith('top') ? [...toastsRef.current] : [...toastsRef.current].reverse();\n const activeToasts = toasts.map(toast => {\n return <Toast key={toast.id} {...toast} removeToast={removeToast} />;\n });\n\n const providerClasses = classes({ position });\n\n return (\n <ToastContext.Provider value={toastCtx}>\n {children}\n <Portal>\n <div className={providerClasses.portal}>\n <VStack className={providerClasses.container}>{activeToasts}</VStack>\n </div>\n </Portal>\n </ToastContext.Provider>\n );\n};\n"],"names":["toastID","Toast","props","dismissible","lifespan","message","variant","toastClasses","classes","dismissId","removeToast","show","setShow","useState","_jsx","Animate","_jsxs","HStack","StatusIcon","Text","IcoDismiss","ToastProvider","defaultIcon","defaultLifespan","position","children","toastsRef","useRef","forceUpdate","useReducer","x","useCallback","id","toast","createToast","options","icon","toastCtx","useMemo","activeToasts","providerClasses","ToastContext","Portal","VStack"],"mappings":"uvBAUA,IAAIA,EAAU,EAaP,MAAMC,EAASC,GAAqC,CACzD,KAAM,CAAE,YAAAC,EAAa,SAAAC,EAAU,QAAAC,EAAU,GAAI,QAAAC,EAAU,SAAW,EAAGJ,EAC/DK,EAAeC,EAAQ,CAAE,QAAAF,CAAO,CAAE,EAClCG,EAAaP,EAAwB,GACrCQ,EAAeR,EAAwB,YACvC,CAACS,EAAMC,CAAO,EAAIC,EAAS,EAAI,EAErC,OAAIT,GACF,WAAW,IAAK,CACdQ,EAAQ,EAAK,CACf,EAAGR,CAAQ,EAIXU,EAACC,EAAO,CAAA,YACK,CAAC,OAAO,EAAE,SAAST,GAAW,EAAE,EAAI,YAAc,SAC7D,KAAMK,EACN,KAAK,QACL,SAAU,IAAK,CACTF,GACFC,EAAYD,CAAS,CAEzB,EAEA,SAAAO,EAACC,EAAM,CAAC,UAAWV,EAAa,gBAC7BL,EAAM,MAAQY,EAACI,EAAU,CAAC,UAAWX,EAAa,KAAM,QAASD,CAAO,CAAA,EACzEQ,EAACK,EAAK,CAAA,UAAU,2BAAmBd,CAAO,CAAA,EACzCF,GACCW,EAAQ,SAAA,CAAA,UAAWP,EAAa,QAAS,QAAS,IAAMK,EAAQ,EAAK,EAAC,aAAa,gBACjF,SAAAE,EAACM,EAAU,CAAC,UAAWb,EAAa,MAC7B,CAAA,CACV,CACM,CAAA,CAAA,CAAA,CAGf,EAEac,EAAgB,CAAC,CAC5B,KAAMC,EAAc,GACpB,SAAUC,EAAkB,EAC5B,SAAAC,EAAW,YACX,SAAAC,CACmB,IAAI,CACvB,MAAMC,EAAYC,EAA0B,CAAE,CAAA,EACxCC,EAAcC,EAAYC,GAAcA,EAAI,EAAG,CAAC,EAAE,CAAC,EAEnDpB,EAA2CqB,EAAaC,GAAc,CAC1EN,EAAU,QAAUA,EAAU,QAAQ,OAAOO,GAASA,EAAM,KAAOD,CAAE,EACrEJ,EAAAA,CACF,EAAG,EAAE,EAECM,EAA2CH,EAAYI,GAAU,CACrE,KAAM,CAAE,KAAAC,EAAOD,EAAQ,MAAQb,EAAa,SAAAlB,EAAW+B,EAAQ,UAAYZ,EAAiB,GAAGrB,CAAK,EAAKiC,EACnGH,EAAK,EAAEhC,EAEb,OAAA0B,EAAU,QAAQ,KAAK,CAAE,KAAAU,EAAM,SAAAhC,EAAU,GAAA4B,EAAI,GAAG9B,CAAK,CAAE,EACvD0B,EAAAA,EAEOI,CACT,EAAG,CAAE,CAAA,EAECK,EAAWC,EAAQ,KAAO,CAAE,YAAAJ,EAAa,YAAAxB,CAAW,GAAK,CAACwB,EAAaxB,CAAW,CAAC,EAEnF6B,GADSf,GAAU,WAAW,KAAK,EAAI,CAAC,GAAGE,EAAU,OAAO,EAAI,CAAC,GAAGA,EAAU,OAAO,EAAE,WACjE,IAAIO,GACvBnB,EAACb,EAAyB,CAAA,GAAAgC,EAAO,YAAavB,CAAlC,EAAAuB,EAAM,EAAE,CAC5B,EAEKO,EAAkBhC,EAAQ,CAAE,SAAAgB,CAAQ,CAAE,EAE5C,OACER,EAACyB,EAAa,UAAS,MAAOJ,EAAQ,SAAA,CACnCZ,EACDX,EAAC4B,EAAM,CAAA,SACL5B,SAAK,UAAW0B,EAAgB,OAC9B,SAAA1B,EAAC6B,EAAM,CAAC,UAAWH,EAAgB,mBAAYD,CAAY,CAAA,GAEtD,CAAA,CAAA,CAAA,CAAA,CAGf"}
@@ -1,2 +1,2 @@
1
- import{jsxs as l,jsx as o}from"react/jsx-runtime";import{token as re}from"@styled/tokens";import te from"../icons/ico-caret-down.js";import oe from"../icons/ico-checkmark-circle-fill.js";import"../primitives/button.js";import"../primitives/checkbox.js";import"../primitives/dropdown-selector.js";import"../primitives/popover.js";import"../primitives/radio.js";import"../primitives/segmented-control.js";import"../primitives/switch.js";import x from"../primitives/text.js";import{css as k}from"@styled/css";import{VStack as ne,Flex as E,HStack as C,Box as ie}from"@styled/jsx";import{useState as c,useRef as d,useMemo as L,useCallback as N,useEffect as I}from"react";import{useButton as ae,useFocusRing as se,useKeyboard as le,mergeProps as _}from"react-aria";import{usePhoneInput as ue,defaultCountries as S,FlagImage as ce}from"react-international-phone";const A=({iso2:h})=>o(E,{width:"1.125rem",height:"1.125rem",borderRadius:"full",borderWidth:"thin",borderColor:"neutral.primary",overflow:"hidden",align:"center",children:o(ce,{src:`https://flagcdn.com/${h}.svg`,iso2:h,size:16,className:k({objectFit:"cover"})})}),B=h=>{const{onChange:M,autoFocus:q=!0,errorMessage:W}=h,[H,K]=c(""),[O,y]=c(!1),[s,m]=c(!1),[a,p]=c(0),[w,P]=c(""),T=d(null),$=d(null),f=d(null),b=d([]),j=d(void 0),{country:n,setCountry:D,inputRef:g,handlePhoneValueChange:U,inputValue:Y}=ue({defaultCountry:"us",value:H,onChange:e=>{K(e.phone),M(e.phone)}}),i=L(()=>{const e=S.filter(([,t])=>t!==n.iso2),r=S.find(([,t])=>t===n.iso2);return r?[r,...e]:[...S]},[n.iso2]),F=L(()=>i.filter(([,e])=>e!==n.iso2),[n.iso2]),R=N(e=>{var r;D(e),m(!1),(r=g.current)===null||r===void 0||r.focus()},[D]),G=N(()=>{m(!s),s||(p(0),setTimeout(()=>{var e;return(e=f.current)===null||e===void 0?void 0:e.focus()}))},[s]),{buttonProps:J}=ae({onPress:G},T),{focusProps:V,isFocusVisible:z}=se(),{keyboardProps:Q}=le({onKeyDown:e=>{var r;if(s)switch(e.key){case"ArrowDown":e.preventDefault(),p(t=>(t+1)%i.length);break;case"ArrowUp":e.preventDefault(),p(t=>(t-1+i.length)%i.length);break;case"Enter":if(e.preventDefault(),a>=0){const[,t]=i[a];R(t)}break;case"Escape":m(!1),(r=g.current)===null||r===void 0||r.focus();break;default:(e.key===" "||e.key.match(/[\w]/i))&&(e.preventDefault(),clearTimeout(j.current),P(t=>t+e.key),j.current=window.setTimeout(()=>{P("")},1e3));break}}});I(()=>{var e;q&&((e=g.current)===null||e===void 0||e.focus());const r=t=>{f.current&&!f.current.contains(t.target)&&(m(!1),y(!1))};return document.addEventListener("mousedown",r),()=>{document.removeEventListener("mousedown",r)}},[]),I(()=>{var e;if(w!==""){const r=F.findIndex(([t])=>t.toLowerCase().startsWith(w.toLowerCase()));if(r!==-1){const t=i.findIndex(([v])=>v===F[r][0]);p(t),(e=b.current[t])===null||e===void 0||e.scrollIntoView({behavior:"smooth",block:"nearest"})}}},[w,i,n.iso2]),I(()=>{var e;a>=0&&b.current[a]&&((e=b.current[a])===null||e===void 0||e.scrollIntoView({behavior:"smooth",block:"nearest"}))},[a]);const X=()=>{y(!0)},Z=()=>{y(!1)};return l(ne,{gap:2,children:[l(E,{..._(Q,V),ref:$,height:"fit-content",width:"full",alignItems:"center",justify:"center",borderWidth:"thin",borderColor:"neutral.secondary",borderRadius:"input",transition:"all linear 120ms",outlineColor:"brand.base",outlineStyle:O&&!z?"solid":"none",outlineWidth:"thick",outlineOffset:.5,onFocus:X,onBlur:Z,position:"relative",_hover:{borderColor:"neutral.primary"},children:[o("button",{..._(J,V),className:k({display:"flex",justifyContent:"center",alignItems:"center",borderStartRadius:"input",h:12,w:20,px:3,outlineColor:"brand.base",outlineStyle:z?"solid":"none",outlineWidth:"thick",outlineOffset:.5,cursor:"pointer",transition:"all linear 120ms",_hover:{bg:"surface.tertiary"}}),children:l(C,{gap:2,children:[o(A,{iso2:n.iso2}),o(te,{width:14,height:14,transform:s?"rotate(180)":""})]})}),s&&o(ie,{ref:f,tabIndex:-1,bg:"surface.primary",position:"absolute",w:"full",rounded:"input",top:55,boxShadow:"4px 8px 20px 0px rgba(0, 0, 0, 0.15)",maxHeight:"17.5rem",overflowY:"auto",outline:"none",children:i.map(([e,r,t],v)=>{const u=n.iso2===r;return l(C,{cursor:"pointer",bg:u?"brand.base":a===v?"brand.lightest":"",_hover:u?{}:{bg:"brand.lightest"},ref:ee=>b.current[v]=ee,gap:2,p:4,onClick:()=>R(r),justify:"space-between",children:[l(C,{gap:4,children:[u?o(oe,{width:18,height:18,color:re("colors.surface.primary")}):o(A,{iso2:r}),o(x,{color:u?"text.quaternary":"text.primary",children:e})]}),l(x,{color:u?"text.quaternary":"text.tertiary",children:["+",t]})]},r)})}),o("input",{type:"tel",inputMode:"tel",onChange:U,value:Y,ref:g,className:k({transition:"all linear 120ms",width:"full",boxSizing:"border-box",borderLeftWidth:"thin",borderColor:"neutral.secondary",rounded:0,margin:0,minWidth:10,fontWeight:"medium",backgroundColor:"transparent",color:"text.primary",height:12,fontSize:"md",py:3,px:4,textAlign:"left",outline:"none",_placeholder:{color:"text.tertiary"}})})]}),W&&o(x,{variant:"error",size:"sm",fontWeight:"normal",children:W})]})};B.displayName="PhoneInput";export{B as default};
1
+ import{jsxs as l,jsx as o}from"react/jsx-runtime";import{token as re}from"@styled/tokens";import te from"../icons/ico-caret-down.js";import oe from"../icons/ico-checkmark-circle-fill.js";import"../primitives/button.js";import"../primitives/checkbox.js";import"../primitives/dropdown-selector.js";import"../primitives/popover.js";import"../primitives/radio.js";import"../primitives/segmented-control.js";import"../primitives/switch.js";import w from"../primitives/text.js";import{css as C}from"@styled/css";import{VStack as ne,Flex as E,HStack as k,Box as ie}from"@styled/jsx";import{useState as c,useRef as d,useMemo as L,useCallback as N,useEffect as I}from"react";import{useButton as ae,useFocusRing as se,useKeyboard as le,mergeProps as _}from"react-aria";import{usePhoneInput as ue,defaultCountries as S,FlagImage as ce}from"react-international-phone";const A=({iso2:h})=>o(E,{width:"1.125rem",height:"1.125rem",borderRadius:"full",borderWidth:"thin",borderColor:"neutral.primary",overflow:"hidden",align:"center",children:o(ce,{src:`https://flagcdn.com/${h}.svg`,iso2:h,size:16,className:C({objectFit:"cover"})})}),B=h=>{const{onChange:M,autoFocus:q=!0,errorMessage:W}=h,[H,K]=c(""),[O,y]=c(!1),[s,m]=c(!1),[a,p]=c(0),[x,P]=c(""),T=d(null),$=d(null),f=d(null),b=d([]),j=d(void 0),{country:n,setCountry:D,inputRef:g,handlePhoneValueChange:U,inputValue:Y}=ue({defaultCountry:"us",value:H,onChange:e=>{K(e.phone),M(e.phone)}}),i=L(()=>{const e=S.filter(([,t])=>t!==n.iso2),r=S.find(([,t])=>t===n.iso2);return r?[r,...e]:[...S]},[n.iso2]),F=L(()=>i.filter(([,e])=>e!==n.iso2),[n.iso2]),R=N(e=>{var r;D(e),m(!1),(r=g.current)===null||r===void 0||r.focus()},[D]),G=N(()=>{m(!s),s||(p(0),setTimeout(()=>{var e;return(e=f.current)===null||e===void 0?void 0:e.focus()}))},[s]),{buttonProps:J}=ae({onPress:G},T),{focusProps:V,isFocusVisible:z}=se(),{keyboardProps:Q}=le({onKeyDown:e=>{var r;if(s)switch(e.key){case"ArrowDown":e.preventDefault(),p(t=>(t+1)%i.length);break;case"ArrowUp":e.preventDefault(),p(t=>(t-1+i.length)%i.length);break;case"Enter":if(e.preventDefault(),a>=0){const[,t]=i[a];R(t)}break;case"Escape":m(!1),(r=g.current)===null||r===void 0||r.focus();break;default:(e.key===" "||e.key.match(/[\w]/i))&&(e.preventDefault(),clearTimeout(j.current),P(t=>t+e.key),j.current=window.setTimeout(()=>{P("")},1e3));break}}});I(()=>{var e;q&&((e=g.current)===null||e===void 0||e.focus());const r=t=>{f.current&&!f.current.contains(t.target)&&(m(!1),y(!1))};return document.addEventListener("mousedown",r),()=>{document.removeEventListener("mousedown",r)}},[]),I(()=>{var e;if(x!==""){const r=F.findIndex(([t])=>t.toLowerCase().startsWith(x.toLowerCase()));if(r!==-1){const t=i.findIndex(([v])=>v===F[r][0]);p(t),(e=b.current[t])===null||e===void 0||e.scrollIntoView({behavior:"smooth",block:"nearest"})}}},[x,i,n.iso2]),I(()=>{var e;a>=0&&b.current[a]&&((e=b.current[a])===null||e===void 0||e.scrollIntoView({behavior:"smooth",block:"nearest"}))},[a]);const X=()=>{y(!0)},Z=()=>{y(!1)};return l(ne,{gap:2,children:[l(E,{..._(Q,V),ref:$,height:"fit-content",width:"full",alignItems:"center",justify:"center",borderWidth:"thin",borderColor:"neutral.secondary",borderRadius:"input",transition:"all linear 120ms",outlineColor:"brand.base",outlineStyle:O&&!z?"solid":"none",outlineWidth:"thick",outlineOffset:.5,onFocus:X,onBlur:Z,position:"relative",_hover:{borderColor:"neutral.primary"},children:[o("button",{..._(J,V),className:C({display:"flex",justifyContent:"center",alignItems:"center",borderStartRadius:"input",h:12,w:20,px:3,outlineColor:"brand.base",outlineStyle:z?"solid":"none",outlineWidth:"thick",outlineOffset:.5,cursor:"pointer",transition:"all linear 120ms",_hover:{bg:"surface.tertiary"}}),children:l(k,{gap:2,children:[o(A,{iso2:n.iso2}),o(te,{width:14,height:14,transform:s?"rotate(180)":""})]})}),s&&o(ie,{ref:f,tabIndex:-1,bg:"surface.primary",position:"absolute",w:"full",rounded:"input",top:55,boxShadow:"4px 8px 20px 0px rgba(0, 0, 0, 0.15)",maxHeight:"17.5rem",overflowY:"auto",outline:"none",children:i.map(([e,r,t],v)=>{const u=n.iso2===r;return l(k,{cursor:"pointer",bg:u?"brand.base":a===v?"brand.lightest":"",_hover:u?{}:{bg:"brand.lightest"},ref:ee=>b.current[v]=ee,gap:2,p:4,onClick:()=>R(r),justify:"space-between",children:[l(k,{gap:4,children:[u?o(oe,{width:18,height:18,color:re("colors.surface.primary")}):o(A,{iso2:r}),o(w,{fontColor:u?"text.quaternary":"text.primary",children:e})]}),l(w,{fontColor:u?"text.quaternary":"text.tertiary",children:["+",t]})]},r)})}),o("input",{type:"tel",inputMode:"tel",onChange:U,value:Y,ref:g,className:C({transition:"all linear 120ms",width:"full",boxSizing:"border-box",borderLeftWidth:"thin",borderColor:"neutral.secondary",rounded:0,margin:0,minWidth:10,fontWeight:"medium",backgroundColor:"transparent",color:"text.primary",height:12,fontSize:"md",py:3,px:4,textAlign:"left",outline:"none",_placeholder:{color:"text.tertiary"}})})]}),W&&o(w,{variant:"error",size:"sm",fontWeight:"normal",children:W})]})};B.displayName="PhoneInput";export{B as default};
2
2
  //# sourceMappingURL=phone-input.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"phone-input.js","sources":["../../../../src/components/inputs/phone-input.tsx"],"sourcesContent":["import { IcoCaretDown, IcoCheckmarkCircleFill } from '@components/icons';\nimport { Text } from '@components/primitives';\nimport { css } from '@styled/css';\nimport { Box, Flex, HStack, VStack } from '@styled/jsx';\nimport { token } from '@styled/tokens';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { mergeProps, useButton, useFocusRing, useKeyboard } from 'react-aria';\nimport { FlagImage, defaultCountries, usePhoneInput, type CountryIso2 } from 'react-international-phone';\n\nexport interface PhoneInputProps {\n onChange: (phone: string) => void;\n autoFocus?: boolean;\n errorMessage?: string;\n}\n\nconst FlagContainer = ({ iso2 }: { iso2: CountryIso2 }) => {\n return (\n <Flex\n width=\"1.125rem\"\n height=\"1.125rem\"\n borderRadius=\"full\"\n borderWidth=\"thin\"\n borderColor=\"neutral.primary\"\n overflow=\"hidden\"\n align=\"center\"\n >\n <FlagImage\n src={`https://flagcdn.com/${iso2}.svg`}\n iso2={iso2}\n size={16}\n className={css({ objectFit: 'cover' })}\n />\n </Flex>\n );\n};\n\nconst PhoneInput = (props: PhoneInputProps) => {\n const { onChange, autoFocus = true, errorMessage } = props;\n const [value, setValue] = useState('');\n const [isFocused, setIsFocused] = useState(false);\n const [showDropdown, setShowDropdown] = useState(false);\n const [focusedIndex, setFocusedIndex] = useState(0);\n const [searchString, setSearchString] = useState('');\n const buttonRef = useRef<HTMLButtonElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const dropdownRef = useRef<HTMLDivElement>(null);\n const itemRefs = useRef<(HTMLDivElement | null)[]>([]);\n const typeAheadTimeout = useRef<number | undefined>(undefined);\n\n const { country, setCountry, inputRef, handlePhoneValueChange, inputValue } = usePhoneInput({\n defaultCountry: 'us',\n value,\n onChange: data => {\n setValue(data.phone);\n onChange(data.phone);\n },\n });\n\n const sortedCountries = useMemo(() => {\n const otherCountries = defaultCountries.filter(([, iso2]) => iso2 !== country.iso2);\n const selectedCountry = defaultCountries.find(([, iso2]) => iso2 === country.iso2);\n return selectedCountry ? [selectedCountry, ...otherCountries] : [...defaultCountries];\n }, [country.iso2]);\n\n const filteredCountries = useMemo(() => {\n return sortedCountries.filter(([, iso2]) => iso2 !== country.iso2);\n }, [country.iso2]);\n\n const handleSelect = useCallback(\n (iso2: CountryIso2) => {\n setCountry(iso2);\n setShowDropdown(false);\n inputRef.current?.focus();\n },\n [setCountry],\n );\n\n const toggleDropdown = useCallback(() => {\n setShowDropdown(!showDropdown);\n if (!showDropdown) {\n setFocusedIndex(0);\n setTimeout(() => dropdownRef.current?.focus());\n }\n }, [showDropdown]);\n\n const { buttonProps } = useButton(\n {\n onPress: toggleDropdown,\n },\n buttonRef,\n );\n\n const { focusProps, isFocusVisible: isButtonFocused } = useFocusRing();\n\n const { keyboardProps } = useKeyboard({\n onKeyDown: e => {\n if (!showDropdown) return;\n\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n setFocusedIndex(prev => (prev + 1) % sortedCountries.length);\n break;\n case 'ArrowUp':\n e.preventDefault();\n setFocusedIndex(prev => (prev - 1 + sortedCountries.length) % sortedCountries.length);\n break;\n case 'Enter':\n e.preventDefault();\n if (focusedIndex >= 0) {\n const [, iso2] = sortedCountries[focusedIndex];\n handleSelect(iso2);\n }\n break;\n case 'Escape':\n setShowDropdown(false);\n inputRef.current?.focus();\n break;\n default:\n if (e.key === ' ' || e.key.match(/[\\w]/i)) {\n e.preventDefault();\n clearTimeout(typeAheadTimeout.current);\n setSearchString(s => s + e.key);\n typeAheadTimeout.current = window.setTimeout(() => {\n setSearchString('');\n }, 1000);\n }\n break;\n }\n },\n });\n\n useEffect(() => {\n // Focus the input when the component mounts if autoFocus is true\n if (autoFocus) {\n inputRef.current?.focus();\n }\n\n // Closes the dropdown when clicking outside of it\n const handleClick = (event: MouseEvent) => {\n if (dropdownRef.current && !dropdownRef.current.contains(event.target as Node)) {\n setShowDropdown(false);\n setIsFocused(false);\n }\n };\n\n document.addEventListener('mousedown', handleClick);\n\n return () => {\n document.removeEventListener('mousedown', handleClick);\n };\n }, []);\n\n useEffect(() => {\n // Implements type-ahead search functionality\n if (searchString !== '') {\n const matchIndex = filteredCountries.findIndex(([name]) =>\n name.toLowerCase().startsWith(searchString.toLowerCase()),\n );\n if (matchIndex !== -1) {\n const actualIndex = sortedCountries.findIndex(([name]) => name === filteredCountries[matchIndex][0]);\n setFocusedIndex(actualIndex);\n itemRefs.current[actualIndex]?.scrollIntoView({\n behavior: 'smooth',\n block: 'nearest',\n });\n }\n }\n }, [searchString, sortedCountries, country.iso2]);\n\n useEffect(() => {\n // Scrolls the focused item into view\n if (focusedIndex >= 0 && itemRefs.current[focusedIndex]) {\n itemRefs.current[focusedIndex]?.scrollIntoView({\n behavior: 'smooth',\n block: 'nearest',\n });\n }\n }, [focusedIndex]);\n\n const handleFocus = () => {\n setIsFocused(true);\n };\n\n const handleBlur = () => {\n setIsFocused(false);\n };\n\n return (\n <VStack gap={2}>\n <Flex\n {...mergeProps(keyboardProps, focusProps)}\n ref={containerRef}\n height=\"fit-content\"\n width=\"full\"\n alignItems=\"center\"\n justify=\"center\"\n borderWidth=\"thin\"\n borderColor=\"neutral.secondary\"\n borderRadius=\"input\"\n transition=\"all linear 120ms\"\n outlineColor=\"brand.base\"\n outlineStyle={isFocused && !isButtonFocused ? 'solid' : 'none'}\n outlineWidth=\"thick\"\n outlineOffset={0.5}\n onFocus={handleFocus}\n onBlur={handleBlur}\n position=\"relative\"\n _hover={{ borderColor: 'neutral.primary' }}\n >\n <button\n {...mergeProps(buttonProps, focusProps)}\n className={css({\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n borderStartRadius: 'input',\n h: 12,\n w: 20,\n px: 3,\n outlineColor: 'brand.base',\n outlineStyle: isButtonFocused ? 'solid' : 'none',\n outlineWidth: 'thick',\n outlineOffset: 0.5,\n cursor: 'pointer',\n transition: 'all linear 120ms',\n _hover: {\n bg: 'surface.tertiary',\n },\n })}\n >\n <HStack gap={2}>\n <FlagContainer iso2={country.iso2} />\n <IcoCaretDown width={14} height={14} transform={showDropdown ? 'rotate(180)' : ''} />\n </HStack>\n </button>\n\n {showDropdown && (\n <Box\n ref={dropdownRef}\n tabIndex={-1}\n bg=\"surface.primary\"\n position=\"absolute\"\n w=\"full\"\n rounded=\"input\"\n top={55}\n boxShadow=\"4px 8px 20px 0px rgba(0, 0, 0, 0.15)\"\n maxHeight=\"17.5rem\"\n overflowY=\"auto\"\n outline=\"none\"\n >\n {sortedCountries.map(([name, iso2, countryCode], index) => {\n const isSelectedCountry = country.iso2 === iso2;\n const isFocusedCountry = focusedIndex === index;\n\n return (\n <HStack\n cursor=\"pointer\"\n bg={isSelectedCountry ? 'brand.base' : isFocusedCountry ? 'brand.lightest' : ''}\n _hover={!isSelectedCountry ? { bg: 'brand.lightest' } : {}}\n key={iso2}\n ref={el => (itemRefs.current[index] = el)}\n gap={2}\n p={4}\n onClick={() => handleSelect(iso2)}\n justify=\"space-between\"\n >\n <HStack gap={4}>\n {isSelectedCountry ? (\n <IcoCheckmarkCircleFill width={18} height={18} color={token('colors.surface.primary')} />\n ) : (\n <FlagContainer iso2={iso2} />\n )}\n <Text color={isSelectedCountry ? 'text.quaternary' : 'text.primary'}>{name}</Text>\n </HStack>\n <Text color={isSelectedCountry ? 'text.quaternary' : 'text.tertiary'}>+{countryCode}</Text>\n </HStack>\n );\n })}\n </Box>\n )}\n <input\n type=\"tel\"\n inputMode=\"tel\"\n onChange={handlePhoneValueChange}\n value={inputValue}\n ref={inputRef}\n className={css({\n transition: 'all linear 120ms',\n width: 'full',\n boxSizing: 'border-box',\n borderLeftWidth: 'thin',\n borderColor: 'neutral.secondary',\n rounded: 0,\n margin: 0,\n minWidth: 10,\n fontWeight: 'medium',\n backgroundColor: 'transparent',\n color: 'text.primary',\n height: 12,\n fontSize: 'md',\n py: 3,\n px: 4,\n textAlign: 'left',\n outline: 'none',\n _placeholder: {\n color: 'text.tertiary',\n },\n })}\n />\n </Flex>\n {errorMessage && (\n <Text variant=\"error\" size=\"sm\" fontWeight=\"normal\">\n {errorMessage}\n </Text>\n )}\n </VStack>\n );\n};\n\nPhoneInput.displayName = 'PhoneInput';\nexport default PhoneInput;\n"],"names":["FlagContainer","iso2","_jsx","Flex","FlagImage","css","PhoneInput","props","onChange","autoFocus","errorMessage","value","setValue","useState","isFocused","setIsFocused","showDropdown","setShowDropdown","focusedIndex","setFocusedIndex","searchString","setSearchString","buttonRef","useRef","containerRef","dropdownRef","itemRefs","typeAheadTimeout","country","setCountry","inputRef","handlePhoneValueChange","inputValue","usePhoneInput","data","sortedCountries","useMemo","otherCountries","defaultCountries","selectedCountry","filteredCountries","handleSelect","useCallback","_a","toggleDropdown","buttonProps","useButton","focusProps","isButtonFocused","useFocusRing","keyboardProps","useKeyboard","prev","s","useEffect","handleClick","event","matchIndex","name","actualIndex","handleFocus","handleBlur","_jsxs","VStack","mergeProps","HStack","IcoCaretDown","Box","countryCode","index","isSelectedCountry","el","IcoCheckmarkCircleFill","token","Text"],"mappings":"w1BAeA,MAAMA,EAAgB,CAAC,CAAE,KAAAC,CAAI,IAEzBC,EAACC,EAAI,CACH,MAAM,WACN,OAAO,WACP,aAAa,OACb,YAAY,OACZ,YAAY,kBACZ,SAAS,SACT,MAAM,SAEN,SAAAD,EAACE,GAAS,CACR,IAAK,uBAAuBH,CAAI,OAChC,KAAMA,EACN,KAAM,GACN,UAAWI,EAAI,CAAE,UAAW,OAAS,CAAA,CACrC,CAAA,CAAA,CAAA,EAKFC,EAAcC,GAA0B,CAC5C,KAAM,CAAE,SAAAC,EAAU,UAAAC,EAAY,GAAM,aAAAC,CAAY,EAAKH,EAC/C,CAACI,EAAOC,CAAQ,EAAIC,EAAS,EAAE,EAC/B,CAACC,EAAWC,CAAY,EAAIF,EAAS,EAAK,E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,CAAC,MAAOJ,EAAoB,kBAAoB,8BAAmBF,CAAW,CAAA,CAAA,CAAQ,GAftFnE,CAAI,CAkBf,CAAC,CAAC,CAAA,EAGNC,EACE,QAAA,CAAA,KAAK,MACL,UAAU,MACV,SAAU6B,EACV,MAAOC,EACP,IAAKF,EACL,UAAWzB,EAAI,CACb,WAAY,mBACZ,MAAO,OACP,UAAW,aACX,gBAAiB,OACjB,YAAa,oBACb,QAAS,EACT,OAAQ,EACR,SAAU,GACV,WAAY,SACZ,gBAAiB,cACjB,MAAO,eACP,OAAQ,GACR,SAAU,KACV,GAAI,EACJ,GAAI,EACJ,UAAW,OACX,QAAS,OACT,aAAc,CACZ,MAAO,eACR,EACF,CAAC,CAAA,CACF,CACG,CAAA,EACNK,GACCR,EAACwE,EAAI,CAAC,QAAQ,QAAQ,KAAK,KAAK,WAAW,SACxC,SAAAhE,CACI,CAAA,CACR,CACM,CAAA,CAEb,EAEAJ,EAAW,YAAc"}
1
+ {"version":3,"file":"phone-input.js","sources":["../../../../src/components/inputs/phone-input.tsx"],"sourcesContent":["import { IcoCaretDown, IcoCheckmarkCircleFill } from '@components/icons';\nimport { Text } from '@components/primitives';\nimport { css } from '@styled/css';\nimport { Box, Flex, HStack, VStack } from '@styled/jsx';\nimport { token } from '@styled/tokens';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { mergeProps, useButton, useFocusRing, useKeyboard } from 'react-aria';\nimport { FlagImage, defaultCountries, usePhoneInput, type CountryIso2 } from 'react-international-phone';\n\nexport interface PhoneInputProps {\n onChange: (phone: string) => void;\n autoFocus?: boolean;\n errorMessage?: string;\n}\n\nconst FlagContainer = ({ iso2 }: { iso2: CountryIso2 }) => {\n return (\n <Flex\n width=\"1.125rem\"\n height=\"1.125rem\"\n borderRadius=\"full\"\n borderWidth=\"thin\"\n borderColor=\"neutral.primary\"\n overflow=\"hidden\"\n align=\"center\"\n >\n <FlagImage\n src={`https://flagcdn.com/${iso2}.svg`}\n iso2={iso2}\n size={16}\n className={css({ objectFit: 'cover' })}\n />\n </Flex>\n );\n};\n\nconst PhoneInput = (props: PhoneInputProps) => {\n const { onChange, autoFocus = true, errorMessage } = props;\n const [value, setValue] = useState('');\n const [isFocused, setIsFocused] = useState(false);\n const [showDropdown, setShowDropdown] = useState(false);\n const [focusedIndex, setFocusedIndex] = useState(0);\n const [searchString, setSearchString] = useState('');\n const buttonRef = useRef<HTMLButtonElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const dropdownRef = useRef<HTMLDivElement>(null);\n const itemRefs = useRef<(HTMLDivElement | null)[]>([]);\n const typeAheadTimeout = useRef<number | undefined>(undefined);\n\n const { country, setCountry, inputRef, handlePhoneValueChange, inputValue } = usePhoneInput({\n defaultCountry: 'us',\n value,\n onChange: data => {\n setValue(data.phone);\n onChange(data.phone);\n },\n });\n\n const sortedCountries = useMemo(() => {\n const otherCountries = defaultCountries.filter(([, iso2]) => iso2 !== country.iso2);\n const selectedCountry = defaultCountries.find(([, iso2]) => iso2 === country.iso2);\n return selectedCountry ? [selectedCountry, ...otherCountries] : [...defaultCountries];\n }, [country.iso2]);\n\n const filteredCountries = useMemo(() => {\n return sortedCountries.filter(([, iso2]) => iso2 !== country.iso2);\n }, [country.iso2]);\n\n const handleSelect = useCallback(\n (iso2: CountryIso2) => {\n setCountry(iso2);\n setShowDropdown(false);\n inputRef.current?.focus();\n },\n [setCountry],\n );\n\n const toggleDropdown = useCallback(() => {\n setShowDropdown(!showDropdown);\n if (!showDropdown) {\n setFocusedIndex(0);\n setTimeout(() => dropdownRef.current?.focus());\n }\n }, [showDropdown]);\n\n const { buttonProps } = useButton(\n {\n onPress: toggleDropdown,\n },\n buttonRef,\n );\n\n const { focusProps, isFocusVisible: isButtonFocused } = useFocusRing();\n\n const { keyboardProps } = useKeyboard({\n onKeyDown: e => {\n if (!showDropdown) return;\n\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n setFocusedIndex(prev => (prev + 1) % sortedCountries.length);\n break;\n case 'ArrowUp':\n e.preventDefault();\n setFocusedIndex(prev => (prev - 1 + sortedCountries.length) % sortedCountries.length);\n break;\n case 'Enter':\n e.preventDefault();\n if (focusedIndex >= 0) {\n const [, iso2] = sortedCountries[focusedIndex];\n handleSelect(iso2);\n }\n break;\n case 'Escape':\n setShowDropdown(false);\n inputRef.current?.focus();\n break;\n default:\n if (e.key === ' ' || e.key.match(/[\\w]/i)) {\n e.preventDefault();\n clearTimeout(typeAheadTimeout.current);\n setSearchString(s => s + e.key);\n typeAheadTimeout.current = window.setTimeout(() => {\n setSearchString('');\n }, 1000);\n }\n break;\n }\n },\n });\n\n useEffect(() => {\n // Focus the input when the component mounts if autoFocus is true\n if (autoFocus) {\n inputRef.current?.focus();\n }\n\n // Closes the dropdown when clicking outside of it\n const handleClick = (event: MouseEvent) => {\n if (dropdownRef.current && !dropdownRef.current.contains(event.target as Node)) {\n setShowDropdown(false);\n setIsFocused(false);\n }\n };\n\n document.addEventListener('mousedown', handleClick);\n\n return () => {\n document.removeEventListener('mousedown', handleClick);\n };\n }, []);\n\n useEffect(() => {\n // Implements type-ahead search functionality\n if (searchString !== '') {\n const matchIndex = filteredCountries.findIndex(([name]) =>\n name.toLowerCase().startsWith(searchString.toLowerCase()),\n );\n if (matchIndex !== -1) {\n const actualIndex = sortedCountries.findIndex(([name]) => name === filteredCountries[matchIndex][0]);\n setFocusedIndex(actualIndex);\n itemRefs.current[actualIndex]?.scrollIntoView({\n behavior: 'smooth',\n block: 'nearest',\n });\n }\n }\n }, [searchString, sortedCountries, country.iso2]);\n\n useEffect(() => {\n // Scrolls the focused item into view\n if (focusedIndex >= 0 && itemRefs.current[focusedIndex]) {\n itemRefs.current[focusedIndex]?.scrollIntoView({\n behavior: 'smooth',\n block: 'nearest',\n });\n }\n }, [focusedIndex]);\n\n const handleFocus = () => {\n setIsFocused(true);\n };\n\n const handleBlur = () => {\n setIsFocused(false);\n };\n\n return (\n <VStack gap={2}>\n <Flex\n {...mergeProps(keyboardProps, focusProps)}\n ref={containerRef}\n height=\"fit-content\"\n width=\"full\"\n alignItems=\"center\"\n justify=\"center\"\n borderWidth=\"thin\"\n borderColor=\"neutral.secondary\"\n borderRadius=\"input\"\n transition=\"all linear 120ms\"\n outlineColor=\"brand.base\"\n outlineStyle={isFocused && !isButtonFocused ? 'solid' : 'none'}\n outlineWidth=\"thick\"\n outlineOffset={0.5}\n onFocus={handleFocus}\n onBlur={handleBlur}\n position=\"relative\"\n _hover={{ borderColor: 'neutral.primary' }}\n >\n <button\n {...mergeProps(buttonProps, focusProps)}\n className={css({\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n borderStartRadius: 'input',\n h: 12,\n w: 20,\n px: 3,\n outlineColor: 'brand.base',\n outlineStyle: isButtonFocused ? 'solid' : 'none',\n outlineWidth: 'thick',\n outlineOffset: 0.5,\n cursor: 'pointer',\n transition: 'all linear 120ms',\n _hover: {\n bg: 'surface.tertiary',\n },\n })}\n >\n <HStack gap={2}>\n <FlagContainer iso2={country.iso2} />\n <IcoCaretDown width={14} height={14} transform={showDropdown ? 'rotate(180)' : ''} />\n </HStack>\n </button>\n\n {showDropdown && (\n <Box\n ref={dropdownRef}\n tabIndex={-1}\n bg=\"surface.primary\"\n position=\"absolute\"\n w=\"full\"\n rounded=\"input\"\n top={55}\n boxShadow=\"4px 8px 20px 0px rgba(0, 0, 0, 0.15)\"\n maxHeight=\"17.5rem\"\n overflowY=\"auto\"\n outline=\"none\"\n >\n {sortedCountries.map(([name, iso2, countryCode], index) => {\n const isSelectedCountry = country.iso2 === iso2;\n const isFocusedCountry = focusedIndex === index;\n\n return (\n <HStack\n cursor=\"pointer\"\n bg={isSelectedCountry ? 'brand.base' : isFocusedCountry ? 'brand.lightest' : ''}\n _hover={!isSelectedCountry ? { bg: 'brand.lightest' } : {}}\n key={iso2}\n ref={el => (itemRefs.current[index] = el)}\n gap={2}\n p={4}\n onClick={() => handleSelect(iso2)}\n justify=\"space-between\"\n >\n <HStack gap={4}>\n {isSelectedCountry ? (\n <IcoCheckmarkCircleFill width={18} height={18} color={token('colors.surface.primary')} />\n ) : (\n <FlagContainer iso2={iso2} />\n )}\n <Text fontColor={isSelectedCountry ? 'text.quaternary' : 'text.primary'}>{name}</Text>\n </HStack>\n <Text fontColor={isSelectedCountry ? 'text.quaternary' : 'text.tertiary'}>+{countryCode}</Text>\n </HStack>\n );\n })}\n </Box>\n )}\n <input\n type=\"tel\"\n inputMode=\"tel\"\n onChange={handlePhoneValueChange}\n value={inputValue}\n ref={inputRef}\n className={css({\n transition: 'all linear 120ms',\n width: 'full',\n boxSizing: 'border-box',\n borderLeftWidth: 'thin',\n borderColor: 'neutral.secondary',\n rounded: 0,\n margin: 0,\n minWidth: 10,\n fontWeight: 'medium',\n backgroundColor: 'transparent',\n color: 'text.primary',\n height: 12,\n fontSize: 'md',\n py: 3,\n px: 4,\n textAlign: 'left',\n outline: 'none',\n _placeholder: {\n color: 'text.tertiary',\n },\n })}\n />\n </Flex>\n {errorMessage && (\n <Text variant=\"error\" size=\"sm\" fontWeight=\"normal\">\n {errorMessage}\n </Text>\n )}\n </VStack>\n );\n};\n\nPhoneInput.displayName = 'PhoneInput';\nexport default PhoneInput;\n"],"names":["FlagContainer","iso2","_jsx","Flex","FlagImage","css","PhoneInput","props","onChange","autoFocus","errorMessage","value","setValue","useState","isFocused","setIsFocused","showDropdown","setShowDropdown","focusedIndex","setFocusedIndex","searchString","setSearchString","buttonRef","useRef","containerRef","dropdownRef","itemRefs","typeAheadTimeout","country","setCountry","inputRef","handlePhoneValueChange","inputValue","usePhoneInput","data","sortedCountries","useMemo","otherCountries","defaultCountries","selectedCountry","filteredCountries","handleSelect","useCallback","_a","toggleDropdown","buttonProps","useButton","focusProps","isButtonFocused","useFocusRing","keyboardProps","useKeyboard","prev","s","useEffect","handleClick","event","matchIndex","name","actualIndex","handleFocus","handleBlur","_jsxs","VStack","mergeProps","HStack","IcoCaretDown","Box","countryCode","index","isSelectedCountry","el","IcoCheckmarkCircleFill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,GAAIK,EAAoB,aALHpD,IAAiBmD,EAKoB,iBAAmB,GAC7E,OAASC,EAA+C,GAA3B,CAAE,GAAI,gBAAkB,EAErD,IAAKC,IAAO7C,EAAS,QAAQ2C,CAAK,EAAIE,GACtC,IAAK,EACL,EAAG,EACH,QAAS,IAAM9B,EAAaxC,CAAI,EAChC,QAAQ,gBAAe,SAAA,CAEvB6D,EAACG,GAAO,IAAK,EAAC,SAAA,CACXK,EACCpE,EAACsE,GAAsB,CAAC,MAAO,GAAI,OAAQ,GAAI,MAAOC,GAAM,wBAAwB,IAEpFvE,EAACF,GAAc,KAAMC,CAAQ,CAAA,EAE/BC,EAACwE,EAAK,CAAA,UAAWJ,EAAoB,kBAAoB,wBAAiBZ,CAAI,CAAA,CAAQ,IAExFI,EAACY,EAAI,CAAC,UAAWJ,EAAoB,kBAAoB,8BAAmBF,CAAW,CAAA,CAAA,CAAQ,GAf1FnE,CAAI,CAkBf,CAAC,CAAC,CAAA,EAGNC,EACE,QAAA,CAAA,KAAK,MACL,UAAU,MACV,SAAU6B,EACV,MAAOC,EACP,IAAKF,EACL,UAAWzB,EAAI,CACb,WAAY,mBACZ,MAAO,OACP,UAAW,aACX,gBAAiB,OACjB,YAAa,oBACb,QAAS,EACT,OAAQ,EACR,SAAU,GACV,WAAY,SACZ,gBAAiB,cACjB,MAAO,eACP,OAAQ,GACR,SAAU,KACV,GAAI,EACJ,GAAI,EACJ,UAAW,OACX,QAAS,OACT,aAAc,CACZ,MAAO,eACR,EACF,CAAC,CAAA,CACF,CACG,CAAA,EACNK,GACCR,EAACwE,EAAI,CAAC,QAAQ,QAAQ,KAAK,KAAK,WAAW,SACxC,SAAAhE,CACI,CAAA,CACR,CACM,CAAA,CAEb,EAEAJ,EAAW,YAAc"}
@@ -1,2 +1,2 @@
1
- import{jsx as t,jsxs as N}from"react/jsx-runtime";import{Children as z,cloneElement as k,isValidElement as ee,forwardRef as D,useRef as E}from"react";import{useTextField as S,useFocusRing as w,useHover as B,mergeProps as H}from"react-aria";import R from"../primitives/button.js";import"../primitives/checkbox.js";import"../primitives/dropdown-selector.js";import"../primitives/popover.js";import"../primitives/radio.js";import"../primitives/segmented-control.js";import"../primitives/switch.js";import p from"../primitives/text.js";import{textInput as V}from"../../recipes/text-input.js";import{cx as q,css as re}from"@styled/css";import{Flex as P,VStack as te,HStack as oe}from"@styled/jsx";import{token as A}from"@styled/tokens";import{createSlot as m,createHost as se}from"create-slots";const G=m(({children:o,...i})=>t(P,{alignItems:"center",justifyContent:"center",children:z.map(o,e=>{var r;return k(e,{...i,color:(r=e.props.color)!==null&&r!==void 0?r:A("colors.neutral.primary")})})})),M=m(({children:o,...i})=>t(P,{alignItems:"center",justifyContent:"center",children:z.map(o,e=>{var r;return ee(e)?k(e,{...i,color:(r=e.props.color)!==null&&r!==void 0?r:A("colors.brand.base")}):null})})),O=m(R),W=m(p),$=m(p),J=D((o,i)=>{const{label:e,disabled:r,size:n="md",alignText:h="left",attr:f,description:a,autoFocus:g,className:x="",errorMessage:d,required:l}=o,u=n==="sm"?16:20,L=E(null),I=i||L,{labelProps:Q,inputProps:U,descriptionProps:X,errorMessageProps:Y,isInvalid:y,validationErrors:C}=S({...o,isDisabled:r??!1,isInvalid:!!d},I),{focusProps:Z}=w({autoFocus:g??!1}),{hoverProps:_}=B({isDisabled:r??!1});return se(o.children,c=>{const v=c.get(G),b=c.get(M),j=c.getProps(O),F=c.getProps(W),T=c.getProps($),s=V({size:n,alignText:h,disabled:r,isError:y});return N(te,{className:q(s.container,x),children:[e&&N("label",{className:s.label,...Q,children:[e," ",l&&t("span",{className:re({color:"negative.darker"}),children:"*"})]}),N(oe,{className:s.inputContainer,children:[v&&{...v,props:{...v.props,className:s.typeIcon,width:u,height:u}},F&&t(p,{...F,color:"text.tertiary"}),t("input",{ref:I,className:s.input,...H(U,Z,_),...f}),T&&t(p,{...T,color:"text.tertiary"}),b&&{...b,props:{...b.props,className:s.actionIcon,width:u,height:u}},j&&t(P,{alignItems:"center",justifyContent:"center",className:s.actionButton,children:t(R,{...j,variant:"text",size:n})})]}),a&&t("div",{className:s.description,...X,children:a}),y&&t(p,{variant:"error",...Y,size:"sm",fontWeight:"normal",children:C.length>0?C.join(" "):d})]})})}),K=D((o,i)=>{const{disabled:e,autoFocus:r,className:n="",attr:h}=o,f=E(null),a=i||f,{inputProps:g}=S({...o,isDisabled:e??!1},a),{focusProps:x}=w({autoFocus:r??!1}),{hoverProps:d}=B({isDisabled:e??!1}),l=V({char:!0,disabled:e});return t("div",{className:q(l.container,l.inputContainer,n),children:t("input",{ref:a,className:l.input,...H(g,x,d),size:1,...h})})}),ie=Object.assign(J,{TypeIcon:G,ActionIcon:M,ActionButton:O,Char:K,Prefix:W,Suffix:$});J.displayName="TextInput",K.displayName="TextInputChar";export{ie as TextInput};
1
+ import{jsx as t,jsxs as N}from"react/jsx-runtime";import{Children as z,cloneElement as k,isValidElement as ee,forwardRef as D,useRef as E}from"react";import{useTextField as S,useFocusRing as w,useHover as B,mergeProps as H}from"react-aria";import R from"../primitives/button.js";import"../primitives/checkbox.js";import"../primitives/dropdown-selector.js";import"../primitives/popover.js";import"../primitives/radio.js";import"../primitives/segmented-control.js";import"../primitives/switch.js";import p from"../primitives/text.js";import{textInput as V}from"../../recipes/text-input.js";import{cx as q,css as re}from"@styled/css";import{Flex as P,VStack as te,HStack as oe}from"@styled/jsx";import{token as A}from"@styled/tokens";import{createSlot as m,createHost as ie}from"create-slots";const G=m(({children:o,...s})=>t(P,{alignItems:"center",justifyContent:"center",children:z.map(o,e=>{var r;return k(e,{...s,color:(r=e.props.color)!==null&&r!==void 0?r:A("colors.neutral.primary")})})})),M=m(({children:o,...s})=>t(P,{alignItems:"center",justifyContent:"center",children:z.map(o,e=>{var r;return ee(e)?k(e,{...s,color:(r=e.props.color)!==null&&r!==void 0?r:A("colors.brand.base")}):null})})),O=m(R),W=m(p),$=m(p),J=D((o,s)=>{const{label:e,disabled:r,size:n="md",alignText:h="left",attr:f,description:a,autoFocus:g,className:x="",errorMessage:d,required:l}=o,u=n==="sm"?16:20,L=E(null),I=s||L,{labelProps:Q,inputProps:U,descriptionProps:X,errorMessageProps:Y,isInvalid:y,validationErrors:C}=S({...o,isDisabled:r??!1,isInvalid:!!d},I),{focusProps:Z}=w({autoFocus:g??!1}),{hoverProps:_}=B({isDisabled:r??!1});return ie(o.children,c=>{const v=c.get(G),b=c.get(M),j=c.getProps(O),F=c.getProps(W),T=c.getProps($),i=V({size:n,alignText:h,disabled:r,isError:y});return N(te,{className:q(i.container,x),children:[e&&N("label",{className:i.label,...Q,children:[e," ",l&&t("span",{className:re({color:"negative.darker"}),children:"*"})]}),N(oe,{className:i.inputContainer,children:[v&&{...v,props:{...v.props,className:i.typeIcon,width:u,height:u}},F&&t(p,{...F,fontColor:"text.tertiary"}),t("input",{ref:I,className:i.input,...H(U,Z,_),...f}),T&&t(p,{...T,fontColor:"text.tertiary"}),b&&{...b,props:{...b.props,className:i.actionIcon,width:u,height:u}},j&&t(P,{alignItems:"center",justifyContent:"center",className:i.actionButton,children:t(R,{...j,variant:"text",size:n})})]}),a&&t("div",{className:i.description,...X,children:a}),y&&t(p,{variant:"error",...Y,size:"sm",fontWeight:"normal",children:C.length>0?C.join(" "):d})]})})}),K=D((o,s)=>{const{disabled:e,autoFocus:r,className:n="",attr:h}=o,f=E(null),a=s||f,{inputProps:g}=S({...o,isDisabled:e??!1},a),{focusProps:x}=w({autoFocus:r??!1}),{hoverProps:d}=B({isDisabled:e??!1}),l=V({char:!0,disabled:e});return t("div",{className:q(l.container,l.inputContainer,n),children:t("input",{ref:a,className:l.input,...H(g,x,d),size:1,...h})})}),se=Object.assign(J,{TypeIcon:G,ActionIcon:M,ActionButton:O,Char:K,Prefix:W,Suffix:$});J.displayName="TextInput",K.displayName="TextInputChar";export{se as TextInput};
2
2
  //# sourceMappingURL=text-input.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"text-input.js","sources":["../../../../src/components/inputs/text-input.tsx"],"sourcesContent":["import {\n Children,\n cloneElement,\n forwardRef,\n HTMLAttributes,\n InputHTMLAttributes,\n isValidElement,\n ReactNode,\n RefObject,\n useRef,\n} from 'react';\nimport type { AriaTextFieldProps } from 'react-aria';\nimport { mergeProps, useFocusRing, useHover, useTextField } from 'react-aria';\n\nimport { Button, Text } from '@components/primitives';\nimport { textInput } from '@recipes/text-input';\nimport { css, cx } from '@styled/css';\nimport { Flex, HStack, VStack } from '@styled/jsx';\nimport { token } from '@styled/tokens';\n\nimport { createHost, createSlot } from 'create-slots';\n\nexport type TextInputProps = AriaTextFieldProps & {\n className?: string;\n disabled?: boolean;\n attr?: InputHTMLAttributes<HTMLInputElement>;\n errorMessage?: string;\n children?: ReactNode;\n size?: 'sm' | 'md' | 'lg';\n alignText?: 'left' | 'center' | 'right';\n required?: boolean;\n};\n\nexport type CharProps = AriaTextFieldProps & {\n className?: string;\n disabled?: boolean;\n attr?: InputHTMLAttributes<HTMLInputElement>;\n};\n\nexport type ActionIconProps = HTMLAttributes<HTMLElement> & {\n onClick: () => void;\n};\n\nconst TypeIcon = createSlot(({ children, ...props }) => {\n return (\n <Flex alignItems=\"center\" justifyContent=\"center\">\n {Children.map(children, child => {\n return cloneElement(child, { ...props, color: child.props.color ?? token('colors.neutral.primary') });\n })}\n </Flex>\n );\n});\n\nconst ActionIcon = createSlot(({ children, ...props }: ActionIconProps) => {\n return (\n <Flex alignItems=\"center\" justifyContent=\"center\">\n {Children.map(children, child => {\n if (isValidElement<ActionIconProps>(child)) {\n return cloneElement(child, { ...props, color: child.props.color ?? token('colors.brand.base') });\n }\n return null;\n })}\n </Flex>\n );\n});\n\nconst ActionButton = createSlot(Button);\nconst Prefix = createSlot(Text);\nconst Suffix = createSlot(Text);\n\nconst Component = forwardRef<HTMLInputElement, TextInputProps>((props, forwardedRef) => {\n const {\n label,\n disabled,\n size = 'md',\n alignText = 'left',\n attr,\n description,\n autoFocus,\n className = '',\n errorMessage,\n required,\n } = props;\n const iconSize = size === 'sm' ? 16 : 20;\n\n const internalRef = useRef(null);\n // forwardedRef is null until after first render\n const ref = forwardedRef || internalRef;\n\n const { labelProps, inputProps, descriptionProps, errorMessageProps, isInvalid, validationErrors } = useTextField(\n { ...props, isDisabled: disabled ?? false, isInvalid: !!errorMessage },\n ref as RefObject<HTMLInputElement>,\n );\n\n const { focusProps } = useFocusRing({\n autoFocus: autoFocus ?? false,\n });\n const { hoverProps } = useHover({ isDisabled: disabled ?? false });\n\n return createHost(props.children, slots => {\n const typeIcon = slots.get(TypeIcon);\n const actionIcon = slots.get(ActionIcon);\n const actionButtonProps = slots.getProps(ActionButton);\n const prefixProps = slots.getProps(Prefix);\n const suffixProps = slots.getProps(Suffix);\n\n const classes = textInput({\n size,\n alignText,\n disabled,\n isError: isInvalid,\n });\n\n return (\n <VStack className={cx(classes.container, className)}>\n {label && (\n <label className={classes.label} {...labelProps}>\n {label} {required && <span className={css({ color: 'negative.darker' })}>*</span>}\n </label>\n )}\n <HStack className={classes.inputContainer}>\n {typeIcon && {\n ...typeIcon,\n props: { ...typeIcon.props, className: classes.typeIcon, width: iconSize, height: iconSize },\n }}\n {prefixProps && <Text {...prefixProps} color=\"text.tertiary\" />}\n <input ref={ref} className={classes.input} {...mergeProps(inputProps, focusProps, hoverProps)} {...attr} />\n {suffixProps && <Text {...suffixProps} color=\"text.tertiary\" />}\n {actionIcon && {\n ...actionIcon,\n props: { ...actionIcon.props, className: classes.actionIcon, width: iconSize, height: iconSize },\n }}\n {actionButtonProps && (\n <Flex alignItems=\"center\" justifyContent=\"center\" className={classes.actionButton}>\n <Button {...actionButtonProps} variant=\"text\" size={size} />\n </Flex>\n )}\n </HStack>\n {description && (\n <div className={classes.description} {...descriptionProps}>\n {description}\n </div>\n )}\n {isInvalid && (\n <Text variant=\"error\" {...errorMessageProps} size={'sm'} fontWeight=\"normal\">\n {validationErrors.length > 0 ? validationErrors.join(' ') : errorMessage}\n </Text>\n )}\n </VStack>\n );\n });\n});\n\nconst Char = forwardRef<HTMLInputElement, CharProps>((props, forwardedRef) => {\n const { disabled, autoFocus, className = '', attr } = props;\n\n const internalRef = useRef(null);\n // forwardedRef is null until after first render\n const ref = forwardedRef || internalRef;\n\n const { inputProps } = useTextField({ ...props, isDisabled: disabled ?? false }, ref as RefObject<HTMLInputElement>);\n\n const { focusProps } = useFocusRing({ autoFocus: autoFocus ?? false });\n const { hoverProps } = useHover({ isDisabled: disabled ?? false });\n\n const classes = textInput({ char: true, disabled });\n\n return (\n <div className={cx(classes.container, classes.inputContainer, className)}>\n <input\n ref={ref}\n className={classes.input}\n {...mergeProps(inputProps, focusProps, hoverProps)}\n size={1}\n {...attr}\n />\n </div>\n );\n});\n\nexport const TextInput = Object.assign(Component, {\n TypeIcon,\n ActionIcon,\n ActionButton,\n Char,\n Prefix,\n Suffix,\n});\n\nComponent.displayName = 'TextInput';\nChar.displayName = 'TextInputChar';\n"],"names":["TypeIcon","createSlot","children","props","_jsx","Flex","Children","child","cloneElement","_a","token","ActionIcon","isValidElement","ActionButton","Button","Prefix","Text","Suffix","Component","forwardRef","forwardedRef","label","disabled","size","alignText","attr","description","autoFocus","className","errorMessage","required","iconSize","internalRef","useRef","ref","labelProps","inputProps","descriptionProps","errorMessageProps","isInvalid","validationErrors","useTextField","focusProps","useFocusRing","hoverProps","useHover","createHost","slots","typeIcon","actionIcon","actionButtonProps","prefixProps","suffixProps","classes","textInput","_jsxs","VStack","cx","css","HStack","mergeProps","Char","TextInput"],"mappings":"sxBA2CA,MAAMA,EAAWC,EAAW,CAAC,CAAE,SAAAC,EAAU,GAAGC,CAAO,IAE/CC,EAACC,EAAI,CAAC,WAAW,SAAS,eAAe,SACtC,SAAAC,EAAS,IAAIJ,EAAUK,GAAQ,OAC9B,OAAOC,EAAaD,EAAO,CAAE,GAAGJ,EAAO,OAAOM,EAAAF,EAAM,MAAM,SAAS,MAAAE,IAAA,OAAAA,EAAAC,EAAM,wBAAwB,CAAG,CAAA,CACtG,CAAC,CACI,CAAA,CAEV,EAEKC,EAAaV,EAAW,CAAC,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EAAiB,KAAK,GAAG,EAAIX,CACvD,CAAA,CACR,CACM,CAAA,CAEb,CAAC,CACH,CAAC,EAEKgC,EAAO1C,EAAwC,CAAChB,EAAOiB,IAAgB,CAC3E,KAAM,CAAE,SAAAE,EAAU,UAAAK,EAAW,UAAAC,EAAY,GAAI,KAAAH,CAAM,EAAGtB,EAEhD6B,EAAcC,EAAO,IAAI,EAEzBC,EAAMd,GAAgBY,EAEtB,CAAE,WAAAI,CAAY,EAAGK,EAAa,CAAE,GAAGtC,EAAO,WAAYmB,GAAY,EAAO,EAAEY,CAAkC,EAE7G,CAAE,WAAAQ,CAAU,EAAKC,EAAa,CAAE,UAAWhB,GAAa,EAAK,CAAE,EAC/D,CAAE,WAAAiB,CAAU,EAAKC,EAAS,CAAE,WAAYvB,GAAY,EAAK,CAAE,EAE3D+B,EAAUC,EAAU,CAAE,KAAM,GAAM,SAAAhC,CAAU,CAAA,EAElD,OACElB,SAAK,UAAWqD,EAAGJ,EAAQ,UAAWA,EAAQ,eAAgBzB,CAAS,WACrExB,EACE,QAAA,CAAA,IAAK8B,EACL,UAAWmB,EAAQ,MAAK,GACpBO,EAAWxB,EAAYM,EAAYE,CAAU,EACjD,KAAM,KACFnB,CAAI,CAAA,CAEN,CAAA,CAEV,CAAC,EAEYqC,GAAY,OAAO,OAAO5C,EAAW,CAChD,SAAAlB,EACA,WAAAW,EACA,aAAAE,EACA,KAAAgD,EACA,OAAA9C,EACA,OAAAE,CACD,CAAA,EAEDC,EAAU,YAAc,YACxB2C,EAAK,YAAc"}
1
+ {"version":3,"file":"text-input.js","sources":["../../../../src/components/inputs/text-input.tsx"],"sourcesContent":["import {\n Children,\n cloneElement,\n forwardRef,\n HTMLAttributes,\n InputHTMLAttributes,\n isValidElement,\n ReactNode,\n RefObject,\n useRef,\n} from 'react';\nimport type { AriaTextFieldProps } from 'react-aria';\nimport { mergeProps, useFocusRing, useHover, useTextField } from 'react-aria';\n\nimport { Button, Text } from '@components/primitives';\nimport { textInput } from '@recipes/text-input';\nimport { css, cx } from '@styled/css';\nimport { Flex, HStack, VStack } from '@styled/jsx';\nimport { token } from '@styled/tokens';\n\nimport { createHost, createSlot } from 'create-slots';\n\nexport type TextInputProps = AriaTextFieldProps & {\n className?: string;\n disabled?: boolean;\n attr?: InputHTMLAttributes<HTMLInputElement>;\n errorMessage?: string;\n children?: ReactNode;\n size?: 'sm' | 'md' | 'lg';\n alignText?: 'left' | 'center' | 'right';\n required?: boolean;\n};\n\nexport type CharProps = AriaTextFieldProps & {\n className?: string;\n disabled?: boolean;\n attr?: InputHTMLAttributes<HTMLInputElement>;\n};\n\nexport type ActionIconProps = HTMLAttributes<HTMLElement> & {\n onClick: () => void;\n};\n\nconst TypeIcon = createSlot(({ children, ...props }) => {\n return (\n <Flex alignItems=\"center\" justifyContent=\"center\">\n {Children.map(children, child => {\n return cloneElement(child, { ...props, color: child.props.color ?? token('colors.neutral.primary') });\n })}\n </Flex>\n );\n});\n\nconst ActionIcon = createSlot(({ children, ...props }: ActionIconProps) => {\n return (\n <Flex alignItems=\"center\" justifyContent=\"center\">\n {Children.map(children, child => {\n if (isValidElement<ActionIconProps>(child)) {\n return cloneElement(child, { ...props, color: child.props.color ?? token('colors.brand.base') });\n }\n return null;\n })}\n </Flex>\n );\n});\n\nconst ActionButton = createSlot(Button);\nconst Prefix = createSlot(Text);\nconst Suffix = createSlot(Text);\n\nconst Component = forwardRef<HTMLInputElement, TextInputProps>((props, forwardedRef) => {\n const {\n label,\n disabled,\n size = 'md',\n alignText = 'left',\n attr,\n description,\n autoFocus,\n className = '',\n errorMessage,\n required,\n } = props;\n const iconSize = size === 'sm' ? 16 : 20;\n\n const internalRef = useRef(null);\n // forwardedRef is null until after first render\n const ref = forwardedRef || internalRef;\n\n const { labelProps, inputProps, descriptionProps, errorMessageProps, isInvalid, validationErrors } = useTextField(\n { ...props, isDisabled: disabled ?? false, isInvalid: !!errorMessage },\n ref as RefObject<HTMLInputElement>,\n );\n\n const { focusProps } = useFocusRing({\n autoFocus: autoFocus ?? false,\n });\n const { hoverProps } = useHover({ isDisabled: disabled ?? false });\n\n return createHost(props.children, slots => {\n const typeIcon = slots.get(TypeIcon);\n const actionIcon = slots.get(ActionIcon);\n const actionButtonProps = slots.getProps(ActionButton);\n const prefixProps = slots.getProps(Prefix);\n const suffixProps = slots.getProps(Suffix);\n\n const classes = textInput({\n size,\n alignText,\n disabled,\n isError: isInvalid,\n });\n\n return (\n <VStack className={cx(classes.container, className)}>\n {label && (\n <label className={classes.label} {...labelProps}>\n {label} {required && <span className={css({ color: 'negative.darker' })}>*</span>}\n </label>\n )}\n <HStack className={classes.inputContainer}>\n {typeIcon && {\n ...typeIcon,\n props: { ...typeIcon.props, className: classes.typeIcon, width: iconSize, height: iconSize },\n }}\n {prefixProps && <Text {...prefixProps} fontColor=\"text.tertiary\" />}\n <input ref={ref} className={classes.input} {...mergeProps(inputProps, focusProps, hoverProps)} {...attr} />\n {suffixProps && <Text {...suffixProps} fontColor=\"text.tertiary\" />}\n {actionIcon && {\n ...actionIcon,\n props: { ...actionIcon.props, className: classes.actionIcon, width: iconSize, height: iconSize },\n }}\n {actionButtonProps && (\n <Flex alignItems=\"center\" justifyContent=\"center\" className={classes.actionButton}>\n <Button {...actionButtonProps} variant=\"text\" size={size} />\n </Flex>\n )}\n </HStack>\n {description && (\n <div className={classes.description} {...descriptionProps}>\n {description}\n </div>\n )}\n {isInvalid && (\n <Text variant=\"error\" {...errorMessageProps} size={'sm'} fontWeight=\"normal\">\n {validationErrors.length > 0 ? validationErrors.join(' ') : errorMessage}\n </Text>\n )}\n </VStack>\n );\n });\n});\n\nconst Char = forwardRef<HTMLInputElement, CharProps>((props, forwardedRef) => {\n const { disabled, autoFocus, className = '', attr } = props;\n\n const internalRef = useRef(null);\n // forwardedRef is null until after first render\n const ref = forwardedRef || internalRef;\n\n const { inputProps } = useTextField({ ...props, isDisabled: disabled ?? false }, ref as RefObject<HTMLInputElement>);\n\n const { focusProps } = useFocusRing({ autoFocus: autoFocus ?? false });\n const { hoverProps } = useHover({ isDisabled: disabled ?? false });\n\n const classes = textInput({ char: true, disabled });\n\n return (\n <div className={cx(classes.container, classes.inputContainer, className)}>\n <input\n ref={ref}\n className={classes.input}\n {...mergeProps(inputProps, focusProps, hoverProps)}\n size={1}\n {...attr}\n />\n </div>\n );\n});\n\nexport const TextInput = Object.assign(Component, {\n TypeIcon,\n ActionIcon,\n ActionButton,\n Char,\n Prefix,\n Suffix,\n});\n\nComponent.displayName = 'TextInput';\nChar.displayName = 'TextInputChar';\n"],"names":["TypeIcon","createSlot","children","props","_jsx","Flex","Children","child","cloneElement","_a","token","ActionIcon","isValidElement","ActionButton","Button","Prefix","Text","Suffix","Component","forwardRef","forwardedRef","label","disabled","size","alignText","attr","description","autoFocus","className","errorMessage","required","iconSize","internalRef","useRef","ref","labelProps","inputProps","descriptionProps","errorMessageProps","isInvalid","validationErrors","useTextField","focusProps","useFocusRing","hoverProps","useHover","createHost","slots","typeIcon","actionIcon","actionButtonProps","prefixProps","suffixProps","classes","textInput","_jsxs","VStack","cx","css","HStack","mergeProps","Char","TextInput"],"mappings":"sxBA2CA,MAAMA,EAAWC,EAAW,CAAC,CAAE,SAAAC,EAAU,GAAGC,CAAO,IAE/CC,EAACC,EAAI,CAAC,WAAW,SAAS,eAAe,SACtC,SAAAC,EAAS,IAAIJ,EAAUK,GAAQ,OAC9B,OAAOC,EAAaD,EAAO,CAAE,GAAGJ,EAAO,OAAOM,EAAAF,EAAM,MAAM,SAAS,MAAAE,IAAA,OAAAA,EAAAC,EAAM,wBAAwB,CAAG,CAAA,CACtG,CAAC,CACI,CAAA,CAEV,EAEKC,EAAaV,EAAW,CAAC,CAAE,SAAAC,EAAU,GAAGC,CAAwB,IAElEC,EAACC,EAAI,CAAC,WAAW,SAAS,eAAe,SACtC,SAAAC,EAAS,IAAIJ,EAAUK,GAAQ,OAC9B,OAAIK,GAAgCL,CAAK,EAChCC,EAAaD,EAAO,CAAE,GAAGJ,EAAO,OAAOM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CAAM,EAAGtB,EAEhD6B,EAAcC,EAAO,IAAI,EAEzBC,EAAMd,GAAgBY,EAEtB,CAAE,WAAAI,CAAY,EAAGK,EAAa,CAAE,GAAGtC,EAAO,WAAYmB,GAAY,EAAO,EAAEY,CAAkC,EAE7G,CAAE,WAAAQ,CAAU,EAAKC,EAAa,CAAE,UAAWhB,GAAa,EAAK,CAAE,EAC/D,CAAE,WAAAiB,CAAU,EAAKC,EAAS,CAAE,WAAYvB,GAAY,EAAK,CAAE,EAE3D+B,EAAUC,EAAU,CAAE,KAAM,GAAM,SAAAhC,CAAU,CAAA,EAElD,OACElB,SAAK,UAAWqD,EAAGJ,EAAQ,UAAWA,EAAQ,eAAgBzB,CAAS,WACrExB,EACE,QAAA,CAAA,IAAK8B,EACL,UAAWmB,EAAQ,MAAK,GACpBO,EAAWxB,EAAYM,EAAYE,CAAU,EACjD,KAAM,KACFnB,CAAI,CAAA,CAEN,CAAA,CAEV,CAAC,EAEYqC,GAAY,OAAO,OAAO5C,EAAW,CAChD,SAAAlB,EACA,WAAAW,EACA,aAAAE,EACA,KAAAgD,EACA,OAAA9C,EACA,OAAAE,CACD,CAAA,EAEDC,EAAU,YAAc,YACxB2C,EAAK,YAAc"}
@@ -1,2 +1,2 @@
1
- import{jsx as t,jsxs as s}from"react/jsx-runtime";import{token as I}from"@styled/tokens";import L from"../icons/ico-external-link.js";import"../primitives/button.js";import"../primitives/checkbox.js";import"../primitives/dropdown-selector.js";import"../primitives/popover.js";import"../primitives/radio.js";import"../primitives/segmented-control.js";import"../primitives/switch.js";import p from"../primitives/text.js";import{css as m}from"@styled/css";import{Center as d,HStack as u}from"@styled/jsx";import{flex as B}from"@styled/patterns";import{createSlot as h,createHost as E}from"create-slots";import{Children as f,cloneElement as b,forwardRef as H,useRef as P}from"react";import{useButton as R,useFocusRing as S,mergeProps as F}from"react-aria";const g=h(({children:r,...o})=>t(d,{children:f.map(r,e=>b(e,o))})),y=h(({children:r,...o})=>t(d,{children:f.map(r,e=>b(e,o))})),x=H((r,o)=>{const{primaryLabel:e,secondaryLabel:l,isExternalLink:k,disabled:v}=r,w=P(null),a=o||w,{buttonProps:N}=R({...r,isDisabled:v??!1},a),{isFocusVisible:j,focusProps:C}=S();return E(r.children,c=>{const i=c.get(g),n=c.get(y);return s("button",{...F(N,C),ref:a,className:B({justifyContent:"space-between",alignItems:"center",w:"full",p:4,bg:"neutral.quaternary",transition:"background-color 0.2s",_hover:{bg:"neutral.secondary"},rounded:"lg",cursor:"pointer",outlineColor:"brand.base",outlineStyle:j?"solid":"none",outlineWidth:"thick",outlineOffset:.5,_disabled:{opacity:"0.3",pointerEvents:"none"}}),children:[s(u,{children:[i&&{...i,props:{...i.props,className:i.props.color?void 0:m({color:"brand.base"}),height:24}},t(p,{fontWeight:"medium",children:e}),k&&t(L,{width:14,height:14,color:I("colors.neutral.primary")})]}),s(u,{children:[l&&t(p,{size:"sm",color:"text.tertiary",children:l}),n&&{...n,props:{...n.props,className:n.props.color?void 0:m({color:"neutral.primary"}),width:16,height:16}}]})]})})});x.displayName="NavigationButton";const O=Object.assign(x,{LeadingIcon:g,TrailingIcon:y});export{O as default};
1
+ import{jsx as t,jsxs as s}from"react/jsx-runtime";import{token as I}from"@styled/tokens";import L from"../icons/ico-external-link.js";import"../primitives/button.js";import"../primitives/checkbox.js";import"../primitives/dropdown-selector.js";import"../primitives/popover.js";import"../primitives/radio.js";import"../primitives/segmented-control.js";import"../primitives/switch.js";import p from"../primitives/text.js";import{css as m}from"@styled/css";import{Center as d,HStack as u}from"@styled/jsx";import{flex as B}from"@styled/patterns";import{createSlot as f,createHost as E}from"create-slots";import{Children as h,cloneElement as b,forwardRef as H,useRef as P}from"react";import{useButton as R,useFocusRing as S,mergeProps as F}from"react-aria";const g=f(({children:r,...o})=>t(d,{children:h.map(r,e=>b(e,o))})),y=f(({children:r,...o})=>t(d,{children:h.map(r,e=>b(e,o))})),x=H((r,o)=>{const{primaryLabel:e,secondaryLabel:l,isExternalLink:k,disabled:v}=r,w=P(null),a=o||w,{buttonProps:N}=R({...r,isDisabled:v??!1},a),{isFocusVisible:j,focusProps:C}=S();return E(r.children,c=>{const i=c.get(g),n=c.get(y);return s("button",{...F(N,C),ref:a,className:B({justifyContent:"space-between",alignItems:"center",w:"full",p:4,bg:"neutral.quaternary",transition:"background-color 0.2s",_hover:{bg:"neutral.secondary"},rounded:"lg",cursor:"pointer",outlineColor:"brand.base",outlineStyle:j?"solid":"none",outlineWidth:"thick",outlineOffset:.5,_disabled:{opacity:"0.3",pointerEvents:"none"}}),children:[s(u,{children:[i&&{...i,props:{...i.props,className:i.props.color?void 0:m({color:"brand.base"}),height:24}},t(p,{fontWeight:"medium",children:e}),k&&t(L,{width:14,height:14,color:I("colors.neutral.primary")})]}),s(u,{children:[l&&t(p,{size:"sm",fontColor:"text.tertiary",children:l}),n&&{...n,props:{...n.props,className:n.props.color?void 0:m({color:"neutral.primary"}),width:16,height:16}}]})]})})});x.displayName="NavigationButton";const O=Object.assign(x,{LeadingIcon:g,TrailingIcon:y});export{O as default};
2
2
  //# sourceMappingURL=navigation-button.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"navigation-button.js","sources":["../../../../src/components/list-items/navigation-button.tsx"],"sourcesContent":["import { IcoExternalLink } from '@components/icons';\nimport { Text } from '@components/primitives';\nimport { css } from '@styled/css';\nimport { Center, HStack } from '@styled/jsx';\nimport { flex } from '@styled/patterns';\nimport { token } from '@styled/tokens';\nimport { createHost, createSlot } from 'create-slots';\nimport { Children, RefObject, cloneElement, forwardRef, useRef } from 'react';\nimport { AriaButtonProps, mergeProps, useButton, useFocusRing } from 'react-aria';\n\nexport interface NavigationButtonProps extends AriaButtonProps {\n primaryLabel: string;\n secondaryLabel?: string;\n isExternalLink?: boolean;\n disabled?: boolean;\n}\n\nconst LeadingIcon = createSlot(({ children, ...props }) => {\n return (\n <Center>\n {Children.map(children, child => {\n return cloneElement(child, props);\n })}\n </Center>\n );\n});\n\nconst TrailingIcon = createSlot(({ children, ...props }) => {\n return (\n <Center>\n {Children.map(children, child => {\n return cloneElement(child, props);\n })}\n </Center>\n );\n});\n\nconst NavigationButtonBase = forwardRef<HTMLButtonElement, NavigationButtonProps>((props, forwardedRef) => {\n const { primaryLabel, secondaryLabel, isExternalLink, disabled } = props;\n\n const internalRef = useRef(null);\n const ref = forwardedRef || internalRef;\n\n const { buttonProps } = useButton({ ...props, isDisabled: disabled ?? false }, ref as RefObject<HTMLButtonElement>);\n const { isFocusVisible, focusProps } = useFocusRing();\n\n return createHost(props.children, slots => {\n const leadingIcon = slots.get(LeadingIcon);\n const trailingIcon = slots.get(TrailingIcon);\n\n return (\n <button\n {...mergeProps(buttonProps, focusProps)}\n ref={ref}\n className={flex({\n justifyContent: 'space-between',\n alignItems: 'center',\n w: 'full',\n p: 4,\n bg: 'neutral.quaternary',\n transition: 'background-color 0.2s',\n _hover: { bg: 'neutral.secondary' },\n rounded: 'lg',\n cursor: 'pointer',\n outlineColor: 'brand.base',\n outlineStyle: isFocusVisible ? 'solid' : 'none',\n outlineWidth: 'thick',\n outlineOffset: 0.5,\n _disabled: { opacity: '0.3', pointerEvents: 'none' },\n })}\n >\n <HStack>\n {leadingIcon && {\n ...leadingIcon,\n props: {\n ...leadingIcon.props,\n className: !leadingIcon.props.color ? css({ color: 'brand.base' }) : undefined,\n height: 24,\n },\n }}\n <Text fontWeight=\"medium\">{primaryLabel}</Text>\n {isExternalLink && <IcoExternalLink width={14} height={14} color={token('colors.neutral.primary')} />}\n </HStack>\n <HStack>\n {secondaryLabel && (\n <Text size=\"sm\" color=\"text.tertiary\">\n {secondaryLabel}\n </Text>\n )}\n {trailingIcon && {\n ...trailingIcon,\n props: {\n ...trailingIcon.props,\n className: !trailingIcon.props.color ? css({ color: 'neutral.primary' }) : undefined,\n width: 16,\n height: 16,\n },\n }}\n </HStack>\n </button>\n );\n });\n});\n\nNavigationButtonBase.displayName = 'NavigationButton';\n\nconst NavigationButton = Object.assign(NavigationButtonBase, { LeadingIcon, TrailingIcon });\n\nexport default NavigationButton;\n"],"names":["LeadingIcon","createSlot","children","props","_jsx","Center","Children","child","cloneElement","TrailingIcon","NavigationButtonBase","forwardRef","forwardedRef","primaryLabel","secondaryLabel","isExternalLink","disabled","internalRef","useRef","ref","buttonProps","useButton","isFocusVisible","focusProps","useFocusRing","createHost","slots","leadingIcon","trailingIcon","_jsxs","mergeProps","flex","HStack","css","Text","IcoExternalLink","token","NavigationButton"],"mappings":"gvBAiBA,MAAMA,EAAcC,EAAW,CAAC,CAAE,SAAAC,EAAU,GAAGC,CAAO,IAElDC,EAACC,EAAM,CAAA,SACJC,EAAS,IAAIJ,EAAUK,GACfC,EAAaD,EAAOJ,CAAK,CACjC,CACM,CAAA,CAEZ,EAEKM,EAAeR,EAAW,CAAC,CAAE,SAAAC,EAAU,GAAGC,CAAO,IAEnDC,EAACC,EAAM,CAAA,SACJC,EAAS,IAAIJ,EAAUK,GACfC,EAAaD,EAAOJ,CAAK,CACjC,CACM,CAAA,CAEZ,EAEKO,EAAuBC,EAAqD,CAACR,EAAOS,IAAgB,CACxG,KAAM,CAAE,aAAAC,EAAc,eAAAC,EAAgB,eAAAC,EAAgB,SAAAC,CAAQ,EAAKb,EAE7Dc,EAAcC,EAAO,IAAI,EACzBC,EAAMP,GAAgBK,EAEtB,CAAE,YAAAG,CAAa,EAAGC,EAAU,CAAE,GAAGlB,EAAO,WAAYa,GAAY,EAAO,EAAEG,CAAmC,EAC5G,CAAE,eAAAG,EAAgB,WAAAC,GAAeC,EAAAA,EAEvC,OAAOC,EAAWtB,EAAM,SAAUuB,GAAQ,CACxC,MAAMC,EAAcD,EAAM,IAAI1B,CAAW,EACnC4B,EAAeF,EAAM,IAAIjB,CAAY,EAE3C,OACEoB,EACM,SAAA,CAAA,GAAAC,EAAWV,EAAaG,CAAU,EACtC,IAAKJ,EACL,UAAWY,EAAK,CACd,eAAgB,gBAChB,WAAY,SACZ,EAAG,OACH,EAAG,EACH,GAAI,qBACJ,WAAY,wBACZ,OAAQ,CAAE,GAAI,mBAAqB,EACnC,QAAS,KACT,OAAQ,UACR,aAAc,aACd,aAAcT,EAAiB,QAAU,OACzC,aAAc,QACd,cAAe,GACf,UAAW,CAAE,QAAS,MAAO,cAAe,MAAQ,CACrD,CAAA,EAED,SAAA,CAAAO,EAACG,EAAM,CAAA,SAAA,CACJL,GAAe,CACd,GAAGA,EACH,MAAO,CACL,GAAGA,EAAY,MACf,UAAYA,EAAY,MAAM,MAAuC,OAA/BM,EAAI,CAAE,MAAO,aAAc,EACjE,OAAQ,EACT,GAEH7B,EAAC8B,EAAI,CAAC,WAAW,SAAU,SAAArB,CAAoB,CAAA,EAC9CE,GAAkBX,EAAC+B,EAAe,CAAC,MAAO,GAAI,OAAQ,GAAI,MAAOC,EAAM,wBAAwB,CAAC,CAAA,CAAI,CAC9F,CAAA,EACTP,EAACG,aACElB,GACCV,EAAC8B,EAAI,CAAC,KAAK,KAAK,MAAM,gBACnB,SAAApB,CACI,CAAA,EAERc,GAAgB,CACf,GAAGA,EACH,MAAO,CACL,GAAGA,EAAa,MAChB,UAAYA,EAAa,MAAM,MAA4C,OAApCK,EAAI,CAAE,MAAO,kBAAmB,EACvE,MAAO,GACP,OAAQ,EACT,EACF,CACM,CAAA,CAAA,CAAA,CAAA,CAGf,CAAC,CACH,CAAC,EAEDvB,EAAqB,YAAc,mBAE7B2B,MAAAA,EAAmB,OAAO,OAAO3B,EAAsB,CAAE,YAAAV,EAAa,aAAAS,CAAY,CAAE"}
1
+ {"version":3,"file":"navigation-button.js","sources":["../../../../src/components/list-items/navigation-button.tsx"],"sourcesContent":["import { IcoExternalLink } from '@components/icons';\nimport { Text } from '@components/primitives';\nimport { css } from '@styled/css';\nimport { Center, HStack } from '@styled/jsx';\nimport { flex } from '@styled/patterns';\nimport { token } from '@styled/tokens';\nimport { createHost, createSlot } from 'create-slots';\nimport { Children, RefObject, cloneElement, forwardRef, useRef } from 'react';\nimport { AriaButtonProps, mergeProps, useButton, useFocusRing } from 'react-aria';\n\nexport interface NavigationButtonProps extends AriaButtonProps {\n primaryLabel: string;\n secondaryLabel?: string;\n isExternalLink?: boolean;\n disabled?: boolean;\n}\n\nconst LeadingIcon = createSlot(({ children, ...props }) => {\n return (\n <Center>\n {Children.map(children, child => {\n return cloneElement(child, props);\n })}\n </Center>\n );\n});\n\nconst TrailingIcon = createSlot(({ children, ...props }) => {\n return (\n <Center>\n {Children.map(children, child => {\n return cloneElement(child, props);\n })}\n </Center>\n );\n});\n\nconst NavigationButtonBase = forwardRef<HTMLButtonElement, NavigationButtonProps>((props, forwardedRef) => {\n const { primaryLabel, secondaryLabel, isExternalLink, disabled } = props;\n\n const internalRef = useRef(null);\n const ref = forwardedRef || internalRef;\n\n const { buttonProps } = useButton({ ...props, isDisabled: disabled ?? false }, ref as RefObject<HTMLButtonElement>);\n const { isFocusVisible, focusProps } = useFocusRing();\n\n return createHost(props.children, slots => {\n const leadingIcon = slots.get(LeadingIcon);\n const trailingIcon = slots.get(TrailingIcon);\n\n return (\n <button\n {...mergeProps(buttonProps, focusProps)}\n ref={ref}\n className={flex({\n justifyContent: 'space-between',\n alignItems: 'center',\n w: 'full',\n p: 4,\n bg: 'neutral.quaternary',\n transition: 'background-color 0.2s',\n _hover: { bg: 'neutral.secondary' },\n rounded: 'lg',\n cursor: 'pointer',\n outlineColor: 'brand.base',\n outlineStyle: isFocusVisible ? 'solid' : 'none',\n outlineWidth: 'thick',\n outlineOffset: 0.5,\n _disabled: { opacity: '0.3', pointerEvents: 'none' },\n })}\n >\n <HStack>\n {leadingIcon && {\n ...leadingIcon,\n props: {\n ...leadingIcon.props,\n className: !leadingIcon.props.color ? css({ color: 'brand.base' }) : undefined,\n height: 24,\n },\n }}\n <Text fontWeight=\"medium\">{primaryLabel}</Text>\n {isExternalLink && <IcoExternalLink width={14} height={14} color={token('colors.neutral.primary')} />}\n </HStack>\n <HStack>\n {secondaryLabel && (\n <Text size=\"sm\" fontColor=\"text.tertiary\">\n {secondaryLabel}\n </Text>\n )}\n {trailingIcon && {\n ...trailingIcon,\n props: {\n ...trailingIcon.props,\n className: !trailingIcon.props.color ? css({ color: 'neutral.primary' }) : undefined,\n width: 16,\n height: 16,\n },\n }}\n </HStack>\n </button>\n );\n });\n});\n\nNavigationButtonBase.displayName = 'NavigationButton';\n\nconst NavigationButton = Object.assign(NavigationButtonBase, { LeadingIcon, TrailingIcon });\n\nexport default NavigationButton;\n"],"names":["LeadingIcon","createSlot","children","props","_jsx","Center","Children","child","cloneElement","TrailingIcon","NavigationButtonBase","forwardRef","forwardedRef","primaryLabel","secondaryLabel","isExternalLink","disabled","internalRef","useRef","ref","buttonProps","useButton","isFocusVisible","focusProps","useFocusRing","createHost","slots","leadingIcon","trailingIcon","_jsxs","mergeProps","flex","HStack","css","Text","IcoExternalLink","token","NavigationButton"],"mappings":"gvBAiBA,MAAMA,EAAcC,EAAW,CAAC,CAAE,SAAAC,EAAU,GAAGC,CAAO,IAElDC,EAACC,EAAM,CAAA,SACJC,EAAS,IAAIJ,EAAUK,GACfC,EAAaD,EAAOJ,CAAK,CACjC,CACM,CAAA,CAEZ,EAEKM,EAAeR,EAAW,CAAC,CAAE,SAAAC,EAAU,GAAGC,CAAO,IAEnDC,EAACC,EAAM,CAAA,SACJC,EAAS,IAAIJ,EAAUK,GACfC,EAAaD,EAAOJ,CAAK,CACjC,CACM,CAAA,CAEZ,EAEKO,EAAuBC,EAAqD,CAACR,EAAOS,IAAgB,CACxG,KAAM,CAAE,aAAAC,EAAc,eAAAC,EAAgB,eAAAC,EAAgB,SAAAC,CAAQ,EAAKb,EAE7Dc,EAAcC,EAAO,IAAI,EACzBC,EAAMP,GAAgBK,EAEtB,CAAE,YAAAG,CAAa,EAAGC,EAAU,CAAE,GAAGlB,EAAO,WAAYa,GAAY,EAAO,EAAEG,CAAmC,EAC5G,CAAE,eAAAG,EAAgB,WAAAC,GAAeC,EAAAA,EAEvC,OAAOC,EAAWtB,EAAM,SAAUuB,GAAQ,CACxC,MAAMC,EAAcD,EAAM,IAAI1B,CAAW,EACnC4B,EAAeF,EAAM,IAAIjB,CAAY,EAE3C,OACEoB,EACM,SAAA,CAAA,GAAAC,EAAWV,EAAaG,CAAU,EACtC,IAAKJ,EACL,UAAWY,EAAK,CACd,eAAgB,gBAChB,WAAY,SACZ,EAAG,OACH,EAAG,EACH,GAAI,qBACJ,WAAY,wBACZ,OAAQ,CAAE,GAAI,mBAAqB,EACnC,QAAS,KACT,OAAQ,UACR,aAAc,aACd,aAAcT,EAAiB,QAAU,OACzC,aAAc,QACd,cAAe,GACf,UAAW,CAAE,QAAS,MAAO,cAAe,MAAQ,CACrD,CAAA,EAED,SAAA,CAAAO,EAACG,EAAM,CAAA,SAAA,CACJL,GAAe,CACd,GAAGA,EACH,MAAO,CACL,GAAGA,EAAY,MACf,UAAYA,EAAY,MAAM,MAAuC,OAA/BM,EAAI,CAAE,MAAO,aAAc,EACjE,OAAQ,EACT,GAEH7B,EAAC8B,EAAI,CAAC,WAAW,SAAU,SAAArB,CAAoB,CAAA,EAC9CE,GAAkBX,EAAC+B,EAAe,CAAC,MAAO,GAAI,OAAQ,GAAI,MAAOC,EAAM,wBAAwB,CAAC,CAAA,CAAI,CAC9F,CAAA,EACTP,EAACG,aACElB,GACCV,EAAC8B,EAAI,CAAC,KAAK,KAAK,UAAU,gBACvB,SAAApB,CACI,CAAA,EAERc,GAAgB,CACf,GAAGA,EACH,MAAO,CACL,GAAGA,EAAa,MAChB,UAAYA,EAAa,MAAM,MAA4C,OAApCK,EAAI,CAAE,MAAO,kBAAmB,EACvE,MAAO,GACP,OAAQ,EACT,EACF,CACM,CAAA,CAAA,CAAA,CAAA,CAGf,CAAC,CACH,CAAC,EAEDvB,EAAqB,YAAc,mBAE7B2B,MAAAA,EAAmB,OAAO,OAAO3B,EAAsB,CAAE,YAAAV,EAAa,aAAAS,CAAY,CAAE"}
@@ -1,2 +1,2 @@
1
- import{jsx as e,jsxs as s}from"react/jsx-runtime";import k from"../logos/icon-generic-token.js";import"@styled/tokens";import"../primitives/button.js";import"../primitives/checkbox.js";import"../primitives/dropdown-selector.js";import"../primitives/popover.js";import"../primitives/radio.js";import"../primitives/segmented-control.js";import"../primitives/switch.js";import m from"../primitives/text.js";import{css as S}from"@styled/css";import{Center as W,HStack as h,VStack as B}from"@styled/jsx";import{createSlot as w,createHost as x}from"create-slots";import{Children as I,cloneElement as H,useRef as P,useCallback as j}from"react";import{useButton as z,useFocusRing as C,mergeProps as U}from"react-aria";const p=w(({children:o,...t})=>e(W,{children:I.map(o,n=>H(n,t))})),u=({name:o,fiatBalanceWithSymbol:t,tokenBalanceWithSymbol:n,tokenIcon:i,logoUrl:r})=>s(h,{w:"full",justify:"space-between",children:[s(h,{gap:2,children:[i?{...i,props:{...i.props,width:30,height:30}}:r?e("img",{width:30,height:30,src:r,alt:`${o} logo`}):e(k,{width:30,height:30}),e(m,{fontWeight:"medium",styles:{textTransform:"capitalize"},children:o})]}),s(B,{gap:0,alignItems:"flex-end",children:[e(m,{size:"sm",fontWeight:"medium",styles:{lineHeight:"1.5rem"},children:t}),e(m,{size:"sm",color:"text.secondary",styles:{lineHeight:"1.5rem"},children:n})]})]}),T=o=>{const{name:t,fiatBalanceWithSymbol:n,tokenBalanceWithSymbol:i,logoUrl:r,onPress:l}=o,a=P(null),d=j(()=>{l?.()},[l]),{buttonProps:f}=z({...o,onPress:d},a),{isFocusVisible:g,focusProps:b}=C();return x(o.children,y=>{const c=y.get(p);return l?e("button",{ref:a,...U(f,b),className:S({w:"full",p:4,minH:20,bg:"neutral.quaternary",transition:"background-color 0.2s",_hover:{bg:"neutral.secondary"},rounded:"lg",outlineColor:"brand.base",outlineStyle:g?"solid":"none",outlineWidth:"thick",outlineOffset:1,cursor:"pointer"}),children:e(u,{name:t,fiatBalanceWithSymbol:n,tokenBalanceWithSymbol:i,tokenIcon:c,logoUrl:r})}):e(u,{name:t,fiatBalanceWithSymbol:n,tokenBalanceWithSymbol:i,tokenIcon:c,logoUrl:r})})},F=Object.assign(T,{TokenIcon:p});export{F as TokenListItem};
1
+ import{jsx as e,jsxs as s}from"react/jsx-runtime";import k from"../logos/icon-generic-token.js";import"@styled/tokens";import"../primitives/button.js";import"../primitives/checkbox.js";import"../primitives/dropdown-selector.js";import"../primitives/popover.js";import"../primitives/radio.js";import"../primitives/segmented-control.js";import"../primitives/switch.js";import m from"../primitives/text.js";import{css as S}from"@styled/css";import{Center as W,HStack as h,VStack as B}from"@styled/jsx";import{createSlot as w,createHost as x}from"create-slots";import{Children as I,cloneElement as C,useRef as H,useCallback as P}from"react";import{useButton as j,useFocusRing as z,mergeProps as U}from"react-aria";const p=w(({children:o,...t})=>e(W,{children:I.map(o,n=>C(n,t))})),u=({name:o,fiatBalanceWithSymbol:t,tokenBalanceWithSymbol:n,tokenIcon:i,logoUrl:r})=>s(h,{w:"full",justify:"space-between",children:[s(h,{gap:2,children:[i?{...i,props:{...i.props,width:30,height:30}}:r?e("img",{width:30,height:30,src:r,alt:`${o} logo`}):e(k,{width:30,height:30}),e(m,{fontWeight:"medium",styles:{textTransform:"capitalize"},children:o})]}),s(B,{gap:0,alignItems:"flex-end",children:[e(m,{size:"sm",fontWeight:"medium",styles:{lineHeight:"1.5rem"},children:t}),e(m,{size:"sm",fontColor:"text.secondary",styles:{lineHeight:"1.5rem"},children:n})]})]}),T=o=>{const{name:t,fiatBalanceWithSymbol:n,tokenBalanceWithSymbol:i,logoUrl:r,onPress:l}=o,a=H(null),d=P(()=>{l?.()},[l]),{buttonProps:f}=j({...o,onPress:d},a),{isFocusVisible:g,focusProps:b}=z();return x(o.children,y=>{const c=y.get(p);return l?e("button",{ref:a,...U(f,b),className:S({w:"full",p:4,minH:20,bg:"neutral.quaternary",transition:"background-color 0.2s",_hover:{bg:"neutral.secondary"},rounded:"lg",outlineColor:"brand.base",outlineStyle:g?"solid":"none",outlineWidth:"thick",outlineOffset:1,cursor:"pointer"}),children:e(u,{name:t,fiatBalanceWithSymbol:n,tokenBalanceWithSymbol:i,tokenIcon:c,logoUrl:r})}):e(u,{name:t,fiatBalanceWithSymbol:n,tokenBalanceWithSymbol:i,tokenIcon:c,logoUrl:r})})},F=Object.assign(T,{TokenIcon:p});export{F as TokenListItem};
2
2
  //# sourceMappingURL=token-list-item.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"token-list-item.js","sources":["../../../../src/components/list-items/token-list-item.tsx"],"sourcesContent":["import { IconGenericToken } from '@components/logos';\nimport { Text } from '@components/primitives';\nimport { css } from '@styled/css';\nimport { Center, HStack, VStack } from '@styled/jsx';\nimport { createHost, createSlot } from 'create-slots';\nimport { Children, cloneElement, useCallback, useRef } from 'react';\nimport { AriaButtonProps, mergeProps, useButton, useFocusRing } from 'react-aria';\n\nexport interface TokenListItemProps extends AriaButtonProps {\n name: string;\n fiatBalanceWithSymbol: string;\n tokenBalanceWithSymbol: string;\n logoUrl?: string;\n onPress?: () => void;\n}\n\nconst TokenIcon = createSlot(({ children, ...props }) => {\n return (\n <Center>\n {Children.map(children, child => {\n return cloneElement(child, props);\n })}\n </Center>\n );\n});\n\ninterface ListContentProps extends Omit<TokenListItemProps, 'onPress'> {\n tokenIcon?: React.ReactElement;\n}\n\nconst ListContent = ({ name, fiatBalanceWithSymbol, tokenBalanceWithSymbol, tokenIcon, logoUrl }: ListContentProps) => {\n return (\n <HStack w=\"full\" justify=\"space-between\">\n <HStack gap={2}>\n {tokenIcon ? (\n {\n ...tokenIcon,\n props: {\n ...tokenIcon.props,\n width: 30,\n height: 30,\n },\n }\n ) : logoUrl ? (\n <img width={30} height={30} src={logoUrl} alt={`${name} logo`} />\n ) : (\n <IconGenericToken width={30} height={30} />\n )}\n <Text fontWeight=\"medium\" styles={{ textTransform: 'capitalize' }}>\n {name}\n </Text>\n </HStack>\n <VStack gap={0} alignItems=\"flex-end\">\n <Text size=\"sm\" fontWeight=\"medium\" styles={{ lineHeight: '1.5rem' }}>\n {fiatBalanceWithSymbol}\n </Text>\n <Text size=\"sm\" color=\"text.secondary\" styles={{ lineHeight: '1.5rem' }}>\n {tokenBalanceWithSymbol}\n </Text>\n </VStack>\n </HStack>\n );\n};\n\nconst TokenListItemBase = (props: TokenListItemProps) => {\n const { name, fiatBalanceWithSymbol, tokenBalanceWithSymbol, logoUrl, onPress } = props;\n\n const ref = useRef(null);\n\n const handlePress = useCallback(() => {\n onPress?.();\n }, [onPress]);\n\n const { buttonProps } = useButton({ ...props, onPress: handlePress }, ref);\n const { isFocusVisible, focusProps } = useFocusRing();\n\n return createHost(props.children, slots => {\n const tokenIcon = slots.get(TokenIcon);\n\n if (onPress)\n return (\n <button\n ref={ref}\n {...mergeProps(buttonProps, focusProps)}\n className={css({\n w: 'full',\n p: 4,\n minH: 20,\n bg: 'neutral.quaternary',\n transition: 'background-color 0.2s',\n _hover: { bg: 'neutral.secondary' },\n rounded: 'lg',\n outlineColor: 'brand.base',\n outlineStyle: isFocusVisible ? 'solid' : 'none',\n outlineWidth: 'thick',\n outlineOffset: 1,\n cursor: 'pointer',\n })}\n >\n <ListContent\n name={name}\n fiatBalanceWithSymbol={fiatBalanceWithSymbol}\n tokenBalanceWithSymbol={tokenBalanceWithSymbol}\n tokenIcon={tokenIcon}\n logoUrl={logoUrl}\n />\n </button>\n );\n\n return (\n <ListContent\n name={name}\n fiatBalanceWithSymbol={fiatBalanceWithSymbol}\n tokenBalanceWithSymbol={tokenBalanceWithSymbol}\n tokenIcon={tokenIcon}\n logoUrl={logoUrl}\n />\n );\n });\n};\n\nexport const TokenListItem = Object.assign(TokenListItemBase, { TokenIcon });\n"],"names":["TokenIcon","createSlot","children","props","_jsx","Center","Children","child","cloneElement","ListContent","name","fiatBalanceWithSymbol","tokenBalanceWithSymbol","tokenIcon","logoUrl","_jsxs","HStack","IconGenericToken","Text","VStack","TokenListItemBase","onPress","ref","useRef","handlePress","useCallback","buttonProps","useButton","isFocusVisible","focusProps","useFocusRing","createHost","slots","mergeProps","css","TokenListItem"],"mappings":"ssBAgBA,MAAMA,EAAYC,EAAW,CAAC,CAAE,SAAAC,EAAU,GAAGC,C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CAAE,eAAAM,EAAgB,WAAAC,GAAeC,IAEvC,OAAOC,EAAW5B,EAAM,SAAU6B,GAAQ,CACxC,MAAMnB,EAAYmB,EAAM,IAAIhC,CAAS,EAErC,OAAIqB,EAEAjB,EACE,SAAA,CAAA,IAAKkB,KACDW,EAAWP,EAAaG,CAAU,EACtC,UAAWK,EAAI,CACb,EAAG,OACH,EAAG,EACH,KAAM,GACN,GAAI,qBACJ,WAAY,wBACZ,OAAQ,CAAE,GAAI,mBAAqB,EACnC,QAAS,KACT,aAAc,aACd,aAAcN,EAAiB,QAAU,OACzC,aAAc,QACd,cAAe,EACf,OAAQ,UACT,EAAC,SAEFxB,EAACK,EACC,CAAA,KAAMC,EACN,sBAAuBC,EACvB,uBAAwBC,EACxB,UAAWC,EACX,QAASC,CAAO,CAAA,CAEX,CAAA,EAIXV,EAACK,EACC,CAAA,KAAMC,EACN,sBAAuBC,EACvB,uBAAwBC,EACxB,UAAWC,EACX,QAASC,CACT,CAAA,CAEN,CAAC,CACH,EAEaqB,EAAgB,OAAO,OAAOf,EAAmB,CAAE,UAAApB,CAAS,CAAE"}
1
+ {"version":3,"file":"token-list-item.js","sources":["../../../../src/components/list-items/token-list-item.tsx"],"sourcesContent":["import { IconGenericToken } from '@components/logos';\nimport { Text } from '@components/primitives';\nimport { css } from '@styled/css';\nimport { Center, HStack, VStack } from '@styled/jsx';\nimport { createHost, createSlot } from 'create-slots';\nimport { Children, cloneElement, useCallback, useRef } from 'react';\nimport { AriaButtonProps, mergeProps, useButton, useFocusRing } from 'react-aria';\n\nexport interface TokenListItemProps extends AriaButtonProps {\n name: string;\n fiatBalanceWithSymbol: string;\n tokenBalanceWithSymbol: string;\n logoUrl?: string;\n onPress?: () => void;\n}\n\nconst TokenIcon = createSlot(({ children, ...props }) => {\n return (\n <Center>\n {Children.map(children, child => {\n return cloneElement(child, props);\n })}\n </Center>\n );\n});\n\ninterface ListContentProps extends Omit<TokenListItemProps, 'onPress'> {\n tokenIcon?: React.ReactElement;\n}\n\nconst ListContent = ({ name, fiatBalanceWithSymbol, tokenBalanceWithSymbol, tokenIcon, logoUrl }: ListContentProps) => {\n return (\n <HStack w=\"full\" justify=\"space-between\">\n <HStack gap={2}>\n {tokenIcon ? (\n {\n ...tokenIcon,\n props: {\n ...tokenIcon.props,\n width: 30,\n height: 30,\n },\n }\n ) : logoUrl ? (\n <img width={30} height={30} src={logoUrl} alt={`${name} logo`} />\n ) : (\n <IconGenericToken width={30} height={30} />\n )}\n <Text fontWeight=\"medium\" styles={{ textTransform: 'capitalize' }}>\n {name}\n </Text>\n </HStack>\n <VStack gap={0} alignItems=\"flex-end\">\n <Text size=\"sm\" fontWeight=\"medium\" styles={{ lineHeight: '1.5rem' }}>\n {fiatBalanceWithSymbol}\n </Text>\n <Text size=\"sm\" fontColor=\"text.secondary\" styles={{ lineHeight: '1.5rem' }}>\n {tokenBalanceWithSymbol}\n </Text>\n </VStack>\n </HStack>\n );\n};\n\nconst TokenListItemBase = (props: TokenListItemProps) => {\n const { name, fiatBalanceWithSymbol, tokenBalanceWithSymbol, logoUrl, onPress } = props;\n\n const ref = useRef(null);\n\n const handlePress = useCallback(() => {\n onPress?.();\n }, [onPress]);\n\n const { buttonProps } = useButton({ ...props, onPress: handlePress }, ref);\n const { isFocusVisible, focusProps } = useFocusRing();\n\n return createHost(props.children, slots => {\n const tokenIcon = slots.get(TokenIcon);\n\n if (onPress)\n return (\n <button\n ref={ref}\n {...mergeProps(buttonProps, focusProps)}\n className={css({\n w: 'full',\n p: 4,\n minH: 20,\n bg: 'neutral.quaternary',\n transition: 'background-color 0.2s',\n _hover: { bg: 'neutral.secondary' },\n rounded: 'lg',\n outlineColor: 'brand.base',\n outlineStyle: isFocusVisible ? 'solid' : 'none',\n outlineWidth: 'thick',\n outlineOffset: 1,\n cursor: 'pointer',\n })}\n >\n <ListContent\n name={name}\n fiatBalanceWithSymbol={fiatBalanceWithSymbol}\n tokenBalanceWithSymbol={tokenBalanceWithSymbol}\n tokenIcon={tokenIcon}\n logoUrl={logoUrl}\n />\n </button>\n );\n\n return (\n <ListContent\n name={name}\n fiatBalanceWithSymbol={fiatBalanceWithSymbol}\n tokenBalanceWithSymbol={tokenBalanceWithSymbol}\n tokenIcon={tokenIcon}\n logoUrl={logoUrl}\n />\n );\n });\n};\n\nexport const TokenListItem = Object.assign(TokenListItemBase, { TokenIcon });\n"],"names":["TokenIcon","createSlot","children","props","_jsx","Center","Children","child","cloneElement","ListContent","name","fiatBalanceWithSymbol","tokenBalanceWithSymbol","tokenIcon","logoUrl","_jsxs","HStack","IconGenericToken","Text","VStack","TokenListItemBase","onPress","ref","useRef","handlePress","useCallback","buttonProps","useButton","isFocusVisible","focusProps","useFocusRing","createHost","slots","mergeProps","css","TokenListItem"],"mappings":"ssBAgBA,MAAMA,EAAYC,EAAW,CAAC,CAAE,SAAAC,EAAU,GAAGC,CAAO,IAEhDC,EAACC,EAAM,CAAA,SACJC,EAAS,IAAIJ,EAAUK,GACfC,EAAaD,EAAOJ,CAAK,CACjC,CACM,CAAA,CAEZ,EAMKM,EAAc,CAAC,CAAE,KAAAC,EAAM,sBAAAC,EAAuB,uBAAAC,EAAwB,UAAAC,EAAW,QAAAC,CAAO,IAE1FC,EAACC,EAAM,CAAC,EAAE,OAAO,QAAQ,0BACvBD,EAACC,EAAO,CAAA,IAAK,YACVH,EACC,CACE,GAAGA,EACH,MAAO,CACL,GAAGA,EAAU,MACb,MAAO,GACP,OAAQ,EACT,GAEDC,EACFV,EAAA,MAAA,CAAK,MAAO,GAAI,OAAQ,GAAI,IAAKU,EAAS,IAAK,GAAGJ,CAAI,OAAO,CAAA,EAE7DN,EAACa,EAAiB,CAAA,MAAO,GAAI,OAAQ,EAAM,CAAA,EAE7Cb,EAACc,EAAI,CAAC,WAAW,SAAS,OAAQ,CAAE,cAAe,YAAc,EAAA,SAC9DR,CACI,CAAA,CAAA,CAAA,CAAA,EAETK,EAACI,EAAM,CAAC,IAAK,EAAG,WAAW,WAAU,SAAA,CACnCf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1,2 +1,2 @@
1
- import{jsxs as b,jsx as o}from"react/jsx-runtime";import"../feedback/callout.js";import{css as A}from"@styled/css";import{HStack as S,Box as W,VStack as T}from"@styled/jsx";import"../feedback/progress-bar.js";import{token as D}from"@styled/tokens";import U from"../icons/ico-caret-down.js";import Y from"../icons/ico-caret-up.js";import G from"../icons/ico-checkmark.js";import J from"../icons/ico-question-circle-fill.js";import"./button.js";import"./checkbox.js";import"./popover.js";import"./radio.js";import"./segmented-control.js";import"./switch.js";import C from"./text.js";import"./portal.js";import{createContext as Q,useContext as X,useCallback as O,useState as B,useRef as F,useMemo as Z,Children as m,useEffect as ee,cloneElement as te}from"react";import"../../hooks/useToast.js";import"../../recipes/toast.js";import re from"../feedback/tooltip.js";import{useButton as oe,useFocusRing as le,useKeyboard as ie,mergeProps as ne}from"react-aria";const L={sm:{caret:16,check:14,height:"2.625rem",top:48,width:"0.75rem",mult:2.25},md:{caret:17,check:15,height:"2.8125rem",top:52,width:"0.85rem",mult:2.25},lg:{caret:18,check:16,height:"3rem",top:55,width:"1rem",mult:2.5}},N=Q({selectedOption:null,setSelectedOption:()=>{}}),R=({value:r,label:s,size:d="lg",isFocused:y})=>{const{selectedOption:u,setSelectedOption:p}=X(N),n=u?.value===r,l=L[d],x=O(()=>{p({value:r,label:s})},[p,r,s]);return b(S,{py:1.5,gap:2,bg:n?"brand.base":y?"brand.lightest":"",_hover:n?{}:{bg:"brand.lightest"},onClick:x,style:{paddingLeft:l.width,paddingRight:l.width},children:[o(W,{style:{width:l.width},children:n&&o(G,{width:l.check,height:l.check,color:D("colors.text.quaternary")})}),o(C,{size:d,fontWeight:"medium",color:n?"text.quaternary":"text.primary",styles:{textAlign:"left"},children:s})]})},_=({children:r,onSelect:s,label:d,placeholder:y="Select one",selectedValue:u,size:p="lg",tooltipContent:n,disabled:l,viewMax:x=5,...j})=>{const[h,g]=B(!1),[t,f]=B(null),w=F(null),k=F(null),a=L[p],q=x*a.mult+1,H=O(()=>{g(e=>!e),h||(f(null),setTimeout(()=>{var e;return(e=k.current)===null||e===void 0?void 0:e.focus()}))},[h]),I=O(e=>{s(e.value),g(!1)},[s]),z=Z(()=>{const e=m.toArray(r).find(i=>i.props.value===u);return e?e.props.label:y},[u,r]),{buttonProps:K}=oe({...j,isDisabled:l,onPress:H},w),{focusProps:V,isFocusVisible:$}=le(),{keyboardProps:M}=ie({onKeyDown:e=>{var i,c;if(!h)return;let v=t;const E=m.toArray(r);switch(e.key){case"ArrowUp":e.preventDefault(),t===null?f(m.count(r)-1):(v=t>0?t-1:m.count(r)-1,f(v));break;case"ArrowDown":e.preventDefault(),t===null?f(0):(v=t<m.count(r)-1?t+1:0,f(v));break;case"Enter":if(e.preventDefault(),(i=w.current)===null||i===void 0||i.focus(),t===null)return;if(t>=0&&t<E.length){const P=E[t];P&&s(P.props.value)}break;case"Escape":g(!1),(c=w.current)===null||c===void 0||c.focus();break}}});return ee(()=>{const e=i=>{var c;!((c=k.current)===null||c===void 0)&&c.contains(i.target)||g(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]),o(N.Provider,{value:{selectedOption:{value:u??"",label:z},setSelectedOption:I},children:b(T,{gap:2,w:"full",alignItems:"flex-start",children:[(d||n)&&b(S,{gap:2,opacity:l?.3:"",transition:"all linear 120ms",children:[d&&o(C,{size:"sm",fontWeight:"medium",children:d}),n&&o(re,{isDisabled:l,content:n,children:o(J,{className:A({w:4,h:4,color:"neutral.primary"})})})]}),b("button",{className:A({w:"full",h:"fit-content",bg:"surface.primary",borderWidth:"thin",borderColor:"neutral.secondary",rounded:"xl",transition:"all linear 120ms",position:"relative",cursor:"pointer",outlineColor:"brand.base",outlineStyle:$?"solid":"none",outlineWidth:"thick",outlineOffset:.5,_hover:{borderColor:"neutral.primary"},_disabled:{opacity:.3,pointerEvents:"none"}}),ref:w,...ne(K,V,M),children:[b(S,{w:"full",p:4,justifyContent:"space-between",style:{height:a.height},children:[o(C,{size:p,color:u?"text.primary":"text.tertiary",children:z}),h?o(Y,{width:a.caret,height:a.caret,color:D("colors.brand.base")}):o(U,{width:a.caret,height:a.caret,color:D("colors.brand.base")})]}),h&&o(W,{ref:k,tabIndex:-1,py:2,bg:"surface.primary",position:"absolute",w:"full",rounded:"input",boxShadow:"4px 8px 20px 0px rgba(0, 0, 0, 0.15)",style:{maxHeight:`${q}rem`,top:a.top},overflowY:"auto",outline:"none",zIndex:"max",children:m.map(r,(e,i)=>te(e,{isFocused:i===t,size:p}))})]})]})})};R.displayName="DropdownOption",_.displayName="DropdownSelector";export{R as DropdownOption,_ as DropdownSelector};
1
+ import{jsxs as b,jsx as o}from"react/jsx-runtime";import"../feedback/callout.js";import{css as A}from"@styled/css";import{HStack as C,Box as W,VStack as T}from"@styled/jsx";import"../feedback/progress-bar.js";import{token as S}from"@styled/tokens";import U from"../icons/ico-caret-down.js";import Y from"../icons/ico-caret-up.js";import G from"../icons/ico-checkmark.js";import J from"../icons/ico-question-circle-fill.js";import"./button.js";import"./checkbox.js";import"./popover.js";import"./radio.js";import"./segmented-control.js";import"./switch.js";import D from"./text.js";import"./portal.js";import{createContext as Q,useContext as X,useCallback as O,useState as B,useRef as F,useMemo as Z,Children as m,useEffect as ee,cloneElement as te}from"react";import"../../hooks/useToast.js";import"../../recipes/toast.js";import re from"../feedback/tooltip.js";import{useButton as oe,useFocusRing as le,useKeyboard as ne,mergeProps as ie}from"react-aria";const L={sm:{caret:16,check:14,height:"2.625rem",top:48,width:"0.75rem",mult:2.25},md:{caret:17,check:15,height:"2.8125rem",top:52,width:"0.85rem",mult:2.25},lg:{caret:18,check:16,height:"3rem",top:55,width:"1rem",mult:2.5}},N=Q({selectedOption:null,setSelectedOption:()=>{}}),R=({value:r,label:s,size:d="lg",isFocused:y})=>{const{selectedOption:u,setSelectedOption:p}=X(N),i=u?.value===r,l=L[d],x=O(()=>{p({value:r,label:s})},[p,r,s]);return b(C,{py:1.5,gap:2,bg:i?"brand.base":y?"brand.lightest":"",_hover:i?{}:{bg:"brand.lightest"},onClick:x,style:{paddingLeft:l.width,paddingRight:l.width},children:[o(W,{style:{width:l.width},children:i&&o(G,{width:l.check,height:l.check,color:S("colors.text.quaternary")})}),o(D,{size:d,fontWeight:"medium",fontColor:i?"text.quaternary":"text.primary",styles:{textAlign:"left"},children:s})]})},_=({children:r,onSelect:s,label:d,placeholder:y="Select one",selectedValue:u,size:p="lg",tooltipContent:i,disabled:l,viewMax:x=5,...j})=>{const[h,g]=B(!1),[t,f]=B(null),w=F(null),k=F(null),a=L[p],q=x*a.mult+1,H=O(()=>{g(e=>!e),h||(f(null),setTimeout(()=>{var e;return(e=k.current)===null||e===void 0?void 0:e.focus()}))},[h]),I=O(e=>{s(e.value),g(!1)},[s]),z=Z(()=>{const e=m.toArray(r).find(n=>n.props.value===u);return e?e.props.label:y},[u,r]),{buttonProps:K}=oe({...j,isDisabled:l,onPress:H},w),{focusProps:V,isFocusVisible:$}=le(),{keyboardProps:M}=ne({onKeyDown:e=>{var n,c;if(!h)return;let v=t;const E=m.toArray(r);switch(e.key){case"ArrowUp":e.preventDefault(),t===null?f(m.count(r)-1):(v=t>0?t-1:m.count(r)-1,f(v));break;case"ArrowDown":e.preventDefault(),t===null?f(0):(v=t<m.count(r)-1?t+1:0,f(v));break;case"Enter":if(e.preventDefault(),(n=w.current)===null||n===void 0||n.focus(),t===null)return;if(t>=0&&t<E.length){const P=E[t];P&&s(P.props.value)}break;case"Escape":g(!1),(c=w.current)===null||c===void 0||c.focus();break}}});return ee(()=>{const e=n=>{var c;!((c=k.current)===null||c===void 0)&&c.contains(n.target)||g(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]),o(N.Provider,{value:{selectedOption:{value:u??"",label:z},setSelectedOption:I},children:b(T,{gap:2,w:"full",alignItems:"flex-start",children:[(d||i)&&b(C,{gap:2,opacity:l?.3:"",transition:"all linear 120ms",children:[d&&o(D,{size:"sm",fontWeight:"medium",children:d}),i&&o(re,{isDisabled:l,content:i,children:o(J,{className:A({w:4,h:4,color:"neutral.primary"})})})]}),b("button",{className:A({w:"full",h:"fit-content",bg:"surface.primary",borderWidth:"thin",borderColor:"neutral.secondary",rounded:"xl",transition:"all linear 120ms",position:"relative",cursor:"pointer",outlineColor:"brand.base",outlineStyle:$?"solid":"none",outlineWidth:"thick",outlineOffset:.5,_hover:{borderColor:"neutral.primary"},_disabled:{opacity:.3,pointerEvents:"none"}}),ref:w,...ie(K,V,M),children:[b(C,{w:"full",p:4,justifyContent:"space-between",style:{height:a.height},children:[o(D,{size:p,fontColor:u?"text.primary":"text.tertiary",children:z}),h?o(Y,{width:a.caret,height:a.caret,color:S("colors.brand.base")}):o(U,{width:a.caret,height:a.caret,color:S("colors.brand.base")})]}),h&&o(W,{ref:k,tabIndex:-1,py:2,bg:"surface.primary",position:"absolute",w:"full",rounded:"input",boxShadow:"4px 8px 20px 0px rgba(0, 0, 0, 0.15)",style:{maxHeight:`${q}rem`,top:a.top},overflowY:"auto",outline:"none",zIndex:"max",children:m.map(r,(e,n)=>te(e,{isFocused:n===t,size:p}))})]})]})})};R.displayName="DropdownOption",_.displayName="DropdownSelector";export{R as DropdownOption,_ as DropdownSelector};
2
2
  //# sourceMappingURL=dropdown-selector.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown-selector.js","sources":["../../../../src/components/primitives/dropdown-selector.tsx"],"sourcesContent":["import { Tooltip } from '@components/feedback';\nimport { IcoCaretDown, IcoCaretUp, IcoCheckmark, IcoQuestionCircleFill } from '@components/icons';\nimport { Text } from '@components/primitives';\nimport { css } from '@styled/css';\nimport { Box, HStack, VStack } from '@styled/jsx';\nimport { token } from '@styled/tokens';\nimport {\n Children,\n cloneElement,\n createContext,\n ReactElement,\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { AriaButtonProps, mergeProps, useButton, useFocusRing, useKeyboard } from 'react-aria';\n\nexport interface DropdownSelectorProps extends AriaButtonProps {\n children: ReactNode;\n onSelect: (value: string) => void;\n label?: string;\n placeholder?: string;\n selectedValue?: string;\n size?: 'sm' | 'md' | 'lg';\n tooltipContent?: string;\n disabled?: boolean;\n viewMax?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;\n}\n\nexport interface DropdownOptionProps {\n value: string;\n label: string;\n isFocused?: boolean;\n size?: DropdownSelectorProps['size'];\n}\n\ninterface OptionData {\n value: string;\n label: string;\n}\n\nexport interface DropdownContextType {\n selectedOption: OptionData | null;\n setSelectedOption: (option: OptionData) => void;\n}\n\nconst SIZES = {\n sm: { caret: 16, check: 14, height: '2.625rem', top: 48, width: '0.75rem', mult: 2.25 },\n md: { caret: 17, check: 15, height: '2.8125rem', top: 52, width: '0.85rem', mult: 2.25 },\n lg: { caret: 18, check: 16, height: '3rem', top: 55, width: '1rem', mult: 2.5 },\n};\n\nconst DropdownContext = createContext<DropdownContextType>({\n selectedOption: null,\n setSelectedOption: () => {},\n});\n\nexport const DropdownOption = ({ value, label, size = 'lg', isFocused }: DropdownOptionProps) => {\n const { selectedOption, setSelectedOption } = useContext(DropdownContext);\n const isSelected = selectedOption?.value === value;\n const sizeProps = SIZES[size];\n\n const handleSelectOption = useCallback(() => {\n setSelectedOption({ value, label });\n }, [setSelectedOption, value, label]);\n\n return (\n <HStack\n py={1.5}\n gap={2}\n bg={isSelected ? 'brand.base' : isFocused ? 'brand.lightest' : ''}\n _hover={!isSelected ? { bg: 'brand.lightest' } : {}}\n onClick={handleSelectOption}\n style={{ paddingLeft: sizeProps.width, paddingRight: sizeProps.width }}\n >\n <Box style={{ width: sizeProps.width }}>\n {isSelected && (\n <IcoCheckmark width={sizeProps.check} height={sizeProps.check} color={token('colors.text.quaternary')} />\n )}\n </Box>\n <Text\n size={size}\n fontWeight=\"medium\"\n color={isSelected ? 'text.quaternary' : 'text.primary'}\n styles={{ textAlign: 'left' }}\n >\n {label}\n </Text>\n </HStack>\n );\n};\n\nexport const DropdownSelector = ({\n children,\n onSelect,\n label,\n placeholder = 'Select one',\n selectedValue,\n size = 'lg',\n tooltipContent,\n disabled,\n viewMax = 5,\n ...props\n}: DropdownSelectorProps) => {\n const [isOpen, setIsOpen] = useState(false);\n const [focusedIndex, setFocusedIndex] = useState<number | null>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const dropdownRef = useRef<HTMLDivElement>(null);\n const sizeProps = SIZES[size];\n const maxHeight = viewMax * sizeProps.mult + 1;\n\n const toggleDropdown = useCallback(() => {\n setIsOpen(prev => !prev);\n if (!isOpen) {\n setFocusedIndex(null);\n setTimeout(() => dropdownRef.current?.focus());\n }\n }, [isOpen]);\n\n const handleSelect = useCallback(\n (option: OptionData) => {\n onSelect(option.value);\n setIsOpen(false);\n },\n [onSelect],\n );\n\n const selectedLabel = useMemo(() => {\n const childElements = Children.toArray(children) as ReactElement<DropdownOptionProps>[];\n const matchedChild = childElements.find(child => child.props.value === selectedValue);\n return matchedChild ? matchedChild.props.label : placeholder;\n }, [selectedValue, children]);\n\n const { buttonProps } = useButton(\n {\n ...props,\n isDisabled: disabled,\n onPress: toggleDropdown,\n },\n buttonRef,\n );\n\n const { focusProps, isFocusVisible } = useFocusRing();\n\n const { keyboardProps } = useKeyboard({\n onKeyDown: event => {\n if (!isOpen) return;\n\n let newFocusedIndex = focusedIndex;\n const childArray = Children.toArray(children);\n\n switch (event.key) {\n case 'ArrowUp':\n event.preventDefault();\n if (focusedIndex === null) {\n setFocusedIndex(Children.count(children) - 1);\n } else {\n newFocusedIndex = focusedIndex > 0 ? focusedIndex - 1 : Children.count(children) - 1;\n setFocusedIndex(newFocusedIndex);\n }\n break;\n case 'ArrowDown':\n event.preventDefault();\n if (focusedIndex === null) {\n setFocusedIndex(0);\n } else {\n newFocusedIndex = focusedIndex < Children.count(children) - 1 ? focusedIndex + 1 : 0;\n setFocusedIndex(newFocusedIndex);\n }\n break;\n case 'Enter':\n event.preventDefault();\n buttonRef.current?.focus();\n if (focusedIndex === null) return;\n if (focusedIndex >= 0 && focusedIndex < childArray.length) {\n const selectedChild = childArray[focusedIndex] as ReactElement<DropdownOptionProps>;\n if (selectedChild) {\n onSelect(selectedChild.props.value);\n }\n }\n break;\n case 'Escape':\n setIsOpen(false);\n buttonRef.current?.focus();\n break;\n default:\n break;\n }\n },\n });\n\n useEffect(() => {\n const handleClick = (event: MouseEvent) => {\n if (!dropdownRef.current?.contains(event.target as Node)) {\n setIsOpen(false);\n }\n };\n\n document.addEventListener('mousedown', handleClick);\n\n return () => {\n document.removeEventListener('mousedown', handleClick);\n };\n }, []);\n\n return (\n <DropdownContext.Provider\n value={{ selectedOption: { value: selectedValue ?? '', label: selectedLabel }, setSelectedOption: handleSelect }}\n >\n <VStack gap={2} w=\"full\" alignItems=\"flex-start\">\n {(label || tooltipContent) && (\n <HStack gap={2} opacity={disabled ? 0.3 : ''} transition={'all linear 120ms'}>\n {label && (\n <Text size=\"sm\" fontWeight=\"medium\">\n {label}\n </Text>\n )}\n\n {tooltipContent && (\n <Tooltip isDisabled={disabled} content={tooltipContent}>\n <IcoQuestionCircleFill className={css({ w: 4, h: 4, color: 'neutral.primary' })} />\n </Tooltip>\n )}\n </HStack>\n )}\n\n <button\n className={css({\n w: 'full',\n h: 'fit-content',\n bg: 'surface.primary',\n borderWidth: 'thin',\n borderColor: 'neutral.secondary',\n rounded: 'xl',\n transition: 'all linear 120ms',\n position: 'relative',\n cursor: 'pointer',\n outlineColor: 'brand.base',\n outlineStyle: isFocusVisible ? 'solid' : 'none',\n outlineWidth: 'thick',\n outlineOffset: 0.5,\n _hover: { borderColor: 'neutral.primary' },\n _disabled: { opacity: 0.3, pointerEvents: 'none' },\n })}\n ref={buttonRef}\n {...mergeProps(buttonProps, focusProps, keyboardProps)}\n >\n <HStack w=\"full\" p={4} justifyContent=\"space-between\" style={{ height: sizeProps.height }}>\n <Text size={size} color={selectedValue ? 'text.primary' : 'text.tertiary'}>\n {selectedLabel}\n </Text>\n {isOpen ? (\n <IcoCaretUp width={sizeProps.caret} height={sizeProps.caret} color={token('colors.brand.base')} />\n ) : (\n <IcoCaretDown width={sizeProps.caret} height={sizeProps.caret} color={token('colors.brand.base')} />\n )}\n </HStack>\n\n {isOpen && (\n <Box\n ref={dropdownRef}\n tabIndex={-1}\n py={2}\n bg=\"surface.primary\"\n position=\"absolute\"\n w=\"full\"\n rounded=\"input\"\n boxShadow=\"4px 8px 20px 0px rgba(0, 0, 0, 0.15)\"\n style={{ maxHeight: `${maxHeight}rem`, top: sizeProps.top }}\n overflowY=\"auto\"\n outline=\"none\"\n zIndex=\"max\"\n >\n {Children.map(children, (child, index) =>\n cloneElement(child as ReactElement<DropdownOptionProps>, {\n isFocused: index === focusedIndex,\n size,\n }),\n )}\n </Box>\n )}\n </button>\n </VStack>\n </DropdownContext.Provider>\n );\n};\n\nDropdownOption.displayName = 'DropdownOption';\nDropdownSelector.displayName = 'DropdownSelector';\n"],"names":["SIZES","DropdownContext","createContext","DropdownOption","value","label","size","isFocused","selectedOption","setSelectedOption","useContext","isSelected","sizeProps","handleSelectOption","useCallback","_jsxs","HStack","_jsx","Box","IcoCheckmark","token","Text","DropdownSelector","children","onSelect","placeholder","selectedValue","tooltipContent","disabled","viewMax","props","isOpen","setIsOpen","useState","focusedIndex","setFocusedIndex","buttonRef","useRef","dropdownRef","maxHeight","toggleDropdown","prev","_a","handleSelect","option","selectedLabel","useMemo","matchedChild","Children","child","buttonProps","useButton","focusProps","isFocusVisible","useFocusRing","keyboardProps","useKeyboard","event","newFocusedIndex","childArray","selectedChild","_b","useEffect","handleClick","VStack","Tooltip","IcoQuestionCircleFill","css","mergeProps","IcoCaretUp","IcoCaretDown","index","cloneElement"],"mappings":"47BAkDA,MAAMA,EAAQ,CACZ,GAAI,CAAE,MAAO,GAAI,MAAO,GAAI,OAAQ,WAAY,IAAK,GAAI,MAAO,UAAW,KAAM,IAAM,EACvF,GAAI,CAAE,MAAO,GAAI,MAAO,GAAI,OAAQ,YAAa,IAAK,GAAI,MAAO,UAAW,KAAM,IAAM,EACxF,GAAI,C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EAEAH,EAAe,YAAc,iBAC7BmB,EAAiB,YAAc"}
1
+ {"version":3,"file":"dropdown-selector.js","sources":["../../../../src/components/primitives/dropdown-selector.tsx"],"sourcesContent":["import { Tooltip } from '@components/feedback';\nimport { IcoCaretDown, IcoCaretUp, IcoCheckmark, IcoQuestionCircleFill } from '@components/icons';\nimport { Text } from '@components/primitives';\nimport { css } from '@styled/css';\nimport { Box, HStack, VStack } from '@styled/jsx';\nimport { token } from '@styled/tokens';\nimport {\n Children,\n cloneElement,\n createContext,\n ReactElement,\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { AriaButtonProps, mergeProps, useButton, useFocusRing, useKeyboard } from 'react-aria';\n\nexport interface DropdownSelectorProps extends AriaButtonProps {\n children: ReactNode;\n onSelect: (value: string) => void;\n label?: string;\n placeholder?: string;\n selectedValue?: string;\n size?: 'sm' | 'md' | 'lg';\n tooltipContent?: string;\n disabled?: boolean;\n viewMax?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;\n}\n\nexport interface DropdownOptionProps {\n value: string;\n label: string;\n isFocused?: boolean;\n size?: DropdownSelectorProps['size'];\n}\n\ninterface OptionData {\n value: string;\n label: string;\n}\n\nexport interface DropdownContextType {\n selectedOption: OptionData | null;\n setSelectedOption: (option: OptionData) => void;\n}\n\nconst SIZES = {\n sm: { caret: 16, check: 14, height: '2.625rem', top: 48, width: '0.75rem', mult: 2.25 },\n md: { caret: 17, check: 15, height: '2.8125rem', top: 52, width: '0.85rem', mult: 2.25 },\n lg: { caret: 18, check: 16, height: '3rem', top: 55, width: '1rem', mult: 2.5 },\n};\n\nconst DropdownContext = createContext<DropdownContextType>({\n selectedOption: null,\n setSelectedOption: () => {},\n});\n\nexport const DropdownOption = ({ value, label, size = 'lg', isFocused }: DropdownOptionProps) => {\n const { selectedOption, setSelectedOption } = useContext(DropdownContext);\n const isSelected = selectedOption?.value === value;\n const sizeProps = SIZES[size];\n\n const handleSelectOption = useCallback(() => {\n setSelectedOption({ value, label });\n }, [setSelectedOption, value, label]);\n\n return (\n <HStack\n py={1.5}\n gap={2}\n bg={isSelected ? 'brand.base' : isFocused ? 'brand.lightest' : ''}\n _hover={!isSelected ? { bg: 'brand.lightest' } : {}}\n onClick={handleSelectOption}\n style={{ paddingLeft: sizeProps.width, paddingRight: sizeProps.width }}\n >\n <Box style={{ width: sizeProps.width }}>\n {isSelected && (\n <IcoCheckmark width={sizeProps.check} height={sizeProps.check} color={token('colors.text.quaternary')} />\n )}\n </Box>\n <Text\n size={size}\n fontWeight=\"medium\"\n fontColor={isSelected ? 'text.quaternary' : 'text.primary'}\n styles={{ textAlign: 'left' }}\n >\n {label}\n </Text>\n </HStack>\n );\n};\n\nexport const DropdownSelector = ({\n children,\n onSelect,\n label,\n placeholder = 'Select one',\n selectedValue,\n size = 'lg',\n tooltipContent,\n disabled,\n viewMax = 5,\n ...props\n}: DropdownSelectorProps) => {\n const [isOpen, setIsOpen] = useState(false);\n const [focusedIndex, setFocusedIndex] = useState<number | null>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const dropdownRef = useRef<HTMLDivElement>(null);\n const sizeProps = SIZES[size];\n const maxHeight = viewMax * sizeProps.mult + 1;\n\n const toggleDropdown = useCallback(() => {\n setIsOpen(prev => !prev);\n if (!isOpen) {\n setFocusedIndex(null);\n setTimeout(() => dropdownRef.current?.focus());\n }\n }, [isOpen]);\n\n const handleSelect = useCallback(\n (option: OptionData) => {\n onSelect(option.value);\n setIsOpen(false);\n },\n [onSelect],\n );\n\n const selectedLabel = useMemo(() => {\n const childElements = Children.toArray(children) as ReactElement<DropdownOptionProps>[];\n const matchedChild = childElements.find(child => child.props.value === selectedValue);\n return matchedChild ? matchedChild.props.label : placeholder;\n }, [selectedValue, children]);\n\n const { buttonProps } = useButton(\n {\n ...props,\n isDisabled: disabled,\n onPress: toggleDropdown,\n },\n buttonRef,\n );\n\n const { focusProps, isFocusVisible } = useFocusRing();\n\n const { keyboardProps } = useKeyboard({\n onKeyDown: event => {\n if (!isOpen) return;\n\n let newFocusedIndex = focusedIndex;\n const childArray = Children.toArray(children);\n\n switch (event.key) {\n case 'ArrowUp':\n event.preventDefault();\n if (focusedIndex === null) {\n setFocusedIndex(Children.count(children) - 1);\n } else {\n newFocusedIndex = focusedIndex > 0 ? focusedIndex - 1 : Children.count(children) - 1;\n setFocusedIndex(newFocusedIndex);\n }\n break;\n case 'ArrowDown':\n event.preventDefault();\n if (focusedIndex === null) {\n setFocusedIndex(0);\n } else {\n newFocusedIndex = focusedIndex < Children.count(children) - 1 ? focusedIndex + 1 : 0;\n setFocusedIndex(newFocusedIndex);\n }\n break;\n case 'Enter':\n event.preventDefault();\n buttonRef.current?.focus();\n if (focusedIndex === null) return;\n if (focusedIndex >= 0 && focusedIndex < childArray.length) {\n const selectedChild = childArray[focusedIndex] as ReactElement<DropdownOptionProps>;\n if (selectedChild) {\n onSelect(selectedChild.props.value);\n }\n }\n break;\n case 'Escape':\n setIsOpen(false);\n buttonRef.current?.focus();\n break;\n default:\n break;\n }\n },\n });\n\n useEffect(() => {\n const handleClick = (event: MouseEvent) => {\n if (!dropdownRef.current?.contains(event.target as Node)) {\n setIsOpen(false);\n }\n };\n\n document.addEventListener('mousedown', handleClick);\n\n return () => {\n document.removeEventListener('mousedown', handleClick);\n };\n }, []);\n\n return (\n <DropdownContext.Provider\n value={{ selectedOption: { value: selectedValue ?? '', label: selectedLabel }, setSelectedOption: handleSelect }}\n >\n <VStack gap={2} w=\"full\" alignItems=\"flex-start\">\n {(label || tooltipContent) && (\n <HStack gap={2} opacity={disabled ? 0.3 : ''} transition={'all linear 120ms'}>\n {label && (\n <Text size=\"sm\" fontWeight=\"medium\">\n {label}\n </Text>\n )}\n\n {tooltipContent && (\n <Tooltip isDisabled={disabled} content={tooltipContent}>\n <IcoQuestionCircleFill className={css({ w: 4, h: 4, color: 'neutral.primary' })} />\n </Tooltip>\n )}\n </HStack>\n )}\n\n <button\n className={css({\n w: 'full',\n h: 'fit-content',\n bg: 'surface.primary',\n borderWidth: 'thin',\n borderColor: 'neutral.secondary',\n rounded: 'xl',\n transition: 'all linear 120ms',\n position: 'relative',\n cursor: 'pointer',\n outlineColor: 'brand.base',\n outlineStyle: isFocusVisible ? 'solid' : 'none',\n outlineWidth: 'thick',\n outlineOffset: 0.5,\n _hover: { borderColor: 'neutral.primary' },\n _disabled: { opacity: 0.3, pointerEvents: 'none' },\n })}\n ref={buttonRef}\n {...mergeProps(buttonProps, focusProps, keyboardProps)}\n >\n <HStack w=\"full\" p={4} justifyContent=\"space-between\" style={{ height: sizeProps.height }}>\n <Text size={size} fontColor={selectedValue ? 'text.primary' : 'text.tertiary'}>\n {selectedLabel}\n </Text>\n {isOpen ? (\n <IcoCaretUp width={sizeProps.caret} height={sizeProps.caret} color={token('colors.brand.base')} />\n ) : (\n <IcoCaretDown width={sizeProps.caret} height={sizeProps.caret} color={token('colors.brand.base')} />\n )}\n </HStack>\n\n {isOpen && (\n <Box\n ref={dropdownRef}\n tabIndex={-1}\n py={2}\n bg=\"surface.primary\"\n position=\"absolute\"\n w=\"full\"\n rounded=\"input\"\n boxShadow=\"4px 8px 20px 0px rgba(0, 0, 0, 0.15)\"\n style={{ maxHeight: `${maxHeight}rem`, top: sizeProps.top }}\n overflowY=\"auto\"\n outline=\"none\"\n zIndex=\"max\"\n >\n {Children.map(children, (child, index) =>\n cloneElement(child as ReactElement<DropdownOptionProps>, {\n isFocused: index === focusedIndex,\n size,\n }),\n )}\n </Box>\n )}\n </button>\n </VStack>\n </DropdownContext.Provider>\n );\n};\n\nDropdownOption.displayName = 'DropdownOption';\nDropdownSelector.displayName = 'DropdownSelector';\n"],"names":["SIZES","DropdownContext","createContext","DropdownOption","value","label","size","isFocused","selectedOption","setSelectedOption","useContext","isSelected","sizeProps","handleSelectOption","useCallback","_jsxs","HStack","_jsx","Box","IcoCheckmark","token","Text","DropdownSelector","children","onSelect","placeholder","selectedValue","tooltipContent","disabled","viewMax","props","isOpen","setIsOpen","useState","focusedIndex","setFocusedIndex","buttonRef","useRef","dropdownRef","maxHeight","toggleDropdown","prev","_a","handleSelect","option","selectedLabel","useMemo","matchedChild","Children","child","buttonProps","useButton","focusProps","isFocusVisible","useFocusRing","keyboardProps","useKeyboard","event","newFocusedIndex","childArray","selectedChild","_b","useEffect","handleClick","VStack","Tooltip","IcoQuestionCircleFill","css","mergeProps","IcoCaretUp","IcoCaretDown","index","cloneElement"],"mappings":"47BAkDA,MAAMA,EAAQ,CACZ,GAAI,CAAE,MAAO,GAAI,MAAO,GAAI,OAAQ,WAAY,IAAK,GAAI,MAAO,UAAW,KAAM,IAAM,EACvF,GAAI,CAAE,MAAO,GAAI,MAAO,GAAI,OAAQ,YAAa,IAAK,GAAI,MAAO,UAAW,KAAM,IAAM,EACxF,GAAI,CAAE,MAAO,GAAI,MAAO,GAAI,OAAQ,OAAQ,IAAK,GAAI,MAAO,OAAQ,KAAM,GAAK,GAG3EC,EAAkBC,EAAmC,CACzD,eAAgB,KAChB,kBAAmB,IAAK,CACzB,CAAA,CAAA,EAEYC,EAAiB,CAAC,CAAE,MAAAC,EAAO,MAAAC,EAAO,KAAAC,EAAO,KAAM,UAAAC,CAAS,IAA2B,CAC9F,KAAM,CAAE,eAAAC,EAAgB,kBAAAC,CAAiB,EAAKC,EAAWT,CAAe,EAClEU,EAAaH,GAAgB,QAAUJ,EACvCQ,EAAYZ,EAAMM,CAAI,EAEtBO,EAAqBC,EAAY,IAAK,CAC1CL,EAAkB,CAAE,MAAAL,EAAO,MAAAC,CAAK,CAAE,CACpC,EAAG,CAACI,EAAmBL,EAAOC,CAAK,CAAC,EAEpC,OACEU,EAACC,EAAM,CACL,GAAI,IACJ,IAAK,EACL,GAAIL,EAAa,aAAeJ,EAAY,iBAAmB,GAC/D,OAASI,EAAwC,CAAA,EAA3B,CAAE,GAAI,gBAAgB,EAC5C,QAASE,EACT,MAAO,CAAE,YAAaD,EAAU,MAAO,aAAcA,EAAU,KAA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B,IAE7FH,EAACqD,EAAY,CAAC,MAAO1D,EAAU,MAAO,OAAQA,EAAU,MAAO,MAAOQ,EAAM,mBAAmB,CAAC,CAAA,CACjG,CACM,CAAA,EAERW,GACCd,EAACC,EACC,CAAA,IAAKoB,EACL,SAAU,GACV,GAAI,EACJ,GAAG,kBACH,SAAS,WACT,EAAE,OACF,QAAQ,QACR,UAAU,uCACV,MAAO,CAAE,UAAW,GAAGC,CAAS,MAAO,IAAK3B,EAAU,GAAK,EAC3D,UAAU,OACV,QAAQ,OACR,OAAO,MAEN,SAAAoC,EAAS,IAAIzB,EAAU,CAAC0B,EAAOsB,IAC9BC,GAAavB,EAA4C,CACvD,UAAWsB,IAAUrC,EACrB,KAAA5B,CACD,CAAA,CAAC,CAEA,CAAA,CACP,GACM,CACF,CAAA,CAAA,CAAA,CAGf,EAEAH,EAAe,YAAc,iBAC7BmB,EAAiB,YAAc"}
@@ -1,2 +1,2 @@
1
- import{jsx as r}from"react/jsx-runtime";import{text as v}from"../../recipes/text.js";import{css as i,cx as z}from"@styled/css";import{forwardRef as o}from"react";const h="text.primary",m=o(({children:e,styles:l={},scale:s,color:a=h,...c},t)=>r("h1",{ref:t,className:i({textStyle:s?"h1-scaled":"h1",color:a,...c}),style:l,children:e})),y=o(({children:e,styles:l={},scale:s,color:a=h,...c},t)=>r("h2",{ref:t,className:i({textStyle:s?"h2-scaled":"h2",color:a,...c}),style:l,children:e})),x=o(({children:e,styles:l={},scale:s,color:a=h,...c},t)=>r("h3",{ref:t,className:i({textStyle:s?"h3-scaled":"h3",color:a,...c}),style:l,children:e})),f=o(({children:e,styles:l={},scale:s,color:a=h,...c},t)=>r("h4",{ref:t,className:i({textStyle:s?"h4-scaled":"h4",color:a,...c}),style:l,children:e})),p=o(({children:e,styles:l={},scale:s,color:a=h,...c},t)=>r("h5",{ref:t,className:i({textStyle:s?"h5-scaled":"h5",color:a,...c}),style:l,children:e})),N=o(({children:e,styles:l={},scale:s,color:a="text.secondary",...c},t)=>r("h6",{ref:t,className:i({textStyle:s?"h6-scaled":"h6",color:a,...c}),style:l,children:e})),n=o(({children:e,styles:l={},scale:s,inline:a=!1,mono:c=!1,variant:t="text",size:T="md",truncate:S=!1,fontWeight:u,...g},b)=>{const j=v({mono:c,variant:t,size:T,scale:s}),d={ref:b,className:z(j,i({truncate:S,fontWeight:u??(t!=="text"?"medium":"normal"),...g})),style:l};return a?r("span",{...d,children:e}):r("p",{...d,children:e})}),H=o((e,l)=>r(n,{ref:l,mono:!0,...e})),M=Object.assign(n,{H1:m,H2:y,H3:x,H4:f,H5:p,H6:N,Mono:H});n.displayName="Text",m.displayName="Text.H1",y.displayName="Text.H2",x.displayName="Text.H3",f.displayName="Text.H4",p.displayName="Text.H5",N.displayName="Text.H6",H.displayName="Text.Mono";export{M as default};
1
+ import{jsx as r}from"react/jsx-runtime";import{text as v}from"../../recipes/text.js";import{css as n,cx as z}from"@styled/css";import{forwardRef as c}from"react";const i="text.primary",m=c(({children:e,styles:l={},scale:s,fontColor:o=i,...a},t)=>r("h1",{ref:t,className:n({textStyle:s?"h1-scaled":"h1",color:o,...a}),style:l,children:e})),y=c(({children:e,styles:l={},scale:s,fontColor:o=i,...a},t)=>r("h2",{ref:t,className:n({textStyle:s?"h2-scaled":"h2",color:o,...a}),style:l,children:e})),f=c(({children:e,styles:l={},scale:s,fontColor:o=i,...a},t)=>r("h3",{ref:t,className:n({textStyle:s?"h3-scaled":"h3",color:o,...a}),style:l,children:e})),x=c(({children:e,styles:l={},scale:s,fontColor:o=i,...a},t)=>r("h4",{ref:t,className:n({textStyle:s?"h4-scaled":"h4",color:o,...a}),style:l,children:e})),p=c(({children:e,styles:l={},scale:s,fontColor:o=i,...a},t)=>r("h5",{ref:t,className:n({textStyle:s?"h5-scaled":"h5",color:o,...a}),style:l,children:e})),N=c(({children:e,styles:l={},scale:s,fontColor:o="text.secondary",...a},t)=>r("h6",{ref:t,className:n({textStyle:s?"h6-scaled":"h6",color:o,...a}),style:l,children:e})),h=c(({children:e,styles:l={},scale:s,inline:o=!1,mono:a=!1,variant:t="text",size:T="md",truncate:C=!1,fontWeight:S,fontColor:u,...g},b)=>{const j=v({mono:a,variant:t,size:T,scale:s}),d={ref:b,className:z(j,n({truncate:C,fontWeight:S??(t!=="text"?"medium":"normal"),color:u,...g})),style:l};return o?r("span",{...d,children:e}):r("p",{...d,children:e})}),H=c((e,l)=>r(h,{ref:l,mono:!0,...e})),M=Object.assign(h,{H1:m,H2:y,H3:f,H4:x,H5:p,H6:N,Mono:H});h.displayName="Text",m.displayName="Text.H1",y.displayName="Text.H2",f.displayName="Text.H3",x.displayName="Text.H4",p.displayName="Text.H5",N.displayName="Text.H6",H.displayName="Text.Mono";export{M as default};
2
2
  //# sourceMappingURL=text.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"text.js","sources":["../../../../src/components/primitives/text.tsx"],"sourcesContent":["import { text } from '@recipes/text';\nimport { css, cx } from '@styled/css';\nimport { CSSProperties, PropsWithChildren, forwardRef } from 'react';\n\nexport type TextStyles = {\n color?: CSSProperties['color'];\n fontWeight?: CSSProperties['fontWeight'];\n fontSize?: CSSProperties['fontSize'];\n lineHeight?: CSSProperties['lineHeight'];\n letterSpacing?: CSSProperties['letterSpacing'];\n textAlign?: CSSProperties['textAlign'];\n textDecoration?: CSSProperties['textDecoration'];\n textTransform?: CSSProperties['textTransform'];\n textWrap?: CSSProperties['textWrap'];\n maxWidth?: CSSProperties['maxWidth'];\n};\n\nexport interface TextProps extends PropsWithChildren {\n styles?: TextStyles;\n scale?: boolean;\n fontWeight?: 'normal' | 'medium' | 'semibold' | 'bold' | 'extrabold';\n color?: 'text.primary' | 'text.secondary' | 'text.tertiary' | 'text.quaternary';\n}\n\nexport interface BodyProps extends TextProps {\n inline?: boolean;\n mono?: boolean;\n variant?: 'text' | 'error' | 'info' | 'success' | 'warning';\n size?: 'xs' | 'sm' | 'md' | 'lg';\n truncate?: boolean;\n}\n\nconst defaultColor = 'text.primary';\n\nconst TextH1 = forwardRef<HTMLHeadingElement, TextProps>(\n ({ children, styles = {}, scale, color = defaultColor, ...props }, ref) => (\n <h1 ref={ref} className={css({ textStyle: scale ? 'h1-scaled' : 'h1', color, ...props })} style={styles}>\n {children}\n </h1>\n ),\n);\n\nconst TextH2 = forwardRef<HTMLHeadingElement, TextProps>(\n ({ children, styles = {}, scale, color = defaultColor, ...props }, ref) => (\n <h2 ref={ref} className={css({ textStyle: scale ? 'h2-scaled' : 'h2', color, ...props })} style={styles}>\n {children}\n </h2>\n ),\n);\n\nconst TextH3 = forwardRef<HTMLHeadingElement, TextProps>(\n ({ children, styles = {}, scale, color = defaultColor, ...props }, ref) => (\n <h3 ref={ref} className={css({ textStyle: scale ? 'h3-scaled' : 'h3', color, ...props })} style={styles}>\n {children}\n </h3>\n ),\n);\n\nconst TextH4 = forwardRef<HTMLHeadingElement, TextProps>(\n ({ children, styles = {}, scale, color = defaultColor, ...props }, ref) => (\n <h4 ref={ref} className={css({ textStyle: scale ? 'h4-scaled' : 'h4', color, ...props })} style={styles}>\n {children}\n </h4>\n ),\n);\n\nconst TextH5 = forwardRef<HTMLHeadingElement, TextProps>(\n ({ children, styles = {}, scale, color = defaultColor, ...props }, ref) => (\n <h5 ref={ref} className={css({ textStyle: scale ? 'h5-scaled' : 'h5', color, ...props })} style={styles}>\n {children}\n </h5>\n ),\n);\n\nconst TextH6 = forwardRef<HTMLHeadingElement, TextProps>(\n ({ children, styles = {}, scale, color = 'text.secondary', ...props }, ref) => (\n <h6 ref={ref} className={css({ textStyle: scale ? 'h6-scaled' : 'h6', color, ...props })} style={styles}>\n {children}\n </h6>\n ),\n);\n\nconst Body = forwardRef<HTMLParagraphElement, BodyProps>(\n (\n {\n children,\n styles = {},\n scale,\n inline = false,\n mono = false,\n variant = 'text',\n size = 'md',\n truncate = false,\n fontWeight,\n ...props\n },\n ref,\n ) => {\n const classStyles = text({ mono, variant, size, scale });\n const fontWeightStyle = fontWeight ?? (variant !== 'text' ? 'medium' : 'normal');\n const bodyProps = {\n ref,\n className: cx(classStyles, css({ truncate, fontWeight: fontWeightStyle, ...props })),\n style: styles,\n };\n\n if (inline) {\n return <span {...bodyProps}>{children}</span>;\n }\n\n return <p {...bodyProps}>{children}</p>;\n },\n);\n\nconst TextMono = forwardRef<HTMLParagraphElement, BodyProps>((props, ref) => {\n return <Body ref={ref} mono {...props} />;\n});\n\nconst Text = Object.assign(Body, {\n H1: TextH1,\n H2: TextH2,\n H3: TextH3,\n H4: TextH4,\n H5: TextH5,\n H6: TextH6,\n Mono: TextMono,\n});\n\nBody.displayName = 'Text';\nTextH1.displayName = 'Text.H1';\nTextH2.displayName = 'Text.H2';\nTextH3.displayName = 'Text.H3';\nTextH4.displayName = 'Text.H4';\nTextH5.displayName = 'Text.H5';\nTextH6.displayName = 'Text.H6';\nTextMono.displayName = 'Text.Mono';\n\nexport default Text;\n"],"names":["defaultColor","TextH1","forwardRef","children","styles","scale","color","props","ref","_jsx","css","TextH2","TextH3","TextH4","TextH5","TextH6","Body","inline","mono","variant","size","truncate","fontWeight","classStyles","text","bodyProps","cx","TextMono","Text"],"mappings":"kKAgCA,MAAMA,EAAe,eAEfC,EAASC,EACb,CAAC,CAAE,SAAAC,EAAU,OAAAC,EAAS,CAAE,EAAE,MAAAC,EAAO,MAAAC,EAAQN,EAAc,GAAGO,CAAK,EAAIC,IACjEC,EAAI,KAAA,CAAA,IAAKD,EAAK,UAAWE,EAAI,CAAE,UAAWL,EAAQ,YAAc,KAAM,MAAAC,EAAO,GAAGC,CAAO,CAAA,EAAG,MAAOH,EAC9F,SAAAD,CACE,CAAA,CACN,EAGGQ,EAAST,EACb,CAAC,CAAE,SAAAC,EAAU,OAAAC,EAAS,CAAE,EAAE,MAAAC,EAAO,MAAAC,EAAQN,EAAc,GAAGO,CAAK,EAAIC,IACjEC,EAAI,KAAA,CAAA,IAAKD,EAAK,UAAWE,EAAI,CAAE,UAAWL,EAAQ,YAAc,KAAM,MAAAC,EAAO,GAAGC,CAAO,CAAA,EAAG,M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ACA,OAAAY,EAAS,GACT,KAAAC,EAAO,GACP,QAAAC,EAAU,OACV,KAAAC,EAAO,KACP,SAAAC,EAAW,GACX,WAAAC,EACA,GAAGf,GAELC,IACE,CACF,MAAMe,EAAcC,EAAK,CAAE,KAAAN,EAAM,QAAAC,EAAS,KAAAC,EAAM,MAAAf,CAAK,CAAE,EAEjDoB,EAAY,CAChB,IAAAjB,EACA,UAAWkB,EAAGH,EAAab,EAAI,CAAE,SAAAW,EAAU,WAHrBC,IAAeH,IAAY,OAAS,SAAW,UAGG,GAAGZ,CAAK,CAAE,CAAC,EACnF,MAAOH,GAGT,OAAIa,EACKR,EAAU,OAAA,CAAA,GAAAgB,EAAY,SAAAtB,IAGxBM,EAAO,IAAA,CAAA,GAAAgB,EAAY,SAAAtB,GAC5B,CAAC,EAGGwB,EAAWzB,EAA4C,CAACK,EAAOC,IAC5DC,EAACO,EAAI,CAAC,IAAKR,EAAK,KAAI,GAAA,GAAKD,CAAK,CAAA,CACtC,EAEKqB,EAAO,OAAO,OAAOZ,EAAM,CAC/B,GAAIf,EACJ,GAAIU,EACJ,GAAIC,EACJ,GAAIC,EACJ,GAAIC,EACJ,GAAIC,EACJ,KAAMY,CACP,CAAA,EAEDX,EAAK,YAAc,OACnBf,EAAO,YAAc,UACrBU,EAAO,YAAc,UACrBC,EAAO,YAAc,UACrBC,EAAO,YAAc,UACrBC,EAAO,YAAc,UACrBC,EAAO,YAAc,UACrBY,EAAS,YAAc"}
1
+ {"version":3,"file":"text.js","sources":["../../../../src/components/primitives/text.tsx"],"sourcesContent":["import { text } from '@recipes/text';\nimport { css, cx } from '@styled/css';\nimport { CSSProperties, PropsWithChildren, forwardRef } from 'react';\n\nexport type TextStyles = {\n color?: CSSProperties['color'];\n fontWeight?: CSSProperties['fontWeight'];\n fontSize?: CSSProperties['fontSize'];\n lineHeight?: CSSProperties['lineHeight'];\n letterSpacing?: CSSProperties['letterSpacing'];\n textAlign?: CSSProperties['textAlign'];\n textDecoration?: CSSProperties['textDecoration'];\n textTransform?: CSSProperties['textTransform'];\n textWrap?: CSSProperties['textWrap'];\n maxWidth?: CSSProperties['maxWidth'];\n};\n\nexport interface TextProps extends PropsWithChildren {\n styles?: TextStyles;\n scale?: boolean;\n fontWeight?: 'normal' | 'medium' | 'semibold' | 'bold' | 'extrabold';\n fontColor?: 'text.primary' | 'text.secondary' | 'text.tertiary' | 'text.quaternary';\n}\n\nexport interface BodyProps extends TextProps {\n inline?: boolean;\n mono?: boolean;\n variant?: 'text' | 'error' | 'info' | 'success' | 'warning';\n size?: 'xs' | 'sm' | 'md' | 'lg';\n truncate?: boolean;\n}\n\nconst defaultColor = 'text.primary';\n\nconst TextH1 = forwardRef<HTMLHeadingElement, TextProps>(\n ({ children, styles = {}, scale, fontColor: color = defaultColor, ...props }, ref) => (\n <h1 ref={ref} className={css({ textStyle: scale ? 'h1-scaled' : 'h1', color, ...props })} style={styles}>\n {children}\n </h1>\n ),\n);\n\nconst TextH2 = forwardRef<HTMLHeadingElement, TextProps>(\n ({ children, styles = {}, scale, fontColor: color = defaultColor, ...props }, ref) => (\n <h2 ref={ref} className={css({ textStyle: scale ? 'h2-scaled' : 'h2', color, ...props })} style={styles}>\n {children}\n </h2>\n ),\n);\n\nconst TextH3 = forwardRef<HTMLHeadingElement, TextProps>(\n ({ children, styles = {}, scale, fontColor: color = defaultColor, ...props }, ref) => (\n <h3 ref={ref} className={css({ textStyle: scale ? 'h3-scaled' : 'h3', color, ...props })} style={styles}>\n {children}\n </h3>\n ),\n);\n\nconst TextH4 = forwardRef<HTMLHeadingElement, TextProps>(\n ({ children, styles = {}, scale, fontColor: color = defaultColor, ...props }, ref) => (\n <h4 ref={ref} className={css({ textStyle: scale ? 'h4-scaled' : 'h4', color, ...props })} style={styles}>\n {children}\n </h4>\n ),\n);\n\nconst TextH5 = forwardRef<HTMLHeadingElement, TextProps>(\n ({ children, styles = {}, scale, fontColor: color = defaultColor, ...props }, ref) => (\n <h5 ref={ref} className={css({ textStyle: scale ? 'h5-scaled' : 'h5', color, ...props })} style={styles}>\n {children}\n </h5>\n ),\n);\n\nconst TextH6 = forwardRef<HTMLHeadingElement, TextProps>(\n ({ children, styles = {}, scale, fontColor: color = 'text.secondary', ...props }, ref) => (\n <h6 ref={ref} className={css({ textStyle: scale ? 'h6-scaled' : 'h6', color, ...props })} style={styles}>\n {children}\n </h6>\n ),\n);\n\nconst Body = forwardRef<HTMLParagraphElement, BodyProps>(\n (\n {\n children,\n styles = {},\n scale,\n inline = false,\n mono = false,\n variant = 'text',\n size = 'md',\n truncate = false,\n fontWeight,\n fontColor: color,\n ...props\n },\n ref,\n ) => {\n const classStyles = text({ mono, variant, size, scale });\n const fontWeightStyle = fontWeight ?? (variant !== 'text' ? 'medium' : 'normal');\n const bodyProps = {\n ref,\n className: cx(classStyles, css({ truncate, fontWeight: fontWeightStyle, color, ...props })),\n style: styles,\n };\n\n if (inline) {\n return <span {...bodyProps}>{children}</span>;\n }\n\n return <p {...bodyProps}>{children}</p>;\n },\n);\n\nconst TextMono = forwardRef<HTMLParagraphElement, BodyProps>((props, ref) => {\n return <Body ref={ref} mono {...props} />;\n});\n\nconst Text = Object.assign(Body, {\n H1: TextH1,\n H2: TextH2,\n H3: TextH3,\n H4: TextH4,\n H5: TextH5,\n H6: TextH6,\n Mono: TextMono,\n});\n\nBody.displayName = 'Text';\nTextH1.displayName = 'Text.H1';\nTextH2.displayName = 'Text.H2';\nTextH3.displayName = 'Text.H3';\nTextH4.displayName = 'Text.H4';\nTextH5.displayName = 'Text.H5';\nTextH6.displayName = 'Text.H6';\nTextMono.displayName = 'Text.Mono';\n\nexport default Text;\n"],"names":["defaultColor","TextH1","forwardRef","children","styles","scale","color","props","ref","_jsx","css","TextH2","TextH3","TextH4","TextH5","TextH6","Body","inline","mono","variant","size","truncate","fontWeight","classStyles","text","bodyProps","cx","TextMono","Text"],"mappings":"kKAgCMA,MAAAA,EAAe,eAEfC,EAASC,EACb,CAAC,CAAE,SAAAC,EAAU,OAAAC,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