@caffeinebounce/ui 0.62.2 → 0.63.0

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