{"version":3,"file":"LegendItem.mjs","names":[],"sources":["../../src/Legend/LegendItem.tsx"],"sourcesContent":["import { Flexbox, Icon } from '@lobehub/ui';\nimport { Text } from '@lobehub/ui/base-ui';\nimport { createStaticStyles, cssVar, cx } from 'antd-style';\nimport { Circle } from 'lucide-react';\nimport { memo } from 'react';\n\nconst styles = createStaticStyles(({ css }) => ({\n  container: css`\n    display: inline-flex;\n    align-items: center;\n\n    border-radius: ${cssVar.borderRadius};\n\n    color: ${cssVar.colorTextDescription};\n    white-space: nowrap;\n  `,\n  hasOnValueChange: css`\n    transition: all 0.25s ${cssVar.motionEaseInOut};\n\n    &:hover {\n      color: ${cssVar.colorTextSecondary};\n      background: ${cssVar.colorFillTertiary};\n    }\n  `,\n  itemContent: css`\n    font-size: 12px;\n    color: inherit;\n  `,\n}));\n\nexport interface LegendItemProps {\n  activeLegend?: string;\n  color: string;\n  label: string;\n  name: string;\n  onClick?: (name: string, color: string) => void;\n}\n\nconst LegendItem = memo<LegendItemProps>(({ label, name, color, onClick, activeLegend }) => {\n  const hasOnValueChange = !!onClick;\n\n  return (\n    <Flexbox\n      className={cx(styles.container, hasOnValueChange && styles.hasOnValueChange)}\n      gap={6}\n      horizontal\n      onClick={(e) => {\n        e.stopPropagation();\n        onClick?.(name, color);\n      }}\n      paddingBlock={2}\n      paddingInline={8}\n      style={{\n        cursor: hasOnValueChange ? 'pointer' : 'default',\n      }}\n    >\n      <Icon\n        color={color}\n        fill={color}\n        icon={Circle}\n        size={10}\n        style={{\n          opacity: activeLegend && activeLegend !== name ? 0.4 : 1,\n        }}\n      />\n      <Text\n        className={styles.itemContent}\n        ellipsis\n        style={{\n          color: activeLegend && activeLegend === name ? cssVar.colorTextSecondary : undefined,\n          margin: 0,\n          opacity: activeLegend && activeLegend !== name ? 0.4 : 1,\n        }}\n      >\n        {label}\n      </Text>\n    </Flexbox>\n  );\n});\n\nexport default LegendItem;\n"],"mappings":";;;;;;;AAMA,MAAM,SAAS,oBAAoB,EAAE,WAAW;CAC9C,WAAW,GAAG;;;;qBAIK,OAAO,aAAa;;aAE5B,OAAO,qBAAqB;;;CAGvC,kBAAkB,GAAG;4BACK,OAAO,gBAAgB;;;eAGpC,OAAO,mBAAmB;oBACrB,OAAO,kBAAkB;;;CAG3C,aAAa,GAAG;;;;AAIlB,EAAE;AAUF,MAAM,aAAa,MAAuB,EAAE,OAAO,MAAM,OAAO,SAAS,mBAAmB;CAC1F,MAAM,mBAAmB,CAAC,CAAC;CAE3B,OACE,qBAAC,SAAD;EACE,WAAW,GAAG,OAAO,WAAW,oBAAoB,OAAO,gBAAgB;EAC3E,KAAK;EACL,YAAA;EACA,UAAU,MAAM;GACd,EAAE,gBAAgB;GAClB,UAAU,MAAM,KAAK;EACvB;EACA,cAAc;EACd,eAAe;EACf,OAAO,EACL,QAAQ,mBAAmB,YAAY,UACzC;EAZF,UAAA,CAcE,oBAAC,MAAD;GACS;GACP,MAAM;GACN,MAAM;GACN,MAAM;GACN,OAAO,EACL,SAAS,gBAAgB,iBAAiB,OAAO,KAAM,EACzD;EACD,CAAA,GACD,oBAAC,MAAD;GACE,WAAW,OAAO;GAClB,UAAA;GACA,OAAO;IACL,OAAO,gBAAgB,iBAAiB,OAAO,OAAO,qBAAqB,KAAA;IAC3E,QAAQ;IACR,SAAS,gBAAgB,iBAAiB,OAAO,KAAM;GACzD;GAEC,UAAA;EACG,CAAA,CACC;;AAEb,CAAC"}