@molecule/app-data-table-ui-react 1.0.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/LICENSE +115 -0
- package/dist/DataTableCard.d.ts +56 -0
- package/dist/DataTableCard.d.ts.map +1 -0
- package/dist/DataTableCard.js +24 -0
- package/dist/RowWithActions.d.ts +22 -0
- package/dist/RowWithActions.d.ts.map +1 -0
- package/dist/RowWithActions.js +12 -0
- package/dist/TableEmpty.d.ts +17 -0
- package/dist/TableEmpty.d.ts.map +1 -0
- package/dist/TableEmpty.js +11 -0
- package/dist/TableFooter.d.ts +16 -0
- package/dist/TableFooter.d.ts.map +1 -0
- package/dist/TableFooter.js +10 -0
- package/dist/TableToolbar.d.ts +20 -0
- package/dist/TableToolbar.d.ts.map +1 -0
- package/dist/TableToolbar.js +12 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work.
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship.
|
|
43
|
+
|
|
44
|
+
"Contribution" shall mean any work of authorship, including the
|
|
45
|
+
original version of the Work and any modifications or additions
|
|
46
|
+
to that Work, that is intentionally submitted to the Licensor for
|
|
47
|
+
inclusion in the Work by the copyright owner or by an individual or
|
|
48
|
+
Legal Entity authorized to submit on behalf of the copyright owner.
|
|
49
|
+
|
|
50
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
51
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
52
|
+
subsequently incorporated within the Work.
|
|
53
|
+
|
|
54
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
55
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
56
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
57
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
58
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
59
|
+
Work and such Derivative Works in Source or Object form.
|
|
60
|
+
|
|
61
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
62
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
63
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
64
|
+
patent license to make, have made, use, offer to sell, sell, import,
|
|
65
|
+
and otherwise transfer the Work.
|
|
66
|
+
|
|
67
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
68
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
69
|
+
modifications, and in Source or Object form, provided that You
|
|
70
|
+
meet the following conditions:
|
|
71
|
+
|
|
72
|
+
(a) You must give any other recipients of the Work or
|
|
73
|
+
Derivative Works a copy of this License; and
|
|
74
|
+
|
|
75
|
+
(b) You must cause any modified files to carry prominent notices
|
|
76
|
+
stating that You changed the files; and
|
|
77
|
+
|
|
78
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
79
|
+
that You distribute, all copyright, patent, trademark, and
|
|
80
|
+
attribution notices from the Source form of the Work,
|
|
81
|
+
excluding those notices that do not pertain to any part of
|
|
82
|
+
the Derivative Works; and
|
|
83
|
+
|
|
84
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
85
|
+
distribution, then any Derivative Works that You distribute must
|
|
86
|
+
include a readable copy of the attribution notices contained
|
|
87
|
+
within such NOTICE file.
|
|
88
|
+
|
|
89
|
+
5. Submission of Contributions.
|
|
90
|
+
|
|
91
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
92
|
+
names, trademarks, service marks, or product names of the Licensor.
|
|
93
|
+
|
|
94
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
95
|
+
agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
|
|
96
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
|
|
97
|
+
|
|
98
|
+
8. Limitation of Liability. In no event and under no legal theory shall
|
|
99
|
+
any Contributor be liable to You for damages.
|
|
100
|
+
|
|
101
|
+
9. Accepting Warranty or Additional Liability.
|
|
102
|
+
|
|
103
|
+
Copyright 2026 Molecule Dev, Inc.
|
|
104
|
+
|
|
105
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
106
|
+
you may not use this file except in compliance with the License.
|
|
107
|
+
You may obtain a copy of the License at
|
|
108
|
+
|
|
109
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
110
|
+
|
|
111
|
+
Unless required by applicable law or agreed to in writing, software
|
|
112
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
113
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
114
|
+
See the License for the specific language governing permissions and
|
|
115
|
+
limitations under the License.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from 'react';
|
|
2
|
+
/** Column definition for a DataTableCard — specifies key, header, and cell renderer. */
|
|
3
|
+
export interface DataTableColumn<Row> {
|
|
4
|
+
/** Stable key for React. */
|
|
5
|
+
key: string;
|
|
6
|
+
/** Header label (usually `t('...')`). */
|
|
7
|
+
header: ReactNode;
|
|
8
|
+
/** Render the cell for this column from a row. */
|
|
9
|
+
cell: (row: Row) => ReactNode;
|
|
10
|
+
/** Optional extra `<th>` / `<td>` classes (e.g. `cm.textCenter`). */
|
|
11
|
+
cellClassName?: string;
|
|
12
|
+
headerClassName?: string;
|
|
13
|
+
}
|
|
14
|
+
/** Props for {@link DataTableCard}. */
|
|
15
|
+
export interface DataTableCardProps<Row> {
|
|
16
|
+
/** Optional title above the table chrome. */
|
|
17
|
+
title?: ReactNode;
|
|
18
|
+
/** Right-aligned action / "View all" / link in the title row. */
|
|
19
|
+
titleAction?: ReactNode;
|
|
20
|
+
/** Column definitions. */
|
|
21
|
+
columns: ReadonlyArray<DataTableColumn<Row>>;
|
|
22
|
+
/** Rows to render. Falls back to `emptyMessage` if empty and not loading. */
|
|
23
|
+
rows: ReadonlyArray<Row>;
|
|
24
|
+
/** Pull a stable React key from a row. */
|
|
25
|
+
rowKey: (row: Row) => string;
|
|
26
|
+
/** When true, renders 5 skeleton rows instead of `rows`. */
|
|
27
|
+
loading?: boolean;
|
|
28
|
+
/** Optional click handler per row. */
|
|
29
|
+
onRowClick?: (row: Row) => void;
|
|
30
|
+
/** Empty-state content shown inside the tbody when not loading + rows is empty. */
|
|
31
|
+
emptyMessage?: ReactNode;
|
|
32
|
+
/** Extra classes on the outer card. */
|
|
33
|
+
className?: string;
|
|
34
|
+
/** `data-mol-id` for AI-agent selectors. */
|
|
35
|
+
dataMolId?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Drop-in card-shaped data table matching the polished flagship pattern.
|
|
39
|
+
*
|
|
40
|
+
* Renders:
|
|
41
|
+
* 1. Optional title + action row
|
|
42
|
+
* 2. Card-wrapped table with:
|
|
43
|
+
* - `bg-surface-container-lowest rounded-xl overflow-hidden shadow-sm` outer
|
|
44
|
+
* - `bg-surface-container-low border-b border-outline-variant/10` thead
|
|
45
|
+
* - `text-[10px] font-black text-on-surface-variant uppercase tracking-widest` th
|
|
46
|
+
* - `divide-y divide-surface-container` tbody
|
|
47
|
+
* - `hover:bg-surface-container-low transition-colors` rows (when `onRowClick` provided)
|
|
48
|
+
* - 5-row pulsing skeleton when `loading`
|
|
49
|
+
* - Single full-width cell with `emptyMessage` when empty
|
|
50
|
+
*
|
|
51
|
+
* For complex per-column rendering, pass cells that compose
|
|
52
|
+
* `<StatusBadge>`, `<Avatar>`, etc.
|
|
53
|
+
* @param props - Component props (see {@link DataTableCardProps}).
|
|
54
|
+
*/
|
|
55
|
+
export declare function DataTableCard<Row>({ title, titleAction, columns, rows, rowKey, loading, onRowClick, emptyMessage, className, dataMolId, }: DataTableCardProps<Row>): JSX.Element;
|
|
56
|
+
//# sourceMappingURL=DataTableCard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataTableCard.d.ts","sourceRoot":"","sources":["../src/DataTableCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAI3C,wFAAwF;AACxF,MAAM,WAAW,eAAe,CAAC,GAAG;IAClC,4BAA4B;IAC5B,GAAG,EAAE,MAAM,CAAA;IACX,yCAAyC;IACzC,MAAM,EAAE,SAAS,CAAA;IACjB,kDAAkD;IAClD,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,SAAS,CAAA;IAC7B,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED,uCAAuC;AACvC,MAAM,WAAW,kBAAkB,CAAC,GAAG;IACrC,6CAA6C;IAC7C,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,iEAAiE;IACjE,WAAW,CAAC,EAAE,SAAS,CAAA;IACvB,0BAA0B;IAC1B,OAAO,EAAE,aAAa,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAA;IAC5C,6EAA6E;IAC7E,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,CAAA;IACxB,0CAA0C;IAC1C,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,CAAA;IAC5B,4DAA4D;IAC5D,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,sCAAsC;IACtC,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAA;IAC/B,mFAAmF;IACnF,YAAY,CAAC,EAAE,SAAS,CAAA;IACxB,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,EACjC,KAAK,EACL,WAAW,EACX,OAAO,EACP,IAAI,EACJ,MAAM,EACN,OAAe,EACf,UAAU,EACV,YAAY,EACZ,SAAS,EACT,SAAS,GACV,EAAE,kBAAkB,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,OAAO,CAqGvC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
3
|
+
/**
|
|
4
|
+
* Drop-in card-shaped data table matching the polished flagship pattern.
|
|
5
|
+
*
|
|
6
|
+
* Renders:
|
|
7
|
+
* 1. Optional title + action row
|
|
8
|
+
* 2. Card-wrapped table with:
|
|
9
|
+
* - `bg-surface-container-lowest rounded-xl overflow-hidden shadow-sm` outer
|
|
10
|
+
* - `bg-surface-container-low border-b border-outline-variant/10` thead
|
|
11
|
+
* - `text-[10px] font-black text-on-surface-variant uppercase tracking-widest` th
|
|
12
|
+
* - `divide-y divide-surface-container` tbody
|
|
13
|
+
* - `hover:bg-surface-container-low transition-colors` rows (when `onRowClick` provided)
|
|
14
|
+
* - 5-row pulsing skeleton when `loading`
|
|
15
|
+
* - Single full-width cell with `emptyMessage` when empty
|
|
16
|
+
*
|
|
17
|
+
* For complex per-column rendering, pass cells that compose
|
|
18
|
+
* `<StatusBadge>`, `<Avatar>`, etc.
|
|
19
|
+
* @param props - Component props (see {@link DataTableCardProps}).
|
|
20
|
+
*/
|
|
21
|
+
export function DataTableCard({ title, titleAction, columns, rows, rowKey, loading = false, onRowClick, emptyMessage, className, dataMolId, }) {
|
|
22
|
+
const cm = getClassMap();
|
|
23
|
+
return (_jsxs("section", { "data-mol-id": dataMolId, className: cm.cn(cm.stack(4), 'bg-surface-container-lowest rounded-xl overflow-hidden shadow-sm', className), children: [(title !== undefined || titleAction !== undefined) && (_jsxs("div", { className: cm.cn(cm.flex({ justify: 'between', align: 'center' }), cm.sp('px', 8), cm.sp('pt', 8)), children: [title !== undefined && (_jsx("h3", { className: cm.cn(cm.textSize('xl'), cm.fontWeight('bold'), 'text-on-surface'), children: title })), titleAction] })), _jsx("div", { className: "overflow-x-auto", children: _jsxs("table", { className: cm.cn(cm.w('full'), 'text-left border-collapse'), children: [_jsx("thead", { children: _jsx("tr", { className: "bg-surface-container-low border-b border-outline-variant/10", children: columns.map((col, idx) => (_jsx("th", { className: cm.cn(idx === 0 ? cm.sp('px', 8) : cm.sp('px', 4), cm.sp('py', 4), 'text-[10px] font-black text-on-surface-variant uppercase tracking-widest', col.headerClassName), children: col.header }, col.key))) }) }), _jsx("tbody", { className: "divide-y divide-surface-container", children: loading ? (Array.from({ length: 5 }).map((_, i) => (_jsx("tr", { "aria-hidden": "true", children: _jsx("td", { colSpan: columns.length, className: cm.cn(cm.sp('px', 8), cm.sp('py', 5)), children: _jsx("div", { className: cm.cn(cm.h(4), 'bg-surface-container-low rounded animate-pulse') }) }) }, `skeleton-${i}`)))) : rows.length === 0 ? (_jsx("tr", { children: _jsx("td", { colSpan: columns.length, className: cm.cn(cm.sp('px', 8), cm.sp('py', 12), cm.textCenter, 'text-on-surface-variant'), children: emptyMessage }) })) : (rows.map((row) => (_jsx("tr", { onClick: onRowClick ? () => onRowClick(row) : undefined, className: cm.cn(onRowClick ? cm.cursorPointer : '', 'hover:bg-surface-container-low transition-colors'), children: columns.map((col, idx) => (_jsx("td", { className: cm.cn(idx === 0 ? cm.sp('px', 8) : cm.sp('px', 4), cm.sp('py', 5), col.cellClassName), children: col.cell(row) }, col.key))) }, rowKey(row))))) })] }) })] }));
|
|
24
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from 'react';
|
|
2
|
+
/** Props for {@link RowWithActions}. */
|
|
3
|
+
export interface RowWithActionsProps {
|
|
4
|
+
/** Row cells (each wrapped in `<td>`). */
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
/** Action buttons/menu to render in the trailing "actions" cell. */
|
|
7
|
+
actions?: ReactNode;
|
|
8
|
+
/** Called when the row body is clicked (not the actions cell). */
|
|
9
|
+
onClick?: () => void;
|
|
10
|
+
/** Whether the row should render in a "selected" visual state. */
|
|
11
|
+
selected?: boolean;
|
|
12
|
+
/** Extra classes on the `<tr>`. */
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* `<tr>` wrapper that adds a trailing actions cell plus a click handler
|
|
17
|
+
* on the body. Useful for data tables where each row has a trailing
|
|
18
|
+
* ellipsis-menu or a row of action buttons.
|
|
19
|
+
* @param props - Component props (see {@link RowWithActionsProps}).
|
|
20
|
+
*/
|
|
21
|
+
export declare function RowWithActions({ children, actions, onClick, selected, className, }: RowWithActionsProps): JSX.Element;
|
|
22
|
+
//# sourceMappingURL=RowWithActions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RowWithActions.d.ts","sourceRoot":"","sources":["../src/RowWithActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAI3C,wCAAwC;AACxC,MAAM,WAAW,mBAAmB;IAClC,0CAA0C;IAC1C,QAAQ,EAAE,SAAS,CAAA;IACnB,oEAAoE;IACpE,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,mCAAmC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,OAAO,EACP,OAAO,EACP,QAAQ,EACR,SAAS,GACV,EAAE,mBAAmB,GAAG,GAAG,CAAC,OAAO,CAgBnC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
3
|
+
/**
|
|
4
|
+
* `<tr>` wrapper that adds a trailing actions cell plus a click handler
|
|
5
|
+
* on the body. Useful for data tables where each row has a trailing
|
|
6
|
+
* ellipsis-menu or a row of action buttons.
|
|
7
|
+
* @param props - Component props (see {@link RowWithActionsProps}).
|
|
8
|
+
*/
|
|
9
|
+
export function RowWithActions({ children, actions, onClick, selected, className, }) {
|
|
10
|
+
const cm = getClassMap();
|
|
11
|
+
return (_jsxs("tr", { onClick: onClick, "aria-selected": selected, className: cm.cn(onClick ? cm.cursorPointer : undefined, className), children: [children, actions !== undefined && (_jsx("td", { onClick: (e) => e.stopPropagation(), className: cm.cn(cm.textCenter), children: actions }))] }));
|
|
12
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from 'react';
|
|
2
|
+
/** Props for {@link TableEmpty}. */
|
|
3
|
+
export interface TableEmptyProps {
|
|
4
|
+
/** Number of columns to span (for colspan on the td). */
|
|
5
|
+
colSpan: number;
|
|
6
|
+
/** Empty-state content. */
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/** Extra classes on the cell. */
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Single full-width row shown when a `<Table>` has no data. Typically
|
|
13
|
+
* wraps `<EmptyState>` from `@molecule/app-empty-state-react`.
|
|
14
|
+
* @param props - Component props (see {@link TableEmptyProps}).
|
|
15
|
+
*/
|
|
16
|
+
export declare function TableEmpty({ colSpan, children, className }: TableEmptyProps): JSX.Element;
|
|
17
|
+
//# sourceMappingURL=TableEmpty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableEmpty.d.ts","sourceRoot":"","sources":["../src/TableEmpty.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAI3C,oCAAoC;AACpC,MAAM,WAAW,eAAe;IAC9B,yDAAyD;IACzD,OAAO,EAAE,MAAM,CAAA;IACf,2BAA2B;IAC3B,QAAQ,EAAE,SAAS,CAAA;IACnB,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,eAAe,GAAG,GAAG,CAAC,OAAO,CASzF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
3
|
+
/**
|
|
4
|
+
* Single full-width row shown when a `<Table>` has no data. Typically
|
|
5
|
+
* wraps `<EmptyState>` from `@molecule/app-empty-state-react`.
|
|
6
|
+
* @param props - Component props (see {@link TableEmptyProps}).
|
|
7
|
+
*/
|
|
8
|
+
export function TableEmpty({ colSpan, children, className }) {
|
|
9
|
+
const cm = getClassMap();
|
|
10
|
+
return (_jsx("tr", { children: _jsx("td", { colSpan: colSpan, className: cm.cn(cm.sp('py', 10), cm.textCenter, className), children: children }) }));
|
|
11
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from 'react';
|
|
2
|
+
/** Props for {@link TableFooter}. */
|
|
3
|
+
export interface TableFooterProps {
|
|
4
|
+
/** Left slot — typically a summary line ("5 rows selected"). */
|
|
5
|
+
left?: ReactNode;
|
|
6
|
+
/** Right slot — typically `<PaginationBar>`. */
|
|
7
|
+
right?: ReactNode;
|
|
8
|
+
/** Extra classes. */
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Footer bar rendered below an `<Table>`. Pass a pagination bar in `right`.
|
|
13
|
+
* @param props - Component props (see {@link TableFooterProps}).
|
|
14
|
+
*/
|
|
15
|
+
export declare function TableFooter({ left, right, className }: TableFooterProps): JSX.Element;
|
|
16
|
+
//# sourceMappingURL=TableFooter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableFooter.d.ts","sourceRoot":"","sources":["../src/TableFooter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAI3C,qCAAqC;AACrC,MAAM,WAAW,gBAAgB;IAC/B,gEAAgE;IAChE,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,gDAAgD;IAChD,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,CAcrF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
3
|
+
/**
|
|
4
|
+
* Footer bar rendered below an `<Table>`. Pass a pagination bar in `right`.
|
|
5
|
+
* @param props - Component props (see {@link TableFooterProps}).
|
|
6
|
+
*/
|
|
7
|
+
export function TableFooter({ left, right, className }) {
|
|
8
|
+
const cm = getClassMap();
|
|
9
|
+
return (_jsxs("div", { className: cm.cn(cm.flex({ justify: 'between', align: 'center', gap: 'sm', wrap: 'wrap' }), cm.sp('pt', 3), className), children: [_jsx("div", { children: left }), _jsx("div", { children: right })] }));
|
|
10
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from 'react';
|
|
2
|
+
/** Props for {@link TableToolbar}. */
|
|
3
|
+
export interface TableToolbarProps {
|
|
4
|
+
/** Left-aligned content — usually a title or a results count. */
|
|
5
|
+
left?: ReactNode;
|
|
6
|
+
/** Right-aligned actions — search input, filter button, export, etc. */
|
|
7
|
+
right?: ReactNode;
|
|
8
|
+
/** Optional full-width filter / chip row rendered below the main row. */
|
|
9
|
+
below?: ReactNode;
|
|
10
|
+
/** Extra classes. */
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Table top-chrome row with left/right slots and an optional bottom
|
|
15
|
+
* sub-row for active filter chips or tabs. Sits above an `<Table>`
|
|
16
|
+
* from `@molecule/app-ui-react`.
|
|
17
|
+
* @param props - Component props (see {@link TableToolbarProps}).
|
|
18
|
+
*/
|
|
19
|
+
export declare function TableToolbar({ left, right, below, className }: TableToolbarProps): JSX.Element;
|
|
20
|
+
//# sourceMappingURL=TableToolbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableToolbar.d.ts","sourceRoot":"","sources":["../src/TableToolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAI3C,sCAAsC;AACtC,MAAM,WAAW,iBAAiB;IAChC,iEAAiE;IACjE,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,wEAAwE;IACxE,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,yEAAyE;IACzE,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,iBAAiB,GAAG,GAAG,CAAC,OAAO,CAW9F"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
3
|
+
/**
|
|
4
|
+
* Table top-chrome row with left/right slots and an optional bottom
|
|
5
|
+
* sub-row for active filter chips or tabs. Sits above an `<Table>`
|
|
6
|
+
* from `@molecule/app-ui-react`.
|
|
7
|
+
* @param props - Component props (see {@link TableToolbarProps}).
|
|
8
|
+
*/
|
|
9
|
+
export function TableToolbar({ left, right, below, className }) {
|
|
10
|
+
const cm = getClassMap();
|
|
11
|
+
return (_jsxs("div", { className: cm.cn(cm.stack(2), className), children: [_jsxs("div", { className: cm.flex({ justify: 'between', align: 'center', gap: 'sm', wrap: 'wrap' }), children: [_jsx("div", { className: cm.flex({ align: 'center', gap: 'sm' }), children: left }), _jsx("div", { className: cm.flex({ align: 'center', gap: 'sm' }), children: right })] }), below] }));
|
|
12
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React data-table UI primitives (standalone — they render plain table
|
|
3
|
+
* elements and do not require `<Table>` from `@molecule/app-ui-react`).
|
|
4
|
+
*
|
|
5
|
+
* Exports:
|
|
6
|
+
* - `<DataTableCard>` — full polished-pattern data table (card wrapper +
|
|
7
|
+
* title + uppercase headers + divided rows + loading skeleton + empty
|
|
8
|
+
* state). Drop-in for the most common dashboard CRUD use case.
|
|
9
|
+
* - `<TableToolbar>` — top chrome with left/right slots + optional filter row.
|
|
10
|
+
* - `<TableEmpty>` — single full-width "no rows" cell for hand-rolled tables.
|
|
11
|
+
* - `<TableFooter>` — bottom bar (left summary + right pagination).
|
|
12
|
+
* - `<RowWithActions>` — `<tr>` wrapper with trailing actions cell and click handler.
|
|
13
|
+
*
|
|
14
|
+
* Use `DataTableCard` for new screens; use the row-level primitives to
|
|
15
|
+
* compose richer custom tables (group-by, expandable rows, etc.).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* import { DataTableCard } from '@molecule/app-data-table-ui-react'
|
|
20
|
+
*
|
|
21
|
+
* const columns = [
|
|
22
|
+
* { key: 'name', header: t('members.name', {}, { defaultValue: 'Name' }), cell: (row) => row.name },
|
|
23
|
+
* { key: 'email', header: t('members.email', {}, { defaultValue: 'Email' }), cell: (row) => row.email },
|
|
24
|
+
* ]
|
|
25
|
+
*
|
|
26
|
+
* <DataTableCard
|
|
27
|
+
* title={t('members.title', {}, { defaultValue: 'Team members' })}
|
|
28
|
+
* columns={columns}
|
|
29
|
+
* rows={members}
|
|
30
|
+
* rowKey={(row) => row.id}
|
|
31
|
+
* onRowClick={(row) => navigate(`/members/${row.id}`)}
|
|
32
|
+
* emptyMessage={t('members.empty', {}, { defaultValue: 'No members yet.' })}
|
|
33
|
+
* />
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* All text (`title`, column `header`s, `emptyMessage`) is consumer-provided —
|
|
38
|
+
* pass translated strings; there is no built-in copy and no locale bond.
|
|
39
|
+
* `DataTableCard`'s chrome uses Tailwind classes with Material-3 theme tokens
|
|
40
|
+
* (`bg-surface-container-lowest`, `divide-surface-container`,
|
|
41
|
+
* `text-on-surface-variant`, …) — the app's Tailwind theme must define those
|
|
42
|
+
* tokens (molecule's default Tailwind ClassMap bond does); with a
|
|
43
|
+
* non-Tailwind ClassMap the card surface, dividers, and skeleton styling
|
|
44
|
+
* drop out. `onRowClick` makes rows pointer-clickable only — add your own
|
|
45
|
+
* keyboard path (e.g. a link/button in a cell) where accessibility matters.
|
|
46
|
+
*
|
|
47
|
+
* @module
|
|
48
|
+
*/
|
|
49
|
+
export * from './DataTableCard.js';
|
|
50
|
+
export * from './RowWithActions.js';
|
|
51
|
+
export * from './TableEmpty.js';
|
|
52
|
+
export * from './TableFooter.js';
|
|
53
|
+
export * from './TableToolbar.js';
|
|
54
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React data-table UI primitives (standalone — they render plain table
|
|
3
|
+
* elements and do not require `<Table>` from `@molecule/app-ui-react`).
|
|
4
|
+
*
|
|
5
|
+
* Exports:
|
|
6
|
+
* - `<DataTableCard>` — full polished-pattern data table (card wrapper +
|
|
7
|
+
* title + uppercase headers + divided rows + loading skeleton + empty
|
|
8
|
+
* state). Drop-in for the most common dashboard CRUD use case.
|
|
9
|
+
* - `<TableToolbar>` — top chrome with left/right slots + optional filter row.
|
|
10
|
+
* - `<TableEmpty>` — single full-width "no rows" cell for hand-rolled tables.
|
|
11
|
+
* - `<TableFooter>` — bottom bar (left summary + right pagination).
|
|
12
|
+
* - `<RowWithActions>` — `<tr>` wrapper with trailing actions cell and click handler.
|
|
13
|
+
*
|
|
14
|
+
* Use `DataTableCard` for new screens; use the row-level primitives to
|
|
15
|
+
* compose richer custom tables (group-by, expandable rows, etc.).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* import { DataTableCard } from '@molecule/app-data-table-ui-react'
|
|
20
|
+
*
|
|
21
|
+
* const columns = [
|
|
22
|
+
* { key: 'name', header: t('members.name', {}, { defaultValue: 'Name' }), cell: (row) => row.name },
|
|
23
|
+
* { key: 'email', header: t('members.email', {}, { defaultValue: 'Email' }), cell: (row) => row.email },
|
|
24
|
+
* ]
|
|
25
|
+
*
|
|
26
|
+
* <DataTableCard
|
|
27
|
+
* title={t('members.title', {}, { defaultValue: 'Team members' })}
|
|
28
|
+
* columns={columns}
|
|
29
|
+
* rows={members}
|
|
30
|
+
* rowKey={(row) => row.id}
|
|
31
|
+
* onRowClick={(row) => navigate(`/members/${row.id}`)}
|
|
32
|
+
* emptyMessage={t('members.empty', {}, { defaultValue: 'No members yet.' })}
|
|
33
|
+
* />
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* All text (`title`, column `header`s, `emptyMessage`) is consumer-provided —
|
|
38
|
+
* pass translated strings; there is no built-in copy and no locale bond.
|
|
39
|
+
* `DataTableCard`'s chrome uses Tailwind classes with Material-3 theme tokens
|
|
40
|
+
* (`bg-surface-container-lowest`, `divide-surface-container`,
|
|
41
|
+
* `text-on-surface-variant`, …) — the app's Tailwind theme must define those
|
|
42
|
+
* tokens (molecule's default Tailwind ClassMap bond does); with a
|
|
43
|
+
* non-Tailwind ClassMap the card surface, dividers, and skeleton styling
|
|
44
|
+
* drop out. `onRowClick` makes rows pointer-clickable only — add your own
|
|
45
|
+
* keyboard path (e.g. a link/button in a cell) where accessibility matters.
|
|
46
|
+
*
|
|
47
|
+
* @module
|
|
48
|
+
*/
|
|
49
|
+
export * from './DataTableCard.js';
|
|
50
|
+
export * from './RowWithActions.js';
|
|
51
|
+
export * from './TableEmpty.js';
|
|
52
|
+
export * from './TableFooter.js';
|
|
53
|
+
export * from './TableToolbar.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@molecule/app-data-table-ui-react",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "React row-level primitives for @molecule/app-ui-react Table (toolbar, row-with-actions, empty)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"test": "vitest run",
|
|
11
|
+
"test:watch": "vitest"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"keywords": [
|
|
23
|
+
"molecule",
|
|
24
|
+
"data-table-ui",
|
|
25
|
+
"react"
|
|
26
|
+
],
|
|
27
|
+
"license": "Apache-2.0",
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@molecule/app-react": "^1.0.0",
|
|
30
|
+
"@molecule/app-ui": "^1.0.0",
|
|
31
|
+
"@molecule/app-ui-react": "^1.0.0",
|
|
32
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@molecule/app-react": "1.0.0",
|
|
36
|
+
"@molecule/app-ui": "1.0.0",
|
|
37
|
+
"@molecule/app-ui-react": "1.0.0",
|
|
38
|
+
"@types/node": "26.1.2",
|
|
39
|
+
"@types/react": "19.2.17",
|
|
40
|
+
"@types/react-dom": "19.2.3",
|
|
41
|
+
"react": "19.2.8",
|
|
42
|
+
"react-dom": "19.2.8",
|
|
43
|
+
"typescript": "6.0.3",
|
|
44
|
+
"vitest": "4.1.10"
|
|
45
|
+
}
|
|
46
|
+
}
|