@platned/ui 0.9.4 → 0.9.5

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.
@@ -429,6 +429,12 @@ interface DataTableProps<TData, TValue = unknown> {
429
429
  onRowSelectionChange?: (selection: RowSelectionState) => void;
430
430
  /** Passed to `useReactTable` last, for anything this API does not cover. */
431
431
  tableOptions?: Partial<TableOptions<TData>>;
432
+ /**
433
+ * Draw the table's own border and radius. Default `true`. Pass `false` to sit it flush inside
434
+ * a `Card`, under a `CardHeader` that carries the title, description and actions: the Card
435
+ * supplies the border, and the toolbar gains the Card's side padding. New in 0.9.5.
436
+ */
437
+ bordered?: boolean;
432
438
  /** Classes on the bordered wrapper. Layout only, e.g. margins. */
433
439
  className?: string;
434
440
  }
@@ -453,6 +459,6 @@ interface DataTableProps<TData, TValue = unknown> {
453
459
  * while loading, a polite announcement of the result count after a search, keyboard row
454
460
  * activation, and named selection checkboxes.
455
461
  */
456
- declare function DataTable<TData, TValue = unknown>({ columns, data, getRowId, label, caption, searchable, columnVisibility: showColumnMenu, pagination: paginated, pageSize, pageSizeOptions, enableRowSelection, onSelectionChange, getRowLabel, onRowClick, getRowHref, renderRowLink, getRowTone, getRowDimmed, loading, loadingRows, error, onRetry, empty, toolbar, footer, density, align, responsive, maxHeight, manual, state, onSortingChange, onGlobalFilterChange, onColumnFiltersChange, onPaginationChange, onColumnVisibilityChange, onRowSelectionChange, tableOptions, className, }: DataTableProps<TData, TValue>): react.JSX.Element;
462
+ declare function DataTable<TData, TValue = unknown>({ columns, data, getRowId, label, caption, searchable, columnVisibility: showColumnMenu, pagination: paginated, pageSize, pageSizeOptions, enableRowSelection, onSelectionChange, getRowLabel, onRowClick, getRowHref, renderRowLink, getRowTone, getRowDimmed, loading, loadingRows, error, onRetry, empty, toolbar, footer, density, align, responsive, maxHeight, manual, state, onSortingChange, onGlobalFilterChange, onColumnFiltersChange, onPaginationChange, onColumnVisibilityChange, onRowSelectionChange, tableOptions, bordered, className, }: DataTableProps<TData, TValue>): react.JSX.Element;
457
463
 
458
464
  export { TableCellProgress as A, type TableCellProgressProps as B, type ColumnMobileRole as C, DataTable as D, type TableCellProps as E, type TableCellSize as F, TableCellText as G, type TableCellTextProps as H, type TableDensity as I, TableFooter as J, TableHead as K, type TableHeadProps as L, TableHeader as M, type TableProps as N, TableRow as O, type ProgressBarTone as P, type TableRowProps as Q, type TableRowTone as R, SELECT_COLUMN_ID as S, Table as T, type TableSortDirection as U, createSelectColumn as V, type CreateSelectColumnOptions as a, type DataTableAlign as b, type DataTableColumnAlign as c, DataTableColumnHeader as d, type DataTableColumnHeaderProps as e, type DataTableDensity as f, type DataTableManual as g, DataTablePagination as h, type DataTablePaginationProps as i, type DataTableProps as j, type DataTableRowLinkProps as k, type DataTableSearchOptions as l, type DataTableState as m, DataTableViewOptions as n, type DataTableViewOptionsProps as o, ProgressBar as p, type ProgressBarProps as q, type ProgressBarSize as r, TableBody as s, TableCaption as t, type TableCaptionProps as u, TableCell as v, TableCellBadge as w, type TableCellBadgeProps as x, TableCellLeadText as y, type TableCellLeadTextProps as z };
@@ -2980,6 +2980,7 @@ function DataTable({
2980
2980
  onColumnVisibilityChange,
2981
2981
  onRowSelectionChange,
2982
2982
  tableOptions,
2983
+ bordered = true,
2983
2984
  className
2984
2985
  }) {
2985
2986
  if (!label && !caption) {
@@ -3048,6 +3049,7 @@ function DataTable({
3048
3049
  onSelectionChange(table.getSelectedRowModel().rows.map((row) => row.original));
3049
3050
  }, [rowSelection]);
3050
3051
  const [wrapRef, containerWidth] = useElementWidth();
3052
+ const captionId = (0, import_react24.useId)();
3051
3053
  const breakpoint = responsive === false ? 0 : typeof responsive === "object" ? responsive.breakpoint ?? DEFAULT_CARD_BREAKPOINT_PX : DEFAULT_CARD_BREAKPOINT_PX;
3052
3054
  const modeRef = (0, import_react24.useRef)("table");
3053
3055
  const mode = nextLayoutMode(modeRef.current, containerWidth, breakpoint);
@@ -3079,6 +3081,7 @@ function DataTable({
3079
3081
  table,
3080
3082
  label,
3081
3083
  caption,
3084
+ captionId,
3082
3085
  density,
3083
3086
  align,
3084
3087
  loading,
@@ -3093,7 +3096,7 @@ function DataTable({
3093
3096
  maxHeight
3094
3097
  };
3095
3098
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { "data-slot": "data-table", className: cn("relative flex flex-col gap-3", className), children: [
3096
- showToolbar && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
3099
+ showToolbar && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: cn("flex flex-wrap items-center gap-2", !bordered && "px-4 pt-3"), children: [
3097
3100
  search && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3098
3101
  SearchInput,
3099
3102
  {
@@ -3110,7 +3113,8 @@ function DataTable({
3110
3113
  showColumnMenu && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "ml-auto", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(DataTableViewOptions, { table }) })
3111
3114
  ] }),
3112
3115
  /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { role: "status", "aria-live": "polite", className: "sr-only", children: filtering && !loading ? `${resultCount} ${resultCount === 1 ? "result" : "results"}` : "" }),
3113
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { ref: wrapRef, className: "overflow-hidden rounded-xl border border-default bg-default", children: [
3116
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { ref: wrapRef, className: cn("overflow-hidden bg-default", bordered && "rounded-xl border border-default"), children: [
3117
+ mode === "cards" && caption && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { id: captionId, className: "px-4 pt-3 text-left text-body-sm text-default-secondary", children: caption }),
3114
3118
  mode === "cards" ? maxHeight ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CardScroll, { label, maxHeight, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CardList, { ...view }) }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CardList, { ...view }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(TableView, { ...view }),
3115
3119
  showPager && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "border-t border-default px-4 py-3", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(DataTablePagination, { table, pageSizeOptions }) }),
3116
3120
  footer && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "border-t border-default px-4 py-3", children: footer })
@@ -3353,6 +3357,8 @@ function CardScroll({ label, maxHeight, children }) {
3353
3357
  function CardList({
3354
3358
  table,
3355
3359
  label,
3360
+ caption,
3361
+ captionId,
3356
3362
  loading,
3357
3363
  loadingRows,
3358
3364
  placeholder,
@@ -3365,7 +3371,7 @@ function CardList({
3365
3371
  }) {
3366
3372
  if (placeholder) return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "px-4", children: placeholder });
3367
3373
  if (loading) {
3368
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("ul", { "aria-label": label, "aria-busy": "true", className: "divide-y divide-default", children: Array.from({ length: loadingRows }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("li", { className: "flex flex-col gap-3 p-4", children: [
3374
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("ul", { "aria-label": label, "aria-labelledby": !label && caption ? captionId : void 0, "aria-busy": "true", className: "divide-y divide-default", children: Array.from({ length: loadingRows }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("li", { className: "flex flex-col gap-3 p-4", children: [
3369
3375
  /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Skeleton, { className: "w-2/3" }),
3370
3376
  /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Skeleton, { className: "w-1/2" }),
3371
3377
  /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Skeleton, { className: "w-5/6" })
@@ -3388,6 +3394,7 @@ function CardList({
3388
3394
  "ul",
3389
3395
  {
3390
3396
  "aria-label": label,
3397
+ "aria-labelledby": !label && caption ? captionId : void 0,
3391
3398
  className: "divide-y divide-default [&_.truncate]:whitespace-normal [&_.truncate]:[overflow-wrap:anywhere]",
3392
3399
  children: table.getRowModel().rows.map((row) => {
3393
3400
  const cells = new Map(row.getVisibleCells().map((cell) => [cell.column.id, cell]));