@molecule/app-transactions-table-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 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.
package/README.md ADDED
@@ -0,0 +1,202 @@
1
+ <!--
2
+ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
+ Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
+ Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
+ To change this document, edit the module-level JSDoc in src/index.ts.
6
+ Generated: 2026-08-04T00:41:27.360Z
7
+ -->
8
+
9
+ # @molecule/app-transactions-table-react
10
+
11
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
12
+ > It is written to be read by coding agents as much as by people, and is generated from this
13
+ > package's source — edit `src/index.ts` JSDoc, not this file.
14
+
15
+ `@molecule/app-transactions-table-react` — financial transactions
16
+ table primitive.
17
+
18
+ - Columns: Date / Description (with category icon tile) / Category
19
+ chip / Account / signed Amount (income tinted with the theme's
20
+ `primary` token, expense with `tertiary`).
21
+ - Loading skeleton, error state with retry, customisable empty state.
22
+ - Stateless about routing: pass `onRowClick` to navigate.
23
+ - Localisable: `formatAmount`, `formatDate`, `headers`, `retryLabel`
24
+ and `emptyState` override the en-US/USD/English defaults.
25
+
26
+ Generalised from the personal-finance TransactionsTable. Works for
27
+ any income/expense ledger: subscription billing rows, refund tables,
28
+ payout history, etc.
29
+
30
+ ## Quick Start
31
+
32
+ ```tsx
33
+ import {
34
+ TransactionsTable,
35
+ type CategoryStyle,
36
+ type TransactionRowData,
37
+ } from '@molecule/app-transactions-table-react'
38
+
39
+ const categoryStyles: Record<string, CategoryStyle> = {
40
+ groceries: { bg: '#d1fae5', color: '#059669', icon: 'shopping_cart' },
41
+ rent: { bg: '#ffe4e6', color: '#e11d48', icon: 'home' },
42
+ }
43
+
44
+ const rows: TransactionRowData[] = [
45
+ {
46
+ id: 't1',
47
+ date: '2026-03-01',
48
+ description: 'Groceries',
49
+ categoryKey: 'groceries',
50
+ categoryLabel: 'Groceries',
51
+ account: 'Checking',
52
+ amount: -54.2,
53
+ },
54
+ ]
55
+
56
+ <TransactionsTable
57
+ transactions={rows}
58
+ categoryStyles={categoryStyles}
59
+ onRowClick={(tx) => console.log('open', tx.id)}
60
+ />
61
+ ```
62
+
63
+ ## Type
64
+
65
+ `feature`
66
+
67
+ ## Installation
68
+
69
+ ```bash
70
+ npm install @molecule/app-transactions-table-react @molecule/app-react @molecule/app-ui @molecule/app-ui-react react
71
+ npm install -D @types/react
72
+ ```
73
+
74
+ ## API
75
+
76
+ ### Interfaces
77
+
78
+ #### `CategoryStyle`
79
+
80
+ Visual treatment for a particular category key.
81
+
82
+ ```typescript
83
+ interface CategoryStyle {
84
+ bg: string
85
+ color: string
86
+ icon: string
87
+ }
88
+ ```
89
+
90
+ #### `TransactionRowData`
91
+
92
+ Per-row data. Stays minimal so the consumer can fold their domain shape in.
93
+
94
+ ```typescript
95
+ interface TransactionRowData {
96
+ id: string
97
+ date: string | Date
98
+ description: ReactNode
99
+ /** Category key (used for the icon + chip styling lookup). */
100
+ categoryKey: string
101
+ categoryLabel: ReactNode
102
+ /** Account name / id rendered in the Account column. */
103
+ account: ReactNode
104
+ /** Signed amount (positive = income, negative = expense) — used for the colour + sign. */
105
+ amount: number
106
+ /** Override sign detection (e.g. when `type` is the canonical signal). */
107
+ isIncome?: boolean
108
+ }
109
+ ```
110
+
111
+ #### `TransactionsTableProps`
112
+
113
+ Props for the {@link TransactionsTable} component.
114
+
115
+ ```typescript
116
+ interface TransactionsTableProps {
117
+ transactions: TransactionRowData[]
118
+ loading?: boolean
119
+ error?: ReactNode
120
+ onRetry?: () => void
121
+ retryLabel?: ReactNode
122
+ /** Map a category key (lowercased automatically) to a style; falls back to neutral grey. */
123
+ categoryStyles?: Record<string, CategoryStyle>
124
+ /** Localised currency formatter; defaults to en-US USD. */
125
+ formatAmount?: (amount: number) => string
126
+ /** Localised date formatter; defaults to "MMM d, yyyy". */
127
+ formatDate?: (date: string | Date) => string
128
+ /** Click handler for each row (typically navigates to a detail page). */
129
+ onRowClick?: (row: TransactionRowData) => void
130
+ /** Column header labels (pre-translated). */
131
+ headers?: {
132
+ date?: ReactNode
133
+ description?: ReactNode
134
+ category?: ReactNode
135
+ account?: ReactNode
136
+ amount?: ReactNode
137
+ }
138
+ /** Empty-state slot (rendered when transactions.length === 0). */
139
+ emptyState?: ReactNode
140
+ /** Optional footer slot (typically a pagination control). */
141
+ footer?: ReactNode
142
+ className?: string
143
+ }
144
+ ```
145
+
146
+ ### Functions
147
+
148
+ #### `TransactionsTable(props)`
149
+
150
+ Renders a pageable financial transactions table with loading, error, and empty states.
151
+
152
+ ```typescript
153
+ function TransactionsTable({
154
+ transactions,
155
+ loading,
156
+ error,
157
+ onRetry,
158
+ retryLabel = 'Try again',
159
+ categoryStyles,
160
+ formatAmount = DEFAULT_AMOUNT_FORMAT,
161
+ formatDate = DEFAULT_DATE_FORMAT,
162
+ onRowClick,
163
+ headers,
164
+ emptyState,
165
+ footer,
166
+ className,
167
+ }: TransactionsTableProps): JSX.Element
168
+ ```
169
+
170
+ ## Injection Notes
171
+
172
+ ### Requirements
173
+
174
+ Peer dependencies:
175
+
176
+ - `@molecule/app-react` ^1.0.0
177
+ - `@molecule/app-ui` ^1.0.0
178
+ - `@molecule/app-ui-react` ^1.0.0
179
+ - `react` ^18.0.0 || ^19.0.0
180
+
181
+ ### Runtime Dependencies
182
+
183
+ - `@molecule/app-react`
184
+ - `@molecule/app-ui`
185
+ - `@molecule/app-ui-react`
186
+ - `react`
187
+
188
+ A custom `formatAmount` receives the SIGNED amount but must return the
189
+ absolute formatted value — the component prepends its own +/− sign (the
190
+ default already does `Math.abs`). Header labels, `retryLabel` and the
191
+ date/amount formats default to English/en-US/USD — pass translated
192
+ overrides (`headers`, `retryLabel`) in non-English apps; there is no
193
+ companion locale bond. `categoryStyles` keys are matched against the
194
+ LOWERCASED `categoryKey`; `icon` is a Material Symbols ligature name, so
195
+ the host must load that font. Styling mixes ClassMap with raw Tailwind +
196
+ Material-3 tokens (`bg-surface-container-lowest`, `font-headline`,
197
+ `text-slate-400/500`), so a Tailwind build source-scanning this package's
198
+ dist + an M3 theme are prerequisites, and the slate grays lean
199
+ light-theme. Props (documented on the exported `TransactionsTableProps`
200
+ interface): transactions, loading, error, onRetry, retryLabel,
201
+ categoryStyles, formatAmount, formatDate, onRowClick, headers,
202
+ emptyState, footer, className.
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Financial transactions table with date / description+icon / category
3
+ * chip / account / signed amount columns, plus loading skeleton, error
4
+ * state, and empty state.
5
+ *
6
+ * Stateless about routing — pass `onRowClick` to navigate, or omit it
7
+ * to render an inert table.
8
+ *
9
+ * @module
10
+ */
11
+ import type { JSX, ReactNode } from 'react';
12
+ import type { CategoryStyle, TransactionRowData } from './types.js';
13
+ /** Props for the {@link TransactionsTable} component. */
14
+ export interface TransactionsTableProps {
15
+ transactions: TransactionRowData[];
16
+ loading?: boolean;
17
+ error?: ReactNode;
18
+ onRetry?: () => void;
19
+ retryLabel?: ReactNode;
20
+ /** Map a category key (lowercased automatically) to a style; falls back to neutral grey. */
21
+ categoryStyles?: Record<string, CategoryStyle>;
22
+ /** Localised currency formatter; defaults to en-US USD. */
23
+ formatAmount?: (amount: number) => string;
24
+ /** Localised date formatter; defaults to "MMM d, yyyy". */
25
+ formatDate?: (date: string | Date) => string;
26
+ /** Click handler for each row (typically navigates to a detail page). */
27
+ onRowClick?: (row: TransactionRowData) => void;
28
+ /** Column header labels (pre-translated). */
29
+ headers?: {
30
+ date?: ReactNode;
31
+ description?: ReactNode;
32
+ category?: ReactNode;
33
+ account?: ReactNode;
34
+ amount?: ReactNode;
35
+ };
36
+ /** Empty-state slot (rendered when transactions.length === 0). */
37
+ emptyState?: ReactNode;
38
+ /** Optional footer slot (typically a pagination control). */
39
+ footer?: ReactNode;
40
+ className?: string;
41
+ }
42
+ /** Renders a pageable financial transactions table with loading, error, and empty states. */
43
+ export declare function TransactionsTable({ transactions, loading, error, onRetry, retryLabel, categoryStyles, formatAmount, formatDate, onRowClick, headers, emptyState, footer, className, }: TransactionsTableProps): JSX.Element;
44
+ export default TransactionsTable;
45
+ //# sourceMappingURL=TransactionsTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransactionsTable.d.ts","sourceRoot":"","sources":["../src/TransactionsTable.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAI3C,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEnE,yDAAyD;AACzD,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,kBAAkB,EAAE,CAAA;IAClC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,UAAU,CAAC,EAAE,SAAS,CAAA;IACtB,4FAA4F;IAC5F,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC9C,2DAA2D;IAC3D,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAA;IACzC,2DAA2D;IAC3D,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,KAAK,MAAM,CAAA;IAC5C,yEAAyE;IACzE,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,kBAAkB,KAAK,IAAI,CAAA;IAC9C,6CAA6C;IAC7C,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,SAAS,CAAA;QAChB,WAAW,CAAC,EAAE,SAAS,CAAA;QACvB,QAAQ,CAAC,EAAE,SAAS,CAAA;QACpB,OAAO,CAAC,EAAE,SAAS,CAAA;QACnB,MAAM,CAAC,EAAE,SAAS,CAAA;KACnB,CAAA;IACD,kEAAkE;IAClE,UAAU,CAAC,EAAE,SAAS,CAAA;IACtB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAgBD,6FAA6F;AAC7F,wBAAgB,iBAAiB,CAAC,EAChC,YAAY,EACZ,OAAO,EACP,KAAK,EACL,OAAO,EACP,UAAwB,EACxB,cAAc,EACd,YAAoC,EACpC,UAAgC,EAChC,UAAU,EACV,OAAO,EACP,UAAU,EACV,MAAM,EACN,SAAS,GACV,EAAE,sBAAsB,GAAG,GAAG,CAAC,OAAO,CA4MtC;AAED,eAAe,iBAAiB,CAAA"}
@@ -0,0 +1,43 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { getClassMap } from '@molecule/app-ui';
3
+ const NEUTRAL_STYLE = { bg: '#f3f4f6', color: '#374151', icon: 'receipt' };
4
+ const DEFAULT_AMOUNT_FORMAT = (n) => new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(Math.abs(n));
5
+ const DEFAULT_DATE_FORMAT = (d) => {
6
+ if (!d)
7
+ return '';
8
+ return new Date(d).toLocaleDateString('en-US', {
9
+ month: 'short',
10
+ day: 'numeric',
11
+ year: 'numeric',
12
+ });
13
+ };
14
+ /** Renders a pageable financial transactions table with loading, error, and empty states. */
15
+ export function TransactionsTable({ transactions, loading, error, onRetry, retryLabel = 'Try again', categoryStyles, formatAmount = DEFAULT_AMOUNT_FORMAT, formatDate = DEFAULT_DATE_FORMAT, onRowClick, headers, emptyState, footer, className, }) {
16
+ const cm = getClassMap();
17
+ if (loading) {
18
+ return (_jsx("div", { className: cm.cn('bg-surface-container-lowest rounded-3xl overflow-hidden shadow-sm', cm.sp('p', 6), className), "data-mol-id": "transactions-table-loading", children: Array.from({ length: 6 }).map((_, i) => (_jsx("div", { "aria-hidden": "true", className: cm.cn('h-12 bg-surface-container-low rounded-lg animate-pulse', cm.sp('mb', 3)) }, i))) }));
19
+ }
20
+ if (error) {
21
+ return (_jsxs("div", { role: "alert", className: cm.cn('bg-surface-container-lowest rounded-3xl overflow-hidden shadow-sm', cm.sp('p', 10), cm.textCenter, className), "data-mol-id": "transactions-table-error", children: [_jsx("p", { className: cm.cn('text-tertiary', cm.textSize('sm'), cm.sp('mb', 3)), children: error }), onRetry ? (_jsx("button", { onClick: onRetry, className: cm.cn(cm.sp('px', 4), cm.sp('py', 2), cm.textSize('sm'), cm.fontWeight('bold'), 'bg-primary text-on-primary rounded-lg'), children: retryLabel })) : null] }));
22
+ }
23
+ if (transactions.length === 0 && emptyState) {
24
+ return (_jsx("div", { className: cm.cn('bg-surface-container-lowest rounded-3xl overflow-hidden shadow-sm', cm.sp('p', 12), cm.textCenter, cm.stack(4), className), "data-mol-id": "transactions-table-empty", children: emptyState }));
25
+ }
26
+ return (_jsx("div", { className: cm.cn('bg-surface-container-lowest rounded-3xl overflow-hidden shadow-sm', className), children: _jsxs("div", { className: cm.cn('overflow-x-auto'), children: [_jsxs("table", { className: cm.cn(cm.w('full'), 'text-left border-collapse'), children: [_jsx("thead", { children: _jsx("tr", { className: cm.cn('bg-surface-container-low/50 border-none'), children: [
27
+ { key: 'date', label: headers?.date ?? 'Date', right: false },
28
+ {
29
+ key: 'description',
30
+ label: headers?.description ?? 'Description',
31
+ right: false,
32
+ },
33
+ { key: 'category', label: headers?.category ?? 'Category', right: false },
34
+ { key: 'account', label: headers?.account ?? 'Account', right: false },
35
+ { key: 'amount', label: headers?.amount ?? 'Amount', right: true },
36
+ ].map((h) => (_jsx("th", { className: cm.cn(cm.sp('px', 6), cm.sp('py', 5), cm.textSize('xs'), cm.fontWeight('bold'), 'font-headline uppercase tracking-widest text-slate-400', h.right ? cm.textRight : ''), children: h.label }, h.key))) }) }), _jsx("tbody", { className: cm.cn('divide-y divide-transparent'), children: transactions.map((tx) => {
37
+ const catKey = tx.categoryKey.toLowerCase();
38
+ const catStyle = categoryStyles?.[catKey] ?? NEUTRAL_STYLE;
39
+ const isIncome = tx.isIncome ?? tx.amount >= 0;
40
+ return (_jsxs("tr", { "data-mol-id": "transactions-table-row", className: cm.cn(onRowClick ? cm.cursorPointer : '', 'group hover:bg-surface-container-low transition-colors duration-200'), onClick: onRowClick ? () => onRowClick(tx) : undefined, children: [_jsx("td", { className: cm.cn(cm.sp('px', 6), cm.sp('py', 5), cm.textSize('sm'), 'text-slate-500'), children: formatDate(tx.date) }), _jsx("td", { className: cm.cn(cm.sp('px', 6), cm.sp('py', 5)), children: _jsxs("div", { className: cm.cn(cm.flex({ align: 'center' }), 'gap-3'), children: [_jsx("div", { className: cm.cn(cm.w(10), cm.h(10), cm.roundedFull, cm.flex({ align: 'center', justify: 'center' })), style: { backgroundColor: catStyle.bg, color: catStyle.color }, children: _jsx("span", { className: cm.cn('material-symbols-outlined'), children: catStyle.icon }) }), _jsx("span", { className: cm.cn(cm.fontWeight('bold'), 'text-on-surface'), children: tx.description })] }) }), _jsx("td", { className: cm.cn(cm.sp('px', 6), cm.sp('py', 5)), children: _jsx("span", { className: cm.cn(cm.sp('px', 3), cm.sp('py', 1), cm.fontWeight('bold'), cm.roundedFull, 'text-[10px] uppercase tracking-wider'), style: { backgroundColor: catStyle.bg, color: catStyle.color }, children: tx.categoryLabel }) }), _jsx("td", { className: cm.cn(cm.sp('px', 6), cm.sp('py', 5), cm.textSize('sm'), 'text-slate-500 italic'), children: tx.account }), _jsxs("td", { className: cm.cn(cm.sp('px', 6), cm.sp('py', 5), cm.textRight, cm.fontWeight('bold'), 'font-headline', isIncome ? 'text-primary' : 'text-tertiary'), children: [isIncome ? '+' : '-', formatAmount(tx.amount)] })] }, tx.id));
41
+ }) })] }), footer ?? null] }) }));
42
+ }
43
+ export default TransactionsTable;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * `@molecule/app-transactions-table-react` — financial transactions
3
+ * table primitive.
4
+ *
5
+ * - Columns: Date / Description (with category icon tile) / Category
6
+ * chip / Account / signed Amount (income tinted with the theme's
7
+ * `primary` token, expense with `tertiary`).
8
+ * - Loading skeleton, error state with retry, customisable empty state.
9
+ * - Stateless about routing: pass `onRowClick` to navigate.
10
+ * - Localisable: `formatAmount`, `formatDate`, `headers`, `retryLabel`
11
+ * and `emptyState` override the en-US/USD/English defaults.
12
+ *
13
+ * Generalised from the personal-finance TransactionsTable. Works for
14
+ * any income/expense ledger: subscription billing rows, refund tables,
15
+ * payout history, etc.
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * import {
20
+ * TransactionsTable,
21
+ * type CategoryStyle,
22
+ * type TransactionRowData,
23
+ * } from '@molecule/app-transactions-table-react'
24
+ *
25
+ * const categoryStyles: Record<string, CategoryStyle> = {
26
+ * groceries: { bg: '#d1fae5', color: '#059669', icon: 'shopping_cart' },
27
+ * rent: { bg: '#ffe4e6', color: '#e11d48', icon: 'home' },
28
+ * }
29
+ *
30
+ * const rows: TransactionRowData[] = [
31
+ * {
32
+ * id: 't1',
33
+ * date: '2026-03-01',
34
+ * description: 'Groceries',
35
+ * categoryKey: 'groceries',
36
+ * categoryLabel: 'Groceries',
37
+ * account: 'Checking',
38
+ * amount: -54.2,
39
+ * },
40
+ * ]
41
+ *
42
+ * <TransactionsTable
43
+ * transactions={rows}
44
+ * categoryStyles={categoryStyles}
45
+ * onRowClick={(tx) => console.log('open', tx.id)}
46
+ * />
47
+ * ```
48
+ *
49
+ * @remarks
50
+ * A custom `formatAmount` receives the SIGNED amount but must return the
51
+ * absolute formatted value — the component prepends its own +/− sign (the
52
+ * default already does `Math.abs`). Header labels, `retryLabel` and the
53
+ * date/amount formats default to English/en-US/USD — pass translated
54
+ * overrides (`headers`, `retryLabel`) in non-English apps; there is no
55
+ * companion locale bond. `categoryStyles` keys are matched against the
56
+ * LOWERCASED `categoryKey`; `icon` is a Material Symbols ligature name, so
57
+ * the host must load that font. Styling mixes ClassMap with raw Tailwind +
58
+ * Material-3 tokens (`bg-surface-container-lowest`, `font-headline`,
59
+ * `text-slate-400/500`), so a Tailwind build source-scanning this package's
60
+ * dist + an M3 theme are prerequisites, and the slate grays lean
61
+ * light-theme. Props (documented on the exported `TransactionsTableProps`
62
+ * interface): transactions, loading, error, onRetry, retryLabel,
63
+ * categoryStyles, formatAmount, formatDate, onRowClick, headers,
64
+ * emptyState, footer, className.
65
+ *
66
+ * @module
67
+ */
68
+ export * from './TransactionsTable.js';
69
+ export * from './types.js';
70
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AAEH,cAAc,wBAAwB,CAAA;AACtC,cAAc,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,69 @@
1
+ /**
2
+ * `@molecule/app-transactions-table-react` — financial transactions
3
+ * table primitive.
4
+ *
5
+ * - Columns: Date / Description (with category icon tile) / Category
6
+ * chip / Account / signed Amount (income tinted with the theme's
7
+ * `primary` token, expense with `tertiary`).
8
+ * - Loading skeleton, error state with retry, customisable empty state.
9
+ * - Stateless about routing: pass `onRowClick` to navigate.
10
+ * - Localisable: `formatAmount`, `formatDate`, `headers`, `retryLabel`
11
+ * and `emptyState` override the en-US/USD/English defaults.
12
+ *
13
+ * Generalised from the personal-finance TransactionsTable. Works for
14
+ * any income/expense ledger: subscription billing rows, refund tables,
15
+ * payout history, etc.
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * import {
20
+ * TransactionsTable,
21
+ * type CategoryStyle,
22
+ * type TransactionRowData,
23
+ * } from '@molecule/app-transactions-table-react'
24
+ *
25
+ * const categoryStyles: Record<string, CategoryStyle> = {
26
+ * groceries: { bg: '#d1fae5', color: '#059669', icon: 'shopping_cart' },
27
+ * rent: { bg: '#ffe4e6', color: '#e11d48', icon: 'home' },
28
+ * }
29
+ *
30
+ * const rows: TransactionRowData[] = [
31
+ * {
32
+ * id: 't1',
33
+ * date: '2026-03-01',
34
+ * description: 'Groceries',
35
+ * categoryKey: 'groceries',
36
+ * categoryLabel: 'Groceries',
37
+ * account: 'Checking',
38
+ * amount: -54.2,
39
+ * },
40
+ * ]
41
+ *
42
+ * <TransactionsTable
43
+ * transactions={rows}
44
+ * categoryStyles={categoryStyles}
45
+ * onRowClick={(tx) => console.log('open', tx.id)}
46
+ * />
47
+ * ```
48
+ *
49
+ * @remarks
50
+ * A custom `formatAmount` receives the SIGNED amount but must return the
51
+ * absolute formatted value — the component prepends its own +/− sign (the
52
+ * default already does `Math.abs`). Header labels, `retryLabel` and the
53
+ * date/amount formats default to English/en-US/USD — pass translated
54
+ * overrides (`headers`, `retryLabel`) in non-English apps; there is no
55
+ * companion locale bond. `categoryStyles` keys are matched against the
56
+ * LOWERCASED `categoryKey`; `icon` is a Material Symbols ligature name, so
57
+ * the host must load that font. Styling mixes ClassMap with raw Tailwind +
58
+ * Material-3 tokens (`bg-surface-container-lowest`, `font-headline`,
59
+ * `text-slate-400/500`), so a Tailwind build source-scanning this package's
60
+ * dist + an M3 theme are prerequisites, and the slate grays lean
61
+ * light-theme. Props (documented on the exported `TransactionsTableProps`
62
+ * interface): transactions, loading, error, onRetry, retryLabel,
63
+ * categoryStyles, formatAmount, formatDate, onRowClick, headers,
64
+ * emptyState, footer, className.
65
+ *
66
+ * @module
67
+ */
68
+ export * from './TransactionsTable.js';
69
+ export * from './types.js';
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Types for the transactions table.
3
+ *
4
+ * @module
5
+ */
6
+ import type { ReactNode } from 'react';
7
+ /** Per-row data. Stays minimal so the consumer can fold their domain shape in. */
8
+ export interface TransactionRowData {
9
+ id: string;
10
+ date: string | Date;
11
+ description: ReactNode;
12
+ /** Category key (used for the icon + chip styling lookup). */
13
+ categoryKey: string;
14
+ categoryLabel: ReactNode;
15
+ /** Account name / id rendered in the Account column. */
16
+ account: ReactNode;
17
+ /** Signed amount (positive = income, negative = expense) — used for the colour + sign. */
18
+ amount: number;
19
+ /** Override sign detection (e.g. when `type` is the canonical signal). */
20
+ isIncome?: boolean;
21
+ }
22
+ /** Visual treatment for a particular category key. */
23
+ export interface CategoryStyle {
24
+ bg: string;
25
+ color: string;
26
+ icon: string;
27
+ }
28
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,kFAAkF;AAClF,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,WAAW,EAAE,SAAS,CAAA;IACtB,8DAA8D;IAC9D,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,SAAS,CAAA;IACxB,wDAAwD;IACxD,OAAO,EAAE,SAAS,CAAA;IAClB,0FAA0F;IAC1F,MAAM,EAAE,MAAM,CAAA;IACd,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,sDAAsD;AACtD,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;CACb"}
package/dist/types.js ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Types for the transactions table.
3
+ *
4
+ * @module
5
+ */
6
+ export {};
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@molecule/app-transactions-table-react",
3
+ "version": "1.0.0",
4
+ "description": "Financial transactions table: date / description+icon / category chip / account / signed amount columns. Loading skeleton, error state, empty state. Extracted from personal-finance TransactionsTable.",
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
+ "README.md"
22
+ ],
23
+ "keywords": [
24
+ "molecule",
25
+ "transactions",
26
+ "finance",
27
+ "ledger",
28
+ "react"
29
+ ],
30
+ "license": "Apache-2.0",
31
+ "peerDependencies": {
32
+ "@molecule/app-react": "^1.0.0",
33
+ "@molecule/app-ui": "^1.0.0",
34
+ "@molecule/app-ui-react": "^1.0.0",
35
+ "react": "^18.0.0 || ^19.0.0"
36
+ },
37
+ "devDependencies": {
38
+ "@molecule/app-react": "1.0.0",
39
+ "@molecule/app-ui": "1.0.0",
40
+ "@molecule/app-ui-react": "1.0.0",
41
+ "@types/node": "26.1.2",
42
+ "@types/react": "19.2.17",
43
+ "react": "19.2.8",
44
+ "typescript": "6.0.3",
45
+ "vitest": "4.1.10"
46
+ }
47
+ }