@molecule/app-comparison-row-react 1.0.0 → 1.0.1
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/README.md +116 -0
- package/package.json +14 -8
package/README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
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-04T01:50:22.230Z
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
# @molecule/app-comparison-row-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
|
+
Period-over-period stat comparison row.
|
|
16
|
+
|
|
17
|
+
Exports `<ComparisonRow>`.
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { ComparisonRow } from '@molecule/app-comparison-row-react'
|
|
23
|
+
|
|
24
|
+
;<ComparisonRow
|
|
25
|
+
label="Revenue"
|
|
26
|
+
current="$24,800"
|
|
27
|
+
previous="$21,300"
|
|
28
|
+
deltaPct={16.4}
|
|
29
|
+
periodLabel="vs. last month"
|
|
30
|
+
/>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Type
|
|
34
|
+
|
|
35
|
+
`feature`
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install @molecule/app-comparison-row-react @molecule/app-react @molecule/app-ui @molecule/app-ui-react react
|
|
41
|
+
npm install -D @types/react
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## API
|
|
45
|
+
|
|
46
|
+
### Interfaces
|
|
47
|
+
|
|
48
|
+
#### `ComparisonRowProps`
|
|
49
|
+
|
|
50
|
+
Props for {@link ComparisonRow}.
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
interface ComparisonRowProps {
|
|
54
|
+
/** Label for the metric (e.g. "Revenue"). */
|
|
55
|
+
label: ReactNode
|
|
56
|
+
/** Current period value (formatted). */
|
|
57
|
+
current: ReactNode
|
|
58
|
+
/** Previous period value (formatted). */
|
|
59
|
+
previous?: ReactNode
|
|
60
|
+
/** Numeric delta% — drives direction + color when present. */
|
|
61
|
+
deltaPct?: number
|
|
62
|
+
/** Custom delta formatter. */
|
|
63
|
+
formatDelta?: (deltaPct: number) => ReactNode
|
|
64
|
+
/** Optional sub-text ("vs. last week"). */
|
|
65
|
+
periodLabel?: ReactNode
|
|
66
|
+
/** Extra classes. */
|
|
67
|
+
className?: string
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Functions
|
|
72
|
+
|
|
73
|
+
#### `ComparisonRow(props)`
|
|
74
|
+
|
|
75
|
+
Period-over-period stat comparison row — current value, optional
|
|
76
|
+
previous value, and a coloured delta% chip. Used in dashboards,
|
|
77
|
+
report summaries, finance overviews.
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
function ComparisonRow({
|
|
81
|
+
label,
|
|
82
|
+
current,
|
|
83
|
+
previous,
|
|
84
|
+
deltaPct,
|
|
85
|
+
formatDelta,
|
|
86
|
+
periodLabel,
|
|
87
|
+
className,
|
|
88
|
+
}: ComparisonRowProps): JSX.Element
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
- `props` — Component props (see {@link ComparisonRowProps}).
|
|
92
|
+
|
|
93
|
+
## Injection Notes
|
|
94
|
+
|
|
95
|
+
### Requirements
|
|
96
|
+
|
|
97
|
+
Peer dependencies:
|
|
98
|
+
|
|
99
|
+
- `@molecule/app-react` ^1.0.1
|
|
100
|
+
- `@molecule/app-ui` ^1.0.1
|
|
101
|
+
- `@molecule/app-ui-react` ^1.0.1
|
|
102
|
+
- `react` ^18.0.0 || ^19.0.0
|
|
103
|
+
|
|
104
|
+
### Runtime Dependencies
|
|
105
|
+
|
|
106
|
+
- `@molecule/app-react`
|
|
107
|
+
- `@molecule/app-ui`
|
|
108
|
+
- `@molecule/app-ui-react`
|
|
109
|
+
- `react`
|
|
110
|
+
|
|
111
|
+
The delta chip colors by SIGN with fixed semantics: positive = green,
|
|
112
|
+
negative = red (hardcoded hexes, not theme tokens). There is no
|
|
113
|
+
"down-is-good" inversion — for metrics like churn or costs, negate
|
|
114
|
+
`deltaPct` (and restate the sign in `formatDelta`, which controls the text
|
|
115
|
+
only, never the color). `label` / `current` / `previous` / `periodLabel`
|
|
116
|
+
are consumer-provided ReactNodes — pass pre-formatted, translated values.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-comparison-row-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Period-over-period stat comparison (\"$X vs $Y\", with delta)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
|
-
"dist"
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
21
22
|
],
|
|
22
23
|
"keywords": [
|
|
23
24
|
"molecule",
|
|
@@ -25,16 +26,21 @@
|
|
|
25
26
|
"react"
|
|
26
27
|
],
|
|
27
28
|
"license": "Apache-2.0",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/molecule-dev/molecule.git",
|
|
32
|
+
"directory": "packages/app/features/comparison-row-react"
|
|
33
|
+
},
|
|
28
34
|
"peerDependencies": {
|
|
29
|
-
"@molecule/app-react": "^1.0.
|
|
30
|
-
"@molecule/app-ui": "^1.0.
|
|
31
|
-
"@molecule/app-ui-react": "^1.0.
|
|
35
|
+
"@molecule/app-react": "^1.0.1",
|
|
36
|
+
"@molecule/app-ui": "^1.0.1",
|
|
37
|
+
"@molecule/app-ui-react": "^1.0.1",
|
|
32
38
|
"react": "^18.0.0 || ^19.0.0"
|
|
33
39
|
},
|
|
34
40
|
"devDependencies": {
|
|
35
|
-
"@molecule/app-react": "1.0.
|
|
36
|
-
"@molecule/app-ui": "1.0.
|
|
37
|
-
"@molecule/app-ui-react": "1.0.
|
|
41
|
+
"@molecule/app-react": "1.0.1",
|
|
42
|
+
"@molecule/app-ui": "1.0.1",
|
|
43
|
+
"@molecule/app-ui-react": "1.0.1",
|
|
38
44
|
"@types/node": "26.1.2",
|
|
39
45
|
"@types/react": "19.2.17",
|
|
40
46
|
"@types/react-dom": "19.2.3",
|