{"version":3,"file":"Steps.mjs","names":[],"sources":["../../../src/base-ui/Steps/Steps.tsx"],"sourcesContent":["'use client';\n\nimport { cx } from 'antd-style';\nimport { Check } from 'lucide-react';\nimport { memo, type ReactNode } from 'react';\n\nimport Icon from '@/Icon';\n\nimport { styles } from './style';\nimport type { StepItem, StepsProps, StepStatus } from './type';\n\nconst getStatus = (\n  index: number,\n  current: number | undefined,\n  item: StepItem,\n): StepStatus | undefined => {\n  if (item.status) return item.status;\n  if (current === undefined) return undefined;\n  if (index < current) return 'finish';\n  if (index === current) return 'process';\n  return 'wait';\n};\n\nconst renderIndicator = (\n  item: StepItem,\n  index: number,\n  status: StepStatus | undefined,\n  isDot: boolean,\n): ReactNode => {\n  if (isDot) return null;\n  if (item.icon != null) return item.icon;\n  if (status === 'finish') return <Icon icon={Check} size={12} />;\n  return index + 1;\n};\n\nconst Steps = memo<StepsProps>(\n  ({\n    className,\n    classNames,\n    current,\n    items,\n    orientation = 'horizontal',\n    ref,\n    styles: customStyles,\n    variant = 'default',\n    ...rest\n  }) => {\n    const isDot = variant === 'dot';\n\n    return (\n      <ol\n        ref={ref}\n        className={cx(\n          styles.root,\n          orientation === 'vertical' ? styles.vertical : styles.horizontal,\n          isDot && styles.dot,\n          className,\n        )}\n        {...rest}\n      >\n        {items.map((item, index) => {\n          const status = getStatus(index, current, item);\n          const isLast = index === items.length - 1;\n\n          return (\n            <li\n              aria-current={current !== undefined && index === current ? 'step' : undefined}\n              className={cx(classNames?.item)}\n              data-status={status ?? 'guide'}\n              key={item.key ?? index}\n              style={customStyles?.item}\n            >\n              <span\n                className={cx(styles.indicator, classNames?.indicator)}\n                style={customStyles?.indicator}\n              >\n                {renderIndicator(item, index, status, isDot)}\n              </span>\n              {(item.title != null || item.description != null) && (\n                <div className={styles.body}>\n                  {item.title != null && (\n                    <div\n                      className={cx(styles.title, classNames?.title)}\n                      style={customStyles?.title}\n                    >\n                      {item.title}\n                    </div>\n                  )}\n                  {item.description != null && (\n                    <div\n                      className={cx(styles.description, classNames?.description)}\n                      style={customStyles?.description}\n                    >\n                      {item.description}\n                    </div>\n                  )}\n                </div>\n              )}\n              {!isLast && (\n                <span\n                  aria-hidden=\"true\"\n                  className={styles.connector}\n                  style={isDot ? { insetBlockStart: 20, insetInlineStart: 3 } : undefined}\n                />\n              )}\n            </li>\n          );\n        })}\n      </ol>\n    );\n  },\n);\n\nSteps.displayName = 'Steps';\n\nexport default Steps;\n"],"mappings":";;;;;;;;AAWA,MAAM,aACJ,OACA,SACA,SAC2B;CAC3B,IAAI,KAAK,QAAQ,OAAO,KAAK;CAC7B,IAAI,YAAY,KAAA,GAAW,OAAO,KAAA;CAClC,IAAI,QAAQ,SAAS,OAAO;CAC5B,IAAI,UAAU,SAAS,OAAO;CAC9B,OAAO;AACT;AAEA,MAAM,mBACJ,MACA,OACA,QACA,UACc;CACd,IAAI,OAAO,OAAO;CAClB,IAAI,KAAK,QAAQ,MAAM,OAAO,KAAK;CACnC,IAAI,WAAW,UAAU,OAAO,oBAAC,MAAD;EAAM,MAAM;EAAO,MAAM;CAAK,CAAA;CAC9D,OAAO,QAAQ;AACjB;AAEA,MAAM,QAAQ,MACX,EACC,WACA,YACA,SACA,OACA,cAAc,cACd,KACA,QAAQ,cACR,UAAU,WACV,GAAG,WACC;CACJ,MAAM,QAAQ,YAAY;CAE1B,OACE,oBAAC,MAAD;EACO;EACL,WAAW,GACT,OAAO,MACP,gBAAgB,aAAa,OAAO,WAAW,OAAO,YACtD,SAAS,OAAO,KAChB,SACF;EACA,GAAI;EAEH,UAAA,MAAM,KAAK,MAAM,UAAU;GAC1B,MAAM,SAAS,UAAU,OAAO,SAAS,IAAI;GAC7C,MAAM,SAAS,UAAU,MAAM,SAAS;GAExC,OACE,qBAAC,MAAD;IACE,gBAAc,YAAY,KAAA,KAAa,UAAU,UAAU,SAAS,KAAA;IACpE,WAAW,GAAG,YAAY,IAAI;IAC9B,eAAa,UAAU;IAEvB,OAAO,cAAc;IALvB,UAAA;KAOE,o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