@travel-match/ui 0.4.0 → 0.5.0

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 (141) hide show
  1. package/dist/components/AccountMenu/AccountMenu.cjs +1 -1
  2. package/dist/components/AccountMenu/AccountMenu.cjs.map +1 -1
  3. package/dist/components/AccountMenu/AccountMenu.js +1 -1
  4. package/dist/components/AccountMenu/AccountMenu.js.map +1 -1
  5. package/dist/components/ConfirmationDialog/ConfirmationDialog.cjs +1 -1
  6. package/dist/components/ConfirmationDialog/ConfirmationDialog.cjs.map +1 -1
  7. package/dist/components/ConfirmationDialog/ConfirmationDialog.js +1 -0
  8. package/dist/components/ConfirmationDialog/ConfirmationDialog.js.map +1 -1
  9. package/dist/components/CtaRequestFlow/CtaRequestFlow.cjs +1 -1
  10. package/dist/components/CtaRequestFlow/CtaRequestFlow.cjs.map +1 -1
  11. package/dist/components/CtaRequestFlow/CtaRequestFlow.js +72 -37
  12. package/dist/components/CtaRequestFlow/CtaRequestFlow.js.map +1 -1
  13. package/dist/components/ExampleRequests/ExampleRequests.cjs +1 -1
  14. package/dist/components/ExampleRequests/ExampleRequests.cjs.map +1 -1
  15. package/dist/components/ExampleRequests/ExampleRequests.js +18 -17
  16. package/dist/components/ExampleRequests/ExampleRequests.js.map +1 -1
  17. package/dist/components/FaqItem/FaqItem.cjs +1 -1
  18. package/dist/components/FaqItem/FaqItem.cjs.map +1 -1
  19. package/dist/components/FaqItem/FaqItem.js +79 -34
  20. package/dist/components/FaqItem/FaqItem.js.map +1 -1
  21. package/dist/components/Field/Field.cjs +1 -1
  22. package/dist/components/Field/Field.cjs.map +1 -1
  23. package/dist/components/Field/Field.js +10 -8
  24. package/dist/components/Field/Field.js.map +1 -1
  25. package/dist/components/InlineAlert/InlineAlert.cjs +1 -1
  26. package/dist/components/InlineAlert/InlineAlert.cjs.map +1 -1
  27. package/dist/components/InlineAlert/InlineAlert.js +9 -8
  28. package/dist/components/InlineAlert/InlineAlert.js.map +1 -1
  29. package/dist/components/NewRequestOverlay/NewRequestOverlay.cjs +1 -1
  30. package/dist/components/NewRequestOverlay/NewRequestOverlay.cjs.map +1 -1
  31. package/dist/components/NewRequestOverlay/NewRequestOverlay.js +67 -48
  32. package/dist/components/NewRequestOverlay/NewRequestOverlay.js.map +1 -1
  33. package/dist/components/NotificationsDropdown/NotificationsMenu.cjs +1 -1
  34. package/dist/components/NotificationsDropdown/NotificationsMenu.cjs.map +1 -1
  35. package/dist/components/NotificationsDropdown/NotificationsMenu.js +1 -1
  36. package/dist/components/NotificationsDropdown/NotificationsMenu.js.map +1 -1
  37. package/dist/components/PartnerCarousel/PartnerCarousel.cjs.map +1 -1
  38. package/dist/components/PartnerCarousel/PartnerCarousel.js.map +1 -1
  39. package/dist/components/PhoneInput/PhoneInput.cjs +1 -1
  40. package/dist/components/PhoneInput/PhoneInput.cjs.map +1 -1
  41. package/dist/components/PhoneInput/PhoneInput.js +8 -5
  42. package/dist/components/PhoneInput/PhoneInput.js.map +1 -1
  43. package/dist/components/PopularQuestions/PopularQuestions.cjs +1 -1
  44. package/dist/components/PopularQuestions/PopularQuestions.cjs.map +1 -1
  45. package/dist/components/PopularQuestions/PopularQuestions.js +22 -21
  46. package/dist/components/PopularQuestions/PopularQuestions.js.map +1 -1
  47. package/dist/components/RegionMap/RegionMap.cjs +2 -0
  48. package/dist/components/RegionMap/RegionMap.cjs.map +1 -0
  49. package/dist/components/RegionMap/RegionMap.js +55 -0
  50. package/dist/components/RegionMap/RegionMap.js.map +1 -0
  51. package/dist/components/RegionMap/mapPaths.cjs +2 -0
  52. package/dist/components/RegionMap/mapPaths.cjs.map +1 -0
  53. package/dist/components/RegionMap/mapPaths.js +86 -0
  54. package/dist/components/RegionMap/mapPaths.js.map +1 -0
  55. package/dist/components/RequestSearch/RequestSearch.cjs +2 -0
  56. package/dist/components/RequestSearch/RequestSearch.cjs.map +1 -0
  57. package/dist/components/RequestSearch/RequestSearch.js +36 -0
  58. package/dist/components/RequestSearch/RequestSearch.js.map +1 -0
  59. package/dist/components/RequestSummary/RequestSummary.cjs +1 -1
  60. package/dist/components/RequestSummary/RequestSummary.cjs.map +1 -1
  61. package/dist/components/RequestSummary/RequestSummary.js +31 -32
  62. package/dist/components/RequestSummary/RequestSummary.js.map +1 -1
  63. package/dist/components/RequestTypeOption/RequestTypeOption.cjs +2 -0
  64. package/dist/components/RequestTypeOption/RequestTypeOption.cjs.map +1 -0
  65. package/dist/components/RequestTypeOption/RequestTypeOption.js +52 -0
  66. package/dist/components/RequestTypeOption/RequestTypeOption.js.map +1 -0
  67. package/dist/components/Select/Select.cjs +1 -1
  68. package/dist/components/Select/Select.cjs.map +1 -1
  69. package/dist/components/Select/Select.js +127 -121
  70. package/dist/components/Select/Select.js.map +1 -1
  71. package/dist/components/ShowMore/ShowMore.cjs +2 -0
  72. package/dist/components/ShowMore/ShowMore.cjs.map +1 -0
  73. package/dist/components/ShowMore/ShowMore.js +34 -0
  74. package/dist/components/ShowMore/ShowMore.js.map +1 -0
  75. package/dist/components/SiteHeader/SiteHeader.cjs.map +1 -1
  76. package/dist/components/SiteHeader/SiteHeader.js.map +1 -1
  77. package/dist/components/SortSelect/SortSelect.cjs +2 -0
  78. package/dist/components/SortSelect/SortSelect.cjs.map +1 -0
  79. package/dist/components/SortSelect/SortSelect.js +18 -0
  80. package/dist/components/SortSelect/SortSelect.js.map +1 -0
  81. package/dist/components/StatusFilter/StatusFilter.cjs +2 -0
  82. package/dist/components/StatusFilter/StatusFilter.cjs.map +1 -0
  83. package/dist/components/StatusFilter/StatusFilter.js +37 -0
  84. package/dist/components/StatusFilter/StatusFilter.js.map +1 -0
  85. package/dist/components/StatusTag/StatusTag.cjs.map +1 -1
  86. package/dist/components/StatusTag/StatusTag.js.map +1 -1
  87. package/dist/components/StepCard/StepCard.cjs +1 -1
  88. package/dist/components/StepCard/StepCard.cjs.map +1 -1
  89. package/dist/components/StepCard/StepCard.js +9 -6
  90. package/dist/components/StepCard/StepCard.js.map +1 -1
  91. package/dist/components/StepProgress/StepProgress.cjs +2 -0
  92. package/dist/components/StepProgress/StepProgress.cjs.map +1 -0
  93. package/dist/components/StepProgress/StepProgress.js +43 -0
  94. package/dist/components/StepProgress/StepProgress.js.map +1 -0
  95. package/dist/components/TelegramConnect/TelegramConnect.cjs +2 -0
  96. package/dist/components/TelegramConnect/TelegramConnect.cjs.map +1 -0
  97. package/dist/components/TelegramConnect/TelegramConnect.js +57 -0
  98. package/dist/components/TelegramConnect/TelegramConnect.js.map +1 -0
  99. package/dist/components/TextInput/TextInput.cjs +1 -1
  100. package/dist/components/TextInput/TextInput.cjs.map +1 -1
  101. package/dist/components/TextInput/TextInput.js +21 -19
  102. package/dist/components/TextInput/TextInput.js.map +1 -1
  103. package/dist/components/Textarea/Textarea.cjs +1 -1
  104. package/dist/components/Textarea/Textarea.cjs.map +1 -1
  105. package/dist/components/Textarea/Textarea.js +18 -16
  106. package/dist/components/Textarea/Textarea.js.map +1 -1
  107. package/dist/components/Toast/Toast.cjs +2 -0
  108. package/dist/components/Toast/Toast.cjs.map +1 -0
  109. package/dist/components/Toast/Toast.js +57 -0
  110. package/dist/components/Toast/Toast.js.map +1 -0
  111. package/dist/icons/generated/CheckmarkIcon.cjs +1 -1
  112. package/dist/icons/generated/CheckmarkIcon.cjs.map +1 -1
  113. package/dist/icons/generated/CheckmarkIcon.js +19 -2
  114. package/dist/icons/generated/CheckmarkIcon.js.map +1 -1
  115. package/dist/icons/generated/InfoIcon.cjs +2 -0
  116. package/dist/icons/generated/InfoIcon.cjs.map +1 -0
  117. package/dist/icons/generated/InfoIcon.js +35 -0
  118. package/dist/icons/generated/InfoIcon.js.map +1 -0
  119. package/dist/icons/generated/SendIcon.cjs +2 -0
  120. package/dist/icons/generated/SendIcon.cjs.map +1 -0
  121. package/dist/icons/generated/SendIcon.js +23 -0
  122. package/dist/icons/generated/SendIcon.js.map +1 -0
  123. package/dist/icons/generated/index.cjs +1 -1
  124. package/dist/icons/generated/index.cjs.map +1 -1
  125. package/dist/icons/generated/index.js +71 -67
  126. package/dist/icons/generated/index.js.map +1 -1
  127. package/dist/index.cjs +1 -1
  128. package/dist/index.d.cts +618 -32
  129. package/dist/index.d.ts +618 -32
  130. package/dist/index.js +146 -135
  131. package/dist/styles.css +1 -1
  132. package/dist/tailwind.css +0 -6
  133. package/dist/tokens/generated.cjs +1 -1
  134. package/dist/tokens/generated.cjs.map +1 -1
  135. package/dist/tokens/generated.js +1 -7
  136. package/dist/tokens/generated.js.map +1 -1
  137. package/dist/tokens.css +0 -12
  138. package/dist/tokens.d.cts +2 -26
  139. package/dist/tokens.d.ts +2 -26
  140. package/dist/tokens.json +1 -7
  141. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../icons/generated/DownArrowIcon.cjs"),n=require("../../icons/generated/UpArrowIcon.cjs"),r=require("../../utils/cn.cjs");;/* empty css */let i=require("react"),a=require("react/jsx-runtime"),o=require("@radix-ui/react-slot"),s=require("@radix-ui/react-popover");s=e.__toESM(s,1);var c=(0,i.createContext)(null),l=e=>e?Array.from(e.querySelectorAll(`[role="menuitem"]:not([aria-disabled="true"]):not(:disabled)`)):[],u=(0,i.forwardRef)(function({name:e,initials:o,avatarSrc:u,avatar:d,heading:f,description:p,children:m,compact:h=!1,"aria-label":g,open:_,defaultOpen:v=!1,onOpenChange:y,align:b=`end`,portalContainer:x,menuClassName:S,className:C,onKeyDown:w,...T},E){let[D,O]=(0,i.useState)(v),k=_??D,A=e=>{_===void 0&&O(e),y?.(e)},j=(0,i.useRef)(null),M=(0,i.useRef)(`first`),N=(0,i.useRef)({text:``,at:0}),P=g??(typeof e==`string`?e:void 0),F=f!=null&&f!==!1||p!=null&&p!==!1,I=`tm-${(0,i.useId)()}`,L=e=>{w?.(e),e.defaultPrevented||k||(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),M.current=e.key===`ArrowUp`?`last`:`first`,A(!0))},R=e=>{let t=l(j.current),n=t.indexOf(document.activeElement),r=e=>t[(e+t.length)%t.length]?.focus();switch(e.key){case`ArrowDown`:e.preventDefault(),r(n+1);break;case`ArrowUp`:e.preventDefault(),r(n===-1?t.length-1:n-1);break;case`Home`:e.preventDefault(),r(0);break;case`End`:e.preventDefault(),r(t.length-1);break;case`Tab`:e.preventDefault(),A(!1);break;default:if(e.key.length===1&&e.key!==` `&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let r=Date.now(),i=(r-N.current.at>600?``:N.current.text)+e.key.toLocaleLowerCase();N.current={text:i,at:r};let a=Math.max(0,n+ +(i.length===1));[...t.slice(a),...t.slice(0,a)].find(e=>(e.textContent??``).trim().toLocaleLowerCase().startsWith(i))?.focus()}}};return(0,a.jsxs)(s.Root,{open:k,onOpenChange:e=>{e&&(M.current=`first`),A(e)},children:[(0,a.jsx)(s.Trigger,{asChild:!0,children:(0,a.jsxs)(`button`,{ref:E,type:`button`,className:r.cn(`tm-account-menu__trigger`,C),"data-compact":h?``:void 0,"aria-label":P,...T,"aria-haspopup":`menu`,onKeyDown:L,children:[(0,a.jsx)(`span`,{className:`tm-account-menu__avatar`,"aria-hidden":`true`,children:d??(u?(0,a.jsx)(`img`,{className:`tm-account-menu__avatar-image`,src:u,alt:``}):o)}),e!=null&&e!==!1?(0,a.jsx)(`span`,{className:`tm-account-menu__name`,children:e}):null,k?(0,a.jsx)(n.UpArrowIcon,{size:`sm`,className:`tm-account-menu__chevron`}):(0,a.jsx)(t.DownArrowIcon,{size:`sm`,className:`tm-account-menu__chevron`})]})}),(0,a.jsx)(s.Portal,{container:x,children:(0,a.jsxs)(s.Content,{role:`presentation`,className:r.cn(`tm-account-menu__panel`,S),align:b,sideOffset:8,collisionPadding:8,onOpenAutoFocus:e=>{e.preventDefault();let t=l(j.current);(M.current===`last`?t[t.length-1]:t[0])?.focus(),M.current=`first`},children:[F?(0,a.jsxs)(`div`,{className:`tm-account-menu__header`,id:I,children:[f!=null&&f!==!1?(0,a.jsx)(`span`,{className:`tm-account-menu__heading`,children:f}):null,p!=null&&p!==!1?(0,a.jsx)(`span`,{className:`tm-account-menu__description`,children:p}):null]}):null,F?(0,a.jsx)(`div`,{className:`tm-account-menu__separator`,"aria-hidden":`true`}):null,(0,a.jsx)(c.Provider,{value:{close:()=>A(!1)},children:(0,a.jsx)(`div`,{ref:j,role:`menu`,"aria-label":P,"aria-describedby":F?I:void 0,"aria-orientation":`vertical`,className:`tm-account-menu__menu`,"data-tm-icon-size":`md`,onKeyDown:R,children:m})})]})})]})}),d=(0,i.forwardRef)(function({icon:e,disabled:t=!1,asChild:n=!1,href:s,className:l,children:u,onClick:d,onKeyDown:f,...p},m){let h=(0,i.useContext)(c),g=n?o.Slot:s===void 0?`button`:`a`;return(0,a.jsxs)(g,{ref:m,role:`menuitem`,tabIndex:-1,className:r.cn(`tm-account-menu__item`,l),href:g===`a`&&!t?s:void 0,type:g===`button`?`button`:void 0,"aria-disabled":t||void 0,onClick:e=>{t?e.preventDefault():(d?.(e),e.defaultPrevented||h?.close())},onKeyDown:e=>{f?.(e),!e.defaultPrevented&&e.key===` `&&e.currentTarget.tagName!==`BUTTON`&&(e.preventDefault(),e.currentTarget.click())},...p,children:[e?(0,a.jsx)(`span`,{className:`tm-account-menu__item-icon`,"aria-hidden":`true`,children:e}):null,(0,a.jsx)(o.Slottable,{children:u})]})}),f=(0,i.forwardRef)(function({className:e,...t},n){return(0,a.jsx)(`div`,{ref:n,role:`separator`,className:r.cn(`tm-account-menu__separator`,e),...t})});exports.AccountMenu=u,exports.AccountMenuItem=d,exports.AccountMenuSeparator=f;
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../icons/generated/DownArrowIcon.cjs"),n=require("../../icons/generated/UpArrowIcon.cjs"),r=require("../../utils/cn.cjs");;/* empty css */let i=require("react"),a=require("react/jsx-runtime"),o=require("@radix-ui/react-slot"),s=require("@radix-ui/react-popover");s=e.__toESM(s,1);var c=(0,i.createContext)(null),l=e=>e?Array.from(e.querySelectorAll(`[role="menuitem"]:not([aria-disabled="true"]):not(:disabled)`)):[],u=(0,i.forwardRef)(function({name:e,initials:o,avatarSrc:u,avatar:d,heading:f,description:p,children:m,compact:h=!1,"aria-label":g,open:_,defaultOpen:v=!1,onOpenChange:y,align:b=`center`,portalContainer:x,menuClassName:S,className:C,onKeyDown:w,...T},E){let[D,O]=(0,i.useState)(v),k=_??D,A=e=>{_===void 0&&O(e),y?.(e)},j=(0,i.useRef)(null),M=(0,i.useRef)(`first`),N=(0,i.useRef)({text:``,at:0}),P=g??(typeof e==`string`?e:void 0),F=f!=null&&f!==!1||p!=null&&p!==!1,I=`tm-${(0,i.useId)()}`,L=e=>{w?.(e),e.defaultPrevented||k||(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),M.current=e.key===`ArrowUp`?`last`:`first`,A(!0))},R=e=>{let t=l(j.current),n=t.indexOf(document.activeElement),r=e=>t[(e+t.length)%t.length]?.focus();switch(e.key){case`ArrowDown`:e.preventDefault(),r(n+1);break;case`ArrowUp`:e.preventDefault(),r(n===-1?t.length-1:n-1);break;case`Home`:e.preventDefault(),r(0);break;case`End`:e.preventDefault(),r(t.length-1);break;case`Tab`:e.preventDefault(),A(!1);break;default:if(e.key.length===1&&e.key!==` `&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let r=Date.now(),i=(r-N.current.at>600?``:N.current.text)+e.key.toLocaleLowerCase();N.current={text:i,at:r};let a=Math.max(0,n+ +(i.length===1));[...t.slice(a),...t.slice(0,a)].find(e=>(e.textContent??``).trim().toLocaleLowerCase().startsWith(i))?.focus()}}};return(0,a.jsxs)(s.Root,{open:k,onOpenChange:e=>{e&&(M.current=`first`),A(e)},children:[(0,a.jsx)(s.Trigger,{asChild:!0,children:(0,a.jsxs)(`button`,{ref:E,type:`button`,className:r.cn(`tm-account-menu__trigger`,C),"data-compact":h?``:void 0,"aria-label":P,...T,"aria-haspopup":`menu`,onKeyDown:L,children:[(0,a.jsx)(`span`,{className:`tm-account-menu__avatar`,"aria-hidden":`true`,children:d??(u?(0,a.jsx)(`img`,{className:`tm-account-menu__avatar-image`,src:u,alt:``}):o)}),e!=null&&e!==!1?(0,a.jsx)(`span`,{className:`tm-account-menu__name`,children:e}):null,k?(0,a.jsx)(n.UpArrowIcon,{size:`sm`,className:`tm-account-menu__chevron`}):(0,a.jsx)(t.DownArrowIcon,{size:`sm`,className:`tm-account-menu__chevron`})]})}),(0,a.jsx)(s.Portal,{container:x,children:(0,a.jsxs)(s.Content,{role:`presentation`,className:r.cn(`tm-account-menu__panel`,S),align:b,sideOffset:8,collisionPadding:8,onOpenAutoFocus:e=>{e.preventDefault();let t=l(j.current);(M.current===`last`?t[t.length-1]:t[0])?.focus(),M.current=`first`},children:[F?(0,a.jsxs)(`div`,{className:`tm-account-menu__header`,id:I,children:[f!=null&&f!==!1?(0,a.jsx)(`span`,{className:`tm-account-menu__heading`,children:f}):null,p!=null&&p!==!1?(0,a.jsx)(`span`,{className:`tm-account-menu__description`,children:p}):null]}):null,F?(0,a.jsx)(`div`,{className:`tm-account-menu__separator`,"aria-hidden":`true`}):null,(0,a.jsx)(c.Provider,{value:{close:()=>A(!1)},children:(0,a.jsx)(`div`,{ref:j,role:`menu`,"aria-label":P,"aria-describedby":F?I:void 0,"aria-orientation":`vertical`,className:`tm-account-menu__menu`,"data-tm-icon-size":`md`,onKeyDown:R,children:m})})]})})]})}),d=(0,i.forwardRef)(function({icon:e,disabled:t=!1,asChild:n=!1,href:s,className:l,children:u,onClick:d,onKeyDown:f,...p},m){let h=(0,i.useContext)(c),g=n?o.Slot:s===void 0?`button`:`a`;return(0,a.jsxs)(g,{ref:m,role:`menuitem`,tabIndex:-1,className:r.cn(`tm-account-menu__item`,l),href:g===`a`&&!t?s:void 0,type:g===`button`?`button`:void 0,"aria-disabled":t||void 0,onClick:e=>{t?e.preventDefault():(d?.(e),e.defaultPrevented||h?.close())},onKeyDown:e=>{f?.(e),!e.defaultPrevented&&e.key===` `&&e.currentTarget.tagName!==`BUTTON`&&(e.preventDefault(),e.currentTarget.click())},...p,children:[e?(0,a.jsx)(`span`,{className:`tm-account-menu__item-icon`,"aria-hidden":`true`,children:e}):null,(0,a.jsx)(o.Slottable,{children:u})]})}),f=(0,i.forwardRef)(function({className:e,...t},n){return(0,a.jsx)(`div`,{ref:n,role:`separator`,className:r.cn(`tm-account-menu__separator`,e),...t})});exports.AccountMenu=u,exports.AccountMenuItem=d,exports.AccountMenuSeparator=f;
2
2
  //# sourceMappingURL=AccountMenu.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"AccountMenu.cjs","names":["createContext","useState","useRef","useId","Popover","cn","UpArrowIcon","DownArrowIcon","useContext","Slot","Slottable","require_runtime","require_DownArrowIcon","require_UpArrowIcon","require_cn","react","react_jsx_runtime","_radix_ui_react_slot","_radix_ui_react_popover","AccountMenuContext","itemsOf","menu","AccountMenu","ariaLabel","props","uncontrolledOpen","setUncontrolledOpen","defaultOpen","isOpen","open","setOpen","next","onOpenChange","menuRef","focusOnOpen","typed","label","name","hasHeader","heading","description","headingId","handleTriggerKeys","onKeyDown","event","handleMenuKeys","items","current","focus","index","now","text","start","item","className","compact","avatar","avatarSrc","initials","portalContainer","menuClassName","AccountMenuItem","Comp","asChild","href","disabled","onClick","icon","AccountMenuSeparator"],"sources":["../../../src/components/AccountMenu/AccountMenu.tsx"],"sourcesContent":["import * as Popover from '@radix-ui/react-popover';\nimport { Slot, Slottable } from '@radix-ui/react-slot';\nimport {\n createContext,\n forwardRef,\n useContext,\n useId,\n useRef,\n useState,\n type AnchorHTMLAttributes,\n type ButtonHTMLAttributes,\n type ElementType,\n type HTMLAttributes,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n} from 'react';\nimport { DownArrowIcon, UpArrowIcon } from '../../icons';\nimport { cn } from '../../utils/cn';\nimport './AccountMenu.css';\n\nconst AccountMenuContext = createContext<{ close: () => void } | null>(null);\n\nexport interface AccountMenuProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'name'> {\n /** Text next to the avatar, usually the first name (\"Anna\"). */\n name?: ReactNode;\n /** One or two letters shown in the avatar when there is no picture (\"AP\"). */\n initials?: string;\n /** Picture for the avatar. It is decorative: the button is named by `name` / `aria-label`. */\n avatarSrc?: string;\n /** Replaces the whole avatar (32px), e.g. with an `AgencyLogo`. */\n avatar?: ReactNode;\n /** First line of the menu header, usually the full name (\"Anna Petrosyan\"). */\n heading?: ReactNode;\n /** Second line of the menu header, usually the e-mail address. */\n description?: ReactNode;\n /** The menu: `AccountMenuItem`s and `AccountMenuSeparator`s. */\n children?: ReactNode;\n /** Avatar-only trigger without the pill, as in the mobile header. Inside a collapsed `PortalHeader` this happens by itself. */\n compact?: boolean;\n /** Accessible name of the button and its menu. Defaults to `name` when that is a string; required otherwise. */\n 'aria-label'?: string;\n /** Whether the menu is open (controlled; Figma \"State=Open\"). */\n open?: boolean;\n /** Opens the menu initially (uncontrolled). */\n defaultOpen?: boolean;\n /** Called when the menu opens or closes. */\n onOpenChange?: (open: boolean) => void;\n /** How the menu lines up with the button. Figma aligns their right edges (`end`). */\n align?: 'start' | 'center' | 'end';\n /** Element the menu is rendered into (default `document.body`). Set it when the theme is scoped to a container. */\n portalContainer?: HTMLElement | null;\n /** Class for the menu panel, which is rendered in a portal outside the button. */\n menuClassName?: string;\n}\n\nconst itemsOf = (menu: HTMLElement | null) =>\n menu ? Array.from(menu.querySelectorAll<HTMLElement>('[role=\"menuitem\"]:not([aria-disabled=\"true\"]):not(:disabled)')) : [];\n\n/**\n * Figma component set \"Account menu\": the avatar pill of the header and the menu it opens.\n * A menu button — Enter, Space or the arrow keys open it; arrows, Home, End and typing a letter move between the items;\n * Escape and Tab close it and return focus to the button. The ref and the remaining props go to the button.\n */\nexport const AccountMenu = /* @__PURE__ */ forwardRef<HTMLButtonElement, AccountMenuProps>(function AccountMenu(\n {\n name,\n initials,\n avatarSrc,\n avatar,\n heading,\n description,\n children,\n compact = false,\n 'aria-label': ariaLabel,\n open,\n defaultOpen = false,\n onOpenChange,\n align = 'end',\n portalContainer,\n menuClassName,\n className,\n onKeyDown,\n ...props\n },\n ref,\n) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n const isOpen = open ?? uncontrolledOpen;\n const setOpen = (next: boolean) => {\n if (open === undefined) setUncontrolledOpen(next);\n onOpenChange?.(next);\n };\n\n const menuRef = useRef<HTMLDivElement>(null);\n /** Which item takes focus when the menu opens: the last one after ArrowUp on the button, otherwise the first. */\n const focusOnOpen = useRef<'first' | 'last'>('first');\n const typed = useRef({ text: '', at: 0 });\n const label = ariaLabel ?? (typeof name === 'string' ? name : undefined);\n const hasHeader = (heading != null && heading !== false) || (description != null && description !== false);\n const headingId = `tm-${useId()}`;\n\n const handleTriggerKeys = (event: KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(event);\n if (event.defaultPrevented || isOpen) return;\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n focusOnOpen.current = event.key === 'ArrowUp' ? 'last' : 'first';\n setOpen(true);\n }\n };\n\n const handleMenuKeys = (event: KeyboardEvent<HTMLDivElement>) => {\n const items = itemsOf(menuRef.current);\n const current = items.indexOf(document.activeElement as HTMLElement);\n const focus = (index: number) => items[(index + items.length) % items.length]?.focus();\n\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n focus(current + 1);\n break;\n case 'ArrowUp':\n event.preventDefault();\n focus(current === -1 ? items.length - 1 : current - 1);\n break;\n case 'Home':\n event.preventDefault();\n focus(0);\n break;\n case 'End':\n event.preventDefault();\n focus(items.length - 1);\n break;\n case 'Tab':\n // A menu is one tab stop: Tab leaves it, back to the button.\n event.preventDefault();\n setOpen(false);\n break;\n default:\n // Type-ahead: letters typed in quick succession jump to the item that starts with them.\n if (event.key.length === 1 && event.key !== ' ' && !event.ctrlKey && !event.metaKey && !event.altKey) {\n const now = Date.now();\n const text = (now - typed.current.at > 600 ? '' : typed.current.text) + event.key.toLocaleLowerCase();\n typed.current = { text, at: now };\n // A first letter looks from the next item on (so repeating it cycles); further letters refine from the current one.\n const start = Math.max(0, current + (text.length === 1 ? 1 : 0));\n const ordered = [...items.slice(start), ...items.slice(0, start)];\n ordered.find((item) => (item.textContent ?? '').trim().toLocaleLowerCase().startsWith(text))?.focus();\n }\n }\n };\n\n return (\n <Popover.Root\n open={isOpen}\n onOpenChange={(next) => {\n if (next) focusOnOpen.current = 'first';\n setOpen(next);\n }}\n >\n <Popover.Trigger asChild>\n <button\n ref={ref}\n type=\"button\"\n className={cn('tm-account-menu__trigger', className)}\n data-compact={compact ? '' : undefined}\n aria-label={label}\n {...props}\n aria-haspopup=\"menu\"\n onKeyDown={handleTriggerKeys}\n >\n <span className=\"tm-account-menu__avatar\" aria-hidden=\"true\">\n {avatar ?? (avatarSrc ? <img className=\"tm-account-menu__avatar-image\" src={avatarSrc} alt=\"\" /> : initials)}\n </span>\n {name != null && name !== false ? <span className=\"tm-account-menu__name\">{name}</span> : null}\n {isOpen ? <UpArrowIcon size=\"sm\" className=\"tm-account-menu__chevron\" /> : <DownArrowIcon size=\"sm\" className=\"tm-account-menu__chevron\" />}\n </button>\n </Popover.Trigger>\n <Popover.Portal container={portalContainer}>\n <Popover.Content\n // The popover is only the surface; the menu inside it carries the semantics.\n role=\"presentation\"\n className={cn('tm-account-menu__panel', menuClassName)}\n align={align}\n sideOffset={8}\n collisionPadding={8}\n onOpenAutoFocus={(event) => {\n event.preventDefault();\n const items = itemsOf(menuRef.current);\n (focusOnOpen.current === 'last' ? items[items.length - 1] : items[0])?.focus();\n focusOnOpen.current = 'first';\n }}\n >\n {hasHeader ? (\n <div className=\"tm-account-menu__header\" id={headingId}>\n {heading != null && heading !== false ? <span className=\"tm-account-menu__heading\">{heading}</span> : null}\n {description != null && description !== false ? <span className=\"tm-account-menu__description\">{description}</span> : null}\n </div>\n ) : null}\n {hasHeader ? <div className=\"tm-account-menu__separator\" aria-hidden=\"true\" /> : null}\n <AccountMenuContext.Provider value={{ close: () => setOpen(false) }}>\n <div\n ref={menuRef}\n role=\"menu\"\n aria-label={label}\n aria-describedby={hasHeader ? headingId : undefined}\n aria-orientation=\"vertical\"\n className=\"tm-account-menu__menu\"\n data-tm-icon-size=\"md\"\n onKeyDown={handleMenuKeys}\n >\n {children}\n </div>\n </AccountMenuContext.Provider>\n </Popover.Content>\n </Popover.Portal>\n </Popover.Root>\n );\n});\n\nexport interface AccountMenuItemProps\n extends HTMLAttributes<HTMLElement>,\n Pick<AnchorHTMLAttributes<HTMLAnchorElement>, 'href' | 'target' | 'rel'> {\n /** Icon before the label (20px, any icon from `@travel-match/ui`). */\n icon?: ReactNode;\n /** Greys the item out and skips it with the keyboard. */\n disabled?: boolean;\n /** Renders the single child element (e.g. a router `<Link>`) as the item instead of an `<a>` / `<button>`. */\n asChild?: boolean;\n}\n\n/**\n * One entry of `AccountMenu` (Figma \"Item / …\"): a link with `href` (or `asChild`), otherwise a button.\n * Choosing it closes the menu; call `event.preventDefault()` in `onClick` to keep the menu open.\n */\nexport const AccountMenuItem = /* @__PURE__ */ forwardRef<HTMLElement, AccountMenuItemProps>(function AccountMenuItem(\n { icon, disabled = false, asChild = false, href, className, children, onClick, onKeyDown, ...props },\n ref,\n) {\n const menu = useContext(AccountMenuContext);\n const Comp: ElementType = asChild ? Slot : href !== undefined ? 'a' : 'button';\n\n const handleClick = (event: MouseEvent<HTMLElement>) => {\n if (disabled) {\n event.preventDefault();\n return;\n }\n onClick?.(event);\n if (!event.defaultPrevented) menu?.close();\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLElement>) => {\n onKeyDown?.(event);\n // Links activate on Enter only; in a menu Space has to work as well.\n if (!event.defaultPrevented && event.key === ' ' && event.currentTarget.tagName !== 'BUTTON') {\n event.preventDefault();\n event.currentTarget.click();\n }\n };\n\n return (\n <Comp\n ref={ref}\n role=\"menuitem\"\n tabIndex={-1}\n className={cn('tm-account-menu__item', className)}\n href={Comp === 'a' && !disabled ? href : undefined}\n type={Comp === 'button' ? 'button' : undefined}\n aria-disabled={disabled || undefined}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n {...props}\n >\n {icon ? (\n <span className=\"tm-account-menu__item-icon\" aria-hidden=\"true\">\n {icon}\n </span>\n ) : null}\n <Slottable>{children}</Slottable>\n </Comp>\n );\n});\n\n/** The 1px rule between groups of `AccountMenuItem`s (Figma \"Divider\"). */\nexport const AccountMenuSeparator = /* @__PURE__ */ forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(function AccountMenuSeparator(\n { className, ...props },\n ref,\n) {\n return <div ref={ref} role=\"separator\" className={cn('tm-account-menu__separator', className)} {...props} />;\n});\n"],"mappings":"A,4XAqBA,IAAMmB,GAAA,EAAqBnB,EAAAA,cAAAA,CAA4C,IAAI,EAmCrEoB,EAAW,GACfC,EAAO,MAAM,KAAKA,EAAK,iBAA8B,8DAA8D,CAAC,EAAI,CAAC,EAO9GC,GAA8B,EAAAP,EAAA,WAAA,CAAgD,SACzF,CACE,OACA,WACA,YACA,SACA,UACA,cACA,WACA,UAAU,GACV,aAAcQ,EACd,OACA,cAAc,GACd,eACA,QAAQ,MACR,kBACA,gBACA,YACA,YACA,GAAGC,GAEL,EACA,CACA,GAAM,CAACC,EAAkBC,IAAA,EAAuBzB,EAAAA,SAAAA,CAAS0B,CAAW,EAC9DC,EAASC,GAAQJ,EACjBK,EAAW,GAAkB,CAC7BD,IAAS,IAAA,IAAWH,EAAoBK,CAAI,EAChDC,IAAeD,CAAI,CACrB,EAEME,GAAA,EAAU/B,EAAAA,OAAAA,CAAuB,IAAI,EAErCgC,GAAA,EAAchC,EAAAA,OAAAA,CAAyB,OAAO,EAC9CiC,GAAA,EAAQjC,EAAAA,OAAAA,CAAO,CAAE,KAAM,GAAI,GAAI,CAAE,CAAC,EAClCkC,EAAQb,IAAc,OAAOc,GAAS,SAAWA,EAAO,IAAA,IACxDC,EAAaC,GAAW,MAAQA,IAAY,IAAWC,GAAe,MAAQA,IAAg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E,OACE,EAAAhD,EAAA,KAAA,CAAC8C,EAAD,CACO,MACL,KAAK,WACL,SAAU,GACV,UAAWzD,EAAAA,GAAG,wBAAyBiD,CAAS,EAChD,KAAMQ,IAAS,KAAO,CAACG,EAAWD,EAAO,IAAA,GACzC,KAAMF,IAAS,SAAW,SAAW,IAAA,GACrC,gBAAeG,GAAY,IAAA,GAC3B,QA3BiB,GAAmC,CAClDA,EACFrB,EAAM,eAAe,GAGvBsB,IAAUtB,CAAK,EACVA,EAAM,kBAAkBvB,GAAM,MAAM,EAC3C,EAqBI,UAnBmB,GAAsC,CAC3DsB,IAAYC,CAAK,EAEb,CAACA,EAAM,kBAAoBA,EAAM,MAAQ,KAAOA,EAAM,cAAc,UAAY,WAClFA,EAAM,eAAe,EACrBA,EAAM,cAAc,MAAM,EAE9B,EAaI,GAAIpB,EAVN,SAAA,CAYG2C,GACC,EAAAnD,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,6BAA6B,cAAY,OACtD,SAAAmD,CACG,CAAA,EACJ,MACJ,EAAAnD,EAAA,IAAA,CAACN,EAAAA,UAAD,CAAY,UAAoB,CAAA,CAC5B,C,EAEV,CAAC,EAGY0D,GAAuC,EAAArD,EAAA,WAAA,CAA2D,SAC7G,CAAE,YAAW,GAAGS,GAChB,EACA,CACA,OAAO,EAAAR,EAAA,IAAA,CAAC,MAAD,CAAU,MAAK,KAAK,YAAY,UAAWX,EAAAA,GAAG,6BAA8BiD,CAAS,EAAG,GAAI9B,CAAQ,CAAA,CAC7G,CAAC,E"}
1
+ {"version":3,"file":"AccountMenu.cjs","names":["createContext","useState","useRef","useId","Popover","cn","UpArrowIcon","DownArrowIcon","useContext","Slot","Slottable","require_runtime","require_DownArrowIcon","require_UpArrowIcon","require_cn","react","react_jsx_runtime","_radix_ui_react_slot","_radix_ui_react_popover","AccountMenuContext","itemsOf","menu","AccountMenu","ariaLabel","props","uncontrolledOpen","setUncontrolledOpen","defaultOpen","isOpen","open","setOpen","next","onOpenChange","menuRef","focusOnOpen","typed","label","name","hasHeader","heading","description","headingId","handleTriggerKeys","onKeyDown","event","handleMenuKeys","items","current","focus","index","now","text","start","item","className","compact","avatar","avatarSrc","initials","portalContainer","menuClassName","AccountMenuItem","Comp","asChild","href","disabled","onClick","icon","AccountMenuSeparator"],"sources":["../../../src/components/AccountMenu/AccountMenu.tsx"],"sourcesContent":["import * as Popover from '@radix-ui/react-popover';\nimport { Slot, Slottable } from '@radix-ui/react-slot';\nimport {\n createContext,\n forwardRef,\n useContext,\n useId,\n useRef,\n useState,\n type AnchorHTMLAttributes,\n type ButtonHTMLAttributes,\n type ElementType,\n type HTMLAttributes,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n} from 'react';\nimport { DownArrowIcon, UpArrowIcon } from '../../icons';\nimport { cn } from '../../utils/cn';\nimport './AccountMenu.css';\n\nconst AccountMenuContext = createContext<{ close: () => void } | null>(null);\n\nexport interface AccountMenuProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'name'> {\n /** Text next to the avatar, usually the first name (\"Anna\"). */\n name?: ReactNode;\n /** One or two letters shown in the avatar when there is no picture (\"AP\"). */\n initials?: string;\n /** Picture for the avatar. It is decorative: the button is named by `name` / `aria-label`. */\n avatarSrc?: string;\n /** Replaces the whole avatar (32px), e.g. with an `AgencyLogo`. */\n avatar?: ReactNode;\n /** First line of the menu header, usually the full name (\"Anna Petrosyan\"). */\n heading?: ReactNode;\n /** Second line of the menu header, usually the e-mail address. */\n description?: ReactNode;\n /** The menu: `AccountMenuItem`s and `AccountMenuSeparator`s. */\n children?: ReactNode;\n /** Avatar-only trigger without the pill, as in the mobile header. Inside a collapsed `PortalHeader` this happens by itself. */\n compact?: boolean;\n /** Accessible name of the button and its menu. Defaults to `name` when that is a string; required otherwise. */\n 'aria-label'?: string;\n /** Whether the menu is open (controlled; Figma \"State=Open\"). */\n open?: boolean;\n /** Opens the menu initially (uncontrolled). */\n defaultOpen?: boolean;\n /** Called when the menu opens or closes. */\n onOpenChange?: (open: boolean) => void;\n /**\n * How the menu lines up with the button. Figma centres it under the button (`center`, the default); near the edge of\n * the screen it shifts to stay 8px inside the viewport.\n */\n align?: 'start' | 'center' | 'end';\n /** Element the menu is rendered into (default `document.body`). Set it when the theme is scoped to a container. */\n portalContainer?: HTMLElement | null;\n /** Class for the menu panel, which is rendered in a portal outside the button. */\n menuClassName?: string;\n}\n\nconst itemsOf = (menu: HTMLElement | null) =>\n menu ? Array.from(menu.querySelectorAll<HTMLElement>('[role=\"menuitem\"]:not([aria-disabled=\"true\"]):not(:disabled)')) : [];\n\n/**\n * Figma component set \"Account menu\": the avatar pill of the header and the menu it opens.\n * A menu button — Enter, Space or the arrow keys open it; arrows, Home, End and typing a letter move between the items;\n * Escape and Tab close it and return focus to the button. The ref and the remaining props go to the button.\n */\nexport const AccountMenu = /* @__PURE__ */ forwardRef<HTMLButtonElement, AccountMenuProps>(function AccountMenu(\n {\n name,\n initials,\n avatarSrc,\n avatar,\n heading,\n description,\n children,\n compact = false,\n 'aria-label': ariaLabel,\n open,\n defaultOpen = false,\n onOpenChange,\n align = 'center',\n portalContainer,\n menuClassName,\n className,\n onKeyDown,\n ...props\n },\n ref,\n) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n const isOpen = open ?? uncontrolledOpen;\n const setOpen = (next: boolean) => {\n if (open === undefined) setUncontrolledOpen(next);\n onOpenChange?.(next);\n };\n\n const menuRef = useRef<HTMLDivElement>(null);\n /** Which item takes focus when the menu opens: the last one after ArrowUp on the button, otherwise the first. */\n const focusOnOpen = useRef<'first' | 'last'>('first');\n const typed = useRef({ text: '', at: 0 });\n const label = ariaLabel ?? (typeof name === 'string' ? name : undefined);\n const hasHeader = (heading != null && heading !== false) || (description != null && description !== false);\n const headingId = `tm-${useId()}`;\n\n const handleTriggerKeys = (event: KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(event);\n if (event.defaultPrevented || isOpen) return;\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n focusOnOpen.current = event.key === 'ArrowUp' ? 'last' : 'first';\n setOpen(true);\n }\n };\n\n const handleMenuKeys = (event: KeyboardEvent<HTMLDivElement>) => {\n const items = itemsOf(menuRef.current);\n const current = items.indexOf(document.activeElement as HTMLElement);\n const focus = (index: number) => items[(index + items.length) % items.length]?.focus();\n\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n focus(current + 1);\n break;\n case 'ArrowUp':\n event.preventDefault();\n focus(current === -1 ? items.length - 1 : current - 1);\n break;\n case 'Home':\n event.preventDefault();\n focus(0);\n break;\n case 'End':\n event.preventDefault();\n focus(items.length - 1);\n break;\n case 'Tab':\n // A menu is one tab stop: Tab leaves it, back to the button.\n event.preventDefault();\n setOpen(false);\n break;\n default:\n // Type-ahead: letters typed in quick succession jump to the item that starts with them.\n if (event.key.length === 1 && event.key !== ' ' && !event.ctrlKey && !event.metaKey && !event.altKey) {\n const now = Date.now();\n const text = (now - typed.current.at > 600 ? '' : typed.current.text) + event.key.toLocaleLowerCase();\n typed.current = { text, at: now };\n // A first letter looks from the next item on (so repeating it cycles); further letters refine from the current one.\n const start = Math.max(0, current + (text.length === 1 ? 1 : 0));\n const ordered = [...items.slice(start), ...items.slice(0, start)];\n ordered.find((item) => (item.textContent ?? '').trim().toLocaleLowerCase().startsWith(text))?.focus();\n }\n }\n };\n\n return (\n <Popover.Root\n open={isOpen}\n onOpenChange={(next) => {\n if (next) focusOnOpen.current = 'first';\n setOpen(next);\n }}\n >\n <Popover.Trigger asChild>\n <button\n ref={ref}\n type=\"button\"\n className={cn('tm-account-menu__trigger', className)}\n data-compact={compact ? '' : undefined}\n aria-label={label}\n {...props}\n aria-haspopup=\"menu\"\n onKeyDown={handleTriggerKeys}\n >\n <span className=\"tm-account-menu__avatar\" aria-hidden=\"true\">\n {avatar ?? (avatarSrc ? <img className=\"tm-account-menu__avatar-image\" src={avatarSrc} alt=\"\" /> : initials)}\n </span>\n {name != null && name !== false ? <span className=\"tm-account-menu__name\">{name}</span> : null}\n {isOpen ? <UpArrowIcon size=\"sm\" className=\"tm-account-menu__chevron\" /> : <DownArrowIcon size=\"sm\" className=\"tm-account-menu__chevron\" />}\n </button>\n </Popover.Trigger>\n <Popover.Portal container={portalContainer}>\n <Popover.Content\n // The popover is only the surface; the menu inside it carries the semantics.\n role=\"presentation\"\n className={cn('tm-account-menu__panel', menuClassName)}\n align={align}\n sideOffset={8}\n collisionPadding={8}\n onOpenAutoFocus={(event) => {\n event.preventDefault();\n const items = itemsOf(menuRef.current);\n (focusOnOpen.current === 'last' ? items[items.length - 1] : items[0])?.focus();\n focusOnOpen.current = 'first';\n }}\n >\n {hasHeader ? (\n <div className=\"tm-account-menu__header\" id={headingId}>\n {heading != null && heading !== false ? <span className=\"tm-account-menu__heading\">{heading}</span> : null}\n {description != null && description !== false ? <span className=\"tm-account-menu__description\">{description}</span> : null}\n </div>\n ) : null}\n {hasHeader ? <div className=\"tm-account-menu__separator\" aria-hidden=\"true\" /> : null}\n <AccountMenuContext.Provider value={{ close: () => setOpen(false) }}>\n <div\n ref={menuRef}\n role=\"menu\"\n aria-label={label}\n aria-describedby={hasHeader ? headingId : undefined}\n aria-orientation=\"vertical\"\n className=\"tm-account-menu__menu\"\n data-tm-icon-size=\"md\"\n onKeyDown={handleMenuKeys}\n >\n {children}\n </div>\n </AccountMenuContext.Provider>\n </Popover.Content>\n </Popover.Portal>\n </Popover.Root>\n );\n});\n\nexport interface AccountMenuItemProps\n extends HTMLAttributes<HTMLElement>,\n Pick<AnchorHTMLAttributes<HTMLAnchorElement>, 'href' | 'target' | 'rel'> {\n /** Icon before the label (20px, any icon from `@travel-match/ui`). */\n icon?: ReactNode;\n /** Greys the item out and skips it with the keyboard. */\n disabled?: boolean;\n /** Renders the single child element (e.g. a router `<Link>`) as the item instead of an `<a>` / `<button>`. */\n asChild?: boolean;\n}\n\n/**\n * One entry of `AccountMenu` (Figma \"Item / …\"): a link with `href` (or `asChild`), otherwise a button.\n * Choosing it closes the menu; call `event.preventDefault()` in `onClick` to keep the menu open.\n */\nexport const AccountMenuItem = /* @__PURE__ */ forwardRef<HTMLElement, AccountMenuItemProps>(function AccountMenuItem(\n { icon, disabled = false, asChild = false, href, className, children, onClick, onKeyDown, ...props },\n ref,\n) {\n const menu = useContext(AccountMenuContext);\n const Comp: ElementType = asChild ? Slot : href !== undefined ? 'a' : 'button';\n\n const handleClick = (event: MouseEvent<HTMLElement>) => {\n if (disabled) {\n event.preventDefault();\n return;\n }\n onClick?.(event);\n if (!event.defaultPrevented) menu?.close();\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLElement>) => {\n onKeyDown?.(event);\n // Links activate on Enter only; in a menu Space has to work as well.\n if (!event.defaultPrevented && event.key === ' ' && event.currentTarget.tagName !== 'BUTTON') {\n event.preventDefault();\n event.currentTarget.click();\n }\n };\n\n return (\n <Comp\n ref={ref}\n role=\"menuitem\"\n tabIndex={-1}\n className={cn('tm-account-menu__item', className)}\n href={Comp === 'a' && !disabled ? href : undefined}\n type={Comp === 'button' ? 'button' : undefined}\n aria-disabled={disabled || undefined}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n {...props}\n >\n {icon ? (\n <span className=\"tm-account-menu__item-icon\" aria-hidden=\"true\">\n {icon}\n </span>\n ) : null}\n <Slottable>{children}</Slottable>\n </Comp>\n );\n});\n\n/** The 1px rule between groups of `AccountMenuItem`s (Figma \"Divider\"). */\nexport const AccountMenuSeparator = /* @__PURE__ */ forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(function AccountMenuSeparator(\n { className, ...props },\n ref,\n) {\n return <div ref={ref} role=\"separator\" className={cn('tm-account-menu__separator', className)} {...props} />;\n});\n"],"mappings":"A,4XAqBA,IAAMmB,GAAA,EAAqBnB,EAAAA,cAAAA,CAA4C,IAAI,EAsCrEoB,EAAW,GACfC,EAAO,MAAM,KAAKA,EAAK,iBAA8B,8DAA8D,CAAC,EAAI,CAAC,EAO9GC,GAA8B,EAAAP,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cAAY,OACtD,SAAAmD,CACG,CAAA,EACJ,MACJ,EAAAnD,EAAA,IAAA,CAACN,EAAAA,UAAD,CAAY,UAAoB,CAAA,CAC5B,C,EAEV,CAAC,EAGY0D,GAAuC,EAAArD,EAAA,WAAA,CAA2D,SAC7G,CAAE,YAAW,GAAGS,GAChB,EACA,CACA,OAAO,EAAAR,EAAA,IAAA,CAAC,MAAD,CAAU,MAAK,KAAK,YAAY,UAAWX,EAAAA,GAAG,6BAA8BiD,CAAS,EAAG,GAAI9B,CAAQ,CAAA,CAC7G,CAAC,E"}
@@ -8,7 +8,7 @@ import { jsx as l, jsxs as u } from "react/jsx-runtime";
8
8
  import { Slot as d, Slottable as f } from "@radix-ui/react-slot";
9
9
  import * as p from "@radix-ui/react-popover";
10
10
  // src/components/AccountMenu/AccountMenu.tsx
11
- var m = r(null), h = (e) => e ? Array.from(e.querySelectorAll("[role=\"menuitem\"]:not([aria-disabled=\"true\"]):not(:disabled)")) : [], g = /* @__PURE__ */ i(function({ name: r, initials: i, avatarSrc: a, avatar: d, heading: f, description: g, children: _, compact: v = !1, "aria-label": y, open: b, defaultOpen: x = !1, onOpenChange: S, align: C = "end", portalContainer: w, menuClassName: T, className: E, onKeyDown: D, ...O }, k) {
11
+ var m = r(null), h = (e) => e ? Array.from(e.querySelectorAll("[role=\"menuitem\"]:not([aria-disabled=\"true\"]):not(:disabled)")) : [], g = /* @__PURE__ */ i(function({ name: r, initials: i, avatarSrc: a, avatar: d, heading: f, description: g, children: _, compact: v = !1, "aria-label": y, open: b, defaultOpen: x = !1, onOpenChange: S, align: C = "center", portalContainer: w, menuClassName: T, className: E, onKeyDown: D, ...O }, k) {
12
12
  let [A, j] = c(x), M = b ?? A, N = (e) => {
13
13
  b === void 0 && j(e), S?.(e);
14
14
  }, P = s(null), F = s("first"), I = s({
@@ -1 +1 @@
1
- {"version":3,"file":"AccountMenu.js","names":["Popover","AccountMenuContext","createContext","itemsOf","menu","AccountMenu","ariaLabel","props","uncontrolledOpen","setUncontrolledOpen","useState","defaultOpen","isOpen","open","setOpen","next","onOpenChange","menuRef","useRef","focusOnOpen","typed","label","name","hasHeader","heading","description","headingId","useId","handleTriggerKeys","onKeyDown","event","handleMenuKeys","items","current","focus","index","now","text","start","item","cn","className","compact","avatar","avatarSrc","initials","jsx","UpArrowIcon","DownArrowIcon","portalContainer","menuClassName","AccountMenuItem","useContext","Comp","asChild","Slot","href","disabled","onClick","icon","Slottable","AccountMenuSeparator"],"sources":["../../../src/components/AccountMenu/AccountMenu.tsx"],"sourcesContent":["import * as Popover from '@radix-ui/react-popover';\nimport { Slot, Slottable } from '@radix-ui/react-slot';\nimport {\n createContext,\n forwardRef,\n useContext,\n useId,\n useRef,\n useState,\n type AnchorHTMLAttributes,\n type ButtonHTMLAttributes,\n type ElementType,\n type HTMLAttributes,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n} from 'react';\nimport { DownArrowIcon, UpArrowIcon } from '../../icons';\nimport { cn } from '../../utils/cn';\nimport './AccountMenu.css';\n\nconst AccountMenuContext = createContext<{ close: () => void } | null>(null);\n\nexport interface AccountMenuProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'name'> {\n /** Text next to the avatar, usually the first name (\"Anna\"). */\n name?: ReactNode;\n /** One or two letters shown in the avatar when there is no picture (\"AP\"). */\n initials?: string;\n /** Picture for the avatar. It is decorative: the button is named by `name` / `aria-label`. */\n avatarSrc?: string;\n /** Replaces the whole avatar (32px), e.g. with an `AgencyLogo`. */\n avatar?: ReactNode;\n /** First line of the menu header, usually the full name (\"Anna Petrosyan\"). */\n heading?: ReactNode;\n /** Second line of the menu header, usually the e-mail address. */\n description?: ReactNode;\n /** The menu: `AccountMenuItem`s and `AccountMenuSeparator`s. */\n children?: ReactNode;\n /** Avatar-only trigger without the pill, as in the mobile header. Inside a collapsed `PortalHeader` this happens by itself. */\n compact?: boolean;\n /** Accessible name of the button and its menu. Defaults to `name` when that is a string; required otherwise. */\n 'aria-label'?: string;\n /** Whether the menu is open (controlled; Figma \"State=Open\"). */\n open?: boolean;\n /** Opens the menu initially (uncontrolled). */\n defaultOpen?: boolean;\n /** Called when the menu opens or closes. */\n onOpenChange?: (open: boolean) => void;\n /** How the menu lines up with the button. Figma aligns their right edges (`end`). */\n align?: 'start' | 'center' | 'end';\n /** Element the menu is rendered into (default `document.body`). Set it when the theme is scoped to a container. */\n portalContainer?: HTMLElement | null;\n /** Class for the menu panel, which is rendered in a portal outside the button. */\n menuClassName?: string;\n}\n\nconst itemsOf = (menu: HTMLElement | null) =>\n menu ? Array.from(menu.querySelectorAll<HTMLElement>('[role=\"menuitem\"]:not([aria-disabled=\"true\"]):not(:disabled)')) : [];\n\n/**\n * Figma component set \"Account menu\": the avatar pill of the header and the menu it opens.\n * A menu button — Enter, Space or the arrow keys open it; arrows, Home, End and typing a letter move between the items;\n * Escape and Tab close it and return focus to the button. The ref and the remaining props go to the button.\n */\nexport const AccountMenu = /* @__PURE__ */ forwardRef<HTMLButtonElement, AccountMenuProps>(function AccountMenu(\n {\n name,\n initials,\n avatarSrc,\n avatar,\n heading,\n description,\n children,\n compact = false,\n 'aria-label': ariaLabel,\n open,\n defaultOpen = false,\n onOpenChange,\n align = 'end',\n portalContainer,\n menuClassName,\n className,\n onKeyDown,\n ...props\n },\n ref,\n) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n const isOpen = open ?? uncontrolledOpen;\n const setOpen = (next: boolean) => {\n if (open === undefined) setUncontrolledOpen(next);\n onOpenChange?.(next);\n };\n\n const menuRef = useRef<HTMLDivElement>(null);\n /** Which item takes focus when the menu opens: the last one after ArrowUp on the button, otherwise the first. */\n const focusOnOpen = useRef<'first' | 'last'>('first');\n const typed = useRef({ text: '', at: 0 });\n const label = ariaLabel ?? (typeof name === 'string' ? name : undefined);\n const hasHeader = (heading != null && heading !== false) || (description != null && description !== false);\n const headingId = `tm-${useId()}`;\n\n const handleTriggerKeys = (event: KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(event);\n if (event.defaultPrevented || isOpen) return;\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n focusOnOpen.current = event.key === 'ArrowUp' ? 'last' : 'first';\n setOpen(true);\n }\n };\n\n const handleMenuKeys = (event: KeyboardEvent<HTMLDivElement>) => {\n const items = itemsOf(menuRef.current);\n const current = items.indexOf(document.activeElement as HTMLElement);\n const focus = (index: number) => items[(index + items.length) % items.length]?.focus();\n\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n focus(current + 1);\n break;\n case 'ArrowUp':\n event.preventDefault();\n focus(current === -1 ? items.length - 1 : current - 1);\n break;\n case 'Home':\n event.preventDefault();\n focus(0);\n break;\n case 'End':\n event.preventDefault();\n focus(items.length - 1);\n break;\n case 'Tab':\n // A menu is one tab stop: Tab leaves it, back to the button.\n event.preventDefault();\n setOpen(false);\n break;\n default:\n // Type-ahead: letters typed in quick succession jump to the item that starts with them.\n if (event.key.length === 1 && event.key !== ' ' && !event.ctrlKey && !event.metaKey && !event.altKey) {\n const now = Date.now();\n const text = (now - typed.current.at > 600 ? '' : typed.current.text) + event.key.toLocaleLowerCase();\n typed.current = { text, at: now };\n // A first letter looks from the next item on (so repeating it cycles); further letters refine from the current one.\n const start = Math.max(0, current + (text.length === 1 ? 1 : 0));\n const ordered = [...items.slice(start), ...items.slice(0, start)];\n ordered.find((item) => (item.textContent ?? '').trim().toLocaleLowerCase().startsWith(text))?.focus();\n }\n }\n };\n\n return (\n <Popover.Root\n open={isOpen}\n onOpenChange={(next) => {\n if (next) focusOnOpen.current = 'first';\n setOpen(next);\n }}\n >\n <Popover.Trigger asChild>\n <button\n ref={ref}\n type=\"button\"\n className={cn('tm-account-menu__trigger', className)}\n data-compact={compact ? '' : undefined}\n aria-label={label}\n {...props}\n aria-haspopup=\"menu\"\n onKeyDown={handleTriggerKeys}\n >\n <span className=\"tm-account-menu__avatar\" aria-hidden=\"true\">\n {avatar ?? (avatarSrc ? <img className=\"tm-account-menu__avatar-image\" src={avatarSrc} alt=\"\" /> : initials)}\n </span>\n {name != null && name !== false ? <span className=\"tm-account-menu__name\">{name}</span> : null}\n {isOpen ? <UpArrowIcon size=\"sm\" className=\"tm-account-menu__chevron\" /> : <DownArrowIcon size=\"sm\" className=\"tm-account-menu__chevron\" />}\n </button>\n </Popover.Trigger>\n <Popover.Portal container={portalContainer}>\n <Popover.Content\n // The popover is only the surface; the menu inside it carries the semantics.\n role=\"presentation\"\n className={cn('tm-account-menu__panel', menuClassName)}\n align={align}\n sideOffset={8}\n collisionPadding={8}\n onOpenAutoFocus={(event) => {\n event.preventDefault();\n const items = itemsOf(menuRef.current);\n (focusOnOpen.current === 'last' ? items[items.length - 1] : items[0])?.focus();\n focusOnOpen.current = 'first';\n }}\n >\n {hasHeader ? (\n <div className=\"tm-account-menu__header\" id={headingId}>\n {heading != null && heading !== false ? <span className=\"tm-account-menu__heading\">{heading}</span> : null}\n {description != null && description !== false ? <span className=\"tm-account-menu__description\">{description}</span> : null}\n </div>\n ) : null}\n {hasHeader ? <div className=\"tm-account-menu__separator\" aria-hidden=\"true\" /> : null}\n <AccountMenuContext.Provider value={{ close: () => setOpen(false) }}>\n <div\n ref={menuRef}\n role=\"menu\"\n aria-label={label}\n aria-describedby={hasHeader ? headingId : undefined}\n aria-orientation=\"vertical\"\n className=\"tm-account-menu__menu\"\n data-tm-icon-size=\"md\"\n onKeyDown={handleMenuKeys}\n >\n {children}\n </div>\n </AccountMenuContext.Provider>\n </Popover.Content>\n </Popover.Portal>\n </Popover.Root>\n );\n});\n\nexport interface AccountMenuItemProps\n extends HTMLAttributes<HTMLElement>,\n Pick<AnchorHTMLAttributes<HTMLAnchorElement>, 'href' | 'target' | 'rel'> {\n /** Icon before the label (20px, any icon from `@travel-match/ui`). */\n icon?: ReactNode;\n /** Greys the item out and skips it with the keyboard. */\n disabled?: boolean;\n /** Renders the single child element (e.g. a router `<Link>`) as the item instead of an `<a>` / `<button>`. */\n asChild?: boolean;\n}\n\n/**\n * One entry of `AccountMenu` (Figma \"Item / …\"): a link with `href` (or `asChild`), otherwise a button.\n * Choosing it closes the menu; call `event.preventDefault()` in `onClick` to keep the menu open.\n */\nexport const AccountMenuItem = /* @__PURE__ */ forwardRef<HTMLElement, AccountMenuItemProps>(function AccountMenuItem(\n { icon, disabled = false, asChild = false, href, className, children, onClick, onKeyDown, ...props },\n ref,\n) {\n const menu = useContext(AccountMenuContext);\n const Comp: ElementType = asChild ? Slot : href !== undefined ? 'a' : 'button';\n\n const handleClick = (event: MouseEvent<HTMLElement>) => {\n if (disabled) {\n event.preventDefault();\n return;\n }\n onClick?.(event);\n if (!event.defaultPrevented) menu?.close();\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLElement>) => {\n onKeyDown?.(event);\n // Links activate on Enter only; in a menu Space has to work as well.\n if (!event.defaultPrevented && event.key === ' ' && event.currentTarget.tagName !== 'BUTTON') {\n event.preventDefault();\n event.currentTarget.click();\n }\n };\n\n return (\n <Comp\n ref={ref}\n role=\"menuitem\"\n tabIndex={-1}\n className={cn('tm-account-menu__item', className)}\n href={Comp === 'a' && !disabled ? href : undefined}\n type={Comp === 'button' ? 'button' : undefined}\n aria-disabled={disabled || undefined}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n {...props}\n >\n {icon ? (\n <span className=\"tm-account-menu__item-icon\" aria-hidden=\"true\">\n {icon}\n </span>\n ) : null}\n <Slottable>{children}</Slottable>\n </Comp>\n );\n});\n\n/** The 1px rule between groups of `AccountMenuItem`s (Figma \"Divider\"). */\nexport const AccountMenuSeparator = /* @__PURE__ */ forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(function AccountMenuSeparator(\n { className, ...props },\n ref,\n) {\n return <div ref={ref} role=\"separator\" className={cn('tm-account-menu__separator', className)} {...props} />;\n});\n"],"mappings":";;;;;;;;;;AAqBA,IAAMC,IAAqBC,EAA4C,IAAI,GAmCrEC,KAAW,MACfC,IAAO,MAAM,KAAKA,EAAK,iBAA8B,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AO,aAAU,IAAO,SAAM,cAAW,aAAU,YAAS,cAAW,GAAG5C,KAC7F,GACA;CACA,IAAMH,IAAOgD,EAAWnD,CAAkB,GACpCoD,IAAoBC,IAAUC,IAAOC,MAAS,KAAA,IAAkB,WAAN;CAoBhE,OACE,kBAACH,GAAD;EACO;EACL,MAAK;EACL,UAAU;EACV,WAAWb,EAAG,yBAAyBC,CAAS;EAChD,MAAMY,MAAS,OAAO,CAACI,IAAWD,IAAO,KAAA;EACzC,MAAMH,MAAS,WAAW,WAAW,KAAA;EACrC,iBAAeI,KAAY,KAAA;EAC3B,UA3BiB,MAAmC;GACtD,AAAIA,IACF3B,EAAM,eAAe,KAGvB4B,IAAU5B,CAAK,GACVA,EAAM,oBAAkB1B,GAAM,MAAM;EAC3C;EAqBI,YAnBmB,MAAsC;GAG3D,AAFAyB,IAAYC,CAAK,GAEb,CAACA,EAAM,oBAAoBA,EAAM,QAAQ,OAAOA,EAAM,cAAc,YAAY,aAClFA,EAAM,eAAe,GACrBA,EAAM,cAAc,MAAM;EAE9B;EAaI,GAAIvB;EAVN,UAAA,CAYGoD,IACC,kBAAC,QAAD;GAAM,WAAU;GAA6B,eAAY;GACtD,UAAAA;EACG,CAAA,IACJ,MACJ,kBAACC,GAAD,EAAY,YAAoB,CAAA,CAC5B;;AAEV,CAAC,GAGYC,IAAuC,kBAA2D,SAC7G,EAAE,cAAW,GAAGtD,KAChB,GACA;CACA,OAAO,kBAAC,OAAD;EAAU;EAAK,MAAK;EAAY,WAAWiC,EAAG,8BAA8BC,CAAS;EAAG,GAAIlC;CAAQ,CAAA;AAC7G,CAAC"}
1
+ {"version":3,"file":"AccountMenu.js","names":["Popover","AccountMenuContext","createContext","itemsOf","menu","AccountMenu","ariaLabel","props","uncontrolledOpen","setUncontrolledOpen","useState","defaultOpen","isOpen","open","setOpen","next","onOpenChange","menuRef","useRef","focusOnOpen","typed","label","name","hasHeader","heading","description","headingId","useId","handleTriggerKeys","onKeyDown","event","handleMenuKeys","items","current","focus","index","now","text","start","item","cn","className","compact","avatar","avatarSrc","initials","jsx","UpArrowIcon","DownArrowIcon","portalContainer","menuClassName","AccountMenuItem","useContext","Comp","asChild","Slot","href","disabled","onClick","icon","Slottable","AccountMenuSeparator"],"sources":["../../../src/components/AccountMenu/AccountMenu.tsx"],"sourcesContent":["import * as Popover from '@radix-ui/react-popover';\nimport { Slot, Slottable } from '@radix-ui/react-slot';\nimport {\n createContext,\n forwardRef,\n useContext,\n useId,\n useRef,\n useState,\n type AnchorHTMLAttributes,\n type ButtonHTMLAttributes,\n type ElementType,\n type HTMLAttributes,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n} from 'react';\nimport { DownArrowIcon, UpArrowIcon } from '../../icons';\nimport { cn } from '../../utils/cn';\nimport './AccountMenu.css';\n\nconst AccountMenuContext = createContext<{ close: () => void } | null>(null);\n\nexport interface AccountMenuProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'name'> {\n /** Text next to the avatar, usually the first name (\"Anna\"). */\n name?: ReactNode;\n /** One or two letters shown in the avatar when there is no picture (\"AP\"). */\n initials?: string;\n /** Picture for the avatar. It is decorative: the button is named by `name` / `aria-label`. */\n avatarSrc?: string;\n /** Replaces the whole avatar (32px), e.g. with an `AgencyLogo`. */\n avatar?: ReactNode;\n /** First line of the menu header, usually the full name (\"Anna Petrosyan\"). */\n heading?: ReactNode;\n /** Second line of the menu header, usually the e-mail address. */\n description?: ReactNode;\n /** The menu: `AccountMenuItem`s and `AccountMenuSeparator`s. */\n children?: ReactNode;\n /** Avatar-only trigger without the pill, as in the mobile header. Inside a collapsed `PortalHeader` this happens by itself. */\n compact?: boolean;\n /** Accessible name of the button and its menu. Defaults to `name` when that is a string; required otherwise. */\n 'aria-label'?: string;\n /** Whether the menu is open (controlled; Figma \"State=Open\"). */\n open?: boolean;\n /** Opens the menu initially (uncontrolled). */\n defaultOpen?: boolean;\n /** Called when the menu opens or closes. */\n onOpenChange?: (open: boolean) => void;\n /**\n * How the menu lines up with the button. Figma centres it under the button (`center`, the default); near the edge of\n * the screen it shifts to stay 8px inside the viewport.\n */\n align?: 'start' | 'center' | 'end';\n /** Element the menu is rendered into (default `document.body`). Set it when the theme is scoped to a container. */\n portalContainer?: HTMLElement | null;\n /** Class for the menu panel, which is rendered in a portal outside the button. */\n menuClassName?: string;\n}\n\nconst itemsOf = (menu: HTMLElement | null) =>\n menu ? Array.from(menu.querySelectorAll<HTMLElement>('[role=\"menuitem\"]:not([aria-disabled=\"true\"]):not(:disabled)')) : [];\n\n/**\n * Figma component set \"Account menu\": the avatar pill of the header and the menu it opens.\n * A menu button — Enter, Space or the arrow keys open it; arrows, Home, End and typing a letter move between the items;\n * Escape and Tab close it and return focus to the button. The ref and the remaining props go to the button.\n */\nexport const AccountMenu = /* @__PURE__ */ forwardRef<HTMLButtonElement, AccountMenuProps>(function AccountMenu(\n {\n name,\n initials,\n avatarSrc,\n avatar,\n heading,\n description,\n children,\n compact = false,\n 'aria-label': ariaLabel,\n open,\n defaultOpen = false,\n onOpenChange,\n align = 'center',\n portalContainer,\n menuClassName,\n className,\n onKeyDown,\n ...props\n },\n ref,\n) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n const isOpen = open ?? uncontrolledOpen;\n const setOpen = (next: boolean) => {\n if (open === undefined) setUncontrolledOpen(next);\n onOpenChange?.(next);\n };\n\n const menuRef = useRef<HTMLDivElement>(null);\n /** Which item takes focus when the menu opens: the last one after ArrowUp on the button, otherwise the first. */\n const focusOnOpen = useRef<'first' | 'last'>('first');\n const typed = useRef({ text: '', at: 0 });\n const label = ariaLabel ?? (typeof name === 'string' ? name : undefined);\n const hasHeader = (heading != null && heading !== false) || (description != null && description !== false);\n const headingId = `tm-${useId()}`;\n\n const handleTriggerKeys = (event: KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(event);\n if (event.defaultPrevented || isOpen) return;\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n focusOnOpen.current = event.key === 'ArrowUp' ? 'last' : 'first';\n setOpen(true);\n }\n };\n\n const handleMenuKeys = (event: KeyboardEvent<HTMLDivElement>) => {\n const items = itemsOf(menuRef.current);\n const current = items.indexOf(document.activeElement as HTMLElement);\n const focus = (index: number) => items[(index + items.length) % items.length]?.focus();\n\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n focus(current + 1);\n break;\n case 'ArrowUp':\n event.preventDefault();\n focus(current === -1 ? items.length - 1 : current - 1);\n break;\n case 'Home':\n event.preventDefault();\n focus(0);\n break;\n case 'End':\n event.preventDefault();\n focus(items.length - 1);\n break;\n case 'Tab':\n // A menu is one tab stop: Tab leaves it, back to the button.\n event.preventDefault();\n setOpen(false);\n break;\n default:\n // Type-ahead: letters typed in quick succession jump to the item that starts with them.\n if (event.key.length === 1 && event.key !== ' ' && !event.ctrlKey && !event.metaKey && !event.altKey) {\n const now = Date.now();\n const text = (now - typed.current.at > 600 ? '' : typed.current.text) + event.key.toLocaleLowerCase();\n typed.current = { text, at: now };\n // A first letter looks from the next item on (so repeating it cycles); further letters refine from the current one.\n const start = Math.max(0, current + (text.length === 1 ? 1 : 0));\n const ordered = [...items.slice(start), ...items.slice(0, start)];\n ordered.find((item) => (item.textContent ?? '').trim().toLocaleLowerCase().startsWith(text))?.focus();\n }\n }\n };\n\n return (\n <Popover.Root\n open={isOpen}\n onOpenChange={(next) => {\n if (next) focusOnOpen.current = 'first';\n setOpen(next);\n }}\n >\n <Popover.Trigger asChild>\n <button\n ref={ref}\n type=\"button\"\n className={cn('tm-account-menu__trigger', className)}\n data-compact={compact ? '' : undefined}\n aria-label={label}\n {...props}\n aria-haspopup=\"menu\"\n onKeyDown={handleTriggerKeys}\n >\n <span className=\"tm-account-menu__avatar\" aria-hidden=\"true\">\n {avatar ?? (avatarSrc ? <img className=\"tm-account-menu__avatar-image\" src={avatarSrc} alt=\"\" /> : initials)}\n </span>\n {name != null && name !== false ? <span className=\"tm-account-menu__name\">{name}</span> : null}\n {isOpen ? <UpArrowIcon size=\"sm\" className=\"tm-account-menu__chevron\" /> : <DownArrowIcon size=\"sm\" className=\"tm-account-menu__chevron\" />}\n </button>\n </Popover.Trigger>\n <Popover.Portal container={portalContainer}>\n <Popover.Content\n // The popover is only the surface; the menu inside it carries the semantics.\n role=\"presentation\"\n className={cn('tm-account-menu__panel', menuClassName)}\n align={align}\n sideOffset={8}\n collisionPadding={8}\n onOpenAutoFocus={(event) => {\n event.preventDefault();\n const items = itemsOf(menuRef.current);\n (focusOnOpen.current === 'last' ? items[items.length - 1] : items[0])?.focus();\n focusOnOpen.current = 'first';\n }}\n >\n {hasHeader ? (\n <div className=\"tm-account-menu__header\" id={headingId}>\n {heading != null && heading !== false ? <span className=\"tm-account-menu__heading\">{heading}</span> : null}\n {description != null && description !== false ? <span className=\"tm-account-menu__description\">{description}</span> : null}\n </div>\n ) : null}\n {hasHeader ? <div className=\"tm-account-menu__separator\" aria-hidden=\"true\" /> : null}\n <AccountMenuContext.Provider value={{ close: () => setOpen(false) }}>\n <div\n ref={menuRef}\n role=\"menu\"\n aria-label={label}\n aria-describedby={hasHeader ? headingId : undefined}\n aria-orientation=\"vertical\"\n className=\"tm-account-menu__menu\"\n data-tm-icon-size=\"md\"\n onKeyDown={handleMenuKeys}\n >\n {children}\n </div>\n </AccountMenuContext.Provider>\n </Popover.Content>\n </Popover.Portal>\n </Popover.Root>\n );\n});\n\nexport interface AccountMenuItemProps\n extends HTMLAttributes<HTMLElement>,\n Pick<AnchorHTMLAttributes<HTMLAnchorElement>, 'href' | 'target' | 'rel'> {\n /** Icon before the label (20px, any icon from `@travel-match/ui`). */\n icon?: ReactNode;\n /** Greys the item out and skips it with the keyboard. */\n disabled?: boolean;\n /** Renders the single child element (e.g. a router `<Link>`) as the item instead of an `<a>` / `<button>`. */\n asChild?: boolean;\n}\n\n/**\n * One entry of `AccountMenu` (Figma \"Item / …\"): a link with `href` (or `asChild`), otherwise a button.\n * Choosing it closes the menu; call `event.preventDefault()` in `onClick` to keep the menu open.\n */\nexport const AccountMenuItem = /* @__PURE__ */ forwardRef<HTMLElement, AccountMenuItemProps>(function AccountMenuItem(\n { icon, disabled = false, asChild = false, href, className, children, onClick, onKeyDown, ...props },\n ref,\n) {\n const menu = useContext(AccountMenuContext);\n const Comp: ElementType = asChild ? Slot : href !== undefined ? 'a' : 'button';\n\n const handleClick = (event: MouseEvent<HTMLElement>) => {\n if (disabled) {\n event.preventDefault();\n return;\n }\n onClick?.(event);\n if (!event.defaultPrevented) menu?.close();\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLElement>) => {\n onKeyDown?.(event);\n // Links activate on Enter only; in a menu Space has to work as well.\n if (!event.defaultPrevented && event.key === ' ' && event.currentTarget.tagName !== 'BUTTON') {\n event.preventDefault();\n event.currentTarget.click();\n }\n };\n\n return (\n <Comp\n ref={ref}\n role=\"menuitem\"\n tabIndex={-1}\n className={cn('tm-account-menu__item', className)}\n href={Comp === 'a' && !disabled ? href : undefined}\n type={Comp === 'button' ? 'button' : undefined}\n aria-disabled={disabled || undefined}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n {...props}\n >\n {icon ? (\n <span className=\"tm-account-menu__item-icon\" aria-hidden=\"true\">\n {icon}\n </span>\n ) : null}\n <Slottable>{children}</Slottable>\n </Comp>\n );\n});\n\n/** The 1px rule between groups of `AccountMenuItem`s (Figma \"Divider\"). */\nexport const AccountMenuSeparator = /* @__PURE__ */ forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(function AccountMenuSeparator(\n { className, ...props },\n ref,\n) {\n return <div ref={ref} role=\"separator\" className={cn('tm-account-menu__separator', className)} {...props} />;\n});\n"],"mappings":";;;;;;;;;;AAqBA,IAAMC,IAAqBC,EAA4C,IAAI,GAsCrEC,KAAW,MACfC,IAAO,MAAM,KAAKA,EAAK,iBAA8B,kEAA8D,CAAC,IAAI,CAAC,GAO9GC,IAA8B,kBAAgD,SACzF,EACE,SACA,aACA,cACA,WACA,YACA,gBACA,aACA,a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AkB,GACpCoD,IAAoBC,IAAUC,IAAOC,MAAS,KAAA,IAAkB,WAAN;CAoBhE,OACE,kBAACH,GAAD;EACO;EACL,MAAK;EACL,UAAU;EACV,WAAWb,EAAG,yBAAyBC,CAAS;EAChD,MAAMY,MAAS,OAAO,CAACI,IAAWD,IAAO,KAAA;EACzC,MAAMH,MAAS,WAAW,WAAW,KAAA;EACrC,iBAAeI,KAAY,KAAA;EAC3B,UA3BiB,MAAmC;GACtD,AAAIA,IACF3B,EAAM,eAAe,KAGvB4B,IAAU5B,CAAK,GACVA,EAAM,oBAAkB1B,GAAM,MAAM;EAC3C;EAqBI,YAnBmB,MAAsC;GAG3D,AAFAyB,IAAYC,CAAK,GAEb,CAACA,EAAM,oBAAoBA,EAAM,QAAQ,OAAOA,EAAM,cAAc,YAAY,aAClFA,EAAM,eAAe,GACrBA,EAAM,cAAc,MAAM;EAE9B;EAaI,GAAIvB;EAVN,UAAA,CAYGoD,IACC,kBAAC,QAAD;GAAM,WAAU;GAA6B,eAAY;GACtD,UAAAA;EACG,CAAA,IACJ,MACJ,kBAACC,GAAD,EAAY,YAAoB,CAAA,CAC5B;;AAEV,CAAC,GAGYC,IAAuC,kBAA2D,SAC7G,EAAE,cAAW,GAAGtD,KAChB,GACA;CACA,OAAO,kBAAC,OAAD;EAAU;EAAK,MAAK;EAAY,WAAWiC,EAAG,8BAA8BC,CAAS;EAAG,GAAIlC;CAAQ,CAAA;AAC7G,CAAC"}
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../utils/cn.cjs"),t=require("../Button/Button.cjs"),n=require("../Dialog/Dialog.cjs");;/* empty css */let r=require("react"),i=require("react/jsx-runtime");var a=e=>typeof e==`object`&&!!e&&typeof e.then==`function`,o=(0,r.forwardRef)(function({tone:o=`default`,confirmLabel:s,cancelLabel:c=`Cancel`,secondaryLabel:l,onConfirm:u,onCancel:d,onSecondary:f,loading:p=!1,closeOnConfirm:m=!0,open:h,defaultOpen:g=!1,onOpenChange:_,placement:v=`auto`,mobilePlacement:y=`sheet`,className:b,...x},S){let[C,w]=(0,r.useState)(g),T=h??C,[E,D]=(0,r.useState)(!1),O=(0,r.useRef)(!1),k=(0,r.useRef)(null),A=(0,r.useRef)(null),j=n.useDialogPlacement(v,y),M=p||E,N=o===`destructive`,P=l!=null&&l!==!1,F=e=>{h===void 0&&w(e),_?.(e)},I=e=>{if(!e){if(M||O.current)return;d?.()}F(e)},L=()=>{if(M||O.current)return;let e=u?.();if(a(e)){O.current=!0,D(!0);let t=()=>{O.current=!1,D(!1)};e.then(()=>{t(),m&&F(!1)},e=>{throw t(),e})}else m&&F(!1)},R=()=>{M||O.current||(f?.(),F(!1))},z=()=>I(!1),B=j===`sheet`?`ghost`:`outline`;return(0,i.jsx)(n.Dialog,{ref:S,className:e.cn(`tm-confirmation-dialog`,b),role:N?`alertdialog`:`dialog`,open:T,onOpenChange:I,placement:j,dismissible:!M,initialFocusRef:N?k:A,"data-tone":o,footer:(0,i.jsxs)(i.Fragment,{children:[P?(0,i.jsx)(t.Button,{ref:k,variant:`text`,disabled:M,onClick:z,children:c}):null,(0,i.jsx)(t.Button,{ref:P?void 0:k,className:`tm-confirmation-dialog__alternative`,variant:B,disabled:M,onClick:P?R:z,children:P?l:c}),(0,i.jsx)(t.Button,{ref:A,variant:N?`destructive`:`primary`,loading:M,onClick:L,children:s})]}),...x})});exports.ConfirmationDialog=o;
1
+ "use client";const e=require("../../utils/cn.cjs"),t=require("../Button/Button.cjs"),n=require("../Dialog/Dialog.cjs");;/* empty css */let r=require("react"),i=require("react/jsx-runtime");var a=e=>typeof e==`object`&&!!e&&typeof e.then==`function`,o=(0,r.forwardRef)(function({tone:o=`default`,confirmLabel:s,cancelLabel:c=`Cancel`,secondaryLabel:l,onConfirm:u,onCancel:d,onSecondary:f,loading:p=!1,closeOnConfirm:m=!0,open:h,defaultOpen:g=!1,onOpenChange:_,placement:v=`auto`,mobilePlacement:y=`sheet`,className:b,...x},S){let[C,w]=(0,r.useState)(g),T=h??C,[E,D]=(0,r.useState)(!1),O=(0,r.useRef)(!1),k=(0,r.useRef)(null),A=(0,r.useRef)(null),j=n.useDialogPlacement(v,y),M=p||E,N=o===`destructive`,P=l!=null&&l!==!1,F=e=>{h===void 0&&w(e),_?.(e)},I=e=>{if(!e){if(M||O.current)return;d?.()}F(e)},L=()=>{if(M||O.current)return;let e=u?.();if(a(e)){O.current=!0,D(!0);let t=()=>{O.current=!1,D(!1)};e.then(()=>{t(),m&&F(!1)},e=>{throw t(),e})}else m&&F(!1)},R=()=>{M||O.current||(f?.(),F(!1))},z=()=>I(!1),B=j===`sheet`?`ghost`:`outline`;return(0,i.jsx)(n.Dialog,{ref:S,className:e.cn(`tm-confirmation-dialog`,b),role:N?`alertdialog`:`dialog`,open:T,onOpenChange:I,placement:j,dismissible:!M,initialFocusRef:N?k:A,"data-tone":o,footer:(0,i.jsxs)(i.Fragment,{children:[P?(0,i.jsx)(t.Button,{ref:k,className:`tm-confirmation-dialog__dismiss`,variant:`text`,disabled:M,onClick:z,children:c}):null,(0,i.jsx)(t.Button,{ref:P?void 0:k,className:`tm-confirmation-dialog__alternative`,variant:B,disabled:M,onClick:P?R:z,children:P?l:c}),(0,i.jsx)(t.Button,{ref:A,variant:N?`destructive`:`primary`,loading:M,onClick:L,children:s})]}),...x})});exports.ConfirmationDialog=o;
2
2
  //# sourceMappingURL=ConfirmationDialog.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConfirmationDialog.cjs","names":["useState","useRef","useDialogPlacement","Dialog","cn","_Fragment","Button","require_cn","require_Button","require_Dialog","react","react_jsx_runtime","isThenable","value","ConfirmationDialog","openProp","props","uncontrolledOpen","setUncontrolledOpen","defaultOpen","open","pending","setPending","pendingRef","cancelRef","confirmRef","resolvedPlacement","placement","mobilePlacement","busy","loading","destructive","tone","hasSecondary","secondaryLabel","setOpen","next","onOpenChange","handleOpenChange","onCancel","handleConfirm","result","onConfirm","settle","closeOnConfirm","error","handleSecondary","onSecondary","dismiss","alternativeVariant","className","cancelLabel","confirmLabel"],"sources":["../../../src/components/ConfirmationDialog/ConfirmationDialog.tsx"],"sourcesContent":["import { forwardRef, useRef, useState, type ReactNode } from 'react';\nimport { cn } from '../../utils/cn';\nimport { Button } from '../Button';\nimport { Dialog, useDialogPlacement, type DialogProps } from '../Dialog';\nimport './ConfirmationDialog.css';\n\n/** `destructive` — the confirm action removes something (Figma \"Type=Remove segment\"); `default` — every other Figma type. */\nexport type ConfirmationDialogTone = 'default' | 'destructive';\n\nexport interface ConfirmationDialogProps\n extends Omit<DialogProps, 'footer' | 'size' | 'role' | 'eyebrow' | 'dismissible' | 'initialFocusRef' | 'hideCloseButton'> {\n /** `destructive` uses the destructive Button, the `alertdialog` role and puts the initial focus on the cancel button. */\n tone?: ConfirmationDialogTone;\n /** Label of the confirming button (Figma \"Save draft\", \"Switch to One-way\", \"Remove flight\", \"Sign out\"). */\n confirmLabel: ReactNode;\n /** Label of the button that dismisses the dialog (Figma \"Cancel\", \"Keep Round trip\", \"Stay\") — translate it. */\n cancelLabel?: ReactNode;\n /**\n * Label of an alternative action between cancel and confirm (Figma \"Type=Unsaved changes\": \"Leave without saving\").\n * When set, the cancel button becomes a text button, as in Figma.\n */\n secondaryLabel?: ReactNode;\n /**\n * Called when the confirm button is pressed. Return a promise to keep the dialog open with the button loading until it settles:\n * it closes when the promise resolves and stays open when it rejects (the rejection is not swallowed).\n */\n onConfirm?: () => void | PromiseLike<unknown>;\n /** Called when the dialog is dismissed: cancel button, close button, Escape or a click on the overlay. */\n onCancel?: () => void;\n /** Called when the alternative action is pressed; the dialog then closes. */\n onSecondary?: () => void;\n /** Shows the confirm button as loading; while loading nothing can be triggered twice and the dialog cannot be dismissed. */\n loading?: boolean;\n /** `false` leaves closing after `onConfirm` to the app (control `open` yourself). */\n closeOnConfirm?: boolean;\n}\n\nconst isThenable = (value: unknown): value is PromiseLike<unknown> =>\n typeof value === 'object' && value !== null && typeof (value as PromiseLike<unknown>).then === 'function';\n\n/**\n * Asks the user to confirm or cancel one action (Figma component set \"Confirmation Dialog\").\n * A centered dialog on desktop, a bottom sheet with stacked buttons below 768px.\n */\nexport const ConfirmationDialog = /* @__PURE__ */ forwardRef<HTMLDivElement, ConfirmationDialogProps>(function ConfirmationDialog(\n {\n tone = 'default',\n confirmLabel,\n cancelLabel = 'Cancel',\n secondaryLabel,\n onConfirm,\n onCancel,\n onSecondary,\n loading = false,\n closeOnConfirm = true,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n placement = 'auto',\n mobilePlacement = 'sheet',\n className,\n ...props\n },\n ref,\n) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n const open = openProp ?? uncontrolledOpen;\n const [pending, setPending] = useState(false);\n // Guards the gap between a click and the re-render that shows the loading state.\n const pendingRef = useRef(false);\n const cancelRef = useRef<HTMLButtonElement>(null);\n const confirmRef = useRef<HTMLButtonElement>(null);\n const resolvedPlacement = useDialogPlacement(placement, mobilePlacement);\n\n const busy = loading || pending;\n const destructive = tone === 'destructive';\n const hasSecondary = secondaryLabel != null && secondaryLabel !== false;\n\n const setOpen = (next: boolean) => {\n if (openProp === undefined) setUncontrolledOpen(next);\n onOpenChange?.(next);\n };\n\n // Everything that closes the dialog without confirming goes through here (cancel, close button, Escape, overlay).\n const handleOpenChange = (next: boolean) => {\n if (!next) {\n if (busy || pendingRef.current) return;\n onCancel?.();\n }\n setOpen(next);\n };\n\n const handleConfirm = () => {\n if (busy || pendingRef.current) return;\n const result = onConfirm?.();\n if (isThenable(result)) {\n pendingRef.current = true;\n setPending(true);\n const settle = () => {\n pendingRef.current = false;\n setPending(false);\n };\n result.then(\n () => {\n settle();\n if (closeOnConfirm) setOpen(false);\n },\n (error: unknown) => {\n settle();\n throw error;\n },\n );\n } else if (closeOnConfirm) {\n setOpen(false);\n }\n };\n\n const handleSecondary = () => {\n if (busy || pendingRef.current) return;\n onSecondary?.();\n setOpen(false);\n };\n\n const dismiss = () => handleOpenChange(false);\n // Figma: the outlined button of the dialog is a ghost button in the sheet, placed after the confirm button (see the CSS).\n const alternativeVariant = resolvedPlacement === 'sheet' ? 'ghost' : 'outline';\n\n return (\n <Dialog\n ref={ref}\n className={cn('tm-confirmation-dialog', className)}\n role={destructive ? 'alertdialog' : 'dialog'}\n open={open}\n onOpenChange={handleOpenChange}\n placement={resolvedPlacement}\n dismissible={!busy}\n initialFocusRef={destructive ? cancelRef : confirmRef}\n data-tone={tone}\n footer={\n <>\n {hasSecondary ? (\n <Button ref={cancelRef} variant=\"text\" disabled={busy} onClick={dismiss}>\n {cancelLabel}\n </Button>\n ) : null}\n <Button\n ref={hasSecondary ? undefined : cancelRef}\n className=\"tm-confirmation-dialog__alternative\"\n variant={alternativeVariant}\n disabled={busy}\n onClick={hasSecondary ? handleSecondary : dismiss}\n >\n {hasSecondary ? secondaryLabel : cancelLabel}\n </Button>\n <Button ref={confirmRef} variant={destructive ? 'destructive' : 'primary'} loading={busy} onClick={handleConfirm}>\n {confirmLabel}\n </Button>\n </>\n }\n {...props}\n />\n );\n});\n"],"mappings":"A,qNAqCA,IAAMY,EAAc,GAClB,OAAOC,GAAU,YAAYA,GAAkB,OAAQA,EAA+B,MAAS,WAMpFC,GAAqC,EAAAJ,EAAA,WAAA,CAAoD,SACpG,CACE,OAAO,UACP,eACA,cAAc,SACd,iBACA,YACA,WACA,cACA,UAAU,GACV,iBAAiB,GACjB,KAAMK,EACN,cAAc,GACd,eACA,YAAY,OACZ,kBAAkB,QAClB,YACA,GAAGC,GAEL,EACA,CACA,GAAM,CAACC,EAAkBC,IAAA,EAAuBlB,EAAAA,SAAAA,CAASmB,CAAW,EAC9DC,EAAOL,GAAYE,EACnB,CAACI,EAASC,IAAA,EAActB,EAAAA,SAAAA,CAAS,EAAK,EAEtCuB,GAAA,EAAatB,EAAAA,OAAAA,CAAO,EAAK,EACzBuB,GAAA,EAAYvB,EAAAA,OAAAA,CAA0B,IAAI,EAC1CwB,GAAA,EAAaxB,EAAAA,OAAAA,CAA0B,IAAI,EAC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7D,SAAAG,CACK,CAAA,EACN,MACJ,EAAAxC,EAAA,IAAA,CAACL,EAAAA,OAAD,CACE,IAAK2B,EAAe,IAAA,GAAYT,EAChC,UAAU,sCACV,QAASyB,EACT,SAAUpB,EACV,QAASI,EAAea,EAAkBE,EAEzC,SAAAf,EAAeC,EAAiBiB,CAC3B,CAAA,GACR,EAAAxC,EAAA,IAAA,CAACL,EAAAA,OAAD,CAAQ,IAAKmB,EAAY,QAASM,EAAc,cAAgB,UAAW,QAASF,EAAM,QAASW,EAChG,SAAAY,CACK,CAAA,CACR,CAAA,CAAA,EAEJ,GAAIpC,CACL,CAAA,CAEL,CAAC,E"}
1
+ {"version":3,"file":"ConfirmationDialog.cjs","names":["useState","useRef","useDialogPlacement","Dialog","cn","_Fragment","Button","require_cn","require_Button","require_Dialog","react","react_jsx_runtime","isThenable","value","ConfirmationDialog","openProp","props","uncontrolledOpen","setUncontrolledOpen","defaultOpen","open","pending","setPending","pendingRef","cancelRef","confirmRef","resolvedPlacement","placement","mobilePlacement","busy","loading","destructive","tone","hasSecondary","secondaryLabel","setOpen","next","onOpenChange","handleOpenChange","onCancel","handleConfirm","result","onConfirm","settle","closeOnConfirm","error","handleSecondary","onSecondary","dismiss","alternativeVariant","className","cancelLabel","confirmLabel"],"sources":["../../../src/components/ConfirmationDialog/ConfirmationDialog.tsx"],"sourcesContent":["import { forwardRef, useRef, useState, type ReactNode } from 'react';\nimport { cn } from '../../utils/cn';\nimport { Button } from '../Button';\nimport { Dialog, useDialogPlacement, type DialogProps } from '../Dialog';\nimport './ConfirmationDialog.css';\n\n/** `destructive` — the confirm action removes something (Figma \"Type=Remove segment\"); `default` — every other Figma type. */\nexport type ConfirmationDialogTone = 'default' | 'destructive';\n\nexport interface ConfirmationDialogProps\n extends Omit<DialogProps, 'footer' | 'size' | 'role' | 'eyebrow' | 'dismissible' | 'initialFocusRef' | 'hideCloseButton'> {\n /** `destructive` uses the destructive Button, the `alertdialog` role and puts the initial focus on the cancel button. */\n tone?: ConfirmationDialogTone;\n /** Label of the confirming button (Figma \"Save draft\", \"Switch to One-way\", \"Remove flight\", \"Sign out\"). */\n confirmLabel: ReactNode;\n /** Label of the button that dismisses the dialog (Figma \"Cancel\", \"Keep Round trip\", \"Stay\") — translate it. */\n cancelLabel?: ReactNode;\n /**\n * Label of an alternative action between cancel and confirm (Figma \"Type=Unsaved changes\": \"Leave without saving\").\n * When set, the cancel button becomes a text button, as in Figma.\n */\n secondaryLabel?: ReactNode;\n /**\n * Called when the confirm button is pressed. Return a promise to keep the dialog open with the button loading until it settles:\n * it closes when the promise resolves and stays open when it rejects (the rejection is not swallowed).\n */\n onConfirm?: () => void | PromiseLike<unknown>;\n /** Called when the dialog is dismissed: cancel button, close button, Escape or a click on the overlay. */\n onCancel?: () => void;\n /** Called when the alternative action is pressed; the dialog then closes. */\n onSecondary?: () => void;\n /** Shows the confirm button as loading; while loading nothing can be triggered twice and the dialog cannot be dismissed. */\n loading?: boolean;\n /** `false` leaves closing after `onConfirm` to the app (control `open` yourself). */\n closeOnConfirm?: boolean;\n}\n\nconst isThenable = (value: unknown): value is PromiseLike<unknown> =>\n typeof value === 'object' && value !== null && typeof (value as PromiseLike<unknown>).then === 'function';\n\n/**\n * Asks the user to confirm or cancel one action (Figma component set \"Confirmation Dialog\").\n * A centered dialog on desktop, a bottom sheet with stacked buttons below 768px.\n */\nexport const ConfirmationDialog = /* @__PURE__ */ forwardRef<HTMLDivElement, ConfirmationDialogProps>(function ConfirmationDialog(\n {\n tone = 'default',\n confirmLabel,\n cancelLabel = 'Cancel',\n secondaryLabel,\n onConfirm,\n onCancel,\n onSecondary,\n loading = false,\n closeOnConfirm = true,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n placement = 'auto',\n mobilePlacement = 'sheet',\n className,\n ...props\n },\n ref,\n) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n const open = openProp ?? uncontrolledOpen;\n const [pending, setPending] = useState(false);\n // Guards the gap between a click and the re-render that shows the loading state.\n const pendingRef = useRef(false);\n const cancelRef = useRef<HTMLButtonElement>(null);\n const confirmRef = useRef<HTMLButtonElement>(null);\n const resolvedPlacement = useDialogPlacement(placement, mobilePlacement);\n\n const busy = loading || pending;\n const destructive = tone === 'destructive';\n const hasSecondary = secondaryLabel != null && secondaryLabel !== false;\n\n const setOpen = (next: boolean) => {\n if (openProp === undefined) setUncontrolledOpen(next);\n onOpenChange?.(next);\n };\n\n // Everything that closes the dialog without confirming goes through here (cancel, close button, Escape, overlay).\n const handleOpenChange = (next: boolean) => {\n if (!next) {\n if (busy || pendingRef.current) return;\n onCancel?.();\n }\n setOpen(next);\n };\n\n const handleConfirm = () => {\n if (busy || pendingRef.current) return;\n const result = onConfirm?.();\n if (isThenable(result)) {\n pendingRef.current = true;\n setPending(true);\n const settle = () => {\n pendingRef.current = false;\n setPending(false);\n };\n result.then(\n () => {\n settle();\n if (closeOnConfirm) setOpen(false);\n },\n (error: unknown) => {\n settle();\n throw error;\n },\n );\n } else if (closeOnConfirm) {\n setOpen(false);\n }\n };\n\n const handleSecondary = () => {\n if (busy || pendingRef.current) return;\n onSecondary?.();\n setOpen(false);\n };\n\n const dismiss = () => handleOpenChange(false);\n // Figma: the outlined button of the dialog is a ghost button in the sheet, placed after the confirm button (see the CSS).\n const alternativeVariant = resolvedPlacement === 'sheet' ? 'ghost' : 'outline';\n\n return (\n <Dialog\n ref={ref}\n className={cn('tm-confirmation-dialog', className)}\n role={destructive ? 'alertdialog' : 'dialog'}\n open={open}\n onOpenChange={handleOpenChange}\n placement={resolvedPlacement}\n dismissible={!busy}\n initialFocusRef={destructive ? cancelRef : confirmRef}\n data-tone={tone}\n footer={\n <>\n {hasSecondary ? (\n <Button ref={cancelRef} className=\"tm-confirmation-dialog__dismiss\" variant=\"text\" disabled={busy} onClick={dismiss}>\n {cancelLabel}\n </Button>\n ) : null}\n <Button\n ref={hasSecondary ? undefined : cancelRef}\n className=\"tm-confirmation-dialog__alternative\"\n variant={alternativeVariant}\n disabled={busy}\n onClick={hasSecondary ? handleSecondary : dismiss}\n >\n {hasSecondary ? secondaryLabel : cancelLabel}\n </Button>\n <Button ref={confirmRef} variant={destructive ? 'destructive' : 'primary'} loading={busy} onClick={handleConfirm}>\n {confirmLabel}\n </Button>\n </>\n }\n {...props}\n />\n );\n});\n"],"mappings":"A,qNAqCA,IAAMY,EAAc,GAClB,OAAOC,GAAU,YAAYA,GAAkB,OAAQA,EAA+B,MAAS,WAMpFC,GAAqC,EAAAJ,EAAA,WAAA,CAAoD,SACpG,CACE,OAAO,UACP,eACA,cAAc,SACd,iBACA,YACA,WACA,cACA,UAAU,GACV,iBAAiB,GACjB,KAAMK,EACN,cAAc,GACd,eACA,YAAY,OACZ,kBAAkB,QAClB,YACA,GAAGC,GAEL,EACA,CACA,GAAM,CAACC,EAAkBC,IAAA,EAAuBlB,EAAAA,SAAAA,CAASmB,CAAW,EAC9DC,EAAOL,GAAYE,EACnB,CAACI,EAASC,IAAA,EAActB,EAAAA,SAAAA,CAAS,EAAK,EAEtCuB,GAAA,EAAatB,EAAAA,OAAAA,CAAO,EAAK,EACzBuB,GAAA,EAAYvB,EAAAA,OAAAA,CAA0B,IAAI,EAC1CwB,GAAA,EAAaxB,EAAAA,OAAAA,CAA0B,IAAI,EAC3CyB,EAAoBxB,EAAAA,mBAAmByB,EAAWC,CAAe,EAEjEC,EAAOC,GAAWT,EAClBU,EAAcC,IAAS,cACvBC,EAAeC,GAAkB,MAAQA,IAAmB,GAE5DC,EAAW,GAAkB,CAC7BpB,IAAa,IAAA,IAAWG,EAAoBkB,CAAI,EACpDC,IAAeD,CAAI,CACrB,EAGME,EAAoB,GAAkB,CAC1C,GAAI,CAACF,EAAM,CACT,GAAIP,GAAQN,EAAW,QAAS,OAChCgB,IAAW,CACb,CACAJ,EAAQC,CAAI,CACd,EAEMI,MAAsB,CAC1B,GAAIX,GAAQN,EAAW,QAAS,OAChC,IAAMkB,EAASC,IAAY,EAC3B,GAAI9B,EAAW6B,CA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u = (e) => typeof e == "object" && !!e && typeof e.then == "function", d = /
45
45
  footer: /* @__PURE__ */ l(s, { children: [
46
46
  R ? /* @__PURE__ */ c(t, {
47
47
  ref: N,
48
+ className: "tm-confirmation-dialog__dismiss",
48
49
  variant: "text",
49
50
  disabled: I,
50
51
  onClick: U,
@@ -1 +1 @@
1
- {"version":3,"file":"ConfirmationDialog.js","names":["_Fragment","Fragment$1","isThenable","value","ConfirmationDialog","openProp","props","uncontrolledOpen","setUncontrolledOpen","useState","defaultOpen","open","pending","setPending","pendingRef","useRef","cancelRef","confirmRef","resolvedPlacement","useDialogPlacement","placement","mobilePlacement","busy","loading","destructive","tone","hasSecondary","secondaryLabel","setOpen","next","onOpenChange","handleOpenChange","handleConfirm","result","onConfirm","settle","closeOnConfirm","error","handleSecondary","onSecondary","dismiss","alternativeVariant","Dialog","cn","className","Button","cancelLabel","confirmLabel"],"sources":["../../../src/components/ConfirmationDialog/ConfirmationDialog.tsx"],"sourcesContent":["import { forwardRef, useRef, useState, type ReactNode } from 'react';\nimport { cn } from '../../utils/cn';\nimport { Button } from '../Button';\nimport { Dialog, useDialogPlacement, type DialogProps } from '../Dialog';\nimport './ConfirmationDialog.css';\n\n/** `destructive` — the confirm action removes something (Figma \"Type=Remove segment\"); `default` — every other Figma type. */\nexport type ConfirmationDialogTone = 'default' | 'destructive';\n\nexport interface ConfirmationDialogProps\n extends Omit<DialogProps, 'footer' | 'size' | 'role' | 'eyebrow' | 'dismissible' | 'initialFocusRef' | 'hideCloseButton'> {\n /** `destructive` uses the destructive Button, the `alertdialog` role and puts the initial focus on the cancel button. */\n tone?: ConfirmationDialogTone;\n /** Label of the confirming button (Figma \"Save draft\", \"Switch to One-way\", \"Remove flight\", \"Sign out\"). */\n confirmLabel: ReactNode;\n /** Label of the button that dismisses the dialog (Figma \"Cancel\", \"Keep Round trip\", \"Stay\") — translate it. */\n cancelLabel?: ReactNode;\n /**\n * Label of an alternative action between cancel and confirm (Figma \"Type=Unsaved changes\": \"Leave without saving\").\n * When set, the cancel button becomes a text button, as in Figma.\n */\n secondaryLabel?: ReactNode;\n /**\n * Called when the confirm button is pressed. Return a promise to keep the dialog open with the button loading until it settles:\n * it closes when the promise resolves and stays open when it rejects (the rejection is not swallowed).\n */\n onConfirm?: () => void | PromiseLike<unknown>;\n /** Called when the dialog is dismissed: cancel button, close button, Escape or a click on the overlay. */\n onCancel?: () => void;\n /** Called when the alternative action is pressed; the dialog then closes. */\n onSecondary?: () => void;\n /** Shows the confirm button as loading; while loading nothing can be triggered twice and the dialog cannot be dismissed. */\n loading?: boolean;\n /** `false` leaves closing after `onConfirm` to the app (control `open` yourself). */\n closeOnConfirm?: boolean;\n}\n\nconst isThenable = (value: unknown): value is PromiseLike<unknown> =>\n typeof value === 'object' && value !== null && typeof (value as PromiseLike<unknown>).then === 'function';\n\n/**\n * Asks the user to confirm or cancel one action (Figma component set \"Confirmation Dialog\").\n * A centered dialog on desktop, a bottom sheet with stacked buttons below 768px.\n */\nexport const ConfirmationDialog = /* @__PURE__ */ forwardRef<HTMLDivElement, ConfirmationDialogProps>(function ConfirmationDialog(\n {\n tone = 'default',\n confirmLabel,\n cancelLabel = 'Cancel',\n secondaryLabel,\n onConfirm,\n onCancel,\n onSecondary,\n loading = false,\n closeOnConfirm = true,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n placement = 'auto',\n mobilePlacement = 'sheet',\n className,\n ...props\n },\n ref,\n) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n const open = openProp ?? uncontrolledOpen;\n const [pending, setPending] = useState(false);\n // Guards the gap between a click and the re-render that shows the loading state.\n const pendingRef = useRef(false);\n const cancelRef = useRef<HTMLButtonElement>(null);\n const confirmRef = useRef<HTMLButtonElement>(null);\n const resolvedPlacement = useDialogPlacement(placement, mobilePlacement);\n\n const busy = loading || pending;\n const destructive = tone === 'destructive';\n const hasSecondary = secondaryLabel != null && secondaryLabel !== false;\n\n const setOpen = (next: boolean) => {\n if (openProp === undefined) setUncontrolledOpen(next);\n onOpenChange?.(next);\n };\n\n // Everything that closes the dialog without confirming goes through here (cancel, close button, Escape, overlay).\n const handleOpenChange = (next: boolean) => {\n if (!next) {\n if (busy || pendingRef.current) return;\n onCancel?.();\n }\n setOpen(next);\n };\n\n const handleConfirm = () => {\n if (busy || pendingRef.current) return;\n const result = onConfirm?.();\n if (isThenable(result)) {\n pendingRef.current = true;\n setPending(true);\n const settle = () => {\n pendingRef.current = false;\n setPending(false);\n };\n result.then(\n () => {\n settle();\n if (closeOnConfirm) setOpen(false);\n },\n (error: unknown) => {\n settle();\n throw error;\n },\n );\n } else if (closeOnConfirm) {\n setOpen(false);\n }\n };\n\n const handleSecondary = () => {\n if (busy || pendingRef.current) return;\n onSecondary?.();\n setOpen(false);\n };\n\n const dismiss = () => handleOpenChange(false);\n // Figma: the outlined button of the dialog is a ghost button in the sheet, placed after the confirm button (see the CSS).\n const alternativeVariant = resolvedPlacement === 'sheet' ? 'ghost' : 'outline';\n\n return (\n <Dialog\n ref={ref}\n className={cn('tm-confirmation-dialog', className)}\n role={destructive ? 'alertdialog' : 'dialog'}\n open={open}\n onOpenChange={handleOpenChange}\n placement={resolvedPlacement}\n dismissible={!busy}\n initialFocusRef={destructive ? cancelRef : confirmRef}\n data-tone={tone}\n footer={\n <>\n {hasSecondary ? (\n <Button ref={cancelRef} variant=\"text\" disabled={busy} onClick={dismiss}>\n {cancelLabel}\n </Button>\n ) : null}\n <Button\n ref={hasSecondary ? undefined : cancelRef}\n className=\"tm-confirmation-dialog__alternative\"\n variant={alternativeVariant}\n disabled={busy}\n onClick={hasSecondary ? handleSecondary : dismiss}\n >\n {hasSecondary ? secondaryLabel : cancelLabel}\n </Button>\n <Button ref={confirmRef} variant={destructive ? 'destructive' : 'primary'} loading={busy} onClick={handleConfirm}>\n {confirmLabel}\n </Button>\n </>\n }\n {...props}\n />\n );\n});\n"],"mappings":";;;;;;;;AAqCA,IAAME,KAAc,MAClB,OAAOC,KAAU,cAAYA,KAA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EtCU,IAAqBvB,MAAsB,UAAU,UAAU;CAErE,OACE,kBAACwB,GAAD;EACO;EACL,WAAWC,EAAG,0BAA0BC,CAAS;EACjD,MAAMpB,IAAc,gBAAgB;EAC9B;EACN,cAAcO;EACd,WAAWb;EACX,aAAa,CAACI;EACd,iBAAiBE,IAAcR,IAAYC;EAC3C,aAAWQ;EACX,QACE,kBAAAzB,GAAA,EAAA,UAAA;GACG0B,IACC,kBAACmB,GAAD;IAAQ,KAAK7B;IAAW,SAAQ;IAAO,UAAUM;IAAM,SAASkB;IAC7D,UAAAM;GACK,CAAA,IACN;GACJ,kBAACD,GAAD;IACE,KAAKnB,IAAe,KAAA,IAAYV;IAChC,WAAU;IACV,SAASyB;IACT,UAAUnB;IACV,SAASI,IAAeY,IAAkBE;IAEzC,UAAAd,IAAeC,IAAiBmB;GAC3B,CAAA;GACR,kBAACD,GAAD;IAAQ,KAAK5B;IAAY,SAASO,IAAc,gBAAgB;IAAW,SAASF;IAAM,SAASU;IAChG,UAAAe;GACK,CAAA;EACR,EAAA,CAAA;EAEJ,GAAIzC;CACL,CAAA;AAEL,CAAC"}
1
+ {"version":3,"file":"ConfirmationDialog.js","names":["_Fragment","Fragment$1","isThenable","value","ConfirmationDialog","openProp","props","uncontrolledOpen","setUncontrolledOpen","useState","defaultOpen","open","pending","setPending","pendingRef","useRef","cancelRef","confirmRef","resolvedPlacement","useDialogPlacement","placement","mobilePlacement","busy","loading","destructive","tone","hasSecondary","secondaryLabel","setOpen","next","onOpenChange","handleOpenChange","handleConfirm","result","onConfirm","settle","closeOnConfirm","error","handleSecondary","onSecondary","dismiss","alternativeVariant","Dialog","cn","className","Button","cancelLabel","confirmLabel"],"sources":["../../../src/components/ConfirmationDialog/ConfirmationDialog.tsx"],"sourcesContent":["import { forwardRef, useRef, useState, type ReactNode } from 'react';\nimport { cn } from '../../utils/cn';\nimport { Button } from '../Button';\nimport { Dialog, useDialogPlacement, type DialogProps } from '../Dialog';\nimport './ConfirmationDialog.css';\n\n/** `destructive` — the confirm action removes something (Figma \"Type=Remove segment\"); `default` — every other Figma type. */\nexport type ConfirmationDialogTone = 'default' | 'destructive';\n\nexport interface ConfirmationDialogProps\n extends Omit<DialogProps, 'footer' | 'size' | 'role' | 'eyebrow' | 'dismissible' | 'initialFocusRef' | 'hideCloseButton'> {\n /** `destructive` uses the destructive Button, the `alertdialog` role and puts the initial focus on the cancel button. */\n tone?: ConfirmationDialogTone;\n /** Label of the confirming button (Figma \"Save draft\", \"Switch to One-way\", \"Remove flight\", \"Sign out\"). */\n confirmLabel: ReactNode;\n /** Label of the button that dismisses the dialog (Figma \"Cancel\", \"Keep Round trip\", \"Stay\") — translate it. */\n cancelLabel?: ReactNode;\n /**\n * Label of an alternative action between cancel and confirm (Figma \"Type=Unsaved changes\": \"Leave without saving\").\n * When set, the cancel button becomes a text button, as in Figma.\n */\n secondaryLabel?: ReactNode;\n /**\n * Called when the confirm button is pressed. Return a promise to keep the dialog open with the button loading until it settles:\n * it closes when the promise resolves and stays open when it rejects (the rejection is not swallowed).\n */\n onConfirm?: () => void | PromiseLike<unknown>;\n /** Called when the dialog is dismissed: cancel button, close button, Escape or a click on the overlay. */\n onCancel?: () => void;\n /** Called when the alternative action is pressed; the dialog then closes. */\n onSecondary?: () => void;\n /** Shows the confirm button as loading; while loading nothing can be triggered twice and the dialog cannot be dismissed. */\n loading?: boolean;\n /** `false` leaves closing after `onConfirm` to the app (control `open` yourself). */\n closeOnConfirm?: boolean;\n}\n\nconst isThenable = (value: unknown): value is PromiseLike<unknown> =>\n typeof value === 'object' && value !== null && typeof (value as PromiseLike<unknown>).then === 'function';\n\n/**\n * Asks the user to confirm or cancel one action (Figma component set \"Confirmation Dialog\").\n * A centered dialog on desktop, a bottom sheet with stacked buttons below 768px.\n */\nexport const ConfirmationDialog = /* @__PURE__ */ forwardRef<HTMLDivElement, ConfirmationDialogProps>(function ConfirmationDialog(\n {\n tone = 'default',\n confirmLabel,\n cancelLabel = 'Cancel',\n secondaryLabel,\n onConfirm,\n onCancel,\n onSecondary,\n loading = false,\n closeOnConfirm = true,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n placement = 'auto',\n mobilePlacement = 'sheet',\n className,\n ...props\n },\n ref,\n) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n const open = openProp ?? uncontrolledOpen;\n const [pending, setPending] = useState(false);\n // Guards the gap between a click and the re-render that shows the loading state.\n const pendingRef = useRef(false);\n const cancelRef = useRef<HTMLButtonElement>(null);\n const confirmRef = useRef<HTMLButtonElement>(null);\n const resolvedPlacement = useDialogPlacement(placement, mobilePlacement);\n\n const busy = loading || pending;\n const destructive = tone === 'destructive';\n const hasSecondary = secondaryLabel != null && secondaryLabel !== false;\n\n const setOpen = (next: boolean) => {\n if (openProp === undefined) setUncontrolledOpen(next);\n onOpenChange?.(next);\n };\n\n // Everything that closes the dialog without confirming goes through here (cancel, close button, Escape, overlay).\n const handleOpenChange = (next: boolean) => {\n if (!next) {\n if (busy || pendingRef.current) return;\n onCancel?.();\n }\n setOpen(next);\n };\n\n const handleConfirm = () => {\n if (busy || pendingRef.current) return;\n const result = onConfirm?.();\n if (isThenable(result)) {\n pendingRef.current = true;\n setPending(true);\n const settle = () => {\n pendingRef.current = false;\n setPending(false);\n };\n result.then(\n () => {\n settle();\n if (closeOnConfirm) setOpen(false);\n },\n (error: unknown) => {\n settle();\n throw error;\n },\n );\n } else if (closeOnConfirm) {\n setOpen(false);\n }\n };\n\n const handleSecondary = () => {\n if (busy || pendingRef.current) return;\n onSecondary?.();\n setOpen(false);\n };\n\n const dismiss = () => handleOpenChange(false);\n // Figma: the outlined button of the dialog is a ghost button in the sheet, placed after the confirm button (see the CSS).\n const alternativeVariant = resolvedPlacement === 'sheet' ? 'ghost' : 'outline';\n\n return (\n <Dialog\n ref={ref}\n className={cn('tm-confirmation-dialog', className)}\n role={destructive ? 'alertdialog' : 'dialog'}\n open={open}\n onOpenChange={handleOpenChange}\n placement={resolvedPlacement}\n dismissible={!busy}\n initialFocusRef={destructive ? cancelRef : confirmRef}\n data-tone={tone}\n footer={\n <>\n {hasSecondary ? (\n <Button ref={cancelRef} className=\"tm-confirmation-dialog__dismiss\" variant=\"text\" disabled={busy} onClick={dismiss}>\n {cancelLabel}\n </Button>\n ) : null}\n <Button\n ref={hasSecondary ? undefined : cancelRef}\n className=\"tm-confirmation-dialog__alternative\"\n variant={alternativeVariant}\n disabled={busy}\n onClick={hasSecondary ? handleSecondary : dismiss}\n >\n {hasSecondary ? secondaryLabel : cancelLabel}\n </Button>\n <Button ref={confirmRef} variant={destructive ? 'destructive' : 'primary'} loading={busy} onClick={handleConfirm}>\n {confirmLabel}\n </Button>\n </>\n }\n {...props}\n />\n );\n});\n"],"mappings":";;;;;;;;AAqCA,IAAME,KAAc,MAClB,OAAOC,KAAU,cAAYA,KAAkB,OAAQA,EAA+B,QAAS,YAMpFC,IAAqC,kBAAoD,SACpG,EACE,UAAO,WACP,iBACA,iBAAc,UACd,mBACA,cACA,aACA,gBACA,aAAU,IACV,oBAAiB,IACjB,MAAMC,GACN,iBAAc,IACd,iBACA,eAAY,QACZ,qBAAkB,SAClB,cACA,GAAGC,KAEL,GACA;CACA,IAAM,CAACC,GAAkBC,KAAuBC,EAASC,CAAW,GAC9DC,IAAON,KAAYE,GACnB,CAACK,GAASC,KAAcJ,EAAS,EAAK,GAEtCK,IAAaC,EAAO,EAAK,GACzBC,IAAYD,EAA0B,IAAI,GAC1CE,IAAaF,EAA0B,IAAI,GAC3CG,IAAoBC,EAAmBC,GAAWC,CAAe,GAEjEC,IAAOC,KAAWX,GAClBY,IAAcC,MAAS,eACvBC,IAAeC,KAAkB,QAAQA,MAAmB,IAE5DC,KAAW,MAAkB;EAEjC,AADIvB,MAAa,KAAA,KAAWG,EAAoBqB,CAAI,GACpDC,IAAeD,CAAI;CACrB,GAGME,KAAoB,MAAkB;EAC1C,IAAI,CAACF,GAAM;GACT,IAAIP,KAAQR,EAAW,SAAS;GAChC,IAAW;EACb;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,2 +1,2 @@
1
- "use client";const e=require("../../utils/cn.cjs"),t=require("../PartnerCarousel/autoplay.cjs"),n=require("./DotMap.cjs");;/* empty css */let r=require("react"),i=require("react/jsx-runtime");var a=800,o=e=>e!=null&&e!==!1&&e!==``,s={x:720,y:390},c=(0,r.forwardRef)(function({items:c,value:l,defaultValue:u=0,onValueChange:d,autoPlay:f=!0,interval:p=2e3,paused:m=!1,target:h=s,children:g,className:_,style:v,...y},b){let x=c.length,S=(0,r.useRef)(null),[C,w]=t.useIndexState(l,u,d,x),[T,E]=(0,r.useState)({current:C,previous:null});T.current!==C&&E({current:C,previous:T.current});let D=T.current===C?T.previous:T.current,{running:O}=t.useAutoplay({enabled:f&&x>1,paused:m,delay:p+a,onTick:()=>w((C+1)%x),rootRef:S,resetKey:C,ignoreInteraction:!0});return(0,i.jsxs)(`div`,{ref:e=>{S.current=e,typeof b==`function`?b(e):b&&(b.current=e)},className:e.cn(`tm-cta-request-flow`,_),"data-autoplay":O?`running`:f?`paused`:void 0,style:{"--_target-x":h.x,"--_target-y":h.y,...v},...y,children:[(0,i.jsxs)(`div`,{className:`tm-cta-request-flow__scene`,"aria-hidden":`true`,children:[(0,i.jsx)(n.DotMap,{className:`tm-cta-request-flow__map`}),c.map((e,t)=>{let n=t===C?`active`:t===D?`leaving`:`idle`,r={"--_x":e.x,"--_y":e.y};return(0,i.jsxs)(`div`,{className:`tm-cta-request-flow__item`,"data-state":n,"data-placement":e.placement??`above`,style:r,children:[(0,i.jsx)(`span`,{className:`tm-cta-request-flow__halo`}),(0,i.jsx)(`span`,{className:`tm-cta-request-flow__pin`}),(0,i.jsxs)(`div`,{className:`tm-cta-request-flow__tag`,children:[o(e.icon)?(0,i.jsx)(`span`,{className:`tm-cta-request-flow__icon`,"data-tm-icon-size":`sm`,children:e.icon}):null,(0,i.jsxs)(`span`,{className:`tm-cta-request-flow__text`,children:[(0,i.jsx)(`span`,{className:`tm-cta-request-flow__title`,children:e.title}),o(e.subtitle)?(0,i.jsx)(`span`,{className:`tm-cta-request-flow__subtitle`,children:e.subtitle}):null]})]})]},e.key??t)})]}),o(g)?(0,i.jsx)(`div`,{className:`tm-cta-request-flow__content`,children:g}):null]})});exports.CtaRequestFlow=c;
1
+ "use client";const e=require("../../utils/cn.cjs"),t=require("../PartnerCarousel/autoplay.cjs"),n=require("./DotMap.cjs");;/* empty css */let r=require("react"),i=require("react/jsx-runtime");var a=800,o=e=>e!=null&&e!==!1&&e!==``,s={x:720,y:390},c={width:1440,height:600},l=20,u=16,d=typeof window>`u`?r.useEffect:r.useLayoutEffect;function f(e,t){let[n,i]=(0,r.useState)(null);return d(()=>{let n=e.current;if(!n)return;let r=()=>{let{clientWidth:e,clientHeight:r}=n;if(e===0&&r===0){i(null);return}let a=n.querySelectorAll(`.tm-cta-request-flow__tag`),o=(e-c.width)/2,s=(r-c.height)/2,d=t.map((t,n)=>{let i=a[n];if(!i||i.offsetWidth===0)return!1;let c=t.x+o,d=t.y+s,f=t.placement===`below`?d+l:d-l-i.offsetHeight;return c-i.offsetWidth/2>=u&&c+i.offsetWidth/2<=e-u&&f>=0&&f+i.offsetHeight<=r});i(e=>e&&e.length===d.length&&e.every((e,t)=>e===d[t])?e:d)};if(r(),typeof ResizeObserver>`u`)return;let a=new ResizeObserver(r);return a.observe(n),()=>a.disconnect()},[e,t]),n}var p=(0,r.forwardRef)(function({items:c,value:l,defaultValue:u=0,onValueChange:d,autoPlay:p=!0,interval:m=2e3,paused:h=!1,target:g=s,map:_=`always`,children:v,className:y,style:b,...x},S){let C=c.length,w=(0,r.useRef)(null),[T,E]=t.useIndexState(l,u,d,C),D=f(w,c),O=e=>D===null||D[e]===!0,k=e=>{for(let t=0;t<C;t+=1){let n=(e+t)%C;if(O(n))return n}return-1},A=k(T),j=c.filter((e,t)=>O(t)).length,[M,N]=(0,r.useState)({current:A,previous:null});M.current!==A&&N({current:A,previous:M.current});let P=A===-1?null:M.current===A?M.previous:M.current,{running:F}=t.useAutoplay({enabled:p&&j>1,paused:h,delay:m+a,onTick:()=>E(k((A+1)%C)),rootRef:w,resetKey:A,ignoreInteraction:!0});return(0,i.jsxs)(`div`,{ref:e=>{w.current=e,typeof S==`function`?S(e):S&&(S.current=e)},className:e.cn(`tm-cta-request-flow`,y),"data-autoplay":F?`running`:p?`paused`:void 0,"data-map":_===`wide-only`?`wide-only`:void 0,style:{"--_target-x":g.x,"--_target-y":g.y,...b},...x,children:[(0,i.jsxs)(`div`,{className:`tm-cta-request-flow__scene`,"aria-hidden":`true`,children:[(0,i.jsx)(n.DotMap,{className:`tm-cta-request-flow__map`}),c.map((e,t)=>{let n=t===A?`active`:t===P?`leaving`:`idle`,r={"--_x":e.x,"--_y":e.y};return(0,i.jsxs)(`div`,{className:`tm-cta-request-flow__item`,"data-state":n,"data-placement":e.placement??`above`,style:r,children:[(0,i.jsx)(`span`,{className:`tm-cta-request-flow__halo`}),(0,i.jsx)(`span`,{className:`tm-cta-request-flow__pin`}),(0,i.jsxs)(`div`,{className:`tm-cta-request-flow__tag`,children:[o(e.icon)?(0,i.jsx)(`span`,{className:`tm-cta-request-flow__icon`,"data-tm-icon-size":`sm`,children:e.icon}):null,(0,i.jsxs)(`span`,{className:`tm-cta-request-flow__text`,children:[(0,i.jsx)(`span`,{className:`tm-cta-request-flow__title`,children:e.title}),o(e.subtitle)?(0,i.jsx)(`span`,{className:`tm-cta-request-flow__subtitle`,children:e.subtitle}):null]})]})]},e.key??t)})]}),o(v)?(0,i.jsx)(`div`,{className:`tm-cta-request-flow__content`,children:v}):null]})});exports.CtaRequestFlow=p;
2
2
  //# sourceMappingURL=CtaRequestFlow.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"CtaRequestFlow.cjs","names":["useRef","useIndexState","useState","useAutoplay","cn","DotMap","require_cn","require_autoplay","require_DotMap","react","react_jsx_runtime","STEP_DURATION","isPresent","node","DEFAULT_TARGET","CtaRequestFlow","props","count","items","rootRef","index","setIndex","value","defaultValue","onValueChange","trail","setTrail","leaving","autoPlay","interval","ref","className","running","target","style","state","i","position","item","children"],"sources":["../../../src/components/CtaRequestFlow/CtaRequestFlow.tsx"],"sourcesContent":["import { forwardRef, useRef, useState, type CSSProperties, type HTMLAttributes, type ReactNode } from 'react';\nimport { cn } from '../../utils/cn';\nimport { useAutoplay, useIndexState } from '../PartnerCarousel/autoplay';\nimport { DotMap } from './DotMap';\nimport './CtaRequestFlow.css';\n\n/** Figma prototype: Smart animate, ease in and out, 800ms. Keep in sync with `--_duration` in the stylesheet. */\nconst STEP_DURATION = 800;\n\n/** One sample request pinned on the map. */\nexport interface CtaRequestFlowItem {\n /** React key; defaults to the position in the list. */\n key?: string;\n /** First line of the tag, e.g. \"Paris, France\". */\n title: ReactNode;\n /** Second line, e.g. \"2 adults · 12–19 Jul\". */\n subtitle?: ReactNode;\n /** One icon from `@travel-match/ui` (e.g. `<BedIcon />`), shown in the round badge of the tag. */\n icon?: ReactNode;\n /** Horizontal position of the pin in the 1440 × 600 map, in px from its left edge. */\n x: number;\n /** Vertical position of the pin in the 1440 × 600 map, in px from its top edge. */\n y: number;\n /** Side of the pin the tag appears on. */\n placement?: 'above' | 'below';\n}\n\nexport interface CtaRequestFlowProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {\n /** The sample requests; one is highlighted at a time. Any number. */\n items: CtaRequestFlowItem[];\n /** Index (0-based) of the highlighted request — Figma \"Step\". Makes the component controlled. */\n value?: number;\n /** Request highlighted first when uncontrolled. */\n defaultValue?: number;\n /** Called with the new index when the highlight moves. */\n onValueChange?: (value: number) => void;\n /** Moves the highlight by itself. Stops for a hidden tab, an off-screen map and reduced motion. */\n autoPlay?: boolean;\n /** Time a request stays highlighted before the next one, in ms (Figma: 2000). */\n interval?: number;\n /** Holds the autoplay. */\n paused?: boolean;\n /** Point of the 1440 × 600 map a tag flies to when its turn ends — where the page's call to action sits. */\n target?: { x: number; y: number };\n /** Content shown on top of the map, centred (the section's heading and button). */\n children?: ReactNode;\n}\n\nconst isPresent = (node: ReactNode) => node !== undefined && node !== null && node !== false && node !== '';\nconst DEFAULT_TARGET = { x: 720, y: 390 };\n\n/**\n * Background of the \"Join\" call to action (Figma component set \"Join / CTA request flow\"): a dotted world map on which\n * sample requests light up one after another, each flying to the middle when its turn ends.\n * The map is decorative and hidden from assistive technology; real content goes in `children`.\n * It keeps the Figma scale and is cropped around its centre, so narrow containers show the middle of the map,\n * like \"Mobile / Join / CTA request flow\".\n */\nexport const CtaRequestFlow = /* @__PURE__ */ forwardRef<HTMLDivElement, CtaRequestFlowProps>(function CtaRequestFlow(\n { items, value, defaultValue = 0, onValueChange, autoPlay = true, interval = 2000, paused = false, target = DEFAULT_TARGET, children, className, style, ...props },\n ref,\n) {\n const count = items.length;\n const rootRef = useRef<HTMLDivElement | null>(null);\n const [index, setIndex] = useIndexState(value, defaultValue, onValueChange, count);\n\n // The request that was highlighted just before: its tag is the one flying to the target.\n const [trail, setTrail] = useState<{ current: number; previous: number | null }>({ current: index, previous: null });\n if (trail.current !== index) setTrail({ current: index, previous: trail.current });\n const leaving = trail.current === index ? trail.previous : trail.current;\n\n const { running } = useAutoplay({\n enabled: autoPlay && count > 1,\n paused,\n delay: interval + STEP_DURATION,\n onTick: () => setIndex((index + 1) % count),\n rootRef,\n resetKey: index,\n // decorative: it must not freeze because the pointer rests on the section it decorates\n ignoreInteraction: true,\n });\n\n return (\n <div\n ref={(node) => {\n rootRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n }}\n className={cn('tm-cta-request-flow', className)}\n data-autoplay={running ? 'running' : autoPlay ? 'paused' : undefined}\n style={{ '--_target-x': target.x, '--_target-y': target.y, ...style } as CSSProperties}\n {...props}\n >\n <div className=\"tm-cta-request-flow__scene\" aria-hidden=\"true\">\n <DotMap className=\"tm-cta-request-flow__map\" />\n {items.map((item, i) => {\n const state = i === index ? 'active' : i === leaving ? 'leaving' : 'idle';\n const position = { '--_x': item.x, '--_y': item.y } as CSSProperties;\n return (\n <div key={item.key ?? i} className=\"tm-cta-request-flow__item\" data-state={state} data-placement={item.placement ?? 'above'} style={position}>\n <span className=\"tm-cta-request-flow__halo\" />\n <span className=\"tm-cta-request-flow__pin\" />\n <div className=\"tm-cta-request-flow__tag\">\n {isPresent(item.icon) ? (\n <span className=\"tm-cta-request-flow__icon\" data-tm-icon-size=\"sm\">\n {item.icon}\n </span>\n ) : null}\n <span className=\"tm-cta-request-flow__text\">\n <span className=\"tm-cta-request-flow__title\">{item.title}</span>\n {isPresent(item.subtitle) ? <span className=\"tm-cta-request-flow__subtitle\">{item.subtitle}</span> : null}\n </span>\n </div>\n </div>\n );\n })}\n </div>\n {isPresent(children) ? <div className=\"tm-cta-request-flow__content\">{children}</div> : null}\n </div>\n );\n});\n"],"mappings":"A,oNAOA,IAAMW,EAAgB,IAyChBC,EAAa,GAAoBC,GAA+B,MAAQA,IAAS,IAASA,IAAS,GACnGC,EAAiB,CAAE,EAAG,IAAK,EAAG,GAAI,EAS3BC,GAAiC,EAAAN,EAAA,WAAA,CAAgD,SAC5F,CAAE,QAAO,QAAO,eAAe,EAAG,gBAAe,WAAW,GAAM,WAAW,IAAM,SAAS,GAAO,SAASK,EAAgB,WAAU,YAAW,QAAO,GAAGE,GAC3J,EACA,CACA,IAAMC,EAAQC,EAAM,OACdC,GAAA,EAAUnB,EAAAA,OAAAA,CAA8B,IAAI,EAC5C,CAACoB,EAAOC,GAAYpB,EAAAA,cAAcqB,EAAOC,EAAcC,EAAeP,CAAK,EAG3E,CAACQ,EAAOC,IAAA,EAAYxB,EAAAA,SAAAA,CAAuD,CAAE,QAASkB,EAAO,SAAU,IAAK,CAAC,EAC/GK,EAAM,UAAYL,GAAOM,EAAS,CAAE,QAASN,EAAO,SAAUK,EAAM,OAAQ,CAAC,EACjF,IAAME,EAAUF,EAAM,UAAYL,EAAQK,EAAM,SAAWA,EAAM,QAE3D,CAAE,WAAYtB,EAAAA,YAAY,CAC9B,QAASyB,GAAYX,EAAQ,EAC7B,SACA,MAAOY,EA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AAM,UAAU,4BAAhB,SAAA,EACE,EAAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,6BAA8B,SAAA4B,EAAK,KAAY,CAAA,EAC9D1B,EAAU0B,EAAK,QAAQ,GAAI,EAAA5B,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,gCAAiC,SAAA4B,EAAK,QAAe,CAAA,EAAI,IACjG,CACH,CAAA,CAAA,C,EACF,CAdK,EAAAA,EAAK,KAAOF,CAcjB,CAET,CAAC,CACE,CACJ,CAAA,EAAAxB,EAAU2B,CAAQ,GAAI,EAAA7B,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,+BAAgC,UAAc,CAAA,EAAI,IACrF,C,EAET,CAAC,E"}
1
+ {"version":3,"file":"CtaRequestFlow.cjs","names":["useEffect","useLayoutEffect","useState","useRef","useIndexState","useAutoplay","cn","DotMap","require_cn","require_autoplay","require_DotMap","react","react_jsx_runtime","STEP_DURATION","isPresent","node","DEFAULT_TARGET","SCENE","TAG_OFFSET","EDGE","useIsomorphicLayoutEffect","useFittingTags","fits","setFits","root","rootRef","measure","width","height","tags","dx","dy","next","items","tag","index","x","item","y","top","current","fit","observer","CtaRequestFlow","props","count","requested","setIndex","value","defaultValue","onValueChange","fitting","i","nextFitting","step","from","fittingCount","trail","setTrail","leaving","autoPlay","interval","ref","className","running","map","target","style","state","position","children"],"sources":["../../../src/components/CtaRequestFlow/CtaRequestFlow.tsx"],"sourcesContent":["import { forwardRef, useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type HTMLAttributes, type ReactNode } from 'react';\nimport { cn } from '../../utils/cn';\nimport { useAutoplay, useIndexState } from '../PartnerCarousel/autoplay';\nimport { DotMap } from './DotMap';\nimport './CtaRequestFlow.css';\n\n/** Figma prototype: Smart animate, ease in and out, 800ms. Keep in sync with `--_duration` in the stylesheet. */\nconst STEP_DURATION = 800;\n\n/** One sample request pinned on the map. */\nexport interface CtaRequestFlowItem {\n /** React key; defaults to the position in the list. */\n key?: string;\n /** First line of the tag, e.g. \"Paris, France\". */\n title: ReactNode;\n /** Second line, e.g. \"2 adults · 12–19 Jul\". */\n subtitle?: ReactNode;\n /** One icon from `@travel-match/ui` (e.g. `<BedIcon />`), shown in the round badge of the tag. */\n icon?: ReactNode;\n /** Horizontal position of the pin in the 1440 × 600 map, in px from its left edge. */\n x: number;\n /** Vertical position of the pin in the 1440 × 600 map, in px from its top edge. */\n y: number;\n /** Side of the pin the tag appears on. */\n placement?: 'above' | 'below';\n}\n\nexport interface CtaRequestFlowProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {\n /** The sample requests; one is highlighted at a time. Any number. */\n items: CtaRequestFlowItem[];\n /**\n * Index (0-based) of the highlighted request — Figma \"Step\". Makes the component controlled. A request whose tag does\n * not fit in the component (see below) is never highlighted: the next one that fits is shown instead, and when none\n * fits (a phone-width root, a hidden map) nothing is.\n */\n value?: number;\n /** Request highlighted first when uncontrolled. */\n defaultValue?: number;\n /** Called with the new index when the highlight moves. */\n onValueChange?: (value: number) => void;\n /** Moves the highlight by itself. Stops for a hidden tab, an off-screen map and reduced motion. */\n autoPlay?: boolean;\n /** Time a request stays highlighted before the next one, in ms (Figma: 2000). */\n interval?: number;\n /** Holds the autoplay. */\n paused?: boolean;\n /** Point of the 1440 × 600 map a tag flies to when its turn ends — where the page's call to action sits. */\n target?: { x: number; y: number };\n /** Content shown on top of the map, centred (the section's heading and button). */\n children?: ReactNode;\n /**\n * `always` (default): the map shows at every width, cropped to the middle on phones (\"Mobile / Join / CTA request\n * flow\"). `wide-only`: on phones (viewports under 768px, the Mobile mode of the tokens) there is no map and the\n * component is just its content, at the content's height — as the Figma \"Join as an Agency — Mobile\" screen draws\n * its final CTA. Nothing is highlighted there.\n */\n map?: 'always' | 'wide-only';\n}\n\nconst isPresent = (node: ReactNode) => node !== undefined && node !== null && node !== false && node !== '';\nconst DEFAULT_TARGET = { x: 720, y: 390 };\n/** The scene (keep in sync with the stylesheet): 1440 × 600, never scaled, centred in the root and cropped by it. */\nconst SCENE = { width: 1440, height: 600 };\n/** Distance from the pin's centre to a shown tag (`--_shown` in the stylesheet). */\nconst TAG_OFFSET = 20;\n/** Room a tag keeps from the left and right edges of the root to count as fitting (spacing/md). */\nconst EDGE = 16;\n\nconst useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\n/**\n * Which items' tags, shown, fit inside the root's box: the scene is cropped around its centre, so on a narrow root\n * (768px: Paris, Lisbon, Barcelona and Tatev) a tag would be cut by the edge or lie entirely outside. `null` until\n * measured (server markup, first paint), meaning every tag fits — as at 1440px. A hidden scene fits nothing.\n */\nfunction useFittingTags(rootRef: { current: HTMLElement | null }, items: CtaRequestFlowItem[]): boolean[] | null {\n const [fits, setFits] = useState<boolean[] | null>(null);\n useIsomorphicLayoutEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n const measure = () => {\n const { clientWidth: width, clientHeight: height } = root;\n // Not laid out (hidden root, or no layout engine as in tests): nothing to measure, so every tag counts.\n if (width === 0 && height === 0) {\n setFits(null);\n return;\n }\n const tags = root.querySelectorAll<HTMLElement>('.tm-cta-request-flow__tag');\n const dx = (width - SCENE.width) / 2;\n const dy = (height - SCENE.height) / 2;\n const next = items.map((item, index) => {\n const tag = tags[index];\n if (!tag || tag.offsetWidth === 0) return false;\n const x = item.x + dx;\n const y = item.y + dy;\n const top = item.placement === 'below' ? y + TAG_OFFSET : y - TAG_OFFSET - tag.offsetHeight;\n return x - tag.offsetWidth / 2 >= EDGE && x + tag.offsetWidth / 2 <= width - EDGE && top >= 0 && top + tag.offsetHeight <= height;\n });\n setFits((current) => (current && current.length === next.length && current.every((fit, index) => fit === next[index]) ? current : next));\n };\n measure();\n if (typeof ResizeObserver === 'undefined') return;\n // A resize changes the crop; the tags' own size changes with fonts and text.\n const observer = new ResizeObserver(measure);\n observer.observe(root);\n return () => observer.disconnect();\n }, [rootRef, items]);\n return fits;\n}\n\n/**\n * Background of the \"Join\" call to action (Figma component set \"Join / CTA request flow\"): a dotted world map on which\n * sample requests light up one after another, each flying to the middle when its turn ends.\n * The map is decorative and hidden from assistive technology; real content goes in `children`.\n * It keeps the Figma scale and is cropped around its centre, so narrow containers show the middle of the map,\n * like \"Mobile / Join / CTA request flow\". There only the requests whose tag fits inside the component (16px clear of\n * its sides) are highlighted — the others keep their pin and the loop skips them; when none fits (a phone-width root)\n * only the pins show and nothing plays. This is measured again on resize.\n */\nexport const CtaRequestFlow = /* @__PURE__ */ forwardRef<HTMLDivElement, CtaRequestFlowProps>(function CtaRequestFlow(\n {\n items,\n value,\n defaultValue = 0,\n onValueChange,\n autoPlay = true,\n interval = 2000,\n paused = false,\n target = DEFAULT_TARGET,\n map = 'always',\n children,\n className,\n style,\n ...props\n },\n ref,\n) {\n const count = items.length;\n const rootRef = useRef<HTMLDivElement | null>(null);\n const [requested, setIndex] = useIndexState(value, defaultValue, onValueChange, count);\n\n // Only requests whose tag fits in the root are highlighted; the others keep their pin and are skipped.\n const fits = useFittingTags(rootRef, items);\n const fitting = (i: number) => fits === null || fits[i] === true;\n /** The first fitting request from `from` on, round the loop; -1 (nothing highlighted) when none fits. */\n const nextFitting = (from: number) => {\n for (let step = 0; step < count; step += 1) {\n const i = (from + step) % count;\n if (fitting(i)) return i;\n }\n return -1;\n };\n const index = nextFitting(requested);\n const fittingCount = items.filter((_, i) => fitting(i)).length;\n\n // The request that was highlighted just before: its tag is the one flying to the target. When nothing fits any more,\n // no tag flies either (the last one may not fit).\n const [trail, setTrail] = useState<{ current: number; previous: number | null }>({ current: index, previous: null });\n if (trail.current !== index) setTrail({ current: index, previous: trail.current });\n const leaving = index === -1 ? null : trail.current === index ? trail.previous : trail.current;\n\n const { running } = useAutoplay({\n enabled: autoPlay && fittingCount > 1,\n paused,\n delay: interval + STEP_DURATION,\n onTick: () => setIndex(nextFitting((index + 1) % count)),\n rootRef,\n resetKey: index,\n // decorative: it must not freeze because the pointer rests on the section it decorates\n ignoreInteraction: true,\n });\n\n return (\n <div\n ref={(node) => {\n rootRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n }}\n className={cn('tm-cta-request-flow', className)}\n data-autoplay={running ? 'running' : autoPlay ? 'paused' : undefined}\n data-map={map === 'wide-only' ? 'wide-only' : undefined}\n style={{ '--_target-x': target.x, '--_target-y': target.y, ...style } as CSSProperties}\n {...props}\n >\n <div className=\"tm-cta-request-flow__scene\" aria-hidden=\"true\">\n <DotMap className=\"tm-cta-request-flow__map\" />\n {items.map((item, i) => {\n const state = i === index ? 'active' : i === leaving ? 'leaving' : 'idle';\n const position = { '--_x': item.x, '--_y': item.y } as CSSProperties;\n return (\n <div key={item.key ?? i} className=\"tm-cta-request-flow__item\" data-state={state} data-placement={item.placement ?? 'above'} style={position}>\n <span className=\"tm-cta-request-flow__halo\" />\n <span className=\"tm-cta-request-flow__pin\" />\n <div className=\"tm-cta-request-flow__tag\">\n {isPresent(item.icon) ? (\n <span className=\"tm-cta-request-flow__icon\" data-tm-icon-size=\"sm\">\n {item.icon}\n </span>\n ) : null}\n <span className=\"tm-cta-request-flow__text\">\n <span className=\"tm-cta-request-flow__title\">{item.title}</span>\n {isPresent(item.subtitle) ? <span className=\"tm-cta-request-flow__subtitle\">{item.subtitle}</span> : null}\n </span>\n </div>\n </div>\n );\n })}\n </div>\n {isPresent(children) ? <div className=\"tm-cta-request-flow__content\">{children}</div> : null}\n </div>\n );\n});\n"],"mappings":"A,oNAOA,IAAMa,EAAgB,IAoDhBC,EAAa,GAAoBC,GAA+B,MAAQA,IAAS,IAASA,IAAS,GACnGC,EAAiB,CAAE,EAAG,IAAK,EAAG,GAAI,EAElCC,EAAQ,CAAE,MAAO,KAAM,OAAQ,GAAI,EAEnCC,EAAa,GAEbC,EAAO,GAEPC,EAA4B,OAAO,OAAW,IAAcpB,EAAAA,UAAYC,EAAAA,gBAO9E,SAASoB,EAAe,EAA0C,EAA+C,CAC/G,GAAM,CAACC,EAAMC,IAAA,EAAWrB,EAAAA,SAAAA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AA,EAAAtC,EAAUwD,CAAQ,GAAI,EAAA1D,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,+BAAgC,UAAc,CAAA,EAAI,IACrF,C,EAET,CAAC,E"}
@@ -3,70 +3,105 @@ import { cn as e } from "../../utils/cn.js";
3
3
  import { useAutoplay as t, useIndexState as n } from "../PartnerCarousel/autoplay.js";
4
4
  import { DotMap as r } from "./DotMap.js";
5
5
  /* empty css */
6
- import { forwardRef as i, useRef as a, useState as o } from "react";
7
- import { jsx as s, jsxs as c } from "react/jsx-runtime";
6
+ import { forwardRef as i, useEffect as a, useLayoutEffect as o, useRef as s, useState as c } from "react";
7
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
8
8
  // src/components/CtaRequestFlow/CtaRequestFlow.tsx
9
- var l = 800, u = (e) => e != null && e !== !1 && e !== "", d = {
9
+ var d = 800, f = (e) => e != null && e !== !1 && e !== "", p = {
10
10
  x: 720,
11
11
  y: 390
12
- }, f = /* @__PURE__ */ i(function({ items: i, value: f, defaultValue: p = 0, onValueChange: m, autoPlay: h = !0, interval: g = 2e3, paused: _ = !1, target: v = d, children: y, className: b, style: x, ...S }, C) {
13
- let w = i.length, T = a(null), [E, D] = n(f, p, m, w), [O, k] = o({
14
- current: E,
12
+ }, m = {
13
+ width: 1440,
14
+ height: 600
15
+ }, h = 20, g = 16, _ = typeof window > "u" ? a : o;
16
+ function v(e, t) {
17
+ let [n, r] = c(null);
18
+ return _(() => {
19
+ let n = e.current;
20
+ if (!n) return;
21
+ let i = () => {
22
+ let { clientWidth: e, clientHeight: i } = n;
23
+ if (e === 0 && i === 0) {
24
+ r(null);
25
+ return;
26
+ }
27
+ let a = n.querySelectorAll(".tm-cta-request-flow__tag"), o = (e - m.width) / 2, s = (i - m.height) / 2, c = t.map((t, n) => {
28
+ let r = a[n];
29
+ if (!r || r.offsetWidth === 0) return !1;
30
+ let c = t.x + o, l = t.y + s, u = t.placement === "below" ? l + h : l - h - r.offsetHeight;
31
+ return c - r.offsetWidth / 2 >= g && c + r.offsetWidth / 2 <= e - g && u >= 0 && u + r.offsetHeight <= i;
32
+ });
33
+ r((e) => e && e.length === c.length && e.every((e, t) => e === c[t]) ? e : c);
34
+ };
35
+ if (i(), typeof ResizeObserver > "u") return;
36
+ let a = new ResizeObserver(i);
37
+ return a.observe(n), () => a.disconnect();
38
+ }, [e, t]), n;
39
+ }
40
+ var y = /* @__PURE__ */ i(function({ items: i, value: a, defaultValue: o = 0, onValueChange: m, autoPlay: h = !0, interval: g = 2e3, paused: _ = !1, target: y = p, map: b = "always", children: x, className: S, style: C, ...w }, T) {
41
+ let E = i.length, D = s(null), [O, k] = n(a, o, m, E), A = v(D, i), j = (e) => A === null || A[e] === !0, M = (e) => {
42
+ for (let t = 0; t < E; t += 1) {
43
+ let n = (e + t) % E;
44
+ if (j(n)) return n;
45
+ }
46
+ return -1;
47
+ }, N = M(O), P = i.filter((e, t) => j(t)).length, [F, I] = c({
48
+ current: N,
15
49
  previous: null
16
50
  });
17
- O.current !== E && k({
18
- current: E,
19
- previous: O.current
51
+ F.current !== N && I({
52
+ current: N,
53
+ previous: F.current
20
54
  });
21
- let A = O.current === E ? O.previous : O.current, { running: j } = t({
22
- enabled: h && w > 1,
55
+ let L = N === -1 ? null : F.current === N ? F.previous : F.current, { running: R } = t({
56
+ enabled: h && P > 1,
23
57
  paused: _,
24
- delay: g + l,
25
- onTick: () => D((E + 1) % w),
26
- rootRef: T,
27
- resetKey: E,
58
+ delay: g + d,
59
+ onTick: () => k(M((N + 1) % E)),
60
+ rootRef: D,
61
+ resetKey: N,
28
62
  ignoreInteraction: !0
29
63
  });
30
- return /* @__PURE__ */ c("div", {
64
+ return /* @__PURE__ */ u("div", {
31
65
  ref: (e) => {
32
- T.current = e, typeof C == "function" ? C(e) : C && (C.current = e);
66
+ D.current = e, typeof T == "function" ? T(e) : T && (T.current = e);
33
67
  },
34
- className: e("tm-cta-request-flow", b),
35
- "data-autoplay": j ? "running" : h ? "paused" : void 0,
68
+ className: e("tm-cta-request-flow", S),
69
+ "data-autoplay": R ? "running" : h ? "paused" : void 0,
70
+ "data-map": b === "wide-only" ? "wide-only" : void 0,
36
71
  style: {
37
- "--_target-x": v.x,
38
- "--_target-y": v.y,
39
- ...x
72
+ "--_target-x": y.x,
73
+ "--_target-y": y.y,
74
+ ...C
40
75
  },
41
- ...S,
42
- children: [/* @__PURE__ */ c("div", {
76
+ ...w,
77
+ children: [/* @__PURE__ */ u("div", {
43
78
  className: "tm-cta-request-flow__scene",
44
79
  "aria-hidden": "true",
45
- children: [/* @__PURE__ */ s(r, { className: "tm-cta-request-flow__map" }), i.map((e, t) => {
46
- let n = t === E ? "active" : t === A ? "leaving" : "idle", r = {
80
+ children: [/* @__PURE__ */ l(r, { className: "tm-cta-request-flow__map" }), i.map((e, t) => {
81
+ let n = t === N ? "active" : t === L ? "leaving" : "idle", r = {
47
82
  "--_x": e.x,
48
83
  "--_y": e.y
49
84
  };
50
- return /* @__PURE__ */ c("div", {
85
+ return /* @__PURE__ */ u("div", {
51
86
  className: "tm-cta-request-flow__item",
52
87
  "data-state": n,
53
88
  "data-placement": e.placement ?? "above",
54
89
  style: r,
55
90
  children: [
56
- /* @__PURE__ */ s("span", { className: "tm-cta-request-flow__halo" }),
57
- /* @__PURE__ */ s("span", { className: "tm-cta-request-flow__pin" }),
58
- /* @__PURE__ */ c("div", {
91
+ /* @__PURE__ */ l("span", { className: "tm-cta-request-flow__halo" }),
92
+ /* @__PURE__ */ l("span", { className: "tm-cta-request-flow__pin" }),
93
+ /* @__PURE__ */ u("div", {
59
94
  className: "tm-cta-request-flow__tag",
60
- children: [u(e.icon) ? /* @__PURE__ */ s("span", {
95
+ children: [f(e.icon) ? /* @__PURE__ */ l("span", {
61
96
  className: "tm-cta-request-flow__icon",
62
97
  "data-tm-icon-size": "sm",
63
98
  children: e.icon
64
- }) : null, /* @__PURE__ */ c("span", {
99
+ }) : null, /* @__PURE__ */ u("span", {
65
100
  className: "tm-cta-request-flow__text",
66
- children: [/* @__PURE__ */ s("span", {
101
+ children: [/* @__PURE__ */ l("span", {
67
102
  className: "tm-cta-request-flow__title",
68
103
  children: e.title
69
- }), u(e.subtitle) ? /* @__PURE__ */ s("span", {
104
+ }), f(e.subtitle) ? /* @__PURE__ */ l("span", {
70
105
  className: "tm-cta-request-flow__subtitle",
71
106
  children: e.subtitle
72
107
  }) : null]
@@ -75,12 +110,12 @@ var l = 800, u = (e) => e != null && e !== !1 && e !== "", d = {
75
110
  ]
76
111
  }, e.key ?? t);
77
112
  })]
78
- }), u(y) ? /* @__PURE__ */ s("div", {
113
+ }), f(x) ? /* @__PURE__ */ l("div", {
79
114
  className: "tm-cta-request-flow__content",
80
- children: y
115
+ children: x
81
116
  }) : null]
82
117
  });
83
118
  });
84
- export { f as CtaRequestFlow };
119
+ export { y as CtaRequestFlow };
85
120
 
86
121
  //# sourceMappingURL=CtaRequestFlow.js.map