@layerfi/components 0.1.117-alpha.1 → 0.1.118-alpha

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.
@@ -57,11 +57,11 @@ const react = require("react");
57
57
  const zustand = require("zustand");
58
58
  const reactPlaidLink = require("react-plaid-link");
59
59
  const dateFns = require("date-fns");
60
+ const effect = require("effect");
60
61
  const date = require("@internationalized/date");
61
62
  const useSWR = require("swr");
62
63
  const classNames = require("classnames");
63
64
  const index = require("effect/index");
64
- const effect = require("effect");
65
65
  const useSWRInfinite = require("swr/infinite");
66
66
  const traditional = require("zustand/traditional");
67
67
  const react$1 = require("@floating-ui/react");
@@ -149,6 +149,13 @@ function toSnakeCase(input) {
149
149
  const segments = (_a = input.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)) != null ? _a : [];
150
150
  return segments.map((segment) => segment.toLowerCase()).join("_");
151
151
  }
152
+ effect.Schema.Union(
153
+ effect.Schema.Date,
154
+ effect.Schema.String,
155
+ effect.Schema.Array(effect.Schema.String),
156
+ effect.Schema.Number,
157
+ effect.Schema.Boolean
158
+ );
152
159
  function toDefinedSearchParameters(input) {
153
160
  const definedParameterPairs = Object.entries(input).flatMap(([key, value]) => {
154
161
  if (value === null || value === void 0) {
@@ -202,7 +209,7 @@ class ErrorHandlerClass {
202
209
  }
203
210
  const errorHandler = new ErrorHandlerClass();
204
211
  const reportError = (payload) => errorHandler.onError(payload);
205
- const version = "0.1.117-alpha.1";
212
+ const version = "0.1.118-alpha";
206
213
  const pkg = {
207
214
  version
208
215
  };
@@ -4632,10 +4639,6 @@ function clampToPresentOrPast(date2, cutoff = dateFns.endOfDay(/* @__PURE__ */ n
4632
4639
  return dateFns.min([date2, cutoff]);
4633
4640
  }
4634
4641
  const RANGE_MODE_LOOKUP = {
4635
- date: {
4636
- getStartDate: ({ startDate }) => dateFns.startOfMonth(startDate),
4637
- getEndDate: ({ endDate }) => clampToPresentOrPast(dateFns.endOfDay(endDate))
4638
- },
4639
4642
  full: {
4640
4643
  getStartDate: ({ startDate }) => startDate,
4641
4644
  getEndDate: ({ endDate }) => clampToPresentOrPast(dateFns.endOfDay(endDate))
@@ -4662,8 +4665,8 @@ function buildStore$2() {
4662
4665
  return next;
4663
4666
  };
4664
4667
  const setDate = ({ date: date2 }) => {
4665
- const s = RANGE_MODE_LOOKUP.date.getStartDate({ startDate: date2 });
4666
- const e = RANGE_MODE_LOOKUP.date.getEndDate({ endDate: date2 });
4668
+ const s = RANGE_MODE_LOOKUP.month.getStartDate({ startDate: date2 });
4669
+ const e = RANGE_MODE_LOOKUP.full.getEndDate({ endDate: date2 });
4667
4670
  return apply2({ startDate: s, endDate: e });
4668
4671
  };
4669
4672
  const setDateRange = withCorrectedRange(({ startDate, endDate }) => {
@@ -4676,30 +4679,11 @@ function buildStore$2() {
4676
4679
  const e = RANGE_MODE_LOOKUP.month.getEndDate({ endDate: startDate });
4677
4680
  return apply2({ startDate: s, endDate: e });
4678
4681
  };
4679
- const setRangeWithExplicitDisplayMode = ({
4680
- startDate,
4681
- endDate,
4682
- displayMode
4683
- }) => {
4684
- switch (displayMode) {
4685
- case "date":
4686
- return setDate({ date: endDate });
4687
- case "full":
4688
- return setDateRange({ startDate, endDate });
4689
- case "month":
4690
- return setMonth({ startDate });
4691
- default:
4692
- unsafeAssertUnreachable({
4693
- message: "Invalid `displayMode`"
4694
- });
4695
- }
4696
- };
4697
4682
  return {
4698
4683
  startDate: dateFns.startOfMonth(now2),
4699
4684
  endDate: clampToPresentOrPast(dateFns.endOfMonth(now2)),
4700
4685
  actions: {
4701
4686
  setDate,
4702
- setRangeWithExplicitDisplayMode,
4703
4687
  setDateRange,
4704
4688
  setMonth,
4705
4689
  setMonthByPeriod: ({ monthNumber, yearNumber }) => {
@@ -4711,10 +4695,17 @@ function buildStore$2() {
4711
4695
  });
4712
4696
  }
4713
4697
  const GlobalDateStoreContext = react.createContext(buildStore$2());
4714
- function useGlobalDate() {
4698
+ const getEffectiveDateForMode = (mode, { date: date2 }) => {
4699
+ const rangeModifierForMode = RANGE_MODE_LOOKUP[mode];
4700
+ return { date: rangeModifierForMode.getEndDate({ endDate: date2 }) };
4701
+ };
4702
+ function useGlobalDate({ dateSelectionMode = "full" } = {}) {
4715
4703
  const store = react.useContext(GlobalDateStoreContext);
4716
- const date2 = useStoreWithDateSelected(store, ({ endDate }) => endDate);
4717
- return { date: date2 };
4704
+ const rawDate = useStoreWithDateSelected(store, ({ endDate }) => endDate);
4705
+ return react.useMemo(
4706
+ () => getEffectiveDateForMode(dateSelectionMode, { date: rawDate }),
4707
+ [dateSelectionMode, rawDate]
4708
+ );
4718
4709
  }
4719
4710
  function useGlobalDateActions() {
4720
4711
  const store = react.useContext(GlobalDateStoreContext);
@@ -4728,28 +4719,23 @@ const getEffectiveDateRangeForMode = (mode, { startDate, endDate }) => {
4728
4719
  endDate: rangeModifierForMode.getEndDate({ endDate })
4729
4720
  };
4730
4721
  };
4731
- function useGlobalDateRange({ displayMode }) {
4722
+ function useGlobalDateRange({ dateSelectionMode }) {
4732
4723
  const store = react.useContext(GlobalDateStoreContext);
4733
4724
  const rawStartDate = useStoreWithDateSelected(store, ({ startDate }) => startDate);
4734
4725
  const rawEndDate = useStoreWithDateSelected(store, ({ endDate }) => endDate);
4735
4726
  return react.useMemo(
4736
4727
  () => getEffectiveDateRangeForMode(
4737
- displayMode,
4728
+ dateSelectionMode,
4738
4729
  { startDate: rawStartDate, endDate: rawEndDate }
4739
4730
  ),
4740
- [displayMode, rawEndDate, rawStartDate]
4731
+ [dateSelectionMode, rawEndDate, rawStartDate]
4741
4732
  );
4742
4733
  }
4743
4734
  function useGlobalDateRangeActions() {
4744
4735
  const store = react.useContext(GlobalDateStoreContext);
4745
- const setRangeWithExplicitDisplayMode = zustand.useStore(
4746
- store,
4747
- ({ actions: { setRangeWithExplicitDisplayMode: setRangeWithExplicitDisplayMode2 } }) => setRangeWithExplicitDisplayMode2
4748
- );
4749
4736
  const setDateRange = zustand.useStore(store, ({ actions: { setDateRange: setDateRange2 } }) => setDateRange2);
4750
4737
  const setMonth = zustand.useStore(store, ({ actions: { setMonth: setMonth2 } }) => setMonth2);
4751
4738
  return {
4752
- setRangeWithExplicitDisplayMode,
4753
4739
  setDateRange,
4754
4740
  setMonth
4755
4741
  };
@@ -4767,7 +4753,7 @@ function GlobalDateStoreProvider({
4767
4753
  }
4768
4754
  const useBankTransactionsFilters = (params) => {
4769
4755
  const dateFilterMode = (params == null ? void 0 : params.applyGlobalDateRange) ? BankTransactionsDateFilterMode.GlobalDateRange : (params == null ? void 0 : params.monthlyView) ? BankTransactionsDateFilterMode.MonthlyView : void 0;
4770
- const globalDateRange = useGlobalDateRange({ displayMode: "full" });
4756
+ const globalDateRange = useGlobalDateRange({ dateSelectionMode: "full" });
4771
4757
  const defaultDateRange = {
4772
4758
  startDate: dateFns.startOfMonth(/* @__PURE__ */ new Date()),
4773
4759
  endDate: dateFns.endOfMonth(/* @__PURE__ */ new Date())
@@ -12754,6 +12740,10 @@ const InvoicePaymentLedgerEntrySourceSchema = effect.Schema.Struct({
12754
12740
  effect.Schema.propertySignature(effect.Schema.String),
12755
12741
  effect.Schema.fromKey("invoice_id")
12756
12742
  ),
12743
+ invoicePaymentId: effect.pipe(
12744
+ effect.Schema.propertySignature(effect.Schema.String),
12745
+ effect.Schema.fromKey("invoice_payment_id")
12746
+ ),
12757
12747
  invoiceNumber: effect.pipe(
12758
12748
  effect.Schema.propertySignature(effect.Schema.NullOr(effect.Schema.String)),
12759
12749
  effect.Schema.fromKey("invoice_number")
@@ -13216,6 +13206,10 @@ const BillPaymentLedgerEntrySourceSchema = effect.Schema.Struct({
13216
13206
  effect.Schema.optional(effect.Schema.NullOr(effect.Schema.String)),
13217
13207
  effect.Schema.fromKey("external_id")
13218
13208
  ),
13209
+ billPaymentId: effect.pipe(
13210
+ effect.Schema.propertySignature(effect.Schema.String),
13211
+ effect.Schema.fromKey("bill_payment_id")
13212
+ ),
13219
13213
  billId: effect.pipe(
13220
13214
  effect.Schema.propertySignature(effect.Schema.String),
13221
13215
  effect.Schema.fromKey("bill_id")
@@ -13341,7 +13335,7 @@ const convertLedgerEntrySourceToLinkingMetadata = (ledgerEntrySource) => {
13341
13335
  baseMetadata.id = ledgerEntrySource.manualEntryId;
13342
13336
  break;
13343
13337
  case "Invoice_Payment_Ledger_Entry_Source":
13344
- baseMetadata.id = ledgerEntrySource.invoiceId;
13338
+ baseMetadata.id = ledgerEntrySource.invoicePaymentId;
13345
13339
  baseMetadata.entityName = EntityName.InvoicePayment;
13346
13340
  if (ledgerEntrySource.invoiceIdentifiers) {
13347
13341
  baseMetadata.relatedEntityLinkingMetadata = ledgerEntrySource.invoiceIdentifiers.map((identifier) => ({
@@ -13447,7 +13441,7 @@ const convertLedgerEntrySourceToLinkingMetadata = (ledgerEntrySource) => {
13447
13441
  baseMetadata.entityName = EntityName.Bill;
13448
13442
  break;
13449
13443
  case "Bill_Payment_Ledger_Entry_Source":
13450
- baseMetadata.id = ledgerEntrySource.billId;
13444
+ baseMetadata.id = ledgerEntrySource.billPaymentId;
13451
13445
  baseMetadata.entityName = EntityName.BillPayment;
13452
13446
  if (ledgerEntrySource.billIdentifiers) {
13453
13447
  baseMetadata.relatedEntityLinkingMetadata = ledgerEntrySource.billIdentifiers.map((identifier) => ({
@@ -14182,11 +14176,13 @@ const CSS_PREFIX$1 = "Layer__UI__Table";
14182
14176
  const getClassName = (component, additionalClassNames, withHidden) => classNames(`${CSS_PREFIX$1}-${component}`, withHidden && `${CSS_PREFIX$1}-${component}--hidden`, additionalClassNames);
14183
14177
  const Table$1 = react.forwardRef(
14184
14178
  (_rb, ref) => {
14185
- var _sb = _rb, { children, className } = _sb, restProps = __objRest(_sb, ["children", "className"]);
14179
+ var _sb = _rb, { children, className, nonAria, slot } = _sb, restProps = __objRest(_sb, ["children", "className", "nonAria", "slot"]);
14180
+ const TableComponent = nonAria ? "table" : reactAriaComponents.Table;
14186
14181
  return /* @__PURE__ */ jsxRuntime.jsx(
14187
- reactAriaComponents.Table,
14182
+ TableComponent,
14188
14183
  __spreadProps(__spreadValues({
14189
- className: getClassName("Table", className)
14184
+ className: getClassName("Table", className),
14185
+ slot: slot != null ? slot : void 0
14190
14186
  }, restProps), {
14191
14187
  ref,
14192
14188
  children
@@ -14196,9 +14192,10 @@ const Table$1 = react.forwardRef(
14196
14192
  );
14197
14193
  Table$1.displayName = "Table";
14198
14194
  const TableHeaderInner = (_tb, ref) => {
14199
- var _ub = _tb, { children, className, hideHeader } = _ub, restProps = __objRest(_ub, ["children", "className", "hideHeader"]);
14195
+ var _ub = _tb, { children, className, hideHeader, nonAria } = _ub, restProps = __objRest(_ub, ["children", "className", "hideHeader", "nonAria"]);
14196
+ const TableHeaderComponent = nonAria ? "thead" : reactAriaComponents.TableHeader;
14200
14197
  return /* @__PURE__ */ jsxRuntime.jsx(
14201
- reactAriaComponents.TableHeader,
14198
+ TableHeaderComponent,
14202
14199
  __spreadProps(__spreadValues({
14203
14200
  className: getClassName("TableHeader", className, hideHeader)
14204
14201
  }, restProps), {
@@ -14210,9 +14207,10 @@ const TableHeaderInner = (_tb, ref) => {
14210
14207
  const TableHeader = react.forwardRef(TableHeaderInner);
14211
14208
  TableHeader.displayName = "TableHeader";
14212
14209
  const TableBodyInner = (_vb, ref) => {
14213
- var _wb = _vb, { children, className } = _wb, restProps = __objRest(_wb, ["children", "className"]);
14210
+ var _wb = _vb, { children, className, nonAria } = _wb, restProps = __objRest(_wb, ["children", "className", "nonAria"]);
14211
+ const TableBodyComponent = nonAria ? "tbody" : reactAriaComponents.TableBody;
14214
14212
  return /* @__PURE__ */ jsxRuntime.jsx(
14215
- reactAriaComponents.TableBody,
14213
+ TableBodyComponent,
14216
14214
  __spreadProps(__spreadValues({
14217
14215
  className: getClassName("TableBody", className)
14218
14216
  }, restProps), {
@@ -14224,14 +14222,16 @@ const TableBodyInner = (_vb, ref) => {
14224
14222
  const TableBody$1 = react.forwardRef(TableBodyInner);
14225
14223
  TableBody$1.displayName = "TableBody";
14226
14224
  const RowInner = (_xb, ref) => {
14227
- var _yb = _xb, { children, className, depth = 0 } = _yb, restProps = __objRest(_yb, ["children", "className", "depth"]);
14225
+ var _yb = _xb, { children, className, depth = 0, nonAria, id } = _yb, restProps = __objRest(_yb, ["children", "className", "depth", "nonAria", "id"]);
14228
14226
  const dataProperties = toDataProperties({ depth });
14227
+ const RowComponent = nonAria ? "tr" : reactAriaComponents.Row;
14229
14228
  return /* @__PURE__ */ jsxRuntime.jsx(
14230
- reactAriaComponents.Row,
14229
+ RowComponent,
14231
14230
  __spreadProps(__spreadValues(__spreadValues({
14232
14231
  className: getClassName("Row", className)
14233
14232
  }, restProps), dataProperties), {
14234
14233
  ref,
14234
+ id: id == null ? void 0 : id.toString(),
14235
14235
  children: withRenderProp(children, (node) => node)
14236
14236
  })
14237
14237
  );
@@ -14240,14 +14240,18 @@ const Row = react.forwardRef(RowInner);
14240
14240
  Row.displayName = "Row";
14241
14241
  const Column = react.forwardRef(
14242
14242
  (_zb, ref) => {
14243
- var _Ab = _zb, { children, className, textAlign = "left" } = _Ab, restProps = __objRest(_Ab, ["children", "className", "textAlign"]);
14243
+ var _Ab = _zb, { children, className, nonAria, id, textAlign = "left", colSpan = 1 } = _Ab, restProps = __objRest(_Ab, ["children", "className", "nonAria", "id", "textAlign", "colSpan"]);
14244
14244
  const dataProperties = toDataProperties({ "text-align": textAlign });
14245
+ const columnClassName = getClassName("Column", className);
14246
+ const ColumnComponent = nonAria ? "th" : reactAriaComponents.Column;
14245
14247
  return /* @__PURE__ */ jsxRuntime.jsx(
14246
- reactAriaComponents.Column,
14248
+ ColumnComponent,
14247
14249
  __spreadProps(__spreadValues(__spreadValues({
14248
- className: getClassName("Column", className)
14250
+ className: columnClassName
14249
14251
  }, restProps), dataProperties), {
14250
14252
  ref,
14253
+ id: id == null ? void 0 : id.toString(),
14254
+ colSpan,
14251
14255
  children: withRenderProp(children, (node) => node)
14252
14256
  })
14253
14257
  );
@@ -14256,19 +14260,44 @@ const Column = react.forwardRef(
14256
14260
  Column.displayName = "Column";
14257
14261
  const Cell = react.forwardRef(
14258
14262
  (_Bb, ref) => {
14259
- var _Cb = _Bb, { children, className } = _Cb, restProps = __objRest(_Cb, ["children", "className"]);
14263
+ var _Cb = _Bb, { children, className, nonAria, id } = _Cb, restProps = __objRest(_Cb, ["children", "className", "nonAria", "id"]);
14264
+ const CellComponent = nonAria ? "td" : reactAriaComponents.Cell;
14260
14265
  return /* @__PURE__ */ jsxRuntime.jsx(
14261
- reactAriaComponents.Cell,
14266
+ CellComponent,
14262
14267
  __spreadProps(__spreadValues({
14263
14268
  className: getClassName("Cell", className)
14264
14269
  }, restProps), {
14265
14270
  ref,
14271
+ id: id == null ? void 0 : id.toString(),
14266
14272
  children: withRenderProp(children, (node) => node)
14267
14273
  })
14268
14274
  );
14269
14275
  }
14270
14276
  );
14271
14277
  Cell.displayName = "Cell";
14278
+ const isLeafColumn = (col) => {
14279
+ return "cell" in col;
14280
+ };
14281
+ const getColumnDefs = (columnConfig) => {
14282
+ const columnHelper = reactTable.createColumnHelper();
14283
+ return columnConfig.map((col) => {
14284
+ if (isLeafColumn(col)) {
14285
+ return columnHelper.display({
14286
+ id: col.id,
14287
+ header: () => col.header,
14288
+ cell: ({ row }) => col.cell(row),
14289
+ meta: {
14290
+ isRowHeader: col.isRowHeader || false
14291
+ }
14292
+ });
14293
+ }
14294
+ return columnHelper.group({
14295
+ id: col.id,
14296
+ header: () => col.header,
14297
+ columns: getColumnDefs(col.columns)
14298
+ });
14299
+ });
14300
+ };
14272
14301
  const Loader = ({ children, size = 28 }) => {
14273
14302
  return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "Layer__loader", children: [
14274
14303
  /* @__PURE__ */ jsxRuntime.jsx(Loader$1, { size, className: "Layer__anim--rotating" }),
@@ -14304,19 +14333,8 @@ const VirtualizedDataTable = ({
14304
14333
  const calculatedHeight = actualRowCount * rowHeight + HEADER_HEIGHT + 1;
14305
14334
  return Math.min(height, calculatedHeight);
14306
14335
  }, [data, height, rowHeight, shrinkHeightToFitRows]);
14307
- const columnHelper = reactTable.createColumnHelper();
14308
- const columns = Object.values(columnConfig);
14309
14336
  const tableData = data != null ? data : EMPTY_ARRAY$2;
14310
- const columnDefs = columns.map((col) => {
14311
- return columnHelper.display({
14312
- id: col.id,
14313
- header: () => col.header,
14314
- cell: ({ row }) => col.cell(row.original),
14315
- meta: {
14316
- isRowHeader: col.isRowHeader || false
14317
- }
14318
- });
14319
- });
14337
+ const columnDefs = getColumnDefs(columnConfig);
14320
14338
  const table2 = reactTable.useReactTable({
14321
14339
  data: tableData,
14322
14340
  columns: columnDefs,
@@ -14414,43 +14432,34 @@ const AffectedTransactionsTable = ({
14414
14432
  isLoading = false,
14415
14433
  isError = false
14416
14434
  }) => {
14417
- const columnConfig = react.useMemo(() => ({
14418
- [
14419
- "Date"
14420
- /* Date */
14421
- ]: {
14435
+ const columnConfig = react.useMemo(() => [
14436
+ {
14422
14437
  id: "Date",
14423
14438
  header: "Date",
14424
14439
  cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(
14425
14440
  DateTime,
14426
14441
  {
14427
- valueAsDate: row.date,
14442
+ valueAsDate: row.original.date,
14428
14443
  onlyDate: true,
14429
14444
  slotProps: { Date: { size: TextSize.md, weight: TextWeight.normal, variant: "subtle" } }
14430
14445
  }
14431
14446
  )
14432
14447
  },
14433
- [
14434
- "Description"
14435
- /* Description */
14436
- ]: {
14448
+ {
14437
14449
  id: "Description",
14438
14450
  header: "Description",
14439
- cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(Span, { withTooltip: true, children: row.counterpartyName || row.description || "-" }),
14451
+ cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(Span, { withTooltip: true, children: row.original.counterpartyName || row.original.description || "-" }),
14440
14452
  isRowHeader: true
14441
14453
  },
14442
- [
14443
- "Amount"
14444
- /* Amount */
14445
- ]: {
14454
+ {
14446
14455
  id: "Amount",
14447
14456
  header: "Amount",
14448
14457
  cell: (row) => {
14449
- const amount = row.direction === BankTransactionDirection.Credit ? row.amount : -row.amount;
14458
+ const amount = row.original.direction === BankTransactionDirection.Credit ? row.original.amount : -row.original.amount;
14450
14459
  return /* @__PURE__ */ jsxRuntime.jsx(MoneySpan, { amount });
14451
14460
  }
14452
14461
  }
14453
- }), []);
14462
+ ], []);
14454
14463
  return /* @__PURE__ */ jsxRuntime.jsx(VStack, { className: "Layer__AffectedTransactionsTable", children: /* @__PURE__ */ jsxRuntime.jsx(
14455
14464
  VirtualizedDataTable,
14456
14465
  {
@@ -17826,7 +17835,7 @@ const ExpandedBankTransactionRow = ({
17826
17835
  className: `${className} ${className}--${isOpen ? "expanded" : "collapsed"}`,
17827
17836
  children: isOpen && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
17828
17837
  /* @__PURE__ */ jsxRuntime.jsx(Separator, {}),
17829
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${className}__wrapper`, ref: bodyRef, children: /* @__PURE__ */ jsxRuntime.jsxs(VStack, { pis: variant === "row" ? "md" : void 0, pbs: "sm", children: [
17838
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${className}__wrapper`, ref: bodyRef, children: /* @__PURE__ */ jsxRuntime.jsxs(VStack, { pis: variant === "row" ? "md" : void 0, pbs: "sm", pbe: "md", children: [
17830
17839
  categorizationEnabled && /* @__PURE__ */ jsxRuntime.jsx(HStack, { pi: "md", pbe: "md", pbs: "3xs", children: /* @__PURE__ */ jsxRuntime.jsx(
17831
17840
  Toggle,
17832
17841
  {
@@ -18484,7 +18493,7 @@ const BankTransactionsListItem = ({
18484
18493
  onValidityChange: setIsExpandedRowValid
18485
18494
  }
18486
18495
  ) }, `expanded-${bankTransaction.id}`) }),
18487
- categorizationEnabled && !displayAsCategorized && /* @__PURE__ */ jsxRuntime.jsx("div", { onClick: preventRowExpansion, children: /* @__PURE__ */ jsxRuntime.jsxs(HStack, { pi: "md", gap: "md", pb: "md", justify: "end", children: [
18496
+ categorizationEnabled && !displayAsCategorized && /* @__PURE__ */ jsxRuntime.jsx("div", { onClick: preventRowExpansion, children: /* @__PURE__ */ jsxRuntime.jsxs(HStack, { pi: "md", gap: "md", pbe: "md", justify: "end", children: [
18488
18497
  !openExpandedRow && /* @__PURE__ */ jsxRuntime.jsx(
18489
18498
  BankTransactionCategoryComboBox,
18490
18499
  {
@@ -18593,16 +18602,13 @@ const BankTransactionsMobileBulkActionsHeader = ({
18593
18602
  gap: "md",
18594
18603
  align: "center",
18595
18604
  justify: "space-between",
18596
- pis: "xs",
18597
- pie: "md",
18605
+ pi: "md",
18598
18606
  pb: "xs",
18599
- className: "Layer__BankTransactionsMobileBulkActionsHeader",
18600
18607
  children: [
18601
18608
  /* @__PURE__ */ jsxRuntime.jsx(
18602
18609
  HStack,
18603
18610
  {
18604
18611
  align: "center",
18605
- pi: "xs",
18606
18612
  gap: "xs",
18607
18613
  children: bulkActionsEnabled && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
18608
18614
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -18956,20 +18962,37 @@ const BankTransactionsMobileListBusinessForm = ({
18956
18962
  )
18957
18963
  ] });
18958
18964
  };
18959
- var PersonalCategories = /* @__PURE__ */ ((PersonalCategories2) => {
18960
- PersonalCategories2["INCOME"] = "PERSONAL_INFLOWS";
18961
- PersonalCategories2["EXPENSES"] = "PERSONAL_EXPENSES";
18962
- return PersonalCategories2;
18963
- })(PersonalCategories || {});
18965
+ var PersonalStableName = /* @__PURE__ */ ((PersonalStableName2) => {
18966
+ PersonalStableName2["CREDIT"] = "CONTRIBUTIONS";
18967
+ PersonalStableName2["DEBIT"] = "PERSONAL_EXPENSES";
18968
+ return PersonalStableName2;
18969
+ })(PersonalStableName || {});
18970
+ var LegacyPersonalCategories = /* @__PURE__ */ ((LegacyPersonalCategories2) => {
18971
+ LegacyPersonalCategories2["INCOME"] = "PERSONAL_INFLOWS";
18972
+ LegacyPersonalCategories2["EXPENSES"] = "PERSONAL_EXPENSES";
18973
+ return LegacyPersonalCategories2;
18974
+ })(LegacyPersonalCategories || {});
18964
18975
  const isAlreadyAssigned = (bankTransaction) => {
18965
18976
  if (bankTransaction.categorization_status === CategorizationStatus.MATCHED || (bankTransaction == null ? void 0 : bankTransaction.categorization_status) === CategorizationStatus.SPLIT) {
18966
18977
  return false;
18967
18978
  }
18968
- return Boolean(
18969
- bankTransaction.category && Object.values(PersonalCategories).includes(
18970
- bankTransaction.category.display_name
18971
- )
18972
- );
18979
+ if (!bankTransaction.category) {
18980
+ return false;
18981
+ }
18982
+ const category = bankTransaction.category;
18983
+ if (category.type === "Account" && "stable_name" in category) {
18984
+ const stableName = category.stable_name;
18985
+ if (stableName === PersonalStableName.CREDIT || stableName === PersonalStableName.DEBIT) {
18986
+ return true;
18987
+ }
18988
+ }
18989
+ if (category.type === "Exclusion") {
18990
+ const displayName = category.display_name;
18991
+ if (Object.values(LegacyPersonalCategories).includes(displayName)) {
18992
+ return true;
18993
+ }
18994
+ }
18995
+ return false;
18973
18996
  };
18974
18997
  const BankTransactionsMobileListPersonalForm = ({
18975
18998
  bankTransaction,
@@ -18998,8 +19021,8 @@ const BankTransactionsMobileListPersonalForm = ({
18998
19021
  {
18999
19022
  type: "Category",
19000
19023
  category: {
19001
- type: "Exclusion",
19002
- exclusionType: isCredit(bankTransaction) ? PersonalCategories.INCOME : PersonalCategories.EXPENSES
19024
+ type: "StableName",
19025
+ stableName: isCredit(bankTransaction) ? PersonalStableName.CREDIT : PersonalStableName.DEBIT
19003
19026
  }
19004
19027
  },
19005
19028
  true
@@ -19537,9 +19560,24 @@ const BankTransactionsMobileListItemExpandedRow = ({
19537
19560
  )
19538
19561
  ] });
19539
19562
  };
19563
+ const isPersonalCategory = (category) => {
19564
+ if (!category) {
19565
+ return false;
19566
+ }
19567
+ if (category.type === "Account" && "stable_name" in category) {
19568
+ const stableName = category.stable_name;
19569
+ if (stableName === PersonalStableName.CREDIT || stableName === PersonalStableName.DEBIT) {
19570
+ return true;
19571
+ }
19572
+ }
19573
+ if (category.type === "Exclusion") {
19574
+ return true;
19575
+ }
19576
+ return false;
19577
+ };
19540
19578
  const getInitialPurpose = (bankTransaction) => {
19541
19579
  if (bankTransaction.category) {
19542
- if (bankTransaction.category.type === "Exclusion") {
19580
+ if (isPersonalCategory(bankTransaction.category)) {
19543
19581
  return Purpose.personal;
19544
19582
  }
19545
19583
  if (bankTransaction.categorization_status === CategorizationStatus.SPLIT) {
@@ -20072,43 +20110,56 @@ function useArchiveCategorizationRule() {
20072
20110
  });
20073
20111
  }
20074
20112
  const DataTable = ({
20075
- columnConfig,
20076
- data,
20077
20113
  isLoading,
20078
20114
  isError,
20079
20115
  componentName,
20080
20116
  ariaLabel,
20081
20117
  slots,
20082
20118
  hideHeader,
20083
- dependencies
20119
+ dependencies,
20120
+ data,
20121
+ headerGroups,
20122
+ numColumns
20084
20123
  }) => {
20085
- const columns = Object.values(columnConfig);
20124
+ const nonAria = headerGroups.length > 1;
20086
20125
  const { EmptyState: EmptyState2, ErrorState: ErrorState2 } = slots;
20087
20126
  const isEmptyTable = (data == null ? void 0 : data.length) === 0;
20088
20127
  const renderTableBody = react.useMemo(() => {
20089
20128
  if (isError) {
20090
- return /* @__PURE__ */ jsxRuntime.jsx(Row, { className: "Layer__DataTable__EmptyState__Row", children: /* @__PURE__ */ jsxRuntime.jsx(Cell, { className: "Layer__DataTable__EmptyState__Cell", colSpan: columns.length, children: /* @__PURE__ */ jsxRuntime.jsx(ErrorState2, {}) }) });
20129
+ return /* @__PURE__ */ jsxRuntime.jsx(Row, { className: "Layer__DataTable__EmptyState__Row", nonAria, children: /* @__PURE__ */ jsxRuntime.jsx(Cell, { className: "Layer__DataTable__EmptyState__Cell", colSpan: numColumns, nonAria, children: /* @__PURE__ */ jsxRuntime.jsx(ErrorState2, {}) }) });
20091
20130
  }
20092
20131
  if (isLoading) {
20093
- return /* @__PURE__ */ jsxRuntime.jsx(Row, { className: "Layer__DataTable__EmptyState__Row", children: /* @__PURE__ */ jsxRuntime.jsx(Cell, { className: "Layer__DataTable__EmptyState__Cell", colSpan: columns.length, children: /* @__PURE__ */ jsxRuntime.jsx(Loader, {}) }) });
20132
+ return /* @__PURE__ */ jsxRuntime.jsx(Row, { className: "Layer__DataTable__EmptyState__Row", nonAria, children: /* @__PURE__ */ jsxRuntime.jsx(Cell, { className: "Layer__DataTable__EmptyState__Cell", colSpan: numColumns, nonAria, children: /* @__PURE__ */ jsxRuntime.jsx(Loader, {}) }) });
20094
20133
  }
20095
20134
  if (isEmptyTable) {
20096
- return /* @__PURE__ */ jsxRuntime.jsx(Row, { className: "Layer__DataTable__EmptyState__Row", children: /* @__PURE__ */ jsxRuntime.jsx(Cell, { className: "Layer__DataTable__EmptyState__Cell", colSpan: columns.length, children: /* @__PURE__ */ jsxRuntime.jsx(EmptyState2, {}) }) });
20135
+ return /* @__PURE__ */ jsxRuntime.jsx(Row, { className: "Layer__DataTable__EmptyState__Row", nonAria, children: /* @__PURE__ */ jsxRuntime.jsx(Cell, { className: "Layer__DataTable__EmptyState__Cell", colSpan: numColumns, nonAria, children: /* @__PURE__ */ jsxRuntime.jsx(EmptyState2, {}) }) });
20097
20136
  }
20098
- const RowRenderer = (row) => /* @__PURE__ */ jsxRuntime.jsx(Row, { depth: row == null ? void 0 : row.depth, children: columns.map((col) => /* @__PURE__ */ jsxRuntime.jsx(
20137
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: data == null ? void 0 : data.map((row) => /* @__PURE__ */ jsxRuntime.jsx(Row, { depth: row.depth, nonAria, children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsxRuntime.jsx(
20099
20138
  Cell,
20100
20139
  {
20101
- className: `Layer__UI__Table-Cell__${componentName}--${col.id}`,
20102
- children: col.cell(row)
20140
+ className: `Layer__UI__Table-Cell__${componentName}--${cell.column.id}`,
20141
+ nonAria,
20142
+ children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext())
20103
20143
  },
20104
- `${row.id}-${col.id}`
20105
- )) }, row.id);
20106
- RowRenderer.displayName = "Row";
20107
- return RowRenderer;
20108
- }, [isError, isLoading, isEmptyTable, columns, ErrorState2, EmptyState2, componentName]);
20109
- return /* @__PURE__ */ jsxRuntime.jsxs(Table$1, { "aria-label": ariaLabel, className: `Layer__UI__Table__${componentName}`, children: [
20110
- /* @__PURE__ */ jsxRuntime.jsx(TableHeader, { columns, hideHeader, children: ({ id, header, isRowHeader }) => /* @__PURE__ */ jsxRuntime.jsx(Column, { isRowHeader, className: `Layer__UI__Table-Column__${componentName}--${id}`, children: header }, id) }),
20111
- /* @__PURE__ */ jsxRuntime.jsx(TableBody$1, { items: data, dependencies, children: renderTableBody })
20144
+ `${row.id}-${cell.id}`
20145
+ )) }, row.id)) });
20146
+ }, [isError, isLoading, isEmptyTable, data, nonAria, numColumns, ErrorState2, EmptyState2, componentName]);
20147
+ return /* @__PURE__ */ jsxRuntime.jsxs(Table$1, { "aria-label": ariaLabel, className: `Layer__UI__Table__${componentName}`, nonAria, children: [
20148
+ /* @__PURE__ */ jsxRuntime.jsx(TableHeader, { hideHeader, nonAria, children: headerGroups.map((headerGroup) => /* @__PURE__ */ jsxRuntime.jsx(Row, { nonAria, children: headerGroup.headers.map((header) => {
20149
+ var _a;
20150
+ return /* @__PURE__ */ jsxRuntime.jsx(
20151
+ Column,
20152
+ {
20153
+ isRowHeader: (_a = header.column.columnDef.meta) == null ? void 0 : _a.isRowHeader,
20154
+ className: `Layer__UI__Table-Column__${componentName}--${header.id}`,
20155
+ nonAria,
20156
+ colSpan: header.colSpan,
20157
+ children: header.isPlaceholder ? null : typeof header.column.columnDef.header === "function" ? header.column.columnDef.header(header.getContext()) : header.column.columnDef.header
20158
+ },
20159
+ header.id
20160
+ );
20161
+ }) }, headerGroup.id)) }),
20162
+ /* @__PURE__ */ jsxRuntime.jsx(TableBody$1, { dependencies, nonAria, children: renderTableBody })
20112
20163
  ] });
20113
20164
  };
20114
20165
  var Dots = /* @__PURE__ */ ((Dots2) => {
@@ -20262,15 +20313,7 @@ function PaginatedTable({
20262
20313
  var _a;
20263
20314
  const { pageSize = 20, hasMore, fetchMore, initialPage = 0, onSetPage, autoResetPageIndexRef } = paginationProps;
20264
20315
  const [pagination, setPagination] = react.useState({ pageIndex: initialPage, pageSize });
20265
- const columnHelper = reactTable.createColumnHelper();
20266
- const columns = Object.values(columnConfig);
20267
- const columnDefs = columns.map((col) => {
20268
- return columnHelper.display({
20269
- id: col.id,
20270
- header: () => col.header,
20271
- cell: ({ row }) => col.cell(row.original)
20272
- });
20273
- });
20316
+ const columnDefs = getColumnDefs(columnConfig);
20274
20317
  const table2 = reactTable.useReactTable({
20275
20318
  data: data != null ? data : [],
20276
20319
  columns: columnDefs,
@@ -20285,21 +20328,23 @@ function PaginatedTable({
20285
20328
  autoResetPageIndex: (_a = autoResetPageIndexRef == null ? void 0 : autoResetPageIndexRef.current) != null ? _a : false
20286
20329
  });
20287
20330
  const { rows } = table2.getRowModel();
20288
- const rowData = react.useMemo(() => rows.map((r) => r.original), [rows]);
20289
20331
  const onPageChange = react.useCallback((page) => {
20290
20332
  table2.setPageIndex(page - 1);
20291
20333
  }, [table2]);
20334
+ const headerGroups = table2.getHeaderGroups();
20335
+ const numColumns = table2.getVisibleLeafColumns().length;
20292
20336
  return /* @__PURE__ */ jsxRuntime.jsxs(VStack, { children: [
20293
20337
  /* @__PURE__ */ jsxRuntime.jsx(
20294
20338
  DataTable,
20295
20339
  {
20296
20340
  ariaLabel,
20297
- columnConfig,
20298
- data: rowData,
20341
+ numColumns,
20342
+ data: rows,
20299
20343
  isLoading,
20300
20344
  isError,
20301
20345
  componentName,
20302
- slots
20346
+ slots,
20347
+ headerGroups
20303
20348
  }
20304
20349
  ),
20305
20350
  !isError && !isLoading && /* @__PURE__ */ jsxRuntime.jsx(
@@ -20389,34 +20434,25 @@ const CategorizationRulesTable = () => {
20389
20434
  spacing: true
20390
20435
  }
20391
20436
  ), [refetch]);
20392
- const columnConfig = react.useMemo(() => ({
20393
- [
20394
- "Counterparty"
20395
- /* Counterparty */
20396
- ]: {
20437
+ const columnConfig = react.useMemo(() => [
20438
+ {
20397
20439
  id: "Counterparty",
20398
20440
  header: "Counterparty",
20399
20441
  cell: (row) => {
20400
20442
  var _a2;
20401
- return /* @__PURE__ */ jsxRuntime.jsx(Span, { ellipsis: true, children: (_a2 = row.counterpartyFilter) == null ? void 0 : _a2.name });
20443
+ return /* @__PURE__ */ jsxRuntime.jsx(Span, { ellipsis: true, children: (_a2 = row.original.counterpartyFilter) == null ? void 0 : _a2.name });
20402
20444
  }
20403
20445
  },
20404
- [
20405
- "Category"
20406
- /* Category */
20407
- ]: {
20446
+ {
20408
20447
  id: "Category",
20409
20448
  header: "Category",
20410
20449
  cell: (row) => {
20411
- const accountIdentifier = row.category;
20450
+ const accountIdentifier = row.original.category;
20412
20451
  return accountIdentifier && /* @__PURE__ */ jsxRuntime.jsx(CategoryDisplay, { accountIdentifier, options: options2 });
20413
20452
  },
20414
20453
  isRowHeader: true
20415
20454
  },
20416
- [
20417
- "Delete"
20418
- /* Delete */
20419
- ]: {
20455
+ {
20420
20456
  id: "Delete",
20421
20457
  cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(
20422
20458
  Button,
@@ -20424,7 +20460,7 @@ const CategorizationRulesTable = () => {
20424
20460
  inset: true,
20425
20461
  icon: true,
20426
20462
  onPress: () => {
20427
- setSelectedRule(row);
20463
+ setSelectedRule(row.original);
20428
20464
  setShowDeletionConfirmationModal(true);
20429
20465
  },
20430
20466
  "aria-label": "Delete rule",
@@ -20433,7 +20469,7 @@ const CategorizationRulesTable = () => {
20433
20469
  }
20434
20470
  )
20435
20471
  }
20436
- }), [options2]);
20472
+ ], [options2]);
20437
20473
  return /* @__PURE__ */ jsxRuntime.jsxs(Container, { name: "CategorizationRulesTable", children: [
20438
20474
  /* @__PURE__ */ jsxRuntime.jsx(
20439
20475
  PaginatedTable,
@@ -22551,7 +22587,7 @@ const DatePicker = ({
22551
22587
  const getIsDateInvalid = (date2, { minDate, maxDate }) => {
22552
22588
  if (date2 === null) return "Cannot select empty date";
22553
22589
  if (minDate && date2.compare(minDate) < 0) return "Cannot select date before the business activation date";
22554
- if (maxDate && date2.compare(maxDate) > 0) return "Cannot select date after current date";
22590
+ if (maxDate && date2.compare(maxDate) > 0) return "Cannot select date in the future";
22555
22591
  return null;
22556
22592
  };
22557
22593
  const useDatePickerState = ({ date: date2, setDate, minDate = null, maxDate = null }) => {
@@ -23069,8 +23105,8 @@ const sortPnlLineItemsAndCalculateTotal = (items, filter) => {
23069
23105
  };
23070
23106
  const useProfitAndLoss = ({ tagFilter, reportingBasis }) => {
23071
23107
  var _a;
23072
- const [displayMode, setDisplayMode] = react.useState("month");
23073
- const dateRange = useGlobalDateRange({ displayMode });
23108
+ const [dateSelectionMode, setDateSelectionMode] = react.useState("month");
23109
+ const dateRange = useGlobalDateRange({ dateSelectionMode });
23074
23110
  const [filters, setFilters] = react.useState({
23075
23111
  expenses: void 0,
23076
23112
  revenue: void 0
@@ -23129,8 +23165,8 @@ const useProfitAndLoss = ({ tagFilter, reportingBasis }) => {
23129
23165
  dateRange,
23130
23166
  selectedLineItem,
23131
23167
  setSelectedLineItem,
23132
- setDisplayMode,
23133
- displayMode
23168
+ setDateSelectionMode,
23169
+ dateSelectionMode
23134
23170
  };
23135
23171
  };
23136
23172
  function isArrayWithAtLeastOne(list) {
@@ -23317,9 +23353,9 @@ const ProfitAndLossContext = react.createContext({
23317
23353
  selectedLineItem: null,
23318
23354
  setSelectedLineItem: () => {
23319
23355
  },
23320
- setDisplayMode: () => {
23356
+ setDateSelectionMode: () => {
23321
23357
  },
23322
- displayMode: "month"
23358
+ dateSelectionMode: "month"
23323
23359
  });
23324
23360
  const isNotOnlyNoneTag = (compareOptions) => {
23325
23361
  return Boolean(
@@ -23351,8 +23387,8 @@ function useProfitAndLossComparison({
23351
23387
  }) {
23352
23388
  var _a;
23353
23389
  const [comparisonPeriodMode, setComparisonPeriodMode] = react.useState(DateGroupBy.AllTime);
23354
- const { displayMode } = react.useContext(ProfitAndLossContext);
23355
- const { startDate, endDate } = useGlobalDateRange({ displayMode: "month" });
23390
+ const { dateSelectionMode } = react.useContext(ProfitAndLossContext);
23391
+ const { startDate, endDate } = useGlobalDateRange({ dateSelectionMode: "month" });
23356
23392
  const comparePeriods = react.useMemo(() => {
23357
23393
  if (!comparisonPeriodMode || comparisonPeriodMode === DateGroupBy.AllTime) {
23358
23394
  return 1;
@@ -23365,7 +23401,7 @@ function useProfitAndLossComparison({
23365
23401
  const [selectedCompareOptions, setSelectedCompareOptionsState] = react.useState(
23366
23402
  (comparisonConfig == null ? void 0 : comparisonConfig.defaultTagFilter) ? [comparisonConfig == null ? void 0 : comparisonConfig.defaultTagFilter] : []
23367
23403
  );
23368
- const dateRange = useGlobalDateRange({ displayMode });
23404
+ const dateRange = useGlobalDateRange({ dateSelectionMode });
23369
23405
  const compareModeActive = react.useMemo(() => comparePeriods > 1 || selectedCompareOptions.length > 1 || selectedCompareOptions.length === 1 && isNotOnlyNoneTag(selectedCompareOptions), [comparePeriods, selectedCompareOptions]);
23370
23406
  const setSelectedCompareOptions = (values) => {
23371
23407
  const options2 = values.map(
@@ -23713,7 +23749,7 @@ const ProfitAndLossChart = ({
23713
23749
  const [compactView, setCompactView] = react.useState(false);
23714
23750
  const barSize = compactView ? 10 : 20;
23715
23751
  const { getColor, business } = useLayerContext();
23716
- const dateRange = useGlobalDateRange({ displayMode: "month" });
23752
+ const dateRange = useGlobalDateRange({ dateSelectionMode: "month" });
23717
23753
  const { setMonth } = useGlobalDateRangeActions();
23718
23754
  const [customCursorSize, setCustomCursorSize] = react.useState({
23719
23755
  width: 0,
@@ -24346,14 +24382,19 @@ const BackButton = (_Ec) => {
24346
24382
  const baseClassName2 = classNames("Layer__btn", "Layer__back-btn", className);
24347
24383
  return /* @__PURE__ */ jsxRuntime.jsx("button", __spreadProps(__spreadValues({}, props), { className: baseClassName2, children: textOnly ? "Back" : /* @__PURE__ */ jsxRuntime.jsx(BackArrow, { size: 16 }) }));
24348
24384
  };
24349
- const GlobalMonthPicker = ({ truncateMonth }) => {
24385
+ function useGlobalDatePickerBounds() {
24350
24386
  const rawActivationDate = useBusinessActivationDate();
24351
- const activationDate = react.useMemo(() => rawActivationDate ? dateFns.startOfDay(rawActivationDate) : null, [rawActivationDate]);
24387
+ const minDate = react.useMemo(() => rawActivationDate ? dateFns.startOfDay(rawActivationDate) : null, [rawActivationDate]);
24388
+ const maxDate = react.useMemo(() => dateFns.endOfDay(/* @__PURE__ */ new Date()), []);
24389
+ return react.useMemo(() => ({ minDate, maxDate }), [minDate, maxDate]);
24390
+ }
24391
+ const GlobalMonthPicker = ({ truncateMonth }) => {
24392
+ const { minDate, maxDate } = useGlobalDatePickerBounds();
24352
24393
  const { setMonth } = useGlobalDateRangeActions();
24353
- const { date: date2 } = useGlobalDate();
24394
+ const { date: date2 } = useGlobalDate({ dateSelectionMode: "month" });
24354
24395
  const dateZdt = react.useMemo(() => convertDateToZonedDateTime(date2), [date2]);
24355
- const minDateZdt = react.useMemo(() => activationDate ? convertDateToZonedDateTime(activationDate) : null, [activationDate]);
24356
- const maxDateZdt = react.useMemo(() => convertDateToZonedDateTime(dateFns.endOfToday()), []);
24396
+ const minDateZdt = react.useMemo(() => minDate ? convertDateToZonedDateTime(minDate) : null, [minDate]);
24397
+ const maxDateZdt = react.useMemo(() => convertDateToZonedDateTime(maxDate), [maxDate]);
24357
24398
  const onChange = react.useCallback((val) => {
24358
24399
  setMonth({ startDate: val.toDate() });
24359
24400
  }, [setMonth]);
@@ -25660,30 +25701,24 @@ const ProfitAndLossDetailReport = ({
25660
25701
  total: runningBalance
25661
25702
  };
25662
25703
  }, [data == null ? void 0 : data.lines]);
25663
- const columnConfig = react.useMemo(() => ({
25664
- [
25665
- "Date"
25666
- /* Date */
25667
- ]: {
25704
+ const columnConfig = react.useMemo(() => [
25705
+ {
25668
25706
  id: "Date",
25669
25707
  header: (stringOverrides == null ? void 0 : stringOverrides.dateColumnHeader) || "Date",
25670
25708
  cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(
25671
25709
  DateTime,
25672
25710
  {
25673
- value: row.date,
25711
+ value: row.original.date,
25674
25712
  onlyDate: true,
25675
25713
  slotProps: { Date: { size: TextSize.md, weight: TextWeight.normal, variant: "subtle" } }
25676
25714
  }
25677
25715
  )
25678
25716
  },
25679
- [
25680
- "Type"
25681
- /* Type */
25682
- ]: {
25717
+ {
25683
25718
  id: "Type",
25684
25719
  header: (stringOverrides == null ? void 0 : stringOverrides.typeColumnHeader) || "Type",
25685
25720
  cell: (row) => {
25686
- const { source } = row;
25721
+ const { source } = row.original;
25687
25722
  return source ? /* @__PURE__ */ jsxRuntime.jsx(
25688
25723
  Button,
25689
25724
  {
@@ -25694,10 +25729,7 @@ const ProfitAndLossDetailReport = ({
25694
25729
  ) : "-";
25695
25730
  }
25696
25731
  },
25697
- [
25698
- "Account"
25699
- /* Account */
25700
- ]: {
25732
+ {
25701
25733
  id: "Account",
25702
25734
  header: (stringOverrides == null ? void 0 : stringOverrides.accountColumnHeader) || "Account",
25703
25735
  cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(
@@ -25706,14 +25738,11 @@ const ProfitAndLossDetailReport = ({
25706
25738
  as: "span",
25707
25739
  withDeprecatedTooltip: TextUseTooltip.whenTruncated,
25708
25740
  ellipsis: true,
25709
- children: row.account.name || "-"
25741
+ children: row.original.account.name || "-"
25710
25742
  }
25711
25743
  )
25712
25744
  },
25713
- [
25714
- "Description"
25715
- /* Description */
25716
- ]: {
25745
+ {
25717
25746
  id: "Description",
25718
25747
  header: (stringOverrides == null ? void 0 : stringOverrides.descriptionColumnHeader) || "Description",
25719
25748
  cell: (row) => {
@@ -25724,33 +25753,27 @@ const ProfitAndLossDetailReport = ({
25724
25753
  as: "span",
25725
25754
  withDeprecatedTooltip: TextUseTooltip.whenTruncated,
25726
25755
  ellipsis: true,
25727
- children: ((_a = row.source) == null ? void 0 : _a.displayDescription) || row.account.accountSubtype.displayName || "-"
25756
+ children: ((_a = row.original.source) == null ? void 0 : _a.displayDescription) || row.original.account.accountSubtype.displayName || "-"
25728
25757
  }
25729
25758
  );
25730
25759
  },
25731
25760
  isRowHeader: true
25732
25761
  },
25733
- [
25734
- "Amount"
25735
- /* Amount */
25736
- ]: {
25762
+ {
25737
25763
  id: "Amount",
25738
25764
  header: (stringOverrides == null ? void 0 : stringOverrides.amountColumnHeader) || "Amount",
25739
25765
  cell: (row) => {
25740
- return /* @__PURE__ */ jsxRuntime.jsx(MoneySpan, { amount: row.direction === Direction.CREDIT ? row.amount : -row.amount });
25766
+ return /* @__PURE__ */ jsxRuntime.jsx(MoneySpan, { amount: row.original.direction === Direction.CREDIT ? row.original.amount : -row.original.amount });
25741
25767
  }
25742
25768
  },
25743
- [
25744
- "Balance"
25745
- /* Balance */
25746
- ]: {
25769
+ {
25747
25770
  id: "Balance",
25748
25771
  header: (stringOverrides == null ? void 0 : stringOverrides.balanceColumnHeader) || "Balance",
25749
25772
  cell: (row) => {
25750
- return /* @__PURE__ */ jsxRuntime.jsx(MoneySpan, { amount: row.runningBalance });
25773
+ return /* @__PURE__ */ jsxRuntime.jsx(MoneySpan, { amount: row.original.runningBalance });
25751
25774
  }
25752
25775
  }
25753
- }), [stringOverrides, handleSourceClick]);
25776
+ ], [stringOverrides, handleSourceClick]);
25754
25777
  const Header3 = react.useCallback(() => {
25755
25778
  return /* @__PURE__ */ jsxRuntime.jsx(
25756
25779
  DetailReportBreadcrumb,
@@ -26070,7 +26093,7 @@ const options$3 = Object.values(dateSelectionOptionConfig).filter((opt) => opt.v
26070
26093
  const DateSelectionComboBox = () => {
26071
26094
  const [lastPreset, setLastPreset] = react.useState(null);
26072
26095
  const { business } = useLayerContext();
26073
- const dateRange = useGlobalDateRange({ displayMode: "full" });
26096
+ const dateRange = useGlobalDateRange({ dateSelectionMode: "full" });
26074
26097
  const { setDateRange } = useGlobalDateRangeActions();
26075
26098
  const selectedPreset = presetForDateRange(dateRange, lastPreset, getActivationDate(business));
26076
26099
  const selectedOption = dateSelectionOptionConfig[selectedPreset != null ? selectedPreset : DatePreset.Custom];
@@ -26093,10 +26116,10 @@ const DateSelectionComboBox = () => {
26093
26116
  }
26094
26117
  );
26095
26118
  };
26096
- const DateRangeSelection = ({ minDate, maxDate }) => {
26097
- const { startDate: globalStartDate, endDate: globalEndDate } = useGlobalDateRange({ displayMode: "full" });
26119
+ const GlobalDateRangePicker = () => {
26120
+ const { startDate: globalStartDate, endDate: globalEndDate } = useGlobalDateRange({ dateSelectionMode: "full" });
26098
26121
  const { setDateRange: setGlobalDateRange } = useGlobalDateRangeActions();
26099
- const { value } = useSizeClass();
26122
+ const { minDate, maxDate } = useGlobalDatePickerBounds();
26100
26123
  const {
26101
26124
  localDate: localStartDate,
26102
26125
  onChange: onChangeStartDate,
@@ -26128,6 +26151,39 @@ const DateRangeSelection = ({ minDate, maxDate }) => {
26128
26151
  const next = { startDate: localStartDate.toDate(), endDate: localEndDate.toDate() };
26129
26152
  setGlobalDateRange(next);
26130
26153
  }, [startDateInvalid, endDateInvalid, localStartDate, localEndDate, setGlobalDateRange]);
26154
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
26155
+ /* @__PURE__ */ jsxRuntime.jsx(
26156
+ DatePicker,
26157
+ {
26158
+ label: "Start Date",
26159
+ showLabel: false,
26160
+ date: localStartDate,
26161
+ onChange: onChangeStartDate,
26162
+ minDate: minStartDate,
26163
+ maxDate: maxStartDate,
26164
+ isInvalid: startDateInvalid,
26165
+ errorText: startDateErrorText,
26166
+ onBlur: onBlurStartDate
26167
+ }
26168
+ ),
26169
+ /* @__PURE__ */ jsxRuntime.jsx(
26170
+ DatePicker,
26171
+ {
26172
+ label: "End Date",
26173
+ showLabel: false,
26174
+ date: localEndDate,
26175
+ onChange: onChangeEndDate,
26176
+ minDate: minEndDate,
26177
+ maxDate: maxEndDate,
26178
+ isInvalid: endDateInvalid,
26179
+ errorText: endDateErrorText,
26180
+ onBlur: onBlurEndDate
26181
+ }
26182
+ )
26183
+ ] });
26184
+ };
26185
+ const DateRangeSelection = () => {
26186
+ const { value } = useSizeClass();
26131
26187
  return /* @__PURE__ */ jsxRuntime.jsxs(
26132
26188
  HStack,
26133
26189
  {
@@ -26136,34 +26192,7 @@ const DateRangeSelection = ({ minDate, maxDate }) => {
26136
26192
  }),
26137
26193
  children: [
26138
26194
  /* @__PURE__ */ jsxRuntime.jsx(DateSelectionComboBox, {}),
26139
- /* @__PURE__ */ jsxRuntime.jsx(
26140
- DatePicker,
26141
- {
26142
- label: "Start Date",
26143
- showLabel: false,
26144
- date: localStartDate,
26145
- onChange: onChangeStartDate,
26146
- minDate: minStartDate,
26147
- maxDate: maxStartDate,
26148
- isInvalid: startDateInvalid,
26149
- errorText: startDateErrorText,
26150
- onBlur: onBlurStartDate
26151
- }
26152
- ),
26153
- /* @__PURE__ */ jsxRuntime.jsx(
26154
- DatePicker,
26155
- {
26156
- label: "End Date",
26157
- showLabel: false,
26158
- date: localEndDate,
26159
- onChange: onChangeEndDate,
26160
- minDate: minEndDate,
26161
- maxDate: maxEndDate,
26162
- isInvalid: endDateInvalid,
26163
- errorText: endDateErrorText,
26164
- onBlur: onBlurEndDate
26165
- }
26166
- )
26195
+ /* @__PURE__ */ jsxRuntime.jsx(GlobalDateRangePicker, {})
26167
26196
  ]
26168
26197
  }
26169
26198
  );
@@ -26488,7 +26517,7 @@ const ProfitAndLossCompareOptions = () => {
26488
26517
  comparisonPeriodMode,
26489
26518
  setComparisonPeriodMode
26490
26519
  } = react.useContext(ProfitAndLossComparisonContext);
26491
- const { displayMode } = react.useContext(ProfitAndLossContext);
26520
+ const { dateSelectionMode } = react.useContext(ProfitAndLossContext);
26492
26521
  const tagComparisonSelectOptions = compareOptions.map(
26493
26522
  (tagComparisonOption) => {
26494
26523
  return {
@@ -26501,7 +26530,7 @@ const ProfitAndLossCompareOptions = () => {
26501
26530
  return null;
26502
26531
  }
26503
26532
  return /* @__PURE__ */ jsxRuntime.jsxs(HStack, { align: "center", gap: "xs", children: [
26504
- displayMode === "full" && /* @__PURE__ */ jsxRuntime.jsx(DateGroupByComboBox, { value: comparisonPeriodMode, onValueChange: setComparisonPeriodMode }),
26533
+ dateSelectionMode === "full" && /* @__PURE__ */ jsxRuntime.jsx(DateGroupByComboBox, { value: comparisonPeriodMode, onValueChange: setComparisonPeriodMode }),
26505
26534
  /* @__PURE__ */ jsxRuntime.jsx(
26506
26535
  MultiSelect,
26507
26536
  {
@@ -26676,7 +26705,7 @@ const useTableExpandRow = () => {
26676
26705
  const ProfitAndLossCompareTable = ({
26677
26706
  stringOverrides
26678
26707
  }) => {
26679
- const { dateRange, displayMode } = react.useContext(ProfitAndLossContext);
26708
+ const { dateRange, dateSelectionMode } = react.useContext(ProfitAndLossContext);
26680
26709
  const {
26681
26710
  data: comparisonData,
26682
26711
  isLoading,
@@ -26693,7 +26722,7 @@ const ProfitAndLossCompareTable = ({
26693
26722
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "Layer__profit-and-loss-table__loader-container", children: /* @__PURE__ */ jsxRuntime.jsx(Loader, {}) });
26694
26723
  }
26695
26724
  const getBookkeepingPeriodStatus = (date2) => {
26696
- if (!bookkeepingPeriods || displayMode !== "month") {
26725
+ if (!bookkeepingPeriods || dateSelectionMode !== "month") {
26697
26726
  return;
26698
26727
  }
26699
26728
  const currentMonth = date2.getMonth() + 1;
@@ -27122,11 +27151,11 @@ const ProfitAndLossReport = ({
27122
27151
  hideHeader
27123
27152
  }) => {
27124
27153
  var _a;
27125
- const { selectedLineItem, setSelectedLineItem, setDisplayMode } = react.useContext(ProfitAndLossContext);
27154
+ const { selectedLineItem, setSelectedLineItem, setDateSelectionMode } = react.useContext(ProfitAndLossContext);
27126
27155
  const { comparisonConfig } = react.useContext(ProfitAndLossComparisonContext);
27127
27156
  react.useEffect(() => {
27128
- setDisplayMode(dateSelectionMode);
27129
- }, [dateSelectionMode, setDisplayMode]);
27157
+ setDateSelectionMode(dateSelectionMode);
27158
+ }, [dateSelectionMode, setDateSelectionMode]);
27130
27159
  const breadcrumbIndexMap = react.useMemo(() => {
27131
27160
  if (!selectedLineItem) return {};
27132
27161
  return selectedLineItem.breadcrumbPath.reduce((acc, item, index2) => {
@@ -27473,7 +27502,7 @@ function Internal_ProfitAndLossSummaries({
27473
27502
  setSidebarScope,
27474
27503
  sidebarScope
27475
27504
  } = react.useContext(ProfitAndLossContext);
27476
- const { startDate, endDate: _endDate } = useGlobalDateRange({ displayMode: "month" });
27505
+ const { startDate, endDate: _endDate } = useGlobalDateRange({ dateSelectionMode: "month" });
27477
27506
  const previousMonthStart = dateFns.sub(startDate, { months: 1 });
27478
27507
  const { data: previousData } = useProfitAndLossSummaries({
27479
27508
  startYear: previousMonthStart.getFullYear(),
@@ -27980,18 +28009,16 @@ const BalanceSheetTable = ({
27980
28009
  ] });
27981
28010
  };
27982
28011
  const GlobalDatePicker = () => {
27983
- const { date: date2 } = useGlobalDate();
28012
+ const { date: date2 } = useGlobalDate({ dateSelectionMode: "full" });
27984
28013
  const { setDate: setGlobalDate } = useGlobalDateActions();
27985
- const rawActivationDate = useBusinessActivationDate();
27986
- const activationDate = react.useMemo(() => rawActivationDate ? dateFns.startOfDay(rawActivationDate) : null, [rawActivationDate]);
27987
- const maxDate = react.useMemo(() => dateFns.endOfDay(/* @__PURE__ */ new Date()), []);
28014
+ const { minDate, maxDate } = useGlobalDatePickerBounds();
27988
28015
  const setDate = react.useCallback((date22) => {
27989
28016
  setGlobalDate({ date: date22 });
27990
28017
  }, [setGlobalDate]);
27991
28018
  const { localDate, onChange, minDateZdt, maxDateZdt, errorText, onBlur, isInvalid } = useDatePickerState({
27992
28019
  date: date2,
27993
28020
  setDate,
27994
- minDate: activationDate,
28021
+ minDate,
27995
28022
  maxDate
27996
28023
  });
27997
28024
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -28026,7 +28053,7 @@ const DateSelection = () => {
28026
28053
  };
28027
28054
  const CombinedDateSelection = ({ mode }) => {
28028
28055
  if (mode === "month") {
28029
- return /* @__PURE__ */ jsxRuntime.jsx(GlobalDatePicker, {});
28056
+ return /* @__PURE__ */ jsxRuntime.jsx(GlobalMonthPicker, {});
28030
28057
  }
28031
28058
  return /* @__PURE__ */ jsxRuntime.jsx(DateSelection, {});
28032
28059
  };
@@ -28046,7 +28073,7 @@ const BalanceSheetView = ({
28046
28073
  stringOverrides,
28047
28074
  dateSelectionMode = "full"
28048
28075
  }) => {
28049
- const { date: effectiveDate } = useGlobalDate();
28076
+ const { date: effectiveDate } = useGlobalDate({ dateSelectionMode });
28050
28077
  const { data, isLoading } = useBalanceSheet({ effectiveDate });
28051
28078
  const { view, containerRef } = useElementViewSize();
28052
28079
  if (asWidget) {
@@ -28361,7 +28388,7 @@ const StatementOfCashFlowView = ({
28361
28388
  stringOverrides,
28362
28389
  dateSelectionMode = "full"
28363
28390
  }) => {
28364
- const dateRange = useGlobalDateRange({ displayMode: dateSelectionMode });
28391
+ const dateRange = useGlobalDateRange({ dateSelectionMode });
28365
28392
  const { data, isLoading } = useStatementOfCashFlow(dateRange);
28366
28393
  const { view, containerRef } = useElementViewSize();
28367
28394
  return /* @__PURE__ */ jsxRuntime.jsx(TableProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -29027,7 +29054,7 @@ const useChartOfAccounts = ({ withDates = false } = {}) => {
29027
29054
  const { businessId } = useLayerContext();
29028
29055
  const { apiUrl } = useEnvironment();
29029
29056
  const { data: auth } = useAuth();
29030
- const { startDate, endDate } = useGlobalDateRange({ displayMode: "month" });
29057
+ const { startDate, endDate } = useGlobalDateRange({ dateSelectionMode: "month" });
29031
29058
  const [form, setForm] = react.useState();
29032
29059
  const [sendingForm, setSendingForm] = react.useState(false);
29033
29060
  const [apiError, setApiError] = react.useState(void 0);
@@ -37009,56 +37036,38 @@ const AmountCell = ({ invoice }) => {
37009
37036
  }
37010
37037
  }
37011
37038
  };
37012
- const getColumnConfig$1 = (onSelectInvoice) => ({
37013
- [
37014
- "SentAt"
37015
- /* SentAt */
37016
- ]: {
37039
+ const getColumnConfig$1 = (onSelectInvoice) => [
37040
+ {
37017
37041
  id: "SentAt",
37018
37042
  header: "Sent Date",
37019
- cell: (row) => row.sentAt ? formatDate(row.sentAt) : null
37043
+ cell: (row) => row.original.sentAt ? formatDate(row.original.sentAt) : null
37020
37044
  },
37021
- [
37022
- "InvoiceNo"
37023
- /* InvoiceNo */
37024
- ]: {
37045
+ {
37025
37046
  id: "InvoiceNo",
37026
37047
  header: "No.",
37027
- cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(Span, { ellipsis: true, children: row.invoiceNumber }),
37048
+ cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(Span, { ellipsis: true, children: row.original.invoiceNumber }),
37028
37049
  isRowHeader: true
37029
37050
  },
37030
- [
37031
- "Customer"
37032
- /* Customer */
37033
- ]: {
37051
+ {
37034
37052
  id: "Customer",
37035
37053
  header: "Customer",
37036
- cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(Span, { ellipsis: true, children: getCustomerName(row.customer) })
37054
+ cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(Span, { ellipsis: true, children: getCustomerName(row.original.customer) })
37037
37055
  },
37038
- [
37039
- "Total"
37040
- /* Total */
37041
- ]: {
37056
+ {
37042
37057
  id: "Total",
37043
37058
  header: "Amount",
37044
- cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(AmountCell, { invoice: row })
37059
+ cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(AmountCell, { invoice: row.original })
37045
37060
  },
37046
- [
37047
- "Status"
37048
- /* Status */
37049
- ]: {
37061
+ {
37050
37062
  id: "Status",
37051
37063
  header: "Status",
37052
- cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(InvoiceStatusCell, { invoice: row })
37064
+ cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(InvoiceStatusCell, { invoice: row.original })
37053
37065
  },
37054
- [
37055
- "Expand"
37056
- /* Expand */
37057
- ]: {
37066
+ {
37058
37067
  id: "Expand",
37059
- cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(Button, { inset: true, icon: true, onPress: () => onSelectInvoice(row), "aria-label": "View invoice", variant: "ghost", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronRightFill, {}) })
37068
+ cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(Button, { inset: true, icon: true, onPress: () => onSelectInvoice(row.original), "aria-label": "View invoice", variant: "ghost", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronRightFill, {}) })
37060
37069
  }
37061
- });
37070
+ ];
37062
37071
  const UNPAID_STATUSES$1 = [InvoiceStatus.Sent, InvoiceStatus.PartiallyPaid];
37063
37072
  const getStatusFilterParams = (statusFilter) => {
37064
37073
  switch (statusFilter) {
@@ -39768,15 +39777,72 @@ effect.Schema.Union(
39768
39777
  DateQueryParamsSchema,
39769
39778
  DateRangeQueryParamsSchema
39770
39779
  );
39780
+ const unifiedReportColumnFields = {
39781
+ columnKey: effect.pipe(
39782
+ effect.Schema.propertySignature(effect.Schema.String),
39783
+ effect.Schema.fromKey("column_key")
39784
+ ),
39785
+ displayName: effect.pipe(
39786
+ effect.Schema.propertySignature(effect.Schema.String),
39787
+ effect.Schema.fromKey("display_name")
39788
+ )
39789
+ };
39790
+ const UnifiedReportColumnSchema = effect.Schema.Struct(__spreadProps(__spreadValues({}, unifiedReportColumnFields), {
39791
+ columns: effect.Schema.optional(
39792
+ effect.Schema.Array(
39793
+ effect.Schema.suspend(() => UnifiedReportColumnSchema)
39794
+ )
39795
+ )
39796
+ }));
39797
+ const UnifiedCellValueAmountSchema = effect.Schema.Struct({
39798
+ type: effect.Schema.Literal("Amount"),
39799
+ value: effect.Schema.Number
39800
+ });
39801
+ const UnifiedCellValueEmptySchema = effect.Schema.Struct({
39802
+ type: effect.Schema.Literal("Empty")
39803
+ });
39804
+ const UnifiedCellValueUnknownSchema = effect.Schema.Struct({
39805
+ type: effect.Schema.String,
39806
+ value: effect.Schema.optional(effect.Schema.Unknown)
39807
+ });
39808
+ const UnifiedCellValueSchema = effect.Schema.Union(
39809
+ UnifiedCellValueAmountSchema,
39810
+ UnifiedCellValueEmptySchema,
39811
+ UnifiedCellValueUnknownSchema
39812
+ );
39813
+ const isAmountCellValue = (value) => value.type === "Amount";
39814
+ const isEmptyCellValue = (value) => value.type === "Empty";
39815
+ const UnifiedReportCellSchema = effect.Schema.Struct({
39816
+ value: UnifiedCellValueSchema
39817
+ });
39818
+ const unifiedReportRowFields = {
39819
+ rowKey: effect.pipe(
39820
+ effect.Schema.propertySignature(effect.Schema.String),
39821
+ effect.Schema.fromKey("row_key")
39822
+ ),
39823
+ displayName: effect.pipe(
39824
+ effect.Schema.propertySignature(effect.Schema.String),
39825
+ effect.Schema.fromKey("display_name")
39826
+ ),
39827
+ cells: effect.Schema.Record({
39828
+ key: effect.Schema.String,
39829
+ value: effect.Schema.NullishOr(UnifiedReportCellSchema)
39830
+ })
39831
+ };
39832
+ const UnifiedReportRowSchema = effect.Schema.Struct(__spreadProps(__spreadValues({}, unifiedReportRowFields), {
39833
+ rows: effect.Schema.optional(
39834
+ effect.Schema.Array(
39835
+ effect.Schema.suspend(() => UnifiedReportRowSchema)
39836
+ )
39837
+ )
39838
+ }));
39771
39839
  const UnifiedReportSchema = effect.Schema.Struct({
39772
39840
  businessId: effect.pipe(
39773
39841
  effect.Schema.propertySignature(effect.Schema.UUID),
39774
39842
  effect.Schema.fromKey("business_id")
39775
39843
  ),
39776
- lineItems: effect.pipe(
39777
- effect.Schema.propertySignature(effect.Schema.Array(LineItemSchema)),
39778
- effect.Schema.fromKey("line_items")
39779
- )
39844
+ columns: effect.Schema.Array(UnifiedReportColumnSchema),
39845
+ rows: effect.Schema.Array(UnifiedReportRowSchema)
39780
39846
  });
39781
39847
  var UnifiedReportDateVariant = /* @__PURE__ */ ((UnifiedReportDateVariant2) => {
39782
39848
  UnifiedReportDateVariant2["Date"] = "Date";
@@ -39798,10 +39864,10 @@ function useUnifiedReportDateVariant() {
39798
39864
  const report = zustand.useStore(store, (state) => state.report);
39799
39865
  return reportToDateVariantMap[report];
39800
39866
  }
39801
- function useUnifiedReportWithDateParams() {
39867
+ function useUnifiedReportWithDateParams({ dateSelectionMode }) {
39802
39868
  const store = react.useContext(UnifiedReportStoreContext);
39803
- const { date: effectiveDate } = useGlobalDate();
39804
- const { startDate, endDate } = useGlobalDateRange({ displayMode: "full" });
39869
+ const { date: effectiveDate } = useGlobalDate({ dateSelectionMode });
39870
+ const { startDate, endDate } = useGlobalDateRange({ dateSelectionMode });
39805
39871
  const report = zustand.useStore(store, (state) => state.report);
39806
39872
  const dateVariant = reportToDateVariantMap[report];
39807
39873
  switch (dateVariant) {
@@ -39861,33 +39927,13 @@ function ExpandableDataTable({
39861
39927
  ariaLabel,
39862
39928
  slots,
39863
39929
  hideHeader,
39864
- getSubRows: getSubRows2
39930
+ getSubRows: getSubRows2,
39931
+ getRowId
39865
39932
  }) {
39866
- const columnHelper = reactTable.createColumnHelper();
39867
- const columns = Object.values(columnConfig);
39868
39933
  const { expanded, setExpanded } = react.useContext(ExpandableDataTableContext);
39869
- const columnDefs = columns.map((col) => {
39870
- return columnHelper.display({
39871
- id: col.id,
39872
- header: () => col.header,
39873
- cell: ({ row }) => col.cell(row)
39874
- });
39875
- });
39876
- const table2 = reactTable.useReactTable({
39877
- data: data != null ? data : EMPTY_ARRAY,
39878
- columns: columnDefs,
39879
- getSubRows: getSubRows2,
39880
- getCoreRowModel: reactTable.getCoreRowModel(),
39881
- getExpandedRowModel: reactTable.getExpandedRowModel(),
39882
- state: { expanded },
39883
- onExpandedChange: setExpanded,
39884
- autoResetPageIndex: false,
39885
- getRowId: (row) => row.id
39886
- });
39887
- const { rows } = table2.getExpandedRowModel();
39888
39934
  const wrappedColumnConfig = react.useMemo(() => {
39889
- if (!columns.length) return columnConfig;
39890
- const [first, ...rest] = columns;
39935
+ const [first, ...rest] = columnConfig;
39936
+ if (!first || !isLeafColumn(first)) return columnConfig;
39891
39937
  const originalFirstCell = first.cell;
39892
39938
  const firstWithChevron = __spreadProps(__spreadValues({}, first), {
39893
39939
  cell: (row) => {
@@ -39900,26 +39946,37 @@ function ExpandableDataTable({
39900
39946
  ] }) });
39901
39947
  }
39902
39948
  });
39903
- return __spreadValues(__spreadProps(__spreadValues({}, columnConfig), {
39904
- [first.id]: firstWithChevron
39905
- }), rest.reduce((acc, col) => {
39906
- acc[col.id] = col;
39907
- return acc;
39908
- }, {}));
39909
- }, [columns, columnConfig]);
39949
+ return [firstWithChevron, ...rest];
39950
+ }, [columnConfig]);
39951
+ const columnDefs = getColumnDefs(wrappedColumnConfig);
39952
+ const table2 = reactTable.useReactTable({
39953
+ data: data != null ? data : EMPTY_ARRAY,
39954
+ columns: columnDefs,
39955
+ getSubRows: getSubRows2,
39956
+ getCoreRowModel: reactTable.getCoreRowModel(),
39957
+ getExpandedRowModel: reactTable.getExpandedRowModel(),
39958
+ state: { expanded },
39959
+ onExpandedChange: setExpanded,
39960
+ autoResetPageIndex: false,
39961
+ getRowId
39962
+ });
39963
+ const { rows } = table2.getExpandedRowModel();
39910
39964
  const dependencies = react.useMemo(() => [expanded], [expanded]);
39965
+ const headerGroups = table2.getHeaderGroups();
39966
+ const numColumns = table2.getVisibleLeafColumns().length;
39911
39967
  return /* @__PURE__ */ jsxRuntime.jsx(
39912
39968
  DataTable,
39913
39969
  {
39914
39970
  ariaLabel,
39915
- columnConfig: wrappedColumnConfig,
39971
+ numColumns,
39916
39972
  data: rows,
39917
39973
  isLoading,
39918
39974
  isError,
39919
39975
  componentName,
39920
39976
  slots,
39921
39977
  hideHeader,
39922
- dependencies
39978
+ dependencies,
39979
+ headerGroups
39923
39980
  }
39924
39981
  );
39925
39982
  }
@@ -39951,10 +40008,6 @@ const getUnifiedReport = get$1((_md) => {
39951
40008
  const parameters = toDefinedSearchParameters(__spreadValues({}, dateParams));
39952
40009
  return `/v1/businesses/${businessId}/reports/unified/${report}?${parameters}`;
39953
40010
  });
39954
- const addIdToLineItem = (li) => __spreadProps(__spreadValues({}, li), {
39955
- id: li.name,
39956
- lineItems: li.lineItems.map(addIdToLineItem)
39957
- });
39958
40011
  class UnifiedReportSWRResponse {
39959
40012
  constructor(swrResponse) {
39960
40013
  __publicField(this, "swrResponse");
@@ -39989,45 +40042,64 @@ function useUnifiedReport(_od) {
39989
40042
  }), dateParams)),
39990
40043
  ({ accessToken, apiUrl: apiUrl2, businessId: businessId2 }) => getUnifiedReport(apiUrl2, accessToken, {
39991
40044
  params: __spreadValues({ businessId: businessId2, report }, dateParams)
39992
- })().then(
39993
- ({ data }) => effect.Schema.decodeUnknownPromise(UnifiedReportSchema)(data).then((rep) => __spreadProps(__spreadValues({}, rep), {
39994
- lineItems: rep.lineItems.map(addIdToLineItem)
39995
- }))
39996
- )
40045
+ })().then(({ data }) => effect.Schema.decodeUnknownPromise(UnifiedReportSchema)(data))
39997
40046
  );
39998
40047
  return new UnifiedReportSWRResponse(swrResponse);
39999
40048
  }
40000
40049
  const COMPONENT_NAME$2 = "UnifiedReport";
40001
- const COLUMN_CONFIG = {
40002
- [
40003
- "DisplayName"
40004
- /* DisplayName */
40005
- ]: {
40006
- id: "DisplayName",
40007
- header: "Line Item",
40050
+ const makeLeafColumn = (col) => ({
40051
+ id: col.columnKey,
40052
+ header: col.displayName,
40053
+ cell: (row) => {
40054
+ var _a;
40055
+ const cellValue = (_a = row.original.cells[col.columnKey]) == null ? void 0 : _a.value;
40056
+ if (!cellValue || isEmptyCellValue(cellValue)) {
40057
+ return null;
40058
+ }
40059
+ if (isAmountCellValue(cellValue)) {
40060
+ return /* @__PURE__ */ jsxRuntime.jsx(MoneySpan, { ellipsis: true, amount: cellValue.value });
40061
+ }
40062
+ if (isEmptyCellValue(cellValue)) {
40063
+ return null;
40064
+ }
40065
+ return /* @__PURE__ */ jsxRuntime.jsx(Span, { ellipsis: true, children: String(cellValue.value) });
40066
+ }
40067
+ });
40068
+ const makeGroupColumn = (col) => ({
40069
+ id: col.columnKey,
40070
+ header: col.displayName,
40071
+ columns: buildNestedColumnConfig(col.columns)
40072
+ });
40073
+ const isGroupColumn = (col) => col.columns !== void 0 && col.columns.length > 0;
40074
+ const buildNestedColumnConfig = (columns) => {
40075
+ return columns.map((col) => {
40076
+ if (isGroupColumn(col)) {
40077
+ return makeGroupColumn(col);
40078
+ }
40079
+ return makeLeafColumn(col);
40080
+ });
40081
+ };
40082
+ const buildColumnConfig = (columns) => {
40083
+ const displayNameColumn = {
40084
+ id: "displayName",
40085
+ header: "",
40008
40086
  cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(Span, { weight: row.depth === 0 ? "bold" : "normal", ellipsis: true, children: row.original.displayName }),
40009
40087
  isRowHeader: true
40010
- },
40011
- [
40012
- "Value"
40013
- /* Value */
40014
- ]: {
40015
- id: "Value",
40016
- header: "Amount",
40017
- cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(MoneySpan, { amount: row.original.value })
40018
- }
40088
+ };
40089
+ return [displayNameColumn, ...buildNestedColumnConfig(columns)];
40019
40090
  };
40020
- const getSubRows = (lineItem) => asMutable(lineItem.lineItems);
40021
- const UnifiedReportTable = () => {
40022
- const _a = useUnifiedReportWithDateParams(), { report } = _a, dateParams = __objRest(_a, ["report"]);
40091
+ const getSubRows = (row) => row.rows ? asMutable(row.rows) : void 0;
40092
+ const UnifiedReportTable = ({ dateSelectionMode }) => {
40093
+ const _a = useUnifiedReportWithDateParams({ dateSelectionMode }), { report } = _a, dateParams = __objRest(_a, ["report"]);
40023
40094
  const { data, isLoading, isError, refetch } = useUnifiedReport(__spreadValues({ report }, dateParams));
40024
40095
  const { setExpanded } = react.useContext(ExpandableDataTableContext);
40025
- const mutableLineItems = data ? asMutable(data == null ? void 0 : data.lineItems) : void 0;
40096
+ const mutableRows = (data == null ? void 0 : data.rows) ? asMutable(data.rows) : void 0;
40097
+ const columnConfig = react.useMemo(() => data ? buildColumnConfig(data.columns) : [], [data]);
40026
40098
  react.useEffect(() => {
40027
- if (mutableLineItems !== void 0) {
40028
- setExpanded(Object.fromEntries(mutableLineItems.map((d) => [d.id, true])));
40099
+ if (mutableRows !== void 0) {
40100
+ setExpanded(Object.fromEntries(mutableRows.map((d) => [d.rowKey, true])));
40029
40101
  }
40030
- }, [mutableLineItems, setExpanded]);
40102
+ }, [mutableRows, setExpanded]);
40031
40103
  const UnifiedReportEmptyState = react.useCallback(() => {
40032
40104
  return /* @__PURE__ */ jsxRuntime.jsx(
40033
40105
  DataState,
@@ -40055,17 +40127,17 @@ const UnifiedReportTable = () => {
40055
40127
  ExpandableDataTable,
40056
40128
  {
40057
40129
  ariaLabel: "Report",
40058
- data: mutableLineItems,
40130
+ data: mutableRows,
40059
40131
  isLoading: data === void 0 || isLoading,
40060
40132
  isError,
40061
- columnConfig: COLUMN_CONFIG,
40133
+ columnConfig,
40062
40134
  componentName: COMPONENT_NAME$2,
40063
40135
  slots: {
40064
40136
  ErrorState: UnifiedReportErrorState,
40065
40137
  EmptyState: UnifiedReportEmptyState
40066
40138
  },
40067
40139
  getSubRows,
40068
- hideHeader: true
40140
+ getRowId: (row) => row.rowKey
40069
40141
  }
40070
40142
  );
40071
40143
  };
@@ -40144,10 +40216,10 @@ function downloadReport(apiUrl, accessToken, businessId, unifiedReportParams) {
40144
40216
  });
40145
40217
  }
40146
40218
  }
40147
- function useUnifiedReportDownload({ onSuccess } = {}) {
40219
+ function useUnifiedReportDownload({ dateSelectionMode, onSuccess }) {
40148
40220
  const { data: auth } = useAuth();
40149
40221
  const { businessId } = useLayerContext();
40150
- const reportWithDateParams = useUnifiedReportWithDateParams();
40222
+ const reportWithDateParams = useUnifiedReportWithDateParams({ dateSelectionMode });
40151
40223
  const rawMutationResponse = useSWRMutation(
40152
40224
  () => buildKey$a(__spreadProps(__spreadValues({}, auth), {
40153
40225
  businessId,
@@ -40164,9 +40236,10 @@ function useUnifiedReportDownload({ onSuccess } = {}) {
40164
40236
  );
40165
40237
  return new DownloadUnifiedReportSWRResponse(rawMutationResponse);
40166
40238
  }
40167
- function UnifiedReportDownloadButton() {
40239
+ function UnifiedReportDownloadButton({ dateSelectionMode }) {
40168
40240
  const { invisibleDownloadRef, triggerInvisibleDownload } = useInvisibleDownload();
40169
40241
  const { trigger, isMutating, isError } = useUnifiedReportDownload({
40242
+ dateSelectionMode,
40170
40243
  onSuccess: ({ presignedUrl }) => triggerInvisibleDownload({ url: presignedUrl })
40171
40244
  });
40172
40245
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -40188,7 +40261,7 @@ function UnifiedReportDownloadButton() {
40188
40261
  /* @__PURE__ */ jsxRuntime.jsx(InvisibleDownload, { ref: invisibleDownloadRef })
40189
40262
  ] });
40190
40263
  }
40191
- const UnifiedReportTableHeader = () => {
40264
+ const UnifiedReportTableHeader = ({ dateSelectionMode }) => {
40192
40265
  const dateVariant = useUnifiedReportDateVariant();
40193
40266
  const { expanded, setExpanded } = react.useContext(ExpandableDataTableContext);
40194
40267
  const shouldCollapse = expanded === true;
@@ -40200,17 +40273,17 @@ const UnifiedReportTableHeader = () => {
40200
40273
  }
40201
40274
  }, [setExpanded, shouldCollapse]);
40202
40275
  return /* @__PURE__ */ jsxRuntime.jsxs(HStack, { fluid: true, justify: "space-between", align: "center", className: "Layer__UnifiedReport__Header", children: [
40203
- /* @__PURE__ */ jsxRuntime.jsx(HStack, { pi: "md", children: dateVariant === UnifiedReportDateVariant.DateRange ? /* @__PURE__ */ jsxRuntime.jsx(DateRangeSelection, {}) : /* @__PURE__ */ jsxRuntime.jsx(DateSelection, {}) }),
40276
+ /* @__PURE__ */ jsxRuntime.jsx(HStack, { pi: "md", children: dateVariant === UnifiedReportDateVariant.DateRange ? /* @__PURE__ */ jsxRuntime.jsx(CombinedDateRangeSelection, { mode: dateSelectionMode }) : /* @__PURE__ */ jsxRuntime.jsx(CombinedDateSelection, { mode: dateSelectionMode }) }),
40204
40277
  /* @__PURE__ */ jsxRuntime.jsxs(HStack, { pi: "md", className: "Layer__UnifiedReport__Header__SecondaryActions", children: [
40205
40278
  /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "outlined", onClick: onClickExpandOrCollapse, children: shouldCollapse ? "Collapse All" : "Expand All" }),
40206
- /* @__PURE__ */ jsxRuntime.jsx(UnifiedReportDownloadButton, {})
40279
+ /* @__PURE__ */ jsxRuntime.jsx(UnifiedReportDownloadButton, { dateSelectionMode })
40207
40280
  ] })
40208
40281
  ] });
40209
40282
  };
40210
- const UnifiedReport = () => {
40283
+ const UnifiedReport = ({ dateSelectionMode }) => {
40211
40284
  return /* @__PURE__ */ jsxRuntime.jsx(Container, { name: "UnifiedReport", children: /* @__PURE__ */ jsxRuntime.jsx(UnifiedReportStoreProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(ExpandableDataTableProvider, { children: [
40212
- /* @__PURE__ */ jsxRuntime.jsx(UnifiedReportTableHeader, {}),
40213
- /* @__PURE__ */ jsxRuntime.jsx(UnifiedReportTable, {})
40285
+ /* @__PURE__ */ jsxRuntime.jsx(UnifiedReportTableHeader, { dateSelectionMode }),
40286
+ /* @__PURE__ */ jsxRuntime.jsx(UnifiedReportTable, { dateSelectionMode })
40214
40287
  ] }) }) });
40215
40288
  };
40216
40289
  const AccountingOverview = ({
@@ -43953,80 +44026,59 @@ const TripsTableHeaderMenu = () => {
43953
44026
  );
43954
44027
  };
43955
44028
  const COMPONENT_NAME = "TripsTable";
43956
- const getColumnConfig = ({ onSelectTrip, onDeleteTrip }) => ({
43957
- [
43958
- "TripDate"
43959
- /* TripDate */
43960
- ]: {
44029
+ const getColumnConfig = ({ onSelectTrip, onDeleteTrip }) => [
44030
+ {
43961
44031
  id: "TripDate",
43962
44032
  header: "Date",
43963
- cell: (row) => formatCalendarDate(row.tripDate)
44033
+ cell: (row) => formatCalendarDate(row.original.tripDate)
43964
44034
  },
43965
- [
43966
- "Vehicle"
43967
- /* Vehicle */
43968
- ]: {
44035
+ {
43969
44036
  id: "Vehicle",
43970
44037
  header: "Vehicle",
43971
- cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(Span, { ellipsis: true, withTooltip: true, children: getVehicleDisplayName(row.vehicle) }),
44038
+ cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(Span, { ellipsis: true, withTooltip: true, children: getVehicleDisplayName(row.original.vehicle) }),
43972
44039
  isRowHeader: true
43973
44040
  },
43974
- [
43975
- "Distance"
43976
- /* Distance */
43977
- ]: {
44041
+ {
43978
44042
  id: "Distance",
43979
44043
  header: "Distance",
43980
- cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(Span, { align: "right", children: formatDistance(row.distance) })
44044
+ cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(Span, { align: "right", children: formatDistance(row.original.distance) })
43981
44045
  },
43982
- [
43983
- "Purpose"
43984
- /* Purpose */
43985
- ]: {
44046
+ {
43986
44047
  id: "Purpose",
43987
44048
  header: "Purpose",
43988
- cell: (row) => getPurposeLabel(row.purpose)
44049
+ cell: (row) => getPurposeLabel(row.original.purpose)
43989
44050
  },
43990
- [
43991
- "Address"
43992
- /* Address */
43993
- ]: {
44051
+ {
43994
44052
  id: "Address",
43995
44053
  header: "Address",
43996
44054
  cell: (row) => {
43997
44055
  return /* @__PURE__ */ jsxRuntime.jsxs(VStack, { gap: "3xs", overflow: "auto", children: [
43998
- row.startAddress && /* @__PURE__ */ jsxRuntime.jsxs(Span, { ellipsis: true, size: "sm", withTooltip: true, children: [
44056
+ row.original.startAddress && /* @__PURE__ */ jsxRuntime.jsxs(Span, { ellipsis: true, size: "sm", withTooltip: true, children: [
43999
44057
  /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "Start:" }),
44000
44058
  " ",
44001
- row.startAddress
44059
+ row.original.startAddress
44002
44060
  ] }),
44003
- row.endAddress && /* @__PURE__ */ jsxRuntime.jsxs(Span, { ellipsis: true, size: "sm", withTooltip: true, children: [
44061
+ row.original.endAddress && /* @__PURE__ */ jsxRuntime.jsxs(Span, { ellipsis: true, size: "sm", withTooltip: true, children: [
44004
44062
  /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "End:" }),
44005
44063
  " ",
44006
- row.endAddress
44064
+ row.original.endAddress
44007
44065
  ] })
44008
44066
  ] });
44009
44067
  }
44010
44068
  },
44011
- [
44012
- "Description"
44013
- /* Description */
44014
- ]: {
44069
+ {
44015
44070
  id: "Description",
44016
44071
  header: "Description",
44017
- cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(Span, { ellipsis: true, withTooltip: true, children: row.description })
44072
+ cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(Span, { ellipsis: true, withTooltip: true, children: row.original.description })
44018
44073
  },
44019
- [
44020
- "Actions"
44021
- /* Actions */
44022
- ]: {
44074
+ {
44023
44075
  id: "Actions",
44024
44076
  cell: (row) => /* @__PURE__ */ jsxRuntime.jsxs(HStack, { gap: "3xs", children: [
44025
- /* @__PURE__ */ jsxRuntime.jsx(Button, { inset: true, icon: true, onPress: () => onSelectTrip(row), "aria-label": "View trip", variant: "ghost", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Edit, { size: 20 }) }),
44026
- /* @__PURE__ */ jsxRuntime.jsx(Button, { inset: true, icon: true, onPress: () => onDeleteTrip(row), "aria-label": "Delete trip", variant: "ghost", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { size: 20 }) })
44077
+ /* @__PURE__ */ jsxRuntime.jsx(Button, { inset: true, icon: true, onPress: () => onSelectTrip(row.original), "aria-label": "View trip", variant: "ghost", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Edit, { size: 20 }) }),
44078
+ /* @__PURE__ */ jsxRuntime.jsx(Button, { inset: true, icon: true, onPress: () => onDeleteTrip(row.original), "aria-label": "Delete trip", variant: "ghost", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { size: 20 }) })
44027
44079
  ] })
44028
44080
  }
44029
- });
44081
+ ];
44030
44082
  const TripsTable = () => {
44031
44083
  var _a;
44032
44084
  const [isTripDrawerOpen, setIsTripDrawerOpen] = react.useState(false);
@@ -45509,7 +45561,7 @@ const BusinessProvider = ({
45509
45561
  hasBeenTouched,
45510
45562
  resetCaches
45511
45563
  } = useDataSync();
45512
- const globalDateRange = useGlobalDateRange({ displayMode: "full" });
45564
+ const globalDateRange = useGlobalDateRange({ dateSelectionMode: "full" });
45513
45565
  const { setDateRange } = useGlobalDateRangeActions();
45514
45566
  const dateRange = react.useMemo(() => ({
45515
45567
  range: globalDateRange,