@robosystems/report-components 0.2.10 → 0.3.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.
@@ -1,3 +1,3 @@
1
- export { cypherAdapter, fetchSecReportShell, fetchSecSection, jsonldFileAdapter, mergeSecSections, parseJsonld, parseStore, parseStructureDefinition, parseStructureName } from '../chunk-P3GQDCL2.js';
1
+ export { cypherAdapter, fetchSecReportShell, fetchSecSection, jsonldFileAdapter, mergeSecSections, parseJsonld, parseStore, parseStructureDefinition, parseStructureName } from '../chunk-ZTYXTMAT.js';
2
2
  //# sourceMappingURL=index.js.map
3
3
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,99 @@
1
1
  import { DataFactory, Store, Parser } from 'n3';
2
2
  import jsonld from 'jsonld';
3
3
 
4
+ // src/format.ts
5
+ function formatMoney(value, opts = {}) {
6
+ if (value === null || value === void 0 || Number.isNaN(value)) return "\u2014";
7
+ const symbol = opts.currencySymbol ?? "$";
8
+ const abs = Math.abs(value).toLocaleString("en-US", {
9
+ minimumFractionDigits: 2,
10
+ maximumFractionDigits: 2
11
+ });
12
+ return value < 0 ? `${symbol}(${abs})` : `${symbol}${abs}`;
13
+ }
14
+ var MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
15
+ function formatDate(iso) {
16
+ if (!iso) return "";
17
+ const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(iso);
18
+ if (!m) return iso;
19
+ const [, year, month, day] = m;
20
+ const idx = Number(month) - 1;
21
+ return `${MONTHS[idx] ?? month} ${Number(day)}, ${year}`;
22
+ }
23
+ function humanizeDuration(value) {
24
+ if (!value) return null;
25
+ const m = /^(-)?P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/.exec(
26
+ value.trim()
27
+ );
28
+ if (!m) return null;
29
+ const [, sign, y, mo, w, d, h, min, s] = m;
30
+ const parts = [];
31
+ const push = (n, unit) => {
32
+ if (n) parts.push(`${n} ${unit}${Number(n) === 1 ? "" : "s"}`);
33
+ };
34
+ push(y, "year");
35
+ push(mo, "month");
36
+ push(w, "week");
37
+ push(d, "day");
38
+ push(h, "hour");
39
+ push(min, "minute");
40
+ push(s, "second");
41
+ if (!parts.length) return null;
42
+ return `${sign ?? ""}${parts.join(" ")}`;
43
+ }
44
+ function formatPeriod(period) {
45
+ if (period.type === "instant") {
46
+ return `As of ${formatDate(period.instant ?? period.end)}`;
47
+ }
48
+ return `${formatDate(period.startDate)} \u2013 ${formatDate(period.endDate ?? period.end)}`;
49
+ }
50
+ function numericKindOf(el) {
51
+ return el.numericKind ?? (el.monetary ? "monetary" : "other");
52
+ }
53
+ var CURRENCY_SYMBOLS = {
54
+ USD: "$",
55
+ EUR: "\u20AC",
56
+ GBP: "\xA3",
57
+ JPY: "\xA5",
58
+ CNY: "\xA5",
59
+ CHF: "CHF ",
60
+ CAD: "CA$",
61
+ AUD: "A$",
62
+ HKD: "HK$",
63
+ INR: "\u20B9",
64
+ KRW: "\u20A9"
65
+ };
66
+ function currencySymbolFor(measure) {
67
+ if (!measure) return null;
68
+ const code = (measure.includes(":") ? measure.split(":").pop() : measure).toUpperCase();
69
+ if (CURRENCY_SYMBOLS[code]) return CURRENCY_SYMBOLS[code];
70
+ return /^[A-Z]{3}$/.test(code) ? `${code} ` : null;
71
+ }
72
+ function formatValue(value, fmt = {}) {
73
+ if (value === null || value === void 0 || Number.isNaN(value)) return "\u2014";
74
+ const kind = fmt.numericKind ?? "monetary";
75
+ const scale = kind === "monetary" ? fmt.scaleFactor ?? 1 : 1;
76
+ const scaled = kind === "percent" ? value * 100 : value / scale;
77
+ let minFrac = 0;
78
+ let maxFrac = 0;
79
+ if (kind === "perShare") {
80
+ minFrac = maxFrac = 2;
81
+ } else if (kind === "monetary") {
82
+ minFrac = maxFrac = scale > 1 ? 0 : 2;
83
+ } else if (kind === "percent") {
84
+ maxFrac = 2;
85
+ } else if (kind === "pure") {
86
+ maxFrac = 4;
87
+ }
88
+ const abs = Math.abs(scaled).toLocaleString("en-US", {
89
+ minimumFractionDigits: minFrac,
90
+ maximumFractionDigits: maxFrac
91
+ });
92
+ const symbol = kind === "monetary" || kind === "perShare" ? fmt.symbol ?? "" : "";
93
+ const suffix = kind === "percent" ? "%" : "";
94
+ return scaled < 0 ? `${symbol}(${abs}${suffix})` : `${symbol}${abs}${suffix}`;
95
+ }
96
+
4
97
  // src/constants.ts
5
98
  var NS = {
6
99
  rdf: "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
@@ -115,99 +208,6 @@ var BLOCK_TITLES = {
115
208
  equity_statement: "Statement of Changes in Equity"
116
209
  };
117
210
 
118
- // src/format.ts
119
- function formatMoney(value, opts = {}) {
120
- if (value === null || value === void 0 || Number.isNaN(value)) return "\u2014";
121
- const symbol = opts.currencySymbol ?? "$";
122
- const abs = Math.abs(value).toLocaleString("en-US", {
123
- minimumFractionDigits: 2,
124
- maximumFractionDigits: 2
125
- });
126
- return value < 0 ? `${symbol}(${abs})` : `${symbol}${abs}`;
127
- }
128
- var MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
129
- function formatDate(iso) {
130
- if (!iso) return "";
131
- const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(iso);
132
- if (!m) return iso;
133
- const [, year, month, day] = m;
134
- const idx = Number(month) - 1;
135
- return `${MONTHS[idx] ?? month} ${Number(day)}, ${year}`;
136
- }
137
- function humanizeDuration(value) {
138
- if (!value) return null;
139
- const m = /^(-)?P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/.exec(
140
- value.trim()
141
- );
142
- if (!m) return null;
143
- const [, sign, y, mo, w, d, h, min, s] = m;
144
- const parts = [];
145
- const push = (n, unit) => {
146
- if (n) parts.push(`${n} ${unit}${Number(n) === 1 ? "" : "s"}`);
147
- };
148
- push(y, "year");
149
- push(mo, "month");
150
- push(w, "week");
151
- push(d, "day");
152
- push(h, "hour");
153
- push(min, "minute");
154
- push(s, "second");
155
- if (!parts.length) return null;
156
- return `${sign ?? ""}${parts.join(" ")}`;
157
- }
158
- function formatPeriod(period) {
159
- if (period.type === "instant") {
160
- return `As of ${formatDate(period.instant ?? period.end)}`;
161
- }
162
- return `${formatDate(period.startDate)} \u2013 ${formatDate(period.endDate ?? period.end)}`;
163
- }
164
- function numericKindOf(el) {
165
- return el.numericKind ?? (el.monetary ? "monetary" : "other");
166
- }
167
- var CURRENCY_SYMBOLS = {
168
- USD: "$",
169
- EUR: "\u20AC",
170
- GBP: "\xA3",
171
- JPY: "\xA5",
172
- CNY: "\xA5",
173
- CHF: "CHF ",
174
- CAD: "CA$",
175
- AUD: "A$",
176
- HKD: "HK$",
177
- INR: "\u20B9",
178
- KRW: "\u20A9"
179
- };
180
- function currencySymbolFor(measure) {
181
- if (!measure) return null;
182
- const code = (measure.includes(":") ? measure.split(":").pop() : measure).toUpperCase();
183
- if (CURRENCY_SYMBOLS[code]) return CURRENCY_SYMBOLS[code];
184
- return /^[A-Z]{3}$/.test(code) ? `${code} ` : null;
185
- }
186
- function formatValue(value, fmt = {}) {
187
- if (value === null || value === void 0 || Number.isNaN(value)) return "\u2014";
188
- const kind = fmt.numericKind ?? "monetary";
189
- const scale = kind === "monetary" ? fmt.scaleFactor ?? 1 : 1;
190
- const scaled = kind === "percent" ? value * 100 : value / scale;
191
- let minFrac = 0;
192
- let maxFrac = 0;
193
- if (kind === "perShare") {
194
- minFrac = maxFrac = 2;
195
- } else if (kind === "monetary") {
196
- minFrac = maxFrac = scale > 1 ? 0 : 2;
197
- } else if (kind === "percent") {
198
- maxFrac = 2;
199
- } else if (kind === "pure") {
200
- maxFrac = 4;
201
- }
202
- const abs = Math.abs(scaled).toLocaleString("en-US", {
203
- minimumFractionDigits: minFrac,
204
- maximumFractionDigits: maxFrac
205
- });
206
- const symbol = kind === "monetary" || kind === "perShare" ? fmt.symbol ?? "" : "";
207
- const suffix = kind === "percent" ? "%" : "";
208
- return scaled < 0 ? `${symbol}(${abs}${suffix})` : `${symbol}${abs}${suffix}`;
209
- }
210
-
211
211
  // src/sections.ts
212
212
  var CORE_STATEMENT_TYPES = /* @__PURE__ */ new Set([
213
213
  "balance_sheet",
@@ -859,5 +859,5 @@ function jsonldFileAdapter(doc, source = "holon.jsonld") {
859
859
  }
860
860
 
861
861
  export { BLOCK_ORDER, BLOCK_TITLES, NS, currencySymbolFor, cypherAdapter, fetchSecReportShell, fetchSecSection, formatDate, formatMoney, formatPeriod, formatValue, humanize, humanizeDuration, isExternalFactUrl, jsonldFileAdapter, mergeSecSections, numericKindOf, parseJsonld, parseStore, parseStructureDefinition, parseStructureName, qname, stripRoleSuffix };
862
- //# sourceMappingURL=chunk-P3GQDCL2.js.map
863
- //# sourceMappingURL=chunk-P3GQDCL2.js.map
862
+ //# sourceMappingURL=chunk-ZTYXTMAT.js.map
863
+ //# sourceMappingURL=chunk-ZTYXTMAT.js.map