@robosystems/report-components 0.1.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 (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +39 -0
  3. package/dist/adapters/cypher.d.ts +21 -0
  4. package/dist/adapters/cypher.d.ts.map +1 -0
  5. package/dist/adapters/cypher.js +9 -0
  6. package/dist/adapters/cypher.js.map +1 -0
  7. package/dist/adapters/index.d.ts +5 -0
  8. package/dist/adapters/index.d.ts.map +1 -0
  9. package/dist/adapters/index.js +3 -0
  10. package/dist/adapters/index.js.map +1 -0
  11. package/dist/adapters/trig.d.ts +7 -0
  12. package/dist/adapters/trig.d.ts.map +1 -0
  13. package/dist/adapters/trig.js +183 -0
  14. package/dist/adapters/trig.js.map +1 -0
  15. package/dist/adapters/types.d.ts +16 -0
  16. package/dist/adapters/types.d.ts.map +1 -0
  17. package/dist/adapters/types.js +2 -0
  18. package/dist/adapters/types.js.map +1 -0
  19. package/dist/components/FactInspector.d.ts +11 -0
  20. package/dist/components/FactInspector.d.ts.map +1 -0
  21. package/dist/components/FactInspector.js +79 -0
  22. package/dist/components/FactInspector.js.map +1 -0
  23. package/dist/components/ReportView.d.ts +9 -0
  24. package/dist/components/ReportView.d.ts.map +1 -0
  25. package/dist/components/ReportView.js +51 -0
  26. package/dist/components/ReportView.js.map +1 -0
  27. package/dist/components/StatementTable.d.ts +15 -0
  28. package/dist/components/StatementTable.d.ts.map +1 -0
  29. package/dist/components/StatementTable.js +86 -0
  30. package/dist/components/StatementTable.js.map +1 -0
  31. package/dist/constants.d.ts +71 -0
  32. package/dist/constants.d.ts.map +1 -0
  33. package/dist/constants.js +115 -0
  34. package/dist/constants.js.map +1 -0
  35. package/dist/format.d.ts +17 -0
  36. package/dist/format.d.ts.map +1 -0
  37. package/dist/format.js +34 -0
  38. package/dist/format.js.map +1 -0
  39. package/dist/index.d.ts +26 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +24 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/model.d.ts +148 -0
  44. package/dist/model.d.ts.map +1 -0
  45. package/dist/model.js +15 -0
  46. package/dist/model.js.map +1 -0
  47. package/dist/project.d.ts +39 -0
  48. package/dist/project.d.ts.map +1 -0
  49. package/dist/project.js +201 -0
  50. package/dist/project.js.map +1 -0
  51. package/package.json +90 -0
@@ -0,0 +1,86 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { formatMoney, formatPeriod } from '../format';
3
+ const styles = {
4
+ wrap: {
5
+ fontFamily: 'var(--rs-font-sans, ui-sans-serif, system-ui, sans-serif)',
6
+ color: 'var(--rs-text, #111827)',
7
+ marginBottom: '2.5rem',
8
+ },
9
+ heading: {
10
+ textAlign: 'center',
11
+ marginBottom: '1rem',
12
+ },
13
+ title: {
14
+ fontFamily: 'var(--rs-font-heading, var(--rs-font-sans, sans-serif))',
15
+ fontSize: '1.15rem',
16
+ fontWeight: 700,
17
+ letterSpacing: '0.02em',
18
+ margin: 0,
19
+ },
20
+ subtitle: {
21
+ fontSize: '0.85rem',
22
+ color: 'var(--rs-muted, #6b7280)',
23
+ marginTop: '0.25rem',
24
+ },
25
+ table: {
26
+ width: '100%',
27
+ borderCollapse: 'collapse',
28
+ fontSize: '0.875rem',
29
+ },
30
+ th: {
31
+ borderBottom: '2px solid var(--rs-border-strong, #9ca3af)',
32
+ padding: '0.5rem 0.75rem',
33
+ fontWeight: 600,
34
+ color: 'var(--rs-muted, #6b7280)',
35
+ fontSize: '0.8rem',
36
+ },
37
+ thConcept: { textAlign: 'left' },
38
+ thNum: { textAlign: 'right', whiteSpace: 'nowrap' },
39
+ labelCell: {
40
+ padding: '0.3rem 0.75rem',
41
+ whiteSpace: 'normal',
42
+ },
43
+ numCell: {
44
+ padding: '0.3rem 0.75rem',
45
+ textAlign: 'right',
46
+ whiteSpace: 'nowrap',
47
+ fontFamily: 'var(--rs-font-mono, ui-monospace, SFMono-Regular, monospace)',
48
+ fontVariantNumeric: 'tabular-nums',
49
+ },
50
+ };
51
+ export function StatementTable({ statement, onCellClick, currencySymbol = '$', selected = null, }) {
52
+ const { columns, rows } = statement;
53
+ const periodCaption = columns.length === 1 ? formatPeriod(columns[0].period) : null;
54
+ return (_jsxs("section", { style: styles.wrap, children: [_jsxs("header", { style: styles.heading, children: [_jsx("h3", { style: styles.title, children: statement.title }), statement.structureName ? (_jsx("div", { style: styles.subtitle, children: statement.structureName })) : null, periodCaption ? _jsx("div", { style: styles.subtitle, children: periodCaption }) : null] }), _jsxs("table", { style: styles.table, children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { style: { ...styles.th, ...styles.thConcept }, children: "Concept" }), columns.map((col) => (_jsx("th", { style: { ...styles.th, ...styles.thNum }, children: col.label }, col.key)))] }) }), _jsx("tbody", { children: rows.map((row) => {
55
+ const isGrandTotal = row.isSubtotal && row.depth === 0;
56
+ const allZeroOrNull = row.cells.every((c) => c.value === null || c.value === 0);
57
+ const rowStyle = {
58
+ backgroundColor: row.isSubtotal ? 'var(--rs-subtotal-bg, #f9fafb)' : undefined,
59
+ };
60
+ const labelStyle = {
61
+ ...styles.labelCell,
62
+ paddingLeft: `${row.depth * 20 + 12}px`,
63
+ fontWeight: row.isSubtotal ? 600 : 400,
64
+ color: !row.isSubtotal && allZeroOrNull ? 'var(--rs-muted, #9ca3af)' : undefined,
65
+ borderBottom: isGrandTotal ? '3px double var(--rs-text, #111827)' : undefined,
66
+ };
67
+ return (_jsxs("tr", { style: rowStyle, children: [_jsx("td", { style: labelStyle, title: row.element.qname, children: row.element.label }), row.cells.map((cell, i) => {
68
+ const isSelected = selected !== null &&
69
+ selected.elementId === row.element.id &&
70
+ selected.columnIndex === i;
71
+ const clickable = onCellClick && cell.fact !== null;
72
+ const numStyle = {
73
+ ...styles.numCell,
74
+ fontWeight: row.isSubtotal ? 600 : 400,
75
+ borderBottom: isGrandTotal ? '3px double var(--rs-text, #111827)' : undefined,
76
+ cursor: clickable ? 'pointer' : 'default',
77
+ backgroundColor: isSelected ? 'var(--rs-selected-bg, #dbeafe)' : undefined,
78
+ color: !row.isSubtotal && (cell.value === null || cell.value === 0)
79
+ ? 'var(--rs-muted, #9ca3af)'
80
+ : undefined,
81
+ };
82
+ return (_jsx("td", { style: numStyle, onClick: clickable ? () => onCellClick?.(row, i) : undefined, children: formatMoney(cell.value, { currencySymbol }) }, columns[i].key));
83
+ })] }, row.element.id));
84
+ }) })] })] }));
85
+ }
86
+ //# sourceMappingURL=StatementTable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StatementTable.js","sourceRoot":"","sources":["../../src/components/StatementTable.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAarD,MAAM,MAAM,GAAkC;IAC5C,IAAI,EAAE;QACJ,UAAU,EAAE,2DAA2D;QACvE,KAAK,EAAE,yBAAyB;QAChC,YAAY,EAAE,QAAQ;KACvB;IACD,OAAO,EAAE;QACP,SAAS,EAAE,QAAQ;QACnB,YAAY,EAAE,MAAM;KACrB;IACD,KAAK,EAAE;QACL,UAAU,EAAE,yDAAyD;QACrE,QAAQ,EAAE,SAAS;QACnB,UAAU,EAAE,GAAG;QACf,aAAa,EAAE,QAAQ;QACvB,MAAM,EAAE,CAAC;KACV;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE,SAAS;QACnB,KAAK,EAAE,0BAA0B;QACjC,SAAS,EAAE,SAAS;KACrB;IACD,KAAK,EAAE;QACL,KAAK,EAAE,MAAM;QACb,cAAc,EAAE,UAAU;QAC1B,QAAQ,EAAE,UAAU;KACrB;IACD,EAAE,EAAE;QACF,YAAY,EAAE,4CAA4C;QAC1D,OAAO,EAAE,gBAAgB;QACzB,UAAU,EAAE,GAAG;QACf,KAAK,EAAE,0BAA0B;QACjC,QAAQ,EAAE,QAAQ;KACnB;IACD,SAAS,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;IA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CACN,CAAA;wBACH,CAAC,CAAC,GACI,IACF,IACA,CACX,CAAA;AACH,CAAC"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * RDF vocabulary and display helpers shared across adapters and projection.
3
+ *
4
+ * A `holon.trig` mixes several vocabularies: `rs:` for structure, `skos:` for
5
+ * human labels, and the XBRL family (`xlink:` / `xbrli:` / `link:`) for the
6
+ * networks. These constants are the single source of truth for the full IRIs.
7
+ */
8
+ export declare const NS: {
9
+ readonly rdf: "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
10
+ readonly rs: "https://robosystems.ai/vocab/";
11
+ readonly rsgaap: "https://robosystems.ai/taxonomy/rs-gaap/v1/";
12
+ readonly skos: "http://www.w3.org/2004/02/skos/core#";
13
+ readonly xlink: "http://www.w3.org/1999/xlink#";
14
+ readonly xbrli: "http://www.xbrl.org/2003/instance#";
15
+ readonly link: "http://www.xbrl.org/2003/linkbase#";
16
+ readonly iso4217: "http://www.xbrl.org/2003/iso4217#";
17
+ };
18
+ /** Frequently-referenced full IRIs, pre-concatenated for terseness. */
19
+ export declare const IRI: {
20
+ readonly type: string;
21
+ readonly Report: string;
22
+ readonly Fact: string;
23
+ readonly InformationBlock: string;
24
+ readonly Structure: string;
25
+ readonly Association: string;
26
+ readonly Element: string;
27
+ readonly Period: string;
28
+ readonly Unit: string;
29
+ readonly Entity: string;
30
+ readonly element: string;
31
+ readonly period: string;
32
+ readonly unit: string;
33
+ readonly entity: string;
34
+ readonly factSet: string;
35
+ readonly numericValue: string;
36
+ readonly decimals: string;
37
+ readonly blockType: string;
38
+ readonly associationType: string;
39
+ readonly hasAssociation: string;
40
+ readonly roleUri: string;
41
+ readonly structureName: string;
42
+ readonly abstract: string;
43
+ readonly monetary: string;
44
+ readonly legalName: string;
45
+ readonly country: string;
46
+ readonly prefLabel: string;
47
+ readonly from: string;
48
+ readonly to: string;
49
+ readonly role: string;
50
+ readonly instant: string;
51
+ readonly startDate: string;
52
+ readonly endDate: string;
53
+ readonly periodType: string;
54
+ readonly balance: string;
55
+ readonly measure: string;
56
+ readonly order: string;
57
+ readonly weight: string;
58
+ };
59
+ /** Compact a concept IRI to `prefix:Local` (e.g. `rs-gaap:Assets`). */
60
+ export declare function qname(iri: string): string;
61
+ /**
62
+ * Readable concept name from a local name when no `skos:prefLabel` is present —
63
+ * splits CamelCase into words (`AssetsCurrent` → `Assets Current`). A graceful
64
+ * fallback for bundles that predate label emit.
65
+ */
66
+ export declare function humanize(iri: string): string;
67
+ /** Stable display order for the canonical statement blocks; others fall after. */
68
+ export declare const BLOCK_ORDER: Record<string, number>;
69
+ /** Friendly section headings keyed by block type. */
70
+ export declare const BLOCK_TITLES: Record<string, string>;
71
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,EAAE;;;;;;;;;CASL,CAAA;AAEV,uEAAuE;AACvE,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6CN,CAAA;AAmBV,uEAAuE;AACvE,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CASzC;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED,kFAAkF;AAClF,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAK9C,CAAA;AAED,qDAAqD;AACrD,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAK/C,CAAA"}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * RDF vocabulary and display helpers shared across adapters and projection.
3
+ *
4
+ * A `holon.trig` mixes several vocabularies: `rs:` for structure, `skos:` for
5
+ * human labels, and the XBRL family (`xlink:` / `xbrli:` / `link:`) for the
6
+ * networks. These constants are the single source of truth for the full IRIs.
7
+ */
8
+ export const NS = {
9
+ rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
10
+ rs: 'https://robosystems.ai/vocab/',
11
+ rsgaap: 'https://robosystems.ai/taxonomy/rs-gaap/v1/',
12
+ skos: 'http://www.w3.org/2004/02/skos/core#',
13
+ xlink: 'http://www.w3.org/1999/xlink#',
14
+ xbrli: 'http://www.xbrl.org/2003/instance#',
15
+ link: 'http://www.xbrl.org/2003/linkbase#',
16
+ iso4217: 'http://www.xbrl.org/2003/iso4217#',
17
+ };
18
+ /** Frequently-referenced full IRIs, pre-concatenated for terseness. */
19
+ export const IRI = {
20
+ type: NS.rdf + 'type',
21
+ // rs: classes
22
+ Report: NS.rs + 'Report',
23
+ Fact: NS.rs + 'Fact',
24
+ InformationBlock: NS.rs + 'InformationBlock',
25
+ Structure: NS.rs + 'Structure',
26
+ Association: NS.rs + 'Association',
27
+ Element: NS.rs + 'Element',
28
+ Period: NS.rs + 'Period',
29
+ Unit: NS.rs + 'Unit',
30
+ Entity: NS.rs + 'Entity',
31
+ // rs: predicates
32
+ element: NS.rs + 'element',
33
+ period: NS.rs + 'period',
34
+ unit: NS.rs + 'unit',
35
+ entity: NS.rs + 'entity',
36
+ factSet: NS.rs + 'factSet',
37
+ numericValue: NS.rs + 'numericValue',
38
+ decimals: NS.rs + 'decimals',
39
+ blockType: NS.rs + 'blockType',
40
+ associationType: NS.rs + 'associationType',
41
+ hasAssociation: NS.rs + 'hasAssociation',
42
+ roleUri: NS.rs + 'roleUri',
43
+ structureName: NS.rs + 'structureName',
44
+ abstract: NS.rs + 'abstract',
45
+ monetary: NS.rs + 'monetary',
46
+ legalName: NS.rs + 'legalName',
47
+ country: NS.rs + 'country',
48
+ // skos:
49
+ prefLabel: NS.skos + 'prefLabel',
50
+ // xlink:
51
+ from: NS.xlink + 'from',
52
+ to: NS.xlink + 'to',
53
+ role: NS.xlink + 'role',
54
+ // xbrli:
55
+ instant: NS.xbrli + 'instant',
56
+ startDate: NS.xbrli + 'startDate',
57
+ endDate: NS.xbrli + 'endDate',
58
+ periodType: NS.xbrli + 'periodType',
59
+ balance: NS.xbrli + 'balance',
60
+ measure: NS.xbrli + 'measure',
61
+ // link:
62
+ order: NS.link + 'order',
63
+ weight: NS.link + 'weight',
64
+ };
65
+ /**
66
+ * Prefixes for compacting concept IRIs to `prefix:Local`. Order matters — the
67
+ * most specific namespace must come first so `rs-gaap:` wins over `rs:`.
68
+ */
69
+ const PREFIXES = [
70
+ ['rs-gaap', NS.rsgaap],
71
+ ['disclosures', 'https://robosystems.ai/taxonomy/rs-gaap/disclosures/v1/'],
72
+ ['us-gaap', 'http://fasb.org/us-gaap/'],
73
+ ['dei', 'http://xbrl.sec.gov/dei/'],
74
+ ['rs', NS.rs],
75
+ ['skos', NS.skos],
76
+ ['xbrli', NS.xbrli],
77
+ ['xlink', NS.xlink],
78
+ ['link', NS.link],
79
+ ['iso4217', NS.iso4217],
80
+ ];
81
+ /** Compact a concept IRI to `prefix:Local` (e.g. `rs-gaap:Assets`). */
82
+ export function qname(iri) {
83
+ for (const [prefix, ns] of PREFIXES) {
84
+ if (iri.startsWith(ns)) {
85
+ return `${prefix}:${iri.slice(ns.length)}`;
86
+ }
87
+ }
88
+ const slash = iri.lastIndexOf('/');
89
+ const hash = iri.lastIndexOf('#');
90
+ return iri.slice(Math.max(slash, hash) + 1);
91
+ }
92
+ /**
93
+ * Readable concept name from a local name when no `skos:prefLabel` is present —
94
+ * splits CamelCase into words (`AssetsCurrent` → `Assets Current`). A graceful
95
+ * fallback for bundles that predate label emit.
96
+ */
97
+ export function humanize(iri) {
98
+ const local = qname(iri).split(':').pop() ?? iri;
99
+ return local.replace(/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/g, ' ');
100
+ }
101
+ /** Stable display order for the canonical statement blocks; others fall after. */
102
+ export const BLOCK_ORDER = {
103
+ balance_sheet: 0,
104
+ income_statement: 1,
105
+ cash_flow_statement: 2,
106
+ equity_statement: 3,
107
+ };
108
+ /** Friendly section headings keyed by block type. */
109
+ export const BLOCK_TITLES = {
110
+ balance_sheet: 'Balance Sheet',
111
+ income_statement: 'Income Statement',
112
+ cash_flow_statement: 'Cash Flow Statement',
113
+ equity_statement: 'Statement of Changes in Equity',
114
+ };
115
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,EAAE,GAAG;IAChB,GAAG,EAAE,6CAA6C;IAClD,EAAE,EAAE,+BAA+B;IACnC,MAAM,EAAE,6CAA6C;IACrD,IAAI,EAAE,sCAAsC;IAC5C,KAAK,EAAE,+BAA+B;IACtC,KAAK,EAAE,oCAAoC;IAC3C,IAAI,EAAE,oCAAoC;IAC1C,OAAO,EAAE,mCAAmC;CACpC,CAAA;AAEV,uEAAuE;AACvE,MAAM,CAAC,MAAM,GAAG,GAAG;IACjB,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,MAAM;IACrB,cAAc;IACd,MAAM,EAAE,EAAE,CAAC,EAAE,GAAG,QAAQ;IACxB,IAAI,EAAE,EAAE,CAAC,EAAE,GAAG,MAAM;IACpB,gBAAgB,EAAE,EAAE,CAAC,EAAE,GAAG,kBAAkB;IAC5C,SAAS,EAAE,EAAE,CAAC,EAAE,GAAG,WAAW;IAC9B,WAAW,EAAE,EAAE,CAAC,EAAE,GAAG,aAAa;IAClC,OAAO,EAAE,EAAE,CAAC,EAAE,GAAG,SAAS;IAC1B,MAAM,EAAE,EAAE,CAAC,EAAE,GAAG,QAAQ;IACxB,IAAI,EAAE,EAAE,CAAC,EAAE,GAAG,MAAM;IACpB,MAAM,EAAE,EAAE,CAAC,EAAE,GAAG,QAAQ;IACxB,iBAAiB;IACjB,OAAO,EAAE,EAAE,CAAC,EAAE,GAAG,SAAS;IAC1B,MAAM,EAAE,EAAE,CAAC,EAAE,GAAG,QAAQ;IAC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AAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,GAAG,CAAA;IAChD,OAAO,KAAK,CAAC,OAAO,CAAC,kDAAkD,EAAE,GAAG,CAAC,CAAA;AAC/E,CAAC;AAED,kFAAkF;AAClF,MAAM,CAAC,MAAM,WAAW,GAA2B;IACjD,aAAa,EAAE,CAAC;IAChB,gBAAgB,EAAE,CAAC;IACnB,mBAAmB,EAAE,CAAC;IACtB,gBAAgB,EAAE,CAAC;CACpB,CAAA;AAED,qDAAqD;AACrD,MAAM,CAAC,MAAM,YAAY,GAA2B;IAClD,aAAa,EAAE,eAAe;IAC9B,gBAAgB,EAAE,kBAAkB;IACpC,mBAAmB,EAAE,qBAAqB;IAC1C,gBAAgB,EAAE,gCAAgC;CACnD,CAAA"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Pure formatting helpers shared by the projection and the components. No React
3
+ * here, so the projection can depend on it without pulling in a renderer.
4
+ */
5
+ import type { PeriodInfo } from './model';
6
+ /**
7
+ * Accounting-style money: negatives in parentheses, no sign, an em-dash for
8
+ * absent values. Matches the RoboLedger statement renderer.
9
+ */
10
+ export declare function formatMoney(value: number | null | undefined, opts?: {
11
+ currencySymbol?: string;
12
+ }): string;
13
+ /** `2024-03-31` → `Mar 31, 2024`. Falls back to the raw string if unparseable. */
14
+ export declare function formatDate(iso: string | null | undefined): string;
15
+ /** A human description of a period — "As of …" for instants, a span for durations. */
16
+ export declare function formatPeriod(period: PeriodInfo): string;
17
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC;;;GAGG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,IAAI,GAAE;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAO,GACrC,MAAM,CAQR;AAID,kFAAkF;AAClF,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAOjE;AAED,sFAAsF;AACtF,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAKvD"}
package/dist/format.js ADDED
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Accounting-style money: negatives in parentheses, no sign, an em-dash for
3
+ * absent values. Matches the RoboLedger statement renderer.
4
+ */
5
+ export function formatMoney(value, opts = {}) {
6
+ if (value === null || value === undefined || Number.isNaN(value))
7
+ return '—';
8
+ const symbol = opts.currencySymbol ?? '$';
9
+ const abs = Math.abs(value).toLocaleString('en-US', {
10
+ minimumFractionDigits: 2,
11
+ maximumFractionDigits: 2,
12
+ });
13
+ return value < 0 ? `${symbol}(${abs})` : `${symbol}${abs}`;
14
+ }
15
+ const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
16
+ /** `2024-03-31` → `Mar 31, 2024`. Falls back to the raw string if unparseable. */
17
+ export function formatDate(iso) {
18
+ if (!iso)
19
+ return '';
20
+ const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(iso);
21
+ if (!m)
22
+ return iso;
23
+ const [, year, month, day] = m;
24
+ const idx = Number(month) - 1;
25
+ return `${MONTHS[idx] ?? month} ${Number(day)}, ${year}`;
26
+ }
27
+ /** A human description of a period — "As of …" for instants, a span for durations. */
28
+ export function formatPeriod(period) {
29
+ if (period.type === 'instant') {
30
+ return `As of ${formatDate(period.instant ?? period.end)}`;
31
+ }
32
+ return `${formatDate(period.startDate)} – ${formatDate(period.endDate ?? period.end)}`;
33
+ }
34
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":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FAAsF;AACtF,MAAM,UAAU,YAAY,CAAC,MAAkB;IAC7C,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,SAAS,UAAU,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE,CAAA;IAC5D,CAAC;IACD,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,UAAU,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE,CAAA;AACxF,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * `@robosystems/report-components` — public API.
3
+ *
4
+ * Render XBRL-grade financial statements from any source behind a thin adapter:
5
+ *
6
+ * import { ReportView } from '@robosystems/report-components'
7
+ * import { trigFileAdapter } from '@robosystems/report-components/adapters'
8
+ *
9
+ * const report = await trigFileAdapter(trigText).load()
10
+ * <ReportView report={report} />
11
+ */
12
+ export { BLOCK_ORDER, BLOCK_TITLES, NS, humanize, qname } from './constants';
13
+ export * from './format';
14
+ export * from './model';
15
+ export * from './project';
16
+ export { FactInspector } from './components/FactInspector';
17
+ export type { FactInspectorProps } from './components/FactInspector';
18
+ export { ReportView } from './components/ReportView';
19
+ export type { ReportViewProps } from './components/ReportView';
20
+ export { StatementTable } from './components/StatementTable';
21
+ export type { StatementTableProps } from './components/StatementTable';
22
+ export { cypherAdapter } from './adapters/cypher';
23
+ export type { CypherAdapterConfig } from './adapters/cypher';
24
+ export { parseTrig, trigFileAdapter } from './adapters/trig';
25
+ export type { ReportAdapter } from './adapters/types';
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAC5E,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AAGzB,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5D,YAAY,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAGtE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAC5D,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * `@robosystems/report-components` — public API.
3
+ *
4
+ * Render XBRL-grade financial statements from any source behind a thin adapter:
5
+ *
6
+ * import { ReportView } from '@robosystems/report-components'
7
+ * import { trigFileAdapter } from '@robosystems/report-components/adapters'
8
+ *
9
+ * const report = await trigFileAdapter(trigText).load()
10
+ * <ReportView report={report} />
11
+ */
12
+ // Model + reconstruction + formatting
13
+ export { BLOCK_ORDER, BLOCK_TITLES, NS, humanize, qname } from './constants';
14
+ export * from './format';
15
+ export * from './model';
16
+ export * from './project';
17
+ // Components
18
+ export { FactInspector } from './components/FactInspector';
19
+ export { ReportView } from './components/ReportView';
20
+ export { StatementTable } from './components/StatementTable';
21
+ // Adapters (also available at the `/adapters` subpath)
22
+ export { cypherAdapter } from './adapters/cypher';
23
+ export { parseTrig, trigFileAdapter } from './adapters/trig';
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAC5E,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AAEzB,aAAa;AACb,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAG5D,uDAAuD;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA"}
@@ -0,0 +1,148 @@
1
+ /**
2
+ * The normalized report model — the load-bearing seam of the library.
3
+ *
4
+ * An **adapter** turns its source (a `holon.trig` file, a cypher endpoint, a
5
+ * live ledger) into a `NormalizedReport`: the raw facts, Information Blocks,
6
+ * elements / periods / units / entity, and the calculation + presentation
7
+ * association networks. Nothing more.
8
+ *
9
+ * The **projection** (`project.ts`) and **components** turn that normalized
10
+ * model into rendered statements — the presentation-order walk, the calculation
11
+ * subtotals, the table layout. That work is identical for every adapter, which
12
+ * is what makes the rendering source-agnostic.
13
+ */
14
+ export type PeriodType = 'instant' | 'duration';
15
+ export type BalanceType = 'debit' | 'credit';
16
+ /** A reportable concept (a taxonomy element). */
17
+ export interface ElementInfo {
18
+ /** Full element IRI — the join key used everywhere. */
19
+ id: string;
20
+ /** Compacted name, e.g. `rs-gaap:Assets`. */
21
+ qname: string;
22
+ /** Human label (`skos:prefLabel`, else a humanized local name). */
23
+ label: string;
24
+ balance: BalanceType | null;
25
+ periodType: PeriodType | null;
26
+ abstract: boolean;
27
+ monetary: boolean;
28
+ }
29
+ /** A reporting period — an instant (balance sheet) or a duration (flows). */
30
+ export interface PeriodInfo {
31
+ id: string;
32
+ type: PeriodType;
33
+ instant: string | null;
34
+ startDate: string | null;
35
+ endDate: string | null;
36
+ /** The date a fact lands on: `instant` for instants, `endDate` for durations. */
37
+ end: string;
38
+ }
39
+ /** A unit of measure, e.g. USD. */
40
+ export interface UnitInfo {
41
+ id: string;
42
+ /** Compacted measure, e.g. `iso4217:USD`. */
43
+ measure: string;
44
+ /** Short display label, e.g. `USD`. */
45
+ label: string;
46
+ }
47
+ /** The reporting entity. */
48
+ export interface EntityInfo {
49
+ id: string;
50
+ name: string;
51
+ legalName: string | null;
52
+ country: string | null;
53
+ }
54
+ /** A single reported value. */
55
+ export interface Fact {
56
+ id: string;
57
+ /** Element IRI. */
58
+ element: string;
59
+ /** Period IRI. */
60
+ period: string;
61
+ /** Unit IRI, when monetary/numeric. */
62
+ unit: string | null;
63
+ /** Entity IRI. */
64
+ entity: string | null;
65
+ /** FactSet IRI — the grouping key shared with an Information Block. */
66
+ factSet: string | null;
67
+ value: number | null;
68
+ decimals: string | null;
69
+ }
70
+ /** A calculation arc: `parent` (subtotal) rolls up `child * weight`. */
71
+ export interface CalcAssociation {
72
+ parent: string;
73
+ child: string;
74
+ weight: number;
75
+ order: number;
76
+ role: string | null;
77
+ structure: string | null;
78
+ }
79
+ /** A presentation arc: `parent` shows `child` at the given order. */
80
+ export interface PresAssociation {
81
+ parent: string;
82
+ child: string;
83
+ order: number;
84
+ role: string | null;
85
+ structure: string | null;
86
+ }
87
+ /** A network root — groups associations under one role / block type. */
88
+ export interface StructureInfo {
89
+ id: string;
90
+ blockType: string;
91
+ roleUri: string | null;
92
+ structureName: string | null;
93
+ }
94
+ /** An Information Block — groups a statement's facts via a shared `factSet`. */
95
+ export interface InformationBlock {
96
+ id: string;
97
+ blockType: string;
98
+ factSet: string | null;
99
+ label: string | null;
100
+ }
101
+ /** The full normalized report — the adapter's output and projection's input. */
102
+ export interface NormalizedReport {
103
+ reportId: string | null;
104
+ reportIri: string | null;
105
+ entity: EntityInfo | null;
106
+ informationBlocks: InformationBlock[];
107
+ structures: StructureInfo[];
108
+ facts: Fact[];
109
+ elements: Record<string, ElementInfo>;
110
+ periods: Record<string, PeriodInfo>;
111
+ units: Record<string, UnitInfo>;
112
+ calcAssociations: CalcAssociation[];
113
+ presAssociations: PresAssociation[];
114
+ }
115
+ /** A statement column, keyed by the period end date facts are matched against. */
116
+ export interface StatementColumn {
117
+ /** The period end date used to match facts into this column. */
118
+ key: string;
119
+ /** Human header label. */
120
+ label: string;
121
+ /** A representative period for this column (for tooltips / fact inspection). */
122
+ period: PeriodInfo;
123
+ }
124
+ /** One value in a row, plus the fact behind it (for inspection / footing). */
125
+ export interface RowCell {
126
+ value: number | null;
127
+ fact: Fact | null;
128
+ }
129
+ /** A rendered statement line. */
130
+ export interface StatementRow {
131
+ element: ElementInfo;
132
+ /** Tree depth — drives indentation. */
133
+ depth: number;
134
+ /** True when the element is a calculation parent (rendered bold). */
135
+ isSubtotal: boolean;
136
+ cells: RowCell[];
137
+ }
138
+ /** A fully reconstructed statement, ready to render. */
139
+ export interface Statement {
140
+ ib: InformationBlock;
141
+ blockType: string;
142
+ /** Friendly heading, e.g. "Balance Sheet". */
143
+ title: string;
144
+ structureName: string | null;
145
+ columns: StatementColumn[];
146
+ rows: StatementRow[];
147
+ }
148
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,CAAA;AAC/C,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,QAAQ,CAAA;AAE5C,iDAAiD;AACjD,MAAM,WAAW,WAAW;IAC1B,uDAAuD;IACvD,EAAE,EAAE,MAAM,CAAA;IACV,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAA;IACb,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAA;IAC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AM,EAAE,QAAQ,CAAC,CAAA;IAC/B,gBAAgB,EAAE,eAAe,EAAE,CAAA;IACnC,gBAAgB,EAAE,eAAe,EAAE,CAAA;CACpC;AAID,kFAAkF;AAClF,MAAM,WAAW,eAAe;IAC9B,gEAAgE;IAChE,GAAG,EAAE,MAAM,CAAA;IACX,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,gFAAgF;IAChF,MAAM,EAAE,UAAU,CAAA;CACnB;AAED,8EAA8E;AAC9E,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAA;CAClB;AAED,iCAAiC;AACjC,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,WAAW,CAAA;IACpB,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAA;IACb,qEAAqE;IACrE,UAAU,EAAE,OAAO,CAAA;IACnB,KAAK,EAAE,OAAO,EAAE,CAAA;CACjB;AAED,wDAAwD;AACxD,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,gBAAgB,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,OAAO,EAAE,eAAe,EAAE,CAAA;IAC1B,IAAI,EAAE,YAAY,EAAE,CAAA;CACrB"}
package/dist/model.js ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The normalized report model — the load-bearing seam of the library.
3
+ *
4
+ * An **adapter** turns its source (a `holon.trig` file, a cypher endpoint, a
5
+ * live ledger) into a `NormalizedReport`: the raw facts, Information Blocks,
6
+ * elements / periods / units / entity, and the calculation + presentation
7
+ * association networks. Nothing more.
8
+ *
9
+ * The **projection** (`project.ts`) and **components** turn that normalized
10
+ * model into rendered statements — the presentation-order walk, the calculation
11
+ * subtotals, the table layout. That work is identical for every adapter, which
12
+ * is what makes the rendering source-agnostic.
13
+ */
14
+ export {};
15
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
@@ -0,0 +1,39 @@
1
+ import type { ElementInfo, NormalizedReport, Statement } from './model';
2
+ interface OrderEntry {
3
+ order: number;
4
+ depth: number;
5
+ }
6
+ /**
7
+ * Post-order the presentation arcs of one structure → `{element: {order, depth}}`.
8
+ * Roots (a `from` that is never a `to`) are visited by their subtree's leading
9
+ * arc order, so a balance sheet's roots (Assets, then Liabilities and Equity)
10
+ * come out in the right sequence.
11
+ */
12
+ export declare function presentationOrder(model: NormalizedReport, structureId: string): Map<string, OrderEntry>;
13
+ /** Concepts that are calculation parents — the authoritative subtotal set. */
14
+ export declare function calcSubtotals(model: NormalizedReport): Set<string>;
15
+ /** Reconstruct every statement in the report, in canonical block order. */
16
+ export declare function buildStatements(model: NormalizedReport): Statement[];
17
+ export interface FootTerm {
18
+ element: ElementInfo;
19
+ weight: number;
20
+ value: number | null;
21
+ }
22
+ export interface FootCheck {
23
+ element: ElementInfo;
24
+ columnIndex: number;
25
+ terms: FootTerm[];
26
+ /** Σ child·weight over the present terms, or null if none are present. */
27
+ expected: number | null;
28
+ /** The subtotal's own reported value in this column. */
29
+ actual: number | null;
30
+ ok: boolean;
31
+ }
32
+ /**
33
+ * Foot a subtotal live: sum its calculation children (× weight) and compare to
34
+ * its reported value, e.g. `13,550 + 900 = 14,450 ✓`. Returns `null` when the
35
+ * element is not a calculation parent (nothing to foot).
36
+ */
37
+ export declare function footCheck(model: NormalizedReport, statement: Statement, elementId: string, columnIndex: number): FootCheck | null;
38
+ export {};
39
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAEV,WAAW,EAGX,gBAAgB,EAGhB,SAAS,EAIV,MAAM,SAAS,CAAA;AAEhB,UAAU,UAAU;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAcD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,gBAAgB,EACvB,WAAW,EAAE,MAAM,GAClB,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAuCzB;AAED,8EAA8E;AAC9E,wBAAgB,aAAa,CAAC,KAAK,EAAE,gBAAgB,GAAG,GAAG,CAAC,MAAM,CAAC,CAIlE;AAoFD,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,KAAK,EAAE,gBAAgB,GAAG,SAAS,EAAE,CASpE;AAID,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,WAAW,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,WAAW,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,QAAQ,EAAE,CAAA;IACjB,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,wDAAwD;IACxD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,EAAE,EAAE,OAAO,CAAA;CACZ;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,gBAAgB,EACvB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAClB,SAAS,GAAG,IAAI,CAiClB"}