@mediaradar/design-components 0.22.1 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +98 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +120 -9
- package/dist/index.d.ts +120 -9
- package/dist/index.js +97 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/scripts/check-tailwind-coverage.mjs +0 -0
package/dist/index.cjs
CHANGED
|
@@ -34,6 +34,7 @@ __export(index_exports, {
|
|
|
34
34
|
ChipContent: () => ChipContent,
|
|
35
35
|
DEFAULT_SEARCH_MATCH: () => DEFAULT_SEARCH_MATCH,
|
|
36
36
|
DataScopeFilter: () => DataScopeFilter,
|
|
37
|
+
DataTable: () => DataTable,
|
|
37
38
|
DateRangeFilter: () => DateRangeFilter,
|
|
38
39
|
DateRangePicker: () => DateRangePicker,
|
|
39
40
|
Delta: () => Delta,
|
|
@@ -4147,7 +4148,10 @@ var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
|
4147
4148
|
var WIDTH = {
|
|
4148
4149
|
sm: "max-w-110",
|
|
4149
4150
|
md: "max-w-160",
|
|
4150
|
-
lg: "max-w-220"
|
|
4151
|
+
lg: "max-w-220",
|
|
4152
|
+
// A whole workspace in a dialog: a column picker, a detail view with its
|
|
4153
|
+
// own tabs, a grid of events. 880 squeezed their tables into scrolling.
|
|
4154
|
+
xl: "max-w-300"
|
|
4151
4155
|
};
|
|
4152
4156
|
var FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
4153
4157
|
function Modal({ open, onClose, title, description, size = "md", footer, children, className }) {
|
|
@@ -4403,6 +4407,98 @@ var TextField = (0, import_react21.forwardRef)(
|
|
|
4403
4407
|
}
|
|
4404
4408
|
);
|
|
4405
4409
|
TextField.displayName = "TextField";
|
|
4410
|
+
|
|
4411
|
+
// src/DataTable.tsx
|
|
4412
|
+
var import_react22 = require("react");
|
|
4413
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
4414
|
+
var WIDTH2 = { fill: "", sm: "w-24", md: "w-36", lg: "w-48" };
|
|
4415
|
+
var MAX_H = { sm: "max-h-80", md: "max-h-120", lg: "max-h-160" };
|
|
4416
|
+
var HEAD_PAD = { default: "px-4 py-3", compact: "px-3 py-2" };
|
|
4417
|
+
var CELL_PAD = { default: "px-4 py-3.5", compact: "px-3 py-2" };
|
|
4418
|
+
function DataTable({
|
|
4419
|
+
columns,
|
|
4420
|
+
rows,
|
|
4421
|
+
rowKey,
|
|
4422
|
+
title,
|
|
4423
|
+
subtitle,
|
|
4424
|
+
action,
|
|
4425
|
+
sort = null,
|
|
4426
|
+
onSortChange,
|
|
4427
|
+
density = "default",
|
|
4428
|
+
loading = false,
|
|
4429
|
+
loadingRows = 5,
|
|
4430
|
+
empty,
|
|
4431
|
+
maxHeight,
|
|
4432
|
+
footer,
|
|
4433
|
+
className,
|
|
4434
|
+
...rest
|
|
4435
|
+
}) {
|
|
4436
|
+
const titleId = (0, import_react22.useId)();
|
|
4437
|
+
const head = HEAD_PAD[density];
|
|
4438
|
+
const pad = CELL_PAD[density];
|
|
4439
|
+
const align = (c) => c.numeric ? "text-right" : "text-left";
|
|
4440
|
+
const width = (c) => WIDTH2[c.width ?? (c.numeric ? "md" : "fill")];
|
|
4441
|
+
const onSort = (key) => {
|
|
4442
|
+
const col = columns.find((c) => c.key === key);
|
|
4443
|
+
onSortChange?.(cycleSort(sort, key, col?.firstDir ?? (col?.numeric ? "desc" : "asc")));
|
|
4444
|
+
};
|
|
4445
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: cn("flex w-full flex-col overflow-hidden rounded-card border border-border-default bg-surface", className), children: [
|
|
4446
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex items-start justify-between gap-2 p-card-padding", children: [
|
|
4447
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "min-w-0", children: [
|
|
4448
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("h3", { id: titleId, className: "text-style-card-title", children: title }),
|
|
4449
|
+
subtitle && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: "mt-0.5 text-xs text-text-tertiary", children: subtitle })
|
|
4450
|
+
] }),
|
|
4451
|
+
action && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "shrink-0", children: action })
|
|
4452
|
+
] }),
|
|
4453
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: cn("overflow-x-auto", maxHeight && cn("overflow-y-auto", MAX_H[maxHeight])), children: /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
|
|
4454
|
+
"table",
|
|
4455
|
+
{
|
|
4456
|
+
"aria-labelledby": title ? titleId : void 0,
|
|
4457
|
+
"aria-label": title ? void 0 : rest["aria-label"],
|
|
4458
|
+
"aria-busy": loading || void 0,
|
|
4459
|
+
className: "w-full border-collapse text-left",
|
|
4460
|
+
children: [
|
|
4461
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("thead", { className: cn(maxHeight && "sticky top-0 z-10"), children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("tr", { className: "bg-subtle text-micro font-semibold uppercase tracking-wider text-text-secondary", children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
4462
|
+
"th",
|
|
4463
|
+
{
|
|
4464
|
+
scope: "col",
|
|
4465
|
+
"aria-sort": c.sortable ? ariaSortFor(sort, c.key) : void 0,
|
|
4466
|
+
className: cn("border-b border-border-default font-semibold", head, align(c), width(c)),
|
|
4467
|
+
children: c.sortable && onSortChange ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
4468
|
+
SortButton,
|
|
4469
|
+
{
|
|
4470
|
+
label: c.label,
|
|
4471
|
+
sortKey: c.key,
|
|
4472
|
+
align: c.numeric ? "right" : "left",
|
|
4473
|
+
sort: sortProp(sort),
|
|
4474
|
+
onSort
|
|
4475
|
+
}
|
|
4476
|
+
) : c.label
|
|
4477
|
+
},
|
|
4478
|
+
c.key
|
|
4479
|
+
)) }) }),
|
|
4480
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("tbody", { className: "text-dense text-text-primary", children: loading ? Array.from({ length: loadingRows }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("tr", { "aria-hidden": "true", className: "[&:last-child>td]:border-b-0", children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("td", { className: cn("border-b border-border-default", pad, align(c)), children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
4481
|
+
"span",
|
|
4482
|
+
{
|
|
4483
|
+
className: cn(
|
|
4484
|
+
"inline-block h-3 animate-pulse rounded-full bg-subtle",
|
|
4485
|
+
c.numeric ? "w-12" : "w-2/3"
|
|
4486
|
+
)
|
|
4487
|
+
}
|
|
4488
|
+
) }, c.key)) }, i)) : rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("td", { colSpan: columns.length, children: empty ?? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(NoResultsEmptyState, {}) }) }) : rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("tr", { className: "hover:bg-subtle [&:last-child>td]:border-b-0", children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
4489
|
+
"td",
|
|
4490
|
+
{
|
|
4491
|
+
className: cn("border-b border-border-default", pad, align(c), c.numeric && "tabular-nums"),
|
|
4492
|
+
children: c.cell(row)
|
|
4493
|
+
},
|
|
4494
|
+
c.key
|
|
4495
|
+
)) }, rowKey(row))) })
|
|
4496
|
+
]
|
|
4497
|
+
}
|
|
4498
|
+
) }),
|
|
4499
|
+
footer && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "border-t border-border-default px-4 py-3", children: footer })
|
|
4500
|
+
] });
|
|
4501
|
+
}
|
|
4406
4502
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4407
4503
|
0 && (module.exports = {
|
|
4408
4504
|
AISpark,
|
|
@@ -4418,6 +4514,7 @@ TextField.displayName = "TextField";
|
|
|
4418
4514
|
ChipContent,
|
|
4419
4515
|
DEFAULT_SEARCH_MATCH,
|
|
4420
4516
|
DataScopeFilter,
|
|
4517
|
+
DataTable,
|
|
4421
4518
|
DateRangeFilter,
|
|
4422
4519
|
DateRangePicker,
|
|
4423
4520
|
Delta,
|