{"version":3,"file":"filter-chip-operation.cjs","sources":["../../../components/filter-chip/filter-chip-operation.tsx"],"sourcesContent":["'use client';\n\nimport { cx } from 'class-variance-authority';\nimport { useCallback } from 'react';\nimport { FilterOperation, FilterOperator } from '~/types/filters';\nimport { Select } from '../select';\nimport { Text } from '../text';\nimport styles from './filter-chip.module.css';\n\ninterface OperationProps {\n  label: string;\n  value?: FilterOperation;\n  onChange: (operation: FilterOperation) => void;\n  operations: FilterOperator<string>[];\n  showAlternateLabel?: boolean;\n}\n\nexport const Operation = ({\n  label,\n  value,\n  onChange,\n  operations,\n  showAlternateLabel = false\n}: OperationProps) => {\n  const operationValue = value?.value ?? '';\n\n  const handleValueChange = useCallback(\n    (newValue: string) => {\n      const operation = operations.find(o => o.value === newValue);\n      if (operation) onChange(operation);\n    },\n    [operations, onChange]\n  );\n\n  if (operations.length === 1)\n    return (\n      <Text\n        variant='secondary'\n        className={cx(styles.selectValue, styles.operationValue)}\n        data-slot='filter-chip-operation'\n      >\n        {operations[0].label}\n      </Text>\n    );\n\n  return (\n    <Select\n      value={operationValue}\n      onValueChange={handleValueChange}\n      aria-labelledby={`${label}-label`}\n    >\n      <Select.Trigger\n        variant='text'\n        className={cx(styles.selectValue, styles.operationValue)}\n        aria-label={`${label} filter operation`}\n        iconProps={{\n          style: {\n            display: 'none'\n          }\n        }}\n        data-slot='filter-chip-operation'\n      >\n        <Select.Value\n          placeholder='Select operation'\n          className={styles.operationText}\n          data-slot='filter-chip-operation-text'\n        />\n      </Select.Trigger>\n      <Select.Content data-variant='filter'>\n        {operations.map(operation => {\n          return (\n            <Select.Item\n              key={operation.value}\n              value={operation.value}\n              aria-label={`Filter ${label} ${operation.label}`}\n            >\n              {showAlternateLabel && operation?.alternateLabel\n                ? operation.alternateLabel\n                : operation.label}\n            </Select.Item>\n          );\n        })}\n      </Select.Content>\n    </Select>\n  );\n};\n"],"names":[],"mappings":";;;;;;;;;;AAiBa;AAOX;AAEA;AAEI;AACA;;AACF;AAIF;AACE;AAUF;AAWQ;AACE;AACD;AACF;;;;AAsBD;AAIR;;"}