UNPKG

@crossed/ui

Version:

A universal & performant styling library for React Native, Next.js & React

104 lines (103 loc) 3.65 kB
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); var Table_exports = {}; __export(Table_exports, { TBody: () => TBody, THead: () => THead, Table: () => Table, Td: () => Td, Th: () => Th, Tr: () => Tr }); module.exports = __toCommonJS(Table_exports); var import_jsx_runtime = require("react/jsx-runtime"); var import_Text = require("../typography/Text"); var import_styled = require("@crossed/styled"); const useTable = (0, import_styled.createStyles)((t) => ({ table: { base: { width: "100%", borderCollapse: "collapse", borderWidth: 0, tableLayout: "fixed" } }, thead: { base: { borderTopWidth: 0, borderLeftWidth: 0, borderRightWidth: 0, borderBottomWidth: 1, borderStyle: "solid" // borderColor: t.colors.neutral.bright, // backgroundColor: t.colors.neutral.low, } }, tbody: { base: {} }, tr: { base: { borderTopWidth: 1, borderLeftWidth: 0, borderRightWidth: 0, borderBottomWidth: 0, borderStyle: "solid" // borderColor: t.colors.neutral[500], } }, td: { base: { padding: t.space.md } }, th: { base: { textAlign: "left", padding: t.space.md } } })); const Table = (props) => { return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("table", { ...props, ...useTable.table.className() }); }; const THead = (props) => { return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { ...props, ...useTable.thead.className() }); }; const TBody = ({ children, ...props }) => { const newChild = Array.isArray(children) && children.length > 0 || children ? children : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Tr, { children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Td, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Text.Text, { color: "warning", children: "-" }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Td, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Text.Text, { color: "warning", children: "-" }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Td, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Text.Text, { color: "warning", children: "-" }) }) ] }); return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { ...props, ...useTable.tbody.className(), children: newChild }); }; const Tr = (props) => { return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { ...props, ...useTable.tr.className() }); }; Tr.id = "Table.Tr"; const Td = (props) => { return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { ...props, ...useTable.td.className() }); }; const Th = (props) => { return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { ...props, ...useTable.th.className() }); }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { TBody, THead, Table, Td, Th, Tr }); //# sourceMappingURL=Table.js.map