{"version":3,"sources":["../src/icon-button.tsx"],"sourcesContent":["import { forwardRef } from \"@chakra-ui/system\"\nimport { cloneElement, isValidElement } from \"react\"\nimport { Button, ButtonProps } from \"./button\"\n\ntype OmittedProps =\n  | \"leftIcon\"\n  | \"rightIcon\"\n  | \"loadingText\"\n  | \"iconSpacing\"\n  | \"spinnerPlacement\"\n\ninterface BaseButtonProps extends Omit<ButtonProps, OmittedProps> {}\n\nexport interface IconButtonProps extends BaseButtonProps {\n  /**\n   * The icon to be used in the button.\n   * @type React.ReactElement\n   */\n  icon?: React.ReactElement\n  /**\n   * If `true`, the button will be perfectly round. Else, it'll be slightly round\n   *\n   * @default false\n   */\n  isRound?: boolean\n  /**\n   * A11y: A label that describes the button\n   */\n  \"aria-label\": string\n}\n\n/**\n * Icon button renders an icon within a button.\n *\n * @see Docs https://chakra-ui.com/docs/components/icon-button\n */\nexport const IconButton = forwardRef<IconButtonProps, \"button\">(\n  (props, ref) => {\n    const { icon, children, isRound, \"aria-label\": ariaLabel, ...rest } = props\n\n    /**\n     * Passing the icon as prop or children should work\n     */\n    const element = icon || children\n    const _children = isValidElement(element)\n      ? cloneElement(element as any, {\n          \"aria-hidden\": true,\n          focusable: false,\n        })\n      : null\n\n    return (\n      <Button\n        padding=\"0\"\n        borderRadius={isRound ? \"full\" : undefined}\n        ref={ref}\n        aria-label={ariaLabel}\n        {...rest}\n      >\n        {_children}\n      </Button>\n    )\n  },\n)\n\nIconButton.displayName = \"IconButton\"\n"],"mappings":";;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,cAAc,sBAAsB;AAmDvC;AAhBC,IAAM,aAAa;AAAA,EACxB,CAAC,OAAO,QAAQ;AACd,UAAM,EAAE,MAAM,UAAU,SAAS,cAAc,WAAW,GAAG,KAAK,IAAI;AAKtE,UAAM,UAAU,QAAQ;AACxB,UAAM,YAAY,eAAe,OAAO,IACpC,aAAa,SAAgB;AAAA,MAC3B,eAAe;AAAA,MACf,WAAW;AAAA,IACb,CAAC,IACD;AAEJ,WACE;AAAA,MAAC;AAAA;AAAA,QACC,SAAQ;AAAA,QACR,cAAc,UAAU,SAAS;AAAA,QACjC;AAAA,QACA,cAAY;AAAA,QACX,GAAG;AAAA,QAEH;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,WAAW,cAAc;","names":[]}