UNPKG

@rdsaude/pulso-react-components

Version:

Biblioteca de componentes React do Pulso Design System da RD Saúde oferece componentes consistentes e de alto desempenho, alinhados com os padrões da RDSaúde. Ideal para desenvolver aplicações modernas e acessíveis.

1 lines 12.9 kB
{"version":3,"sources":["../../../src/components/link/index.ts","../../../src/components/link/link.tsx","../../../src/components/icon/index.tsx","../../../src/hooks/use-theme.ts","../../../src/components/theme-provider/index.tsx","../../../src/components/link/components/link-icon.tsx","../../../src/utils/tv.ts","../../../src/components/link/link.styles.ts"],"sourcesContent":["export { Link } from './link'\nexport type { LinkProps } from './link.types'\n","import { type Scope, createContextScope } from '@radix-ui/react-context'\nimport { forwardRef } from 'react'\nimport { LinkIcon } from './components/link-icon'\nimport {\n iconLinkVariants,\n labelLinkVariants,\n linkVariants,\n} from './link.styles'\nimport type { LinkProps } from './link.types'\n\ntype LinkContext = Pick<LinkProps, 'size' | 'disabled'>\n\nconst DISPLAY_NAME = 'Link'\n\nconst LinkRoot = forwardRef<HTMLAnchorElement, LinkProps>(\n (props: LinkScopedProps<LinkProps>, ref) => {\n const {\n children,\n icon,\n size,\n disabled,\n full,\n __scopeLink,\n href,\n onClick,\n ...rest\n } = props\n\n const linkClassName = linkVariants({\n size,\n disabled,\n full,\n })\n\n const handleClick = (\n event: React.MouseEvent<HTMLAnchorElement, MouseEvent>\n ) => {\n if (disabled) {\n event.preventDefault()\n event.stopPropagation()\n return\n }\n if (onClick) {\n onClick(event)\n }\n }\n\n return (\n <LinkProvider scope={__scopeLink} size={size} disabled={disabled}>\n <a\n {...rest}\n ref={ref}\n href={disabled ? undefined : href}\n className={linkClassName}\n aria-disabled={disabled}\n role=\"link\"\n onClick={handleClick}\n >\n <div className={labelLinkVariants()}>{children}</div>\n {icon && <LinkIcon className={iconLinkVariants()} />}\n </a>\n </LinkProvider>\n )\n }\n)\n\nLinkRoot.displayName = DISPLAY_NAME\n\n/*\nScope Definition\n*/\n\nexport type LinkScopedProps<P> = P & {\n __scopeLink?: Scope\n}\n\nconst [createLinkContext] = createContextScope(DISPLAY_NAME)\n\nexport const [LinkProvider, useLinkContext]: readonly [\n ProviderType<LinkContext>,\n (consumerName: string, scope: Scope) => LinkContext,\n] = createLinkContext<LinkContext>(DISPLAY_NAME)\n\n/*\nComposition Export\n*/\n\nexport const Link = {\n Root: LinkRoot,\n}\n","import * as React from 'react'\n\nimport type { RDSAUDESISTEMAS_TOKENS } from '@raiadrogasil/pulso-design-tokens'\nimport type { IconName } from '@raiadrogasil/pulso-icons'\n\nimport { useTheme } from '~/hooks/use-theme'\n\ntype IconVisualSize = 'tiny' | 'extra-small' | 'small' | 'medium'\ntype DesignTokens = typeof RDSAUDESISTEMAS_TOKENS\n\ntype TokenColorKeys = {\n [K in keyof DesignTokens as K extends `color${string}`\n ? K\n : never]: DesignTokens[K]\n}\n\n/**\n * Propriedades do componente Icon.\n */\nexport type IconProps = React.ComponentProps<'i'> & {\n /**\n * Define o ícone a ser exibido, com base na lista de nomes disponíveis em `@raiadrogasil/pulso-icons`.\n *\n * @default 'rdicon-default'\n */\n symbol?: IconName\n\n /**\n * Define o tamanho visual do ícone, controlando o `font-size` com base nos tokens de espaçamento.\n *\n * Valores possíveis: 'tiny', 'extra-small', 'small', 'medium'.\n *\n * @default 'small'\n */\n size?: IconVisualSize\n\n /**\n * Define a cor do ícone usando uma chave de token de cor do design system.\n * A cor é aplicada via `style.color`.\n *\n * @default 'colorActionFillBrandPrimaryEnabled'\n */\n color?: keyof TokenColorKeys\n}\n\nexport function Icon({\n symbol = 'rdicon-default',\n size = 'small',\n color = 'colorActionFillBrandPrimaryEnabled',\n ...props\n}: IconProps) {\n const theme = useTheme()\n\n const resolvedFontSizes = React.useMemo(() => {\n return {\n tiny: theme.sizingTiny,\n 'extra-small': theme.sizingExtrasmall,\n small: theme.sizingSmall,\n medium: theme.sizingMedium,\n }\n }, [])\n\n return (\n <i\n {...props}\n className={symbol}\n style={{\n fontSize: resolvedFontSizes[size],\n color: theme[color],\n display: 'inline-flex',\n }}\n />\n )\n}\n\nIcon.displayName = 'Icon'\n\nexport * from './deprecated'\n","import * as React from 'react'\n\nimport {\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 { ThemeContext } from '~/components/theme-provider'\n\ntype ThemeTokens = typeof RDSAUDESISTEMAS_TOKENS & typeof GLOBALS_TOKENS\n\nexport function useTheme(): ThemeTokens {\n const mappedTheme = React.useMemo(() => {\n return {\n rdsaudesistemas: RDSAUDESISTEMAS_TOKENS,\n drogasil: DROGASIL_TOKENS,\n raia: RAIA_TOKENS,\n subscription: SUBSCRIPTION_TOKENS,\n prime: PRIME_TOKENS,\n }\n }, [])\n\n const context = React.useContext(ThemeContext)\n\n if (!context) {\n throw new Error(\n '[Pulso] useTheme precisa estar dentro de um <ThemeProvider>. Verifique se o provedor está corretamente configurado na raiz da aplicação.'\n )\n }\n\n const { currentTheme } = context\n\n const result = {\n ...GLOBALS_TOKENS,\n ...mappedTheme[currentTheme],\n } as ThemeTokens\n\n return result\n}\n","import * as React from 'react'\n\nimport type { Themes } from '@raiadrogasil/pulso-design-tokens'\n\nexport const ThemeContext = React.createContext({\n currentTheme: 'rdsaudesistemas',\n} as {\n currentTheme: Themes\n})\n\ntype ThemeProviderProps = {\n children: React.ReactNode\n theme?: Themes\n}\n\nexport function ThemeProvider({\n children,\n theme = 'rdsaudesistemas',\n}: ThemeProviderProps) {\n if (typeof window !== 'undefined') {\n document.documentElement.setAttribute('class', theme)\n }\n\n return (\n <ThemeContext.Provider\n value={{\n currentTheme: theme,\n }}\n >\n {children}\n </ThemeContext.Provider>\n )\n}\n","import { Icon, type TIconProps } from '~/components/icon'\nimport { useLinkContext } from '../link'\nimport type { LinkIconProps, LinkScopedProps } from '../link.types'\n\nexport function LinkIcon({\n __scopeLink,\n color = 'colorTextNeutralDefault',\n className,\n ...props\n}: LinkScopedProps<LinkIconProps> & { className?: string }) {\n const { size, disabled } = useLinkContext('LinkIcon', __scopeLink)\n\n const iconSizeMapper: Record<string, TIconProps['size']> = {\n md: 'tiny',\n ml: 'tiny',\n } as const\n\n return (\n <div\n className={`flex items-center ${className && className}`}\n role=\"figure\"\n >\n <Icon\n {...props}\n symbol=\"rdicon-open\"\n color={disabled ? 'colorTextNeutralDisabled' : color}\n size={iconSizeMapper[size!]}\n />\n </div>\n )\n}\n","import { type VariantProps, createTV } from 'tailwind-variants'\n\nexport const tv = createTV({\n twMerge: true,\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 linkVariants = tv({\n base: 'letter-spacing-default inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md rounded-pill border-action-border-neutral-tertiary-enabled bg-action-fill-neutral-tertiary-enabled px-fourpulse text-text-neutral hover:border-action-border-neutral-tertiary-hovered hover:bg-action-fill-neutral-tertiary-hovered focus:border-action-border-focused focus:border-halfpulse active:border-action-border-neutral-tertiary-pressed active:bg-action-fill-neutral-tertiary-pressed focus:active:border-action-border-focused',\n variants: {\n size: {\n md: 'h-medium min-w-medium font-semibold text-threepulse leading-medium',\n ml: 'h-mediumlarge min-w-mediumlarge font-semibold text-threeandhalfpulse leading-small',\n },\n disabled: {\n true: 'cursor-not-allowed border-action-border-neutral-tertiary-disabled bg-action-fill-neutral-tertiary-disabled text-text-neutral-disabled hover:bg-action-fill-neutral-tertiary-disabled active:bg-action-fill-neutral-tertiary-disabled',\n false: '',\n },\n full: {\n true: 'w-full',\n },\n withIcon: {\n true: 'pl-1',\n },\n },\n defaultVariants: {\n size: 'md',\n },\n})\nexport const labelLinkVariants = tv({\n base: 'inline-flex h-small items-center justify-center underline decoration-solid',\n})\nexport const iconLinkVariants = tv({\n base: 'pl-onepulse no-underline',\n})\n"],"mappings":"ojCAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,UAAAE,IAAA,eAAAC,GAAAH,ICAA,IAAAI,EAA+C,mCAC/CC,EAA2B,iBCD3B,IAAAC,EAAuB,sBCAvB,IAAAC,EAAuB,sBAEvBC,EAOO,6CCTP,IAAAC,EAAuB,sBAwBnBC,GAAA,6BApBSC,EAAqB,gBAAc,CAC9C,aAAc,iBAChB,CAEC,EDOM,SAASC,GAAwB,CACtC,IAAMC,EAAoB,UAAQ,KACzB,CACL,gBAAiB,yBACjB,SAAU,kBACV,KAAM,cACN,aAAc,sBACd,MAAO,cACT,GACC,CAAC,CAAC,EAECC,EAAgB,aAAWC,CAAY,EAE7C,GAAI,CAACD,EACH,MAAM,IAAI,MACR,mJACF,EAGF,GAAM,CAAE,aAAAE,CAAa,EAAIF,EAOzB,OALeG,IAAA,GACV,kBACAJ,EAAYG,CAAY,EAI/B,CDqBI,IAAAE,EAAA,6BAlBG,SAASC,EAAKC,EAKP,CALO,IAAAC,EAAAD,EACnB,QAAAE,EAAS,iBACT,KAAAC,EAAO,QACP,MAAAC,EAAQ,oCAhDV,EA6CqBH,EAIhBI,EAAAC,EAJgBL,EAIhB,CAHH,SACA,OACA,UAGA,IAAMM,EAAQC,EAAS,EAEjBC,EAA0B,UAAQ,KAC/B,CACL,KAAMF,EAAM,WACZ,cAAeA,EAAM,iBACrB,MAAOA,EAAM,YACb,OAAQA,EAAM,YAChB,GACC,CAAC,CAAC,EAEL,SACE,OAAC,IAAAG,EAAAC,EAAA,GACKN,GADL,CAEC,UAAWH,EACX,MAAO,CACL,SAAUO,EAAkBN,CAAI,EAChC,MAAOI,EAAMH,CAAK,EAClB,QAAS,aACX,GACF,CAEJ,CAEAL,EAAK,YAAc,OGrDb,IAAAa,EAAA,6BAlBC,SAASC,E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A,YAAAC,EACA,KAAAC,EACA,QAAAC,CAxBN,EA0BQR,EADCS,EAAAC,EACDV,EADC,CARH,WACA,OACA,OACA,WACA,OACA,cACA,OACA,YAIIW,EAAgBC,EAAa,CACjC,KAAAT,EACA,SAAAC,EACA,KAAAC,CACF,CAAC,EAEKQ,EACJC,GACG,CACH,GAAIV,EAAU,CACZU,EAAM,eAAe,EACrBA,EAAM,gBAAgB,EACtB,MACF,CACIN,GACFA,EAAQM,CAAK,CAEjB,EAEA,SACE,OAACC,GAAA,CAAa,MAAOT,EAAa,KAAMH,EAAM,SAAUC,EACtD,oBAAC,IAAAY,EAAAC,EAAA,GACKR,GADL,CAEC,IAAKV,EACL,KAAMK,EAAW,OAAYG,EAC7B,UAAWI,EACX,gBAAeP,EACf,KAAK,OACL,QAASS,EAET,oBAAC,OAAI,UAAWK,EAAkB,EAAI,SAAAjB,EAAS,EAC9CC,MAAQ,OAACiB,EAAA,CAAS,UAAWC,EAAiB,EAAG,IACpD,EACF,CAEJ,CACF,EAEAvB,EAAS,YAAcD,EAUvB,GAAM,CAACyB,EAAiB,KAAI,sBAAmBzB,CAAY,EAE9C,CAACmB,GAAcO,CAAc,EAGtCD,GAA+BzB,CAAY,EAMlC2B,EAAO,CAClB,KAAM1B,CACR","names":["link_exports","__export","Link","__toCommonJS","import_react_context","import_react","React","React","import_pulso_design_tokens","React","import_jsx_runtime","ThemeContext","useTheme","mappedTheme","context","ThemeContext","currentTheme","__spreadValues","import_jsx_runtime","Icon","_a","_b","symbol","size","color","props","__objRest","theme","useTheme","resolvedFontSizes","__spreadProps","__spreadValues","import_jsx_runtime","LinkIcon","_a","_b","__scopeLink","color","className","props","__objRest","size","disabled","useLinkContext","iconSizeMapper","Icon","__spreadProps","__spreadValues","import_tailwind_variants","tv","linkVariants","tv","labelLinkVariants","iconLinkVariants","import_jsx_runtime","DISPLAY_NAME","LinkRoot","props","ref","_a","children","icon","size","disabled","full","__scopeLink","href","onClick","rest","__objRest","linkClassName","linkVariants","handleClick","event","LinkProvider","__spreadProps","__spreadValues","labelLinkVariants","LinkIcon","iconLinkVariants","createLinkContext","useLinkContext","Link"]}