{"version":3,"sources":["../../../src/components/button/index.ts","../../../src/components/button/button.tsx","../../../src/utils/tv.ts","../../../src/components/button/button.styles.ts","../../../src/hooks/use-theme.ts","../../../src/components/theme-provider/theme-provider.tsx","../../../src/components/icon/utils/get-icon-color.ts","../../../src/components/icon/utils/get-icon-size.ts","../../../src/components/icon/icon.tsx","../../../src/components/button/components/button-icon.tsx","../../../src/components/refresh/utils/get-refresh-color.ts","../../../src/components/refresh/refresh.tsx","../../../src/components/button/components/button-refresh.tsx","../../../src/components/button/utils/is-icon-only.ts"],"sourcesContent":["export { Button } from './button'\nexport type { ButtonProps } from './button.types'\n","import { forwardRef } from 'react'\n\nimport { type Scope, createContextScope } from '@radix-ui/react-context'\n\nimport type { ButtonProps } from './button.types'\n\nimport { buttonVariants } from './button.styles'\n\nimport { ButtonIcon } from './components/button-icon'\nimport { ButtonRefresh } from './components/button-refresh'\n\nimport { isIconOnly } from './utils/is-icon-only'\n\ntype ButtonContext = Pick<ButtonProps, 'variant' | 'size' | 'disabled'>\n\nconst DISPLAY_NAME = 'Button'\n\nconst ButtonRoot = forwardRef<HTMLButtonElement, ButtonProps>(\n  (props: ScopedProps<ButtonProps>, ref) => {\n    const {\n      children,\n      variant = 'brand-primary',\n      size = 'ml',\n      loading = false,\n      disabled = false,\n      full,\n      className,\n      __scopeButton,\n    } = props\n\n    const isDisabled = loading || disabled\n\n    return (\n      <ButtonProvider\n        scope={__scopeButton}\n        variant={variant}\n        size={size}\n        disabled={disabled}\n      >\n        <button\n          {...props}\n          ref={ref}\n          className={buttonVariants({\n            variant,\n            size,\n            disabled,\n            full,\n            className,\n            asIconOnly: isIconOnly(children),\n          })}\n          disabled={isDisabled}\n          aria-disabled={disabled}\n        >\n          {loading ? <ButtonRefresh /> : children}\n        </button>\n      </ButtonProvider>\n    )\n  }\n)\n\nButtonRoot.displayName = DISPLAY_NAME\n\n/*\n----------------------------------------------------------------\nScope Definition\n----------------------------------------------------------------\n*/\n\nexport type ScopedProps<P> = P & {\n  __scopeButton?: Scope\n}\n\nconst [createButtonContext] = createContextScope(DISPLAY_NAME)\n\nexport const [ButtonProvider, useButtonContext]: readonly [\n  ProviderType<ButtonContext>,\n  (consumerName: string, scope: Scope) => ButtonContext,\n] = createButtonContext<ButtonContext>(DISPLAY_NAME)\n\n/*\n----------------------------------------------------------------\nComposition Export\n----------------------------------------------------------------\n*/\n\nexport const Button = {\n  Root: ButtonRoot,\n  Icon: ButtonIcon,\n}\n","import { type VariantProps, createTV } from 'tailwind-variants'\n\nexport const tv = createTV({\n  twMergeConfig: {\n    extend: {\n      classGroups: {\n        'font-size': [\n          {\n            text: ['threepulse', 'threeandhalfpulse'],\n          },\n        ],\n        'border-width': [\n          {\n            border: ['quarterpulse', 'halfpulse'],\n          },\n        ],\n        '--tw-ring-inset': [\n          {\n            ring: ['none', 'quarterpulse', 'halfpulse'],\n          },\n        ],\n      },\n    },\n  },\n})\n\nexport type { VariantProps }\n","import { tv } from '~/utils/tv'\n\nexport const buttonVariants = tv({\n  base: `\n    tracking inline-flex items-center justify-center gap-twopulse rounded-pill\n    border-quarterpulse border-[transparent] font-bold font-rdmodern text-threeandhalfpulse truncate`,\n  variants: {\n    variant: {\n      'brand-primary': `bg-action-fill-brand-primary-enabled text-text-neutral-inverse\n        enabled:active:bg-action-fill-brand-primary-pressed enabled:hover:bg-action-fill-brand-primary-hovered`,\n      'neutral-secondary': `border-action-border-neutral-secondary-enabled bg-action-fill-neutral-secondary-enabled text-text-neutral\n        enabled:active:border-action-border-neutral-secondary-pressed enabled:active:bg-action-fill-neutral-secondary-pressed enabled:hover:bg-action-fill-neutral-secondary-hovered`,\n      'neutral-tertiary': `border-action-border-neutral-tertiary-enabled bg-action-fill-neutral-tertiary-enabled text-text-neutral\n        enabled:active:bg-action-fill-neutral-tertiary-pressed enabled:hover:bg-action-fill-neutral-tertiary-hovered`,\n    },\n    size: {\n      md: 'h-medium min-w-medium px-fourpulse text-threepulse leading-medium',\n      ml: 'h-mediumlarge min-w-mediumlarge px-fourpulse leading-small',\n      lg: 'h-large min-w-large px-fivepulse leading-small',\n      xl: 'h-extralarge min-w-extralarge px-sixpulse leading-small',\n    },\n    disabled: {\n      true: 'cursor-not-allowed text-text-neutral-disabled outline-none',\n      false:\n        'outline-action-border-focused outline-offset-4 focus-visible:outline-1',\n    },\n    full: {\n      true: 'w-full',\n    },\n    asIconOnly: {\n      true: 'aspect-square px-none',\n    },\n  },\n  compoundVariants: [\n    {\n      variant: 'brand-primary',\n      disabled: true,\n      class:\n        'border-action-border-brand-primary-disabled bg-action-fill-brand-primary-disabled',\n    },\n    {\n      variant: 'neutral-secondary',\n      disabled: true,\n      class:\n        'border-action-border-neutral-secondary-disabled bg-action-fill-neutral-secondary-disabled',\n    },\n    {\n      variant: 'neutral-tertiary',\n      disabled: true,\n      class:\n        'border-action-fill-neutral-tertiary-disabled bg-action-fill-neutral-tertiary-enabled',\n    },\n  ],\n\n  defaultVariants: {\n    variant: 'brand-primary',\n    size: 'ml',\n  },\n})\n","import {\n  DROGASIL_TOKENS,\n  GLOBALS_TOKENS,\n  PRIME_TOKENS,\n  RAIA_TOKENS,\n  RDSAUDESISTEMAS_TOKENS,\n  SUBSCRIPTION_TOKENS,\n} from '@raiadrogasil/pulso-design-tokens'\n\nimport { useContext } from 'react'\n\nimport { ThemeContext } from '~/components/theme-provider/theme-provider'\n\nexport function useTheme() {\n  const { currentTheme } = useContext(ThemeContext)\n\n  const themes = {\n    rdsaudesistemas: RDSAUDESISTEMAS_TOKENS,\n    drogasil: DROGASIL_TOKENS,\n    raia: RAIA_TOKENS,\n    subscription: SUBSCRIPTION_TOKENS,\n    prime: PRIME_TOKENS,\n  }\n\n  return {\n    ...themes[currentTheme],\n    ...GLOBALS_TOKENS,\n  }\n}\n","import { createContext, useEffect } from 'react'\n\nimport type { Themes } from '@raiadrogasil/pulso-design-tokens'\n\ntype TThemeContextData = {\n  currentTheme: Themes\n}\n\ninterface IThemeProviderProps {\n  children: React.ReactNode\n  theme: Themes\n}\n\nexport const ThemeContext = createContext({} as TThemeContextData)\n\nexport function ThemeProvider({ children, theme }: IThemeProviderProps) {\n  useEffect(() => {\n    if (theme && document) {\n      document?.documentElement?.classList?.add(theme)\n    }\n\n    return () => {\n      document?.documentElement?.classList?.remove(theme)\n    }\n  }, [theme])\n\n  return (\n    <ThemeContext.Provider\n      value={{\n        currentTheme: theme,\n      }}\n    >\n      {children}\n    </ThemeContext.Provider>\n  )\n}\n","import type { TIconColors } from '../icon.types'\n\nimport { useTheme } from '~/hooks/use-theme'\n\nexport function getColorIcon(color: keyof TIconColors) {\n  const theme = useTheme()\n  const allTokens = Object.keys(theme)\n\n  const colorTokens = allTokens.reduce((acc, tokenKey) => {\n    if (tokenKey.includes('color')) {\n      const colorToken = tokenKey as keyof TIconColors\n      acc[colorToken] = theme[colorToken]\n    }\n\n    return acc\n  }, {} as TIconColors)\n\n  return colorTokens[color]\n}\n","export const getIconSize = {\n  tiny: 'var(--sizing-tiny)',\n  'extra-small': 'var(--sizing-extrasmall)',\n  small: 'var(--sizing-small)',\n  medium: 'var(--sizing-medium)',\n}\n","import type { TIconProps } from './icon.types'\n\nimport { getColorIcon } from './utils/get-icon-color'\nimport { getIconSize } from './utils/get-icon-size'\n\nexport function Icon({\n  symbol = 'rdicon-default',\n  size = 'small',\n  color = 'colorActionFillBrandPrimaryEnabled',\n  ...props\n}: TIconProps) {\n  const symbolName = symbol.replace('rdicon', '').trim()\n\n  return (\n    <i\n      {...props}\n      title={symbolName}\n      className={symbol}\n      style={{\n        fontSize: getIconSize[size],\n        color: getColorIcon(color),\n      }}\n    />\n  )\n}\n\nexport type { TIconProps }\n","import { type ScopedProps, useButtonContext } from '../button'\nimport type { ButtonSizes, ButtonVariants } from '../button.types'\n\nimport { Icon, type TIconProps } from '~/components/icon'\n\ntype ButtonIconProps = Pick<TIconProps, 'symbol'>\n\nexport function ButtonIcon(props: ButtonIconProps) {\n  const { __scopeButton, ...rest } = props as ScopedProps<ButtonIconProps>\n\n  const { variant, size, disabled } = useButtonContext(\n    'ButtonIcon',\n    __scopeButton\n  )\n\n  const iconColorMapper: Record<ButtonVariants, TIconProps['color']> = {\n    'brand-primary': 'colorTextNeutralInverse',\n    'neutral-secondary': 'colorTextNeutralDefault',\n    'neutral-tertiary': 'colorTextNeutralDefault',\n  } as const\n\n  const iconSizeMapper: Record<ButtonSizes, TIconProps['size']> = {\n    md: 'extra-small',\n    ml: 'small',\n    lg: 'small',\n    xl: 'small',\n  } as const\n\n  return (\n    <Icon\n      {...rest}\n      color={disabled ? 'colorTextNeutralDisabled' : iconColorMapper[variant!]}\n      size={iconSizeMapper[size!]}\n    />\n  )\n}\n","import { useTheme } from '~/hooks/use-theme'\n\nimport type { TRefreshColor } from '../refresh.types'\n\nexport function getRefreshColor(color: TRefreshColor) {\n  const theme = useTheme()\n\n  const colors = {\n    brand: theme.colorActionFillBrandPrimaryEnabled,\n    neutral: theme.colorTextNeutralReadonly,\n    black: theme.colorTextNeutralDefault,\n    white: theme.colorTextNeutralInverse,\n  } as Record<TRefreshColor, string>\n\n  return colors[color]\n}\n","import type { TRefreshProps } from './refresh.types'\n\nimport { getRefreshColor } from './utils/get-refresh-color'\n\nexport function Refresh({ color = 'brand', srText }: TRefreshProps) {\n  return (\n    <div\n      role=\"status\"\n      className=\"grid size-eightpulse place-items-center\"\n      aria-label={srText}\n    >\n      <svg className=\"size-sixpulse animate-spin fill-none\" viewBox=\"0 0 24 24\">\n        <path\n          fillRule=\"evenodd\"\n          d=\"M0 12c0 6.627 5.373 12 12 12s12-5.373 12-12S18.627 0 12 0v2c5.523 0 10 4.477 10 10s-4.477 10-10 10S2 17.523 2 12H0z\"\n          clipRule=\"evenodd\"\n          fill={getRefreshColor(color)}\n        />\n\n        <title>{srText}</title>\n      </svg>\n    </div>\n  )\n}\n\nexport type { TRefreshProps }\n","import { type ScopedProps, useButtonContext } from '../button'\n\nimport { Refresh, type TRefreshProps } from '~/components/refresh'\nimport type { ButtonVariants } from '../button.types'\n\ntype ButtonRefreshProps = Pick<TRefreshProps, 'srText'>\n\nexport function ButtonRefresh(props: ButtonRefreshProps) {\n  const { __scopeButton, ...rest } = props as ScopedProps<ButtonRefreshProps>\n\n  const { variant } = useButtonContext('ButtonRefresh', __scopeButton)\n\n  const refreshColorMapper = {\n    'brand-primary': 'white',\n    'neutral-secondary': 'neutral',\n    'neutral-tertiary': 'black',\n  } as Record<ButtonVariants, TRefreshProps['color']>\n\n  return <Refresh {...rest} color={refreshColorMapper[variant!]} />\n}\n","import React from 'react'\n\nimport { ButtonIcon } from '../components/button-icon'\n\nexport function isIconOnly(children: React.ReactNode) {\n  if (React.Children.count(children) === 1 && React.isValidElement(children)) {\n    return children.type === ButtonIcon\n  }\n\n  return false\n}\n"],"mappings":"sjCAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,YAAAE,IAAA,eAAAC,GAAAH,ICAA,IAAAI,EAA2B,iBAE3BC,EAA+C,mCCF/C,IAAAC,EAA4C,6BAE/BC,KAAK,YAAS,CACzB,cAAe,CACb,OAAQ,CACN,YAAa,CACX,YAAa,CACX,CACE,KAAM,CAAC,aAAc,mBAAmB,CAC1C,CACF,EACA,eAAgB,CACd,CACE,OAAQ,CAAC,eAAgB,WAAW,CACtC,CACF,EACA,kBAAmB,CACjB,CACE,KAAM,CAAC,OAAQ,eAAgB,WAAW,CAC5C,CACF,CACF,CACF,CACF,CACF,CAAC,ECtBM,IAAMC,EAAiBC,EAAG,CAC/B,KAAM;AAAA;AAAA,sGAGN,SAAU,CACR,QAAS,CACP,gBAAiB;AAAA,gHAEjB,oBAAqB;AAAA,sLAErB,mBAAoB;AAAA,qHAEtB,EACA,KAAM,CACJ,GAAI,oEACJ,GAAI,6DACJ,GAAI,iDACJ,GAAI,yDACN,EACA,SAAU,CACR,KAAM,6DACN,MACE,wEACJ,EACA,KAAM,CACJ,KAAM,QACR,EACA,WAAY,CACV,KAAM,uBACR,CACF,EACA,iBAAkB,CAChB,CACE,QAAS,gBACT,SAAU,GACV,MACE,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AAYP,GAAZ,CAAkB,MAAOI,EAAmBF,CAAQ,GAAG,CACjE,CCnBA,IAAAM,EAAkB,uBAIX,SAASC,EAAWC,EAA2B,CACpD,OAAI,EAAAC,QAAM,SAAS,MAAMD,CAAQ,IAAM,GAAK,EAAAC,QAAM,eAAeD,CAAQ,EAChEA,EAAS,OAASE,EAGpB,EACT,CZ2CqB,IAAAC,EAAA,6BAtCfC,EAAe,SAEfC,KAAa,cACjB,CAACC,EAAiCC,IAAQ,CACxC,GAAM,CACJ,SAAAC,EACA,QAAAC,EAAU,gBACV,KAAAC,EAAO,KACP,QAAAC,EAAU,GACV,SAAAC,EAAW,GACX,KAAAC,EACA,UAAAC,EACA,cAAAC,CACF,EAAIT,EAEEU,EAAaL,GAAWC,EAE9B,SACE,OAACK,GAAA,CACC,MAAOF,EACP,QAASN,EACT,KAAMC,EACN,SAAUE,EAEV,mBAAC,SAAAM,EAAAC,EAAA,GACKb,GADL,CAEC,IAAKC,EACL,UAAWa,EAAe,CACxB,QAAAX,EACA,KAAAC,EACA,SAAAE,EACA,KAAAC,EACA,UAAAC,EACA,WAAYO,EAAWb,CAAQ,CACjC,CAAC,EACD,SAAUQ,EACV,gBAAeJ,EAEd,SAAAD,KAAU,OAACW,EAAA,EAAc,EAAKd,GACjC,EACF,CAEJ,CACF,EAEAH,EAAW,YAAcD,EAYzB,GAAM,CAACmB,EAAmB,KAAI,sBAAmBnB,CAAY,EAEhD,CAACa,GAAgBO,CAAgB,EAG1CD,GAAmCnB,CAAY,EAQtCqB,EAAS,CACpB,KAAMpB,EACN,KAAMqB,CACR","names":["button_exports","__export","Button","__toCommonJS","import_react","import_react_context","import_tailwind_variants","tv","buttonVariants","tv","import_pulso_design_tokens","import_react","import_react","import_jsx_runtime","ThemeContext","useTheme","currentTheme","ThemeContext","__spreadValues","getColorIcon","color","theme","useTheme","acc","tokenKey","colorToken","getIconSize","import_jsx_runtime","Icon","_a","_b","symbol","size","color","props","__objRest","symbolName","__spreadProps","__spreadValues","getIconSize","getColorIcon","import_jsx_runtime","ButtonIcon","props","_a","__scopeButton","rest","__objRest","variant","size","disabled","useButtonContext","iconColorMapper","iconSizeMapper","Icon","__spreadProps","__spreadValues","getRefreshColor","color","theme","useTheme","import_jsx_runtime","Refresh","color","srText","getRefreshColor","import_jsx_runtime","ButtonRefresh","props","_a","__scopeButton","rest","__objRest","variant","useButtonContext","refreshColorMapper","Refresh","__spreadProps","__spreadValues","import_react","isIconOnly","children","React","ButtonIcon","import_jsx_runtime","DISPLAY_NAME","ButtonRoot","props","ref","children","variant","size","loading","disabled","full","className","__scopeButton","isDisabled","ButtonProvider","__spreadProps","__spreadValues","buttonVariants","isIconOnly","ButtonRefresh","createButtonContext","useButtonContext","Button","ButtonIcon"]}