@travel-match/ui 0.2.0 → 0.3.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 (40) hide show
  1. package/dist/components/CtaSentence/CtaSentence.cjs +1 -1
  2. package/dist/components/CtaSentence/CtaSentence.cjs.map +1 -1
  3. package/dist/components/CtaSentence/CtaSentence.js +142 -69
  4. package/dist/components/CtaSentence/CtaSentence.js.map +1 -1
  5. package/dist/components/HeroColumns/heroMotion.cjs +1 -1
  6. package/dist/components/HeroColumns/heroMotion.cjs.map +1 -1
  7. package/dist/components/HeroColumns/heroMotion.js +7 -44
  8. package/dist/components/HeroColumns/heroMotion.js.map +1 -1
  9. package/dist/components/HeroMap/HeroMap.cjs +1 -1
  10. package/dist/components/HeroMap/HeroMap.cjs.map +1 -1
  11. package/dist/components/HeroMap/HeroMap.js +58 -67
  12. package/dist/components/HeroMap/HeroMap.js.map +1 -1
  13. package/dist/components/HeroSwitcher/HeroSwitcher.cjs +1 -1
  14. package/dist/components/HeroSwitcher/HeroSwitcher.cjs.map +1 -1
  15. package/dist/components/HeroSwitcher/HeroSwitcher.js +85 -92
  16. package/dist/components/HeroSwitcher/HeroSwitcher.js.map +1 -1
  17. package/dist/components/HowItWorksSteps/HowItWorksSteps.cjs +1 -1
  18. package/dist/components/HowItWorksSteps/HowItWorksSteps.cjs.map +1 -1
  19. package/dist/components/HowItWorksSteps/HowItWorksSteps.js +84 -102
  20. package/dist/components/HowItWorksSteps/HowItWorksSteps.js.map +1 -1
  21. package/dist/components/PackageAnimation/PackageAnimation.cjs +1 -1
  22. package/dist/components/PackageAnimation/PackageAnimation.cjs.map +1 -1
  23. package/dist/components/PackageAnimation/PackageAnimation.js +31 -40
  24. package/dist/components/PackageAnimation/PackageAnimation.js.map +1 -1
  25. package/dist/components/PartnerCarousel/PartnerCarousel.cjs +1 -1
  26. package/dist/components/PartnerCarousel/PartnerCarousel.cjs.map +1 -1
  27. package/dist/components/PartnerCarousel/PartnerCarousel.js +94 -101
  28. package/dist/components/PartnerCarousel/PartnerCarousel.js.map +1 -1
  29. package/dist/components/PartnerCarousel/autoplay.cjs +1 -1
  30. package/dist/components/PartnerCarousel/autoplay.cjs.map +1 -1
  31. package/dist/components/PartnerCarousel/autoplay.js +13 -9
  32. package/dist/components/PartnerCarousel/autoplay.js.map +1 -1
  33. package/dist/index.d.cts +33 -55
  34. package/dist/index.d.ts +33 -55
  35. package/dist/styles.css +1 -1
  36. package/package.json +1 -1
  37. package/dist/components/PartnerCarousel/AutoplayToggle.cjs +0 -2
  38. package/dist/components/PartnerCarousel/AutoplayToggle.cjs.map +0 -1
  39. package/dist/components/PartnerCarousel/AutoplayToggle.js +0 -36
  40. package/dist/components/PartnerCarousel/AutoplayToggle.js.map +0 -1
@@ -31,129 +31,111 @@ var l = /* @__PURE__ */ n(function({ icon: e, className: n, children: r, ...i },
31
31
  document.removeEventListener("visibilitychange", n), i?.disconnect();
32
32
  };
33
33
  }, [e, t]), n && a;
34
- }, p = /* @__PURE__ */ n(function({ items: n, value: l, defaultValue: p, onValueChange: m, autoPlay: h = !1, interval: g = 2200, paused: _ = !1, label: v, pauseLabel: y = "Pause", playLabel: b = "Play", collapseBelow: x, className: S, style: C, onPointerEnter: w, onPointerLeave: T, onFocus: E, onBlur: D, ...O }, k) {
35
- let A = a(null), j = r((e) => {
36
- A.current = e, typeof k == "function" ? k(e) : k && (k.current = e);
37
- }, [k]), [M, N] = o(p), [P, F] = o(!1), [I, L] = o(!1), [R, z] = o(!1), B = d(), V = f(A, h), H = n.length, U = l === void 0 ? M : l, W = n.findIndex((e) => e.value === U), G = W === -1 ? 0 : W, K = (e) => {
34
+ }, p = /* @__PURE__ */ n(function({ items: n, value: l, defaultValue: p, onValueChange: m, autoPlay: h = !1, interval: g = 2200, paused: _ = !1, label: v, collapseBelow: y, className: b, style: x, onPointerEnter: S, onPointerLeave: C, onFocus: w, onBlur: T, ...E }, D) {
35
+ let O = a(null), k = r((e) => {
36
+ O.current = e, typeof D == "function" ? D(e) : D && (D.current = e);
37
+ }, [D]), [A, j] = o(p), [M, N] = o(!1), [P, F] = o(!1), I = d(), L = f(O, h), R = n.length, z = l === void 0 ? A : l, B = n.findIndex((e) => e.value === z), V = B === -1 ? 0 : B, H = (e) => {
38
38
  let t = n[e];
39
- t && e !== G && (l === void 0 && N(t.value), m?.(t.value));
40
- }, q = a(K);
41
- q.current = K;
42
- let J = h && H > 1 && !B, Y = J && !P && !_ && !I && !R && V;
39
+ t && e !== V && (l === void 0 && j(t.value), m?.(t.value));
40
+ }, U = a(H);
41
+ U.current = H;
42
+ let W = h && R > 1 && !I && !_ && !M && !P && L;
43
43
  if (i(() => {
44
- if (!Y) return;
45
- let e = window.setTimeout(() => q.current((G + 1) % H), Math.max(g, 0) + u);
44
+ if (!W) return;
45
+ let e = window.setTimeout(() => U.current((V + 1) % R), Math.max(g, 0) + u);
46
46
  return () => window.clearTimeout(e);
47
47
  }, [
48
- Y,
49
- G,
50
- H,
48
+ W,
49
+ V,
50
+ R,
51
51
  g
52
- ]), H === 0) return null;
53
- let X = Math.max(480, x ?? H * 136 + (H - 1) * 16), Z = {
54
- "--_count": H,
55
- "--_progress": H > 1 ? G / (H - 1) : 0,
56
- "--_collapse": X,
57
- ...C
52
+ ]), R === 0) return null;
53
+ let G = Math.max(480, y ?? R * 136 + (R - 1) * 16), K = {
54
+ "--_count": R,
55
+ "--_progress": R > 1 ? V / (R - 1) : 0,
56
+ "--_collapse": G,
57
+ ...x
58
58
  };
59
59
  return /* @__PURE__ */ s("div", {
60
- ref: j,
61
- className: t("tm-how-it-works-steps", S),
62
- style: Z,
63
- "data-playing": Y ? "" : void 0,
60
+ ref: k,
61
+ className: t("tm-how-it-works-steps", b),
62
+ style: K,
63
+ "data-playing": W ? "" : void 0,
64
64
  onPointerEnter: (e) => {
65
- w?.(e), e.pointerType !== "touch" && L(!0);
65
+ S?.(e), e.pointerType !== "touch" && N(!0);
66
66
  },
67
67
  onPointerLeave: (e) => {
68
- T?.(e), L(!1);
68
+ C?.(e), N(!1);
69
69
  },
70
70
  onFocus: (e) => {
71
- E?.(e), z(!0);
71
+ w?.(e);
72
+ let t = !0;
73
+ try {
74
+ t = e.target.matches(":focus-visible");
75
+ } catch {}
76
+ t && F(!0);
72
77
  },
73
78
  onBlur: (e) => {
74
- D?.(e), e.currentTarget.contains(e.relatedTarget) || z(!1);
79
+ T?.(e), e.currentTarget.contains(e.relatedTarget) || F(!1);
75
80
  },
76
- ...O,
81
+ ...E,
77
82
  children: /* @__PURE__ */ s("div", {
78
83
  className: "tm-how-it-works-steps__frame",
79
84
  children: /* @__PURE__ */ c("div", {
80
85
  className: "tm-how-it-works-steps__inner",
81
- children: [
82
- J ? /* @__PURE__ */ s("div", {
83
- className: "tm-how-it-works-steps__controls",
84
- children: /* @__PURE__ */ s("button", {
85
- type: "button",
86
- className: "tm-how-it-works-steps__toggle",
87
- "aria-label": P ? b : y,
88
- onClick: () => F((e) => !e),
89
- children: /* @__PURE__ */ s("svg", {
90
- viewBox: "0 0 16 16",
91
- width: "16",
92
- height: "16",
93
- fill: "currentColor",
94
- "aria-hidden": "true",
95
- focusable: "false",
96
- children: P ? /* @__PURE__ */ s("path", { d: "M5 3.2v9.6a.6.6 0 0 0 .92.5l7.4-4.8a.6.6 0 0 0 0-1L5.92 2.7a.6.6 0 0 0-.92.5Z" }) : /* @__PURE__ */ s("path", { d: "M4 3h3v10H4zM9 3h3v10H9z" })
86
+ children: [/* @__PURE__ */ c("div", {
87
+ className: "tm-how-it-works-steps__rail",
88
+ "aria-hidden": "true",
89
+ "data-tm-icon-size": "sm",
90
+ children: [
91
+ /* @__PURE__ */ s("span", { className: "tm-how-it-works-steps__track" }),
92
+ /* @__PURE__ */ s("span", { className: "tm-how-it-works-steps__progress" }),
93
+ n.map((t, n) => /* @__PURE__ */ c("span", {
94
+ className: "tm-how-it-works-steps__node",
95
+ "data-state": n < V ? "done" : n === V ? "current" : "upcoming",
96
+ children: [/* @__PURE__ */ s("span", {
97
+ className: "tm-how-it-works-steps__number",
98
+ children: n + 1
99
+ }), /* @__PURE__ */ s(e, { className: "tm-how-it-works-steps__check" })]
100
+ }, t.value))
101
+ ]
102
+ }), /* @__PURE__ */ s("ol", {
103
+ className: "tm-how-it-works-steps__list",
104
+ "aria-label": v,
105
+ children: n.map((e, t) => {
106
+ let n = t === V;
107
+ return /* @__PURE__ */ s("li", {
108
+ className: "tm-how-it-works-steps__item",
109
+ children: /* @__PURE__ */ c("button", {
110
+ type: "button",
111
+ className: "tm-how-it-works-steps__card",
112
+ "aria-current": n ? "step" : void 0,
113
+ "data-current": n ? "" : void 0,
114
+ onClick: () => H(t),
115
+ children: [/* @__PURE__ */ c("span", {
116
+ className: "tm-how-it-works-steps__main",
117
+ children: [e.icon ? /* @__PURE__ */ s("span", {
118
+ className: "tm-how-it-works-steps__icon",
119
+ "data-tm-icon-size": "md",
120
+ children: e.icon
121
+ }) : null, /* @__PURE__ */ c("span", {
122
+ className: "tm-how-it-works-steps__text",
123
+ children: [/* @__PURE__ */ s("span", {
124
+ className: "tm-how-it-works-steps__title",
125
+ children: e.title
126
+ }), e.description ? /* @__PURE__ */ s("span", {
127
+ className: "tm-how-it-works-steps__description",
128
+ children: e.description
129
+ }) : null]
130
+ })]
131
+ }), e.badge ? /* @__PURE__ */ s("span", {
132
+ className: "tm-how-it-works-steps__badge",
133
+ children: e.badge
134
+ }) : null]
97
135
  })
98
- })
99
- }) : null,
100
- /* @__PURE__ */ c("div", {
101
- className: "tm-how-it-works-steps__rail",
102
- "aria-hidden": "true",
103
- "data-tm-icon-size": "sm",
104
- children: [
105
- /* @__PURE__ */ s("span", { className: "tm-how-it-works-steps__track" }),
106
- /* @__PURE__ */ s("span", { className: "tm-how-it-works-steps__progress" }),
107
- n.map((t, n) => /* @__PURE__ */ c("span", {
108
- className: "tm-how-it-works-steps__node",
109
- "data-state": n < G ? "done" : n === G ? "current" : "upcoming",
110
- children: [/* @__PURE__ */ s("span", {
111
- className: "tm-how-it-works-steps__number",
112
- children: n + 1
113
- }), /* @__PURE__ */ s(e, { className: "tm-how-it-works-steps__check" })]
114
- }, t.value))
115
- ]
116
- }),
117
- /* @__PURE__ */ s("ol", {
118
- className: "tm-how-it-works-steps__list",
119
- "aria-label": v,
120
- children: n.map((e, t) => {
121
- let n = t === G;
122
- return /* @__PURE__ */ s("li", {
123
- className: "tm-how-it-works-steps__item",
124
- children: /* @__PURE__ */ c("button", {
125
- type: "button",
126
- className: "tm-how-it-works-steps__card",
127
- "aria-current": n ? "step" : void 0,
128
- "data-current": n ? "" : void 0,
129
- onClick: () => {
130
- F(!0), K(t);
131
- },
132
- children: [/* @__PURE__ */ c("span", {
133
- className: "tm-how-it-works-steps__main",
134
- children: [e.icon ? /* @__PURE__ */ s("span", {
135
- className: "tm-how-it-works-steps__icon",
136
- "data-tm-icon-size": "md",
137
- children: e.icon
138
- }) : null, /* @__PURE__ */ c("span", {
139
- className: "tm-how-it-works-steps__text",
140
- children: [/* @__PURE__ */ s("span", {
141
- className: "tm-how-it-works-steps__title",
142
- children: e.title
143
- }), e.description ? /* @__PURE__ */ s("span", {
144
- className: "tm-how-it-works-steps__description",
145
- children: e.description
146
- }) : null]
147
- })]
148
- }), e.badge ? /* @__PURE__ */ s("span", {
149
- className: "tm-how-it-works-steps__badge",
150
- children: e.badge
151
- }) : null]
152
- })
153
- }, e.value);
154
- })
136
+ }, e.value);
155
137
  })
156
- ]
138
+ })]
157
139
  })
158
140
  })
159
141
  });
@@ -1 +1 @@
1
- {"version":3,"file":"HowItWorksSteps.js","names":["HowItWorksStepTag","props","cn","className","icon","children","STEP_DURATION","useReducedMotion","reduced","setReduced","useState","useEffect","query","update","useOnScreen","inView","setInView","tabVisible","setTabVisible","enabled","observer","ref","entry","HowItWorksSteps","rootRef","useRef","setRef","useCallback","node","uncontrolled","setUncontrolled","defaultValue","stopped","setStopped","hovered","setHovered","focused","setFocused","reducedMotion","onScreen","autoPlay","count","items","requested","value","found","item","activeIndex","select","next","index","onValueChange","selectRef","canPlay","playing","paused","timer","interval","threshold","collapseBelow","rootStyle","style","onPointerEnter","event","onPointerLeave","onFocus","onBlur","playLabel","pauseLabel","current","CheckmarkIcon","label","isCurrent"],"sources":["../../../src/components/HowItWorksSteps/HowItWorksSteps.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useRef,\n useState,\n type CSSProperties,\n type FocusEvent,\n type HTMLAttributes,\n type PointerEvent,\n type ReactNode,\n} from 'react';\nimport { CheckmarkIcon } from '../../icons';\nimport { cn } from '../../utils/cn';\nimport './HowItWorksSteps.css';\n\nexport interface HowItWorksStepItem {\n /** Identifies the step in `value` / `onValueChange`. */\n value: string;\n /** One icon from `@travel-match/ui` for the icon tile, e.g. `<PaperIcon />`. */\n icon?: ReactNode;\n /** Step name, e.g. \"Submit a request\". Phrasing content only — it is rendered inside a button. */\n title: ReactNode;\n /** One or two sentences about the step. Phrasing content only. */\n description?: ReactNode;\n /** Pill at the bottom of the card, e.g. a `<RequestStatus>` or a `<Tag>`. Must not be interactive. */\n badge?: ReactNode;\n}\n\nexport interface HowItWorksStepsProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'defaultValue' | 'onChange'> {\n /** The steps, in order. Nothing is rendered for an empty list. */\n items: HowItWorksStepItem[];\n /** Controlled: `value` of the current step (Figma \"Step\"). */\n value?: string;\n /** Uncontrolled: `value` of the step that starts current. Defaults to the first one. */\n defaultValue?: string;\n /** Called with the `value` of the step that became current, by a click or by auto-play. */\n onValueChange?: (value: string) => void;\n /** Advances to the next step on a timer and loops. Stops for good once the user picks a step or presses pause. */\n autoPlay?: boolean;\n /** Time a step rests once its 500ms transition has finished, in ms (Figma: 2200 — a new step every 2.7s). */\n interval?: number;\n /** Holds auto-play without unmounting it (e.g. while a dialog is open). */\n paused?: boolean;\n /** Accessible name of the list of steps, e.g. \"How it works\". */\n label?: string;\n /** Accessible name of the pause button shown while auto-playing. Translate it in the app. */\n pauseLabel?: string;\n /** Accessible name of the same button once auto-play is paused. Translate it in the app. */\n playLabel?: string;\n /** Width of the component in px below which the steps stack (the Figma mobile layout). Default: 136px per step plus the gaps, at least 480. */\n collapseBelow?: number;\n}\n\nexport interface HowItWorksStepTagProps extends HTMLAttributes<HTMLSpanElement> {\n /** One icon from `@travel-match/ui`, e.g. `<CompareIcon />`. */\n icon?: ReactNode;\n}\n\n/** The tinted pill Figma draws at the bottom of the steps that have no request status (\"Up to 3 offers\"). Use it as a step's `badge`. */\nexport const HowItWorksStepTag = /* @__PURE__ */ forwardRef<HTMLSpanElement, HowItWorksStepTagProps>(function HowItWorksStepTag(\n { icon, className, children, ...props },\n ref,\n) {\n return (\n <span ref={ref} className={cn('tm-how-it-works-steps__tag', className)} data-tm-icon-size=\"sm\" {...props}>\n {icon}\n {children}\n </span>\n );\n});\n\n/** Figma prototype: Smart animate, ease in and out, 500ms. Keep in sync with `--_duration` in the stylesheet. */\nconst STEP_DURATION = 500;\n\nconst useReducedMotion = () => {\n const [reduced, setReduced] = useState(false);\n useEffect(() => {\n if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') return;\n const query = window.matchMedia('(prefers-reduced-motion: reduce)');\n const update = () => setReduced(query.matches);\n update();\n query.addEventListener?.('change', update);\n return () => query.removeEventListener?.('change', update);\n }, []);\n return reduced;\n};\n\n/** True while the element is on screen and the tab is visible — the only time a timer should run. */\nconst useOnScreen = (ref: { current: Element | null }, enabled: boolean) => {\n const [inView, setInView] = useState(true);\n const [tabVisible, setTabVisible] = useState(true);\n useEffect(() => {\n if (!enabled) return;\n const update = () => setTabVisible(document.visibilityState !== 'hidden');\n update();\n document.addEventListener('visibilitychange', update);\n let observer: IntersectionObserver | undefined;\n if (ref.current && typeof IntersectionObserver === 'function') {\n observer = new IntersectionObserver(([entry]) => setInView(entry.isIntersecting));\n observer.observe(ref.current);\n }\n return () => {\n document.removeEventListener('visibilitychange', update);\n observer?.disconnect();\n };\n }, [ref, enabled]);\n return inView && tabVisible;\n};\n\n/**\n * The request journey as a numbered rail over a row of step cards, one of which is current\n * (Figma \"How it works / Steps\"; its \"Step=1…7\" variants are the `value`). Every card is a button that makes its step\n * current; with `autoPlay` the steps also advance on a timer until the user takes over. Below `collapseBelow` the\n * cards stack and the rail is dropped (Figma \"Mobile / How it works / Steps\").\n */\nexport const HowItWorksSteps = /* @__PURE__ */ forwardRef<HTMLDivElement, HowItWorksStepsProps>(function HowItWorksSteps(\n {\n items,\n value,\n defaultValue,\n onValueChange,\n autoPlay = false,\n interval = 2200,\n paused = false,\n label,\n pauseLabel = 'Pause',\n playLabel = 'Play',\n collapseBelow,\n className,\n style,\n onPointerEnter,\n onPointerLeave,\n onFocus,\n onBlur,\n ...props\n },\n ref,\n) {\n const rootRef = useRef<HTMLDivElement | null>(null);\n const setRef = useCallback(\n (node: HTMLDivElement | null) => {\n rootRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [ref],\n );\n\n const [uncontrolled, setUncontrolled] = useState(defaultValue);\n const [stopped, setStopped] = useState(false);\n const [hovered, setHovered] = useState(false);\n const [focused, setFocused] = useState(false);\n const reducedMotion = useReducedMotion();\n const onScreen = useOnScreen(rootRef, autoPlay);\n\n const count = items.length;\n const requested = value !== undefined ? value : uncontrolled;\n const found = items.findIndex((item) => item.value === requested);\n // One step is always current: an unknown or missing value falls back to the first step.\n const activeIndex = found === -1 ? 0 : found;\n\n const select = (index: number) => {\n const next = items[index];\n if (!next || index === activeIndex) return;\n if (value === undefined) setUncontrolled(next.value);\n onValueChange?.(next.value);\n };\n const selectRef = useRef(select);\n selectRef.current = select;\n\n const canPlay = autoPlay && count > 1 && !reducedMotion;\n const playing = canPlay && !stopped && !paused && !hovered && !focused && onScreen;\n\n useEffect(() => {\n if (!playing) return;\n const timer = window.setTimeout(() => selectRef.current((activeIndex + 1) % count), Math.max(interval, 0) + STEP_DURATION);\n return () => window.clearTimeout(timer);\n }, [playing, activeIndex, count, interval]);\n\n if (count === 0) return null;\n\n // 136px per step keeps the Figma card (157px at 1200) readable; below that the row would crush the text.\n const threshold = Math.max(480, collapseBelow ?? count * 136 + (count - 1) * 16);\n const rootStyle = {\n '--_count': count,\n '--_progress': count > 1 ? activeIndex / (count - 1) : 0,\n '--_collapse': threshold,\n ...style,\n } as CSSProperties;\n\n return (\n <div\n ref={setRef}\n className={cn('tm-how-it-works-steps', className)}\n style={rootStyle}\n data-playing={playing ? '' : undefined}\n onPointerEnter={(event: PointerEvent<HTMLDivElement>) => {\n onPointerEnter?.(event);\n // A touch \"enters\" just before it taps; only a resting mouse or pen holds the timer.\n if (event.pointerType !== 'touch') setHovered(true);\n }}\n onPointerLeave={(event: PointerEvent<HTMLDivElement>) => {\n onPointerLeave?.(event);\n setHovered(false);\n }}\n onFocus={(event: FocusEvent<HTMLDivElement>) => {\n onFocus?.(event);\n setFocused(true);\n }}\n onBlur={(event: FocusEvent<HTMLDivElement>) => {\n onBlur?.(event);\n if (!event.currentTarget.contains(event.relatedTarget)) setFocused(false);\n }}\n {...props}\n >\n <div className=\"tm-how-it-works-steps__frame\">\n <div className=\"tm-how-it-works-steps__inner\">\n {canPlay ? (\n <div className=\"tm-how-it-works-steps__controls\">\n <button\n type=\"button\"\n className=\"tm-how-it-works-steps__toggle\"\n aria-label={stopped ? playLabel : pauseLabel}\n onClick={() => setStopped((current) => !current)}\n >\n <svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" fill=\"currentColor\" aria-hidden=\"true\" focusable=\"false\">\n {stopped ? <path d=\"M5 3.2v9.6a.6.6 0 0 0 .92.5l7.4-4.8a.6.6 0 0 0 0-1L5.92 2.7a.6.6 0 0 0-.92.5Z\" /> : <path d=\"M4 3h3v10H4zM9 3h3v10H9z\" />}\n </svg>\n </button>\n </div>\n ) : null}\n\n {/* The rail repeats what the list below already says (order, current step), so it is decorative. */}\n <div className=\"tm-how-it-works-steps__rail\" aria-hidden=\"true\" data-tm-icon-size=\"sm\">\n <span className=\"tm-how-it-works-steps__track\" />\n <span className=\"tm-how-it-works-steps__progress\" />\n {items.map((item, index) => (\n <span\n key={item.value}\n className=\"tm-how-it-works-steps__node\"\n data-state={index < activeIndex ? 'done' : index === activeIndex ? 'current' : 'upcoming'}\n >\n <span className=\"tm-how-it-works-steps__number\">{index + 1}</span>\n <CheckmarkIcon className=\"tm-how-it-works-steps__check\" />\n </span>\n ))}\n </div>\n\n <ol className=\"tm-how-it-works-steps__list\" aria-label={label}>\n {items.map((item, index) => {\n const isCurrent = index === activeIndex;\n return (\n <li key={item.value} className=\"tm-how-it-works-steps__item\">\n <button\n type=\"button\"\n className=\"tm-how-it-works-steps__card\"\n aria-current={isCurrent ? 'step' : undefined}\n data-current={isCurrent ? '' : undefined}\n onClick={() => {\n // The user has taken over: auto-play does not fight their choice.\n setStopped(true);\n select(index);\n }}\n >\n <span className=\"tm-how-it-works-steps__main\">\n {item.icon ? (\n <span className=\"tm-how-it-works-steps__icon\" data-tm-icon-size=\"md\">\n {item.icon}\n </span>\n ) : null}\n <span className=\"tm-how-it-works-steps__text\">\n <span className=\"tm-how-it-works-steps__title\">{item.title}</span>\n {item.description ? <span className=\"tm-how-it-works-steps__description\">{item.description}</span> : null}\n </span>\n </span>\n {item.badge ? <span className=\"tm-how-it-works-steps__badge\">{item.badge}</span> : null}\n </button>\n </li>\n );\n })}\n </ol>\n </div>\n </div>\n </div>\n );\n});\n"],"mappings":";;;;;;;AA4DA,IAAaA,IAAoC,kBAAoD,SACnG,EAAE,SAAM,cAAW,aAAU,GAAGC,KAChC,GACA;CACA,OACE,kBAAC,QAAD;EAAW;EAAK,WAAWC,EAAG,8BAA8BC,CAAS;EAAG,qBAAkB;EAAK,GAAIF;EAAnG,UAAA,CACGG,GACAC,CACG;;AAEV,CAAC,GAGKC,IAAgB,KAEhBC,UAAyB;CAC7B,IAAM,CAACC,GAASC,KAAcC,EAAS,EAAK;CAS5C,OARAC,QAAgB;EACd,IAAI,OAAO,SAAW,OAAe,OAAO,OAAO,cAAe,YAAY;EAC9E,IAAMC,I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;MAA8B,cAAYyB;MACrD,UAAA7B,EAAM,KAAK,GAAM,MAAU;OAC1B,IAAM8B,IAAYtB,MAAUH;OAC5B,OACE,kBAAC,MAAD;QAAqB,WAAU;QAC7B,UAAA,kBAAC,UAAD;SACE,MAAK;SACL,WAAU;SACV,gBAAcyB,IAAY,SAAS,KAAA;SACnC,gBAAcA,IAAY,KAAK,KAAA;SAC/B,eAAe;UAGb,AADAvC,EAAW,EAAI,GACfe,EAAOE,CAAK;SACd;SATF,UAAA,CAWE,kBAAC,QAAD;UAAM,WAAU;UAAhB,UAAA,CACGJ,EAAK,OACJ,kBAAC,QAAD;WAAM,WAAU;WAA8B,qBAAkB;WAC7D,UAAAA,EAAK;UACF,CAAA,IACJ,MACJ,kBAAC,QAAD;WAAM,WAAU;WAAhB,UAAA,CACE,kBAAC,QAAD;YAAM,WAAU;YAAgC,UAAAA,EAAK;WAAY,CAAA,GAChEA,EAAK,cAAc,kBAAC,QAAD;YAAM,WAAU;YAAsC,UAAAA,EAAK;WAAkB,CAAA,IAAI,IACjG;UACF,CAAA,CAAA;SACL,CAAA,GAAAA,EAAK,QAAQ,kBAAC,QAAD;UAAM,WAAU;UAAgC,UAAAA,EAAK;SAAY,CAAA,IAAI,IAC7E;;OACN,GAzBKA,EAAK,KAyBV;MAER,CAAC;KACC,CAAA;IACD;;EACF,CAAA;CACF,CAAA;AAET,CAAC"}
1
+ {"version":3,"file":"HowItWorksSteps.js","names":["HowItWorksStepTag","props","cn","className","icon","children","STEP_DURATION","useReducedMotion","reduced","setReduced","useState","useEffect","query","update","useOnScreen","inView","setInView","tabVisible","setTabVisible","enabled","observer","ref","entry","HowItWorksSteps","rootRef","useRef","setRef","useCallback","node","uncontrolled","setUncontrolled","defaultValue","hovered","setHovered","focused","setFocused","reducedMotion","onScreen","autoPlay","count","items","requested","value","found","item","activeIndex","select","next","index","onValueChange","selectRef","playing","paused","timer","interval","threshold","collapseBelow","rootStyle","style","onPointerEnter","event","onPointerLeave","keyboard","onBlur","CheckmarkIcon","label","isCurrent"],"sources":["../../../src/components/HowItWorksSteps/HowItWorksSteps.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useRef,\n useState,\n type CSSProperties,\n type FocusEvent,\n type HTMLAttributes,\n type PointerEvent,\n type ReactNode,\n} from 'react';\nimport { CheckmarkIcon } from '../../icons';\nimport { cn } from '../../utils/cn';\nimport './HowItWorksSteps.css';\n\nexport interface HowItWorksStepItem {\n /** Identifies the step in `value` / `onValueChange`. */\n value: string;\n /** One icon from `@travel-match/ui` for the icon tile, e.g. `<PaperIcon />`. */\n icon?: ReactNode;\n /** Step name, e.g. \"Submit a request\". Phrasing content only — it is rendered inside a button. */\n title: ReactNode;\n /** One or two sentences about the step. Phrasing content only. */\n description?: ReactNode;\n /** Pill at the bottom of the card, e.g. a `<RequestStatus>` or a `<Tag>`. Must not be interactive. */\n badge?: ReactNode;\n}\n\nexport interface HowItWorksStepsProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'defaultValue' | 'onChange'> {\n /** The steps, in order. Nothing is rendered for an empty list. */\n items: HowItWorksStepItem[];\n /** Controlled: `value` of the current step (Figma \"Step\"). */\n value?: string;\n /** Uncontrolled: `value` of the step that starts current. Defaults to the first one. */\n defaultValue?: string;\n /** Called with the `value` of the step that became current, by a click or by auto-play. */\n onValueChange?: (value: string) => void;\n /** Advances to the next step on a timer, in an endless loop; after the user picks a step it carries on from that step. */\n autoPlay?: boolean;\n /** Time a step rests once its 500ms transition has finished, in ms (Figma: 2200 — a new step every 2.7s). */\n interval?: number;\n /** Holds auto-play without unmounting it (e.g. while a dialog is open); it carries on once this is `false` again. */\n paused?: boolean;\n /** Accessible name of the list of steps, e.g. \"How it works\". */\n label?: string;\n /** Width of the component in px below which the steps stack (the Figma mobile layout). Default: 136px per step plus the gaps, at least 480. */\n collapseBelow?: number;\n}\n\nexport interface HowItWorksStepTagProps extends HTMLAttributes<HTMLSpanElement> {\n /** One icon from `@travel-match/ui`, e.g. `<CompareIcon />`. */\n icon?: ReactNode;\n}\n\n/** The tinted pill Figma draws at the bottom of the steps that have no request status (\"Up to 3 offers\"). Use it as a step's `badge`. */\nexport const HowItWorksStepTag = /* @__PURE__ */ forwardRef<HTMLSpanElement, HowItWorksStepTagProps>(function HowItWorksStepTag(\n { icon, className, children, ...props },\n ref,\n) {\n return (\n <span ref={ref} className={cn('tm-how-it-works-steps__tag', className)} data-tm-icon-size=\"sm\" {...props}>\n {icon}\n {children}\n </span>\n );\n});\n\n/** Figma prototype: Smart animate, ease in and out, 500ms. Keep in sync with `--_duration` in the stylesheet. */\nconst STEP_DURATION = 500;\n\nconst useReducedMotion = () => {\n const [reduced, setReduced] = useState(false);\n useEffect(() => {\n if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') return;\n const query = window.matchMedia('(prefers-reduced-motion: reduce)');\n const update = () => setReduced(query.matches);\n update();\n query.addEventListener?.('change', update);\n return () => query.removeEventListener?.('change', update);\n }, []);\n return reduced;\n};\n\n/** True while the element is on screen and the tab is visible — the only time a timer should run. */\nconst useOnScreen = (ref: { current: Element | null }, enabled: boolean) => {\n const [inView, setInView] = useState(true);\n const [tabVisible, setTabVisible] = useState(true);\n useEffect(() => {\n if (!enabled) return;\n const update = () => setTabVisible(document.visibilityState !== 'hidden');\n update();\n document.addEventListener('visibilitychange', update);\n let observer: IntersectionObserver | undefined;\n if (ref.current && typeof IntersectionObserver === 'function') {\n observer = new IntersectionObserver(([entry]) => setInView(entry.isIntersecting));\n observer.observe(ref.current);\n }\n return () => {\n document.removeEventListener('visibilitychange', update);\n observer?.disconnect();\n };\n }, [ref, enabled]);\n return inView && tabVisible;\n};\n\n/**\n * The request journey as a numbered rail over a row of step cards, one of which is current\n * (Figma \"How it works / Steps\"; its \"Step=1…7\" variants are the `value`). Every card is a button that makes its step\n * current; with `autoPlay` the steps also advance on a timer in an endless loop, which holds while the pointer or\n * keyboard focus is inside and carries on from the step the user picked. Below `collapseBelow` the cards stack and the\n * rail is dropped (Figma \"Mobile / How it works / Steps\").\n */\nexport const HowItWorksSteps = /* @__PURE__ */ forwardRef<HTMLDivElement, HowItWorksStepsProps>(function HowItWorksSteps(\n {\n items,\n value,\n defaultValue,\n onValueChange,\n autoPlay = false,\n interval = 2200,\n paused = false,\n label,\n collapseBelow,\n className,\n style,\n onPointerEnter,\n onPointerLeave,\n onFocus,\n onBlur,\n ...props\n },\n ref,\n) {\n const rootRef = useRef<HTMLDivElement | null>(null);\n const setRef = useCallback(\n (node: HTMLDivElement | null) => {\n rootRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [ref],\n );\n\n const [uncontrolled, setUncontrolled] = useState(defaultValue);\n const [hovered, setHovered] = useState(false);\n const [focused, setFocused] = useState(false);\n const reducedMotion = useReducedMotion();\n const onScreen = useOnScreen(rootRef, autoPlay);\n\n const count = items.length;\n const requested = value !== undefined ? value : uncontrolled;\n const found = items.findIndex((item) => item.value === requested);\n // One step is always current: an unknown or missing value falls back to the first step.\n const activeIndex = found === -1 ? 0 : found;\n\n const select = (index: number) => {\n const next = items[index];\n if (!next || index === activeIndex) return;\n if (value === undefined) setUncontrolled(next.value);\n onValueChange?.(next.value);\n };\n const selectRef = useRef(select);\n selectRef.current = select;\n\n const playing = autoPlay && count > 1 && !reducedMotion && !paused && !hovered && !focused && onScreen;\n\n useEffect(() => {\n if (!playing) return;\n const timer = window.setTimeout(() => selectRef.current((activeIndex + 1) % count), Math.max(interval, 0) + STEP_DURATION);\n return () => window.clearTimeout(timer);\n }, [playing, activeIndex, count, interval]);\n\n if (count === 0) return null;\n\n // 136px per step keeps the Figma card (157px at 1200) readable; below that the row would crush the text.\n const threshold = Math.max(480, collapseBelow ?? count * 136 + (count - 1) * 16);\n const rootStyle = {\n '--_count': count,\n '--_progress': count > 1 ? activeIndex / (count - 1) : 0,\n '--_collapse': threshold,\n ...style,\n } as CSSProperties;\n\n return (\n <div\n ref={setRef}\n className={cn('tm-how-it-works-steps', className)}\n style={rootStyle}\n data-playing={playing ? '' : undefined}\n onPointerEnter={(event: PointerEvent<HTMLDivElement>) => {\n onPointerEnter?.(event);\n // A touch \"enters\" just before it taps; only a resting mouse or pen holds the timer.\n if (event.pointerType !== 'touch') setHovered(true);\n }}\n onPointerLeave={(event: PointerEvent<HTMLDivElement>) => {\n onPointerLeave?.(event);\n setHovered(false);\n }}\n onFocus={(event: FocusEvent<HTMLDivElement>) => {\n onFocus?.(event);\n // Keyboard focus only: the focus a click or a tap leaves on a card must not hold auto-play until the next blur.\n let keyboard = true;\n try {\n keyboard = event.target.matches(':focus-visible');\n } catch {\n /* :focus-visible unsupported — treat every focus as keyboard focus */\n }\n if (keyboard) setFocused(true);\n }}\n onBlur={(event: FocusEvent<HTMLDivElement>) => {\n onBlur?.(event);\n if (!event.currentTarget.contains(event.relatedTarget)) setFocused(false);\n }}\n {...props}\n >\n <div className=\"tm-how-it-works-steps__frame\">\n <div className=\"tm-how-it-works-steps__inner\">\n {/* The rail repeats what the list below already says (order, current step), so it is decorative. */}\n <div className=\"tm-how-it-works-steps__rail\" aria-hidden=\"true\" data-tm-icon-size=\"sm\">\n <span className=\"tm-how-it-works-steps__track\" />\n <span className=\"tm-how-it-works-steps__progress\" />\n {items.map((item, index) => (\n <span\n key={item.value}\n className=\"tm-how-it-works-steps__node\"\n data-state={index < activeIndex ? 'done' : index === activeIndex ? 'current' : 'upcoming'}\n >\n <span className=\"tm-how-it-works-steps__number\">{index + 1}</span>\n <CheckmarkIcon className=\"tm-how-it-works-steps__check\" />\n </span>\n ))}\n </div>\n\n <ol className=\"tm-how-it-works-steps__list\" aria-label={label}>\n {items.map((item, index) => {\n const isCurrent = index === activeIndex;\n return (\n <li key={item.value} className=\"tm-how-it-works-steps__item\">\n <button\n type=\"button\"\n className=\"tm-how-it-works-steps__card\"\n aria-current={isCurrent ? 'step' : undefined}\n data-current={isCurrent ? '' : undefined}\n // Shows the chosen step; auto-play carries on from it once the pointer and keyboard focus have left.\n onClick={() => select(index)}\n >\n <span className=\"tm-how-it-works-steps__main\">\n {item.icon ? (\n <span className=\"tm-how-it-works-steps__icon\" data-tm-icon-size=\"md\">\n {item.icon}\n </span>\n ) : null}\n <span className=\"tm-how-it-works-steps__text\">\n <span className=\"tm-how-it-works-steps__title\">{item.title}</span>\n {item.description ? <span className=\"tm-how-it-works-steps__description\">{item.description}</span> : null}\n </span>\n </span>\n {item.badge ? <span className=\"tm-how-it-works-steps__badge\">{item.badge}</span> : null}\n </button>\n </li>\n );\n })}\n </ol>\n </div>\n </div>\n </div>\n );\n});\n"],"mappings":";;;;;;;AAwDA,IAAaA,IAAoC,kBAAoD,SACnG,EAAE,SAAM,cAAW,aAAU,GAAGC,KAChC,GACA;CACA,OACE,kBAAC,QAAD;EAAW;EAAK,WAAWC,EAAG,8BAA8BC,CAAS;EAAG,qBAAkB;EAAK,GAAIF;EAAnG,UAAA,CACGG,GACAC,CACG;;AAEV,CAAC,GAGKC,IAAgB,KAEhBC,UAAyB;CAC7B,IAAM,CAACC,GAASC,KAAcC,EAAS,EAAK;CAS5C,OARAC,QAAgB;EACd,IAAI,OAAO,SAAW,OAAe,OAAO,OAAO,cAAe,YAAY;EAC9E,IAAMC,IAAQ,OAAO,WAAW,kCAAkC,GAC5DC,UAAeJ,EAAWG,EAAM,OAAO;EAG7C,OAFAC,EAAO,GACPD,EAAM,mBAAmB,UAAUC,CAAM,SAC5BD,EAAM,sBAAsB,UAAUC,CAAM;CAC3D,GAAG,CAAC,CAAC,GACEL;AACT,GAGMM,KAAe,GAAkC,MAAqB;CAC1E,IAAM,CAACC,GAAQC,KAAaN,EAAS,EAAI,GACnC,CAACO,GAAYC,KAAiBR,EAAS,EAAI;CAgBjD,OAfAC,QAAgB;EACd,IAAI,CAACQ,GAAS;EACd,IAAMN,UAAeK,EAAc,SAAS,oBAAoB,QAAQ;EAExE,AADAL,EAAO,GACP,SAAS,iBAAiB,oBAAoBA,CAAM;EACpD,IAAIO;EAKJ,OAJIC,EAAI,WAAW,OAAO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require("../PartnerCarousel/AutoplayToggle.cjs"),n=require("../PartnerCarousel/autoplay.cjs");;/* empty css */let r=require("react"),i=require("react/jsx-runtime");var a=300,o=(0,r.forwardRef)(function({children:o,value:s,defaultValue:c=0,onValueChange:l,autoPlay:u=!1,interval:d=4e3,paused:f=!1,pauseLabel:p=`Pause the animation`,playLabel:m=`Play the animation`,className:h,...g},_){let v=r.Children.toArray(o),y=v.length,b=(0,r.useRef)(null),[x,S]=n.useIndexState(s,c,l,y),{running:C,userPaused:w,toggle:T,interactionProps:E}=n.useAutoplay({enabled:u&&y>1,paused:f,delay:d+a,onTick:()=>S((x+1)%y),rootRef:b,resetKey:x}),{onPointerEnter:D,onPointerLeave:O,onFocus:k,onBlur:A}=E,j=e=>{e!==x&&S(e)},M=e=>t=>{let n=!0;try{n=t.target.matches(`:focus-visible`)}catch{}n&&j(e)};return(0,i.jsxs)(`div`,{ref:e=>{b.current=e,typeof _==`function`?_(e):_&&(_.current=e)},className:e.cn(`tm-package-animation`,h),"data-autoplay":C?`running`:u?`paused`:void 0,...g,onPointerEnter:e=>{g.onPointerEnter?.(e),D(e)},onPointerLeave:e=>{g.onPointerLeave?.(e),O()},onFocus:e=>{g.onFocus?.(e),k()},onBlur:e=>{g.onBlur?.(e),A(e)},children:[(0,i.jsx)(`div`,{className:`tm-package-animation__stage`,children:v.map((e,t)=>(0,i.jsx)(`div`,{className:`tm-package-animation__card`,"data-position":t===x?`front`:`back`,onClick:()=>j(t),onFocus:M(t),children:e},t))}),u&&y>1?(0,i.jsx)(`div`,{className:`tm-package-animation__controls`,children:(0,i.jsx)(t.AutoplayToggle,{paused:w,pauseLabel:p,playLabel:m,onClick:T})}):null]})});exports.PackageAnimation=o;
1
+ "use client";const e=require("../../utils/cn.cjs"),t=require("../PartnerCarousel/autoplay.cjs");;/* empty css */let n=require("react"),r=require("react/jsx-runtime");var i=300,a=(0,n.forwardRef)(function({children:a,value:o,defaultValue:s=0,onValueChange:c,autoPlay:l=!1,interval:u=4e3,paused:d=!1,className:f,...p},m){let h=n.Children.toArray(a),g=h.length,_=(0,n.useRef)(null),[v,y]=t.useIndexState(o,s,c,g),{running:b,interactionProps:x}=t.useAutoplay({enabled:l&&g>1,paused:d,delay:u+i,onTick:()=>y((v+1)%g),rootRef:_,resetKey:v}),{onPointerEnter:S,onPointerLeave:C,onFocus:w,onBlur:T}=x,E=e=>{e!==v&&y(e)},D=e=>t=>{let n=!0;try{n=t.target.matches(`:focus-visible`)}catch{}n&&E(e)};return(0,r.jsx)(`div`,{ref:e=>{_.current=e,typeof m==`function`?m(e):m&&(m.current=e)},className:e.cn(`tm-package-animation`,f),"data-autoplay":b?`running`:l?`paused`:void 0,...p,onPointerEnter:e=>{p.onPointerEnter?.(e),S(e)},onPointerLeave:e=>{p.onPointerLeave?.(e),C()},onFocus:e=>{p.onFocus?.(e),w(e)},onBlur:e=>{p.onBlur?.(e),T(e)},children:(0,r.jsx)(`div`,{className:`tm-package-animation__stage`,children:h.map((e,t)=>(0,r.jsx)(`div`,{className:`tm-package-animation__card`,"data-position":t===v?`front`:`back`,onClick:()=>E(t),onFocus:D(t),children:e},t))})})});exports.PackageAnimation=a;
2
2
  //# sourceMappingURL=PackageAnimation.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"PackageAnimation.cjs","names":["Children","useRef","useIndexState","useAutoplay","cn","AutoplayToggle","require_cn","require_AutoplayToggle","require_autoplay","react","react_jsx_runtime","SWAP_DURATION","PackageAnimation","props","cards","children","count","rootRef","index","setIndex","value","defaultValue","onValueChange","autoPlay","interval","interactionProps","bringToFront","i","handleFocus","keyboard","event","node","ref","className","running","onPointerEnter","onPointerLeave","onFocus","onBlur","card","userPaused","toggle"],"sources":["../../../src/components/PackageAnimation/PackageAnimation.tsx"],"sourcesContent":["import { Children, forwardRef, useRef, type FocusEvent, type HTMLAttributes, type ReactNode } from 'react';\nimport { cn } from '../../utils/cn';\nimport { AutoplayToggle } from '../PartnerCarousel/AutoplayToggle';\nimport { useAutoplay, useIndexState } from '../PartnerCarousel/autoplay';\nimport './PackageAnimation.css';\n\n/** Figma prototype: Smart animate, ease out, 300ms. Keep in sync with `--_duration` in the stylesheet. */\nconst SWAP_DURATION = 300;\n\nexport interface PackageAnimationProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {\n /** The cards of the stack — two `PackageCard`s in Figma. The one at `value` lies in front, the others behind it. */\n children?: ReactNode;\n /** Index (0-based) of the card in front — Figma \"Property 1\": Default is the first swap state, Variant2 the other. Makes the component controlled. */\n value?: number;\n /** Card in front at first when uncontrolled. */\n defaultValue?: number;\n /** Called with the index of the card that comes to the front (click, keyboard focus or autoplay). */\n onValueChange?: (value: number) => void;\n /** Swaps the cards by itself (the Figma prototype swaps on click only). Stops for hover, focus, a hidden tab, an off-screen stack and reduced motion. */\n autoPlay?: boolean;\n /** Time a card stays in front before the next swap, in ms. */\n interval?: number;\n /** Holds the autoplay (the pause control stays available). */\n paused?: boolean;\n /** Name of the pause button shown with `autoPlay` — translate it. */\n pauseLabel?: string;\n /** Name of the play button shown with `autoPlay` — translate it. */\n playLabel?: string;\n}\n\n/**\n * Two overlapping, tilted package cards that swap places (Figma component set \"Package animation\").\n * Clicking the card behind — or moving keyboard focus into it — brings it to the front. Both cards stay in the page for\n * assistive technology. Below 661px of container width the cards are upright and stacked, like \"Mobile / Package animation\".\n */\nexport const PackageAnimation = /* @__PURE__ */ forwardRef<HTMLDivElement, PackageAnimationProps>(function PackageAnimation(\n {\n children,\n value,\n defaultValue = 0,\n onValueChange,\n autoPlay = false,\n interval = 4000,\n paused = false,\n pauseLabel = 'Pause the animation',\n playLabel = 'Play the animation',\n className,\n ...props\n },\n ref,\n) {\n const cards = Children.toArray(children);\n const count = cards.length;\n const rootRef = useRef<HTMLDivElement | null>(null);\n const [index, setIndex] = useIndexState(value, defaultValue, onValueChange, count);\n\n const { running, userPaused, toggle, interactionProps } = useAutoplay({\n enabled: autoPlay && count > 1,\n paused,\n delay: interval + SWAP_DURATION,\n onTick: () => setIndex((index + 1) % count),\n rootRef,\n resetKey: index,\n });\n const { onPointerEnter, onPointerLeave, onFocus, onBlur } = interactionProps;\n\n const bringToFront = (i: number) => {\n if (i !== index) setIndex(i);\n };\n // Keyboard focus must not land on a covered control (WCAG 2.4.11). A pointer press is left alone here: moving the card\n // under the pointer would lose the click; the click handler brings the card forward afterwards.\n const handleFocus = (i: number) => (event: FocusEvent<HTMLDivElement>) => {\n let keyboard = true;\n try {\n keyboard = event.target.matches(':focus-visible');\n } catch {\n /* :focus-visible unsupported — treat every focus as keyboard focus */\n }\n if (keyboard) bringToFront(i);\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-package-animation', className)}\n data-autoplay={running ? 'running' : autoPlay ? 'paused' : undefined}\n {...props}\n onPointerEnter={(event) => {\n props.onPointerEnter?.(event);\n onPointerEnter(event);\n }}\n onPointerLeave={(event) => {\n props.onPointerLeave?.(event);\n onPointerLeave();\n }}\n onFocus={(event) => {\n props.onFocus?.(event);\n onFocus();\n }}\n onBlur={(event) => {\n props.onBlur?.(event);\n onBlur(event);\n }}\n >\n <div className=\"tm-package-animation__stage\">\n {cards.map((card, i) => (\n <div key={i} className=\"tm-package-animation__card\" data-position={i === index ? 'front' : 'back'} onClick={() => bringToFront(i)} onFocus={handleFocus(i)}>\n {card}\n </div>\n ))}\n </div>\n {autoPlay && count > 1 ? (\n <div className=\"tm-package-animation__controls\">\n <AutoplayToggle paused={userPaused} pauseLabel={pauseLabel} playLabel={playLabel} onClick={toggle} />\n </div>\n ) : null}\n </div>\n );\n});\n"],"mappings":"A,+OAOA,IAAMW,EAAgB,IA4BTC,GAAmC,EAAAH,EAAA,WAAA,CAAkD,SAChG,CACE,WACA,QACA,eAAe,EACf,gBACA,WAAW,GACX,WAAW,IACX,SAAS,GACT,aAAa,sBACb,YAAY,qBACZ,YACA,GAAGI,GAEL,EACA,CACA,IAAM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I,EAAM,KAAK,EAAM,KAChB,EAAAJ,EAAA,IAAA,CAAC,MAAD,CAAa,UAAU,6BAA6B,gBAAeiB,IAAMT,EAAQ,QAAU,OAAQ,YAAeQ,EAAaC,CAAC,EAAG,QAASC,EAAYD,CAAC,EACtJ,SAAAY,CACE,EAFKZ,CAEL,CACN,CACE,CAAA,EACJJ,GAAYP,EAAQ,GACnB,EAAAN,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,iCACb,UAAA,EAAAA,EAAA,IAAA,CAACL,EAAAA,eAAD,CAAgB,OAAQmC,EAAwB,aAAuB,YAAW,QAASC,CAAS,CAAA,CACjG,CAAA,EACH,IACD,C,EAET,CAAC,E"}
1
+ {"version":3,"file":"PackageAnimation.cjs","names":["Children","useRef","useIndexState","useAutoplay","cn","require_cn","require_autoplay","react","react_jsx_runtime","SWAP_DURATION","PackageAnimation","props","cards","children","count","rootRef","index","setIndex","value","defaultValue","onValueChange","autoPlay","interval","interactionProps","bringToFront","i","handleFocus","keyboard","event","node","ref","className","running","onPointerEnter","onPointerLeave","onFocus","onBlur","card"],"sources":["../../../src/components/PackageAnimation/PackageAnimation.tsx"],"sourcesContent":["import { Children, forwardRef, useRef, type FocusEvent, type HTMLAttributes, type ReactNode } from 'react';\nimport { cn } from '../../utils/cn';\nimport { useAutoplay, useIndexState } from '../PartnerCarousel/autoplay';\nimport './PackageAnimation.css';\n\n/** Figma prototype: Smart animate, ease out, 300ms. Keep in sync with `--_duration` in the stylesheet. */\nconst SWAP_DURATION = 300;\n\nexport interface PackageAnimationProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {\n /** The cards of the stack — two `PackageCard`s in Figma. The one at `value` lies in front, the others behind it. */\n children?: ReactNode;\n /** Index (0-based) of the card in front — Figma \"Property 1\": Default is the first swap state, Variant2 the other. Makes the component controlled. */\n value?: number;\n /** Card in front at first when uncontrolled. */\n defaultValue?: number;\n /** Called with the index of the card that comes to the front (click, keyboard focus or autoplay). */\n onValueChange?: (value: number) => void;\n /** Swaps the cards by itself, in an endless loop (the Figma prototype swaps on click only). Holds for hover, keyboard focus, a hidden tab, an off-screen stack and reduced motion. */\n autoPlay?: boolean;\n /** Time a card stays in front before the next swap, in ms. */\n interval?: number;\n /** Holds the autoplay from outside; it carries on once this is `false` again. */\n paused?: boolean;\n}\n\n/**\n * Two overlapping, tilted package cards that swap places (Figma component set \"Package animation\").\n * Clicking the card behind — or moving keyboard focus into it — brings it to the front. Both cards stay in the page for\n * assistive technology. Below 661px of container width the cards are upright and stacked, like \"Mobile / Package animation\".\n */\nexport const PackageAnimation = /* @__PURE__ */ forwardRef<HTMLDivElement, PackageAnimationProps>(function PackageAnimation(\n {\n children,\n value,\n defaultValue = 0,\n onValueChange,\n autoPlay = false,\n interval = 4000,\n paused = false,\n className,\n ...props\n },\n ref,\n) {\n const cards = Children.toArray(children);\n const count = cards.length;\n const rootRef = useRef<HTMLDivElement | null>(null);\n const [index, setIndex] = useIndexState(value, defaultValue, onValueChange, count);\n\n const { running, interactionProps } = useAutoplay({\n enabled: autoPlay && count > 1,\n paused,\n delay: interval + SWAP_DURATION,\n onTick: () => setIndex((index + 1) % count),\n rootRef,\n resetKey: index,\n });\n const { onPointerEnter, onPointerLeave, onFocus, onBlur } = interactionProps;\n\n const bringToFront = (i: number) => {\n if (i !== index) setIndex(i);\n };\n // Keyboard focus must not land on a covered control (WCAG 2.4.11). A pointer press is left alone here: moving the card\n // under the pointer would lose the click; the click handler brings the card forward afterwards.\n const handleFocus = (i: number) => (event: FocusEvent<HTMLDivElement>) => {\n let keyboard = true;\n try {\n keyboard = event.target.matches(':focus-visible');\n } catch {\n /* :focus-visible unsupported — treat every focus as keyboard focus */\n }\n if (keyboard) bringToFront(i);\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-package-animation', className)}\n data-autoplay={running ? 'running' : autoPlay ? 'paused' : undefined}\n {...props}\n onPointerEnter={(event) => {\n props.onPointerEnter?.(event);\n onPointerEnter(event);\n }}\n onPointerLeave={(event) => {\n props.onPointerLeave?.(event);\n onPointerLeave();\n }}\n onFocus={(event) => {\n props.onFocus?.(event);\n onFocus(event);\n }}\n onBlur={(event) => {\n props.onBlur?.(event);\n onBlur(event);\n }}\n >\n <div className=\"tm-package-animation__stage\">\n {cards.map((card, i) => (\n <div key={i} className=\"tm-package-animation__card\" data-position={i === index ? 'front' : 'back'} onClick={() => bringToFront(i)} onFocus={handleFocus(i)}>\n {card}\n </div>\n ))}\n </div>\n </div>\n );\n});\n"],"mappings":"A,4LAMA,IAAMS,EAAgB,IAwBTC,GAAmC,EAAAH,EAAA,WAAA,CAAkD,SAChG,CACE,WACA,QACA,eAAe,EACf,gBACA,WAAW,GACX,WAAW,IACX,SAAS,GACT,YACA,GAAGI,GAEL,EACA,CACA,IAAMC,EAAQZ,EAAAA,SAAS,QAAQa,CAAQ,EACjCC,EAAQF,EAAM,OACdG,GAAA,EAAUd,EAAAA,OAAAA,CAA8B,IAAI,EAC5C,CAACe,EAAOC,GAAYf,EAAAA,cAAcgB,EAAOC,EAAcC,EAAeN,CAAK,EAE3E,CAAE,UAAS,oBAAqBX,EAAAA,YAAY,CAChD,QAASkB,GAAYP,EAAQ,EAC7B,SACA,MAAOQ,EAAWb,EAClB,WAAcQ,GAAUD,EAAQ,GAAKF,CAAK,EAC1C,UACA,SAAUE,CACZ,CAAC,EACK,CAAE,iBAAgB,iBAAgB,UAAS,UAAWO,EAEtDC,EAAgB,GAAc,CAC9BC,IAAMT,GAAOC,EAASQ,CAAC,CAC7B,EAGMC,EAAe,GAAe,GAAsC,CACxE,IAAIC,EAAW,GACf,GAAI,CACF,EAAWC,EAAM,OAAO,QAAQ,gBAAgB,CAClD,MAAQ,CAER,CACID,GAAUH,EAAaC,CAAC,CAC9B,EAEA,OACE,EAAAjB,EAAA,IAAA,CAAC,MAAD,CACE,IAAM,GAAS,CACb,EAAQ,QAAUqB,EACd,OAAOC,GAAQ,WAAYA,EAAID,CAAI,EAC9BC,IAAK,EAAI,QAAUD,EAC9B,EACA,UAAWzB,EAAAA,GAAG,uBAAwB2B,CAAS,EAC/C,gBAAeC,EAAU,UAAYX,EAAW,SAAW,IAAA,GAC3D,GAAIV,EACJ,eAAiB,GAAU,CACzBA,EAAM,iBAAiBiB,CAAK,EAC5BK,EAAeL,CAAK,CACtB,EACA,eAAiB,GAAU,CACzBjB,EAAM,iBAAiBiB,CAAK,EAC5BM,EAAe,CACjB,EACA,QAAU,GAAU,CAClBvB,EAAM,UAAUiB,CAAK,EACrBO,EAAQP,CAAK,CACf,EACA,OAAS,GAAU,CACjBjB,EAAM,SAASiB,CAAK,EACpBQ,EAAOR,CAAK,CACd,EAEA,UAAA,EAAApB,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,8BACZ,SAAAI,EAAM,KAAK,EAAM,KAChB,EAAAJ,EAAA,IAAA,CAAC,MAAD,CAAa,UAAU,6BAA6B,gBAAeiB,IAAMT,EAAQ,QAAU,OAAQ,YAAeQ,EAAaC,CAAC,EAAG,QAASC,EAAYD,CAAC,EACtJ,SAAAY,CACE,EAFKZ,CAEL,CACN,CACE,CAAA,CACF,CAAA,CAET,CAAC,E"}
@@ -1,67 +1,58 @@
1
1
  "use client";
2
2
  import { cn as e } from "../../utils/cn.js";
3
- import { AutoplayToggle as t } from "../PartnerCarousel/AutoplayToggle.js";
4
- import { useAutoplay as n, useIndexState as r } from "../PartnerCarousel/autoplay.js";
3
+ import { useAutoplay as t, useIndexState as n } from "../PartnerCarousel/autoplay.js";
5
4
  /* empty css */
6
- import { Children as i, forwardRef as a, useRef as o } from "react";
7
- import { jsx as s, jsxs as c } from "react/jsx-runtime";
5
+ import { Children as r, forwardRef as i, useRef as a } from "react";
6
+ import { jsx as o } from "react/jsx-runtime";
8
7
  // src/components/PackageAnimation/PackageAnimation.tsx
9
- var l = 300, u = /* @__PURE__ */ a(function({ children: a, value: u, defaultValue: d = 0, onValueChange: f, autoPlay: p = !1, interval: m = 4e3, paused: h = !1, pauseLabel: g = "Pause the animation", playLabel: _ = "Play the animation", className: v, ...y }, b) {
10
- let x = i.toArray(a), S = x.length, C = o(null), [w, T] = r(u, d, f, S), { running: E, userPaused: D, toggle: O, interactionProps: k } = n({
11
- enabled: p && S > 1,
12
- paused: h,
13
- delay: m + l,
14
- onTick: () => T((w + 1) % S),
15
- rootRef: C,
16
- resetKey: w
17
- }), { onPointerEnter: A, onPointerLeave: j, onFocus: M, onBlur: N } = k, P = (e) => {
18
- e !== w && T(e);
19
- }, F = (e) => (t) => {
8
+ var s = 300, c = /* @__PURE__ */ i(function({ children: i, value: c, defaultValue: l = 0, onValueChange: u, autoPlay: d = !1, interval: f = 4e3, paused: p = !1, className: m, ...h }, g) {
9
+ let _ = r.toArray(i), v = _.length, y = a(null), [b, x] = n(c, l, u, v), { running: S, interactionProps: C } = t({
10
+ enabled: d && v > 1,
11
+ paused: p,
12
+ delay: f + s,
13
+ onTick: () => x((b + 1) % v),
14
+ rootRef: y,
15
+ resetKey: b
16
+ }), { onPointerEnter: w, onPointerLeave: T, onFocus: E, onBlur: D } = C, O = (e) => {
17
+ e !== b && x(e);
18
+ }, k = (e) => (t) => {
20
19
  let n = !0;
21
20
  try {
22
21
  n = t.target.matches(":focus-visible");
23
22
  } catch {}
24
- n && P(e);
23
+ n && O(e);
25
24
  };
26
- return /* @__PURE__ */ c("div", {
25
+ return /* @__PURE__ */ o("div", {
27
26
  ref: (e) => {
28
- C.current = e, typeof b == "function" ? b(e) : b && (b.current = e);
27
+ y.current = e, typeof g == "function" ? g(e) : g && (g.current = e);
29
28
  },
30
- className: e("tm-package-animation", v),
31
- "data-autoplay": E ? "running" : p ? "paused" : void 0,
32
- ...y,
29
+ className: e("tm-package-animation", m),
30
+ "data-autoplay": S ? "running" : d ? "paused" : void 0,
31
+ ...h,
33
32
  onPointerEnter: (e) => {
34
- y.onPointerEnter?.(e), A(e);
33
+ h.onPointerEnter?.(e), w(e);
35
34
  },
36
35
  onPointerLeave: (e) => {
37
- y.onPointerLeave?.(e), j();
36
+ h.onPointerLeave?.(e), T();
38
37
  },
39
38
  onFocus: (e) => {
40
- y.onFocus?.(e), M();
39
+ h.onFocus?.(e), E(e);
41
40
  },
42
41
  onBlur: (e) => {
43
- y.onBlur?.(e), N(e);
42
+ h.onBlur?.(e), D(e);
44
43
  },
45
- children: [/* @__PURE__ */ s("div", {
44
+ children: /* @__PURE__ */ o("div", {
46
45
  className: "tm-package-animation__stage",
47
- children: x.map((e, t) => /* @__PURE__ */ s("div", {
46
+ children: _.map((e, t) => /* @__PURE__ */ o("div", {
48
47
  className: "tm-package-animation__card",
49
- "data-position": t === w ? "front" : "back",
50
- onClick: () => P(t),
51
- onFocus: F(t),
48
+ "data-position": t === b ? "front" : "back",
49
+ onClick: () => O(t),
50
+ onFocus: k(t),
52
51
  children: e
53
52
  }, t))
54
- }), p && S > 1 ? /* @__PURE__ */ s("div", {
55
- className: "tm-package-animation__controls",
56
- children: /* @__PURE__ */ s(t, {
57
- paused: D,
58
- pauseLabel: g,
59
- playLabel: _,
60
- onClick: O
61
- })
62
- }) : null]
53
+ })
63
54
  });
64
55
  });
65
- export { u as PackageAnimation };
56
+ export { c as PackageAnimation };
66
57
 
67
58
  //# sourceMappingURL=PackageAnimation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PackageAnimation.js","names":["SWAP_DURATION","PackageAnimation","props","cards","Children","children","count","rootRef","useRef","index","setIndex","useIndexState","value","defaultValue","onValueChange","useAutoplay","autoPlay","interval","interactionProps","bringToFront","i","handleFocus","keyboard","event","node","ref","cn","className","running","onPointerEnter","onPointerLeave","onFocus","onBlur","card","AutoplayToggle","userPaused","toggle"],"sources":["../../../src/components/PackageAnimation/PackageAnimation.tsx"],"sourcesContent":["import { Children, forwardRef, useRef, type FocusEvent, type HTMLAttributes, type ReactNode } from 'react';\nimport { cn } from '../../utils/cn';\nimport { AutoplayToggle } from '../PartnerCarousel/AutoplayToggle';\nimport { useAutoplay, useIndexState } from '../PartnerCarousel/autoplay';\nimport './PackageAnimation.css';\n\n/** Figma prototype: Smart animate, ease out, 300ms. Keep in sync with `--_duration` in the stylesheet. */\nconst SWAP_DURATION = 300;\n\nexport interface PackageAnimationProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {\n /** The cards of the stack — two `PackageCard`s in Figma. The one at `value` lies in front, the others behind it. */\n children?: ReactNode;\n /** Index (0-based) of the card in front — Figma \"Property 1\": Default is the first swap state, Variant2 the other. Makes the component controlled. */\n value?: number;\n /** Card in front at first when uncontrolled. */\n defaultValue?: number;\n /** Called with the index of the card that comes to the front (click, keyboard focus or autoplay). */\n onValueChange?: (value: number) => void;\n /** Swaps the cards by itself (the Figma prototype swaps on click only). Stops for hover, focus, a hidden tab, an off-screen stack and reduced motion. */\n autoPlay?: boolean;\n /** Time a card stays in front before the next swap, in ms. */\n interval?: number;\n /** Holds the autoplay (the pause control stays available). */\n paused?: boolean;\n /** Name of the pause button shown with `autoPlay` — translate it. */\n pauseLabel?: string;\n /** Name of the play button shown with `autoPlay` — translate it. */\n playLabel?: string;\n}\n\n/**\n * Two overlapping, tilted package cards that swap places (Figma component set \"Package animation\").\n * Clicking the card behind — or moving keyboard focus into it — brings it to the front. Both cards stay in the page for\n * assistive technology. Below 661px of container width the cards are upright and stacked, like \"Mobile / Package animation\".\n */\nexport const PackageAnimation = /* @__PURE__ */ forwardRef<HTMLDivElement, PackageAnimationProps>(function PackageAnimation(\n {\n children,\n value,\n defaultValue = 0,\n onValueChange,\n autoPlay = false,\n interval = 4000,\n paused = false,\n pauseLabel = 'Pause the animation',\n playLabel = 'Play the animation',\n className,\n ...props\n },\n ref,\n) {\n const cards = Children.toArray(children);\n const count = cards.length;\n const rootRef = useRef<HTMLDivElement | null>(null);\n const [index, setIndex] = useIndexState(value, defaultValue, onValueChange, count);\n\n const { running, userPaused, toggle, interactionProps } = useAutoplay({\n enabled: autoPlay && count > 1,\n paused,\n delay: interval + SWAP_DURATION,\n onTick: () => setIndex((index + 1) % count),\n rootRef,\n resetKey: index,\n });\n const { onPointerEnter, onPointerLeave, onFocus, onBlur } = interactionProps;\n\n const bringToFront = (i: number) => {\n if (i !== index) setIndex(i);\n };\n // Keyboard focus must not land on a covered control (WCAG 2.4.11). A pointer press is left alone here: moving the card\n // under the pointer would lose the click; the click handler brings the card forward afterwards.\n const handleFocus = (i: number) => (event: FocusEvent<HTMLDivElement>) => {\n let keyboard = true;\n try {\n keyboard = event.target.matches(':focus-visible');\n } catch {\n /* :focus-visible unsupported — treat every focus as keyboard focus */\n }\n if (keyboard) bringToFront(i);\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-package-animation', className)}\n data-autoplay={running ? 'running' : autoPlay ? 'paused' : undefined}\n {...props}\n onPointerEnter={(event) => {\n props.onPointerEnter?.(event);\n onPointerEnter(event);\n }}\n onPointerLeave={(event) => {\n props.onPointerLeave?.(event);\n onPointerLeave();\n }}\n onFocus={(event) => {\n props.onFocus?.(event);\n onFocus();\n }}\n onBlur={(event) => {\n props.onBlur?.(event);\n onBlur(event);\n }}\n >\n <div className=\"tm-package-animation__stage\">\n {cards.map((card, i) => (\n <div key={i} className=\"tm-package-animation__card\" data-position={i === index ? 'front' : 'back'} onClick={() => bringToFront(i)} onFocus={handleFocus(i)}>\n {card}\n </div>\n ))}\n </div>\n {autoPlay && count > 1 ? (\n <div className=\"tm-package-animation__controls\">\n <AutoplayToggle paused={userPaused} pauseLabel={pauseLabel} playLabel={playLabel} onClick={toggle} />\n </div>\n ) : null}\n </div>\n );\n});\n"],"mappings":";;;;;;;;AAOA,IAAMA,IAAgB,KA4BTC,IAAmC,kBAAkD,SAChG,EACE,aACA,UACA,kBAAe,GACf,kBACA,cAAW,IACX,cAAW,KACX,YAAS,IACT,gBAAa,uBACb,eAAY,sBACZ,cACA,GAAGC,KAEL,GACA;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AU;IAA6B,iBAAeiB,MAAMX,IAAQ,UAAU;IAAQ,eAAeU,EAAaC,CAAC;IAAG,SAASC,EAAYD,CAAC;IACtJ,UAAAa;GACE,GAFKb,CAEL,CACN;EACE,CAAA,GACJJ,KAAYV,IAAQ,IACnB,kBAAC,OAAD;GAAK,WAAU;GACb,UAAA,kBAAC4B,GAAD;IAAgB,QAAQC;IAAwB;IAAuB;IAAW,SAASC;GAAS,CAAA;EACjG,CAAA,IACH,IACD;;AAET,CAAC"}
1
+ {"version":3,"file":"PackageAnimation.js","names":["SWAP_DURATION","PackageAnimation","props","cards","Children","children","count","rootRef","useRef","index","setIndex","useIndexState","value","defaultValue","onValueChange","useAutoplay","autoPlay","interval","interactionProps","bringToFront","i","handleFocus","keyboard","event","node","ref","cn","className","running","onPointerEnter","onPointerLeave","onFocus","onBlur","card"],"sources":["../../../src/components/PackageAnimation/PackageAnimation.tsx"],"sourcesContent":["import { Children, forwardRef, useRef, type FocusEvent, type HTMLAttributes, type ReactNode } from 'react';\nimport { cn } from '../../utils/cn';\nimport { useAutoplay, useIndexState } from '../PartnerCarousel/autoplay';\nimport './PackageAnimation.css';\n\n/** Figma prototype: Smart animate, ease out, 300ms. Keep in sync with `--_duration` in the stylesheet. */\nconst SWAP_DURATION = 300;\n\nexport interface PackageAnimationProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {\n /** The cards of the stack — two `PackageCard`s in Figma. The one at `value` lies in front, the others behind it. */\n children?: ReactNode;\n /** Index (0-based) of the card in front — Figma \"Property 1\": Default is the first swap state, Variant2 the other. Makes the component controlled. */\n value?: number;\n /** Card in front at first when uncontrolled. */\n defaultValue?: number;\n /** Called with the index of the card that comes to the front (click, keyboard focus or autoplay). */\n onValueChange?: (value: number) => void;\n /** Swaps the cards by itself, in an endless loop (the Figma prototype swaps on click only). Holds for hover, keyboard focus, a hidden tab, an off-screen stack and reduced motion. */\n autoPlay?: boolean;\n /** Time a card stays in front before the next swap, in ms. */\n interval?: number;\n /** Holds the autoplay from outside; it carries on once this is `false` again. */\n paused?: boolean;\n}\n\n/**\n * Two overlapping, tilted package cards that swap places (Figma component set \"Package animation\").\n * Clicking the card behind — or moving keyboard focus into it — brings it to the front. Both cards stay in the page for\n * assistive technology. Below 661px of container width the cards are upright and stacked, like \"Mobile / Package animation\".\n */\nexport const PackageAnimation = /* @__PURE__ */ forwardRef<HTMLDivElement, PackageAnimationProps>(function PackageAnimation(\n {\n children,\n value,\n defaultValue = 0,\n onValueChange,\n autoPlay = false,\n interval = 4000,\n paused = false,\n className,\n ...props\n },\n ref,\n) {\n const cards = Children.toArray(children);\n const count = cards.length;\n const rootRef = useRef<HTMLDivElement | null>(null);\n const [index, setIndex] = useIndexState(value, defaultValue, onValueChange, count);\n\n const { running, interactionProps } = useAutoplay({\n enabled: autoPlay && count > 1,\n paused,\n delay: interval + SWAP_DURATION,\n onTick: () => setIndex((index + 1) % count),\n rootRef,\n resetKey: index,\n });\n const { onPointerEnter, onPointerLeave, onFocus, onBlur } = interactionProps;\n\n const bringToFront = (i: number) => {\n if (i !== index) setIndex(i);\n };\n // Keyboard focus must not land on a covered control (WCAG 2.4.11). A pointer press is left alone here: moving the card\n // under the pointer would lose the click; the click handler brings the card forward afterwards.\n const handleFocus = (i: number) => (event: FocusEvent<HTMLDivElement>) => {\n let keyboard = true;\n try {\n keyboard = event.target.matches(':focus-visible');\n } catch {\n /* :focus-visible unsupported — treat every focus as keyboard focus */\n }\n if (keyboard) bringToFront(i);\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-package-animation', className)}\n data-autoplay={running ? 'running' : autoPlay ? 'paused' : undefined}\n {...props}\n onPointerEnter={(event) => {\n props.onPointerEnter?.(event);\n onPointerEnter(event);\n }}\n onPointerLeave={(event) => {\n props.onPointerLeave?.(event);\n onPointerLeave();\n }}\n onFocus={(event) => {\n props.onFocus?.(event);\n onFocus(event);\n }}\n onBlur={(event) => {\n props.onBlur?.(event);\n onBlur(event);\n }}\n >\n <div className=\"tm-package-animation__stage\">\n {cards.map((card, i) => (\n <div key={i} className=\"tm-package-animation__card\" data-position={i === index ? 'front' : 'back'} onClick={() => bringToFront(i)} onFocus={handleFocus(i)}>\n {card}\n </div>\n ))}\n </div>\n </div>\n );\n});\n"],"mappings":";;;;;;;AAMA,IAAMA,IAAgB,KAwBTC,IAAmC,kBAAkD,SAChG,EACE,aACA,UACA,kBAAe,GACf,kBACA,cAAW,IACX,cAAW,KACX,YAAS,IACT,cACA,GAAGC,KAEL,GACA;CACA,IAAMC,IAAQC,EAAS,QAAQC,CAAQ,GACjCC,IAAQH,EAAM,QACdI,IAAUC,EAA8B,IAAI,GAC5C,CAACC,GAAOC,KAAYC,EAAcC,GAAOC,GAAcC,GAAeR,CAAK,GAE3E,EAAE,YAAS,wBAAqBS,EAAY;EAChD,SAASC,KAAYV,IAAQ;EAC7B;EACA,OAAOW,IAAWjB;EAClB,cAAcU,GAAUD,IAAQ,KAAKH,CAAK;EAC1C;EACA,UAAUG;CACZ,CAAC,GACK,EAAE,mBAAgB,mBAAgB,YAAS,cAAWS,GAEtDC,KAAgB,MAAc;EAClC,AAAIC,MAAMX,KAAOC,EAASU,CAAC;CAC7B,GAGMC,KAAe,OAAe,MAAsC;EACxE,IAAIC,IAAW;EACf,IAAI;GACF,IAAWC,EAAM,OAAO,QAAQ,gBAAgB;EAClD,QAAQ,CAER;EACA,AAAID,KAAUH,EAAaC,CAAC;CAC9B;CAEA,OACE,kBAAC,OAAD;EACE,MAAM,MAAS;GAEb,AADA,EAAQ,UAAUI,GACd,OAAOC,KAAQ,aAAYA,EAAID,CAAI,IAC9BC,MAAK,EAAI,UAAUD;EAC9B;EACA,WAAWE,EAAG,wBAAwBC,CAAS;EAC/C,iBAAeC,IAAU,YAAYZ,IAAW,WAAW,KAAA;EAC3D,GAAId;EACJ,iBAAiB,MAAU;GAEzB,AADAA,EAAM,iBAAiBqB,CAAK,GAC5BM,EAAeN,CAAK;EACtB;EACA,iBAAiB,MAAU;GAEzB,AADArB,EAAM,iBAAiBqB,CAAK,GAC5BO,EAAe;EACjB;EACA,UAAU,MAAU;GAElB,AADA5B,EAAM,UAAUqB,CAAK,GACrBQ,EAAQR,CAAK;EACf;EACA,SAAS,MAAU;GAEjB,AADArB,EAAM,SAASqB,CAAK,GACpBS,EAAOT,CAAK;EACd;EAEA,UAAA,kBAAC,OAAD;GAAK,WAAU;GACZ,UAAApB,EAAM,KAAK,GAAM,MAChB,kBAAC,OAAD;IAAa,WAAU;IAA6B,iBAAeiB,MAAMX,IAAQ,UAAU;IAAQ,eAAeU,EAAaC,CAAC;IAAG,SAASC,EAAYD,CAAC;IACtJ,UAAAa;GACE,GAFKb,CAEL,CACN;EACE,CAAA;CACF,CAAA;AAET,CAAC"}
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../utils/cn.cjs"),t=require("../Pagination/Pagination.cjs"),n=require("./AutoplayToggle.cjs"),r=require("./autoplay.cjs");;/* empty css */let i=require("react"),a=require("react/jsx-runtime");var o=700,s=e=>e<.5?2*e*e:1-(-2*e+2)**2/2,c=typeof window>`u`?i.useEffect:i.useLayoutEffect,l=(e,t)=>`${e+1} of ${t}`,u=(e,t)=>`Slide ${e} of ${t}`,d=e=>e?.setAttribute(`inert`,``),f=(0,i.forwardRef)(function({children:f,value:p,defaultValue:m=0,onValueChange:h,autoPlay:g=!0,interval:_=3e3,paused:v=!1,loop:y=!0,controls:b=!0,getSlideLabel:x=l,getPageLabel:S=u,paginationLabel:C=`Slides`,pauseLabel:w=`Pause the slide show`,playLabel:T=`Play the slide show`,className:E,...D},O){let k=i.Children.toArray(f),A=k.length,j=y&&A>2,M=(0,i.useRef)(null),N=(0,i.useRef)(null),[P,F]=r.useIndexState(p,m,h,A),[I,L]=(0,i.useState)(A),R=j?A:Math.max(1,Math.min(I,A)),z=(0,i.useRef)(P),B=(0,i.useRef)(0),V=(0,i.useRef)(!1),H=(0,i.useRef)(void 0),U=(0,i.useCallback)(()=>{let e=N.current?.querySelectorAll(`.tm-partner-carousel__slide`);return!e||e.length<2?0:e[1].offsetLeft-e[0].offsetLeft},[]),W=(0,i.useCallback)(()=>{V.current&&(cancelAnimationFrame(B.current),V.current=!1,N.current&&(N.current.style.scrollSnapType=``))},[]),G=(0,i.useCallback)(()=>{let e=N.current,t=U();if(!e||t<=0||V.current)return;let n=Math.round(e.scrollLeft/t);j&&n>=A&&(n-=A,e.scrollLeft=n*t);let r=Math.max(0,Math.min(n,R-1));r!==z.current&&(z.current=r,F(r))},[A,U,j,R,F]),K=(0,i.useCallback)((e,t)=>{let n=N.current,r=U();if(!n||r<=0)return;W();let i=n.scrollLeft,a=Math.min(e*r,n.scrollWidth-n.clientWidth),c=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;if(!t||c||Math.abs(a-i)<1){n.scrollLeft=a,G();return}V.current=!0,n.style.scrollSnapType=`none`;let l=performance.now(),u=e=>{let t=Math.min(1,(e-l)/o);n.scrollLeft=i+(a-i)*s(t),t<1?B.current=requestAnimationFrame(u):(V.current=!1,n.style.scrollSnapType=``,G())};B.current=requestAnimationFrame(u)},[U,G,W]),q=(0,i.useCallback)((e,t={})=>{let n=N.current,r=U(),i=e;if(t.forward&&j&&n&&r>0){let e=Math.round(n.scrollLeft/r);e>=A&&(e-=A,n.scrollLeft=e*r),i=e+1}z.current=e,t.silent||F(e),K(i,t.animate??!0)},[A,U,j,K,F]);c(()=>(z.current>0&&K(z.current,!1),()=>{cancelAnimationFrame(B.current),clearTimeout(H.current)}),[]),(0,i.useEffect)(()=>{P!==z.current&&q(P,{silent:!0})},[P,q]),(0,i.useEffect)(()=>{let e=N.current;if(!e)return;let t=()=>{let t=U();if(t<=0)return L(A);L(Math.ceil((e.scrollWidth-e.clientWidth)/t-.05)+1)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[A,U,j]);let{running:J,userPaused:Y,toggle:X,interactionProps:Z}=r.useAutoplay({enabled:g&&R>1,paused:v,delay:_+o,onTick:()=>q((z.current+1)%R,{forward:!0}),rootRef:M,resetKey:P}),Q=()=>{if(V.current)return;let e=N.current,t=U();if(!e||t<=0)return;let n=Math.round(e.scrollLeft/t),r=Math.max(0,Math.min(j?n%A:n,R-1));r!==z.current&&(z.current=r,F(r)),clearTimeout(H.current),H.current=setTimeout(G,140)},{onPointerEnter:$,onPointerLeave:ee,onFocus:te,onBlur:ne}=Z;return(0,a.jsxs)(`section`,{ref:e=>{M.current=e,typeof O==`function`?O(e):O&&(O.current=e)},className:e.cn(`tm-partner-carousel`,E),"aria-roledescription":`carousel`,"data-autoplay":J?`running`:g?`paused`:void 0,...D,onPointerEnter:e=>{D.onPointerEnter?.(e),$(e)},onPointerLeave:e=>{D.onPointerLeave?.(e),ee()},onFocus:e=>{D.onFocus?.(e),te()},onBlur:e=>{D.onBlur?.(e),ne(e)},children:[(0,a.jsx)(`div`,{ref:N,className:`tm-partner-carousel__viewport`,onScroll:Q,onPointerDown:W,onTouchStart:W,onWheel:W,onKeyDown:e=>{(e.key.startsWith(`Arrow`)||e.key===`Home`||e.key===`End`)&&W()},children:(0,a.jsxs)(`div`,{className:`tm-partner-carousel__track`,children:[k.map((e,t)=>(0,a.jsx)(`div`,{className:`tm-partner-carousel__slide`,role:`group`,"aria-roledescription":`slide`,"aria-label":x(t,A),children:e},t)),j?k.map((e,t)=>(0,a.jsx)(`div`,{ref:d,className:`tm-partner-carousel__slide`,"data-clone":``,"aria-hidden":`true`,children:e},`clone-${t}`)):null]})}),b&&R>1?(0,a.jsxs)(`div`,{className:`tm-partner-carousel__controls`,children:[(0,a.jsx)(t.Pagination,{page:P+1,pageCount:R,onPageChange:e=>q(e-1),getPageLabel:S,"aria-label":C}),g?(0,a.jsx)(n.AutoplayToggle,{className:`tm-partner-carousel__toggle`,paused:Y,pauseLabel:w,playLabel:T,onClick:X}):null]}):null]})});exports.PartnerCarousel=f;
1
+ "use client";const e=require("../../utils/cn.cjs"),t=require("../Pagination/Pagination.cjs"),n=require("./autoplay.cjs");;/* empty css */let r=require("react"),i=require("react/jsx-runtime");var a=700,o=e=>e<.5?2*e*e:1-(-2*e+2)**2/2,s=typeof window>`u`?r.useEffect:r.useLayoutEffect,c=(e,t)=>`${e+1} of ${t}`,l=(e,t)=>`Slide ${e} of ${t}`,u=e=>e?.setAttribute(`inert`,``),d=(0,r.forwardRef)(function({children:d,value:f,defaultValue:p=0,onValueChange:m,autoPlay:h=!0,interval:g=3e3,paused:_=!1,loop:v=!0,controls:y=!0,getSlideLabel:b=c,getPageLabel:x=l,paginationLabel:S=`Slides`,className:C,...w},T){let E=r.Children.toArray(d),D=E.length,O=v&&D>2,k=(0,r.useRef)(null),A=(0,r.useRef)(null),[j,M]=n.useIndexState(f,p,m,D),[N,P]=(0,r.useState)(D),F=O?D:Math.max(1,Math.min(N,D)),I=(0,r.useRef)(j),L=(0,r.useRef)(0),R=(0,r.useRef)(!1),z=(0,r.useRef)(void 0),B=(0,r.useCallback)(()=>{let e=A.current?.querySelectorAll(`.tm-partner-carousel__slide`);return!e||e.length<2?0:e[1].offsetLeft-e[0].offsetLeft},[]),V=(0,r.useCallback)(()=>{R.current&&(cancelAnimationFrame(L.current),R.current=!1,A.current&&(A.current.style.scrollSnapType=``))},[]),H=(0,r.useCallback)(()=>{let e=A.current,t=B();if(!e||t<=0||R.current)return;let n=Math.round(e.scrollLeft/t);O&&n>=D&&(n-=D,e.scrollLeft=n*t);let r=Math.max(0,Math.min(n,F-1));r!==I.current&&(I.current=r,M(r))},[D,B,O,F,M]),U=(0,r.useCallback)((e,t)=>{let n=A.current,r=B();if(!n||r<=0)return;V();let i=n.scrollLeft,s=Math.min(e*r,n.scrollWidth-n.clientWidth),c=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;if(!t||c||Math.abs(s-i)<1){n.scrollLeft=s,H();return}R.current=!0,n.style.scrollSnapType=`none`;let l=performance.now(),u=e=>{let t=Math.min(1,(e-l)/a);n.scrollLeft=i+(s-i)*o(t),t<1?L.current=requestAnimationFrame(u):(R.current=!1,n.style.scrollSnapType=``,H())};L.current=requestAnimationFrame(u)},[B,H,V]),W=(0,r.useCallback)((e,t={})=>{let n=A.current,r=B(),i=e;if(t.forward&&O&&n&&r>0){let e=Math.round(n.scrollLeft/r);e>=D&&(e-=D,n.scrollLeft=e*r),i=e+1}I.current=e,t.silent||M(e),U(i,t.animate??!0)},[D,B,O,U,M]);s(()=>(I.current>0&&U(I.current,!1),()=>{cancelAnimationFrame(L.current),clearTimeout(z.current)}),[]),(0,r.useEffect)(()=>{j!==I.current&&W(j,{silent:!0})},[j,W]),(0,r.useEffect)(()=>{let e=A.current;if(!e)return;let t=()=>{let t=B();if(t<=0)return P(D);P(Math.ceil((e.scrollWidth-e.clientWidth)/t-.05)+1)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[D,B,O]);let{running:G,interactionProps:K}=n.useAutoplay({enabled:h&&F>1,paused:_,delay:g+a,onTick:()=>W((I.current+1)%F,{forward:!0}),rootRef:k,resetKey:j}),q=()=>{if(R.current)return;let e=A.current,t=B();if(!e||t<=0)return;let n=Math.round(e.scrollLeft/t),r=Math.max(0,Math.min(O?n%D:n,F-1));r!==I.current&&(I.current=r,M(r)),clearTimeout(z.current),z.current=setTimeout(H,140)},{onPointerEnter:J,onPointerLeave:Y,onFocus:X,onBlur:Z}=K;return(0,i.jsxs)(`section`,{ref:e=>{k.current=e,typeof T==`function`?T(e):T&&(T.current=e)},className:e.cn(`tm-partner-carousel`,C),"aria-roledescription":`carousel`,"data-autoplay":G?`running`:h?`paused`:void 0,...w,onPointerEnter:e=>{w.onPointerEnter?.(e),J(e)},onPointerLeave:e=>{w.onPointerLeave?.(e),Y()},onFocus:e=>{w.onFocus?.(e),X(e)},onBlur:e=>{w.onBlur?.(e),Z(e)},children:[(0,i.jsx)(`div`,{ref:A,className:`tm-partner-carousel__viewport`,onScroll:q,onPointerDown:V,onTouchStart:V,onWheel:V,onKeyDown:e=>{(e.key.startsWith(`Arrow`)||e.key===`Home`||e.key===`End`)&&V()},children:(0,i.jsxs)(`div`,{className:`tm-partner-carousel__track`,children:[E.map((e,t)=>(0,i.jsx)(`div`,{className:`tm-partner-carousel__slide`,role:`group`,"aria-roledescription":`slide`,"aria-label":b(t,D),children:e},t)),O?E.map((e,t)=>(0,i.jsx)(`div`,{ref:u,className:`tm-partner-carousel__slide`,"data-clone":``,"aria-hidden":`true`,children:e},`clone-${t}`)):null]})}),y&&F>1?(0,i.jsx)(`div`,{className:`tm-partner-carousel__controls`,children:(0,i.jsx)(t.Pagination,{page:j+1,pageCount:F,onPageChange:e=>W(e-1),getPageLabel:x,"aria-label":S})}):null]})});exports.PartnerCarousel=d;
2
2
  //# sourceMappingURL=PartnerCarousel.cjs.map