@camstack/ui-library 1.2.95 → 1.2.97

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.
@@ -7,15 +7,11 @@
7
7
  * is not one of them. `DataTable` supports both; this module decides which, so
8
8
  * the choice is a pure, testable rule instead of per-page CSS.
9
9
  *
10
- * The default rule is column count. Below the card breakpoint a phone fits
11
- * roughly three readable columns; past that, a sideways scroll means the
12
- * operator reads a wide table through a slit and loses the row they started
13
- * on. Cards trade the column alignment (which nobody can use at that width
14
- * anyway) for every field of one row being readable at once.
10
+ * The default is a table that scrolls horizontally inside its own container.
11
+ * Cards exist as an explicit `mobileMode="cards"` opt-in. `auto` still
12
+ * applies a column-count rule for surfaces that want the old behaviour.
15
13
  *
16
- * Pass an explicit `mobileMode` to override per table — a wide table whose
17
- * value IS the side-by-side comparison (a schedule, a matrix) is better
18
- * scrolled than carded, and says so at its call site.
14
+ * Pass an explicit `mobileMode` to override per table.
19
15
  */
20
16
  /** Per-table override. `auto` applies the column-count rule below. */
21
17
  export type TableMobileMode = 'auto' | 'scroll' | 'cards';
@@ -10,7 +10,9 @@ export interface DataColumn<T> {
10
10
  readonly headerRender?: () => ReactNode;
11
11
  /** Cell horizontal alignment. Default: `left`. */
12
12
  readonly align?: 'left' | 'right' | 'center';
13
- /** Suppress text wrapping on header + cell. Default: header `true`, cell `false`. */
13
+ /** Suppress text wrapping on header + cell. Default: `true` — a cell that
14
+ * wraps is a row that has already lost its table. Pass `false` only for a
15
+ * column whose value is meant to wrap (a description, a blob). */
14
16
  readonly nowrap?: boolean;
15
17
  /** Cell renderer. Receives the row value. */
16
18
  readonly render: (row: T, rowIndex: number) => ReactNode;
@@ -58,10 +60,9 @@ export interface DataTableProps<T> {
58
60
  /** Per-row className resolver (e.g. status-coloured backgrounds). */
59
61
  readonly rowClassName?: (row: T, rowIndex: number) => string | undefined;
60
62
  /**
61
- * Narrow-viewport rendering. Default `auto` — cards from
62
- * `CARD_MODE_MIN_COLUMNS` columns up, rows below it. Pass `scroll` when the
63
- * point of the table is the side-by-side comparison, `cards` to force the
64
- * card list at any column count.
63
+ * Narrow-viewport rendering. Default `scroll` — the table stays a table and
64
+ * the wrapper scrolls sideways. Pass `cards` to force the card list,
65
+ * `auto` for the old column-count rule (`CARD_MODE_MIN_COLUMNS`).
65
66
  */
66
67
  readonly mobileMode?: TableMobileMode;
67
68
  /**
package/dist/index.cjs CHANGED
@@ -26327,11 +26327,12 @@ function ariaSortForColumn(sort, columnKey) {
26327
26327
  * `header` (e.g. for a sortable click affordance).
26328
26328
  *
26329
26329
  * ── Narrow viewports ──────────────────────────────────────────────────────
26330
- * Below the mobile breakpoint a table with `CARD_MODE_MIN_COLUMNS` columns or
26331
- * more re-renders as one card per row (label above value) instead of a
26332
- * sideways scroll through a slit. Narrower tables keep their rows — they fit,
26333
- * and aligned rows compare better than cards. `mobileMode` overrides per
26334
- * table; see `resolveTableLayout` for the rule and the reasoning.
26330
+ * The table stays a table. The wrapper is `overflow-x-auto`, so a phone
26331
+ * scrolls the columns sideways INSIDE the table — the page body never moves
26332
+ * sideways, and the cells stay one line (`whitespace-nowrap`). That is the
26333
+ * default (`mobileMode="scroll"`). Cards are opt-in via `mobileMode="cards"`;
26334
+ * `auto` still applies the old column-count rule for a surface that wants it.
26335
+ * See `resolveTableLayout`.
26335
26336
  *
26336
26337
  * ── Scrolling the BODY, not the page ──────────────────────────────────────
26337
26338
  * `maxBodyHeight` caps the table and scrolls its rows INSIDE the container
@@ -26356,7 +26357,7 @@ var ALIGN_CLASS = {
26356
26357
  right: "text-right",
26357
26358
  center: "text-center"
26358
26359
  };
26359
- function DataTable({ columns, rows, rowKey, onRowClick, minWidthPx = 480, emptyMessage, className, bordered = true, rowClassName, mobileMode = "auto", maxBodyHeight, defaultSort }) {
26360
+ function DataTable({ columns, rows, rowKey, onRowClick, minWidthPx = 480, emptyMessage, className, bordered = true, rowClassName, mobileMode = "scroll", maxBodyHeight, defaultSort }) {
26360
26361
  const isNarrow = useIsMobile();
26361
26362
  const [sort, setSort] = (0, react$1.useState)(defaultSort ?? null);
26362
26363
  const layout = resolveTableLayout({
@@ -26434,7 +26435,7 @@ function DataTable({ columns, rows, rowKey, onRowClick, minWidthPx = 480, emptyM
26434
26435
  className: [interactive ? "cursor-pointer hover:bg-primary/5" : "hover:bg-primary/5", extra].filter(Boolean).join(" "),
26435
26436
  children: columns.map((col) => {
26436
26437
  const align = col.align ?? "left";
26437
- const nowrap = col.nowrap ?? false;
26438
+ const nowrap = col.nowrap ?? true;
26438
26439
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
26439
26440
  className: [
26440
26441
  "px-3 py-2 text-foreground border-b border-border",
package/dist/index.js CHANGED
@@ -26303,11 +26303,12 @@ function ariaSortForColumn(sort, columnKey) {
26303
26303
  * `header` (e.g. for a sortable click affordance).
26304
26304
  *
26305
26305
  * ── Narrow viewports ──────────────────────────────────────────────────────
26306
- * Below the mobile breakpoint a table with `CARD_MODE_MIN_COLUMNS` columns or
26307
- * more re-renders as one card per row (label above value) instead of a
26308
- * sideways scroll through a slit. Narrower tables keep their rows — they fit,
26309
- * and aligned rows compare better than cards. `mobileMode` overrides per
26310
- * table; see `resolveTableLayout` for the rule and the reasoning.
26306
+ * The table stays a table. The wrapper is `overflow-x-auto`, so a phone
26307
+ * scrolls the columns sideways INSIDE the table — the page body never moves
26308
+ * sideways, and the cells stay one line (`whitespace-nowrap`). That is the
26309
+ * default (`mobileMode="scroll"`). Cards are opt-in via `mobileMode="cards"`;
26310
+ * `auto` still applies the old column-count rule for a surface that wants it.
26311
+ * See `resolveTableLayout`.
26311
26312
  *
26312
26313
  * ── Scrolling the BODY, not the page ──────────────────────────────────────
26313
26314
  * `maxBodyHeight` caps the table and scrolls its rows INSIDE the container
@@ -26332,7 +26333,7 @@ var ALIGN_CLASS = {
26332
26333
  right: "text-right",
26333
26334
  center: "text-center"
26334
26335
  };
26335
- function DataTable({ columns, rows, rowKey, onRowClick, minWidthPx = 480, emptyMessage, className, bordered = true, rowClassName, mobileMode = "auto", maxBodyHeight, defaultSort }) {
26336
+ function DataTable({ columns, rows, rowKey, onRowClick, minWidthPx = 480, emptyMessage, className, bordered = true, rowClassName, mobileMode = "scroll", maxBodyHeight, defaultSort }) {
26336
26337
  const isNarrow = useIsMobile();
26337
26338
  const [sort, setSort] = useState(defaultSort ?? null);
26338
26339
  const layout = resolveTableLayout({
@@ -26410,7 +26411,7 @@ function DataTable({ columns, rows, rowKey, onRowClick, minWidthPx = 480, emptyM
26410
26411
  className: [interactive ? "cursor-pointer hover:bg-primary/5" : "hover:bg-primary/5", extra].filter(Boolean).join(" "),
26411
26412
  children: columns.map((col) => {
26412
26413
  const align = col.align ?? "left";
26413
- const nowrap = col.nowrap ?? false;
26414
+ const nowrap = col.nowrap ?? true;
26414
26415
  return /* @__PURE__ */ jsx("td", {
26415
26416
  className: [
26416
26417
  "px-3 py-2 text-foreground border-b border-border",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/ui-library",
3
- "version": "1.2.95",
3
+ "version": "1.2.97",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",