{"version":3,"file":"Button.cjs","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ElementType } from \"react\";\nimport { forwardRef } from \"react\";\nimport type { PolymorphicComponentPropWithRef, PolymorphicRef } from \"../../helpers/generic-as-prop\";\nimport { get } from \"../../helpers/get\";\nimport { resolveProps } from \"../../helpers/resolve-props\";\nimport { useResolveTheme } from \"../../helpers/resolve-theme\";\nimport { twMerge } from \"../../helpers/tailwind-merge\";\nimport { useThemeProvider } from \"../../theme/provider\";\nimport type {\n  DynamicStringEnumKeysOf,\n  FlowbiteColors,\n  FlowbiteSizes,\n  FlowbiteStateColors,\n  ThemingProps,\n} from \"../../types\";\nimport { ButtonBase } from \"./ButtonBase\";\nimport { useButtonGroupContext } from \"./ButtonGroupContext\";\nimport { buttonTheme } from \"./theme\";\n\nexport interface ButtonTheme {\n  base: string;\n  disabled: string;\n  fullSized: string;\n  grouped: string;\n  pill: string;\n  size: ButtonSizes;\n  // colors\n  color: ButtonColors;\n  outlineColor: ButtonOutlineColors;\n}\n\nexport interface ButtonColors extends Omit<FlowbiteColors, keyof FlowbiteStateColors> {\n  [key: string]: string;\n  default: string;\n  alternative: string;\n}\n\nexport interface ButtonOutlineColors extends Omit<ButtonColors, \"alternative\" | \"light\"> {\n  [key: string]: string;\n}\n\nexport interface ButtonSizes extends Pick<FlowbiteSizes, \"xs\" | \"sm\" | \"lg\" | \"xl\"> {\n  [key: string]: string;\n}\n\nexport type ButtonProps<T extends ElementType = \"button\"> = PolymorphicComponentPropWithRef<\n  T,\n  {\n    href?: string;\n    color?: DynamicStringEnumKeysOf<ButtonColors>;\n    fullSized?: boolean;\n    outline?: boolean;\n    pill?: boolean;\n    size?: DynamicStringEnumKeysOf<ButtonSizes>;\n  }\n> &\n  ThemingProps<ButtonTheme>;\n\ntype ButtonComponentType = (<C extends ElementType = \"button\">(props: ButtonProps<C>) => JSX.Element) & {\n  displayName?: string;\n};\n\nexport const Button = forwardRef(<T extends ElementType = \"button\">(props: ButtonProps<T>, ref: PolymorphicRef<T>) => {\n  const provider = useThemeProvider();\n  const theme = useResolveTheme(\n    [buttonTheme, provider.theme?.button, props.theme],\n    [get(provider.clearTheme, \"button\"), props.clearTheme],\n    [get(provider.applyTheme, \"button\"), props.applyTheme],\n  );\n\n  const {\n    children,\n    className,\n    color = \"default\",\n    disabled,\n    fullSized,\n    outline: _outline,\n    pill: _pill,\n    size = \"md\",\n    ...restProps\n  } = resolveProps(props, provider.props?.button);\n\n  const buttonGroup = useButtonGroupContext();\n\n  const outline = buttonGroup?.outline ?? _outline;\n  const pill = buttonGroup?.pill ?? _pill;\n\n  return (\n    <ButtonBase\n      ref={ref}\n      disabled={disabled}\n      className={twMerge(\n        theme.base,\n        theme.size[size],\n        pill && theme.pill,\n        disabled && theme.disabled,\n        fullSized && theme.fullSized,\n        outline ? theme.outlineColor[color] : theme.color[color],\n        buttonGroup && theme.grouped,\n        className,\n      )}\n      {...restProps}\n    >\n      {children}\n    </ButtonBase>\n  );\n}) as ButtonComponentType;\n\nButton.displayName = \"Button\";\n"],"names":["forwardRef","provider","useThemeProvider","theme","useResolveTheme","buttonTheme","get","resolveProps","useButtonGroupContext","jsx","ButtonBase","twMerge"],"mappings":";;;;;;;;;;;;;AAYY,MAAC,MAAM,GAAGA,gBAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AACjD,EAAE,MAAMC,UAAQ,GAAGC,yBAAgB,EAAE;AACrC,EAAE,MAAMC,OAAK,GAAGC,4BAAe;AAC/B,IAAI,CAACC,iBAAW,EAAEJ,UAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC;AACtD,IAAI,CAACK,OAAG,CAACL,UAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC;AAC1D,IAAI,CAACK,OAAG,CAACL,UAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,UAAU;AACzD,GAAG;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