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