{"version":3,"file":"ButtonWrapper.cjs","sources":["../../../src/components/Button/ButtonWrapper.tsx"],"sourcesContent":["import {\n  type FilteredAnchorProps,\n  type FilteredButtonProps,\n  type Props,\n  useButtonWrapper,\n} from './useButtonWrapper'\n\nimport type { FC, MouseEvent } from 'react'\n\nconst EVENT_CANCELLER = (e: MouseEvent<HTMLButtonElement>) => {\n  e.preventDefault()\n  e.stopPropagation()\n}\n\nexport const ButtonWrapper: FC<Props> = (props: Props) => {\n  const { classNames, children, filteredProps } = useButtonWrapper(props)\n\n  if (props.isAnchor) {\n    const { anchorRef, elementAs, ...rest } = filteredProps as FilteredAnchorProps\n    const Component = elementAs || 'a'\n\n    return (\n      <Component {...rest} className={classNames.wrapper} ref={anchorRef}>\n        {children}\n      </Component>\n    )\n  }\n\n  const { buttonRef, disabled, $loading, onClick, ...rest } = filteredProps as FilteredButtonProps\n  const disabledOnLoading = $loading || disabled\n\n  return (\n    // eslint-disable-next-line smarthr/best-practice-for-button-element\n    <button\n      {...rest}\n      ref={buttonRef}\n      aria-disabled={disabledOnLoading}\n      className={classNames.wrapper}\n      onClick={disabledOnLoading ? EVENT_CANCELLER : onClick}\n    >\n      {children}\n    </button>\n  )\n}\n"],"names":["useButtonWrapper","_jsx"],"mappings":";;;;;AASA,MAAM,eAAe,GAAG,CAAC,CAAgC,KAAI;IAC3D,CAAC,CAAC,cAAc,EAAE;IAClB,CAAC,CAAC,eAAe,EAAE;AACrB,CAAC;AAEM,MAAM,aAAa,GAAc,CAAC,KAAY,KAAI;AACvD,IAAA,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAGA,mDAAgB,CAAC,KAAK,CAAC;AAEvE,IAAA,IAAI,KAAK,CAAC,QAAQ,EAAE;QAClB,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,aAAoC;AAC9E,QAAA,MAAM,SAAS,GAAG,SAAS,IAAI,GAAG;AAElC,QAAA,QACEC,cAAA,CAAC,SAAS,OAAK,IAAI,EAAE,SAAS,EAAE,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,SAAS,YAC/D,QAAQ,EAAA,CACC;IAEhB;AAEA,IAAA,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,aAAoC;AAChG,IAAA,MAAM,iBAAiB,GAAG,QAAQ,IAAI,QAAQ;IAE9C;;AAEE,IAAAA,cAAA,CAAA,QAAA,EAAA,EAAA,GACM,IAAI,EACR,GAAG,EAAE,SAAS,EAAA,eAAA,EACC,iBAAiB,EAChC,SAAS,EAAE,UAAU,CAAC,OAAO,EAC7B,OAAO,EAAE,iBAAiB,GAAG,eAAe,GAAG,OAAO,EAAA,QAAA,EAErD,QAAQ,EAAA,CACF;AAEb;;;;"}