@caffeinebounce/ui 0.62.2 → 0.63.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 (122) hide show
  1. package/README.md +1 -1
  2. package/dist/blog.js +8 -6
  3. package/dist/blog.mjs +3 -1
  4. package/dist/charts.d.cts +1 -1
  5. package/dist/charts.d.ts +1 -1
  6. package/dist/{chunk-6DVWMJ3H.mjs → chunk-2EFVMX6V.mjs} +4 -3
  7. package/dist/chunk-33JR5SYE.js +1 -0
  8. package/dist/{chunk-OZZWDIOY.js → chunk-375DECW4.js} +32 -31
  9. package/dist/chunk-3NDB4YPC.js +1 -0
  10. package/dist/{chunk-PZRI43EZ.js → chunk-46JYKBRX.js} +0 -43
  11. package/dist/chunk-5D55OVD5.js +75 -0
  12. package/dist/chunk-5RW4PYZ6.js +1 -0
  13. package/dist/chunk-5THF4YP6.mjs +1 -0
  14. package/dist/{chunk-JORVSG52.js → chunk-663CFAHS.js} +212 -269
  15. package/dist/chunk-6BUBNZPG.mjs +1 -0
  16. package/dist/chunk-6HKJDV43.mjs +48 -0
  17. package/dist/chunk-6NCRGHV3.mjs +64 -0
  18. package/dist/{chunk-OLAAXLXY.mjs → chunk-6QAKQG57.mjs} +5 -4
  19. package/dist/chunk-72JGQ7IJ.mjs +1 -0
  20. package/dist/{chunk-N6AFNFZR.mjs → chunk-7ERVZXIN.mjs} +215 -270
  21. package/dist/chunk-7IKHZKAC.js +1 -0
  22. package/dist/chunk-APFEP5B7.mjs +100 -0
  23. package/dist/chunk-C3OADNSG.js +348 -0
  24. package/dist/{chunk-RVEFPVZF.mjs → chunk-C57MX3BG.mjs} +1 -0
  25. package/dist/{chunk-CC4KUIKC.js → chunk-DH5Z3ETN.js} +67 -45
  26. package/dist/chunk-DYWZ23QT.mjs +90 -0
  27. package/dist/{chunk-KRRIRS6A.mjs → chunk-E67IR6HU.mjs} +31 -9
  28. package/dist/{chunk-D3QXPL47.mjs → chunk-EXQSWHLD.mjs} +7 -6
  29. package/dist/{chunk-ZOA7B32D.js → chunk-F35KL6TX.js} +10 -9
  30. package/dist/{chunk-YSLD2HLP.mjs → chunk-FFJC66KO.mjs} +2 -1
  31. package/dist/chunk-FRRS2YZH.mjs +1 -0
  32. package/dist/chunk-G5TQWWQA.mjs +1 -0
  33. package/dist/{chunk-MPZFPU4X.js → chunk-GMBLPQ3I.js} +4 -3
  34. package/dist/chunk-IJFPPLQW.js +50 -0
  35. package/dist/chunk-J6OLBSZR.js +1 -0
  36. package/dist/chunk-KGGQ5NZV.js +1 -0
  37. package/dist/chunk-KHCC5UKW.mjs +1 -0
  38. package/dist/{chunk-BMFQG6RA.mjs → chunk-KJIX6V32.mjs} +108 -1885
  39. package/dist/chunk-LABHD4PU.js +109 -0
  40. package/dist/chunk-LQCVRWVF.js +1 -0
  41. package/dist/{chunk-GAIQJCAZ.js → chunk-LT5VD4KR.js} +150 -1953
  42. package/dist/{chunk-7DHKQODW.mjs → chunk-LTLCIRZY.mjs} +257 -474
  43. package/dist/chunk-N5BHXWR3.mjs +34 -0
  44. package/dist/chunk-OCO3Z5YA.js +37 -0
  45. package/dist/chunk-OFQLWSUR.mjs +1 -0
  46. package/dist/chunk-OIJ7XMDV.mjs +71 -0
  47. package/dist/chunk-ORBH4IBC.mjs +316 -0
  48. package/dist/{chunk-C4UT5V3P.js → chunk-OWHI5VGJ.js} +1 -0
  49. package/dist/chunk-OWWOAYIY.js +2652 -0
  50. package/dist/chunk-PFHOXDSW.mjs +10 -0
  51. package/dist/chunk-Q52ZEL62.mjs +1 -0
  52. package/dist/chunk-QRS7DJGS.js +103 -0
  53. package/dist/chunk-R26Y7LGJ.js +1 -0
  54. package/dist/{chunk-BFWX5GJZ.mjs → chunk-R3X4B4JJ.mjs} +56 -8
  55. package/dist/chunk-RBUYW6QQ.js +1 -0
  56. package/dist/chunk-RM7ACPTM.mjs +2601 -0
  57. package/dist/chunk-RODSGPBB.mjs +75 -0
  58. package/dist/chunk-SORWLKOK.js +1 -0
  59. package/dist/{chunk-T6ZBA6VJ.js → chunk-UHAV34YX.js} +9 -8
  60. package/dist/{chunk-GUSTCU2W.mjs → chunk-ULANYJ7Y.mjs} +1 -59
  61. package/dist/chunk-ULDE7QSN.js +70 -0
  62. package/dist/chunk-UT36VNVZ.mjs +47 -0
  63. package/dist/chunk-UY3H4PKB.js +71 -0
  64. package/dist/{chunk-KB7UXIQZ.mjs → chunk-VIVWFQG5.mjs} +3 -1
  65. package/dist/{chunk-ESZ7CBA2.js → chunk-VKBJ3SGT.js} +7 -5
  66. package/dist/{chunk-UM7WMXIU.js → chunk-W3YOQ5ZD.js} +265 -505
  67. package/dist/chunk-WOITB4JL.js +1 -0
  68. package/dist/{chunk-E42B4GSB.js → chunk-XGJL6DLV.js} +58 -7
  69. package/dist/chunk-YKZEKJMZ.mjs +1 -0
  70. package/dist/chunk-YRIBFIQ5.js +116 -0
  71. package/dist/chunk-ZFLZA7UP.mjs +1 -0
  72. package/dist/chunk-ZKUIUE7W.mjs +1 -0
  73. package/dist/chunk-ZWWJ3RRA.js +15 -0
  74. package/dist/data-grid.d.cts +241 -0
  75. package/dist/data-grid.d.ts +241 -0
  76. package/dist/data-grid.js +6486 -0
  77. package/dist/data-grid.mjs +6459 -0
  78. package/dist/data-table-CDQBo-Ve.d.ts +818 -0
  79. package/dist/data-table-jLzt6plY.d.cts +818 -0
  80. package/dist/data-table.d.cts +8 -42
  81. package/dist/data-table.d.ts +8 -42
  82. package/dist/data-table.js +61 -187
  83. package/dist/data-table.mjs +11 -5
  84. package/dist/finance.d.cts +534 -0
  85. package/dist/finance.d.ts +534 -0
  86. package/dist/finance.js +188 -0
  87. package/dist/finance.mjs +15 -0
  88. package/dist/forms.js +9 -6
  89. package/dist/forms.mjs +7 -4
  90. package/dist/{hooks-B2jU1GVT.d.ts → hooks-A55E0fgf.d.ts} +3 -2
  91. package/dist/{hooks-8ORd7T1A.d.cts → hooks-Bys_AZPI.d.cts} +3 -2
  92. package/dist/hooks.d.cts +1 -1
  93. package/dist/hooks.d.ts +1 -1
  94. package/dist/hooks.js +26 -23
  95. package/dist/hooks.mjs +6 -3
  96. package/dist/index.d.cts +536 -665
  97. package/dist/index.d.ts +536 -665
  98. package/dist/index.js +3830 -3408
  99. package/dist/index.mjs +2068 -1767
  100. package/dist/layouts.js +26 -25
  101. package/dist/layouts.mjs +5 -4
  102. package/dist/marketing-3d.js +1 -0
  103. package/dist/marketing-3d.mjs +1 -0
  104. package/dist/marketing.js +75 -74
  105. package/dist/marketing.mjs +5 -4
  106. package/dist/media.js +1 -0
  107. package/dist/media.mjs +1 -0
  108. package/dist/navigation.js +29 -28
  109. package/dist/navigation.mjs +7 -6
  110. package/dist/primitives.d.cts +72 -109
  111. package/dist/primitives.d.ts +72 -109
  112. package/dist/primitives.js +78 -72
  113. package/dist/primitives.mjs +8 -6
  114. package/dist/settings.js +9 -9
  115. package/dist/settings.mjs +4 -4
  116. package/package.json +21 -4
  117. package/dist/UnifiedTableControls-CG299y9h.d.ts +0 -1233
  118. package/dist/UnifiedTableControls-CIjRpNhy.d.cts +0 -1233
  119. package/dist/chunk-GMBGWOCR.mjs +0 -48
  120. package/dist/chunk-HBLKVQIQ.mjs +0 -23
  121. package/dist/chunk-HMAMMC72.js +0 -26
  122. package/dist/chunk-MVYRNJA6.js +0 -74
@@ -1,131 +1,230 @@
1
+ "use client";
2
+ import { TableHeader, TableRow, TableHead, TableBody, TableCell } from './chunk-APFEP5B7.mjs';
1
3
  import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from './chunk-6BUBNZPG.mjs';
2
4
  import { Button } from './chunk-VBD4Q5LL.mjs';
3
- import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent } from './chunk-OFQLWSUR.mjs';
5
+ import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent, DropdownMenuItem } from './chunk-OFQLWSUR.mjs';
4
6
  import { TooltipProvider, Tooltip, TooltipTrigger, TooltipContent } from './chunk-YKZEKJMZ.mjs';
5
7
  import { Input } from './chunk-STEP6C4C.mjs';
6
8
  import { cn } from './chunk-IMKLN273.mjs';
7
- import * as PopoverPrimitive from '@radix-ui/react-popover';
9
+ import * as React4 from 'react';
8
10
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
9
- import { MoreHorizontal, Trash2, Check, X, Plus, GripVertical, ChevronDown, ChevronRight, Filter, ArrowDown, ArrowUp, ListOrdered, WrapText, EyeOff, ChevronsDownUp, ChevronsUpDown, Text, List, CheckSquare, Calendar, Hash, BookOpen, Info, DollarSign, TrendingUp, CheckCircle2, AlertTriangle } from 'lucide-react';
10
- import * as React3 from 'react';
11
- import { flexRender, useReactTable, getExpandedRowModel, getCoreRowModel } from '@tanstack/react-table';
11
+ import { useReactTable, getExpandedRowModel, getCoreRowModel, flexRender } from '@tanstack/react-table';
12
+ import { BookOpen, Info, Calendar, DollarSign, TrendingUp, GripVertical, ChevronDown, ChevronRight, Filter, ArrowDown, ArrowUp, ListOrdered, WrapText, EyeOff, X, Plus, ChevronsDownUp, ChevronsUpDown, Text, List, CheckSquare, Hash, MoreHorizontal, Trash2, Check, CheckCircle2, AlertTriangle } from 'lucide-react';
12
13
 
13
- var Popover = PopoverPrimitive.Root;
14
- var PopoverTrigger = PopoverPrimitive.Trigger;
15
- var PopoverAnchor = PopoverPrimitive.Anchor;
16
- function PopoverContent({
17
- className,
18
- align = "center",
19
- sideOffset = 4,
20
- ...props
14
+ var FinanceDisplayContext = React4.createContext({
15
+ decimals: 0,
16
+ displayUnits: "actuals",
17
+ currencySignDisplay: "all"
18
+ });
19
+ var FinanceDecimalsContext = React4.createContext(0);
20
+ function FinanceDisplayProvider({
21
+ decimals,
22
+ displayUnits = "actuals",
23
+ currencySignDisplay = "all",
24
+ children
21
25
  }) {
22
- return /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(
23
- PopoverPrimitive.Content,
24
- {
25
- align,
26
- sideOffset,
27
- className: cn(
28
- "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 rounded-box border p-4 shadow-md outline-none",
29
- className
30
- ),
31
- ...props
32
- }
33
- ) });
26
+ const value = React4.useMemo(
27
+ () => ({ decimals, displayUnits, currencySignDisplay }),
28
+ [decimals, displayUnits, currencySignDisplay]
29
+ );
30
+ return /* @__PURE__ */ jsx(FinanceDisplayContext.Provider, { value, children: /* @__PURE__ */ jsx(FinanceDecimalsContext.Provider, { value: decimals, children }) });
34
31
  }
35
- function Table({ className, ...props }) {
36
- return /* @__PURE__ */ jsx("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ jsx(
37
- "table",
38
- {
39
- "data-slot": "table",
40
- className: cn("w-full caption-bottom text-sm", className),
41
- ...props
42
- }
43
- ) });
32
+ function FinanceDecimalsProvider({
33
+ decimals,
34
+ children
35
+ }) {
36
+ return /* @__PURE__ */ jsx(FinanceDisplayProvider, { decimals, children });
44
37
  }
45
- function TableHeader({ className, ...props }) {
46
- return /* @__PURE__ */ jsx(
47
- "thead",
48
- {
49
- "data-slot": "table-header",
50
- className: cn("[&_tr]:border-b", className),
51
- ...props
52
- }
53
- );
38
+ function useFinanceDecimals() {
39
+ return React4.useContext(FinanceDecimalsContext);
54
40
  }
55
- function TableBody({ className, ...props }) {
56
- return /* @__PURE__ */ jsx(
57
- "tbody",
58
- {
59
- "data-slot": "table-body",
60
- className: cn("[&_tr:last-child]:border-0", className),
61
- ...props
62
- }
63
- );
41
+ function useFinanceDisplay() {
42
+ return React4.useContext(FinanceDisplayContext);
64
43
  }
65
- function TableFooter({ className, ...props }) {
66
- return /* @__PURE__ */ jsx(
67
- "tfoot",
68
- {
69
- "data-slot": "table-footer",
70
- className: cn(
71
- "bg-muted/50 border-t font-medium [&>tr]:last:border-b-0",
72
- className
73
- ),
74
- ...props
75
- }
76
- );
44
+ function getUnitDivisor(units) {
45
+ switch (units) {
46
+ case "thousands":
47
+ return 1e3;
48
+ case "millions":
49
+ return 1e6;
50
+ default:
51
+ return 1;
52
+ }
77
53
  }
78
- function TableRow({ className, ...props }) {
79
- return /* @__PURE__ */ jsx(
80
- "tr",
81
- {
82
- "data-slot": "table-row",
83
- className: cn(
84
- "hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",
85
- className
86
- ),
87
- ...props
88
- }
89
- );
54
+ function getUnitLabel(units) {
55
+ switch (units) {
56
+ case "thousands":
57
+ return "in thousands";
58
+ case "millions":
59
+ return "in millions";
60
+ default:
61
+ return null;
62
+ }
90
63
  }
91
- function TableHead({ className, ...props }) {
92
- return /* @__PURE__ */ jsx(
93
- "th",
94
- {
95
- "data-slot": "table-head",
96
- className: cn(
97
- "text-muted-foreground h-10 px-2 text-left align-middle font-medium [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
98
- className
99
- ),
100
- ...props
101
- }
64
+ function getUnitSuffix(units) {
65
+ switch (units) {
66
+ case "thousands":
67
+ return "(000s)";
68
+ case "millions":
69
+ return "(M)";
70
+ default:
71
+ return null;
72
+ }
73
+ }
74
+ function useFinanceDecimalsSetting(storageKey = "finance-decimal-places", defaultValue = 0) {
75
+ const [decimals, setDecimalsState] = React4.useState(() => {
76
+ if (typeof window === "undefined") return defaultValue;
77
+ const stored = localStorage.getItem(storageKey);
78
+ return stored !== null ? Number(stored) : defaultValue;
79
+ });
80
+ const setDecimals = React4.useCallback(
81
+ (v) => {
82
+ setDecimalsState(v);
83
+ if (typeof window !== "undefined") {
84
+ localStorage.setItem(storageKey, String(v));
85
+ }
86
+ },
87
+ [storageKey]
102
88
  );
89
+ return [decimals, setDecimals];
103
90
  }
104
- function TableCell({ className, ...props }) {
91
+ var formatterCache = /* @__PURE__ */ new Map();
92
+ function getFormatter(locale, currencyCode, decimals) {
93
+ const key = `${locale}:${currencyCode}:${decimals}`;
94
+ let fmt = formatterCache.get(key);
95
+ if (!fmt) {
96
+ fmt = new Intl.NumberFormat(locale, {
97
+ style: "currency",
98
+ currency: currencyCode,
99
+ minimumFractionDigits: decimals,
100
+ maximumFractionDigits: decimals
101
+ });
102
+ formatterCache.set(key, fmt);
103
+ }
104
+ return fmt;
105
+ }
106
+ function formatCurrencyValue(value, options) {
107
+ const raw = value ?? 0;
108
+ const divisor = getUnitDivisor(options?.displayUnits ?? "actuals");
109
+ const v = divisor === 1 ? raw : raw / divisor;
110
+ const isZero = raw === 0;
111
+ const isNegative = v < 0;
112
+ const curr = options?.currency ?? "USD";
113
+ const locale = options?.locale ?? "en-US";
114
+ const dashZero = options?.dashZero ?? false;
115
+ const decimals = options?.decimals ?? 2;
116
+ const showSign = options?.showCurrencySign ?? true;
117
+ if (isZero && dashZero) {
118
+ return { text: "\u2014", isNegative: false, isZero: true };
119
+ }
120
+ const absV = Math.abs(v);
121
+ let formatted;
122
+ if (showSign) {
123
+ const fmt = getFormatter(locale, curr, decimals);
124
+ formatted = fmt.format(absV);
125
+ } else {
126
+ formatted = absV.toLocaleString(locale, {
127
+ minimumFractionDigits: decimals,
128
+ maximumFractionDigits: decimals
129
+ });
130
+ }
131
+ if (isNegative) {
132
+ return { text: `(${formatted})`, isNegative: true, isZero: false };
133
+ }
134
+ return { text: formatted, isNegative: false, isZero };
135
+ }
136
+ function DataTableCurrencyCell({
137
+ value,
138
+ currency: currencyCode = "USD",
139
+ locale = "en-US",
140
+ dashZero = false,
141
+ decimals,
142
+ className,
143
+ /** Whether this cell is in a summary/total row */
144
+ isSummaryRow
145
+ }) {
146
+ const ctx = useFinanceDisplay();
147
+ const resolvedDecimals = decimals ?? ctx.decimals;
148
+ const showCurrencySign = ctx.currencySignDisplay === "all" || ctx.currencySignDisplay === "summary" && isSummaryRow;
149
+ const { text, isNegative, isZero } = formatCurrencyValue(value, {
150
+ currency: currencyCode,
151
+ locale,
152
+ dashZero,
153
+ decimals: resolvedDecimals,
154
+ displayUnits: ctx.displayUnits,
155
+ showCurrencySign
156
+ });
105
157
  return /* @__PURE__ */ jsx(
106
- "td",
158
+ "span",
107
159
  {
108
- "data-slot": "table-cell",
109
160
  className: cn(
110
- "p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
161
+ "font-mono tabular-nums",
162
+ isNegative && "text-red-600 dark:text-red-400",
163
+ isZero && dashZero && "text-muted-foreground",
111
164
  className
112
165
  ),
113
- ...props
166
+ children: text
114
167
  }
115
168
  );
116
169
  }
117
- function TableCaption({
118
- className,
119
- ...props
120
- }) {
121
- return /* @__PURE__ */ jsx(
122
- "caption",
123
- {
124
- "data-slot": "table-caption",
125
- className: cn("text-muted-foreground mt-4 text-sm", className),
126
- ...props
127
- }
170
+
171
+ // src/blocks/finance/financialStatementRowImportance.ts
172
+ var DEFAULT_ROW_IMPORTANCE_CONFIG = {
173
+ "income-statement": {
174
+ emphasis: ["Total Revenue", "Total Expenses", "Operating Income"],
175
+ keySummary: ["Net Income"]
176
+ },
177
+ "balance-sheet": {
178
+ emphasis: ["Total Liabilities", "Total Equity"],
179
+ keySummary: ["Total Assets", "Total Liabilities & Equity"]
180
+ },
181
+ "cash-flow": {
182
+ emphasis: [
183
+ "Total Operating Activities",
184
+ "Total Investing Activities",
185
+ "Total Financing Activities",
186
+ "Net Cash from Operating Activities",
187
+ "Net Cash from Investing Activities",
188
+ "Net Cash from Financing Activities"
189
+ ],
190
+ keySummary: [
191
+ "Net Change in Cash",
192
+ "Ending Cash",
193
+ "Total Cash & Cash Equivalents"
194
+ ]
195
+ },
196
+ "working-capital": {
197
+ emphasis: ["Total Current Assets", "Total Current Liabilities"],
198
+ keySummary: ["NWC", "Net Working Capital"]
199
+ }
200
+ };
201
+ function normalizeLabel(value) {
202
+ return value.trim().toLowerCase().replace(/\s+/g, " ");
203
+ }
204
+ function createFinancialStatementRowImportanceResolver(kind, overrides) {
205
+ const base = DEFAULT_ROW_IMPORTANCE_CONFIG[kind];
206
+ const emphasis = new Set(
207
+ (overrides?.emphasis ?? base?.emphasis ?? []).map(normalizeLabel)
128
208
  );
209
+ const keySummary = new Set(
210
+ (overrides?.keySummary ?? base?.keySummary ?? []).map(normalizeLabel)
211
+ );
212
+ return (row) => {
213
+ const label = normalizeLabel(row.name);
214
+ if (keySummary.has(label)) return "key-summary";
215
+ if (emphasis.has(label)) return "emphasis";
216
+ return "normal";
217
+ };
218
+ }
219
+ function getFinancialStatementRowImportanceClassName(importance) {
220
+ switch (importance) {
221
+ case "emphasis":
222
+ return "bg-muted/25 border-t border-border/50 font-medium";
223
+ case "key-summary":
224
+ return "bg-muted/45 border-t-2 border-border/70 font-semibold";
225
+ default:
226
+ return void 0;
227
+ }
129
228
  }
130
229
  var colorMap = {
131
230
  green: "#22c55e",
@@ -202,16 +301,16 @@ function DataTableColumnFilterContent({
202
301
  placeholder,
203
302
  showDeleteMenu = true
204
303
  }) {
205
- const [localValue, setLocalValue] = React3.useState(value ?? "");
206
- const [operator, setOperator] = React3.useState("is");
207
- React3.useEffect(() => setLocalValue(value ?? ""), [value]);
304
+ const [localValue, setLocalValue] = React4.useState(value ?? "");
305
+ const [operator, setOperator] = React4.useState("is");
306
+ React4.useEffect(() => setLocalValue(value ?? ""), [value]);
208
307
  const handleApply = () => onChange(localValue || void 0);
209
308
  const handleClear = () => {
210
309
  setLocalValue("");
211
310
  onClear?.();
212
311
  onChange(void 0);
213
312
  };
214
- const selectedValues = React3.useMemo(() => {
313
+ const selectedValues = React4.useMemo(() => {
215
314
  if (!localValue) return /* @__PURE__ */ new Set();
216
315
  return new Set(localValue.split(",").filter(Boolean));
217
316
  }, [localValue]);
@@ -335,7 +434,7 @@ function DataTableColumnFilterContent({
335
434
  const colorValue = opt.color ? getColorValue(opt.color) : void 0;
336
435
  let iconElement = null;
337
436
  if (opt.icon) {
338
- if (React3.isValidElement(opt.icon)) {
437
+ if (React4.isValidElement(opt.icon)) {
339
438
  iconElement = opt.icon;
340
439
  } else {
341
440
  const Icon = opt.icon;
@@ -391,37 +490,6 @@ function DataTableColumnFilterContent({
391
490
  ) })
392
491
  ] });
393
492
  }
394
- function DataTableColumnFilter({
395
- column,
396
- title,
397
- filterType = "text",
398
- filterOptions,
399
- placeholder,
400
- children,
401
- onFilterChange
402
- }) {
403
- const [open, setOpen] = React3.useState(false);
404
- const current = column.getFilterValue();
405
- return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
406
- /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children }),
407
- /* @__PURE__ */ jsx(PopoverContent, { align: "start", className: "w-56 p-0", sideOffset: 4, children: /* @__PURE__ */ jsx(
408
- DataTableColumnFilterContent,
409
- {
410
- title,
411
- value: current,
412
- onChange: (v) => {
413
- column.setFilterValue(v);
414
- onFilterChange?.(column.id, v);
415
- },
416
- onClear: () => column.setFilterValue(void 0),
417
- filterType,
418
- filterOptions,
419
- placeholder,
420
- showDeleteMenu: false
421
- }
422
- ) })
423
- ] });
424
- }
425
493
  function DataTableFilterBadges({
426
494
  filters,
427
495
  onRemoveFilter,
@@ -450,7 +518,7 @@ function DataTableFilterBadges({
450
518
  "text-xs hover:bg-sky-100 dark:hover:bg-sky-900/40 transition-colors cursor-pointer"
451
519
  ),
452
520
  children: [
453
- filter.icon && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground shrink-0 [&>svg]:size-3", children: React3.isValidElement(filter.icon) ? filter.icon : (() => {
521
+ filter.icon && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground shrink-0 [&>svg]:size-3", children: React4.isValidElement(filter.icon) ? filter.icon : (() => {
454
522
  const Icon = filter.icon;
455
523
  return /* @__PURE__ */ jsx(Icon, { className: "size-3" });
456
524
  })() }),
@@ -521,16 +589,16 @@ function DataTableFilterBadges({
521
589
  }
522
590
  );
523
591
  }
524
- var DataTableContext = React3.createContext(null);
592
+ var DataTableContext = React4.createContext(null);
525
593
  function useDataTableContext() {
526
- return React3.useContext(DataTableContext);
594
+ return React4.useContext(DataTableContext);
527
595
  }
528
596
  function TreeExpandCycleButton({
529
597
  table,
530
598
  density
531
599
  }) {
532
- const depthRef = React3.useRef(-1);
533
- const maxDepth = React3.useMemo(() => {
600
+ const depthRef = React4.useRef(-1);
601
+ const maxDepth = React4.useMemo(() => {
534
602
  let max = 0;
535
603
  const walk = (rows) => {
536
604
  for (const row of rows) {
@@ -543,7 +611,7 @@ function TreeExpandCycleButton({
543
611
  );
544
612
  return max;
545
613
  }, [table]);
546
- const handleClick = React3.useCallback(() => {
614
+ const handleClick = React4.useCallback(() => {
547
615
  const nextDepth = depthRef.current + 1;
548
616
  if (nextDepth > maxDepth) {
549
617
  table.toggleAllRowsExpanded(false);
@@ -634,21 +702,21 @@ function DataTable({
634
702
  md: "size-3",
635
703
  lg: "size-3.5"
636
704
  }[fontSize];
637
- const [columnSizing, setColumnSizing] = React3.useState({});
638
- const [resizingColumn, setResizingColumn] = React3.useState(
705
+ const [columnSizing, setColumnSizing] = React4.useState({});
706
+ const [resizingColumn, setResizingColumn] = React4.useState(
639
707
  null
640
708
  );
641
- const [hoveredRowId, setHoveredRowId] = React3.useState(null);
642
- const defaultColumnOrder = React3.useMemo(
709
+ const [hoveredRowId, setHoveredRowId] = React4.useState(null);
710
+ const defaultColumnOrder = React4.useMemo(
643
711
  () => columns.map(
644
712
  (col) => col.id ? col.id : "accessorKey" in col ? String(col.accessorKey) : ""
645
713
  ),
646
714
  [columns]
647
715
  );
648
- const [internalColumnOrder, setInternalColumnOrder] = React3.useState(defaultColumnOrder);
716
+ const [internalColumnOrder, setInternalColumnOrder] = React4.useState(defaultColumnOrder);
649
717
  const columnOrder = externalColumnOrder ?? internalColumnOrder;
650
718
  const setColumnOrder = onColumnOrderChange ?? setInternalColumnOrder;
651
- const renderedLeafColumns = React3.useMemo(() => {
719
+ const renderedLeafColumns = React4.useMemo(() => {
652
720
  let leafColumns = table.getVisibleLeafColumns();
653
721
  if (rowSelectionStyle === "hover" || enableRowDrag) {
654
722
  leafColumns = leafColumns.filter((column) => column.id !== "select");
@@ -664,14 +732,14 @@ function DataTable({
664
732
  }
665
733
  return leafColumns;
666
734
  }, [table, rowSelectionStyle, enableRowDrag, enableColumnDrag, columnOrder]);
667
- const renderedLeafIndexById = React3.useMemo(() => {
735
+ const renderedLeafIndexById = React4.useMemo(() => {
668
736
  const indexById = /* @__PURE__ */ new Map();
669
737
  renderedLeafColumns.forEach((column, index) => {
670
738
  indexById.set(column.id, index);
671
739
  });
672
740
  return indexById;
673
741
  }, [renderedLeafColumns]);
674
- const stickyLeafColumns = React3.useMemo(() => {
742
+ const stickyLeafColumns = React4.useMemo(() => {
675
743
  if (explicitStickyColumnIds && explicitStickyColumnIds.length > 0) {
676
744
  const stickyIdSet = new Set(explicitStickyColumnIds);
677
745
  return renderedLeafColumns.filter((column) => stickyIdSet.has(column.id));
@@ -679,11 +747,11 @@ function DataTable({
679
747
  if (!stickyColumns || stickyColumns <= 0) return [];
680
748
  return renderedLeafColumns.slice(0, stickyColumns);
681
749
  }, [renderedLeafColumns, stickyColumns, explicitStickyColumnIds]);
682
- const stickyColumnIds = React3.useMemo(
750
+ const stickyColumnIds = React4.useMemo(
683
751
  () => new Set(stickyLeafColumns.map((column) => column.id)),
684
752
  [stickyLeafColumns]
685
753
  );
686
- const stickyColumnLefts = React3.useMemo(() => {
754
+ const stickyColumnLefts = React4.useMemo(() => {
687
755
  const lefts = /* @__PURE__ */ new Map();
688
756
  let runningLeft = 0;
689
757
  for (const column of stickyLeafColumns) {
@@ -692,7 +760,7 @@ function DataTable({
692
760
  }
693
761
  return lefts;
694
762
  }, [stickyLeafColumns]);
695
- const renderedTableWidth = React3.useMemo(() => {
763
+ const renderedTableWidth = React4.useMemo(() => {
696
764
  return renderedLeafColumns.reduce((total, column) => {
697
765
  const resizedWidth = columnSizing[column.id];
698
766
  const baseWidth = resizedWidth ?? column.getSize();
@@ -705,17 +773,17 @@ function DataTable({
705
773
  return total + clamped;
706
774
  }, 0);
707
775
  }, [renderedLeafColumns, columnSizing]);
708
- const [internalColumnWrapping, setInternalColumnWrapping] = React3.useState({});
776
+ const [internalColumnWrapping, setInternalColumnWrapping] = React4.useState({});
709
777
  const columnWrapping = externalColumnWrapping ?? internalColumnWrapping;
710
778
  const setColumnWrapping = onColumnWrappingChange ?? setInternalColumnWrapping;
711
- const [draggedColumnId, setDraggedColumnId] = React3.useState(
779
+ const [draggedColumnId, setDraggedColumnId] = React4.useState(
712
780
  null
713
781
  );
714
- const [dragOverColumnId, setDragOverColumnId] = React3.useState(
782
+ const [dragOverColumnId, setDragOverColumnId] = React4.useState(
715
783
  null
716
784
  );
717
- const [dragOverColumnPosition, setDragOverColumnPosition] = React3.useState(null);
718
- const handleColumnDragStart = React3.useCallback(
785
+ const [dragOverColumnPosition, setDragOverColumnPosition] = React4.useState(null);
786
+ const handleColumnDragStart = React4.useCallback(
719
787
  (e, columnId) => {
720
788
  setDraggedColumnId(columnId);
721
789
  e.dataTransfer.effectAllowed = "move";
@@ -726,7 +794,7 @@ function DataTable({
726
794
  },
727
795
  []
728
796
  );
729
- const handleColumnDragOver = React3.useCallback(
797
+ const handleColumnDragOver = React4.useCallback(
730
798
  (e, columnId) => {
731
799
  e.preventDefault();
732
800
  e.dataTransfer.dropEffect = "move";
@@ -740,11 +808,11 @@ function DataTable({
740
808
  },
741
809
  [draggedColumnId]
742
810
  );
743
- const handleColumnDragLeave = React3.useCallback(() => {
811
+ const handleColumnDragLeave = React4.useCallback(() => {
744
812
  setDragOverColumnId(null);
745
813
  setDragOverColumnPosition(null);
746
814
  }, []);
747
- const handleColumnDrop = React3.useCallback(
815
+ const handleColumnDrop = React4.useCallback(
748
816
  (e, targetColumnId) => {
749
817
  e.preventDefault();
750
818
  if (draggedColumnId && draggedColumnId !== targetColumnId) {
@@ -767,13 +835,13 @@ function DataTable({
767
835
  },
768
836
  [draggedColumnId, columnOrder, dragOverColumnPosition, setColumnOrder]
769
837
  );
770
- const handleColumnDragEnd = React3.useCallback((e) => {
838
+ const handleColumnDragEnd = React4.useCallback((e) => {
771
839
  e.target.closest("th")?.classList.remove("opacity-50");
772
840
  setDraggedColumnId(null);
773
841
  setDragOverColumnId(null);
774
842
  setDragOverColumnPosition(null);
775
843
  }, []);
776
- const toggleColumnWrapping = React3.useCallback(
844
+ const toggleColumnWrapping = React4.useCallback(
777
845
  (columnId) => {
778
846
  setColumnWrapping({
779
847
  ...columnWrapping,
@@ -782,14 +850,14 @@ function DataTable({
782
850
  },
783
851
  [columnWrapping, setColumnWrapping]
784
852
  );
785
- const [draggedRowIndex, setDraggedRowIndex] = React3.useState(
853
+ const [draggedRowIndex, setDraggedRowIndex] = React4.useState(
786
854
  null
787
855
  );
788
- const [dragOverRowIndex, setDragOverRowIndex] = React3.useState(
856
+ const [dragOverRowIndex, setDragOverRowIndex] = React4.useState(
789
857
  null
790
858
  );
791
- const [dragOverPosition, setDragOverPosition] = React3.useState(null);
792
- const handleRowDragStart = React3.useCallback(
859
+ const [dragOverPosition, setDragOverPosition] = React4.useState(null);
860
+ const handleRowDragStart = React4.useCallback(
793
861
  (e, rowIndex) => {
794
862
  setDraggedRowIndex(rowIndex);
795
863
  e.dataTransfer.effectAllowed = "move";
@@ -800,7 +868,7 @@ function DataTable({
800
868
  },
801
869
  []
802
870
  );
803
- const handleRowDragOver = React3.useCallback(
871
+ const handleRowDragOver = React4.useCallback(
804
872
  (e, rowIndex) => {
805
873
  e.preventDefault();
806
874
  e.dataTransfer.dropEffect = "move";
@@ -814,11 +882,11 @@ function DataTable({
814
882
  },
815
883
  [draggedRowIndex]
816
884
  );
817
- const handleRowDragLeave = React3.useCallback(() => {
885
+ const handleRowDragLeave = React4.useCallback(() => {
818
886
  setDragOverRowIndex(null);
819
887
  setDragOverPosition(null);
820
888
  }, []);
821
- const handleRowDrop = React3.useCallback(
889
+ const handleRowDrop = React4.useCallback(
822
890
  (e, toIndex) => {
823
891
  e.preventDefault();
824
892
  const fromIndex = draggedRowIndex;
@@ -840,13 +908,13 @@ function DataTable({
840
908
  },
841
909
  [draggedRowIndex, dragOverPosition, onRowDragEnd]
842
910
  );
843
- const handleRowDragEnd = React3.useCallback((e) => {
911
+ const handleRowDragEnd = React4.useCallback((e) => {
844
912
  e.target.closest("tr")?.classList.remove("opacity-50");
845
913
  setDraggedRowIndex(null);
846
914
  setDragOverRowIndex(null);
847
915
  setDragOverPosition(null);
848
916
  }, []);
849
- const handleResizeStart = React3.useCallback(
917
+ const handleResizeStart = React4.useCallback(
850
918
  (columnId, startX, startWidth) => {
851
919
  setResizingColumn(columnId);
852
920
  const handleMouseMove = (e) => {
@@ -868,7 +936,7 @@ function DataTable({
868
936
  },
869
937
  []
870
938
  );
871
- const contextValue = React3.useMemo(
939
+ const contextValue = React4.useMemo(
872
940
  () => ({
873
941
  columnWrapping,
874
942
  toggleColumnWrapping,
@@ -1496,9 +1564,9 @@ function DataTableColumnHeader({
1496
1564
  const resolvedFilterType = filterType ?? meta?.filterType ?? "text";
1497
1565
  const resolvedFilterOptions = filterOptions ?? meta?.filterOptions;
1498
1566
  const filterPlaceholder = meta?.filterPlaceholder;
1499
- const [isOpen, setIsOpen] = React3.useState(false);
1500
- const mouseDownPosRef = React3.useRef(null);
1501
- const didDragRef = React3.useRef(false);
1567
+ const [isOpen, setIsOpen] = React4.useState(false);
1568
+ const mouseDownPosRef = React4.useRef(null);
1569
+ const didDragRef = React4.useRef(false);
1502
1570
  const canDrag = dataTableContext?.enableColumnDrag ?? false;
1503
1571
  const handleMouseDown = (e) => {
1504
1572
  mouseDownPosRef.current = { x: e.clientX, y: e.clientY };
@@ -1678,221 +1746,6 @@ function DataTableColumnHeader({
1678
1746
  ] })
1679
1747
  ] }) });
1680
1748
  }
1681
- var FinanceDisplayContext = React3.createContext({
1682
- decimals: 0,
1683
- displayUnits: "actuals",
1684
- currencySignDisplay: "all"
1685
- });
1686
- var FinanceDecimalsContext = React3.createContext(0);
1687
- function FinanceDisplayProvider({
1688
- decimals,
1689
- displayUnits = "actuals",
1690
- currencySignDisplay = "all",
1691
- children
1692
- }) {
1693
- const value = React3.useMemo(
1694
- () => ({ decimals, displayUnits, currencySignDisplay }),
1695
- [decimals, displayUnits, currencySignDisplay]
1696
- );
1697
- return /* @__PURE__ */ jsx(FinanceDisplayContext.Provider, { value, children: /* @__PURE__ */ jsx(FinanceDecimalsContext.Provider, { value: decimals, children }) });
1698
- }
1699
- function FinanceDecimalsProvider({
1700
- decimals,
1701
- children
1702
- }) {
1703
- return /* @__PURE__ */ jsx(FinanceDisplayProvider, { decimals, children });
1704
- }
1705
- function useFinanceDecimals() {
1706
- return React3.useContext(FinanceDecimalsContext);
1707
- }
1708
- function useFinanceDisplay() {
1709
- return React3.useContext(FinanceDisplayContext);
1710
- }
1711
- function getUnitDivisor(units) {
1712
- switch (units) {
1713
- case "thousands":
1714
- return 1e3;
1715
- case "millions":
1716
- return 1e6;
1717
- default:
1718
- return 1;
1719
- }
1720
- }
1721
- function getUnitLabel(units) {
1722
- switch (units) {
1723
- case "thousands":
1724
- return "in thousands";
1725
- case "millions":
1726
- return "in millions";
1727
- default:
1728
- return null;
1729
- }
1730
- }
1731
- function getUnitSuffix(units) {
1732
- switch (units) {
1733
- case "thousands":
1734
- return "(000s)";
1735
- case "millions":
1736
- return "(M)";
1737
- default:
1738
- return null;
1739
- }
1740
- }
1741
- function useFinanceDecimalsSetting(storageKey = "finance-decimal-places", defaultValue = 0) {
1742
- const [decimals, setDecimalsState] = React3.useState(() => {
1743
- if (typeof window === "undefined") return defaultValue;
1744
- const stored = localStorage.getItem(storageKey);
1745
- return stored !== null ? Number(stored) : defaultValue;
1746
- });
1747
- const setDecimals = React3.useCallback(
1748
- (v) => {
1749
- setDecimalsState(v);
1750
- if (typeof window !== "undefined") {
1751
- localStorage.setItem(storageKey, String(v));
1752
- }
1753
- },
1754
- [storageKey]
1755
- );
1756
- return [decimals, setDecimals];
1757
- }
1758
- var formatterCache = /* @__PURE__ */ new Map();
1759
- function getFormatter(locale, currencyCode, decimals) {
1760
- const key = `${locale}:${currencyCode}:${decimals}`;
1761
- let fmt = formatterCache.get(key);
1762
- if (!fmt) {
1763
- fmt = new Intl.NumberFormat(locale, {
1764
- style: "currency",
1765
- currency: currencyCode,
1766
- minimumFractionDigits: decimals,
1767
- maximumFractionDigits: decimals
1768
- });
1769
- formatterCache.set(key, fmt);
1770
- }
1771
- return fmt;
1772
- }
1773
- function formatCurrencyValue(value, options) {
1774
- const raw = value ?? 0;
1775
- const divisor = getUnitDivisor(options?.displayUnits ?? "actuals");
1776
- const v = divisor === 1 ? raw : raw / divisor;
1777
- const isZero = raw === 0;
1778
- const isNegative = v < 0;
1779
- const curr = options?.currency ?? "USD";
1780
- const locale = options?.locale ?? "en-US";
1781
- const dashZero = options?.dashZero ?? false;
1782
- const decimals = options?.decimals ?? 2;
1783
- const showSign = options?.showCurrencySign ?? true;
1784
- if (isZero && dashZero) {
1785
- return { text: "\u2014", isNegative: false, isZero: true };
1786
- }
1787
- const absV = Math.abs(v);
1788
- let formatted;
1789
- if (showSign) {
1790
- const fmt = getFormatter(locale, curr, decimals);
1791
- formatted = fmt.format(absV);
1792
- } else {
1793
- formatted = absV.toLocaleString(locale, {
1794
- minimumFractionDigits: decimals,
1795
- maximumFractionDigits: decimals
1796
- });
1797
- }
1798
- if (isNegative) {
1799
- return { text: `(${formatted})`, isNegative: true, isZero: false };
1800
- }
1801
- return { text: formatted, isNegative: false, isZero };
1802
- }
1803
- function DataTableCurrencyCell({
1804
- value,
1805
- currency: currencyCode = "USD",
1806
- locale = "en-US",
1807
- dashZero = false,
1808
- decimals,
1809
- className,
1810
- /** Whether this cell is in a summary/total row */
1811
- isSummaryRow
1812
- }) {
1813
- const ctx = useFinanceDisplay();
1814
- const resolvedDecimals = decimals ?? ctx.decimals;
1815
- const showCurrencySign = ctx.currencySignDisplay === "all" || ctx.currencySignDisplay === "summary" && isSummaryRow;
1816
- const { text, isNegative, isZero } = formatCurrencyValue(value, {
1817
- currency: currencyCode,
1818
- locale,
1819
- dashZero,
1820
- decimals: resolvedDecimals,
1821
- displayUnits: ctx.displayUnits,
1822
- showCurrencySign
1823
- });
1824
- return /* @__PURE__ */ jsx(
1825
- "span",
1826
- {
1827
- className: cn(
1828
- "font-mono tabular-nums",
1829
- isNegative && "text-red-600 dark:text-red-400",
1830
- isZero && dashZero && "text-muted-foreground",
1831
- className
1832
- ),
1833
- children: text
1834
- }
1835
- );
1836
- }
1837
-
1838
- // src/blocks/data-table/financialStatementRowImportance.ts
1839
- var DEFAULT_ROW_IMPORTANCE_CONFIG = {
1840
- "income-statement": {
1841
- emphasis: ["Total Revenue", "Total Expenses", "Operating Income"],
1842
- keySummary: ["Net Income"]
1843
- },
1844
- "balance-sheet": {
1845
- emphasis: ["Total Liabilities", "Total Equity"],
1846
- keySummary: ["Total Assets", "Total Liabilities & Equity"]
1847
- },
1848
- "cash-flow": {
1849
- emphasis: [
1850
- "Total Operating Activities",
1851
- "Total Investing Activities",
1852
- "Total Financing Activities",
1853
- "Net Cash from Operating Activities",
1854
- "Net Cash from Investing Activities",
1855
- "Net Cash from Financing Activities"
1856
- ],
1857
- keySummary: [
1858
- "Net Change in Cash",
1859
- "Ending Cash",
1860
- "Total Cash & Cash Equivalents"
1861
- ]
1862
- },
1863
- "working-capital": {
1864
- emphasis: ["Total Current Assets", "Total Current Liabilities"],
1865
- keySummary: ["NWC", "Net Working Capital"]
1866
- }
1867
- };
1868
- function normalizeLabel(value) {
1869
- return value.trim().toLowerCase().replace(/\s+/g, " ");
1870
- }
1871
- function createFinancialStatementRowImportanceResolver(kind, overrides) {
1872
- const base = DEFAULT_ROW_IMPORTANCE_CONFIG[kind];
1873
- const emphasis = new Set(
1874
- (overrides?.emphasis ?? base?.emphasis ?? []).map(normalizeLabel)
1875
- );
1876
- const keySummary = new Set(
1877
- (overrides?.keySummary ?? base?.keySummary ?? []).map(normalizeLabel)
1878
- );
1879
- return (row) => {
1880
- const label = normalizeLabel(row.name);
1881
- if (keySummary.has(label)) return "key-summary";
1882
- if (emphasis.has(label)) return "emphasis";
1883
- return "normal";
1884
- };
1885
- }
1886
- function getFinancialStatementRowImportanceClassName(importance) {
1887
- switch (importance) {
1888
- case "emphasis":
1889
- return "bg-muted/25 border-t border-border/50 font-medium";
1890
- case "key-summary":
1891
- return "bg-muted/45 border-t-2 border-border/70 font-semibold";
1892
- default:
1893
- return void 0;
1894
- }
1895
- }
1896
1749
  var TOLERANCE = 0.01;
1897
1750
  function RecCheck({ computed, raw }) {
1898
1751
  const diff = Math.abs(computed - raw);
@@ -2685,25 +2538,25 @@ function FinancialStatementTable({
2685
2538
  className,
2686
2539
  rowImportanceResolver
2687
2540
  }) {
2688
- const [expanded, setExpanded] = React3.useState({});
2689
- const [columnVisibility, setColumnVisibility] = React3.useState({});
2690
- const [viewportLayout, setViewportLayout] = React3.useState("unknown");
2691
- const { rows: rawRows, periods } = React3.useMemo(
2541
+ const [expanded, setExpanded] = React4.useState({});
2542
+ const [columnVisibility, setColumnVisibility] = React4.useState({});
2543
+ const [viewportLayout, setViewportLayout] = React4.useState("unknown");
2544
+ const { rows: rawRows, periods } = React4.useMemo(
2692
2545
  () => buildFinancialStatementData(data, config, timeUnit, subtotalRules, {
2693
2546
  preserveEmptySections
2694
2547
  }),
2695
2548
  [data, config, timeUnit, subtotalRules, preserveEmptySections]
2696
2549
  );
2697
- const rows = React3.useMemo(
2550
+ const rows = React4.useMemo(
2698
2551
  () => hideZeroRows ? filterZeroRows(rawRows) : rawRows,
2699
2552
  [rawRows, hideZeroRows]
2700
2553
  );
2701
- const orderedPeriods = React3.useMemo(
2554
+ const orderedPeriods = React4.useMemo(
2702
2555
  () => resolvePeriodColumns(periods, timeUnit, periodOrder, periodColumnOrder),
2703
2556
  [periods, timeUnit, periodOrder, periodColumnOrder]
2704
2557
  );
2705
2558
  const effectiveShowRowTotals = isMobile && mobileCompareEnabled ? false : showRowTotals;
2706
- const columns = React3.useMemo(
2559
+ const columns = React4.useMemo(
2707
2560
  () => buildColumns(
2708
2561
  orderedPeriods,
2709
2562
  timeUnit,
@@ -2735,7 +2588,7 @@ function FinancialStatementTable({
2735
2588
  accountColumnMenuItems
2736
2589
  ]
2737
2590
  );
2738
- React3.useEffect(() => {
2591
+ React4.useEffect(() => {
2739
2592
  if (typeof window === "undefined") return;
2740
2593
  const updateViewportLayout = () => {
2741
2594
  setViewportLayout(
@@ -2750,7 +2603,7 @@ function FinancialStatementTable({
2750
2603
  window.removeEventListener("orientationchange", updateViewportLayout);
2751
2604
  };
2752
2605
  }, []);
2753
- React3.useEffect(() => {
2606
+ React4.useEffect(() => {
2754
2607
  if (rows.length === 0) return;
2755
2608
  const toExpand = {};
2756
2609
  for (const row of rows) {
@@ -2859,74 +2712,4 @@ var BALANCE_SHEET_CONFIG = {
2859
2712
  ]
2860
2713
  };
2861
2714
 
2862
- // src/hooks/spreadsheetWorkbook.ts
2863
- function escapeXml(value) {
2864
- return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
2865
- }
2866
- function styleId(style) {
2867
- if (!style) return void 0;
2868
- const map = {
2869
- header: "Header",
2870
- text: "Text",
2871
- number: "Number",
2872
- currency: "Currency",
2873
- percent: "Percent",
2874
- totalLabel: "TotalLabel",
2875
- totalNumber: "TotalNumber"
2876
- };
2877
- return map[style];
2878
- }
2879
- function excelColumnName(columnIndex) {
2880
- let n = columnIndex + 1;
2881
- let result = "";
2882
- while (n > 0) {
2883
- const rem = (n - 1) % 26;
2884
- result = String.fromCharCode(65 + rem) + result;
2885
- n = Math.floor((n - 1) / 26);
2886
- }
2887
- return result;
2888
- }
2889
- function buildSpreadsheetWorkbookXml({
2890
- worksheetName,
2891
- rows
2892
- }) {
2893
- const xmlRows = rows.map(
2894
- (row) => `<Row>${row.map((cell) => {
2895
- const inferredType = cell.type ?? (typeof cell.value === "number" || cell.formula ? "Number" : "String");
2896
- const rawValue = cell.value ?? "";
2897
- const value = inferredType === "Number" ? Number(rawValue || 0) : escapeXml(String(rawValue));
2898
- const style = styleId(cell.style);
2899
- const styleAttr = style ? ` ss:StyleID="${style}"` : "";
2900
- const formulaAttr = cell.formula ? ` ss:Formula="=${escapeXml(cell.formula)}"` : "";
2901
- return `<Cell${styleAttr}${formulaAttr}><Data ss:Type="${inferredType}">${value}</Data></Cell>`;
2902
- }).join("")}</Row>`
2903
- ).join("\n");
2904
- return `<?xml version="1.0" encoding="UTF-8"?>
2905
- <?mso-application progid="Excel.Sheet"?>
2906
- <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
2907
- <Styles>
2908
- <Style ss:ID="Header"><Font ss:Bold="1"/><Interior ss:Color="#F3F4F6" ss:Pattern="Solid"/></Style>
2909
- <Style ss:ID="Text"><NumberFormat ss:Format="@"/></Style>
2910
- <Style ss:ID="Number"><NumberFormat ss:Format="#,##0.00"/></Style>
2911
- <Style ss:ID="Currency"><NumberFormat ss:Format="$#,##0.00;[Red]($#,##0.00)"/></Style>
2912
- <Style ss:ID="Percent"><NumberFormat ss:Format="0.00%"/></Style>
2913
- <Style ss:ID="TotalLabel"><Font ss:Bold="1"/><Interior ss:Color="#F9FAFB" ss:Pattern="Solid"/></Style>
2914
- <Style ss:ID="TotalNumber"><Font ss:Bold="1"/><NumberFormat ss:Format="$#,##0.00;[Red]($#,##0.00)"/><Interior ss:Color="#F9FAFB" ss:Pattern="Solid"/></Style>
2915
- </Styles>
2916
- <Worksheet ss:Name="${escapeXml(worksheetName)}"><Table>
2917
- ${xmlRows}
2918
- </Table></Worksheet></Workbook>`;
2919
- }
2920
- function downloadExcelXml(xml, filename) {
2921
- const blob = new Blob([xml], {
2922
- type: "application/vnd.ms-excel;charset=utf-8;"
2923
- });
2924
- const url = URL.createObjectURL(blob);
2925
- const link = document.createElement("a");
2926
- link.href = url;
2927
- link.download = `${filename}.xls`;
2928
- link.click();
2929
- URL.revokeObjectURL(url);
2930
- }
2931
-
2932
- export { BALANCE_SHEET_CONFIG, DataTable, DataTableColumnFilter, DataTableColumnFilterContent, DataTableColumnHeader, DataTableContext, DataTableCurrencyCell, DataTableFilterBadges, FinanceDecimalsProvider, FinanceDisplayProvider, FinancialStatementTable, INCOME_STATEMENT_CONFIG, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, buildFinancialStatementData, buildSpreadsheetWorkbookXml, calculateDesktopFinancialColumnSizing, createFinancialStatementRowImportanceResolver, downloadExcelXml, excelColumnName, flattenStatementForExport, formatCurrencyValue, getFinancialStatementRowImportanceClassName, getUnitDivisor, getUnitLabel, getUnitSuffix, resolvePeriodColumns, useDataTableContext, useFinanceDecimals, useFinanceDecimalsSetting, useFinanceDisplay };
2715
+ export { BALANCE_SHEET_CONFIG, DataTableCurrencyCell, FinanceDecimalsProvider, FinanceDisplayProvider, FinancialStatementTable, INCOME_STATEMENT_CONFIG, buildFinancialStatementData, calculateDesktopFinancialColumnSizing, createFinancialStatementRowImportanceResolver, flattenStatementForExport, formatCurrencyValue, getFinancialStatementRowImportanceClassName, getUnitDivisor, getUnitLabel, getUnitSuffix, resolvePeriodColumns, useFinanceDecimals, useFinanceDecimalsSetting, useFinanceDisplay };