@yamada-ui/card
Version:
Yamada UI card component
140 lines (139 loc) • 4.04 kB
JavaScript
"use client"
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/card.tsx
var card_exports = {};
__export(card_exports, {
Card: () => Card,
CardBody: () => CardBody,
CardFooter: () => CardFooter,
CardHeader: () => CardHeader
});
module.exports = __toCommonJS(card_exports);
var import_core = require("@yamada-ui/core");
var import_utils = require("@yamada-ui/utils");
var import_jsx_runtime = require("react/jsx-runtime");
var [CardProvider, useCard] = (0, import_utils.createContext)({
name: `CardContext`,
errorMessage: `useCard returned is 'undefined'. Seems you forgot to wrap the components in "<Card />" `
});
var Card = (0, import_core.forwardRef)((props, ref) => {
const [styles, mergedProps] = (0, import_core.useComponentMultiStyle)("Card", props);
const {
className,
align: alignItems,
direction = "column",
flexDirection = direction,
justify: justifyContent,
...rest
} = (0, import_core.omitThemeProps)(mergedProps);
const css = {
alignItems,
display: "flex",
flexDirection,
justifyContent,
wordWrap: "break-word",
...styles.container
};
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CardProvider, { value: styles, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_core.ui.article,
{
ref,
className: (0, import_utils.cx)("ui-card", className),
__css: css,
...rest
}
) });
});
Card.displayName = "Card";
Card.__ui__ = "Card";
var CardHeader = (0, import_core.forwardRef)(
({ className, ...rest }, ref) => {
const styles = useCard();
const css = {
alignItems: "center",
display: "flex",
justifyContent: "flex-start",
...styles.header
};
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_core.ui.header,
{
ref,
className: (0, import_utils.cx)("ui-card__header", className),
__css: css,
...rest
}
);
}
);
CardHeader.displayName = "CardHeader";
CardHeader.__ui__ = "CardHeader";
var CardBody = (0, import_core.forwardRef)(
({ className, ...rest }, ref) => {
const styles = useCard();
const css = {
alignItems: "flex-start",
display: "flex",
flexDirection: "column",
...styles.body
};
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_core.ui.div,
{
ref,
className: (0, import_utils.cx)("ui-card__body", className),
__css: css,
...rest
}
);
}
);
CardBody.displayName = "CardBody";
CardBody.__ui__ = "CardBody";
var CardFooter = (0, import_core.forwardRef)(
({ className, ...rest }, ref) => {
const styles = useCard();
const css = {
alignItems: "center",
display: "flex",
justifyContent: "flex-start",
...styles.footer
};
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_core.ui.footer,
{
ref,
className: (0, import_utils.cx)("ui-card__footer", className),
__css: css,
...rest
}
);
}
);
CardFooter.displayName = "CardFooter";
CardFooter.__ui__ = "CardFooter";
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
Card,
CardBody,
CardFooter,
CardHeader
});
//# sourceMappingURL=card.js.map