{"version":3,"file":"SelectOption.mjs","sources":["../../../src/lib/elements/SelectOption/SelectOption.jsx"],"sourcesContent":["/*\nCopyright 2022 Iguazio Systems Ltd.\nLicensed under the Apache License, Version 2.0 (the \"License\") with\nan addition restriction as set forth herein. You may not use this\nfile except in compliance with the License. You may obtain a copy of\nthe License at http://www.apache.org/licenses/LICENSE-2.0.\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\nimplied. See the License for the specific language governing\npermissions and limitations under the License.\nIn addition, you may not use the software for any purposes that are\nillegal under applicable law, and the grant of the foregoing license\nunder the Apache 2.0 license is conditioned upon your compliance with\nsuch restriction.\n*/\nimport React from 'react'\nimport PropTypes from 'prop-types'\nimport classnames from 'classnames'\n\nimport FormCheckBox from '../../components/FormCheckBox/FormCheckBox'\nimport Tooltip from '../../components/Tooltip/Tooltip'\nimport TextTooltipTemplate from '../../components/TooltipTemplate/TextTooltipTemplate'\n\nimport { SELECT_OPTION } from '../../types'\n\nimport Checkmark from '../../images/checkmark.svg?react'\n\nimport './selectOption.scss'\n\nconst SelectOption = ({\n  item,\n  name,\n  onClick = () => {},\n  multiple = false,\n  selectedId,\n  withSelectedIcon = true\n}) => {\n  const selectClassName = classnames(\n    'select__item',\n    multiple && 'multiple',\n    item.hidden && 'hidden',\n    item.disabled && 'disabled'\n  )\n\n  if (multiple) {\n    return (\n      <div data-testid=\"select-checkbox\" className={selectClassName}>\n        <FormCheckBox\n          name={name}\n          value={item.id}\n          label={item.label}\n          disabled={item.disabled || false}\n        >\n          {item.status && <span className={`state-${item.status}-job status`} />}\n        </FormCheckBox>\n      </div>\n    )\n  }\n\n  return (\n    <li\n      data-testid=\"select-option\"\n      className={selectClassName}\n      onClick={() => {\n        !item.disabled && onClick(item.id)\n      }}\n      data-custom-id={item.id}\n    >\n      <div className=\"label-row\">\n        <div className=\"data-ellipsis select__item-label\">\n          <div className=\"select__item-main-label\">\n            {item.icon && (\n              <span data-testid=\"select-icon\" className=\"select__item-icon\">\n                {item.icon}\n              </span>\n            )}\n            {item.status && <span className={`state-${item.status}-job status`} />}\n            <Tooltip\n              renderChildAsHtml={item.labelHtml?.length > 0}\n              template={<TextTooltipTemplate text={item.label} />}\n            >\n              {item.labelHtml ? item.labelHtml : item.label}\n            </Tooltip>\n          </div>\n          {item.subLabel && (\n            <Tooltip\n              className=\"select__item-sub-label\"\n              template={<TextTooltipTemplate text={item.subLabel} />}\n            >\n              <span>{item.subLabel}</span>\n            </Tooltip>\n          )}\n        </div>\n        {withSelectedIcon && item.id === selectedId && <Checkmark className=\"checkmark\" />}\n      </div>\n    </li>\n  )\n}\n\nSelectOption.propTypes = {\n  name: PropTypes.string.isRequired,\n  item: SELECT_OPTION.isRequired,\n  onClick: PropTypes.func,\n  multiple: PropTypes.bool,\n  selectedId: PropTypes.string,\n  withSelectedIcon: PropTypes.bool\n}\n\nexport default SelectOption\n"],"names":["SelectOption","item","name","onClick","multiple","selectedId","withSelectedIcon","selectClassName","classnames","jsx","FormCheckBox","jsxs","Tooltip","_a","TextTooltipTemplate","Checkmark","PropTypes","SELECT_OPTION"],"mappings":";;;;;;;;;;AA8BA,MAAMA,IAAe,CAAC;AAAA,EACpB,MAAAC;AAAA,EACA,MAAAC;AAAA,EACA,SAAAC,IAAU,MAAM;AAAA,EAAC;AAAA,EACjB,UAAAC,IAAW;AAAA,EACX,YAAAC;AAAA,EACA,kBAAAC,IAAmB;AACrB,MAAM;;AACJ,QAAMC,IAAkBC;AAAA,IACtB;AAAA,IACAJ,KAAY;AAAA,IACZH,EAAK,UAAU;AAAA,IACfA,EAAK,YAAY;AAAA,EAAA;AAGnB,SAAIG,IAEA,gBAAAK,EAAC,OAAA,EAAI,eAAY,mBAAkB,WAAWF,GAC5C,UAAA,gBAAAE;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,MAAAR;AAAA,MACA,OAAOD,EAAK;AAAA,MACZ,OAAOA,EAAK;A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