@openwarelabs/ui 0.12.1 → 0.13.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.
@@ -1,60 +1,4 @@
1
- import { type Key, type ReactNode } from "react";
2
- export interface TableColumn<Row> {
3
- /** Unique; also the row field shown when there's no `render`. */
4
- key: string;
5
- header: ReactNode;
6
- /** Numbers and amounts go at the end, so their digits line up.
7
- * @default "start" */
8
- align?: "start" | "center" | "end";
9
- /** A CSS width, e.g. 120 or "30%". */
10
- width?: number | string;
11
- /** Lets the person sort by this column. */
12
- sortable?: boolean;
13
- /** What the cell shows. Defaults to the row's field named by `key`. */
14
- render?(row: Row): ReactNode;
15
- /** The value sorted by, when it isn't the field itself. */
16
- sortValue?(row: Row): string | number;
17
- }
18
- export interface TableSort {
19
- key: string;
20
- direction: "ascending" | "descending";
21
- }
22
- export interface TableProps<Row> {
23
- columns: Array<TableColumn<Row>>;
24
- rows: Row[];
25
- /** A field name or function giving each row a unique key.
26
- * @default "id" */
27
- rowKey?: keyof Row | ((row: Row) => Key);
28
- /** Describes the table for screen readers; shown above it unless `hideCaption`. */
29
- caption?: ReactNode;
30
- /** @default false */
31
- hideCaption?: boolean;
32
- sort?: TableSort;
33
- defaultSort?: TableSort;
34
- onSortChange?(sort: TableSort): void;
35
- /** Sort the rows yourself (e.g. on a server) and only show the arrows.
36
- * @default false */
37
- manualSort?: boolean;
38
- /** Adds a checkbox column.
39
- * @default "none" */
40
- selectionMode?: "none" | "multiple";
41
- selectedKeys?: Key[];
42
- defaultSelectedKeys?: Key[];
43
- onSelectionChange?(keys: Key[]): void;
44
- /**
45
- * Names a row for its checkbox, read out as "Select …": the person, the file, the project. Defaults to the
46
- * first column's value when it's text or a number, else "row 3".
47
- */
48
- rowLabel?(row: Row): string;
49
- /** Shown in place of the rows when there are none, such as an EmptyState. */
50
- emptyContent?: ReactNode;
51
- /** `compact` rows are 36px; `comfortable` 44px.
52
- * @default "comfortable" */
53
- density?: "compact" | "comfortable";
54
- /** Keeps the header in view while the table scrolls; use with maxHeight. */
55
- stickyHeader?: boolean;
56
- maxHeight?: number | string;
57
- className?: string;
58
- }
59
- /** Rows of records with sortable columns and optional selection, in a bordered card. */
60
- export declare function Table<Row extends object>({ columns, rows, rowKey, caption, hideCaption, sort, defaultSort, onSortChange, manualSort, selectionMode, selectedKeys, defaultSelectedKeys, onSelectionChange, rowLabel, emptyContent, density, stickyHeader, maxHeight, className, }: TableProps<Row>): import("react").JSX.Element;
1
+ import type { TableProps } from "./Table.types.cjs";
2
+ export type { TableColumn, TableProps, TableSort } from "./Table.types.cjs";
3
+ /** Rows of records with sortable columns and optional selection: on a raised panel in a tray, or in a bordered card. */
4
+ export declare function Table<Row extends object>({ columns, rows, rowKey, caption, hideCaption, sort, defaultSort, onSortChange, manualSort, selectionMode, selectedKeys, defaultSelectedKeys, onSelectionChange, rowLabel, emptyContent, variant, density, stickyHeader, maxHeight, className, }: TableProps<Row>): import("react").JSX.Element;
@@ -1,60 +1,4 @@
1
- import { type Key, type ReactNode } from "react";
2
- export interface TableColumn<Row> {
3
- /** Unique; also the row field shown when there's no `render`. */
4
- key: string;
5
- header: ReactNode;
6
- /** Numbers and amounts go at the end, so their digits line up.
7
- * @default "start" */
8
- align?: "start" | "center" | "end";
9
- /** A CSS width, e.g. 120 or "30%". */
10
- width?: number | string;
11
- /** Lets the person sort by this column. */
12
- sortable?: boolean;
13
- /** What the cell shows. Defaults to the row's field named by `key`. */
14
- render?(row: Row): ReactNode;
15
- /** The value sorted by, when it isn't the field itself. */
16
- sortValue?(row: Row): string | number;
17
- }
18
- export interface TableSort {
19
- key: string;
20
- direction: "ascending" | "descending";
21
- }
22
- export interface TableProps<Row> {
23
- columns: Array<TableColumn<Row>>;
24
- rows: Row[];
25
- /** A field name or function giving each row a unique key.
26
- * @default "id" */
27
- rowKey?: keyof Row | ((row: Row) => Key);
28
- /** Describes the table for screen readers; shown above it unless `hideCaption`. */
29
- caption?: ReactNode;
30
- /** @default false */
31
- hideCaption?: boolean;
32
- sort?: TableSort;
33
- defaultSort?: TableSort;
34
- onSortChange?(sort: TableSort): void;
35
- /** Sort the rows yourself (e.g. on a server) and only show the arrows.
36
- * @default false */
37
- manualSort?: boolean;
38
- /** Adds a checkbox column.
39
- * @default "none" */
40
- selectionMode?: "none" | "multiple";
41
- selectedKeys?: Key[];
42
- defaultSelectedKeys?: Key[];
43
- onSelectionChange?(keys: Key[]): void;
44
- /**
45
- * Names a row for its checkbox, read out as "Select …": the person, the file, the project. Defaults to the
46
- * first column's value when it's text or a number, else "row 3".
47
- */
48
- rowLabel?(row: Row): string;
49
- /** Shown in place of the rows when there are none, such as an EmptyState. */
50
- emptyContent?: ReactNode;
51
- /** `compact` rows are 36px; `comfortable` 44px.
52
- * @default "comfortable" */
53
- density?: "compact" | "comfortable";
54
- /** Keeps the header in view while the table scrolls; use with maxHeight. */
55
- stickyHeader?: boolean;
56
- maxHeight?: number | string;
57
- className?: string;
58
- }
59
- /** Rows of records with sortable columns and optional selection, in a bordered card. */
60
- export declare function Table<Row extends object>({ columns, rows, rowKey, caption, hideCaption, sort, defaultSort, onSortChange, manualSort, selectionMode, selectedKeys, defaultSelectedKeys, onSelectionChange, rowLabel, emptyContent, density, stickyHeader, maxHeight, className, }: TableProps<Row>): import("react").JSX.Element;
1
+ import type { TableProps } from "./Table.types.js";
2
+ export type { TableColumn, TableProps, TableSort } from "./Table.types.js";
3
+ /** Rows of records with sortable columns and optional selection: on a raised panel in a tray, or in a bordered card. */
4
+ export declare function Table<Row extends object>({ columns, rows, rowKey, caption, hideCaption, sort, defaultSort, onSortChange, manualSort, selectionMode, selectedKeys, defaultSelectedKeys, onSelectionChange, rowLabel, emptyContent, variant, density, stickyHeader, maxHeight, className, }: TableProps<Row>): import("react").JSX.Element;
@@ -0,0 +1,64 @@
1
+ import type { Key, ReactNode } from "react";
2
+ export interface TableColumn<Row> {
3
+ /** Unique; also the row field shown when there's no `render`. */
4
+ key: string;
5
+ header: ReactNode;
6
+ /** Numbers and amounts go at the end, so their digits line up.
7
+ * @default "start" */
8
+ align?: "start" | "center" | "end";
9
+ /** A CSS width, e.g. 120 or "30%". */
10
+ width?: number | string;
11
+ /** Lets the person sort by this column. */
12
+ sortable?: boolean;
13
+ /** What the cell shows. Defaults to the row's field named by `key`. */
14
+ render?(row: Row): ReactNode;
15
+ /** The value sorted by, when it isn't the field itself. */
16
+ sortValue?(row: Row): string | number;
17
+ }
18
+ export interface TableSort {
19
+ key: string;
20
+ direction: "ascending" | "descending";
21
+ }
22
+ export interface TableProps<Row> {
23
+ columns: Array<TableColumn<Row>>;
24
+ rows: Row[];
25
+ /** A field name or function giving each row a unique key.
26
+ * @default "id" */
27
+ rowKey?: keyof Row | ((row: Row) => Key);
28
+ /** Describes the table for screen readers; shown above it unless `hideCaption`. */
29
+ caption?: ReactNode;
30
+ /** @default false */
31
+ hideCaption?: boolean;
32
+ sort?: TableSort;
33
+ defaultSort?: TableSort;
34
+ onSortChange?(sort: TableSort): void;
35
+ /** Sort the rows yourself (e.g. on a server) and only show the arrows.
36
+ * @default false */
37
+ manualSort?: boolean;
38
+ /** Adds a checkbox column.
39
+ * @default "none" */
40
+ selectionMode?: "none" | "multiple";
41
+ selectedKeys?: Key[];
42
+ defaultSelectedKeys?: Key[];
43
+ onSelectionChange?(keys: Key[]): void;
44
+ /**
45
+ * Names a row for its checkbox, read out as "Select …": the person, the file, the project. Defaults to the
46
+ * first column's value when it's text or a number, else "row 3".
47
+ */
48
+ rowLabel?(row: Row): string;
49
+ /** Shown in place of the rows when there are none, such as an EmptyState. */
50
+ emptyContent?: ReactNode;
51
+ /**
52
+ * `inset` sets the rows on a raised panel inside a tinted tray, with the header in the tray above them; `plain` is
53
+ * one bordered card with a shaded header row.
54
+ * @default "inset"
55
+ */
56
+ variant?: "inset" | "plain";
57
+ /** `compact` rows are 36px; `comfortable` 44px.
58
+ * @default "comfortable" */
59
+ density?: "compact" | "comfortable";
60
+ /** Keeps the header in view while the table scrolls; use with maxHeight. */
61
+ stickyHeader?: boolean;
62
+ maxHeight?: number | string;
63
+ className?: string;
64
+ }
@@ -0,0 +1,64 @@
1
+ import type { Key, ReactNode } from "react";
2
+ export interface TableColumn<Row> {
3
+ /** Unique; also the row field shown when there's no `render`. */
4
+ key: string;
5
+ header: ReactNode;
6
+ /** Numbers and amounts go at the end, so their digits line up.
7
+ * @default "start" */
8
+ align?: "start" | "center" | "end";
9
+ /** A CSS width, e.g. 120 or "30%". */
10
+ width?: number | string;
11
+ /** Lets the person sort by this column. */
12
+ sortable?: boolean;
13
+ /** What the cell shows. Defaults to the row's field named by `key`. */
14
+ render?(row: Row): ReactNode;
15
+ /** The value sorted by, when it isn't the field itself. */
16
+ sortValue?(row: Row): string | number;
17
+ }
18
+ export interface TableSort {
19
+ key: string;
20
+ direction: "ascending" | "descending";
21
+ }
22
+ export interface TableProps<Row> {
23
+ columns: Array<TableColumn<Row>>;
24
+ rows: Row[];
25
+ /** A field name or function giving each row a unique key.
26
+ * @default "id" */
27
+ rowKey?: keyof Row | ((row: Row) => Key);
28
+ /** Describes the table for screen readers; shown above it unless `hideCaption`. */
29
+ caption?: ReactNode;
30
+ /** @default false */
31
+ hideCaption?: boolean;
32
+ sort?: TableSort;
33
+ defaultSort?: TableSort;
34
+ onSortChange?(sort: TableSort): void;
35
+ /** Sort the rows yourself (e.g. on a server) and only show the arrows.
36
+ * @default false */
37
+ manualSort?: boolean;
38
+ /** Adds a checkbox column.
39
+ * @default "none" */
40
+ selectionMode?: "none" | "multiple";
41
+ selectedKeys?: Key[];
42
+ defaultSelectedKeys?: Key[];
43
+ onSelectionChange?(keys: Key[]): void;
44
+ /**
45
+ * Names a row for its checkbox, read out as "Select …": the person, the file, the project. Defaults to the
46
+ * first column's value when it's text or a number, else "row 3".
47
+ */
48
+ rowLabel?(row: Row): string;
49
+ /** Shown in place of the rows when there are none, such as an EmptyState. */
50
+ emptyContent?: ReactNode;
51
+ /**
52
+ * `inset` sets the rows on a raised panel inside a tinted tray, with the header in the tray above them; `plain` is
53
+ * one bordered card with a shaded header row.
54
+ * @default "inset"
55
+ */
56
+ variant?: "inset" | "plain";
57
+ /** `compact` rows are 36px; `comfortable` 44px.
58
+ * @default "comfortable" */
59
+ density?: "compact" | "comfortable";
60
+ /** Keeps the header in view while the table scrolls; use with maxHeight. */
61
+ stickyHeader?: boolean;
62
+ maxHeight?: number | string;
63
+ className?: string;
64
+ }
@@ -5720,6 +5720,66 @@
5720
5720
  text-align: center;
5721
5721
  }
5722
5722
 
5723
+ /* Inset: the rows on a raised panel inside a tinted tray, the header in the tray above them. The tray's corners are
5724
+ the panel's plus the 4px between them, so the two curves run parallel. */
5725
+ .ow-table-wrap--inset {
5726
+ --ow-table-gap: 4px;
5727
+ background: var(--ow-track);
5728
+ border-radius: calc(var(--ow-radius-container) + var(--ow-table-gap));
5729
+ padding: 0 var(--ow-table-gap) var(--ow-table-gap);
5730
+ }
5731
+
5732
+ .ow-table-wrap--inset .ow-table th {
5733
+ border-bottom: 0;
5734
+ background: var(--ow-track);
5735
+ }
5736
+
5737
+ .ow-table-wrap--inset .ow-table td {
5738
+ background: var(--ow-surface);
5739
+ }
5740
+
5741
+ .ow-table-wrap--inset .ow-table tbody tr:hover td {
5742
+ background: var(--ow-surface-muted);
5743
+ }
5744
+
5745
+ .ow-table-wrap--inset .ow-table__row--selected td,
5746
+ .ow-table-wrap--inset .ow-table__row--selected:hover td {
5747
+ background: var(--ow-primary-subtle);
5748
+ }
5749
+
5750
+ /* The panel's edge, drawn on its outer cells, since a table body can't have a border of its own. */
5751
+ .ow-table-wrap--inset .ow-table tbody tr td:first-child {
5752
+ border-left: 1px solid var(--ow-border);
5753
+ }
5754
+
5755
+ .ow-table-wrap--inset .ow-table tbody tr td:last-child {
5756
+ border-right: 1px solid var(--ow-border);
5757
+ }
5758
+
5759
+ .ow-table-wrap--inset .ow-table tbody tr:first-child td {
5760
+ border-top: 1px solid var(--ow-border);
5761
+ }
5762
+
5763
+ .ow-table-wrap--inset .ow-table tbody tr:last-child td {
5764
+ border-bottom: 1px solid var(--ow-border);
5765
+ }
5766
+
5767
+ .ow-table-wrap--inset .ow-table tbody tr:first-child td:first-child {
5768
+ border-top-left-radius: var(--ow-radius-container);
5769
+ }
5770
+
5771
+ .ow-table-wrap--inset .ow-table tbody tr:first-child td:last-child {
5772
+ border-top-right-radius: var(--ow-radius-container);
5773
+ }
5774
+
5775
+ .ow-table-wrap--inset .ow-table tbody tr:last-child td:first-child {
5776
+ border-bottom-left-radius: var(--ow-radius-container);
5777
+ }
5778
+
5779
+ .ow-table-wrap--inset .ow-table tbody tr:last-child td:last-child {
5780
+ border-bottom-right-radius: var(--ow-radius-container);
5781
+ }
5782
+
5723
5783
  /* components/Stat/Stat.css */
5724
5784
  /* Stat: an overview card. A muted label, a big tabular number, a change and an optional trend line. */
5725
5785
  .ow-stat {
package/dist/index.cjs CHANGED
@@ -6164,6 +6164,7 @@ function Table({
6164
6164
  onSelectionChange,
6165
6165
  rowLabel,
6166
6166
  emptyContent = "Nothing here yet.",
6167
+ variant = "inset",
6167
6168
  density = "comfortable",
6168
6169
  stickyHeader = false,
6169
6170
  maxHeight,
@@ -6197,7 +6198,7 @@ function Table({
6197
6198
  return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6198
6199
  "div",
6199
6200
  {
6200
- className: cx("ow-table-wrap", stickyHeader && "ow-table-wrap--sticky", className),
6201
+ className: cx("ow-table-wrap", `ow-table-wrap--${variant}`, stickyHeader && "ow-table-wrap--sticky", className),
6201
6202
  style: maxHeight ? { maxHeight } : void 0,
6202
6203
  tabIndex: maxHeight ? 0 : void 0,
6203
6204
  children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("table", { className: cx("ow-table", `ow-table--${density}`), children: [