{"version":3,"file":"Timeline-BHV9Jz3W.cjs","sources":["../src/components/Timeline/Timeline.tsx"],"sourcesContent":["'use client';\nimport { Children, forwardRef, useEffect, useRef } from 'react';\nimport type { HTMLAttributes, KeyboardEvent, ReactNode } from 'react';\nimport { withSx } from '../../utils/withSx';\nimport type { SxProp } from '../Layout/sx';\nimport { Skeleton } from '../Skeleton';\nimport { useScrollFocusable } from '../Scroll/useScrollFocusable';\n\nexport type TimelineDotColor = 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'neutral';\n\n/** Which side the content sits on relative to the central rail. */\nexport type TimelinePosition = 'right' | 'left' | 'alternate';\n/** Rail direction. */\nexport type TimelineOrientation = 'vertical' | 'horizontal';\n/** Density preset — scales dots, connector thickness, and type. */\nexport type TimelineSize = 'sm' | 'md' | 'lg';\n\nexport interface TimelineProps extends HTMLAttributes<HTMLOListElement> {\n  /** Side the content sits on relative to the rail. Default `'right'`. (Vertical only.) */\n  position?: TimelinePosition;\n  /** Rail direction. Default `'vertical'`. */\n  orientation?: TimelineOrientation;\n  /** Density preset. Default `'md'`. */\n  size?: TimelineSize;\n  /**\n   * Make the entries keyboard-navigable: one Tab stop, then Up/Down (Left/Right\n   * when horizontal) and Home/End move between items.\n   */\n  navigable?: boolean;\n  /** Replace the items with skeleton entries and mark the timeline `aria-busy`. */\n  loading?: boolean;\n  /** Shown in place of the items when there are none (and not `loading`). */\n  empty?: ReactNode;\n  /**\n   * One-off CSS, same as `Box`'s `sx`: each value may be a scalar or a\n   * responsive breakpoint map (`{ base, sm, md, lg, xl }`). Scalar-only sx\n   * merges into inline style; responsive sx injects a scoped class.\n   */\n  sx?: SxProp;\n}\nexport const Timeline = forwardRef<HTMLOListElement, TimelineProps>(function Timeline(\n  {\n    position = 'right',\n    orientation = 'vertical',\n    size = 'md',\n    navigable = false,\n    loading = false,\n    empty,\n    className,\n    style,\n    sx,\n    children,\n    onKeyDown,\n    ...rest\n  },\n  ref,\n) {\n  const inner = useRef<HTMLOListElement | null>(null);\n  const horizontalScroll = orientation === 'horizontal';\n  const { ref: measureRef, overflowing } = useScrollFocusable<HTMLOListElement>(horizontalScroll && !navigable);\n  const setRefs = (node: HTMLOListElement | null) => {\n    inner.current = node;\n    measureRef(node);\n    if (typeof ref === 'function') ref(node);\n    else if (ref) ref.current = node;\n  };\n  const horizontal = orientation === 'horizontal';\n  // Roving tabindex, set on the DOM because items are plain `<li>`s with no shared context.\n  useEffect(() => {\n    if (!navigable || !inner.current) return;\n    const items = Array.from(inner.current.querySelectorAll<HTMLElement>(':scope > .cny-timeline-item'));\n    const current = items.find((el) => el.tabIndex === 0) ?? items[0];\n    items.forEach((el) => el.setAttribute('tabindex', el === current ? '0' : '-1'));\n  });\n  const handleKeyDown = (e: KeyboardEvent<HTMLOListElement>) => {\n    onKeyDown?.(e);\n    if (!navigable || e.defaultPrevented) return;\n    const items = Array.from(e.currentTarget.querySelectorAll<HTMLElement>(':scope > .cny-timeline-item'));\n    const idx = items.indexOf(e.target as HTMLElement);\n    if (idx < 0) return;\n    const prevKey = horizontal ? 'ArrowLeft' : 'ArrowUp';\n    const nextKey = horizontal ? 'ArrowRight' : 'ArrowDown';\n    let next = -1;\n    if (e.key === prevKey) next = idx - 1;\n    else if (e.key === nextKey) next = idx + 1;\n    else if (e.key === 'Home') next = 0;\n    else if (e.key === 'End') next = items.length - 1;\n    if (next < 0) return;\n    e.preventDefault();\n    const target = items[Math.min(items.length - 1, next)];\n    items.forEach((el) => el.setAttribute('tabindex', el === target ? '0' : '-1'));\n    target.focus();\n  };\n\n  const { className: classes, style: mergedStyle, styleTag } = withSx(\n    sx,\n    style,\n    'cny-timeline',\n    orientation === 'horizontal' ? 'cny-timeline-horizontal' : `cny-timeline-${position}`,\n    size !== 'md' && `cny-timeline-${size}`,\n    className,\n  );\n  return (\n    <ol\n      ref={setRefs}\n      className={classes}\n      style={mergedStyle}\n      aria-busy={loading || undefined}\n      tabIndex={overflowing ? 0 : undefined}\n      onKeyDown={handleKeyDown}\n      {...rest}\n    >\n      {styleTag}\n      {loading\n        ? [0, 1, 2].map((i) => (\n            <li key={i} className=\"cny-timeline-item cny-timeline-skeleton\">\n              <div className=\"cny-timeline-separator\">\n                <Skeleton shape=\"avatar\" width={12} height={12} />\n                {i < 2 && <span className=\"cny-timeline-connector\" aria-hidden=\"true\" />}\n              </div>\n              <div className=\"cny-timeline-content\">\n                <Skeleton width=\"40%\" />\n                <Skeleton width=\"70%\" />\n              </div>\n            </li>\n          ))\n        : empty != null && Children.count(children) === 0\n          ? <li className=\"cny-timeline-empty\">{empty}</li>\n          : children}\n    </ol>\n  );\n});\n\nexport interface TimelineItemProps extends HTMLAttributes<HTMLLIElement> {\n  /** One-off CSS, same as `Box`'s `sx` (scalar or responsive `{ base, sm, md, lg, xl }` map). */\n  sx?: SxProp;\n}\nexport const TimelineItem = forwardRef<HTMLLIElement, TimelineItemProps>(function TimelineItem(\n  { className, style, sx, children, ...rest },\n  ref,\n) {\n  const { className: classes, style: mergedStyle, styleTag } = withSx(sx, style, 'cny-timeline-item', className);\n  return (\n    <li ref={ref} className={classes} style={mergedStyle} {...rest}>\n      {styleTag}\n      {children}\n    </li>\n  );\n});\n\nexport interface TimelineSeparatorProps extends HTMLAttributes<HTMLDivElement> {\n  /** One-off CSS, same as `Box`'s `sx` (scalar or responsive `{ base, sm, md, lg, xl }` map). */\n  sx?: SxProp;\n}\nexport const TimelineSeparator = forwardRef<HTMLDivElement, TimelineSeparatorProps>(\n  function TimelineSeparator({ className, style, sx, children, ...rest }, ref) {\n    const { className: classes, style: mergedStyle, styleTag } = withSx(sx, style, 'cny-timeline-separator', className);\n    return (\n      <div ref={ref} className={classes} style={mergedStyle} {...rest}>\n        {styleTag}\n        {children}\n      </div>\n    );\n  },\n);\n\n/** Dot fill treatment. */\nexport type TimelineDotVariant = 'filled' | 'outlined' | 'soft';\n\nexport interface TimelineDotProps extends HTMLAttributes<HTMLSpanElement> {\n  /** Semantic color. Default `'neutral'`. */\n  color?: TimelineDotColor;\n  /** Fill treatment: filled (default), outlined ring, or soft tint. */\n  variant?: TimelineDotVariant;\n  /** Optional icon (or number) rendered inside the dot. */\n  icon?: ReactNode;\n  /** Pulsing ring to mark the current step. Respects reduced-motion. */\n  active?: boolean;\n  /** One-off CSS, same as `Box`'s `sx` (scalar or responsive `{ base, sm, md, lg, xl }` map). */\n  sx?: SxProp;\n}\nexport const TimelineDot = forwardRef<HTMLSpanElement, TimelineDotProps>(function TimelineDot(\n  { color = 'neutral', variant = 'filled', icon, active = false, className, style, sx, children, ...rest },\n  ref,\n) {\n  const glyph = icon ?? children;\n  const { className: classes, style: mergedStyle, styleTag } = withSx(\n    sx,\n    style,\n    'cny-timeline-dot',\n    `cny-timeline-dot-${color}`,\n    `cny-timeline-dot-${variant}`,\n    glyph != null && glyph !== false && 'cny-timeline-dot-icon',\n    active && 'cny-timeline-dot-active',\n    className,\n  );\n  return (\n    <span\n      ref={ref}\n      className={classes}\n      style={mergedStyle}\n      {...rest}\n    >\n      {styleTag}\n      {glyph}\n    </span>\n  );\n});\n\n/** Connector line style. */\nexport type TimelineConnectorLineStyle = 'solid' | 'dashed' | 'dotted';\n\nexport interface TimelineConnectorProps extends HTMLAttributes<HTMLSpanElement> {\n  /** Tint the segment to show a completed step. Omit for a neutral hairline. */\n  color?: TimelineDotColor;\n  /** Line style. Default `'solid'`. */\n  lineStyle?: TimelineConnectorLineStyle;\n  /** One-off CSS, same as `Box`'s `sx` (scalar or responsive `{ base, sm, md, lg, xl }` map). */\n  sx?: SxProp;\n}\nexport const TimelineConnector = forwardRef<HTMLSpanElement, TimelineConnectorProps>(\n  function TimelineConnector({ color, lineStyle = 'solid', className, style, sx, children, ...rest }, ref) {\n    const { className: classes, style: mergedStyle, styleTag } = withSx(\n      sx,\n      style,\n      'cny-timeline-connector',\n      color && `cny-timeline-connector-${color}`,\n      lineStyle !== 'solid' && `cny-timeline-connector-${lineStyle}`,\n      className,\n    );\n    return (\n      <span\n        ref={ref}\n        className={classes}\n        style={mergedStyle}\n        aria-hidden=\"true\"\n        {...rest}\n      >\n        {styleTag}\n        {children}\n      </span>\n    );\n  },\n);\n\n/** Content treatment: plain, bordered card, or elevated card. */\nexport type TimelineContentVariant = 'plain' | 'card' | 'elevated';\n\nexport interface TimelineContentProps extends HTMLAttributes<HTMLDivElement> {\n  /** `'card'` = bordered block, `'elevated'` = card with shadow. Default `'plain'`. */\n  variant?: TimelineContentVariant;\n  /** Adds a colored left-accent border to a card, matched to a status color. */\n  accentColor?: TimelineDotColor;\n  /** One-off CSS, same as `Box`'s `sx` (scalar or responsive `{ base, sm, md, lg, xl }` map). */\n  sx?: SxProp;\n}\nexport const TimelineContent = forwardRef<HTMLDivElement, TimelineContentProps>(\n  function TimelineContent({ variant = 'plain', accentColor, className, style, sx, children, ...rest }, ref) {\n    const isCard = variant === 'card' || variant === 'elevated';\n    const { className: classes, style: mergedStyle, styleTag } = withSx(\n      sx,\n      style,\n      'cny-timeline-content',\n      isCard && 'cny-timeline-content-card',\n      variant === 'elevated' && 'cny-timeline-content-elevated',\n      accentColor && 'cny-timeline-content-accent',\n      accentColor && `cny-timeline-content-accent-${accentColor}`,\n      className,\n    );\n    return (\n      <div ref={ref} className={classes} style={mergedStyle} {...rest}>\n        {styleTag}\n        {children}\n      </div>\n    );\n  },\n);\n\n/** Slot rendered on the opposite side of the rail from the content (e.g. a timestamp). */\nexport interface TimelineOppositeContentProps extends HTMLAttributes<HTMLDivElement> {\n  /** One-off CSS, same as `Box`'s `sx` (scalar or responsive `{ base, sm, md, lg, xl }` map). */\n  sx?: SxProp;\n}\nexport const TimelineOppositeContent = forwardRef<HTMLDivElement, TimelineOppositeContentProps>(\n  function TimelineOppositeContent({ className, style, sx, children, ...rest }, ref) {\n    const { className: classes, style: mergedStyle, styleTag } = withSx(\n      sx, style, 'cny-timeline-opposite-content', className,\n    );\n    return (\n      <div ref={ref} className={classes} style={mergedStyle} {...rest}>\n        {styleTag}\n        {children}\n      </div>\n    );\n  },\n);\n"],"names":["Timeline","forwardRef","position","orientation","size","navigable","loading","empty","className","style","sx","children","onKeyDown","rest","ref","inner","useRef","horizontalScroll","measureRef","overflowing","useScrollFocusable","setRefs","node","horizontal","useEffect","items","current","el","handleKeyDown","idx","prevKey","nextKey","next","target","classes","mergedStyle","styleTag","withSx","jsxs","i","jsx","Skeleton","Children","TimelineItem","TimelineSeparator","TimelineDot","color","variant","icon","active","glyph","TimelineConnector","lineStyle","TimelineContent","accentColor","isCard","TimelineOppositeContent"],"mappings":"yMAwCaA,EAAWC,EAAAA,WAA4C,SAClE,CACE,SAAAC,EAAW,QACX,YAAAC,EAAc,WACd,KAAAC,EAAO,KACP,UAAAC,EAAY,GACZ,QAAAC,EAAU,GACV,MAAAC,EACA,UAAAC,EACA,MAAAC,EACA,GAAAC,EACA,SAAAC,EACA,UAAAC,EACA,GAAGC,CACL,EACAC,EACA,CACA,MAAMC,EAAQC,EAAAA,OAAgC,IAAI,EAC5CC,EAAmBd,IAAgB,aACnC,CAAE,IAAKe,EAAY,YAAAC,CAAA,EAAgBC,qBAAqCH,GAAoB,CAACZ,CAAS,EACtGgB,EAAWC,GAAkC,CACjDP,EAAM,QAAUO,EAChBJ,EAAWI,CAAI,EACX,OAAOR,GAAQ,WAAYA,EAAIQ,CAAI,EAC9BR,MAAS,QAAUQ,EAC9B,EACMC,EAAapB,IAAgB,aAEnCqB,EAAAA,UAAU,IAAM,CACd,GAAI,CAACnB,GAAa,CAACU,EAAM,QAAS,OAClC,MAAMU,EAAQ,MAAM,KAAKV,EAAM,QAAQ,iBAA8B,6BAA6B,CAAC,EAC7FW,EAAUD,EAAM,KAAME,GAAOA,EAAG,WAAa,CAAC,GAAKF,EAAM,CAAC,EAChEA,EAAM,QAASE,GAAOA,EAAG,aAAa,WAAYA,IAAOD,EAAU,IAAM,IAAI,CAAC,CAChF,CAAC,EACD,MAAME,EAAiB,GAAuC,CAE5D,GADAhB,GAAA,MAAAA,EAAY,GACR,CAACP,GAAa,EAAE,iBAAkB,OACtC,MAAMoB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