@mechane-ai/elements 0.42.0 → 0.43.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.
Files changed (44) hide show
  1. package/README.md +32 -32
  2. package/dist/catalog.json +89 -1
  3. package/dist/{categorical-values-B6lGI7BH.js → categorical-values-DzhbfZ5w.js} +2 -2
  4. package/dist/{chart-frame-D0enjyj9.js → chart-frame-9dQQNF3F.js} +73 -21
  5. package/dist/{chart-input-D4_Awave.js → chart-input-DT0STflx.js} +1 -1
  6. package/dist/{chart-navigation-D4-pdgpj.js → chart-navigation-BAbb5PV9.js} +56 -32
  7. package/dist/charts/cartesian.js +1696 -547
  8. package/dist/charts/distribution.js +4 -4
  9. package/dist/charts/graph.js +442 -75
  10. package/dist/charts/hierarchy.js +4 -4
  11. package/dist/charts/matrix.js +231 -62
  12. package/dist/charts/timeline.js +2 -2
  13. package/dist/charts.js +1 -1
  14. package/dist/label-spacing-BncjePGb.js +6 -0
  15. package/dist/packages/charts/src/cartesian/bar-chart.d.ts +15 -3
  16. package/dist/packages/charts/src/cartesian/bar-data.d.ts +43 -0
  17. package/dist/packages/charts/src/cartesian/bar-overlays.d.ts +32 -0
  18. package/dist/packages/charts/src/cartesian/bridge-chart.d.ts +29 -0
  19. package/dist/packages/charts/src/cartesian/bridge-data.d.ts +40 -0
  20. package/dist/packages/charts/src/cartesian/index.d.ts +7 -2
  21. package/dist/packages/charts/src/cartesian/reference-lines.d.ts +34 -0
  22. package/dist/packages/charts/src/cartesian/sparkline.d.ts +10 -1
  23. package/dist/packages/charts/src/cartesian/time-series-bands.d.ts +66 -0
  24. package/dist/packages/charts/src/cartesian/time-series-data.d.ts +11 -1
  25. package/dist/packages/charts/src/cartesian/time-series-overlays.d.ts +35 -0
  26. package/dist/packages/charts/src/cartesian/time-series.d.ts +6 -1
  27. package/dist/packages/charts/src/chart-inspection.d.ts +3 -1
  28. package/dist/packages/charts/src/chart-navigation.d.ts +3 -1
  29. package/dist/packages/charts/src/chart-series-marker.d.ts +8 -1
  30. package/dist/packages/charts/src/chart-surface.d.ts +2 -0
  31. package/dist/packages/charts/src/chart-theme.d.ts +26 -0
  32. package/dist/packages/charts/src/graph/flow-diagram.d.ts +26 -0
  33. package/dist/packages/charts/src/graph/flow-layout.d.ts +70 -0
  34. package/dist/packages/charts/src/graph/index.d.ts +2 -0
  35. package/dist/packages/charts/src/index.d.ts +1 -1
  36. package/dist/packages/charts/src/label-spacing.d.ts +15 -0
  37. package/dist/packages/charts/src/matrix/matrix-cells.d.ts +4 -0
  38. package/dist/packages/charts/src/matrix/matrix-strip.d.ts +20 -0
  39. package/dist/packages/charts/src/matrix/matrix-types.d.ts +21 -0
  40. package/dist/packages/charts/src/matrix/matrix.d.ts +8 -19
  41. package/dist/{plot-width-BQQS-mw9.js → plot-width-DzCmthQW.js} +28 -0
  42. package/dist/styles2.css +115 -0
  43. package/package.json +1 -1
  44. package/recipes/allocation-report.tsx +115 -0
package/dist/styles2.css CHANGED
@@ -1086,6 +1086,10 @@
1086
1086
  column-gap: var(--x1qq5i99);
1087
1087
  }
1088
1088
 
1089
+ .xuwhhnn {
1090
+ column-gap: var(--xjighox);
1091
+ }
1092
+
1089
1093
  .xa2sdi0 {
1090
1094
  column-gap: var(--xxhyxt);
1091
1095
  }
@@ -1182,6 +1186,10 @@
1182
1186
  fill: none;
1183
1187
  }
1184
1188
 
1189
+ .x19zyb68 {
1190
+ fill: var(--x-fill);
1191
+ }
1192
+
1185
1193
  .x1fytgo2 {
1186
1194
  fill: var(--x13kja51);
1187
1195
  }
@@ -1210,6 +1218,18 @@
1210
1218
  fill-opacity: .08;
1211
1219
  }
1212
1220
 
1221
+ .xd6etog {
1222
+ fill-opacity: .16;
1223
+ }
1224
+
1225
+ .x14kjgpu {
1226
+ fill-opacity: .34;
1227
+ }
1228
+
1229
+ .xif5ylx {
1230
+ fill-opacity: .62;
1231
+ }
1232
+
1213
1233
  .x1l7klhg {
1214
1234
  flex-basis: 100%;
1215
1235
  }
@@ -1374,6 +1394,10 @@
1374
1394
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
1375
1395
  }
1376
1396
 
1397
+ .xqketvx {
1398
+ grid-template-columns: var(--x-gridTemplateColumns);
1399
+ }
1400
+
1377
1401
  .x1eqwfih {
1378
1402
  grid-template-columns: var(--x1ud0cvw) minmax(0,1fr);
1379
1403
  }
@@ -1422,6 +1446,10 @@
1422
1446
  letter-spacing: var(--xgto76l);
1423
1447
  }
1424
1448
 
1449
+ .xo5v014 {
1450
+ line-height: 1;
1451
+ }
1452
+
1425
1453
  .xasj1m4 {
1426
1454
  line-height: calc(var(--x14tmdi9) - 2px);
1427
1455
  }
@@ -1490,10 +1518,18 @@
1490
1518
  object-fit: cover;
1491
1519
  }
1492
1520
 
1521
+ .xz5rk10 {
1522
+ opacity: .2;
1523
+ }
1524
+
1493
1525
  .xuzhngd {
1494
1526
  opacity: .3;
1495
1527
  }
1496
1528
 
1529
+ .xk8c4ds {
1530
+ opacity: .32;
1531
+ }
1532
+
1497
1533
  .x1hc1fzr {
1498
1534
  opacity: 1;
1499
1535
  }
@@ -1610,6 +1646,10 @@
1610
1646
  padding-inline-start: var(--xxhyxt);
1611
1647
  }
1612
1648
 
1649
+ .x1x0jnz8 {
1650
+ paint-order: stroke;
1651
+ }
1652
+
1613
1653
  .x67bb7w {
1614
1654
  pointer-events: auto;
1615
1655
  }
@@ -1654,6 +1694,10 @@
1654
1694
  row-gap: var(--x1xijsos);
1655
1695
  }
1656
1696
 
1697
+ .x1hm1d26 {
1698
+ row-gap: var(--xjighox);
1699
+ }
1700
+
1657
1701
  .xpb3s3w {
1658
1702
  row-gap: var(--xxhyxt);
1659
1703
  }
@@ -1670,6 +1714,10 @@
1670
1714
  stroke: currentColor;
1671
1715
  }
1672
1716
 
1717
+ .x6mkzkt {
1718
+ stroke: var(--x-stroke);
1719
+ }
1720
+
1673
1721
  .xaep1og {
1674
1722
  stroke: var(--x13kja51);
1675
1723
  }
@@ -1694,6 +1742,18 @@
1694
1742
  stroke: var(--xzqn2nu);
1695
1743
  }
1696
1744
 
1745
+ .xbw2l0c {
1746
+ stroke-dasharray: 2 2;
1747
+ }
1748
+
1749
+ .x1bpwu3k {
1750
+ stroke-dasharray: 2 3;
1751
+ }
1752
+
1753
+ .x1ypbokr {
1754
+ stroke-dasharray: 3 2;
1755
+ }
1756
+
1697
1757
  .x1ntoi03 {
1698
1758
  stroke-dasharray: 3 3;
1699
1759
  }
@@ -1702,6 +1762,26 @@
1702
1762
  stroke-dasharray: 4 3;
1703
1763
  }
1704
1764
 
1765
+ .x1dz65qj {
1766
+ stroke-dasharray: 5 4;
1767
+ }
1768
+
1769
+ .x5lxx2x {
1770
+ stroke-linecap: butt;
1771
+ }
1772
+
1773
+ .x1f6yumg {
1774
+ stroke-linejoin: round;
1775
+ }
1776
+
1777
+ .x1bsw5e1 {
1778
+ stroke-opacity: .45;
1779
+ }
1780
+
1781
+ .x1r6sdyr {
1782
+ stroke-width: 1.25px;
1783
+ }
1784
+
1705
1785
  .xhr4kjn {
1706
1786
  stroke-width: 1.5px;
1707
1787
  }
@@ -1714,6 +1794,10 @@
1714
1794
  stroke-width: 2px;
1715
1795
  }
1716
1796
 
1797
+ .xqjr0vm {
1798
+ stroke-width: 3px;
1799
+ }
1800
+
1717
1801
  .xzly4p3 {
1718
1802
  stroke-width: var(--xxx3t85);
1719
1803
  }
@@ -1758,6 +1842,10 @@
1758
1842
  text-decoration-line: underline;
1759
1843
  }
1760
1844
 
1845
+ .xbrixnn {
1846
+ text-overflow: clip;
1847
+ }
1848
+
1761
1849
  .xlyipyv {
1762
1850
  text-overflow: ellipsis;
1763
1851
  }
@@ -2414,6 +2502,10 @@
2414
2502
  height: 20px;
2415
2503
  }
2416
2504
 
2505
+ .x17rw0jw {
2506
+ height: 22px;
2507
+ }
2508
+
2417
2509
  .xxk0z11 {
2418
2510
  height: 24px;
2419
2511
  }
@@ -3415,6 +3507,10 @@
3415
3507
  color: var(--x169lqhw);
3416
3508
  }
3417
3509
 
3510
+ .xqd9x96.xqd9x96:hover {
3511
+ outline-color: var(--x169lqhw);
3512
+ }
3513
+
3418
3514
  .x5638nf.x5638nf:hover {
3419
3515
  text-decoration-line: underline;
3420
3516
  }
@@ -3477,6 +3573,10 @@
3477
3573
  }
3478
3574
 
3479
3575
  @media (pointer: coarse) {
3576
+ .x1ilzfib.x1ilzfib {
3577
+ height: 32px;
3578
+ }
3579
+
3480
3580
  .x992rv9.x992rv9 {
3481
3581
  height: var(--x6uufy4);
3482
3582
  }
@@ -3916,6 +4016,16 @@
3916
4016
  inherits: false
3917
4017
  }
3918
4018
 
4019
+ @property --x-fill {
4020
+ syntax: "*";
4021
+ inherits: false
4022
+ }
4023
+
4024
+ @property --x-gridTemplateColumns {
4025
+ syntax: "*";
4026
+ inherits: false
4027
+ }
4028
+
3919
4029
  @property --x-height {
3920
4030
  syntax: "*";
3921
4031
  inherits: false
@@ -3946,6 +4056,11 @@
3946
4056
  inherits: false
3947
4057
  }
3948
4058
 
4059
+ @property --x-stroke {
4060
+ syntax: "*";
4061
+ inherits: false
4062
+ }
4063
+
3949
4064
  @property --x-top {
3950
4065
  syntax: "*";
3951
4066
  inherits: false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mechane-ai/elements",
3
- "version": "0.42.0",
3
+ "version": "0.43.0",
4
4
  "description": "Elements by Mechane — React components for applications, AI interfaces, and analytical graphics",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -0,0 +1,115 @@
1
+ import { Stack, Text } from '@mechane-ai/elements';
2
+ import type { ChartTone } from '@mechane-ai/elements/charts';
3
+ import { BreakdownBar, BridgeChart } from '@mechane-ai/elements/charts/cartesian';
4
+ import type { BridgeStep, ChartReferenceLine } from '@mechane-ai/elements/charts/cartesian';
5
+ import { FlowDiagram } from '@mechane-ai/elements/charts/graph';
6
+ import type { FlowLink, FlowNode } from '@mechane-ai/elements/charts/graph';
7
+ import { PageContent, PageLayout } from '@mechane-ai/elements/layout';
8
+
9
+ type AllocationPart = { readonly id: string; readonly label: string; readonly amount: number };
10
+
11
+ type Commitment = AllocationPart & { readonly tone: ChartTone; readonly parts?: ReadonlyArray<AllocationPart> };
12
+
13
+ type AllocationProps = {
14
+ readonly title: string;
15
+ readonly headline: string;
16
+ readonly totalLabel: string;
17
+ readonly total: number;
18
+ readonly commitments: ReadonlyArray<Commitment>;
19
+ readonly remainderLabel: string;
20
+ readonly target?: ChartReferenceLine;
21
+ readonly explanation: 'bridge' | 'flow';
22
+ readonly formatValue: (value: number) => string;
23
+ };
24
+
25
+ const REMAINDER_ID = 'remainder';
26
+ const REMAINDER_TONE: ChartTone = 'series2';
27
+
28
+ /**
29
+ * Explain how one total divides among commitments and what remains, with the parts strip above one explanatory chart.
30
+ * Use a BridgeChart for the path from total to remainder, or a FlowDiagram when commitments divide again. Give each
31
+ * commitment one tone everywhere; the application computes amounts and writes the report's one-sentence headline.
32
+ */
33
+ export function AllocationReport({
34
+ title,
35
+ headline,
36
+ totalLabel,
37
+ total,
38
+ commitments,
39
+ remainderLabel,
40
+ target,
41
+ explanation,
42
+ formatValue,
43
+ }: AllocationProps) {
44
+ const remainder = total - commitments.reduce((sum, commitment) => sum + commitment.amount, 0);
45
+ const report = { summary: <Text>{headline}</Text> };
46
+
47
+ const steps: ReadonlyArray<BridgeStep> = [
48
+ { id: 'total', label: totalLabel, kind: 'start', value: total, tone: 'series1' },
49
+ ...commitments.map((commitment): BridgeStep => ({
50
+ id: commitment.id,
51
+ label: commitment.label,
52
+ kind: 'change',
53
+ value: -commitment.amount,
54
+ tone: commitment.tone,
55
+ })),
56
+ { id: REMAINDER_ID, label: remainderLabel, kind: 'total', tone: REMAINDER_TONE },
57
+ ];
58
+
59
+ const nodes: ReadonlyArray<FlowNode> = [
60
+ { id: 'total', label: totalLabel, tone: 'series1' },
61
+ ...commitments.flatMap((commitment) => [
62
+ { id: commitment.id, label: commitment.label, tone: commitment.tone },
63
+ ...(commitment.parts ?? []).map((part) => ({ id: part.id, label: part.label, tone: commitment.tone })),
64
+ ]),
65
+ { id: REMAINDER_ID, label: remainderLabel, tone: REMAINDER_TONE },
66
+ ];
67
+
68
+ const links: ReadonlyArray<FlowLink> = [
69
+ ...commitments.flatMap((commitment) => [
70
+ { id: `total-${commitment.id}`, sourceId: 'total', targetId: commitment.id, value: commitment.amount },
71
+ ...(commitment.parts ?? []).map((part) => ({
72
+ id: `${commitment.id}-${part.id}`,
73
+ sourceId: commitment.id,
74
+ targetId: part.id,
75
+ value: part.amount,
76
+ })),
77
+ ]),
78
+ { id: `total-${REMAINDER_ID}`, sourceId: 'total', targetId: REMAINDER_ID, value: remainder },
79
+ ];
80
+
81
+ return (
82
+ <PageLayout title={title} showNavigation={false}>
83
+ <PageContent>
84
+ <Stack>
85
+ <BreakdownBar
86
+ title={`${totalLabel}: ${formatValue(total)}`}
87
+ items={[
88
+ ...commitments.map(({ id, label, amount, tone }) => ({ id, label, value: amount, tone })),
89
+ { id: REMAINDER_ID, label: remainderLabel, value: remainder, tone: REMAINDER_TONE },
90
+ ]}
91
+ total={total}
92
+ formatValue={formatValue}
93
+ />
94
+ {explanation === 'bridge' ? (
95
+ <BridgeChart
96
+ title={`From ${totalLabel.toLowerCase()} to ${remainderLabel.toLowerCase()}`}
97
+ report={report}
98
+ steps={steps}
99
+ formatValue={formatValue}
100
+ referenceLines={target === undefined ? [] : [target]}
101
+ />
102
+ ) : (
103
+ <FlowDiagram
104
+ title={`Where ${totalLabel.toLowerCase()} goes`}
105
+ report={report}
106
+ nodes={nodes}
107
+ links={links}
108
+ formatValue={formatValue}
109
+ />
110
+ )}
111
+ </Stack>
112
+ </PageContent>
113
+ </PageLayout>
114
+ );
115
+ }