@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,17 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
var chunkLABHD4PU_js = require('./chunk-LABHD4PU.js');
|
|
4
5
|
var chunkWOITB4JL_js = require('./chunk-WOITB4JL.js');
|
|
5
6
|
var chunk6TGV2DNP_js = require('./chunk-6TGV2DNP.js');
|
|
6
7
|
var chunkJ6OLBSZR_js = require('./chunk-J6OLBSZR.js');
|
|
7
8
|
var chunkSORWLKOK_js = require('./chunk-SORWLKOK.js');
|
|
8
9
|
var chunkDQWHYBV2_js = require('./chunk-DQWHYBV2.js');
|
|
9
10
|
var chunkADIDI7AJ_js = require('./chunk-ADIDI7AJ.js');
|
|
10
|
-
var
|
|
11
|
+
var React4 = require('react');
|
|
11
12
|
var jsxRuntime = require('react/jsx-runtime');
|
|
12
|
-
var lucideReact = require('lucide-react');
|
|
13
|
-
var React3 = require('react');
|
|
14
13
|
var reactTable = require('@tanstack/react-table');
|
|
14
|
+
var lucideReact = require('lucide-react');
|
|
15
15
|
|
|
16
16
|
function _interopNamespace(e) {
|
|
17
17
|
if (e && e.__esModule) return e;
|
|
@@ -31,125 +31,222 @@ function _interopNamespace(e) {
|
|
|
31
31
|
return Object.freeze(n);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
var
|
|
35
|
-
var React3__namespace = /*#__PURE__*/_interopNamespace(React3);
|
|
34
|
+
var React4__namespace = /*#__PURE__*/_interopNamespace(React4);
|
|
36
35
|
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
var FinanceDisplayContext = React4__namespace.createContext({
|
|
37
|
+
decimals: 0,
|
|
38
|
+
displayUnits: "actuals",
|
|
39
|
+
currencySignDisplay: "all"
|
|
40
|
+
});
|
|
41
|
+
var FinanceDecimalsContext = React4__namespace.createContext(0);
|
|
42
|
+
function FinanceDisplayProvider({
|
|
43
|
+
decimals,
|
|
44
|
+
displayUnits = "actuals",
|
|
45
|
+
currencySignDisplay = "all",
|
|
46
|
+
children
|
|
45
47
|
}) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
className: chunkADIDI7AJ_js.cn(
|
|
52
|
-
"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",
|
|
53
|
-
className
|
|
54
|
-
),
|
|
55
|
-
...props
|
|
56
|
-
}
|
|
57
|
-
) });
|
|
48
|
+
const value = React4__namespace.useMemo(
|
|
49
|
+
() => ({ decimals, displayUnits, currencySignDisplay }),
|
|
50
|
+
[decimals, displayUnits, currencySignDisplay]
|
|
51
|
+
);
|
|
52
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FinanceDisplayContext.Provider, { value, children: /* @__PURE__ */ jsxRuntime.jsx(FinanceDecimalsContext.Provider, { value: decimals, children }) });
|
|
58
53
|
}
|
|
59
|
-
function
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
className: chunkADIDI7AJ_js.cn("w-full caption-bottom text-sm", className),
|
|
65
|
-
...props
|
|
66
|
-
}
|
|
67
|
-
) });
|
|
54
|
+
function FinanceDecimalsProvider({
|
|
55
|
+
decimals,
|
|
56
|
+
children
|
|
57
|
+
}) {
|
|
58
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FinanceDisplayProvider, { decimals, children });
|
|
68
59
|
}
|
|
69
|
-
function
|
|
70
|
-
return
|
|
71
|
-
"thead",
|
|
72
|
-
{
|
|
73
|
-
"data-slot": "table-header",
|
|
74
|
-
className: chunkADIDI7AJ_js.cn("[&_tr]:border-b", className),
|
|
75
|
-
...props
|
|
76
|
-
}
|
|
77
|
-
);
|
|
60
|
+
function useFinanceDecimals() {
|
|
61
|
+
return React4__namespace.useContext(FinanceDecimalsContext);
|
|
78
62
|
}
|
|
79
|
-
function
|
|
80
|
-
return
|
|
81
|
-
"tbody",
|
|
82
|
-
{
|
|
83
|
-
"data-slot": "table-body",
|
|
84
|
-
className: chunkADIDI7AJ_js.cn("[&_tr:last-child]:border-0", className),
|
|
85
|
-
...props
|
|
86
|
-
}
|
|
87
|
-
);
|
|
63
|
+
function useFinanceDisplay() {
|
|
64
|
+
return React4__namespace.useContext(FinanceDisplayContext);
|
|
88
65
|
}
|
|
89
|
-
function
|
|
90
|
-
|
|
91
|
-
"
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
...props
|
|
99
|
-
}
|
|
100
|
-
);
|
|
66
|
+
function getUnitDivisor(units) {
|
|
67
|
+
switch (units) {
|
|
68
|
+
case "thousands":
|
|
69
|
+
return 1e3;
|
|
70
|
+
case "millions":
|
|
71
|
+
return 1e6;
|
|
72
|
+
default:
|
|
73
|
+
return 1;
|
|
74
|
+
}
|
|
101
75
|
}
|
|
102
|
-
function
|
|
103
|
-
|
|
104
|
-
"
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
...props
|
|
112
|
-
}
|
|
113
|
-
);
|
|
76
|
+
function getUnitLabel(units) {
|
|
77
|
+
switch (units) {
|
|
78
|
+
case "thousands":
|
|
79
|
+
return "in thousands";
|
|
80
|
+
case "millions":
|
|
81
|
+
return "in millions";
|
|
82
|
+
default:
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
114
85
|
}
|
|
115
|
-
function
|
|
116
|
-
|
|
117
|
-
"
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
86
|
+
function getUnitSuffix(units) {
|
|
87
|
+
switch (units) {
|
|
88
|
+
case "thousands":
|
|
89
|
+
return "(000s)";
|
|
90
|
+
case "millions":
|
|
91
|
+
return "(M)";
|
|
92
|
+
default:
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function useFinanceDecimalsSetting(storageKey = "finance-decimal-places", defaultValue = 0) {
|
|
97
|
+
const [decimals, setDecimalsState] = React4__namespace.useState(() => {
|
|
98
|
+
if (typeof window === "undefined") return defaultValue;
|
|
99
|
+
const stored = localStorage.getItem(storageKey);
|
|
100
|
+
return stored !== null ? Number(stored) : defaultValue;
|
|
101
|
+
});
|
|
102
|
+
const setDecimals = React4__namespace.useCallback(
|
|
103
|
+
(v) => {
|
|
104
|
+
setDecimalsState(v);
|
|
105
|
+
if (typeof window !== "undefined") {
|
|
106
|
+
localStorage.setItem(storageKey, String(v));
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
[storageKey]
|
|
126
110
|
);
|
|
111
|
+
return [decimals, setDecimals];
|
|
112
|
+
}
|
|
113
|
+
var formatterCache = /* @__PURE__ */ new Map();
|
|
114
|
+
function getFormatter(locale, currencyCode, decimals) {
|
|
115
|
+
const key = `${locale}:${currencyCode}:${decimals}`;
|
|
116
|
+
let fmt = formatterCache.get(key);
|
|
117
|
+
if (!fmt) {
|
|
118
|
+
fmt = new Intl.NumberFormat(locale, {
|
|
119
|
+
style: "currency",
|
|
120
|
+
currency: currencyCode,
|
|
121
|
+
minimumFractionDigits: decimals,
|
|
122
|
+
maximumFractionDigits: decimals
|
|
123
|
+
});
|
|
124
|
+
formatterCache.set(key, fmt);
|
|
125
|
+
}
|
|
126
|
+
return fmt;
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function formatCurrencyValue(value, options) {
|
|
129
|
+
const raw = value ?? 0;
|
|
130
|
+
const divisor = getUnitDivisor(options?.displayUnits ?? "actuals");
|
|
131
|
+
const v = divisor === 1 ? raw : raw / divisor;
|
|
132
|
+
const isZero = raw === 0;
|
|
133
|
+
const isNegative = v < 0;
|
|
134
|
+
const curr = options?.currency ?? "USD";
|
|
135
|
+
const locale = options?.locale ?? "en-US";
|
|
136
|
+
const dashZero = options?.dashZero ?? false;
|
|
137
|
+
const decimals = options?.decimals ?? 2;
|
|
138
|
+
const showSign = options?.showCurrencySign ?? true;
|
|
139
|
+
if (isZero && dashZero) {
|
|
140
|
+
return { text: "\u2014", isNegative: false, isZero: true };
|
|
141
|
+
}
|
|
142
|
+
const absV = Math.abs(v);
|
|
143
|
+
let formatted;
|
|
144
|
+
if (showSign) {
|
|
145
|
+
const fmt = getFormatter(locale, curr, decimals);
|
|
146
|
+
formatted = fmt.format(absV);
|
|
147
|
+
} else {
|
|
148
|
+
formatted = absV.toLocaleString(locale, {
|
|
149
|
+
minimumFractionDigits: decimals,
|
|
150
|
+
maximumFractionDigits: decimals
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
if (isNegative) {
|
|
154
|
+
return { text: `(${formatted})`, isNegative: true, isZero: false };
|
|
155
|
+
}
|
|
156
|
+
return { text: formatted, isNegative: false, isZero };
|
|
157
|
+
}
|
|
158
|
+
function DataTableCurrencyCell({
|
|
159
|
+
value,
|
|
160
|
+
currency: currencyCode = "USD",
|
|
161
|
+
locale = "en-US",
|
|
162
|
+
dashZero = false,
|
|
163
|
+
decimals,
|
|
164
|
+
className,
|
|
165
|
+
/** Whether this cell is in a summary/total row */
|
|
166
|
+
isSummaryRow
|
|
167
|
+
}) {
|
|
168
|
+
const ctx = useFinanceDisplay();
|
|
169
|
+
const resolvedDecimals = decimals ?? ctx.decimals;
|
|
170
|
+
const showCurrencySign = ctx.currencySignDisplay === "all" || ctx.currencySignDisplay === "summary" && isSummaryRow;
|
|
171
|
+
const { text, isNegative, isZero } = formatCurrencyValue(value, {
|
|
172
|
+
currency: currencyCode,
|
|
173
|
+
locale,
|
|
174
|
+
dashZero,
|
|
175
|
+
decimals: resolvedDecimals,
|
|
176
|
+
displayUnits: ctx.displayUnits,
|
|
177
|
+
showCurrencySign
|
|
178
|
+
});
|
|
129
179
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
130
|
-
"
|
|
180
|
+
"span",
|
|
131
181
|
{
|
|
132
|
-
"data-slot": "table-cell",
|
|
133
182
|
className: chunkADIDI7AJ_js.cn(
|
|
134
|
-
"
|
|
183
|
+
"font-mono tabular-nums",
|
|
184
|
+
isNegative && "text-red-600 dark:text-red-400",
|
|
185
|
+
isZero && dashZero && "text-muted-foreground",
|
|
135
186
|
className
|
|
136
187
|
),
|
|
137
|
-
|
|
188
|
+
children: text
|
|
138
189
|
}
|
|
139
190
|
);
|
|
140
191
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
"
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
192
|
+
|
|
193
|
+
// src/blocks/finance/financialStatementRowImportance.ts
|
|
194
|
+
var DEFAULT_ROW_IMPORTANCE_CONFIG = {
|
|
195
|
+
"income-statement": {
|
|
196
|
+
emphasis: ["Total Revenue", "Total Expenses", "Operating Income"],
|
|
197
|
+
keySummary: ["Net Income"]
|
|
198
|
+
},
|
|
199
|
+
"balance-sheet": {
|
|
200
|
+
emphasis: ["Total Liabilities", "Total Equity"],
|
|
201
|
+
keySummary: ["Total Assets", "Total Liabilities & Equity"]
|
|
202
|
+
},
|
|
203
|
+
"cash-flow": {
|
|
204
|
+
emphasis: [
|
|
205
|
+
"Total Operating Activities",
|
|
206
|
+
"Total Investing Activities",
|
|
207
|
+
"Total Financing Activities",
|
|
208
|
+
"Net Cash from Operating Activities",
|
|
209
|
+
"Net Cash from Investing Activities",
|
|
210
|
+
"Net Cash from Financing Activities"
|
|
211
|
+
],
|
|
212
|
+
keySummary: [
|
|
213
|
+
"Net Change in Cash",
|
|
214
|
+
"Ending Cash",
|
|
215
|
+
"Total Cash & Cash Equivalents"
|
|
216
|
+
]
|
|
217
|
+
},
|
|
218
|
+
"working-capital": {
|
|
219
|
+
emphasis: ["Total Current Assets", "Total Current Liabilities"],
|
|
220
|
+
keySummary: ["NWC", "Net Working Capital"]
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
function normalizeLabel(value) {
|
|
224
|
+
return value.trim().toLowerCase().replace(/\s+/g, " ");
|
|
225
|
+
}
|
|
226
|
+
function createFinancialStatementRowImportanceResolver(kind, overrides) {
|
|
227
|
+
const base = DEFAULT_ROW_IMPORTANCE_CONFIG[kind];
|
|
228
|
+
const emphasis = new Set(
|
|
229
|
+
(overrides?.emphasis ?? base?.emphasis ?? []).map(normalizeLabel)
|
|
152
230
|
);
|
|
231
|
+
const keySummary = new Set(
|
|
232
|
+
(overrides?.keySummary ?? base?.keySummary ?? []).map(normalizeLabel)
|
|
233
|
+
);
|
|
234
|
+
return (row) => {
|
|
235
|
+
const label = normalizeLabel(row.name);
|
|
236
|
+
if (keySummary.has(label)) return "key-summary";
|
|
237
|
+
if (emphasis.has(label)) return "emphasis";
|
|
238
|
+
return "normal";
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
function getFinancialStatementRowImportanceClassName(importance) {
|
|
242
|
+
switch (importance) {
|
|
243
|
+
case "emphasis":
|
|
244
|
+
return "bg-muted/25 border-t border-border/50 font-medium";
|
|
245
|
+
case "key-summary":
|
|
246
|
+
return "bg-muted/45 border-t-2 border-border/70 font-semibold";
|
|
247
|
+
default:
|
|
248
|
+
return void 0;
|
|
249
|
+
}
|
|
153
250
|
}
|
|
154
251
|
var colorMap = {
|
|
155
252
|
green: "#22c55e",
|
|
@@ -226,16 +323,16 @@ function DataTableColumnFilterContent({
|
|
|
226
323
|
placeholder,
|
|
227
324
|
showDeleteMenu = true
|
|
228
325
|
}) {
|
|
229
|
-
const [localValue, setLocalValue] =
|
|
230
|
-
const [operator, setOperator] =
|
|
231
|
-
|
|
326
|
+
const [localValue, setLocalValue] = React4__namespace.useState(value ?? "");
|
|
327
|
+
const [operator, setOperator] = React4__namespace.useState("is");
|
|
328
|
+
React4__namespace.useEffect(() => setLocalValue(value ?? ""), [value]);
|
|
232
329
|
const handleApply = () => onChange(localValue || void 0);
|
|
233
330
|
const handleClear = () => {
|
|
234
331
|
setLocalValue("");
|
|
235
332
|
onClear?.();
|
|
236
333
|
onChange(void 0);
|
|
237
334
|
};
|
|
238
|
-
const selectedValues =
|
|
335
|
+
const selectedValues = React4__namespace.useMemo(() => {
|
|
239
336
|
if (!localValue) return /* @__PURE__ */ new Set();
|
|
240
337
|
return new Set(localValue.split(",").filter(Boolean));
|
|
241
338
|
}, [localValue]);
|
|
@@ -359,7 +456,7 @@ function DataTableColumnFilterContent({
|
|
|
359
456
|
const colorValue = opt.color ? getColorValue(opt.color) : void 0;
|
|
360
457
|
let iconElement = null;
|
|
361
458
|
if (opt.icon) {
|
|
362
|
-
if (
|
|
459
|
+
if (React4__namespace.isValidElement(opt.icon)) {
|
|
363
460
|
iconElement = opt.icon;
|
|
364
461
|
} else {
|
|
365
462
|
const Icon = opt.icon;
|
|
@@ -415,37 +512,6 @@ function DataTableColumnFilterContent({
|
|
|
415
512
|
) })
|
|
416
513
|
] });
|
|
417
514
|
}
|
|
418
|
-
function DataTableColumnFilter({
|
|
419
|
-
column,
|
|
420
|
-
title,
|
|
421
|
-
filterType = "text",
|
|
422
|
-
filterOptions,
|
|
423
|
-
placeholder,
|
|
424
|
-
children,
|
|
425
|
-
onFilterChange
|
|
426
|
-
}) {
|
|
427
|
-
const [open, setOpen] = React3__namespace.useState(false);
|
|
428
|
-
const current = column.getFilterValue();
|
|
429
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
430
|
-
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children }),
|
|
431
|
-
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { align: "start", className: "w-56 p-0", sideOffset: 4, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
432
|
-
DataTableColumnFilterContent,
|
|
433
|
-
{
|
|
434
|
-
title,
|
|
435
|
-
value: current,
|
|
436
|
-
onChange: (v) => {
|
|
437
|
-
column.setFilterValue(v);
|
|
438
|
-
onFilterChange?.(column.id, v);
|
|
439
|
-
},
|
|
440
|
-
onClear: () => column.setFilterValue(void 0),
|
|
441
|
-
filterType,
|
|
442
|
-
filterOptions,
|
|
443
|
-
placeholder,
|
|
444
|
-
showDeleteMenu: false
|
|
445
|
-
}
|
|
446
|
-
) })
|
|
447
|
-
] });
|
|
448
|
-
}
|
|
449
515
|
function DataTableFilterBadges({
|
|
450
516
|
filters,
|
|
451
517
|
onRemoveFilter,
|
|
@@ -474,7 +540,7 @@ function DataTableFilterBadges({
|
|
|
474
540
|
"text-xs hover:bg-sky-100 dark:hover:bg-sky-900/40 transition-colors cursor-pointer"
|
|
475
541
|
),
|
|
476
542
|
children: [
|
|
477
|
-
filter.icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground shrink-0 [&>svg]:size-3", children:
|
|
543
|
+
filter.icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground shrink-0 [&>svg]:size-3", children: React4__namespace.isValidElement(filter.icon) ? filter.icon : (() => {
|
|
478
544
|
const Icon = filter.icon;
|
|
479
545
|
return /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "size-3" });
|
|
480
546
|
})() }),
|
|
@@ -545,16 +611,16 @@ function DataTableFilterBadges({
|
|
|
545
611
|
}
|
|
546
612
|
);
|
|
547
613
|
}
|
|
548
|
-
var DataTableContext =
|
|
614
|
+
var DataTableContext = React4__namespace.createContext(null);
|
|
549
615
|
function useDataTableContext() {
|
|
550
|
-
return
|
|
616
|
+
return React4__namespace.useContext(DataTableContext);
|
|
551
617
|
}
|
|
552
618
|
function TreeExpandCycleButton({
|
|
553
619
|
table,
|
|
554
620
|
density
|
|
555
621
|
}) {
|
|
556
|
-
const depthRef =
|
|
557
|
-
const maxDepth =
|
|
622
|
+
const depthRef = React4__namespace.useRef(-1);
|
|
623
|
+
const maxDepth = React4__namespace.useMemo(() => {
|
|
558
624
|
let max = 0;
|
|
559
625
|
const walk = (rows) => {
|
|
560
626
|
for (const row of rows) {
|
|
@@ -567,7 +633,7 @@ function TreeExpandCycleButton({
|
|
|
567
633
|
);
|
|
568
634
|
return max;
|
|
569
635
|
}, [table]);
|
|
570
|
-
const handleClick =
|
|
636
|
+
const handleClick = React4__namespace.useCallback(() => {
|
|
571
637
|
const nextDepth = depthRef.current + 1;
|
|
572
638
|
if (nextDepth > maxDepth) {
|
|
573
639
|
table.toggleAllRowsExpanded(false);
|
|
@@ -658,21 +724,21 @@ function DataTable({
|
|
|
658
724
|
md: "size-3",
|
|
659
725
|
lg: "size-3.5"
|
|
660
726
|
}[fontSize];
|
|
661
|
-
const [columnSizing, setColumnSizing] =
|
|
662
|
-
const [resizingColumn, setResizingColumn] =
|
|
727
|
+
const [columnSizing, setColumnSizing] = React4__namespace.useState({});
|
|
728
|
+
const [resizingColumn, setResizingColumn] = React4__namespace.useState(
|
|
663
729
|
null
|
|
664
730
|
);
|
|
665
|
-
const [hoveredRowId, setHoveredRowId] =
|
|
666
|
-
const defaultColumnOrder =
|
|
731
|
+
const [hoveredRowId, setHoveredRowId] = React4__namespace.useState(null);
|
|
732
|
+
const defaultColumnOrder = React4__namespace.useMemo(
|
|
667
733
|
() => columns.map(
|
|
668
734
|
(col) => col.id ? col.id : "accessorKey" in col ? String(col.accessorKey) : ""
|
|
669
735
|
),
|
|
670
736
|
[columns]
|
|
671
737
|
);
|
|
672
|
-
const [internalColumnOrder, setInternalColumnOrder] =
|
|
738
|
+
const [internalColumnOrder, setInternalColumnOrder] = React4__namespace.useState(defaultColumnOrder);
|
|
673
739
|
const columnOrder = externalColumnOrder ?? internalColumnOrder;
|
|
674
740
|
const setColumnOrder = onColumnOrderChange ?? setInternalColumnOrder;
|
|
675
|
-
const renderedLeafColumns =
|
|
741
|
+
const renderedLeafColumns = React4__namespace.useMemo(() => {
|
|
676
742
|
let leafColumns = table.getVisibleLeafColumns();
|
|
677
743
|
if (rowSelectionStyle === "hover" || enableRowDrag) {
|
|
678
744
|
leafColumns = leafColumns.filter((column) => column.id !== "select");
|
|
@@ -688,14 +754,14 @@ function DataTable({
|
|
|
688
754
|
}
|
|
689
755
|
return leafColumns;
|
|
690
756
|
}, [table, rowSelectionStyle, enableRowDrag, enableColumnDrag, columnOrder]);
|
|
691
|
-
const renderedLeafIndexById =
|
|
757
|
+
const renderedLeafIndexById = React4__namespace.useMemo(() => {
|
|
692
758
|
const indexById = /* @__PURE__ */ new Map();
|
|
693
759
|
renderedLeafColumns.forEach((column, index) => {
|
|
694
760
|
indexById.set(column.id, index);
|
|
695
761
|
});
|
|
696
762
|
return indexById;
|
|
697
763
|
}, [renderedLeafColumns]);
|
|
698
|
-
const stickyLeafColumns =
|
|
764
|
+
const stickyLeafColumns = React4__namespace.useMemo(() => {
|
|
699
765
|
if (explicitStickyColumnIds && explicitStickyColumnIds.length > 0) {
|
|
700
766
|
const stickyIdSet = new Set(explicitStickyColumnIds);
|
|
701
767
|
return renderedLeafColumns.filter((column) => stickyIdSet.has(column.id));
|
|
@@ -703,11 +769,11 @@ function DataTable({
|
|
|
703
769
|
if (!stickyColumns || stickyColumns <= 0) return [];
|
|
704
770
|
return renderedLeafColumns.slice(0, stickyColumns);
|
|
705
771
|
}, [renderedLeafColumns, stickyColumns, explicitStickyColumnIds]);
|
|
706
|
-
const stickyColumnIds =
|
|
772
|
+
const stickyColumnIds = React4__namespace.useMemo(
|
|
707
773
|
() => new Set(stickyLeafColumns.map((column) => column.id)),
|
|
708
774
|
[stickyLeafColumns]
|
|
709
775
|
);
|
|
710
|
-
const stickyColumnLefts =
|
|
776
|
+
const stickyColumnLefts = React4__namespace.useMemo(() => {
|
|
711
777
|
const lefts = /* @__PURE__ */ new Map();
|
|
712
778
|
let runningLeft = 0;
|
|
713
779
|
for (const column of stickyLeafColumns) {
|
|
@@ -716,7 +782,7 @@ function DataTable({
|
|
|
716
782
|
}
|
|
717
783
|
return lefts;
|
|
718
784
|
}, [stickyLeafColumns]);
|
|
719
|
-
const renderedTableWidth =
|
|
785
|
+
const renderedTableWidth = React4__namespace.useMemo(() => {
|
|
720
786
|
return renderedLeafColumns.reduce((total, column) => {
|
|
721
787
|
const resizedWidth = columnSizing[column.id];
|
|
722
788
|
const baseWidth = resizedWidth ?? column.getSize();
|
|
@@ -729,17 +795,17 @@ function DataTable({
|
|
|
729
795
|
return total + clamped;
|
|
730
796
|
}, 0);
|
|
731
797
|
}, [renderedLeafColumns, columnSizing]);
|
|
732
|
-
const [internalColumnWrapping, setInternalColumnWrapping] =
|
|
798
|
+
const [internalColumnWrapping, setInternalColumnWrapping] = React4__namespace.useState({});
|
|
733
799
|
const columnWrapping = externalColumnWrapping ?? internalColumnWrapping;
|
|
734
800
|
const setColumnWrapping = onColumnWrappingChange ?? setInternalColumnWrapping;
|
|
735
|
-
const [draggedColumnId, setDraggedColumnId] =
|
|
801
|
+
const [draggedColumnId, setDraggedColumnId] = React4__namespace.useState(
|
|
736
802
|
null
|
|
737
803
|
);
|
|
738
|
-
const [dragOverColumnId, setDragOverColumnId] =
|
|
804
|
+
const [dragOverColumnId, setDragOverColumnId] = React4__namespace.useState(
|
|
739
805
|
null
|
|
740
806
|
);
|
|
741
|
-
const [dragOverColumnPosition, setDragOverColumnPosition] =
|
|
742
|
-
const handleColumnDragStart =
|
|
807
|
+
const [dragOverColumnPosition, setDragOverColumnPosition] = React4__namespace.useState(null);
|
|
808
|
+
const handleColumnDragStart = React4__namespace.useCallback(
|
|
743
809
|
(e, columnId) => {
|
|
744
810
|
setDraggedColumnId(columnId);
|
|
745
811
|
e.dataTransfer.effectAllowed = "move";
|
|
@@ -750,7 +816,7 @@ function DataTable({
|
|
|
750
816
|
},
|
|
751
817
|
[]
|
|
752
818
|
);
|
|
753
|
-
const handleColumnDragOver =
|
|
819
|
+
const handleColumnDragOver = React4__namespace.useCallback(
|
|
754
820
|
(e, columnId) => {
|
|
755
821
|
e.preventDefault();
|
|
756
822
|
e.dataTransfer.dropEffect = "move";
|
|
@@ -764,11 +830,11 @@ function DataTable({
|
|
|
764
830
|
},
|
|
765
831
|
[draggedColumnId]
|
|
766
832
|
);
|
|
767
|
-
const handleColumnDragLeave =
|
|
833
|
+
const handleColumnDragLeave = React4__namespace.useCallback(() => {
|
|
768
834
|
setDragOverColumnId(null);
|
|
769
835
|
setDragOverColumnPosition(null);
|
|
770
836
|
}, []);
|
|
771
|
-
const handleColumnDrop =
|
|
837
|
+
const handleColumnDrop = React4__namespace.useCallback(
|
|
772
838
|
(e, targetColumnId) => {
|
|
773
839
|
e.preventDefault();
|
|
774
840
|
if (draggedColumnId && draggedColumnId !== targetColumnId) {
|
|
@@ -791,13 +857,13 @@ function DataTable({
|
|
|
791
857
|
},
|
|
792
858
|
[draggedColumnId, columnOrder, dragOverColumnPosition, setColumnOrder]
|
|
793
859
|
);
|
|
794
|
-
const handleColumnDragEnd =
|
|
860
|
+
const handleColumnDragEnd = React4__namespace.useCallback((e) => {
|
|
795
861
|
e.target.closest("th")?.classList.remove("opacity-50");
|
|
796
862
|
setDraggedColumnId(null);
|
|
797
863
|
setDragOverColumnId(null);
|
|
798
864
|
setDragOverColumnPosition(null);
|
|
799
865
|
}, []);
|
|
800
|
-
const toggleColumnWrapping =
|
|
866
|
+
const toggleColumnWrapping = React4__namespace.useCallback(
|
|
801
867
|
(columnId) => {
|
|
802
868
|
setColumnWrapping({
|
|
803
869
|
...columnWrapping,
|
|
@@ -806,14 +872,14 @@ function DataTable({
|
|
|
806
872
|
},
|
|
807
873
|
[columnWrapping, setColumnWrapping]
|
|
808
874
|
);
|
|
809
|
-
const [draggedRowIndex, setDraggedRowIndex] =
|
|
875
|
+
const [draggedRowIndex, setDraggedRowIndex] = React4__namespace.useState(
|
|
810
876
|
null
|
|
811
877
|
);
|
|
812
|
-
const [dragOverRowIndex, setDragOverRowIndex] =
|
|
878
|
+
const [dragOverRowIndex, setDragOverRowIndex] = React4__namespace.useState(
|
|
813
879
|
null
|
|
814
880
|
);
|
|
815
|
-
const [dragOverPosition, setDragOverPosition] =
|
|
816
|
-
const handleRowDragStart =
|
|
881
|
+
const [dragOverPosition, setDragOverPosition] = React4__namespace.useState(null);
|
|
882
|
+
const handleRowDragStart = React4__namespace.useCallback(
|
|
817
883
|
(e, rowIndex) => {
|
|
818
884
|
setDraggedRowIndex(rowIndex);
|
|
819
885
|
e.dataTransfer.effectAllowed = "move";
|
|
@@ -824,7 +890,7 @@ function DataTable({
|
|
|
824
890
|
},
|
|
825
891
|
[]
|
|
826
892
|
);
|
|
827
|
-
const handleRowDragOver =
|
|
893
|
+
const handleRowDragOver = React4__namespace.useCallback(
|
|
828
894
|
(e, rowIndex) => {
|
|
829
895
|
e.preventDefault();
|
|
830
896
|
e.dataTransfer.dropEffect = "move";
|
|
@@ -838,11 +904,11 @@ function DataTable({
|
|
|
838
904
|
},
|
|
839
905
|
[draggedRowIndex]
|
|
840
906
|
);
|
|
841
|
-
const handleRowDragLeave =
|
|
907
|
+
const handleRowDragLeave = React4__namespace.useCallback(() => {
|
|
842
908
|
setDragOverRowIndex(null);
|
|
843
909
|
setDragOverPosition(null);
|
|
844
910
|
}, []);
|
|
845
|
-
const handleRowDrop =
|
|
911
|
+
const handleRowDrop = React4__namespace.useCallback(
|
|
846
912
|
(e, toIndex) => {
|
|
847
913
|
e.preventDefault();
|
|
848
914
|
const fromIndex = draggedRowIndex;
|
|
@@ -864,13 +930,13 @@ function DataTable({
|
|
|
864
930
|
},
|
|
865
931
|
[draggedRowIndex, dragOverPosition, onRowDragEnd]
|
|
866
932
|
);
|
|
867
|
-
const handleRowDragEnd =
|
|
933
|
+
const handleRowDragEnd = React4__namespace.useCallback((e) => {
|
|
868
934
|
e.target.closest("tr")?.classList.remove("opacity-50");
|
|
869
935
|
setDraggedRowIndex(null);
|
|
870
936
|
setDragOverRowIndex(null);
|
|
871
937
|
setDragOverPosition(null);
|
|
872
938
|
}, []);
|
|
873
|
-
const handleResizeStart =
|
|
939
|
+
const handleResizeStart = React4__namespace.useCallback(
|
|
874
940
|
(columnId, startX, startWidth) => {
|
|
875
941
|
setResizingColumn(columnId);
|
|
876
942
|
const handleMouseMove = (e) => {
|
|
@@ -892,7 +958,7 @@ function DataTable({
|
|
|
892
958
|
},
|
|
893
959
|
[]
|
|
894
960
|
);
|
|
895
|
-
const contextValue =
|
|
961
|
+
const contextValue = React4__namespace.useMemo(
|
|
896
962
|
() => ({
|
|
897
963
|
columnWrapping,
|
|
898
964
|
toggleColumnWrapping,
|
|
@@ -953,7 +1019,7 @@ function DataTable({
|
|
|
953
1019
|
tableLayout: "fixed"
|
|
954
1020
|
},
|
|
955
1021
|
children: [
|
|
956
|
-
/* @__PURE__ */ jsxRuntime.jsx(TableHeader, { children: table.getHeaderGroups().map((headerGroup) => {
|
|
1022
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkLABHD4PU_js.TableHeader, { children: table.getHeaderGroups().map((headerGroup) => {
|
|
957
1023
|
const renderableHeaders = headerGroup.headers.filter(
|
|
958
1024
|
(h) => !((rowSelectionStyle === "hover" || enableRowDrag) && h.id === "select")
|
|
959
1025
|
);
|
|
@@ -965,12 +1031,12 @@ function DataTable({
|
|
|
965
1031
|
return aIndex - bIndex;
|
|
966
1032
|
}) : renderableHeaders;
|
|
967
1033
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
968
|
-
TableRow,
|
|
1034
|
+
chunkLABHD4PU_js.TableRow,
|
|
969
1035
|
{
|
|
970
1036
|
className: "hover:bg-transparent",
|
|
971
1037
|
children: [
|
|
972
1038
|
(rowSelectionStyle === "hover" || enableRowDrag) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
973
|
-
TableHead,
|
|
1039
|
+
chunkLABHD4PU_js.TableHead,
|
|
974
1040
|
{
|
|
975
1041
|
className: chunkADIDI7AJ_js.cn(
|
|
976
1042
|
"p-0 border-r-0 whitespace-nowrap border-l border-b border-border group/header-gutter",
|
|
@@ -1078,7 +1144,7 @@ function DataTable({
|
|
|
1078
1144
|
renderedLeafColumns[firstLeafIndex - 1]?.id ?? ""
|
|
1079
1145
|
);
|
|
1080
1146
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1081
|
-
TableHead,
|
|
1147
|
+
chunkLABHD4PU_js.TableHead,
|
|
1082
1148
|
{
|
|
1083
1149
|
"data-sticky-column": isStickyColumn ? "true" : void 0,
|
|
1084
1150
|
colSpan: header.colSpan,
|
|
@@ -1190,7 +1256,7 @@ function DataTable({
|
|
|
1190
1256
|
);
|
|
1191
1257
|
}) }),
|
|
1192
1258
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1193
|
-
TableBody,
|
|
1259
|
+
chunkLABHD4PU_js.TableBody,
|
|
1194
1260
|
{
|
|
1195
1261
|
className: summary ? "[&_tr:last-child]:border-b" : void 0,
|
|
1196
1262
|
children: table.getRowModel().rows?.length ? table.getRowModel().rows.map((row, rowIndex) => {
|
|
@@ -1200,7 +1266,7 @@ function DataTable({
|
|
|
1200
1266
|
const isDragOverAbove = dragOverRowIndex === rowIndex && dragOverPosition === "above";
|
|
1201
1267
|
const isDragOverBelow = dragOverRowIndex === rowIndex && dragOverPosition === "below";
|
|
1202
1268
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1203
|
-
TableRow,
|
|
1269
|
+
chunkLABHD4PU_js.TableRow,
|
|
1204
1270
|
{
|
|
1205
1271
|
"data-state": isSelected && "selected",
|
|
1206
1272
|
"data-hovered": isHovered,
|
|
@@ -1219,7 +1285,7 @@ function DataTable({
|
|
|
1219
1285
|
),
|
|
1220
1286
|
children: [
|
|
1221
1287
|
(rowSelectionStyle === "hover" || enableRowDrag) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1222
|
-
TableCell,
|
|
1288
|
+
chunkLABHD4PU_js.TableCell,
|
|
1223
1289
|
{
|
|
1224
1290
|
className: chunkADIDI7AJ_js.cn(
|
|
1225
1291
|
"p-0 border-r-0 whitespace-nowrap border-l border-border",
|
|
@@ -1335,7 +1401,7 @@ function DataTable({
|
|
|
1335
1401
|
const treeIndent = showTreeUI ? row.depth * treeIndentPx : 0;
|
|
1336
1402
|
const canExpand = showTreeUI && row.getCanExpand();
|
|
1337
1403
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1338
|
-
TableCell,
|
|
1404
|
+
chunkLABHD4PU_js.TableCell,
|
|
1339
1405
|
{
|
|
1340
1406
|
"data-sticky-column": isStickyCell ? "true" : void 0,
|
|
1341
1407
|
className: chunkADIDI7AJ_js.cn(
|
|
@@ -1455,8 +1521,8 @@ function DataTable({
|
|
|
1455
1521
|
},
|
|
1456
1522
|
row.id
|
|
1457
1523
|
);
|
|
1458
|
-
}) : /* @__PURE__ */ jsxRuntime.jsx(TableRow, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1459
|
-
TableCell,
|
|
1524
|
+
}) : /* @__PURE__ */ jsxRuntime.jsx(chunkLABHD4PU_js.TableRow, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1525
|
+
chunkLABHD4PU_js.TableCell,
|
|
1460
1526
|
{
|
|
1461
1527
|
colSpan: columns.length + (rowSelectionStyle === "hover" || enableRowDrag ? 1 : 0),
|
|
1462
1528
|
className: "h-24",
|
|
@@ -1520,9 +1586,9 @@ function DataTableColumnHeader({
|
|
|
1520
1586
|
const resolvedFilterType = filterType ?? meta?.filterType ?? "text";
|
|
1521
1587
|
const resolvedFilterOptions = filterOptions ?? meta?.filterOptions;
|
|
1522
1588
|
const filterPlaceholder = meta?.filterPlaceholder;
|
|
1523
|
-
const [isOpen, setIsOpen] =
|
|
1524
|
-
const mouseDownPosRef =
|
|
1525
|
-
const didDragRef =
|
|
1589
|
+
const [isOpen, setIsOpen] = React4__namespace.useState(false);
|
|
1590
|
+
const mouseDownPosRef = React4__namespace.useRef(null);
|
|
1591
|
+
const didDragRef = React4__namespace.useRef(false);
|
|
1526
1592
|
const canDrag = dataTableContext?.enableColumnDrag ?? false;
|
|
1527
1593
|
const handleMouseDown = (e) => {
|
|
1528
1594
|
mouseDownPosRef.current = { x: e.clientX, y: e.clientY };
|
|
@@ -1702,221 +1768,6 @@ function DataTableColumnHeader({
|
|
|
1702
1768
|
] })
|
|
1703
1769
|
] }) });
|
|
1704
1770
|
}
|
|
1705
|
-
var FinanceDisplayContext = React3__namespace.createContext({
|
|
1706
|
-
decimals: 0,
|
|
1707
|
-
displayUnits: "actuals",
|
|
1708
|
-
currencySignDisplay: "all"
|
|
1709
|
-
});
|
|
1710
|
-
var FinanceDecimalsContext = React3__namespace.createContext(0);
|
|
1711
|
-
function FinanceDisplayProvider({
|
|
1712
|
-
decimals,
|
|
1713
|
-
displayUnits = "actuals",
|
|
1714
|
-
currencySignDisplay = "all",
|
|
1715
|
-
children
|
|
1716
|
-
}) {
|
|
1717
|
-
const value = React3__namespace.useMemo(
|
|
1718
|
-
() => ({ decimals, displayUnits, currencySignDisplay }),
|
|
1719
|
-
[decimals, displayUnits, currencySignDisplay]
|
|
1720
|
-
);
|
|
1721
|
-
return /* @__PURE__ */ jsxRuntime.jsx(FinanceDisplayContext.Provider, { value, children: /* @__PURE__ */ jsxRuntime.jsx(FinanceDecimalsContext.Provider, { value: decimals, children }) });
|
|
1722
|
-
}
|
|
1723
|
-
function FinanceDecimalsProvider({
|
|
1724
|
-
decimals,
|
|
1725
|
-
children
|
|
1726
|
-
}) {
|
|
1727
|
-
return /* @__PURE__ */ jsxRuntime.jsx(FinanceDisplayProvider, { decimals, children });
|
|
1728
|
-
}
|
|
1729
|
-
function useFinanceDecimals() {
|
|
1730
|
-
return React3__namespace.useContext(FinanceDecimalsContext);
|
|
1731
|
-
}
|
|
1732
|
-
function useFinanceDisplay() {
|
|
1733
|
-
return React3__namespace.useContext(FinanceDisplayContext);
|
|
1734
|
-
}
|
|
1735
|
-
function getUnitDivisor(units) {
|
|
1736
|
-
switch (units) {
|
|
1737
|
-
case "thousands":
|
|
1738
|
-
return 1e3;
|
|
1739
|
-
case "millions":
|
|
1740
|
-
return 1e6;
|
|
1741
|
-
default:
|
|
1742
|
-
return 1;
|
|
1743
|
-
}
|
|
1744
|
-
}
|
|
1745
|
-
function getUnitLabel(units) {
|
|
1746
|
-
switch (units) {
|
|
1747
|
-
case "thousands":
|
|
1748
|
-
return "in thousands";
|
|
1749
|
-
case "millions":
|
|
1750
|
-
return "in millions";
|
|
1751
|
-
default:
|
|
1752
|
-
return null;
|
|
1753
|
-
}
|
|
1754
|
-
}
|
|
1755
|
-
function getUnitSuffix(units) {
|
|
1756
|
-
switch (units) {
|
|
1757
|
-
case "thousands":
|
|
1758
|
-
return "(000s)";
|
|
1759
|
-
case "millions":
|
|
1760
|
-
return "(M)";
|
|
1761
|
-
default:
|
|
1762
|
-
return null;
|
|
1763
|
-
}
|
|
1764
|
-
}
|
|
1765
|
-
function useFinanceDecimalsSetting(storageKey = "finance-decimal-places", defaultValue = 0) {
|
|
1766
|
-
const [decimals, setDecimalsState] = React3__namespace.useState(() => {
|
|
1767
|
-
if (typeof window === "undefined") return defaultValue;
|
|
1768
|
-
const stored = localStorage.getItem(storageKey);
|
|
1769
|
-
return stored !== null ? Number(stored) : defaultValue;
|
|
1770
|
-
});
|
|
1771
|
-
const setDecimals = React3__namespace.useCallback(
|
|
1772
|
-
(v) => {
|
|
1773
|
-
setDecimalsState(v);
|
|
1774
|
-
if (typeof window !== "undefined") {
|
|
1775
|
-
localStorage.setItem(storageKey, String(v));
|
|
1776
|
-
}
|
|
1777
|
-
},
|
|
1778
|
-
[storageKey]
|
|
1779
|
-
);
|
|
1780
|
-
return [decimals, setDecimals];
|
|
1781
|
-
}
|
|
1782
|
-
var formatterCache = /* @__PURE__ */ new Map();
|
|
1783
|
-
function getFormatter(locale, currencyCode, decimals) {
|
|
1784
|
-
const key = `${locale}:${currencyCode}:${decimals}`;
|
|
1785
|
-
let fmt = formatterCache.get(key);
|
|
1786
|
-
if (!fmt) {
|
|
1787
|
-
fmt = new Intl.NumberFormat(locale, {
|
|
1788
|
-
style: "currency",
|
|
1789
|
-
currency: currencyCode,
|
|
1790
|
-
minimumFractionDigits: decimals,
|
|
1791
|
-
maximumFractionDigits: decimals
|
|
1792
|
-
});
|
|
1793
|
-
formatterCache.set(key, fmt);
|
|
1794
|
-
}
|
|
1795
|
-
return fmt;
|
|
1796
|
-
}
|
|
1797
|
-
function formatCurrencyValue(value, options) {
|
|
1798
|
-
const raw = value ?? 0;
|
|
1799
|
-
const divisor = getUnitDivisor(options?.displayUnits ?? "actuals");
|
|
1800
|
-
const v = divisor === 1 ? raw : raw / divisor;
|
|
1801
|
-
const isZero = raw === 0;
|
|
1802
|
-
const isNegative = v < 0;
|
|
1803
|
-
const curr = options?.currency ?? "USD";
|
|
1804
|
-
const locale = options?.locale ?? "en-US";
|
|
1805
|
-
const dashZero = options?.dashZero ?? false;
|
|
1806
|
-
const decimals = options?.decimals ?? 2;
|
|
1807
|
-
const showSign = options?.showCurrencySign ?? true;
|
|
1808
|
-
if (isZero && dashZero) {
|
|
1809
|
-
return { text: "\u2014", isNegative: false, isZero: true };
|
|
1810
|
-
}
|
|
1811
|
-
const absV = Math.abs(v);
|
|
1812
|
-
let formatted;
|
|
1813
|
-
if (showSign) {
|
|
1814
|
-
const fmt = getFormatter(locale, curr, decimals);
|
|
1815
|
-
formatted = fmt.format(absV);
|
|
1816
|
-
} else {
|
|
1817
|
-
formatted = absV.toLocaleString(locale, {
|
|
1818
|
-
minimumFractionDigits: decimals,
|
|
1819
|
-
maximumFractionDigits: decimals
|
|
1820
|
-
});
|
|
1821
|
-
}
|
|
1822
|
-
if (isNegative) {
|
|
1823
|
-
return { text: `(${formatted})`, isNegative: true, isZero: false };
|
|
1824
|
-
}
|
|
1825
|
-
return { text: formatted, isNegative: false, isZero };
|
|
1826
|
-
}
|
|
1827
|
-
function DataTableCurrencyCell({
|
|
1828
|
-
value,
|
|
1829
|
-
currency: currencyCode = "USD",
|
|
1830
|
-
locale = "en-US",
|
|
1831
|
-
dashZero = false,
|
|
1832
|
-
decimals,
|
|
1833
|
-
className,
|
|
1834
|
-
/** Whether this cell is in a summary/total row */
|
|
1835
|
-
isSummaryRow
|
|
1836
|
-
}) {
|
|
1837
|
-
const ctx = useFinanceDisplay();
|
|
1838
|
-
const resolvedDecimals = decimals ?? ctx.decimals;
|
|
1839
|
-
const showCurrencySign = ctx.currencySignDisplay === "all" || ctx.currencySignDisplay === "summary" && isSummaryRow;
|
|
1840
|
-
const { text, isNegative, isZero } = formatCurrencyValue(value, {
|
|
1841
|
-
currency: currencyCode,
|
|
1842
|
-
locale,
|
|
1843
|
-
dashZero,
|
|
1844
|
-
decimals: resolvedDecimals,
|
|
1845
|
-
displayUnits: ctx.displayUnits,
|
|
1846
|
-
showCurrencySign
|
|
1847
|
-
});
|
|
1848
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1849
|
-
"span",
|
|
1850
|
-
{
|
|
1851
|
-
className: chunkADIDI7AJ_js.cn(
|
|
1852
|
-
"font-mono tabular-nums",
|
|
1853
|
-
isNegative && "text-red-600 dark:text-red-400",
|
|
1854
|
-
isZero && dashZero && "text-muted-foreground",
|
|
1855
|
-
className
|
|
1856
|
-
),
|
|
1857
|
-
children: text
|
|
1858
|
-
}
|
|
1859
|
-
);
|
|
1860
|
-
}
|
|
1861
|
-
|
|
1862
|
-
// src/blocks/data-table/financialStatementRowImportance.ts
|
|
1863
|
-
var DEFAULT_ROW_IMPORTANCE_CONFIG = {
|
|
1864
|
-
"income-statement": {
|
|
1865
|
-
emphasis: ["Total Revenue", "Total Expenses", "Operating Income"],
|
|
1866
|
-
keySummary: ["Net Income"]
|
|
1867
|
-
},
|
|
1868
|
-
"balance-sheet": {
|
|
1869
|
-
emphasis: ["Total Liabilities", "Total Equity"],
|
|
1870
|
-
keySummary: ["Total Assets", "Total Liabilities & Equity"]
|
|
1871
|
-
},
|
|
1872
|
-
"cash-flow": {
|
|
1873
|
-
emphasis: [
|
|
1874
|
-
"Total Operating Activities",
|
|
1875
|
-
"Total Investing Activities",
|
|
1876
|
-
"Total Financing Activities",
|
|
1877
|
-
"Net Cash from Operating Activities",
|
|
1878
|
-
"Net Cash from Investing Activities",
|
|
1879
|
-
"Net Cash from Financing Activities"
|
|
1880
|
-
],
|
|
1881
|
-
keySummary: [
|
|
1882
|
-
"Net Change in Cash",
|
|
1883
|
-
"Ending Cash",
|
|
1884
|
-
"Total Cash & Cash Equivalents"
|
|
1885
|
-
]
|
|
1886
|
-
},
|
|
1887
|
-
"working-capital": {
|
|
1888
|
-
emphasis: ["Total Current Assets", "Total Current Liabilities"],
|
|
1889
|
-
keySummary: ["NWC", "Net Working Capital"]
|
|
1890
|
-
}
|
|
1891
|
-
};
|
|
1892
|
-
function normalizeLabel(value) {
|
|
1893
|
-
return value.trim().toLowerCase().replace(/\s+/g, " ");
|
|
1894
|
-
}
|
|
1895
|
-
function createFinancialStatementRowImportanceResolver(kind, overrides) {
|
|
1896
|
-
const base = DEFAULT_ROW_IMPORTANCE_CONFIG[kind];
|
|
1897
|
-
const emphasis = new Set(
|
|
1898
|
-
(overrides?.emphasis ?? base?.emphasis ?? []).map(normalizeLabel)
|
|
1899
|
-
);
|
|
1900
|
-
const keySummary = new Set(
|
|
1901
|
-
(overrides?.keySummary ?? base?.keySummary ?? []).map(normalizeLabel)
|
|
1902
|
-
);
|
|
1903
|
-
return (row) => {
|
|
1904
|
-
const label = normalizeLabel(row.name);
|
|
1905
|
-
if (keySummary.has(label)) return "key-summary";
|
|
1906
|
-
if (emphasis.has(label)) return "emphasis";
|
|
1907
|
-
return "normal";
|
|
1908
|
-
};
|
|
1909
|
-
}
|
|
1910
|
-
function getFinancialStatementRowImportanceClassName(importance) {
|
|
1911
|
-
switch (importance) {
|
|
1912
|
-
case "emphasis":
|
|
1913
|
-
return "bg-muted/25 border-t border-border/50 font-medium";
|
|
1914
|
-
case "key-summary":
|
|
1915
|
-
return "bg-muted/45 border-t-2 border-border/70 font-semibold";
|
|
1916
|
-
default:
|
|
1917
|
-
return void 0;
|
|
1918
|
-
}
|
|
1919
|
-
}
|
|
1920
1771
|
var TOLERANCE = 0.01;
|
|
1921
1772
|
function RecCheck({ computed, raw }) {
|
|
1922
1773
|
const diff = Math.abs(computed - raw);
|
|
@@ -2709,25 +2560,25 @@ function FinancialStatementTable({
|
|
|
2709
2560
|
className,
|
|
2710
2561
|
rowImportanceResolver
|
|
2711
2562
|
}) {
|
|
2712
|
-
const [expanded, setExpanded] =
|
|
2713
|
-
const [columnVisibility, setColumnVisibility] =
|
|
2714
|
-
const [viewportLayout, setViewportLayout] =
|
|
2715
|
-
const { rows: rawRows, periods } =
|
|
2563
|
+
const [expanded, setExpanded] = React4__namespace.useState({});
|
|
2564
|
+
const [columnVisibility, setColumnVisibility] = React4__namespace.useState({});
|
|
2565
|
+
const [viewportLayout, setViewportLayout] = React4__namespace.useState("unknown");
|
|
2566
|
+
const { rows: rawRows, periods } = React4__namespace.useMemo(
|
|
2716
2567
|
() => buildFinancialStatementData(data, config, timeUnit, subtotalRules, {
|
|
2717
2568
|
preserveEmptySections
|
|
2718
2569
|
}),
|
|
2719
2570
|
[data, config, timeUnit, subtotalRules, preserveEmptySections]
|
|
2720
2571
|
);
|
|
2721
|
-
const rows =
|
|
2572
|
+
const rows = React4__namespace.useMemo(
|
|
2722
2573
|
() => hideZeroRows ? filterZeroRows(rawRows) : rawRows,
|
|
2723
2574
|
[rawRows, hideZeroRows]
|
|
2724
2575
|
);
|
|
2725
|
-
const orderedPeriods =
|
|
2576
|
+
const orderedPeriods = React4__namespace.useMemo(
|
|
2726
2577
|
() => resolvePeriodColumns(periods, timeUnit, periodOrder, periodColumnOrder),
|
|
2727
2578
|
[periods, timeUnit, periodOrder, periodColumnOrder]
|
|
2728
2579
|
);
|
|
2729
2580
|
const effectiveShowRowTotals = isMobile && mobileCompareEnabled ? false : showRowTotals;
|
|
2730
|
-
const columns =
|
|
2581
|
+
const columns = React4__namespace.useMemo(
|
|
2731
2582
|
() => buildColumns(
|
|
2732
2583
|
orderedPeriods,
|
|
2733
2584
|
timeUnit,
|
|
@@ -2759,7 +2610,7 @@ function FinancialStatementTable({
|
|
|
2759
2610
|
accountColumnMenuItems
|
|
2760
2611
|
]
|
|
2761
2612
|
);
|
|
2762
|
-
|
|
2613
|
+
React4__namespace.useEffect(() => {
|
|
2763
2614
|
if (typeof window === "undefined") return;
|
|
2764
2615
|
const updateViewportLayout = () => {
|
|
2765
2616
|
setViewportLayout(
|
|
@@ -2774,7 +2625,7 @@ function FinancialStatementTable({
|
|
|
2774
2625
|
window.removeEventListener("orientationchange", updateViewportLayout);
|
|
2775
2626
|
};
|
|
2776
2627
|
}, []);
|
|
2777
|
-
|
|
2628
|
+
React4__namespace.useEffect(() => {
|
|
2778
2629
|
if (rows.length === 0) return;
|
|
2779
2630
|
const toExpand = {};
|
|
2780
2631
|
for (const row of rows) {
|
|
@@ -2883,106 +2734,15 @@ var BALANCE_SHEET_CONFIG = {
|
|
|
2883
2734
|
]
|
|
2884
2735
|
};
|
|
2885
2736
|
|
|
2886
|
-
// src/hooks/spreadsheetWorkbook.ts
|
|
2887
|
-
function escapeXml(value) {
|
|
2888
|
-
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
2889
|
-
}
|
|
2890
|
-
function styleId(style) {
|
|
2891
|
-
if (!style) return void 0;
|
|
2892
|
-
const map = {
|
|
2893
|
-
header: "Header",
|
|
2894
|
-
text: "Text",
|
|
2895
|
-
number: "Number",
|
|
2896
|
-
currency: "Currency",
|
|
2897
|
-
percent: "Percent",
|
|
2898
|
-
totalLabel: "TotalLabel",
|
|
2899
|
-
totalNumber: "TotalNumber"
|
|
2900
|
-
};
|
|
2901
|
-
return map[style];
|
|
2902
|
-
}
|
|
2903
|
-
function excelColumnName(columnIndex) {
|
|
2904
|
-
let n = columnIndex + 1;
|
|
2905
|
-
let result = "";
|
|
2906
|
-
while (n > 0) {
|
|
2907
|
-
const rem = (n - 1) % 26;
|
|
2908
|
-
result = String.fromCharCode(65 + rem) + result;
|
|
2909
|
-
n = Math.floor((n - 1) / 26);
|
|
2910
|
-
}
|
|
2911
|
-
return result;
|
|
2912
|
-
}
|
|
2913
|
-
function buildSpreadsheetWorkbookXml({
|
|
2914
|
-
worksheetName,
|
|
2915
|
-
rows
|
|
2916
|
-
}) {
|
|
2917
|
-
const xmlRows = rows.map(
|
|
2918
|
-
(row) => `<Row>${row.map((cell) => {
|
|
2919
|
-
const inferredType = cell.type ?? (typeof cell.value === "number" || cell.formula ? "Number" : "String");
|
|
2920
|
-
const rawValue = cell.value ?? "";
|
|
2921
|
-
const value = inferredType === "Number" ? Number(rawValue || 0) : escapeXml(String(rawValue));
|
|
2922
|
-
const style = styleId(cell.style);
|
|
2923
|
-
const styleAttr = style ? ` ss:StyleID="${style}"` : "";
|
|
2924
|
-
const formulaAttr = cell.formula ? ` ss:Formula="=${escapeXml(cell.formula)}"` : "";
|
|
2925
|
-
return `<Cell${styleAttr}${formulaAttr}><Data ss:Type="${inferredType}">${value}</Data></Cell>`;
|
|
2926
|
-
}).join("")}</Row>`
|
|
2927
|
-
).join("\n");
|
|
2928
|
-
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
2929
|
-
<?mso-application progid="Excel.Sheet"?>
|
|
2930
|
-
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
|
|
2931
|
-
<Styles>
|
|
2932
|
-
<Style ss:ID="Header"><Font ss:Bold="1"/><Interior ss:Color="#F3F4F6" ss:Pattern="Solid"/></Style>
|
|
2933
|
-
<Style ss:ID="Text"><NumberFormat ss:Format="@"/></Style>
|
|
2934
|
-
<Style ss:ID="Number"><NumberFormat ss:Format="#,##0.00"/></Style>
|
|
2935
|
-
<Style ss:ID="Currency"><NumberFormat ss:Format="$#,##0.00;[Red]($#,##0.00)"/></Style>
|
|
2936
|
-
<Style ss:ID="Percent"><NumberFormat ss:Format="0.00%"/></Style>
|
|
2937
|
-
<Style ss:ID="TotalLabel"><Font ss:Bold="1"/><Interior ss:Color="#F9FAFB" ss:Pattern="Solid"/></Style>
|
|
2938
|
-
<Style ss:ID="TotalNumber"><Font ss:Bold="1"/><NumberFormat ss:Format="$#,##0.00;[Red]($#,##0.00)"/><Interior ss:Color="#F9FAFB" ss:Pattern="Solid"/></Style>
|
|
2939
|
-
</Styles>
|
|
2940
|
-
<Worksheet ss:Name="${escapeXml(worksheetName)}"><Table>
|
|
2941
|
-
${xmlRows}
|
|
2942
|
-
</Table></Worksheet></Workbook>`;
|
|
2943
|
-
}
|
|
2944
|
-
function downloadExcelXml(xml, filename) {
|
|
2945
|
-
const blob = new Blob([xml], {
|
|
2946
|
-
type: "application/vnd.ms-excel;charset=utf-8;"
|
|
2947
|
-
});
|
|
2948
|
-
const url = URL.createObjectURL(blob);
|
|
2949
|
-
const link = document.createElement("a");
|
|
2950
|
-
link.href = url;
|
|
2951
|
-
link.download = `${filename}.xls`;
|
|
2952
|
-
link.click();
|
|
2953
|
-
URL.revokeObjectURL(url);
|
|
2954
|
-
}
|
|
2955
|
-
|
|
2956
2737
|
exports.BALANCE_SHEET_CONFIG = BALANCE_SHEET_CONFIG;
|
|
2957
|
-
exports.DataTable = DataTable;
|
|
2958
|
-
exports.DataTableColumnFilter = DataTableColumnFilter;
|
|
2959
|
-
exports.DataTableColumnFilterContent = DataTableColumnFilterContent;
|
|
2960
|
-
exports.DataTableColumnHeader = DataTableColumnHeader;
|
|
2961
|
-
exports.DataTableContext = DataTableContext;
|
|
2962
2738
|
exports.DataTableCurrencyCell = DataTableCurrencyCell;
|
|
2963
|
-
exports.DataTableFilterBadges = DataTableFilterBadges;
|
|
2964
2739
|
exports.FinanceDecimalsProvider = FinanceDecimalsProvider;
|
|
2965
2740
|
exports.FinanceDisplayProvider = FinanceDisplayProvider;
|
|
2966
2741
|
exports.FinancialStatementTable = FinancialStatementTable;
|
|
2967
2742
|
exports.INCOME_STATEMENT_CONFIG = INCOME_STATEMENT_CONFIG;
|
|
2968
|
-
exports.Popover = Popover;
|
|
2969
|
-
exports.PopoverAnchor = PopoverAnchor;
|
|
2970
|
-
exports.PopoverContent = PopoverContent;
|
|
2971
|
-
exports.PopoverTrigger = PopoverTrigger;
|
|
2972
|
-
exports.Table = Table;
|
|
2973
|
-
exports.TableBody = TableBody;
|
|
2974
|
-
exports.TableCaption = TableCaption;
|
|
2975
|
-
exports.TableCell = TableCell;
|
|
2976
|
-
exports.TableFooter = TableFooter;
|
|
2977
|
-
exports.TableHead = TableHead;
|
|
2978
|
-
exports.TableHeader = TableHeader;
|
|
2979
|
-
exports.TableRow = TableRow;
|
|
2980
2743
|
exports.buildFinancialStatementData = buildFinancialStatementData;
|
|
2981
|
-
exports.buildSpreadsheetWorkbookXml = buildSpreadsheetWorkbookXml;
|
|
2982
2744
|
exports.calculateDesktopFinancialColumnSizing = calculateDesktopFinancialColumnSizing;
|
|
2983
2745
|
exports.createFinancialStatementRowImportanceResolver = createFinancialStatementRowImportanceResolver;
|
|
2984
|
-
exports.downloadExcelXml = downloadExcelXml;
|
|
2985
|
-
exports.excelColumnName = excelColumnName;
|
|
2986
2746
|
exports.flattenStatementForExport = flattenStatementForExport;
|
|
2987
2747
|
exports.formatCurrencyValue = formatCurrencyValue;
|
|
2988
2748
|
exports.getFinancialStatementRowImportanceClassName = getFinancialStatementRowImportanceClassName;
|
|
@@ -2990,7 +2750,6 @@ exports.getUnitDivisor = getUnitDivisor;
|
|
|
2990
2750
|
exports.getUnitLabel = getUnitLabel;
|
|
2991
2751
|
exports.getUnitSuffix = getUnitSuffix;
|
|
2992
2752
|
exports.resolvePeriodColumns = resolvePeriodColumns;
|
|
2993
|
-
exports.useDataTableContext = useDataTableContext;
|
|
2994
2753
|
exports.useFinanceDecimals = useFinanceDecimals;
|
|
2995
2754
|
exports.useFinanceDecimalsSetting = useFinanceDecimalsSetting;
|
|
2996
2755
|
exports.useFinanceDisplay = useFinanceDisplay;
|