UNPKG

carbon-react

Version:

A library of reusable React components for easily building user interfaces.

2 lines (1 loc) 2.85 kB
import{jsxs as e,jsx as r}from"react/jsx-runtime";import{useState as t}from"react";import"../../style/utils/filter-styled-system-padding-props.js";import o from"../../style/utils/filter-styled-system-margin-props.js";import{CardProvider as n}from"./__internal__/card.context.js";import{StyledCard as a,StyledCardContent as i}from"./card.style.js";import l from"../icon/icon.component.js";import c from"../../__internal__/utils/helpers/tags/tags.js";import s from"../../__internal__/utils/logger/index.js";function d(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}const p=p=>{var{"data-element":u,"data-role":f,children:b,width:m="500px",draggable:g,height:h,onClick:y,href:O,spacing:j="medium",boxShadow:v,hoverBoxShadow:w,roundness:x="default",footer:P,rel:S,target:_,"aria-label":k}=p,C=function(e,r){if(null==e)return{};var t,o,n=function(e,r){if(null==e)return{};var t,o,n={},a=Object.keys(e);for(o=0;o<a.length;o++)t=a[o],r.indexOf(t)>=0||(n[t]=e[t]);return n}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)t=a[o],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}(p,["data-element","data-role","children","width","draggable","height","onClick","href","spacing","boxShadow","hoverBoxShadow","roundness","footer","rel","target","aria-label"]);const[D,B]=t(null),E=!(!y&&!O);let F=!1;return!F&&E&&(null==D?void 0:D.querySelector("[data-component='card-footer']"))&&(F=!0,s.warn("This `Card` is interactive you should use the `footer` prop to render a `CardFooter` to avoid potential accessibility issues")),e(a,function(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})),e}(function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),o.forEach((function(r){d(e,r,t[r])}))}return e}({cardWidth:m,interactive:E,draggable:!!g,spacing:j,boxShadow:v,hoverBoxShadow:w,height:h,roundness:x},o(C),c("card",{"data-element":u,"data-role":f})),{children:[g&&r(l,{type:"drag"}),e(n,{value:{roundness:x,spacing:j},children:[r(i,{"data-element":"card-content-container",onClick:g?void 0:y,href:g?void 0:O,rel:!g&&O?S:void 0,target:!g&&O?_:void 0,interactive:E,spacing:j,roundness:x,hasFooter:!!P,ref:B,"aria-label":k,children:b}),P]})]}))};p.displayName="Card";export{p as default};