@molecule/app-comparison-row-react 4.0.1 → 4.0.2
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComparisonRow.d.ts","sourceRoot":"","sources":["../src/ComparisonRow.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"ComparisonRow.d.ts","sourceRoot":"","sources":["../src/ComparisonRow.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAK3C,uCAAuC;AACvC,MAAM,WAAW,kBAAkB;IACjC,6CAA6C;IAC7C,KAAK,EAAE,SAAS,CAAA;IAChB,wCAAwC;IACxC,OAAO,EAAE,SAAS,CAAA;IAClB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,8BAA8B;IAC9B,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,SAAS,CAAA;IAC7C,2CAA2C;IAC3C,WAAW,CAAC,EAAE,SAAS,CAAA;IACvB,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAUD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,WAAW,EACX,SAAS,GACV,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,CAwClC"}
|
package/dist/ComparisonRow.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { getClassMap } from '@molecule/app-ui';
|
|
3
3
|
const ARROW = (n) => (n > 0 ? '▲' : n < 0 ? '▼' : '–');
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* The semantic tone colouring the delta: the theme's success green for a
|
|
6
|
+
* rise, its error red for a fall, its secondary grey for no change.
|
|
7
|
+
*/
|
|
8
|
+
const TONE = (n) => (n > 0 ? 'success' : n < 0 ? 'error' : 'secondary');
|
|
5
9
|
/**
|
|
6
10
|
* Period-over-period stat comparison row — current value, optional
|
|
7
11
|
* previous value, and a coloured delta% chip. Used in dashboards,
|
|
@@ -10,5 +14,5 @@ const COLOR = (n) => (n > 0 ? '#22c55e' : n < 0 ? '#ef4444' : '#94a3b8');
|
|
|
10
14
|
*/
|
|
11
15
|
export function ComparisonRow({ label, current, previous, deltaPct, formatDelta, periodLabel, className, }) {
|
|
12
16
|
const cm = getClassMap();
|
|
13
|
-
return (_jsxs("div", { className: cm.cn(cm.flex({ align: 'baseline', justify: 'between', gap: 'md' }), className), children: [_jsxs("div", { className: cm.stack(0), children: [_jsx("span", { className: cm.cn(cm.textSize('xs'), cm.fontWeight('semibold')), children: label }), periodLabel && _jsx("span", { className: cm.textSize('xs'), children: periodLabel })] }), _jsxs("div", { className: cm.flex({ align: 'baseline', gap: 'sm' }), children: [_jsx("span", { className: cm.cn(cm.textSize('lg'), cm.fontWeight('bold')), children: current }), previous !== undefined && (_jsx("span", { className: cm.cn(cm.textSize('xs')), style: { textDecoration: 'line-through', opacity: 0.6 }, children: previous })), deltaPct !== undefined && (_jsx("span", { className: cm.cn(cm.textSize('xs'), cm.fontWeight('semibold')
|
|
17
|
+
return (_jsxs("div", { className: cm.cn(cm.flex({ align: 'baseline', justify: 'between', gap: 'md' }), className), children: [_jsxs("div", { className: cm.stack(0), children: [_jsx("span", { className: cm.cn(cm.textSize('xs'), cm.fontWeight('semibold')), children: label }), periodLabel && _jsx("span", { className: cm.textSize('xs'), children: periodLabel })] }), _jsxs("div", { className: cm.flex({ align: 'baseline', gap: 'sm' }), children: [_jsx("span", { className: cm.cn(cm.textSize('lg'), cm.fontWeight('bold')), children: current }), previous !== undefined && (_jsx("span", { className: cm.cn(cm.textSize('xs')), style: { textDecoration: 'line-through', opacity: 0.6 }, children: previous })), deltaPct !== undefined && (_jsx("span", { className: cm.cn(cm.textSize('xs'), cm.fontWeight('semibold'), cm.textTone(TONE(deltaPct))), children: formatDelta ? (formatDelta(deltaPct)) : (_jsxs(_Fragment, { children: [ARROW(deltaPct), " ", Math.abs(deltaPct).toFixed(1), "%"] })) }))] })] }));
|
|
14
18
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-comparison-row-react",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Period-over-period stat comparison (\" vs \", with delta)",
|
|
5
5
|
"homepage": "https://www.molecule.dev/packages/app-comparison-row-react",
|
|
6
6
|
"type": "module",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"react": "^18.0.0 || ^19.0.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@molecule/app-react": "4.7.
|
|
42
|
+
"@molecule/app-react": "4.7.2",
|
|
43
43
|
"@molecule/app-ui": "1.4.0",
|
|
44
|
-
"@molecule/app-ui-react": "4.1.
|
|
44
|
+
"@molecule/app-ui-react": "4.1.5",
|
|
45
45
|
"@types/node": "26.6.5",
|
|
46
46
|
"@types/react": "19.3.0",
|
|
47
47
|
"@types/react-dom": "19.3.0",
|