UNPKG

@yamada-ui/react

Version:

React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion

1 lines 2.68 kB
{"version":3,"file":"link-box.cjs","names":["createSlotComponent","linkBoxStyle","useExtractProps","radiusProperties","styled"],"sources":["../../../../src/components/link-box/link-box.tsx"],"sourcesContent":["\"use client\"\n\nimport type { HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { Dict } from \"../../utils\"\nimport type { LinkBoxStyle } from \"./link-box.style\"\nimport {\n createSlotComponent,\n radiusProperties,\n styled,\n useExtractProps,\n} from \"../../core\"\nimport { dataAttr } from \"../../utils\"\nimport { linkBoxStyle } from \"./link-box.style\"\n\ninterface ComponentContext extends Dict {}\n\nexport interface LinkBoxRootProps\n extends HTMLStyledProps,\n ThemeProps<LinkBoxStyle> {}\n\nconst {\n ComponentContext,\n PropsContext: LinkBoxPropsContext,\n useComponentContext,\n usePropsContext: useLinkBoxPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<LinkBoxRootProps, LinkBoxStyle, ComponentContext>(\n \"link-box\",\n linkBoxStyle,\n)\n\nexport { LinkBoxPropsContext, useLinkBoxPropsContext }\n\n/**\n * `LinkBox` is a component that allows elements such as articles or cards to function as a single link.\n *\n * @see https://yamada-ui.com/docs/components/link-box\n */\nexport const LinkBoxRoot = withProvider<\"div\", LinkBoxRootProps>(\n ({ children, ...rest }) => {\n const context = useExtractProps(rest, radiusProperties)\n\n return (\n <ComponentContext value={context}>\n <styled.div {...rest}>{children}</styled.div>\n </ComponentContext>\n )\n },\n \"root\",\n)()\n\nexport interface LinkBoxOverlayProps extends HTMLStyledProps<\"a\"> {\n /**\n * If `true`, the link will open in new tab.\n *\n * @default false\n */\n external?: boolean\n}\n\nexport const LinkBoxOverlay = withContext<\"a\", LinkBoxOverlayProps>(\n \"a\",\n \"overlay\",\n)(undefined, ({ external, _before, ...rest }) => {\n const context = useComponentContext()\n\n return {\n rel: external ? \"noopener\" : undefined,\n target: external ? \"_blank\" : undefined,\n \"data-link-box-overlay\": dataAttr(true),\n _before: { ..._before, ...context },\n ...rest,\n }\n})\n"],"mappings":";;;;;;;;;;;;;;AAoBA,MAAM,EACJ,kBACA,cAAc,qBACd,qBACA,iBAAiB,wBACjB,aACA,iBACEA,6CACF,YACAC,oCACD;;;;;;AASD,MAAa,cAAc,cACxB,EAAE,SAAU,GAAG,WAAW;AAGzB,QACE,2CAAC;EAAiB,OAHJC,8BAAgB,MAAMC,gCAAiB;YAInD,2CAACC,uBAAO;GAAI,GAAI;GAAO;IAAsB;GAC5B;GAGvB,OACD,EAAE;AAWH,MAAa,iBAAiB,YAC5B,KACA,UACD,CAAC,SAAY,EAAE,UAAU,QAAS,GAAG,WAAW;CAC/C,MAAM,UAAU,qBAAqB;AAErC,QAAO;EACL,KAAK,WAAW,aAAa;EAC7B,QAAQ,WAAW,WAAW;EAC9B,yEAAkC,KAAK;EACvC,SAAS;GAAE,GAAG;GAAS,GAAG;GAAS;EACnC,GAAG;EACJ;EACD"}