@travel-match/ui 0.3.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 (161) 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/HowItWorksSteps/HowItWorksSteps.cjs +1 -1
  26. package/dist/components/HowItWorksSteps/HowItWorksSteps.cjs.map +1 -1
  27. package/dist/components/HowItWorksSteps/HowItWorksSteps.js +1 -1
  28. package/dist/components/HowItWorksSteps/HowItWorksSteps.js.map +1 -1
  29. package/dist/components/InlineAlert/InlineAlert.cjs +1 -1
  30. package/dist/components/InlineAlert/InlineAlert.cjs.map +1 -1
  31. package/dist/components/InlineAlert/InlineAlert.js +9 -8
  32. package/dist/components/InlineAlert/InlineAlert.js.map +1 -1
  33. package/dist/components/LogoAnimation/LogoAnimation.cjs +2 -0
  34. package/dist/components/LogoAnimation/LogoAnimation.cjs.map +1 -0
  35. package/dist/components/LogoAnimation/LogoAnimation.js +202 -0
  36. package/dist/components/LogoAnimation/LogoAnimation.js.map +1 -0
  37. package/dist/components/LogoAnimation/LogoAnimationArtwork.cjs +2 -0
  38. package/dist/components/LogoAnimation/LogoAnimationArtwork.cjs.map +1 -0
  39. package/dist/components/LogoAnimation/LogoAnimationArtwork.js +57 -0
  40. package/dist/components/LogoAnimation/LogoAnimationArtwork.js.map +1 -0
  41. package/dist/components/LogoAnimation/motion.cjs +2 -0
  42. package/dist/components/LogoAnimation/motion.cjs.map +1 -0
  43. package/dist/components/LogoAnimation/motion.js +180 -0
  44. package/dist/components/LogoAnimation/motion.js.map +1 -0
  45. package/dist/components/NewRequestOverlay/NewRequestOverlay.cjs +1 -1
  46. package/dist/components/NewRequestOverlay/NewRequestOverlay.cjs.map +1 -1
  47. package/dist/components/NewRequestOverlay/NewRequestOverlay.js +67 -48
  48. package/dist/components/NewRequestOverlay/NewRequestOverlay.js.map +1 -1
  49. package/dist/components/NotificationsDropdown/NotificationsMenu.cjs +1 -1
  50. package/dist/components/NotificationsDropdown/NotificationsMenu.cjs.map +1 -1
  51. package/dist/components/NotificationsDropdown/NotificationsMenu.js +1 -1
  52. package/dist/components/NotificationsDropdown/NotificationsMenu.js.map +1 -1
  53. package/dist/components/PackageAnimation/PackageAnimation.cjs +1 -1
  54. package/dist/components/PackageAnimation/PackageAnimation.cjs.map +1 -1
  55. package/dist/components/PackageAnimation/PackageAnimation.js +1 -1
  56. package/dist/components/PackageAnimation/PackageAnimation.js.map +1 -1
  57. package/dist/components/PartnerCarousel/PartnerCarousel.cjs.map +1 -1
  58. package/dist/components/PartnerCarousel/PartnerCarousel.js.map +1 -1
  59. package/dist/components/PhoneInput/PhoneInput.cjs +1 -1
  60. package/dist/components/PhoneInput/PhoneInput.cjs.map +1 -1
  61. package/dist/components/PhoneInput/PhoneInput.js +8 -5
  62. package/dist/components/PhoneInput/PhoneInput.js.map +1 -1
  63. package/dist/components/PopularQuestions/PopularQuestions.cjs +1 -1
  64. package/dist/components/PopularQuestions/PopularQuestions.cjs.map +1 -1
  65. package/dist/components/PopularQuestions/PopularQuestions.js +22 -21
  66. package/dist/components/PopularQuestions/PopularQuestions.js.map +1 -1
  67. package/dist/components/RegionMap/RegionMap.cjs +2 -0
  68. package/dist/components/RegionMap/RegionMap.cjs.map +1 -0
  69. package/dist/components/RegionMap/RegionMap.js +55 -0
  70. package/dist/components/RegionMap/RegionMap.js.map +1 -0
  71. package/dist/components/RegionMap/mapPaths.cjs +2 -0
  72. package/dist/components/RegionMap/mapPaths.cjs.map +1 -0
  73. package/dist/components/RegionMap/mapPaths.js +86 -0
  74. package/dist/components/RegionMap/mapPaths.js.map +1 -0
  75. package/dist/components/RequestSearch/RequestSearch.cjs +2 -0
  76. package/dist/components/RequestSearch/RequestSearch.cjs.map +1 -0
  77. package/dist/components/RequestSearch/RequestSearch.js +36 -0
  78. package/dist/components/RequestSearch/RequestSearch.js.map +1 -0
  79. package/dist/components/RequestSummary/RequestSummary.cjs +1 -1
  80. package/dist/components/RequestSummary/RequestSummary.cjs.map +1 -1
  81. package/dist/components/RequestSummary/RequestSummary.js +31 -32
  82. package/dist/components/RequestSummary/RequestSummary.js.map +1 -1
  83. package/dist/components/RequestTypeOption/RequestTypeOption.cjs +2 -0
  84. package/dist/components/RequestTypeOption/RequestTypeOption.cjs.map +1 -0
  85. package/dist/components/RequestTypeOption/RequestTypeOption.js +52 -0
  86. package/dist/components/RequestTypeOption/RequestTypeOption.js.map +1 -0
  87. package/dist/components/Select/Select.cjs +1 -1
  88. package/dist/components/Select/Select.cjs.map +1 -1
  89. package/dist/components/Select/Select.js +127 -121
  90. package/dist/components/Select/Select.js.map +1 -1
  91. package/dist/components/ShowMore/ShowMore.cjs +2 -0
  92. package/dist/components/ShowMore/ShowMore.cjs.map +1 -0
  93. package/dist/components/ShowMore/ShowMore.js +34 -0
  94. package/dist/components/ShowMore/ShowMore.js.map +1 -0
  95. package/dist/components/SiteHeader/SiteHeader.cjs.map +1 -1
  96. package/dist/components/SiteHeader/SiteHeader.js.map +1 -1
  97. package/dist/components/SortSelect/SortSelect.cjs +2 -0
  98. package/dist/components/SortSelect/SortSelect.cjs.map +1 -0
  99. package/dist/components/SortSelect/SortSelect.js +18 -0
  100. package/dist/components/SortSelect/SortSelect.js.map +1 -0
  101. package/dist/components/StatusFilter/StatusFilter.cjs +2 -0
  102. package/dist/components/StatusFilter/StatusFilter.cjs.map +1 -0
  103. package/dist/components/StatusFilter/StatusFilter.js +37 -0
  104. package/dist/components/StatusFilter/StatusFilter.js.map +1 -0
  105. package/dist/components/StatusTag/StatusTag.cjs.map +1 -1
  106. package/dist/components/StatusTag/StatusTag.js.map +1 -1
  107. package/dist/components/StepCard/StepCard.cjs +1 -1
  108. package/dist/components/StepCard/StepCard.cjs.map +1 -1
  109. package/dist/components/StepCard/StepCard.js +9 -6
  110. package/dist/components/StepCard/StepCard.js.map +1 -1
  111. package/dist/components/StepProgress/StepProgress.cjs +2 -0
  112. package/dist/components/StepProgress/StepProgress.cjs.map +1 -0
  113. package/dist/components/StepProgress/StepProgress.js +43 -0
  114. package/dist/components/StepProgress/StepProgress.js.map +1 -0
  115. package/dist/components/TelegramConnect/TelegramConnect.cjs +2 -0
  116. package/dist/components/TelegramConnect/TelegramConnect.cjs.map +1 -0
  117. package/dist/components/TelegramConnect/TelegramConnect.js +57 -0
  118. package/dist/components/TelegramConnect/TelegramConnect.js.map +1 -0
  119. package/dist/components/TextInput/TextInput.cjs +1 -1
  120. package/dist/components/TextInput/TextInput.cjs.map +1 -1
  121. package/dist/components/TextInput/TextInput.js +21 -19
  122. package/dist/components/TextInput/TextInput.js.map +1 -1
  123. package/dist/components/Textarea/Textarea.cjs +1 -1
  124. package/dist/components/Textarea/Textarea.cjs.map +1 -1
  125. package/dist/components/Textarea/Textarea.js +18 -16
  126. package/dist/components/Textarea/Textarea.js.map +1 -1
  127. package/dist/components/Toast/Toast.cjs +2 -0
  128. package/dist/components/Toast/Toast.cjs.map +1 -0
  129. package/dist/components/Toast/Toast.js +57 -0
  130. package/dist/components/Toast/Toast.js.map +1 -0
  131. package/dist/icons/generated/CheckmarkIcon.cjs +1 -1
  132. package/dist/icons/generated/CheckmarkIcon.cjs.map +1 -1
  133. package/dist/icons/generated/CheckmarkIcon.js +19 -2
  134. package/dist/icons/generated/CheckmarkIcon.js.map +1 -1
  135. package/dist/icons/generated/InfoIcon.cjs +2 -0
  136. package/dist/icons/generated/InfoIcon.cjs.map +1 -0
  137. package/dist/icons/generated/InfoIcon.js +35 -0
  138. package/dist/icons/generated/InfoIcon.js.map +1 -0
  139. package/dist/icons/generated/SendIcon.cjs +2 -0
  140. package/dist/icons/generated/SendIcon.cjs.map +1 -0
  141. package/dist/icons/generated/SendIcon.js +23 -0
  142. package/dist/icons/generated/SendIcon.js.map +1 -0
  143. package/dist/icons/generated/index.cjs +1 -1
  144. package/dist/icons/generated/index.cjs.map +1 -1
  145. package/dist/icons/generated/index.js +71 -67
  146. package/dist/icons/generated/index.js.map +1 -1
  147. package/dist/index.cjs +1 -1
  148. package/dist/index.d.cts +649 -34
  149. package/dist/index.d.ts +649 -34
  150. package/dist/index.js +146 -134
  151. package/dist/styles.css +1 -1
  152. package/dist/tailwind.css +0 -6
  153. package/dist/tokens/generated.cjs +1 -1
  154. package/dist/tokens/generated.cjs.map +1 -1
  155. package/dist/tokens/generated.js +1 -7
  156. package/dist/tokens/generated.js.map +1 -1
  157. package/dist/tokens.css +0 -12
  158. package/dist/tokens.d.cts +2 -26
  159. package/dist/tokens.d.ts +2 -26
  160. package/dist/tokens.json +1 -7
  161. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"CtaRequestFlow.js","names":["STEP_DURATION","isPresent","node","DEFAULT_TARGET","CtaRequestFlow","props","count","items","rootRef","useRef","index","setIndex","useIndexState","value","defaultValue","onValueChange","trail","setTrail","useState","leaving","useAutoplay","autoPlay","interval","ref","cn","className","running","target","style","DotMap","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":";;;;;;;;AAOA,IAAMA,IAAgB,KAyChBC,KAAa,MAAoBC,KAA+B,QAAQA,MAAS,MAASA,MAAS,IACnGC,IAAiB;CAAE,GAAG;CAAK,GAAG;AAAI,GAS3BC,IAAiC,kBAAgD,SAC5F,EAAE,UAAO,UAAO,kBAAe,GAAG,kBAAe,cAAW,IAAM,cAAW,KAAM,YAAS,IAAO,YAASD,GAAgB,aAAU,cAAW,UAAO,GAAGE,KAC3J,GACA;CACA,IAAMC,IAAQC,EAAM,QACdC,IAAUC,EAA8B,IAAI,GAC5C,CAACC,GAAOC,KAAYC,EAAcC,GAAOC,GAAcC,GAAeT,CAAK,GAG3E,CAACU,GAAOC,KAAYC,EAAuD;EAAE,SAASR;EAAO,UAAU;CAAK,CAAC;CACnH,AAAIM,EAAM,YAAYN,KAAOO,E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QAAD;QAAM,WAAU;QAAhB,UAAA,CACE,kBAAC,QAAD;SAAM,WAAU;SAA8B,UAAAA,EAAK;QAAY,CAAA,GAC9DhC,EAAUgC,EAAK,QAAQ,IAAI,kBAAC,QAAD;SAAM,WAAU;SAAiC,UAAAA,EAAK;QAAe,CAAA,IAAI,IACjG;OACH,CAAA,CAAA;;KACF;IAdK,GAAAA,EAAK,OAAOF,CAcjB;GAET,CAAC,CACE;EACJ,CAAA,GAAA9B,EAAUiC,CAAQ,IAAI,kBAAC,OAAD;GAAK,WAAU;GAAgC;EAAc,CAAA,IAAI,IACrF;;AAET,CAAC"}
1
+ {"version":3,"file":"CtaRequestFlow.js","names":["STEP_DURATION","isPresent","node","DEFAULT_TARGET","SCENE","TAG_OFFSET","EDGE","useIsomorphicLayoutEffect","useEffect","useLayoutEffect","useFittingTags","fits","setFits","useState","root","rootRef","measure","width","height","tags","dx","dy","next","items","tag","index","x","item","y","top","current","fit","observer","CtaRequestFlow","props","count","useRef","requested","setIndex","useIndexState","value","defaultValue","onValueChange","fitting","i","nextFitting","step","from","fittingCount","trail","setTrail","leaving","useAutoplay","autoPlay","interval","ref","cn","className","running","map","target","style","DotMap","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":";;;;;;;;AAOA,IAAMA,IAAgB,KAoDhBC,KAAa,MAAoBC,KAA+B,QAAQA,MAAS,MAASA,MAAS,IACnGC,IAAiB;CAAE,GAAG;CAAK,GAAG;AAAI,GAElCC,IAAQ;CAAE,OAAO;CAAM,QAAQ;AAAI,GAEnCC,IAAa,IAEbC,IAAO,IAEPC,IAA4B,OAAO,SAAW,MAAcC,IAAYC;AAO9E,SAASC,EAAe,GAA0C,GAA+C;CAC/G,IAAM,CAACC,GAAMC,KAAWC,EAA2B,IAAI;CA+BvD,OA9BAN,QAAgC;EAC9B,IAAMO,IAAOC,EAAQ;EACrB,IAAI,CAACD,GAAM;EACX,IAAME,UAAgB;GACpB,IAAM,EAAE,aAAaC,G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M,KAAK,GAAM,MAAM;IACtB,IAAMwC,IAAQnB,MAAMnB,IAAQ,WAAWmB,MAAMO,IAAU,YAAY,QAC7Da,IAAW;KAAE,QAAQrC,EAAK;KAAG,QAAQA,EAAK;IAAE;IAClD,OACE,kBAAC,OAAD;KAAyB,WAAU;KAA4B,cAAYoC;KAAO,kBAAgBpC,EAAK,aAAa;KAAS,OAAOqC;KAApI,UAAA;MACE,kBAAC,QAAD,EAAM,WAAU,4BAA6B,CAAA;MAC7C,kBAAC,QAAD,EAAM,WAAU,2BAA4B,CAAA;MAC5C,kBAAC,OAAD;OAAK,WAAU;OAAf,UAAA,CACG/D,EAAU0B,EAAK,IAAI,IAClB,kBAAC,QAAD;QAAM,WAAU;QAA4B,qBAAkB;QAC3D,UAAAA,EAAK;OACF,CAAA,IACJ,MACJ,kBAAC,QAAD;QAAM,WAAU;QAAhB,UAAA,CACE,kBAAC,QAAD;SAAM,WAAU;SAA8B,UAAAA,EAAK;QAAY,CAAA,GAC9D1B,EAAU0B,EAAK,QAAQ,IAAI,kBAAC,QAAD;SAAM,WAAU;SAAiC,UAAAA,EAAK;QAAe,CAAA,IAAI,IACjG;OACH,CAAA,CAAA;;KACF;IAdK,GAAAA,EAAK,OAAOiB,CAcjB;GAET,CAAC,CACE;EACJ,CAAA,GAAA3C,EAAUgE,CAAQ,IAAI,kBAAC,OAAD;GAAK,WAAU;GAAgC;EAAc,CAAA,IAAI,IACrF;;AAET,CAAC"}
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../icons/generated/NextArrowIcon.cjs"),t=require("../../utils/cn.cjs");;/* empty css */let n=require("react"),r=require("react/jsx-runtime");var i=(0,n.forwardRef)(function({items:i,linkLabel:a,value:o,defaultValue:s=null,onValueChange:c,headingLevel:l=3,label:u,renderLink:d,className:f,style:p,...m},h){let g=(0,n.useId)(),[_,v]=(0,n.useState)(s);if(i.length===0)return null;let y=o===void 0?_:o,b=e=>{e!==y&&(o===void 0&&v(e),c?.(e))},x=`h${l}`,S={"--_rows":Math.max(1,Math.ceil((i.length-1)/2)),...p};return(0,r.jsx)(`div`,{ref:h,className:t.cn(`tm-example-requests`,f),style:S,"data-single":i.length===1?``:void 0,...m,children:(0,r.jsx)(`ul`,{className:`tm-example-requests__list`,"aria-label":u,children:i.map((t,n)=>{let i=t.value===y,o=`${g}-title-${n}`,s=`${g}-link-${n}`,c=t.linkLabel??a,l=t.href?{id:s,className:`tm-example-requests__link`,href:t.href,"aria-labelledby":`${o} ${s}`,children:(0,r.jsxs)(r.Fragment,{children:[c,(0,r.jsx)(e.NextArrowIcon,{className:`tm-example-requests__arrow`})]})}:null;return(0,r.jsx)(`li`,{className:`tm-example-requests__card`,"data-featured":n===0?``:void 0,"data-active":i?``:void 0,onPointerEnter:e=>e.pointerType!==`touch`&&b(t.value),onPointerLeave:e=>e.pointerType!==`touch`&&t.value===y&&b(null),onPointerDown:e=>e.pointerType===`touch`&&b(t.value),onFocus:()=>b(t.value),onBlur:e=>{!e.currentTarget.contains(e.relatedTarget)&&t.value===y&&b(null)},children:(0,r.jsxs)(`div`,{className:`tm-example-requests__clip`,children:[(0,r.jsx)(`div`,{className:`tm-example-requests__media`,children:t.image??(t.imageSrc?(0,r.jsx)(`img`,{src:t.imageSrc,alt:t.imageAlt??``,loading:`lazy`,decoding:`async`}):null)}),(0,r.jsx)(`div`,{className:`tm-example-requests__overlay`}),t.type||t.typeIcon?(0,r.jsxs)(`span`,{className:`tm-example-requests__type`,"data-tm-icon-size":`sm`,children:[t.typeIcon,t.type]}):null,(0,r.jsxs)(`div`,{className:`tm-example-requests__brief`,children:[(0,r.jsx)(`span`,{className:`tm-example-requests__glass`,"aria-hidden":`true`}),(0,r.jsxs)(`div`,{className:`tm-example-requests__content`,children:[(0,r.jsx)(x,{id:o,className:`tm-example-requests__title`,children:t.title}),t.details?(0,r.jsx)(`p`,{className:`tm-example-requests__details`,children:t.details}):null,l?(0,r.jsx)(`span`,{className:`tm-example-requests__action`,"data-tm-icon-size":`sm`,children:d?d(l,t):(0,r.jsx)(`a`,{...l})}):null]})]})]})},t.value)})})})});exports.ExampleRequests=i;
1
+ "use client";const e=require("../../icons/generated/NextArrowIcon.cjs"),t=require("../../utils/cn.cjs");;/* empty css */let n=require("react"),r=require("react/jsx-runtime");var i=(0,n.forwardRef)(function({items:i,linkLabel:a,value:o,defaultValue:s=null,onValueChange:c,headingLevel:l=3,label:u,renderLink:d,briefStyle:f=`glass`,className:p,style:m,...h},g){let _=(0,n.useId)(),[v,y]=(0,n.useState)(s);if(i.length===0)return null;let b=o===void 0?v:o,x=e=>{e!==b&&(o===void 0&&y(e),c?.(e))},S=`h${l}`,C={"--_rows":Math.max(1,Math.ceil((i.length-1)/2)),...m};return(0,r.jsx)(`div`,{ref:g,className:t.cn(`tm-example-requests`,p),style:C,"data-single":i.length===1?``:void 0,"data-brief-style":f===`solid`?`solid`:void 0,...h,children:(0,r.jsx)(`ul`,{className:`tm-example-requests__list`,"aria-label":u,children:i.map((t,n)=>{let i=t.value===b,o=`${_}-title-${n}`,s=`${_}-link-${n}`,c=t.linkLabel??a,l=t.href?{id:s,className:`tm-example-requests__link`,href:t.href,"aria-labelledby":`${o} ${s}`,children:(0,r.jsxs)(r.Fragment,{children:[c,(0,r.jsx)(e.NextArrowIcon,{className:`tm-example-requests__arrow`})]})}:null;return(0,r.jsx)(`li`,{className:`tm-example-requests__card`,"data-featured":n===0?``:void 0,"data-active":i?``:void 0,onPointerEnter:e=>e.pointerType!==`touch`&&x(t.value),onPointerLeave:e=>e.pointerType!==`touch`&&t.value===b&&x(null),onPointerDown:e=>e.pointerType===`touch`&&x(t.value),onFocus:()=>x(t.value),onBlur:e=>{!e.currentTarget.contains(e.relatedTarget)&&t.value===b&&x(null)},children:(0,r.jsxs)(`div`,{className:`tm-example-requests__clip`,children:[(0,r.jsx)(`div`,{className:`tm-example-requests__media`,children:t.image??(t.imageSrc?(0,r.jsx)(`img`,{src:t.imageSrc,alt:t.imageAlt??``,loading:`lazy`,decoding:`async`}):null)}),(0,r.jsx)(`div`,{className:`tm-example-requests__overlay`}),t.type||t.typeIcon?(0,r.jsxs)(`span`,{className:`tm-example-requests__type`,"data-tm-icon-size":`sm`,children:[t.typeIcon,t.type]}):null,(0,r.jsxs)(`div`,{className:`tm-example-requests__brief`,children:[(0,r.jsx)(`span`,{className:`tm-example-requests__glass`,"aria-hidden":`true`}),(0,r.jsxs)(`div`,{className:`tm-example-requests__content`,children:[(0,r.jsx)(S,{id:o,className:`tm-example-requests__title`,children:t.title}),t.details?(0,r.jsx)(`p`,{className:`tm-example-requests__details`,children:t.details}):null,l?(0,r.jsx)(`span`,{className:`tm-example-requests__action`,"data-tm-icon-size":`sm`,children:d?d(l,t):(0,r.jsx)(`a`,{...l})}):null]})]})]})},t.value)})})})});exports.ExampleRequests=i;
2
2
  //# sourceMappingURL=ExampleRequests.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExampleRequests.cjs","names":["useId","useState","cn","_Fragment","NextArrowIcon","require_NextArrowIcon","require_cn","react","react_jsx_runtime","ExampleRequests","props","baseId","uncontrolled","setUncontrolled","defaultValue","items","active","value","highlight","next","onValueChange","Heading","headingLevel","rootStyle","style","className","label","isActive","item","titleId","index","linkId","text","linkLabel","linkProps","event","renderLink"],"sources":["../../../src/components/ExampleRequests/ExampleRequests.tsx"],"sourcesContent":["import { forwardRef, useId, useState, type CSSProperties, type FocusEvent, type HTMLAttributes, type PointerEvent, type ReactNode } from 'react';\nimport { NextArrowIcon } from '../../icons';\nimport { cn } from '../../utils/cn';\nimport './ExampleRequests.css';\n\nexport type ExampleRequestsHeadingLevel = 2 | 3 | 4 | 5 | 6;\n\nexport interface ExampleRequestItem {\n /** Identifies the example in `value` / `onValueChange`. */\n value: string;\n /** Request type shown in the pill on the photo, e.g. \"Travel Package\". */\n type?: ReactNode;\n /** One icon from `@travel-match/ui` for the pill, e.g. `<RoadmapIcon />`. */\n typeIcon?: ReactNode;\n /** Name of the example, e.g. \"Summer in Santorini\". */\n title: ReactNode;\n /** One line under the title, e.g. \"7 nights · 2 adults, 1 child · Flights, hotel & transfers\". */\n details?: ReactNode;\n /** Photo behind the card. It is cropped to cover the card, so keep the subject near the centre. */\n imageSrc?: string;\n /** Alternative text of the photo. Leave it out when the photo only illustrates the title. */\n imageAlt?: string;\n /** Replaces the `<img>`, e.g. a `next/image` with `fill`. It is stretched to cover the card. */\n image?: ReactNode;\n /** Where the card leads, e.g. the request form prefilled with this example. Without it the card is not a link. */\n href?: string;\n /** Text of this card's link; defaults to the component's `linkLabel`. */\n linkLabel?: ReactNode;\n}\n\n/** What `renderLink` receives: spread `props` on your link element and render `children` inside it. */\nexport interface ExampleRequestLinkProps {\n id: string;\n className: string;\n href: string;\n 'aria-labelledby': string;\n children: ReactNode;\n}\n\nexport interface ExampleRequestsProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'defaultValue' | 'onChange'> {\n /** The examples, in order. The first one is the large card. Nothing is rendered for an empty list. */\n items: ExampleRequestItem[];\n /** Text of every card's link, e.g. \"Start a similar request\". */\n linkLabel?: ReactNode;\n /** Controlled: `value` of the highlighted card, or `null` for none (Figma \"Hover\" / mobile \"Selected\"). */\n value?: string | null;\n /** Uncontrolled: `value` of the card that starts highlighted. None by default. */\n defaultValue?: string | null;\n /** Called when hover, focus or a touch highlights a card, and with `null` when the highlight ends. */\n onValueChange?: (value: string | null) => void;\n /** Level of each card's heading — pick the one that fits the page outline. */\n headingLevel?: ExampleRequestsHeadingLevel;\n /** Accessible name of the list, e.g. \"Example requests\". */\n label?: string;\n /** Renders a card's link with the app's router, e.g. `(props) => <Link {...props} />`. Defaults to an `<a>`. */\n renderLink?: (props: ExampleRequestLinkProps, item: ExampleRequestItem) => ReactNode;\n}\n\n/**\n * Example travel requests as photo cards: one large card and a grid of smaller ones (Figma \"Travel Requests /\n * Example requests\"). The card under the pointer or holding focus is highlighted — its photo zooms in and darkens and\n * it lifts off the page. Each card is one link. On narrow containers the cards become a horizontal, snapping row\n * (Figma \"Mobile / Travel Requests / Example requests\").\n */\nexport const ExampleRequests = /* @__PURE__ */ forwardRef<HTMLDivElement, ExampleRequestsProps>(function ExampleRequests(\n { items, linkLabel, value, defaultValue = null, onValueChange, headingLevel = 3, label, renderLink, className, style, ...props },\n ref,\n) {\n const baseId = useId();\n const [uncontrolled, setUncontrolled] = useState<string | null>(defaultValue);\n if (items.length === 0) return null;\n\n const active = value !== undefined ? value : uncontrolled;\n\n const highlight = (next: string | null) => {\n if (next === active) return;\n if (value === undefined) setUncontrolled(next);\n onValueChange?.(next);\n };\n\n const Heading = `h${headingLevel}` as const;\n // The large card spans every row of the grid beside it (two small cards per row).\n const rows = Math.max(1, Math.ceil((items.length - 1) / 2));\n const rootStyle = { '--_rows': rows, ...style } as CSSProperties;\n\n return (\n <div ref={ref} className={cn('tm-example-requests', className)} style={rootStyle} data-single={items.length === 1 ? '' : undefined} {...props}>\n <ul className=\"tm-example-requests__list\" aria-label={label}>\n {items.map((item, index) => {\n const isActive = item.value === active;\n const titleId = `${baseId}-title-${index}`;\n const linkId = `${baseId}-link-${index}`;\n const text = item.linkLabel ?? linkLabel;\n const linkProps: ExampleRequestLinkProps | null = item.href\n ? {\n id: linkId,\n className: 'tm-example-requests__link',\n href: item.href,\n // \"Summer in Santorini, Start a similar request\" — every link would otherwise read the same.\n 'aria-labelledby': `${titleId} ${linkId}`,\n children: (\n <>\n {text}\n <NextArrowIcon className=\"tm-example-requests__arrow\" />\n </>\n ),\n }\n : null;\n return (\n <li\n key={item.value}\n className=\"tm-example-requests__card\"\n data-featured={index === 0 ? '' : undefined}\n data-active={isActive ? '' : undefined}\n // A touch \"enters\" just before it taps; it is handled by pointerdown so that it also sticks afterwards.\n onPointerEnter={(event: PointerEvent) => event.pointerType !== 'touch' && highlight(item.value)}\n onPointerLeave={(event: PointerEvent) => event.pointerType !== 'touch' && item.value === active && highlight(null)}\n onPointerDown={(event: PointerEvent) => event.pointerType === 'touch' && highlight(item.value)}\n onFocus={() => highlight(item.value)}\n onBlur={(event: FocusEvent<HTMLLIElement>) => {\n if (!event.currentTarget.contains(event.relatedTarget) && item.value === active) highlight(null);\n }}\n >\n <div className=\"tm-example-requests__clip\">\n <div className=\"tm-example-requests__media\">\n {item.image ?? (item.imageSrc ? <img src={item.imageSrc} alt={item.imageAlt ?? ''} loading=\"lazy\" decoding=\"async\" /> : null)}\n </div>\n <div className=\"tm-example-requests__overlay\" />\n {item.type || item.typeIcon ? (\n <span className=\"tm-example-requests__type\" data-tm-icon-size=\"sm\">\n {item.typeIcon}\n {item.type}\n </span>\n ) : null}\n <div className=\"tm-example-requests__brief\">\n <span className=\"tm-example-requests__glass\" aria-hidden=\"true\" />\n <div className=\"tm-example-requests__content\">\n <Heading id={titleId} className=\"tm-example-requests__title\">\n {item.title}\n </Heading>\n {item.details ? <p className=\"tm-example-requests__details\">{item.details}</p> : null}\n {linkProps ? (\n <span className=\"tm-example-requests__action\" data-tm-icon-size=\"sm\">\n {renderLink ? renderLink(linkProps, item) : <a {...linkProps} />}\n </span>\n ) : null}\n </div>\n </div>\n </div>\n </li>\n );\n })}\n </ul>\n </div>\n );\n});\n"],"mappings":"A,mMAgEA,IAAaS,GAAkC,EAAAF,EAAA,WAAA,CAAiD,SAC9F,CAAE,QAAO,YAAW,QAAO,eAAe,KAAM,gBAAe,eAAe,EAAG,QAAO,aAAY,YAAW,QAAO,GAAGG,GACzH,EACA,CACA,IAAMC,GAAA,EAASX,EAAAA,MAAAA,CAAM,EACf,CAACY,EAAcC,IAAA,EAAmBZ,EAAAA,SAAAA,CAAwBa,CAAY,EAC5E,GAAIC,EAAM,SAAW,EAAG,OAAO,KAE/B,IAAMC,EAASC,IAAU,IAAA,GAAoBL,EAARK,EAE/BC,EAAa,GAAwB,CACrCC,IAASH,IACTC,IAAU,IAAA,IAAWJ,EAAgBM,CAAI,EAC7CC,IAAgBD,CAAI,EACtB,EAEME,EAAU,IAAIC,IAGdC,EAAY,CAAE,UADP,KAAK,IAAI,EAAG,KAAK,MAAMR,EAAM,O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n","_Fragment","NextArrowIcon","require_NextArrowIcon","require_cn","react","react_jsx_runtime","ExampleRequests","props","baseId","uncontrolled","setUncontrolled","defaultValue","items","active","value","highlight","next","onValueChange","Heading","headingLevel","rootStyle","style","className","briefStyle","label","isActive","item","titleId","index","linkId","text","linkLabel","linkProps","event","renderLink"],"sources":["../../../src/components/ExampleRequests/ExampleRequests.tsx"],"sourcesContent":["import { forwardRef, useId, useState, type CSSProperties, type FocusEvent, type HTMLAttributes, type PointerEvent, type ReactNode } from 'react';\nimport { NextArrowIcon } from '../../icons';\nimport { cn } from '../../utils/cn';\nimport './ExampleRequests.css';\n\nexport type ExampleRequestsHeadingLevel = 2 | 3 | 4 | 5 | 6;\n\nexport interface ExampleRequestItem {\n /** Identifies the example in `value` / `onValueChange`. */\n value: string;\n /** Request type shown in the pill on the photo, e.g. \"Travel Package\". */\n type?: ReactNode;\n /** One icon from `@travel-match/ui` for the pill, e.g. `<RoadmapIcon />`. */\n typeIcon?: ReactNode;\n /** Name of the example, e.g. \"Summer in Santorini\". */\n title: ReactNode;\n /** One line under the title, e.g. \"7 nights · 2 adults, 1 child · Flights, hotel & transfers\". */\n details?: ReactNode;\n /** Photo behind the card. It is cropped to cover the card, so keep the subject near the centre. */\n imageSrc?: string;\n /** Alternative text of the photo. Leave it out when the photo only illustrates the title. */\n imageAlt?: string;\n /** Replaces the `<img>`, e.g. a `next/image` with `fill`. It is stretched to cover the card. */\n image?: ReactNode;\n /** Where the card leads, e.g. the request form prefilled with this example. Without it the card is not a link. */\n href?: string;\n /** Text of this card's link; defaults to the component's `linkLabel`. */\n linkLabel?: ReactNode;\n}\n\n/** What `renderLink` receives: spread `props` on your link element and render `children` inside it. */\nexport interface ExampleRequestLinkProps {\n id: string;\n className: string;\n href: string;\n 'aria-labelledby': string;\n children: ReactNode;\n}\n\nexport interface ExampleRequestsProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'defaultValue' | 'onChange'> {\n /** The examples, in order. The first one is the large card. Nothing is rendered for an empty list. */\n items: ExampleRequestItem[];\n /** Text of every card's link, e.g. \"Start a similar request\". */\n linkLabel?: ReactNode;\n /** Controlled: `value` of the highlighted card, or `null` for none (Figma \"Hover\" / mobile \"Selected\"). */\n value?: string | null;\n /** Uncontrolled: `value` of the card that starts highlighted. None by default. */\n defaultValue?: string | null;\n /** Called when hover, focus or a touch highlights a card, and with `null` when the highlight ends. */\n onValueChange?: (value: string | null) => void;\n /** Level of each card's heading — pick the one that fits the page outline. */\n headingLevel?: ExampleRequestsHeadingLevel;\n /** Accessible name of the list, e.g. \"Example requests\". */\n label?: string;\n /** Renders a card's link with the app's router, e.g. `(props) => <Link {...props} />`. Defaults to an `<a>`. */\n renderLink?: (props: ExampleRequestLinkProps, item: ExampleRequestItem) => ReactNode;\n /**\n * Background of the text box on the smaller cards: `glass` (default) background/card at 80% with a 4px blur, as in the\n * Figma component; `solid` background/card without blur, e.g. for the Travel Requests page. The large\n * card is always solid.\n */\n briefStyle?: 'glass' | 'solid';\n}\n\n/**\n * Example travel requests as photo cards: one large card and a grid of smaller ones (Figma \"Travel Requests /\n * Example requests\"). The card under the pointer or holding focus is highlighted — its photo zooms in and darkens and\n * it lifts off the page. Each card is one link. On narrow containers the cards become a horizontal, snapping row\n * (Figma \"Mobile / Travel Requests / Example requests\").\n */\nexport const ExampleRequests = /* @__PURE__ */ forwardRef<HTMLDivElement, ExampleRequestsProps>(function ExampleRequests(\n { items, linkLabel, value, defaultValue = null, onValueChange, headingLevel = 3, label, renderLink, briefStyle = 'glass', className, style, ...props },\n ref,\n) {\n const baseId = useId();\n const [uncontrolled, setUncontrolled] = useState<string | null>(defaultValue);\n if (items.length === 0) return null;\n\n const active = value !== undefined ? value : uncontrolled;\n\n const highlight = (next: string | null) => {\n if (next === active) return;\n if (value === undefined) setUncontrolled(next);\n onValueChange?.(next);\n };\n\n const Heading = `h${headingLevel}` as const;\n // The large card spans every row of the grid beside it (two small cards per row).\n const rows = Math.max(1, Math.ceil((items.length - 1) / 2));\n const rootStyle = { '--_rows': rows, ...style } as CSSProperties;\n\n return (\n <div\n ref={ref}\n className={cn('tm-example-requests', className)}\n style={rootStyle}\n data-single={items.length === 1 ? '' : undefined}\n data-brief-style={briefStyle === 'solid' ? 'solid' : undefined}\n {...props}\n >\n <ul className=\"tm-example-requests__list\" aria-label={label}>\n {items.map((item, index) => {\n const isActive = item.value === active;\n const titleId = `${baseId}-title-${index}`;\n const linkId = `${baseId}-link-${index}`;\n const text = item.linkLabel ?? linkLabel;\n const linkProps: ExampleRequestLinkProps | null = item.href\n ? {\n id: linkId,\n className: 'tm-example-requests__link',\n href: item.href,\n // \"Summer in Santorini, Start a similar request\" — every link would otherwise read the same.\n 'aria-labelledby': `${titleId} ${linkId}`,\n children: (\n <>\n {text}\n <NextArrowIcon className=\"tm-example-requests__arrow\" />\n </>\n ),\n }\n : null;\n return (\n <li\n key={item.value}\n className=\"tm-example-requests__card\"\n data-featured={index === 0 ? '' : undefined}\n data-active={isActive ? '' : undefined}\n // A touch \"enters\" just before it taps; it is handled by pointerdown so that it also sticks afterwards.\n onPointerEnter={(event: PointerEvent) => event.pointerType !== 'touch' && highlight(item.value)}\n onPointerLeave={(event: PointerEvent) => event.pointerType !== 'touch' && item.value === active && highlight(null)}\n onPointerDown={(event: PointerEvent) => event.pointerType === 'touch' && highlight(item.value)}\n onFocus={() => highlight(item.value)}\n onBlur={(event: FocusEvent<HTMLLIElement>) => {\n if (!event.currentTarget.contains(event.relatedTarget) && item.value === active) highlight(null);\n }}\n >\n <div className=\"tm-example-requests__clip\">\n <div className=\"tm-example-requests__media\">\n {item.image ?? (item.imageSrc ? <img src={item.imageSrc} alt={item.imageAlt ?? ''} loading=\"lazy\" decoding=\"async\" /> : null)}\n </div>\n <div className=\"tm-example-requests__overlay\" />\n {item.type || item.typeIcon ? (\n <span className=\"tm-example-requests__type\" data-tm-icon-size=\"sm\">\n {item.typeIcon}\n {item.type}\n </span>\n ) : null}\n <div className=\"tm-example-requests__brief\">\n <span className=\"tm-example-requests__glass\" aria-hidden=\"true\" />\n <div className=\"tm-example-requests__content\">\n <Heading id={titleId} className=\"tm-example-requests__title\">\n {item.title}\n </Heading>\n {item.details ? <p className=\"tm-example-requests__details\">{item.details}</p> : null}\n {linkProps ? (\n <span className=\"tm-example-requests__action\" data-tm-icon-size=\"sm\">\n {renderLink ? renderLink(linkProps, item) : <a {...linkProps} />}\n </span>\n ) : null}\n </div>\n </div>\n </div>\n </li>\n );\n })}\n </ul>\n </div>\n );\n});\n"],"mappings":"A,mMAsEA,IAAaS,GAAkC,EAAAF,EAAA,WAAA,CAAiD,SAC9F,CAAE,QAAO,YAAW,QAAO,eAAe,KAAM,gBAAe,eAAe,EAAG,QAAO,aAAY,aAAa,QAAS,YAAW,QAAO,GAAGG,GAC/I,EACA,CACA,IAAMC,GAAA,EAASX,EAAAA,MAAAA,CAAM,EACf,CAACY,EAAcC,IAAA,EAAmBZ,EAAAA,SAAAA,CAAwBa,CAAY,EAC5E,GAAIC,EAAM,SAAW,EAAG,OAAO,KAE/B,IAAMC,EAASC,IAAU,IAAA,GAAoBL,EAARK,EAE/BC,EAAa,GAAwB,CACrCC,IAASH,IACTC,IAAU,IAAA,IAAWJ,EAAgBM,CAAI,EAC7CC,IAAgBD,CAAI,EACtB,EAEME,EAAU,IAAIC,IAGdC,EAAY,CAAE,UADP,KAAK,IAAI,EAAG,KAAK,MAAMR,EAAM,OAAS,GAAK,CAAC,CAC1B,EAAM,GAAGS,CAAM,EAE9C,OACE,EAAAhB,EAAA,IAAA,CAAC,MAAD,CACO,MACL,UAAWN,EAAAA,GAAG,sBAAuBuB,CAAS,EAC9C,MAAOF,EACP,cAAaR,EAAM,SAAW,EAAI,GAAK,IAAA,GACvC,mBAAkBW,IAAe,QAAU,QAAU,IAAA,GACrD,GAAIhB,EAEJ,UAAA,EAAAF,EAAA,IAAA,CAAC,KAAD,CAAI,UAAU,4BAA4B,aAAYmB,EACnD,SAAAZ,EAAM,KAAK,EAAM,IAAU,CAC1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AAA,EAC9CqB,EAAK,MAAQA,EAAK,UACjB,EAAArB,EAAA,KAAA,CAAC,OAAD,CAAM,UAAU,4BAA4B,oBAAkB,KAA9D,SAAA,CACGqB,EAAK,SACLA,EAAK,IACF,CACJ,CAAA,EAAA,MACJ,EAAArB,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,6BAAf,SAAA,EACE,EAAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,6BAA6B,cAAY,MAAQ,CAAA,GACjE,EAAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,+BAAf,SAAA,EACE,EAAAA,EAAA,IAAA,CAACa,EAAD,CAAS,GAAIS,EAAS,UAAU,6BAC7B,SAAAD,EAAK,KACC,CAAA,EACRA,EAAK,SAAU,EAAArB,EAAA,IAAA,CAAC,IAAD,CAAG,UAAU,+BAAgC,SAAAqB,EAAK,OAAW,CAAA,EAAI,KAChFM,GACC,EAAA3B,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,8BAA8B,oBAAkB,KAC7D,SAAA6B,EAAaA,EAAWF,EAAWN,CAAI,GAAI,EAAArB,EAAA,IAAA,CAAC,IAAD,CAAG,GAAI2B,CAAY,CAAA,CAC3D,CAAA,EACJ,IACD,CACF,CAAA,CAAA,C,EACF,C,EACH,EAvCGN,EAAK,KAuCR,CAER,CAAC,CACC,CAAA,CACD,CAAA,CAET,CAAC,E"}
@@ -5,26 +5,27 @@ import { cn as t } from "../../utils/cn.js";
5
5
  import { forwardRef as n, useId as r, useState as i } from "react";
6
6
  import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
7
7
  // src/components/ExampleRequests/ExampleRequests.tsx
8
- var c = /* @__PURE__ */ n(function({ items: n, linkLabel: c, value: l, defaultValue: u = null, onValueChange: d, headingLevel: f = 3, label: p, renderLink: m, className: h, style: g, ..._ }, v) {
9
- let y = r(), [b, x] = i(u);
8
+ var c = /* @__PURE__ */ n(function({ items: n, linkLabel: c, value: l, defaultValue: u = null, onValueChange: d, headingLevel: f = 3, label: p, renderLink: m, briefStyle: h = "glass", className: g, style: _, ...v }, y) {
9
+ let b = r(), [x, S] = i(u);
10
10
  if (n.length === 0) return null;
11
- let S = l === void 0 ? b : l, C = (e) => {
12
- e !== S && (l === void 0 && x(e), d?.(e));
13
- }, w = `h${f}`, T = {
11
+ let C = l === void 0 ? x : l, w = (e) => {
12
+ e !== C && (l === void 0 && S(e), d?.(e));
13
+ }, T = `h${f}`, E = {
14
14
  "--_rows": Math.max(1, Math.ceil((n.length - 1) / 2)),
15
- ...g
15
+ ..._
16
16
  };
17
17
  return /* @__PURE__ */ o("div", {
18
- ref: v,
19
- className: t("tm-example-requests", h),
20
- style: T,
18
+ ref: y,
19
+ className: t("tm-example-requests", g),
20
+ style: E,
21
21
  "data-single": n.length === 1 ? "" : void 0,
22
- ..._,
22
+ "data-brief-style": h === "solid" ? "solid" : void 0,
23
+ ...v,
23
24
  children: /* @__PURE__ */ o("ul", {
24
25
  className: "tm-example-requests__list",
25
26
  "aria-label": p,
26
27
  children: n.map((t, n) => {
27
- let r = t.value === S, i = `${y}-title-${n}`, l = `${y}-link-${n}`, u = t.linkLabel ?? c, d = t.href ? {
28
+ let r = t.value === C, i = `${b}-title-${n}`, l = `${b}-link-${n}`, u = t.linkLabel ?? c, d = t.href ? {
28
29
  id: l,
29
30
  className: "tm-example-requests__link",
30
31
  href: t.href,
@@ -35,12 +36,12 @@ var c = /* @__PURE__ */ n(function({ items: n, linkLabel: c, value: l, defaultVa
35
36
  className: "tm-example-requests__card",
36
37
  "data-featured": n === 0 ? "" : void 0,
37
38
  "data-active": r ? "" : void 0,
38
- onPointerEnter: (e) => e.pointerType !== "touch" && C(t.value),
39
- onPointerLeave: (e) => e.pointerType !== "touch" && t.value === S && C(null),
40
- onPointerDown: (e) => e.pointerType === "touch" && C(t.value),
41
- onFocus: () => C(t.value),
39
+ onPointerEnter: (e) => e.pointerType !== "touch" && w(t.value),
40
+ onPointerLeave: (e) => e.pointerType !== "touch" && t.value === C && w(null),
41
+ onPointerDown: (e) => e.pointerType === "touch" && w(t.value),
42
+ onFocus: () => w(t.value),
42
43
  onBlur: (e) => {
43
- !e.currentTarget.contains(e.relatedTarget) && t.value === S && C(null);
44
+ !e.currentTarget.contains(e.relatedTarget) && t.value === C && w(null);
44
45
  },
45
46
  children: /* @__PURE__ */ s("div", {
46
47
  className: "tm-example-requests__clip",
@@ -68,7 +69,7 @@ var c = /* @__PURE__ */ n(function({ items: n, linkLabel: c, value: l, defaultVa
68
69
  }), /* @__PURE__ */ s("div", {
69
70
  className: "tm-example-requests__content",
70
71
  children: [
71
- /* @__PURE__ */ o(w, {
72
+ /* @__PURE__ */ o(T, {
72
73
  id: i,
73
74
  className: "tm-example-requests__title",
74
75
  children: t.title
@@ -1 +1 @@
1
- {"version":3,"file":"ExampleRequests.js","names":["_Fragment","Fragment$1","ExampleRequests","props","baseId","useId","uncontrolled","setUncontrolled","useState","defaultValue","items","active","value","highlight","next","onValueChange","Heading","headingLevel","rootStyle","style","cn","className","label","isActive","item","titleId","index","linkId","text","linkLabel","linkProps","NextArrowIcon","event","renderLink"],"sources":["../../../src/components/ExampleRequests/ExampleRequests.tsx"],"sourcesContent":["import { forwardRef, useId, useState, type CSSProperties, type FocusEvent, type HTMLAttributes, type PointerEvent, type ReactNode } from 'react';\nimport { NextArrowIcon } from '../../icons';\nimport { cn } from '../../utils/cn';\nimport './ExampleRequests.css';\n\nexport type ExampleRequestsHeadingLevel = 2 | 3 | 4 | 5 | 6;\n\nexport interface ExampleRequestItem {\n /** Identifies the example in `value` / `onValueChange`. */\n value: string;\n /** Request type shown in the pill on the photo, e.g. \"Travel Package\". */\n type?: ReactNode;\n /** One icon from `@travel-match/ui` for the pill, e.g. `<RoadmapIcon />`. */\n typeIcon?: ReactNode;\n /** Name of the example, e.g. \"Summer in Santorini\". */\n title: ReactNode;\n /** One line under the title, e.g. \"7 nights · 2 adults, 1 child · Flights, hotel & transfers\". */\n details?: ReactNode;\n /** Photo behind the card. It is cropped to cover the card, so keep the subject near the centre. */\n imageSrc?: string;\n /** Alternative text of the photo. Leave it out when the photo only illustrates the title. */\n imageAlt?: string;\n /** Replaces the `<img>`, e.g. a `next/image` with `fill`. It is stretched to cover the card. */\n image?: ReactNode;\n /** Where the card leads, e.g. the request form prefilled with this example. Without it the card is not a link. */\n href?: string;\n /** Text of this card's link; defaults to the component's `linkLabel`. */\n linkLabel?: ReactNode;\n}\n\n/** What `renderLink` receives: spread `props` on your link element and render `children` inside it. */\nexport interface ExampleRequestLinkProps {\n id: string;\n className: string;\n href: string;\n 'aria-labelledby': string;\n children: ReactNode;\n}\n\nexport interface ExampleRequestsProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'defaultValue' | 'onChange'> {\n /** The examples, in order. The first one is the large card. Nothing is rendered for an empty list. */\n items: ExampleRequestItem[];\n /** Text of every card's link, e.g. \"Start a similar request\". */\n linkLabel?: ReactNode;\n /** Controlled: `value` of the highlighted card, or `null` for none (Figma \"Hover\" / mobile \"Selected\"). */\n value?: string | null;\n /** Uncontrolled: `value` of the card that starts highlighted. None by default. */\n defaultValue?: string | null;\n /** Called when hover, focus or a touch highlights a card, and with `null` when the highlight ends. */\n onValueChange?: (value: string | null) => void;\n /** Level of each card's heading — pick the one that fits the page outline. */\n headingLevel?: ExampleRequestsHeadingLevel;\n /** Accessible name of the list, e.g. \"Example requests\". */\n label?: string;\n /** Renders a card's link with the app's router, e.g. `(props) => <Link {...props} />`. Defaults to an `<a>`. */\n renderLink?: (props: ExampleRequestLinkProps, item: ExampleRequestItem) => ReactNode;\n}\n\n/**\n * Example travel requests as photo cards: one large card and a grid of smaller ones (Figma \"Travel Requests /\n * Example requests\"). The card under the pointer or holding focus is highlighted — its photo zooms in and darkens and\n * it lifts off the page. Each card is one link. On narrow containers the cards become a horizontal, snapping row\n * (Figma \"Mobile / Travel Requests / Example requests\").\n */\nexport const ExampleRequests = /* @__PURE__ */ forwardRef<HTMLDivElement, ExampleRequestsProps>(function ExampleRequests(\n { items, linkLabel, value, defaultValue = null, onValueChange, headingLevel = 3, label, renderLink, className, style, ...props },\n ref,\n) {\n const baseId = useId();\n const [uncontrolled, setUncontrolled] = useState<string | null>(defaultValue);\n if (items.length === 0) return null;\n\n const active = value !== undefined ? value : uncontrolled;\n\n const highlight = (next: string | null) => {\n if (next === active) return;\n if (value === undefined) setUncontrolled(next);\n onValueChange?.(next);\n };\n\n const Heading = `h${headingLevel}` as const;\n // The large card spans every row of the grid beside it (two small cards per row).\n const rows = Math.max(1, Math.ceil((items.length - 1) / 2));\n const rootStyle = { '--_rows': rows, ...style } as CSSProperties;\n\n return (\n <div ref={ref} className={cn('tm-example-requests', className)} style={rootStyle} data-single={items.length === 1 ? '' : undefined} {...props}>\n <ul className=\"tm-example-requests__list\" aria-label={label}>\n {items.map((item, index) => {\n const isActive = item.value === active;\n const titleId = `${baseId}-title-${index}`;\n const linkId = `${baseId}-link-${index}`;\n const text = item.linkLabel ?? linkLabel;\n const linkProps: ExampleRequestLinkProps | null = item.href\n ? {\n id: linkId,\n className: 'tm-example-requests__link',\n href: item.href,\n // \"Summer in Santorini, Start a similar request\" — every link would otherwise read the same.\n 'aria-labelledby': `${titleId} ${linkId}`,\n children: (\n <>\n {text}\n <NextArrowIcon className=\"tm-example-requests__arrow\" />\n </>\n ),\n }\n : null;\n return (\n <li\n key={item.value}\n className=\"tm-example-requests__card\"\n data-featured={index === 0 ? '' : undefined}\n data-active={isActive ? '' : undefined}\n // A touch \"enters\" just before it taps; it is handled by pointerdown so that it also sticks afterwards.\n onPointerEnter={(event: PointerEvent) => event.pointerType !== 'touch' && highlight(item.value)}\n onPointerLeave={(event: PointerEvent) => event.pointerType !== 'touch' && item.value === active && highlight(null)}\n onPointerDown={(event: PointerEvent) => event.pointerType === 'touch' && highlight(item.value)}\n onFocus={() => highlight(item.value)}\n onBlur={(event: FocusEvent<HTMLLIElement>) => {\n if (!event.currentTarget.contains(event.relatedTarget) && item.value === active) highlight(null);\n }}\n >\n <div className=\"tm-example-requests__clip\">\n <div className=\"tm-example-requests__media\">\n {item.image ?? (item.imageSrc ? <img src={item.imageSrc} alt={item.imageAlt ?? ''} loading=\"lazy\" decoding=\"async\" /> : null)}\n </div>\n <div className=\"tm-example-requests__overlay\" />\n {item.type || item.typeIcon ? (\n <span className=\"tm-example-requests__type\" data-tm-icon-size=\"sm\">\n {item.typeIcon}\n {item.type}\n </span>\n ) : null}\n <div className=\"tm-example-requests__brief\">\n <span className=\"tm-example-requests__glass\" aria-hidden=\"true\" />\n <div className=\"tm-example-requests__content\">\n <Heading id={titleId} className=\"tm-example-requests__title\">\n {item.title}\n </Heading>\n {item.details ? <p className=\"tm-example-requests__details\">{item.details}</p> : null}\n {linkProps ? (\n <span className=\"tm-example-requests__action\" data-tm-icon-size=\"sm\">\n {renderLink ? renderLink(linkProps, item) : <a {...linkProps} />}\n </span>\n ) : null}\n </div>\n </div>\n </div>\n </li>\n );\n })}\n </ul>\n </div>\n );\n});\n"],"mappings":";;;;;;;AAgEA,IAAaE,IAAkC,kBAAiD,SAC9F,EAAE,UAAO,cAAW,UAAO,kBAAe,MAAM,kBAAe,kBAAe,GAAG,UAAO,eAAY,cAAW,UAAO,GAAGC,KACzH,GACA;CACA,IAAMC,IAASC,EAAM,GACf,CAACC,GAAcC,KAAmBC,EAAwBC,CAAY;CAC5E,IAAIC,EAAM,WAAW,GAAG,OAAO;CAE/B,IAAMC,IAASC,MAAU,KAAA,IAAoBN,IAARM,GAE/BC,KAAa,MAAwB;EACzC,AAAIC,MAASH,MACTC,MAAU,KAAA,KAAWL,EAAgBO,CAAI,GAC7CC,IAAgBD,CAAI;CACtB,GAEME,IAAU,IAAIC,KAGdC,IAAY;EAAE,WADP,KAAK,IAAI,GAAG,KAAK,MAAMR,EAAM,SAAS,KAAK,CAAC,CAC1B;EAAM,GAAGS;CAAM;CAE9C,OACE,kBAAC,OAAD;EAAU;EAAK,WAAWC,EAAG,uBAAuBC,CAAS;EAAG,OAAOH;EAAW,eAA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AAgC,CAAA;OAC9CA,EAAK,QAAQA,EAAK,WACjB,kBAAC,QAAD;QAAM,WAAU;QAA4B,qBAAkB;QAA9D,UAAA,CACGA,EAAK,UACLA,EAAK,IACF;OACJ,CAAA,IAAA;OACJ,kBAAC,OAAD;QAAK,WAAU;QAAf,UAAA,CACE,kBAAC,QAAD;SAAM,WAAU;SAA6B,eAAY;QAAQ,CAAA,GACjE,kBAAC,OAAD;SAAK,WAAU;SAAf,UAAA;UACE,kBAACR,GAAD;WAAS,IAAIS;WAAS,WAAU;WAC7B,UAAAD,EAAK;UACC,CAAA;UACRA,EAAK,UAAU,kBAAC,KAAD;WAAG,WAAU;WAAgC,UAAAA,EAAK;UAAW,CAAA,IAAI;UAChFM,IACC,kBAAC,QAAD;WAAM,WAAU;WAA8B,qBAAkB;WAC7D,UAAAG,IAAaA,EAAWH,GAAWN,CAAI,IAAI,kBAAC,KAAD,EAAG,GAAIM,EAAY,CAAA;UAC3D,CAAA,IACJ;SACD;QACF,CAAA,CAAA;;MACF;;IACH,GAvCGN,EAAK,KAuCR;GAER,CAAC;EACC,CAAA;CACD,CAAA;AAET,CAAC"}
1
+ {"version":3,"file":"ExampleRequests.js","names":["_Fragment","Fragment$1","ExampleRequests","props","baseId","useId","uncontrolled","setUncontrolled","useState","defaultValue","items","active","value","highlight","next","onValueChange","Heading","headingLevel","rootStyle","style","cn","className","briefStyle","label","isActive","item","titleId","index","linkId","text","linkLabel","linkProps","NextArrowIcon","event","renderLink"],"sources":["../../../src/components/ExampleRequests/ExampleRequests.tsx"],"sourcesContent":["import { forwardRef, useId, useState, type CSSProperties, type FocusEvent, type HTMLAttributes, type PointerEvent, type ReactNode } from 'react';\nimport { NextArrowIcon } from '../../icons';\nimport { cn } from '../../utils/cn';\nimport './ExampleRequests.css';\n\nexport type ExampleRequestsHeadingLevel = 2 | 3 | 4 | 5 | 6;\n\nexport interface ExampleRequestItem {\n /** Identifies the example in `value` / `onValueChange`. */\n value: string;\n /** Request type shown in the pill on the photo, e.g. \"Travel Package\". */\n type?: ReactNode;\n /** One icon from `@travel-match/ui` for the pill, e.g. `<RoadmapIcon />`. */\n typeIcon?: ReactNode;\n /** Name of the example, e.g. \"Summer in Santorini\". */\n title: ReactNode;\n /** One line under the title, e.g. \"7 nights · 2 adults, 1 child · Flights, hotel & transfers\". */\n details?: ReactNode;\n /** Photo behind the card. It is cropped to cover the card, so keep the subject near the centre. */\n imageSrc?: string;\n /** Alternative text of the photo. Leave it out when the photo only illustrates the title. */\n imageAlt?: string;\n /** Replaces the `<img>`, e.g. a `next/image` with `fill`. It is stretched to cover the card. */\n image?: ReactNode;\n /** Where the card leads, e.g. the request form prefilled with this example. Without it the card is not a link. */\n href?: string;\n /** Text of this card's link; defaults to the component's `linkLabel`. */\n linkLabel?: ReactNode;\n}\n\n/** What `renderLink` receives: spread `props` on your link element and render `children` inside it. */\nexport interface ExampleRequestLinkProps {\n id: string;\n className: string;\n href: string;\n 'aria-labelledby': string;\n children: ReactNode;\n}\n\nexport interface ExampleRequestsProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'defaultValue' | 'onChange'> {\n /** The examples, in order. The first one is the large card. Nothing is rendered for an empty list. */\n items: ExampleRequestItem[];\n /** Text of every card's link, e.g. \"Start a similar request\". */\n linkLabel?: ReactNode;\n /** Controlled: `value` of the highlighted card, or `null` for none (Figma \"Hover\" / mobile \"Selected\"). */\n value?: string | null;\n /** Uncontrolled: `value` of the card that starts highlighted. None by default. */\n defaultValue?: string | null;\n /** Called when hover, focus or a touch highlights a card, and with `null` when the highlight ends. */\n onValueChange?: (value: string | null) => void;\n /** Level of each card's heading — pick the one that fits the page outline. */\n headingLevel?: ExampleRequestsHeadingLevel;\n /** Accessible name of the list, e.g. \"Example requests\". */\n label?: string;\n /** Renders a card's link with the app's router, e.g. `(props) => <Link {...props} />`. Defaults to an `<a>`. */\n renderLink?: (props: ExampleRequestLinkProps, item: ExampleRequestItem) => ReactNode;\n /**\n * Background of the text box on the smaller cards: `glass` (default) background/card at 80% with a 4px blur, as in the\n * Figma component; `solid` background/card without blur, e.g. for the Travel Requests page. The large\n * card is always solid.\n */\n briefStyle?: 'glass' | 'solid';\n}\n\n/**\n * Example travel requests as photo cards: one large card and a grid of smaller ones (Figma \"Travel Requests /\n * Example requests\"). The card under the pointer or holding focus is highlighted — its photo zooms in and darkens and\n * it lifts off the page. Each card is one link. On narrow containers the cards become a horizontal, snapping row\n * (Figma \"Mobile / Travel Requests / Example requests\").\n */\nexport const ExampleRequests = /* @__PURE__ */ forwardRef<HTMLDivElement, ExampleRequestsProps>(function ExampleRequests(\n { items, linkLabel, value, defaultValue = null, onValueChange, headingLevel = 3, label, renderLink, briefStyle = 'glass', className, style, ...props },\n ref,\n) {\n const baseId = useId();\n const [uncontrolled, setUncontrolled] = useState<string | null>(defaultValue);\n if (items.length === 0) return null;\n\n const active = value !== undefined ? value : uncontrolled;\n\n const highlight = (next: string | null) => {\n if (next === active) return;\n if (value === undefined) setUncontrolled(next);\n onValueChange?.(next);\n };\n\n const Heading = `h${headingLevel}` as const;\n // The large card spans every row of the grid beside it (two small cards per row).\n const rows = Math.max(1, Math.ceil((items.length - 1) / 2));\n const rootStyle = { '--_rows': rows, ...style } as CSSProperties;\n\n return (\n <div\n ref={ref}\n className={cn('tm-example-requests', className)}\n style={rootStyle}\n data-single={items.length === 1 ? '' : undefined}\n data-brief-style={briefStyle === 'solid' ? 'solid' : undefined}\n {...props}\n >\n <ul className=\"tm-example-requests__list\" aria-label={label}>\n {items.map((item, index) => {\n const isActive = item.value === active;\n const titleId = `${baseId}-title-${index}`;\n const linkId = `${baseId}-link-${index}`;\n const text = item.linkLabel ?? linkLabel;\n const linkProps: ExampleRequestLinkProps | null = item.href\n ? {\n id: linkId,\n className: 'tm-example-requests__link',\n href: item.href,\n // \"Summer in Santorini, Start a similar request\" — every link would otherwise read the same.\n 'aria-labelledby': `${titleId} ${linkId}`,\n children: (\n <>\n {text}\n <NextArrowIcon className=\"tm-example-requests__arrow\" />\n </>\n ),\n }\n : null;\n return (\n <li\n key={item.value}\n className=\"tm-example-requests__card\"\n data-featured={index === 0 ? '' : undefined}\n data-active={isActive ? '' : undefined}\n // A touch \"enters\" just before it taps; it is handled by pointerdown so that it also sticks afterwards.\n onPointerEnter={(event: PointerEvent) => event.pointerType !== 'touch' && highlight(item.value)}\n onPointerLeave={(event: PointerEvent) => event.pointerType !== 'touch' && item.value === active && highlight(null)}\n onPointerDown={(event: PointerEvent) => event.pointerType === 'touch' && highlight(item.value)}\n onFocus={() => highlight(item.value)}\n onBlur={(event: FocusEvent<HTMLLIElement>) => {\n if (!event.currentTarget.contains(event.relatedTarget) && item.value === active) highlight(null);\n }}\n >\n <div className=\"tm-example-requests__clip\">\n <div className=\"tm-example-requests__media\">\n {item.image ?? (item.imageSrc ? <img src={item.imageSrc} alt={item.imageAlt ?? ''} loading=\"lazy\" decoding=\"async\" /> : null)}\n </div>\n <div className=\"tm-example-requests__overlay\" />\n {item.type || item.typeIcon ? (\n <span className=\"tm-example-requests__type\" data-tm-icon-size=\"sm\">\n {item.typeIcon}\n {item.type}\n </span>\n ) : null}\n <div className=\"tm-example-requests__brief\">\n <span className=\"tm-example-requests__glass\" aria-hidden=\"true\" />\n <div className=\"tm-example-requests__content\">\n <Heading id={titleId} className=\"tm-example-requests__title\">\n {item.title}\n </Heading>\n {item.details ? <p className=\"tm-example-requests__details\">{item.details}</p> : null}\n {linkProps ? (\n <span className=\"tm-example-requests__action\" data-tm-icon-size=\"sm\">\n {renderLink ? renderLink(linkProps, item) : <a {...linkProps} />}\n </span>\n ) : null}\n </div>\n </div>\n </div>\n </li>\n );\n })}\n </ul>\n </div>\n );\n});\n"],"mappings":";;;;;;;AAsEA,IAAaE,IAAkC,kBAAiD,SAC9F,EAAE,UAAO,cAAW,UAAO,kBAAe,MAAM,kBAAe,kBAAe,GAAG,UAAO,eAAY,gBAAa,SAAS,cAAW,UAAO,GAAGC,KAC/I,GACA;CACA,IAAMC,IAASC,EAAM,GACf,C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ownArrowIcon.cjs"),t=require("../../utils/cn.cjs");;/* empty css */let n=require("react"),r=require("react/jsx-runtime");var i=(0,n.createContext)({}),a=(0,n.forwardRef)(function({question:a,children:o,open:s,defaultOpen:c=!1,onOpenChange:l,headingLevel:u,id:d,className:f,...p},m){let h=(0,n.useContext)(i),[g,_]=(0,n.useState)(c),v=s??g,y=(0,n.useId)(),b=d??y,x=`${b}-question`,S=`${b}-answer`,C=`h${u??h.headingLevel??3}`,w=()=>{s===void 0&&_(!v),l?.(!v)};return(0,r.jsxs)(`div`,{ref:m,id:d,className:t.cn(`tm-faq-item`,f),"data-open":v?``:void 0,...p,children:[(0,r.jsx)(C,{className:`tm-faq-item__heading`,children:(0,r.jsxs)(`button`,{type:`button`,id:x,className:`tm-faq-item__trigger`,"aria-expanded":v,"aria-controls":S,onClick:w,children:[(0,r.jsx)(`span`,{className:`tm-faq-item__question`,children:a}),(0,r.jsx)(e.DownArrowIcon,{size:`md`,className:`tm-faq-item__icon`})]})}),(0,r.jsx)(`div`,{id:S,className:`tm-faq-item__panel`,role:`region`,"aria-labelledby":x,hidden:!v,children:(0,r.jsx)(`div`,{className:`tm-faq-item__clip`,children:(0,r.jsx)(`div`,{className:`tm-faq-item__answer`,children:o})})})]})}),o=(0,n.forwardRef)(function({headingLevel:e,className:n,children:a,...o},s){return(0,r.jsx)(`div`,{ref:s,className:t.cn(`tm-faq-list`,n),...o,children:(0,r.jsx)(i.Provider,{value:{headingLevel:e},children:a})})});exports.FaqItem=a,exports.FaqList=o;
1
+ "use client";const e=require("../../icons/generated/DownArrowIcon.cjs"),t=require("../../utils/cn.cjs");;/* empty css */let n=require("react"),r=require("react/jsx-runtime");var i=typeof window>`u`?n.useEffect:n.useLayoutEffect,a=(0,n.createContext)({}),o=(0,n.forwardRef)(function({question:i,children:o,open:s,defaultOpen:c=!1,onOpenChange:l,headingLevel:u,value:d,id:f,className:p,...m},h){let g=(0,n.useContext)(a),[_,v]=(0,n.useState)(c),y=(0,n.useId)(),b=d??y,x=s??(g.single?g.single.value===b:_),S=f??y,C=`${S}-question`,w=`${S}-answer`,T=`h${u??g.headingLevel??3}`,E=()=>{s===void 0&&(g.single?g.single.setValue(x?null:b):v(!x)),l?.(!x)};return(0,r.jsxs)(`div`,{ref:h,id:f,className:t.cn(`tm-faq-item`,p),"data-open":x?``:void 0,...m,children:[(0,r.jsx)(T,{className:`tm-faq-item__heading`,children:(0,r.jsxs)(`button`,{type:`button`,id:C,className:`tm-faq-item__trigger`,"aria-expanded":x,"aria-controls":w,onClick:E,children:[(0,r.jsx)(`span`,{className:`tm-faq-item__question`,children:i}),(0,r.jsx)(e.DownArrowIcon,{size:`md`,className:`tm-faq-item__icon`})]})}),(0,r.jsx)(`div`,{id:w,className:`tm-faq-item__panel`,role:`region`,"aria-labelledby":C,hidden:!x,children:(0,r.jsx)(`div`,{className:`tm-faq-item__clip`,children:(0,r.jsx)(`div`,{className:`tm-faq-item__answer`,children:o})})})]})});function s(e){let[t,r]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{if(typeof e!=`string`||typeof window>`u`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),n=()=>r(t.matches);return n(),t.addEventListener?.(`change`,n),()=>t.removeEventListener?.(`change`,n)},[e]),typeof e==`string`?t:e}var c=(0,n.forwardRef)(function({headingLevel:e,type:o=`multiple`,value:c,defaultValue:l=null,onValueChange:u,reserveHeight:d=!1,className:f,style:p,children:m,...h},g){let[_,v]=(0,n.useState)(l),y=c===void 0?_:c,b=(0,n.useCallback)(e=>{c===void 0&&v(e),u?.(e)},[c,u]),x=o===`single`?{value:y,setValue:b}:void 0,S=(0,n.useRef)(null),[C,w]=(0,n.useState)(),T=d!==!1,E=s(d)&&C!==void 0;return i(()=>{let e=S.current;if(!T||!e)return;let t=document.createElement(`div`);t.className=`tm-faq-item__answer tm-faq-list__probe`,t.setAttribute(`aria-hidden`,`true`),e.appendChild(t);let n=()=>{let n=0,r=0;for(let i of e.querySelectorAll(`:scope > .tm-faq-item`)){let e=i.querySelector(`.tm-faq-item__panel`),a=i.querySelector(`.tm-faq-item__answer`);n+=i.offsetHeight-(e?.offsetHeight??0),t.innerHTML=a?.innerHTML??``,r=Math.max(r,t.offsetHeight)}t.innerHTML=``;let i=e.offsetHeight-e.clientHeight,a=Math.ceil(n+r+i);w(e=>e===a?e:a)};n();let r;return typeof ResizeObserver<`u`&&(r=new ResizeObserver(n),r.observe(e)),()=>{r?.disconnect(),t.remove()}},[T,m]),(0,r.jsx)(`div`,{ref:e=>{S.current=e,typeof g==`function`?g(e):g&&(g.current=e)},className:t.cn(`tm-faq-list`,f),"data-reserve-height":T?``:void 0,style:E?{"--_reserved-height":`${C}px`,...p}:p,...h,children:(0,r.jsx)(a.Provider,{value:{headingLevel:e,single:x},children:m})})});exports.FaqItem=o,exports.FaqList=c;
2
2
  //# sourceMappingURL=FaqItem.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"FaqItem.cjs","names":["createContext","useContext","useState","useId","cn","DownArrowIcon","require_DownArrowIcon","require_cn","react","react_jsx_runtime","ListContext","FaqItem","props","list","uncontrolled","setUncontrolled","defaultOpen","isOpen","open","autoId","baseId","id","triggerId","panelId","Heading","headingLevel","toggle","onOpenChange","className","question","FaqList"],"sources":["../../../src/components/FaqItem/FaqItem.tsx"],"sourcesContent":["import { createContext, forwardRef, useContext, useId, useState, type HTMLAttributes, type ReactNode } from 'react';\nimport { DownArrowIcon } from '../../icons';\nimport { cn } from '../../utils/cn';\nimport './FaqItem.css';\n\n/** Heading level of the question (`<h2>`–`<h6>`); it depends on where the FAQ sits in the page outline. */\nexport type FaqHeadingLevel = 2 | 3 | 4 | 5 | 6;\n\nconst ListContext = createContext<{ headingLevel?: FaqHeadingLevel }>({});\n\n// ── Item ─────────────────────────────────────────────────────────────\nexport interface FaqItemProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n /** The question (Figma \"Question\"). It is the label of the button that shows and hides the answer. */\n question: ReactNode;\n /** The answer (Figma \"Answer\"): text or any content — paragraphs, lists, links. */\n children?: ReactNode;\n /** Controlled state (Figma \"State\": Closed · Open). */\n open?: boolean;\n /** Initial state of an uncontrolled item. */\n defaultOpen?: boolean;\n /** Called with the new state when the user opens or closes the item. */\n onOpenChange?: (open: boolean) => void;\n /** Heading level of the question. Defaults to the `FaqList`'s level, otherwise `3`. */\n headingLevel?: FaqHeadingLevel;\n}\n\n/**\n * One question of a FAQ (Figma component set \"FAQ item\"): a disclosure — a heading with a button\n * (`aria-expanded`) that reveals the answer below it.\n */\nexport const FaqItem = /* @__PURE__ */ forwardRef<HTMLDivElement, FaqItemProps>(function FaqItem(\n { question, children, open, defaultOpen = false, onOpenChange, headingLevel, id, className, ...props },\n ref,\n) {\n const list = useContext(ListContext);\n const [uncontrolled, setUncontrolled] = useState(defaultOpen);\n const isOpen = open ?? uncontrolled;\n const autoId = useId();\n const baseId = id ?? autoId;\n const triggerId = `${baseId}-question`;\n const panelId = `${baseId}-answer`;\n const Heading = `h${headingLevel ?? list.headingLevel ?? 3}` as 'h3';\n\n const toggle = () => {\n if (open === undefined) setUncontrolled(!isOpen);\n onOpenChange?.(!isOpen);\n };\n\n return (\n <div ref={ref} id={id} className={cn('tm-faq-item', className)} data-open={isOpen ? '' : undefined} {...props}>\n <Heading className=\"tm-faq-item__heading\">\n <button type=\"button\" id={triggerId} className=\"tm-faq-item__trigger\" aria-expanded={isOpen} aria-controls={panelId} onClick={toggle}>\n <span className=\"tm-faq-item__question\">{question}</span>\n {/* Figma swaps down-arrow for up-arrow; one icon turned 180° is the same drawing and can animate. */}\n <DownArrowIcon size=\"md\" className=\"tm-faq-item__icon\" />\n </button>\n </Heading>\n {/* `hidden` keeps the closed answer out of the tab order and the accessibility tree; the CSS keeps it in the\n layout (collapsed, `visibility: hidden`) so the height can animate. */}\n <div id={panelId} className=\"tm-faq-item__panel\" role=\"region\" aria-labelledby={triggerId} hidden={!isOpen}>\n <div className=\"tm-faq-item__clip\">\n <div className=\"tm-faq-item__answer\">{children}</div>\n </div>\n </div>\n </div>\n );\n});\n\n// ── List ─────────────────────────────────────────────────────────────\nexport interface FaqListProps extends HTMLAttributes<HTMLDivElement> {\n /** Heading level for the question of every item in the list (an item's own `headingLevel` wins). */\n headingLevel?: FaqHeadingLevel;\n}\n\n/** Stacks `FaqItem`s (each draws its own divider) and sets the heading level of their questions once. */\nexport const FaqList = /* @__PURE__ */ forwardRef<HTMLDivElement, FaqListProps>(function FaqList({ headingLevel, className, children, ...props }, ref) {\n return (\n <div ref={ref} className={cn('tm-faq-list', className)} {...props}>\n <ListContext.Provider value={{ headingLevel }}>{children}</ListContext.Provider>\n </div>\n );\n});\n"],"mappings":"A,2LAQA,IAAMU,GAAA,EAAcV,EAAAA,cAAAA,CAAkD,CAAC,CAAC,EAsB3DW,GAA0B,EAAAH,EAAA,WAAA,CAAyC,SAC9E,CAAE,WAAU,WAAU,OAAM,cAAc,GAAO,eAAc,eAAc,KAAI,YAAW,GAAGI,GAC/F,EACA,CACA,IAAMC,GAAA,EAAOZ,EAAAA,WAAAA,CAAWS,CAAW,EAC7B,CAACI,EAAcC,IAAA,EAAmBb,EAAAA,SAAAA,CAASc,CAAW,EACtDC,EAASC,GAAQJ,EACjBK,GAAA,EAAShB,EAAAA,MAAAA,CAAM,EACfiB,EAASC,GAAMF,EACfG,EAAY,GAAGF,EAAO,WACtBG,EAAU,GAAGH,EAAO,SACpBI,EAAU,IAAIC,GAAgBZ,EAAK,cAAgB,IAEnDa,MAAe,CACfR,IAAS,IAAA,IAAWH,EAAgB,CAACE,CAAM,EAC/CU,IAAe,CAACV,CAAM,CACxB,EAEA,OACE,EAAAR,EAAA,KAAA,CAAC,MAAD,CAAU,MAAS,KAAI,UAAWL,EAAAA,GAAG,cAAewB,CAAS,EAAG,YAAWX,EAAS,GAAK,IAAA,GAAW,GAAIL,EAAxG,SAAA,EACE,EAAAH,EAAA,IAAA,CAACe,EAAD,CAAS,UAAU,uBACjB,UAAA,EAAAf,EAAA,KAAA,CAAC,SAAD,CAAQ,KAAK,SAAS,GAAIa,EAAW,UAAU,uBAAuB,gBAAeL,EAAQ,gBAAeM,EAAS,QAASG,EAA9H,SAAA,EACE,EAAAjB,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,wBAAyB,SAAAoB,CAAe,CAAA,GAExD,EAAApB,EAAA,IAAA,CAACJ,EAAAA,cAAD,CAAe,KAAK,KAAK,UAAU,mBAAqB,CAAA,CAClD,C,EACD,CAAA,GAGT,EAAAI,EAAA,IAAA,CAAC,MAAD,CAAK,GAAIc,EAAS,UAAU,qBAAqB,KAAK,SAAS,kBAAiBD,EAAW,OAAQ,CAACL,EAClG,UAAA,EAAAR,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,oBACb,UAAA,EAAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,sBAAuB,UAAc,CAAA,CACjD,CAAA,CACF,CAAA,CACF,C,EAET,CAAC,EASYqB,GAA0B,EAAAtB,EAAA,WAAA,CAAyC,SAAiB,CAAE,eAAc,YAAW,WAAU,GAAGI,GAAS,EAAK,CACrJ,OACE,EAAAH,EAAA,IAAA,CAAC,MAAD,CAAU,MAAK,UAAWL,EAAAA,GAAG,cAAewB,CAAS,EAAG,GAAIhB,EAC1D,UAAA,EAAAH,EAAA,IAAA,CAACC,EAAY,SAAb,CAAsB,MAAO,CAAE,cAAa,EAAI,UAA+B,CAAA,CAC5E,CAAA,CAET,CAAC,E"}
1
+ {"version":3,"file":"FaqItem.cjs","names":["useEffect","useLayoutEffect","createContext","useContext","useState","useId","cn","DownArrowIcon","useCallback","useRef","require_DownArrowIcon","require_cn","react","react_jsx_runtime","useIsomorphicLayoutEffect","ListContext","FaqItem","props","list","uncontrolled","setUncontrolled","defaultOpen","autoId","itemValue","value","isOpen","open","baseId","id","triggerId","panelId","Heading","headingLevel","toggle","onOpenChange","className","question","useMatches","matches","setMatches","query","media","update","FaqList","defaultValue","openValue","setValue","next","onValueChange","single","type","listRef","reserved","setReserved","measuring","reserveHeight","reserving","probe","measure","rows","tallestAnswer","item","panel","answer","borders","current","observer","children","node","ref","style"],"sources":["../../../src/components/FaqItem/FaqItem.tsx"],"sourcesContent":["import {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type CSSProperties,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport { DownArrowIcon } from '../../icons';\nimport { cn } from '../../utils/cn';\nimport './FaqItem.css';\n\n/** Heading level of the question (`<h2>`–`<h6>`); it depends on where the FAQ sits in the page outline. */\nexport type FaqHeadingLevel = 2 | 3 | 4 | 5 | 6;\n\nconst useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\ninterface ListContextValue {\n headingLevel?: FaqHeadingLevel;\n /** Set in a `type=\"single\"` list: the open item's value and the setter. */\n single?: { value: string | null; setValue: (value: string | null) => void };\n}\n\nconst ListContext = createContext<ListContextValue>({});\n\n// ── Item ─────────────────────────────────────────────────────────────\nexport interface FaqItemProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n /** The question (Figma \"Question\"). It is the label of the button that shows and hides the answer. */\n question: ReactNode;\n /** The answer (Figma \"Answer\"): text or any content — paragraphs, lists, links. */\n children?: ReactNode;\n /** Controlled state (Figma \"State\": Closed · Open). */\n open?: boolean;\n /** Initial state of an uncontrolled item. */\n defaultOpen?: boolean;\n /** Called with the new state when the user opens or closes the item. */\n onOpenChange?: (open: boolean) => void;\n /** Heading level of the question. Defaults to the `FaqList`'s level, otherwise `3`. */\n headingLevel?: FaqHeadingLevel;\n /** Identifies the item in a `type=\"single\"` `FaqList` (its `value` / `defaultValue`). Defaults to a generated id. */\n value?: string;\n}\n\n/**\n * One question of a FAQ (Figma component set \"FAQ item\"): a disclosure — a heading with a button\n * (`aria-expanded`) that reveals the answer below it.\n */\nexport const FaqItem = /* @__PURE__ */ forwardRef<HTMLDivElement, FaqItemProps>(function FaqItem(\n { question, children, open, defaultOpen = false, onOpenChange, headingLevel, value, id, className, ...props },\n ref,\n) {\n const list = useContext(ListContext);\n const [uncontrolled, setUncontrolled] = useState(defaultOpen);\n const autoId = useId();\n const itemValue = value ?? autoId;\n // In a single list the list holds the open item; an item's own `open` prop still wins.\n const isOpen = open ?? (list.single ? list.single.value === itemValue : uncontrolled);\n const baseId = id ?? autoId;\n const triggerId = `${baseId}-question`;\n const panelId = `${baseId}-answer`;\n const Heading = `h${headingLevel ?? list.headingLevel ?? 3}` as 'h3';\n\n const toggle = () => {\n if (open === undefined) {\n if (list.single) list.single.setValue(isOpen ? null : itemValue);\n else setUncontrolled(!isOpen);\n }\n onOpenChange?.(!isOpen);\n };\n\n return (\n <div ref={ref} id={id} className={cn('tm-faq-item', className)} data-open={isOpen ? '' : undefined} {...props}>\n <Heading className=\"tm-faq-item__heading\">\n <button type=\"button\" id={triggerId} className=\"tm-faq-item__trigger\" aria-expanded={isOpen} aria-controls={panelId} onClick={toggle}>\n <span className=\"tm-faq-item__question\">{question}</span>\n {/* Figma swaps down-arrow for up-arrow; one icon turned 180° is the same drawing and can animate. */}\n <DownArrowIcon size=\"md\" className=\"tm-faq-item__icon\" />\n </button>\n </Heading>\n {/* `hidden` keeps the closed answer out of the tab order and the accessibility tree; the CSS keeps it in the\n layout (collapsed, `visibility: hidden`) so the height can animate. */}\n <div id={panelId} className=\"tm-faq-item__panel\" role=\"region\" aria-labelledby={triggerId} hidden={!isOpen}>\n <div className=\"tm-faq-item__clip\">\n <div className=\"tm-faq-item__answer\">{children}</div>\n </div>\n </div>\n </div>\n );\n});\n\n// ── List ─────────────────────────────────────────────────────────────\nexport interface FaqListProps extends Omit<HTMLAttributes<HTMLDivElement>, 'defaultValue' | 'onChange'> {\n /** Heading level for the question of every item in the list (an item's own `headingLevel` wins). */\n headingLevel?: FaqHeadingLevel;\n /** `multiple` (default): every item opens and closes on its own. `single`: opening an item closes the open one. */\n type?: 'single' | 'multiple';\n /** `type=\"single\"`, controlled: `value` of the open item, or `null` for none. */\n value?: string | null;\n /** `type=\"single\"`, uncontrolled: `value` of the item open at first. None by default. */\n defaultValue?: string | null;\n /** `type=\"single\"`: called with the newly open item's `value`, or `null` when it closes. */\n onValueChange?: (value: string | null) => void;\n /**\n * Keeps the height the list has with its tallest answer open, so opening or switching answers never moves what\n * follows the list (use it with `type=\"single\"`). `true` always; a media query (e.g. `'(min-width: 1280px)'`) only\n * while it matches — say, where the list sits beside other content and would otherwise push the next section.\n * Measured in the browser and again whenever the list is resized; nothing is reserved before that.\n */\n reserveHeight?: boolean | string;\n}\n\n/** `true` while `query` matches; `true` for `true`, `false` for `false`. Starts `false` for a query (server markup). */\nfunction useMatches(query: boolean | string): boolean {\n const [matches, setMatches] = useState(false);\n useEffect(() => {\n if (typeof query !== 'string' || typeof window === 'undefined' || typeof window.matchMedia !== 'function') return;\n const media = window.matchMedia(query);\n const update = () => setMatches(media.matches);\n update();\n media.addEventListener?.('change', update);\n return () => media.removeEventListener?.('change', update);\n }, [query]);\n return typeof query === 'string' ? matches : query;\n}\n\n/**\n * Stacks `FaqItem`s (each draws its own divider) and sets the heading level of their questions once. With\n * `type=\"single\"` only one answer is open at a time; `reserveHeight` keeps the list as tall as with its tallest answer open.\n */\nexport const FaqList = /* @__PURE__ */ forwardRef<HTMLDivElement, FaqListProps>(function FaqList(\n { headingLevel, type = 'multiple', value, defaultValue = null, onValueChange, reserveHeight = false, className, style, children, ...props },\n ref,\n) {\n const [uncontrolled, setUncontrolled] = useState<string | null>(defaultValue);\n const openValue = value !== undefined ? value : uncontrolled;\n const setValue = useCallback(\n (next: string | null) => {\n if (value === undefined) setUncontrolled(next);\n onValueChange?.(next);\n },\n [value, onValueChange],\n );\n const single = type === 'single' ? { value: openValue, setValue } : undefined;\n\n const listRef = useRef<HTMLDivElement | null>(null);\n const [reserved, setReserved] = useState<number>();\n const measuring = reserveHeight !== false;\n const reserving = useMatches(reserveHeight) && reserved !== undefined;\n\n useIsomorphicLayoutEffect(() => {\n const list = listRef.current;\n if (!measuring || !list) return;\n\n // A closed answer may be out of the layout (an app's `[hidden] { display: none }`), so each answer is measured in\n // an invisible copy that has the answer's class and the list's width.\n const probe = document.createElement('div');\n probe.className = 'tm-faq-item__answer tm-faq-list__probe';\n probe.setAttribute('aria-hidden', 'true');\n list.appendChild(probe);\n\n const measure = () => {\n let rows = 0;\n let tallestAnswer = 0;\n for (const item of list.querySelectorAll<HTMLElement>(':scope > .tm-faq-item')) {\n const panel = item.querySelector<HTMLElement>('.tm-faq-item__panel');\n const answer = item.querySelector<HTMLElement>('.tm-faq-item__answer');\n // The item without its (possibly half-open) panel is the closed row.\n rows += item.offsetHeight - (panel?.offsetHeight ?? 0);\n probe.innerHTML = answer?.innerHTML ?? '';\n tallestAnswer = Math.max(tallestAnswer, probe.offsetHeight);\n }\n probe.innerHTML = '';\n const borders = list.offsetHeight - list.clientHeight;\n const next = Math.ceil(rows + tallestAnswer + borders);\n setReserved((current) => (current === next ? current : next));\n };\n\n measure();\n let observer: ResizeObserver | undefined;\n if (typeof ResizeObserver !== 'undefined') {\n // Width changes rewrap the text (and fonts may load late), so measure again whenever the list resizes.\n observer = new ResizeObserver(measure);\n observer.observe(list);\n }\n return () => {\n observer?.disconnect();\n probe.remove();\n };\n }, [measuring, children]);\n\n return (\n <div\n ref={(node) => {\n listRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n }}\n className={cn('tm-faq-list', className)}\n data-reserve-height={measuring ? '' : undefined}\n style={reserving ? ({ '--_reserved-height': `${reserved}px`, ...style } as CSSProperties) : style}\n {...props}\n >\n <ListContext.Provider value={{ headingLevel, single }}>{children}</ListContext.Provider>\n </div>\n );\n});\n"],"mappings":"A,2LAqBA,IAAMc,EAA4B,OAAO,OAAW,IAAcd,EAAAA,UAAYC,EAAAA,gBAQxEc,GAAA,EAAcb,EAAAA,cAAAA,CAAgC,CAAC,CAAC,EAwBzCc,GAA0B,EAAAJ,EAAA,WAAA,CAAyC,SAC9E,CAAE,WAAU,WAAU,OAAM,cA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GAAIrD,EAEJ,UAAA,EAAAJ,EAAA,IAAA,CAACE,EAAY,SAAb,CAAsB,MAAO,CAAE,eAAc,QAAO,EAAI,UAA+B,CAAA,CACpF,CAAA,CAET,CAAC,E"}
@@ -2,62 +2,107 @@
2
2
  import { DownArrowIcon as e } from "../../icons/generated/DownArrowIcon.js";
3
3
  import { cn as t } from "../../utils/cn.js";
4
4
  /* empty css */
5
- import { createContext as n, forwardRef as r, useContext as i, useId as a, useState as o } from "react";
6
- import { jsx as s, jsxs as c } from "react/jsx-runtime";
5
+ import { createContext as n, forwardRef as r, useCallback as i, useContext as a, useEffect as o, useId as s, useLayoutEffect as c, useRef as l, useState as u } from "react";
6
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
7
7
  // src/components/FaqItem/FaqItem.tsx
8
- var l = n({}), u = /* @__PURE__ */ r(function({ question: n, children: r, open: u, defaultOpen: d = !1, onOpenChange: f, headingLevel: p, id: m, className: h, ...g }, _) {
9
- let v = i(l), [y, b] = o(d), x = u ?? y, S = a(), C = m ?? S, w = `${C}-question`, T = `${C}-answer`, E = `h${p ?? v.headingLevel ?? 3}`, D = () => {
10
- u === void 0 && b(!x), f?.(!x);
8
+ var p = typeof window > "u" ? o : c, m = n({}), h = /* @__PURE__ */ r(function({ question: n, children: r, open: i, defaultOpen: o = !1, onOpenChange: c, headingLevel: l, value: p, id: h, className: g, ..._ }, v) {
9
+ let y = a(m), [b, x] = u(o), S = s(), C = p ?? S, w = i ?? (y.single ? y.single.value === C : b), T = h ?? S, E = `${T}-question`, D = `${T}-answer`, O = `h${l ?? y.headingLevel ?? 3}`, k = () => {
10
+ i === void 0 && (y.single ? y.single.setValue(w ? null : C) : x(!w)), c?.(!w);
11
11
  };
12
- return /* @__PURE__ */ c("div", {
13
- ref: _,
14
- id: m,
15
- className: t("tm-faq-item", h),
16
- "data-open": x ? "" : void 0,
17
- ...g,
18
- children: [/* @__PURE__ */ s(E, {
12
+ return /* @__PURE__ */ f("div", {
13
+ ref: v,
14
+ id: h,
15
+ className: t("tm-faq-item", g),
16
+ "data-open": w ? "" : void 0,
17
+ ..._,
18
+ children: [/* @__PURE__ */ d(O, {
19
19
  className: "tm-faq-item__heading",
20
- children: /* @__PURE__ */ c("button", {
20
+ children: /* @__PURE__ */ f("button", {
21
21
  type: "button",
22
- id: w,
22
+ id: E,
23
23
  className: "tm-faq-item__trigger",
24
- "aria-expanded": x,
25
- "aria-controls": T,
26
- onClick: D,
27
- children: [/* @__PURE__ */ s("span", {
24
+ "aria-expanded": w,
25
+ "aria-controls": D,
26
+ onClick: k,
27
+ children: [/* @__PURE__ */ d("span", {
28
28
  className: "tm-faq-item__question",
29
29
  children: n
30
- }), /* @__PURE__ */ s(e, {
30
+ }), /* @__PURE__ */ d(e, {
31
31
  size: "md",
32
32
  className: "tm-faq-item__icon"
33
33
  })]
34
34
  })
35
- }), /* @__PURE__ */ s("div", {
36
- id: T,
35
+ }), /* @__PURE__ */ d("div", {
36
+ id: D,
37
37
  className: "tm-faq-item__panel",
38
38
  role: "region",
39
- "aria-labelledby": w,
40
- hidden: !x,
41
- children: /* @__PURE__ */ s("div", {
39
+ "aria-labelledby": E,
40
+ hidden: !w,
41
+ children: /* @__PURE__ */ d("div", {
42
42
  className: "tm-faq-item__clip",
43
- children: /* @__PURE__ */ s("div", {
43
+ children: /* @__PURE__ */ d("div", {
44
44
  className: "tm-faq-item__answer",
45
45
  children: r
46
46
  })
47
47
  })
48
48
  })]
49
49
  });
50
- }), d = /* @__PURE__ */ r(function({ headingLevel: e, className: n, children: r, ...i }, a) {
51
- return /* @__PURE__ */ s("div", {
52
- ref: a,
53
- className: t("tm-faq-list", n),
54
- ...i,
55
- children: /* @__PURE__ */ s(l.Provider, {
56
- value: { headingLevel: e },
57
- children: r
50
+ });
51
+ function g(e) {
52
+ let [t, n] = u(!1);
53
+ return o(() => {
54
+ if (typeof e != "string" || typeof window > "u" || typeof window.matchMedia != "function") return;
55
+ let t = window.matchMedia(e), r = () => n(t.matches);
56
+ return r(), t.addEventListener?.("change", r), () => t.removeEventListener?.("change", r);
57
+ }, [e]), typeof e == "string" ? t : e;
58
+ }
59
+ var _ = /* @__PURE__ */ r(function({ headingLevel: e, type: n = "multiple", value: r, defaultValue: a = null, onValueChange: o, reserveHeight: s = !1, className: c, style: f, children: h, ..._ }, v) {
60
+ let [y, b] = u(a), x = r === void 0 ? y : r, S = i((e) => {
61
+ r === void 0 && b(e), o?.(e);
62
+ }, [r, o]), C = n === "single" ? {
63
+ value: x,
64
+ setValue: S
65
+ } : void 0, w = l(null), [T, E] = u(), D = s !== !1, O = g(s) && T !== void 0;
66
+ return p(() => {
67
+ let e = w.current;
68
+ if (!D || !e) return;
69
+ let t = document.createElement("div");
70
+ t.className = "tm-faq-item__answer tm-faq-list__probe", t.setAttribute("aria-hidden", "true"), e.appendChild(t);
71
+ let n = () => {
72
+ let n = 0, r = 0;
73
+ for (let i of e.querySelectorAll(":scope > .tm-faq-item")) {
74
+ let e = i.querySelector(".tm-faq-item__panel"), a = i.querySelector(".tm-faq-item__answer");
75
+ n += i.offsetHeight - (e?.offsetHeight ?? 0), t.innerHTML = a?.innerHTML ?? "", r = Math.max(r, t.offsetHeight);
76
+ }
77
+ t.innerHTML = "";
78
+ let i = e.offsetHeight - e.clientHeight, a = Math.ceil(n + r + i);
79
+ E((e) => e === a ? e : a);
80
+ };
81
+ n();
82
+ let r;
83
+ return typeof ResizeObserver < "u" && (r = new ResizeObserver(n), r.observe(e)), () => {
84
+ r?.disconnect(), t.remove();
85
+ };
86
+ }, [D, h]), /* @__PURE__ */ d("div", {
87
+ ref: (e) => {
88
+ w.current = e, typeof v == "function" ? v(e) : v && (v.current = e);
89
+ },
90
+ className: t("tm-faq-list", c),
91
+ "data-reserve-height": D ? "" : void 0,
92
+ style: O ? {
93
+ "--_reserved-height": `${T}px`,
94
+ ...f
95
+ } : f,
96
+ ..._,
97
+ children: /* @__PURE__ */ d(m.Provider, {
98
+ value: {
99
+ headingLevel: e,
100
+ single: C
101
+ },
102
+ children: h
58
103
  })
59
104
  });
60
105
  });
61
- export { u as FaqItem, d as FaqList };
106
+ export { h as FaqItem, _ as FaqList };
62
107
 
63
108
  //# sourceMappingURL=FaqItem.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FaqItem.js","names":["ListContext","createContext","FaqItem","props","list","useContext","uncontrolled","setUncontrolled","useState","defaultOpen","isOpen","open","autoId","useId","baseId","id","triggerId","panelId","Heading","headingLevel","toggle","onOpenChange","cn","className","question","DownArrowIcon","FaqList"],"sources":["../../../src/components/FaqItem/FaqItem.tsx"],"sourcesContent":["import { createContext, forwardRef, useContext, useId, useState, type HTMLAttributes, type ReactNode } from 'react';\nimport { DownArrowIcon } from '../../icons';\nimport { cn } from '../../utils/cn';\nimport './FaqItem.css';\n\n/** Heading level of the question (`<h2>`–`<h6>`); it depends on where the FAQ sits in the page outline. */\nexport type FaqHeadingLevel = 2 | 3 | 4 | 5 | 6;\n\nconst ListContext = createContext<{ headingLevel?: FaqHeadingLevel }>({});\n\n// ── Item ─────────────────────────────────────────────────────────────\nexport interface FaqItemProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n /** The question (Figma \"Question\"). It is the label of the button that shows and hides the answer. */\n question: ReactNode;\n /** The answer (Figma \"Answer\"): text or any content — paragraphs, lists, links. */\n children?: ReactNode;\n /** Controlled state (Figma \"State\": Closed · Open). */\n open?: boolean;\n /** Initial state of an uncontrolled item. */\n defaultOpen?: boolean;\n /** Called with the new state when the user opens or closes the item. */\n onOpenChange?: (open: boolean) => void;\n /** Heading level of the question. Defaults to the `FaqList`'s level, otherwise `3`. */\n headingLevel?: FaqHeadingLevel;\n}\n\n/**\n * One question of a FAQ (Figma component set \"FAQ item\"): a disclosure — a heading with a button\n * (`aria-expanded`) that reveals the answer below it.\n */\nexport const FaqItem = /* @__PURE__ */ forwardRef<HTMLDivElement, FaqItemProps>(function FaqItem(\n { question, children, open, defaultOpen = false, onOpenChange, headingLevel, id, className, ...props },\n ref,\n) {\n const list = useContext(ListContext);\n const [uncontrolled, setUncontrolled] = useState(defaultOpen);\n const isOpen = open ?? uncontrolled;\n const autoId = useId();\n const baseId = id ?? autoId;\n const triggerId = `${baseId}-question`;\n const panelId = `${baseId}-answer`;\n const Heading = `h${headingLevel ?? list.headingLevel ?? 3}` as 'h3';\n\n const toggle = () => {\n if (open === undefined) setUncontrolled(!isOpen);\n onOpenChange?.(!isOpen);\n };\n\n return (\n <div ref={ref} id={id} className={cn('tm-faq-item', className)} data-open={isOpen ? '' : undefined} {...props}>\n <Heading className=\"tm-faq-item__heading\">\n <button type=\"button\" id={triggerId} className=\"tm-faq-item__trigger\" aria-expanded={isOpen} aria-controls={panelId} onClick={toggle}>\n <span className=\"tm-faq-item__question\">{question}</span>\n {/* Figma swaps down-arrow for up-arrow; one icon turned 180° is the same drawing and can animate. */}\n <DownArrowIcon size=\"md\" className=\"tm-faq-item__icon\" />\n </button>\n </Heading>\n {/* `hidden` keeps the closed answer out of the tab order and the accessibility tree; the CSS keeps it in the\n layout (collapsed, `visibility: hidden`) so the height can animate. */}\n <div id={panelId} className=\"tm-faq-item__panel\" role=\"region\" aria-labelledby={triggerId} hidden={!isOpen}>\n <div className=\"tm-faq-item__clip\">\n <div className=\"tm-faq-item__answer\">{children}</div>\n </div>\n </div>\n </div>\n );\n});\n\n// ── List ─────────────────────────────────────────────────────────────\nexport interface FaqListProps extends HTMLAttributes<HTMLDivElement> {\n /** Heading level for the question of every item in the list (an item's own `headingLevel` wins). */\n headingLevel?: FaqHeadingLevel;\n}\n\n/** Stacks `FaqItem`s (each draws its own divider) and sets the heading level of their questions once. */\nexport const FaqList = /* @__PURE__ */ forwardRef<HTMLDivElement, FaqListProps>(function FaqList({ headingLevel, className, children, ...props }, ref) {\n return (\n <div ref={ref} className={cn('tm-faq-list', className)} {...props}>\n <ListContext.Provider value={{ headingLevel }}>{children}</ListContext.Provider>\n </div>\n );\n});\n"],"mappings":";;;;;;;AAQA,IAAMA,IAAcC,EAAkD,CAA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GAAIpB;EAC1D,UAAA,kBAACH,EAAY,UAAb;GAAsB,OAAO,EAAE,gBAAa;GAAI;EAA+B,CAAA;CAC5E,CAAA;AAET,CAAC"}
1
+ {"version":3,"file":"FaqItem.js","names":["useIsomorphicLayoutEffect","useEffect","useLayoutEffect","ListContext","createContext","FaqItem","props","list","useContext","uncontrolled","setUncontrolled","useState","defaultOpen","autoId","useId","itemValue","value","isOpen","open","baseId","id","triggerId","panelId","Heading","headingLevel","toggle","onOpenChange","cn","className","question","DownArrowIcon","useMatches","matches","setMatches","query","media","update","FaqList","defaultValue","openValue","setValue","useCallback","next","onValueChange","single","type","listRef","useRef","reserved","setReserved","measuring","reserveHeight","reserving","probe","measure","rows","tallestAnswer","item","panel","answer","borders","current","observer","children","node","ref","style"],"sources":["../../../src/components/FaqItem/FaqItem.tsx"],"sourcesContent":["import {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type CSSProperties,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport { DownArrowIcon } from '../../icons';\nimport { cn } from '../../utils/cn';\nimport './FaqItem.css';\n\n/** Heading level of the question (`<h2>`–`<h6>`); it depends on where the FAQ sits in the page outline. */\nexport type FaqHeadingLevel = 2 | 3 | 4 | 5 | 6;\n\nconst useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\ninterface ListContextValue {\n headingLevel?: FaqHeadingLevel;\n /** Set in a `type=\"single\"` list: the open item's value and the setter. */\n single?: { value: string | null; setValue: (value: string | null) => void };\n}\n\nconst ListContext = createContext<ListContextValue>({});\n\n// ── Item ─────────────────────────────────────────────────────────────\nexport interface FaqItemProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n /** The question (Figma \"Question\"). It is the label of the button that shows and hides the answer. */\n question: ReactNode;\n /** The answer (Figma \"Answer\"): text or any content — paragraphs, lists, links. */\n children?: ReactNode;\n /** Controlled state (Figma \"State\": Closed · Open). */\n open?: boolean;\n /** Initial state of an uncontrolled item. */\n defaultOpen?: boolean;\n /** Called with the new state when the user opens or closes the item. */\n onOpenChange?: (open: boolean) => void;\n /** Heading level of the question. Defaults to the `FaqList`'s level, otherwise `3`. */\n headingLevel?: FaqHeadingLevel;\n /** Identifies the item in a `type=\"single\"` `FaqList` (its `value` / `defaultValue`). Defaults to a generated id. */\n value?: string;\n}\n\n/**\n * One question of a FAQ (Figma component set \"FAQ item\"): a disclosure — a heading with a button\n * (`aria-expanded`) that reveals the answer below it.\n */\nexport const FaqItem = /* @__PURE__ */ forwardRef<HTMLDivElement, FaqItemProps>(function FaqItem(\n { question, children, open, defaultOpen = false, onOpenChange, headingLevel, value, id, className, ...props },\n ref,\n) {\n const list = useContext(ListContext);\n const [uncontrolled, setUncontrolled] = useState(defaultOpen);\n const autoId = useId();\n const itemValue = value ?? autoId;\n // In a single list the list holds the open item; an item's own `open` prop still wins.\n const isOpen = open ?? (list.single ? list.single.value === itemValue : uncontrolled);\n const baseId = id ?? autoId;\n const triggerId = `${baseId}-question`;\n const panelId = `${baseId}-answer`;\n const Heading = `h${headingLevel ?? list.headingLevel ?? 3}` as 'h3';\n\n const toggle = () => {\n if (open === undefined) {\n if (list.single) list.single.setValue(isOpen ? null : itemValue);\n else setUncontrolled(!isOpen);\n }\n onOpenChange?.(!isOpen);\n };\n\n return (\n <div ref={ref} id={id} className={cn('tm-faq-item', className)} data-open={isOpen ? '' : undefined} {...props}>\n <Heading className=\"tm-faq-item__heading\">\n <button type=\"button\" id={triggerId} className=\"tm-faq-item__trigger\" aria-expanded={isOpen} aria-controls={panelId} onClick={toggle}>\n <span className=\"tm-faq-item__question\">{question}</span>\n {/* Figma swaps down-arrow for up-arrow; one icon turned 180° is the same drawing and can animate. */}\n <DownArrowIcon size=\"md\" className=\"tm-faq-item__icon\" />\n </button>\n </Heading>\n {/* `hidden` keeps the closed answer out of the tab order and the accessibility tree; the CSS keeps it in the\n layout (collapsed, `visibility: hidden`) so the height can animate. */}\n <div id={panelId} className=\"tm-faq-item__panel\" role=\"region\" aria-labelledby={triggerId} hidden={!isOpen}>\n <div className=\"tm-faq-item__clip\">\n <div className=\"tm-faq-item__answer\">{children}</div>\n </div>\n </div>\n </div>\n );\n});\n\n// ── List ─────────────────────────────────────────────────────────────\nexport interface FaqListProps extends Omit<HTMLAttributes<HTMLDivElement>, 'defaultValue' | 'onChange'> {\n /** Heading level for the question of every item in the list (an item's own `headingLevel` wins). */\n headingLevel?: FaqHeadingLevel;\n /** `multiple` (default): every item opens and closes on its own. `single`: opening an item closes the open one. */\n type?: 'single' | 'multiple';\n /** `type=\"single\"`, controlled: `value` of the open item, or `null` for none. */\n value?: string | null;\n /** `type=\"single\"`, uncontrolled: `value` of the item open at first. None by default. */\n defaultValue?: string | null;\n /** `type=\"single\"`: called with the newly open item's `value`, or `null` when it closes. */\n onValueChange?: (value: string | null) => void;\n /**\n * Keeps the height the list has with its tallest answer open, so opening or switching answers never moves what\n * follows the list (use it with `type=\"single\"`). `true` always; a media query (e.g. `'(min-width: 1280px)'`) only\n * while it matches — say, where the list sits beside other content and would otherwise push the next section.\n * Measured in the browser and again whenever the list is resized; nothing is reserved before that.\n */\n reserveHeight?: boolean | string;\n}\n\n/** `true` while `query` matches; `true` for `true`, `false` for `false`. Starts `false` for a query (server markup). */\nfunction useMatches(query: boolean | string): boolean {\n const [matches, setMatches] = useState(false);\n useEffect(() => {\n if (typeof query !== 'string' || typeof window === 'undefined' || typeof window.matchMedia !== 'function') return;\n const media = window.matchMedia(query);\n const update = () => setMatches(media.matches);\n update();\n media.addEventListener?.('change', update);\n return () => media.removeEventListener?.('change', update);\n }, [query]);\n return typeof query === 'string' ? matches : query;\n}\n\n/**\n * Stacks `FaqItem`s (each draws its own divider) and sets the heading level of their questions once. With\n * `type=\"single\"` only one answer is open at a time; `reserveHeight` keeps the list as tall as with its tallest answer open.\n */\nexport const FaqList = /* @__PURE__ */ forwardRef<HTMLDivElement, FaqListProps>(function FaqList(\n { headingLevel, type = 'multiple', value, defaultValue = null, onValueChange, reserveHeight = false, className, style, children, ...props },\n ref,\n) {\n const [uncontrolled, setUncontrolled] = useState<string | null>(defaultValue);\n const openValue = value !== undefined ? value : uncontrolled;\n const setValue = useCallback(\n (next: string | null) => {\n if (value === undefined) setUncontrolled(next);\n onValueChange?.(next);\n },\n [value, onValueChange],\n );\n const single = type === 'single' ? { value: openValue, setValue } : undefined;\n\n const listRef = useRef<HTMLDivElement | null>(null);\n const [reserved, setReserved] = useState<number>();\n const measuring = reserveHeight !== false;\n const reserving = useMatches(reserveHeight) && reserved !== undefined;\n\n useIsomorphicLayoutEffect(() => {\n const list = listRef.current;\n if (!measuring || !list) return;\n\n // A closed answer may be out of the layout (an app's `[hidden] { display: none }`), so each answer is measured in\n // an invisible copy that has the answer's class and the list's width.\n const probe = document.createElement('div');\n probe.className = 'tm-faq-item__answer tm-faq-list__probe';\n probe.setAttribute('aria-hidden', 'true');\n list.appendChild(probe);\n\n const measure = () => {\n let rows = 0;\n let tallestAnswer = 0;\n for (const item of list.querySelectorAll<HTMLElement>(':scope > .tm-faq-item')) {\n const panel = item.querySelector<HTMLElement>('.tm-faq-item__panel');\n const answer = item.querySelector<HTMLElement>('.tm-faq-item__answer');\n // The item without its (possibly half-open) panel is the closed row.\n rows += item.offsetHeight - (panel?.offsetHeight ?? 0);\n probe.innerHTML = answer?.innerHTML ?? '';\n tallestAnswer = Math.max(tallestAnswer, probe.offsetHeight);\n }\n probe.innerHTML = '';\n const borders = list.offsetHeight - list.clientHeight;\n const next = Math.ceil(rows + tallestAnswer + borders);\n setReserved((current) => (current === next ? current : next));\n };\n\n measure();\n let observer: ResizeObserver | undefined;\n if (typeof ResizeObserver !== 'undefined') {\n // Width changes rewrap the text (and fonts may load late), so measure again whenever the list resizes.\n observer = new ResizeObserver(measure);\n observer.observe(list);\n }\n return () => {\n observer?.disconnect();\n probe.remove();\n };\n }, [measuring, children]);\n\n return (\n <div\n ref={(node) => {\n listRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n }}\n className={cn('tm-faq-list', className)}\n data-reserve-height={measuring ? '' : undefined}\n style={reserving ? ({ '--_reserved-height': `${reserved}px`, ...style } as CSSProperties) : style}\n {...props}\n >\n <ListContext.Provider value={{ headingLevel, single }}>{children}</ListContext.Provider>\n </div>\n );\n});\n"],"mappings":";;;;;;;AAqBA,IAAMA,IAA4B,OAAO,SAAW,MAAcC,IAAYC,GAQxEC,IAAcC,EAAgC,CAAC,CAAC,GAwBzCC,IAA0B,kBAAyC,SAC9E,EAAE,aAAU,aAAU,SAAM,iBAAc,IAAO,iBAAc,iBAAc,UAAO,OAAI,cAAW,GAAGC,KACtG,GACA;CACA,IAAMC,IAAOC,EAAWL,CAAW,GAC7B,CAACM,GAAcC,KAAmBC,EAASC,CAAW,GACtDC,IAASC,EAAM,GACfC,IAAYC,KAASH,GAErBI,IAASC,MAASX,EAAK,SAASA,EAAK,OAAO,UAAUQ,IAAYN,IAClEU,IAASC,KAAMP,GACfQ,IAAY,GAAGF,EAAO,YACtBG,IAAU,GAAGH,EAAO,UACpBI,IAAU,IAAIC,KAAgBjB,EAAK,gBAAgB,KAEnDkB,UAAe;EAKnB,AAJIP,MAAS,KAAA,MACPX,EAAK,SAAQA,EAAK,OAAO,SAASU,IAAS,OAAOF,CAAS,IAC1DL,EAAgB,CAACO,CAAM,IAE9BS,IAAe,CAACT,CAAM;CACxB;CAEA,OACE,kBAAC,OAAD;EAAU;EAAS;EAAI,WAAWU,EAAG,eAAeC,CAAS;EAAG,aAAWX,IAAS,KAAK,KAAA;EAAW,GAAIX;EAAxG,UAAA,CACE,kBAACiB,GAAD;GAAS,WAAU;GACjB,UAAA,kBAAC,UAAD;IAAQ,MAAK;IAAS,IAAIF;IAAW,WAAU;IAAuB,iBAAeJ;IAAQ,iBAAeK;IAAS,SAASG;IAA9H,UAAA,CACE,kBAAC,QAAD;KAAM,WAAU;KAAyB,UAAAI;IAAe,CAAA,GAExD,kBAACC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GAAI5D;EAEJ,UAAA,kBAACH,EAAY,UAAb;GAAsB,OAAO;IAAE;IAAc;GAAO;GAAI;EAA+B,CAAA;CACpF,CAAA;AAET,CAAC"}
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../icons/generated/CheckmarkIcon.cjs"),t=require("../../icons/generated/ErrorCircleIcon.cjs"),n=require("../../utils/cn.cjs");;/* empty css */let r=require("react"),i=require("react/jsx-runtime");var a=(0,r.forwardRef)(function({size:e=`md`,required:t,optional:r,className:a,children:o,...s},c){return(0,i.jsxs)(`label`,{ref:c,className:n.cn(`tm-label`,a),"data-size":e,...s,children:[o,t?(0,i.jsx)(`span`,{className:`tm-label__required`,"aria-hidden":`true`,children:`*`}):null,r?(0,i.jsx)(`span`,{className:`tm-label__optional`,children:typeof r==`string`?r:`(Optional)`}):null]})}),o=(0,r.forwardRef)(function({tone:r=`neutral`,size:a=`md`,icon:o=r!==`neutral`,className:s,children:c,...l},u){return(0,i.jsxs)(`p`,{ref:u,className:n.cn(`tm-field-message`,s),"data-tone":r,"data-size":a,...l,children:[o?r===`success`?(0,i.jsx)(e.CheckmarkIcon,{size:a===`lg`?`md`:`sm`}):(0,i.jsx)(t.ErrorCircleIcon,{size:a===`lg`?`md`:`sm`}):null,(0,i.jsx)(`span`,{children:c})]})});function s(e,t){let n=(0,r.useId)(),i=e??`tm-${n}`;return{controlId:i,labelId:`${i}-label`,messageId:t?`${i}-message`:void 0}}var c=(0,r.forwardRef)(function({ids:e,label:t,helperText:r,error:s,required:c,optional:l,size:u=`md`,helperIcon:d,className:f,children:p,...m},h){let g=s||r;return(0,i.jsxs)(`div`,{ref:h,className:n.cn(`tm-form-field`,f),"data-size":u,...m,children:[t?(0,i.jsx)(a,{id:e.labelId,htmlFor:e.controlId,size:u,required:c,optional:l,children:t}):null,p,g?(0,i.jsx)(o,{id:e.messageId,tone:s?`error`:`neutral`,size:u,icon:s?!0:d,children:g}):null]})});exports.FieldMessage=o,exports.FormField=c,exports.Label=a,exports.useFieldIds=s;
1
+ "use client";const e=require("../../icons/generated/CheckmarkIcon.cjs"),t=require("../../icons/generated/ErrorCircleIcon.cjs"),n=require("../../utils/cn.cjs");;/* empty css */let r=require("react"),i=require("react/jsx-runtime");var a=(0,r.forwardRef)(function({size:e=`md`,required:t,optional:r,className:a,children:o,...s},c){return(0,i.jsxs)(`label`,{ref:c,className:n.cn(`tm-label`,a),"data-size":e,...s,children:[o,t?(0,i.jsx)(`span`,{className:`tm-label__required`,"aria-hidden":`true`,children:`*`}):null,r?(0,i.jsx)(`span`,{className:`tm-label__optional`,children:typeof r==`string`?r:`(Optional)`}):null]})}),o=(0,r.forwardRef)(function({tone:r=`neutral`,size:a=`md`,icon:o=r!==`neutral`,className:s,children:c,...l},u){return(0,i.jsxs)(`p`,{ref:u,className:n.cn(`tm-field-message`,s),"data-tone":r,"data-size":a,...l,children:[o?r===`success`?(0,i.jsx)(e.CheckmarkIcon,{size:a===`lg`?`md`:`sm`}):(0,i.jsx)(t.ErrorCircleIcon,{size:a===`lg`?`md`:`sm`}):null,(0,i.jsx)(`span`,{children:c})]})});function s(e,t){let n=(0,r.useId)(),i=e??`tm-${n}`;return{controlId:i,labelId:`${i}-label`,messageId:t?`${i}-message`:void 0}}var c=(0,r.forwardRef)(function({ids:e,label:t,helperText:r,error:s,required:c,optional:l,size:u=`md`,helperIcon:d,errorColor:f,errorBox:p,className:m,children:h,...g},_){let v=s||r;return(0,i.jsxs)(`div`,{ref:_,className:n.cn(`tm-form-field`,m),"data-size":u,"data-error-color":f===`content`?`content`:void 0,"data-error-box":p===`neutral`?`neutral`:void 0,...g,children:[t?(0,i.jsx)(a,{id:e.labelId,htmlFor:e.controlId,size:u,required:c,optional:l,children:t}):null,h,v?(0,i.jsx)(o,{id:e.messageId,tone:s?`error`:`neutral`,size:u,icon:s?!0:d,children:v}):null]})});exports.FieldMessage=o,exports.FormField=c,exports.Label=a,exports.useFieldIds=s;
2
2
  //# sourceMappingURL=Field.cjs.map