@mx-cartographer/experiences 7.2.15-alpha.sms3 → 7.2.15-alpha.sms5

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.
@@ -4,31 +4,31 @@ import U from "@mui/material/FormControlLabel";
4
4
  import K from "@mui/material/Radio";
5
5
  import V from "@mui/material/styles/useTheme";
6
6
  import v from "@mui/material/Tooltip";
7
- import { makeAutoObservable as y, autorun as B, runInAction as d } from "mobx";
7
+ import { makeAutoObservable as y, runInAction as d } from "mobx";
8
8
  import { endOfToday as D } from "date-fns/endOfToday";
9
- import { formatISO as Y } from "date-fns/formatISO";
9
+ import { formatISO as B } from "date-fns/formatISO";
10
10
  import { fromUnixTime as h } from "date-fns/fromUnixTime";
11
11
  import { getUnixTime as u } from "date-fns/getUnixTime";
12
- import { isBefore as F } from "date-fns/isBefore";
12
+ import { isBefore as Y } from "date-fns/isBefore";
13
13
  import { startOfMonth as R } from "date-fns/startOfMonth";
14
14
  import { startOfToday as b } from "date-fns/startOfToday";
15
- import { subDays as W } from "date-fns/subDays";
15
+ import { subDays as F } from "date-fns/subDays";
16
16
  import { O as n, a as G, T as w } from "./User-BQUxBeZV.mjs";
17
17
  import { T as p } from "./TransactionApi-B3Tksf7L.mjs";
18
- import { b as z } from "./Category-CevNQ03n.mjs";
19
- import { f as k } from "./exportTransactionsToCSV-7bVS7KXf.mjs";
20
- import { format as $ } from "date-fns/format";
21
- import { f as g, D as O, O as X } from "./Dialog-CWW597AF.mjs";
22
- import { endOfMonth as j } from "date-fns/endOfMonth";
18
+ import { b as W } from "./Category-CevNQ03n.mjs";
19
+ import { f as z } from "./exportTransactionsToCSV-7bVS7KXf.mjs";
20
+ import { format as k } from "date-fns/format";
21
+ import { f as g, D as O, O as $ } from "./Dialog-CWW597AF.mjs";
22
+ import { endOfMonth as X } from "date-fns/endOfMonth";
23
23
  import { B as f } from "./BeatApi-DhJpgCLz.mjs";
24
- const Z = ({
24
+ const j = ({
25
25
  checked: l = !1,
26
26
  label: t,
27
27
  sx: a = {},
28
28
  tooltip: e = "",
29
29
  value: c
30
30
  }) => {
31
- const _ = V(), i = _.palette.mode === "light" ? _.palette.grey[400] : _.palette.grey[700], A = l ? _.palette.action.active : i;
31
+ const _ = V(), s = _.palette.mode === "light" ? _.palette.grey[400] : _.palette.grey[700], A = l ? _.palette.action.active : s;
32
32
  return /* @__PURE__ */ C(
33
33
  P,
34
34
  {
@@ -59,7 +59,7 @@ const Z = ({
59
59
  ) })
60
60
  }
61
61
  );
62
- }, mt = Z, x = {
62
+ }, ft = j, x = {
63
63
  ASC: "ASC",
64
64
  DESC: "DESC",
65
65
  DIRECTION: {
@@ -322,16 +322,16 @@ const Z = ({
322
322
  category: o.TRANSACTIONS_WIDGET,
323
323
  label: r.DELETE_TRANSACTION
324
324
  }
325
- }, q = async (l, t) => !t || !m[l] ? null : t.sendAnalyticEvent(m[l]), L = {
325
+ }, Z = async (l, t) => !t || !m[l] ? null : t.sendAnalyticEvent(m[l]), L = {
326
326
  FLAG: "flag",
327
327
  DATE: "date",
328
328
  PAYEE: "payee",
329
329
  CATEGORY: "category",
330
330
  ACCOUNT: "account",
331
331
  AMOUNT: "amount"
332
- }, J = (l, t, a, e = []) => {
333
- const c = t.reduce((A, s) => ({ ...A, [s.guid]: s }), {}), _ = a.reduce((A, s) => ({ ...A, [s.guid]: s }), {}), i = e.reduce((A, s) => {
334
- const { transaction_guid: N, tag_guid: I } = s;
332
+ }, q = (l, t, a, e = []) => {
333
+ const c = t.reduce((A, i) => ({ ...A, [i.guid]: i }), {}), _ = a.reduce((A, i) => ({ ...A, [i.guid]: i }), {}), s = e.reduce((A, i) => {
334
+ const { transaction_guid: N, tag_guid: I } = i;
335
335
  if (!A[N])
336
336
  return {
337
337
  ...A,
@@ -344,52 +344,52 @@ const Z = ({
344
344
  };
345
345
  }, {});
346
346
  return l.map((A) => {
347
- const s = c[A.account_guid], N = A.category_guid ? _[A.category_guid] : null, I = i[A.guid] ?? [];
347
+ const i = c[A.account_guid], N = A.category_guid ? _[A.category_guid] : null, I = s[A.guid] ?? [];
348
348
  return {
349
349
  ...A,
350
- account: s?.user_name || "Unknown",
351
- accountIsClosed: s?.is_closed,
352
- accountIsHidden: s?.is_hidden,
350
+ account: i?.user_name || "Unknown",
351
+ accountIsClosed: i?.is_closed,
352
+ accountIsHidden: i?.is_hidden,
353
353
  category: N?.name || "Uncategorized",
354
- isIncome: A.top_level_category_guid === z.INCOME,
354
+ isIncome: A.top_level_category_guid === W.INCOME,
355
355
  isPending: A.feed_status === G.PENDING,
356
- number: s?.account_number || "",
356
+ number: i?.account_number || "",
357
357
  payee: A.description,
358
358
  tags: I
359
359
  };
360
360
  });
361
- }, Q = "uncategorized", tt = (l, t, a, e, c, _) => {
362
- const i = at(l, c, _), A = et(i, a, e);
363
- return t.forEach((s) => {
364
- const N = A.findIndex((E) => E.guid === s), I = _.filter((E) => E.parent_guid === s);
361
+ }, J = "uncategorized", Q = (l, t, a, e, c, _) => {
362
+ const s = tt(l, c, _), A = at(s, a, e);
363
+ return t.forEach((i) => {
364
+ const N = A.findIndex((E) => E.guid === i), I = _.filter((E) => E.parent_guid === i);
365
365
  A.splice(N + 1, 0, ...I);
366
366
  }), A;
367
- }, at = (l, t, a) => {
367
+ }, tt = (l, t, a) => {
368
368
  const {
369
369
  accounts: e = [],
370
370
  dateRange: c = { start: R(b()), end: D() },
371
371
  custom: _ = () => !0,
372
- searchTerm: i = "",
372
+ searchTerm: s = "",
373
373
  showSplits: A = !1
374
374
  } = l;
375
- return a.filter((s) => A ? !s.has_been_split : !s.parent_guid).filter((s) => !!e.find((N) => N === s.account_guid)).filter((s) => s.date >= u(c.start) && s.date <= u(c.end)).filter(_).filter((s) => {
376
- if (i === Q && s.has_been_split)
375
+ return a.filter((i) => A ? !i.has_been_split : !i.parent_guid).filter((i) => !!e.find((N) => N === i.account_guid)).filter((i) => i.date >= u(c.start) && i.date <= u(c.end)).filter(_).filter((i) => {
376
+ if (s === J && i.has_been_split)
377
377
  return !1;
378
- if (/^spl/i.test(i) && (s.has_been_split || s.parent_guid))
378
+ if (/^spl/i.test(s) && (i.has_been_split || i.parent_guid))
379
379
  return !0;
380
- const I = s.tags.some(
381
- (M) => S(i, t.find((H) => H.guid === M)?.name)
382
- ), E = h(s.date);
383
- return S(i, s.payee) || S(i, s.feed_description) || S(i, s.category) || S(i, g(E, O.MONTH)) || S(i, g(E, O.DAY)) || S(i, g(E, O.FULL_MONTH_DAY)) || S(i, g(E, O.MONTH_DAY_YEAR)) || S(i, $(E, X)) || S(i, s.account) || S(i, `${s.amount}`) || S(i, s.memo) || I;
380
+ const I = i.tags.some(
381
+ (M) => S(s, t.find((H) => H.guid === M)?.name)
382
+ ), E = h(i.date);
383
+ return S(s, i.payee) || S(s, i.feed_description) || S(s, i.category) || S(s, g(E, O.MONTH)) || S(s, g(E, O.DAY)) || S(s, g(E, O.FULL_MONTH_DAY)) || S(s, g(E, O.MONTH_DAY_YEAR)) || S(s, k(E, $)) || S(s, i.account) || S(s, `${i.amount}`) || S(s, i.memo) || I;
384
384
  });
385
- }, et = (l, t, a) => [...l].sort((e, c) => {
386
- const _ = t, i = (e[_] || "") > (c[_] || "");
387
- let A = i ? -1 : 1, s = i ? 1 : -1;
388
- return (t === L.DATE || t === L.AMOUNT) && (A = i ? 1 : -1, s = i ? -1 : 1), a === x.ASC ? A : s;
385
+ }, at = (l, t, a) => [...l].sort((e, c) => {
386
+ const _ = t, s = (e[_] || "") > (c[_] || "");
387
+ let A = s ? -1 : 1, i = s ? 1 : -1;
388
+ return (t === L.DATE || t === L.AMOUNT) && (A = s ? 1 : -1, i = s ? -1 : 1), a === x.ASC ? A : i;
389
389
  }), S = (l, t) => {
390
390
  const a = l.toLowerCase().split(" "), e = t?.toString().toLowerCase() ?? "";
391
391
  return a.every((c) => e.indexOf(c) > -1);
392
- }, it = {
392
+ }, et = {
393
393
  account_guid: "",
394
394
  amount: 0,
395
395
  currency_code: "",
@@ -420,7 +420,7 @@ const Z = ({
420
420
  };
421
421
  class st {
422
422
  beginDate = R(/* @__PURE__ */ new Date());
423
- endDate = j(/* @__PURE__ */ new Date());
423
+ endDate = X(/* @__PURE__ */ new Date());
424
424
  expandedSplits = [];
425
425
  isInitialized = !1;
426
426
  height = 550;
@@ -428,7 +428,7 @@ class st {
428
428
  shouldDisableDrawerScroll = !1;
429
429
  searchValue = "";
430
430
  selectedAccountGuids = [];
431
- manualTransaction = it;
431
+ manualTransaction = et;
432
432
  isAmountValid = !1;
433
433
  showInsights = !1;
434
434
  constructor() {
@@ -459,13 +459,13 @@ class st {
459
459
  this.manualTransaction = t;
460
460
  };
461
461
  }
462
- class yt {
462
+ class mt {
463
463
  globalStore;
464
464
  uiStore;
465
465
  api = new p("/", "");
466
466
  beatApi = new f("/", "");
467
467
  associatedBeats = [];
468
- cachedStartDate = W(b(), 90);
468
+ cachedStartDate = F(b(), 90);
469
469
  filter = {};
470
470
  isLoading = !0;
471
471
  rawTransactions = [];
@@ -474,13 +474,14 @@ class yt {
474
474
  taggings = [];
475
475
  tags = [];
476
476
  transactionRules = [];
477
- onAnalyticEvent = q;
477
+ listeners = [];
478
+ onAnalyticEvent = Z;
478
479
  constructor(t) {
479
480
  this.globalStore = t, this.uiStore = new st(), this.api = new p(
480
481
  t.endpoint,
481
482
  t.sessionToken,
482
483
  t.onError
483
- ), this.beatApi = new f(t.endpoint, t.sessionToken, t.onError), y(this), B(() => this.transactions);
484
+ ), this.beatApi = new f(t.endpoint, t.sessionToken, t.onError), y(this);
484
485
  }
485
486
  loadTransactionData = async ({
486
487
  associatedBeats: t,
@@ -498,8 +499,12 @@ class yt {
498
499
  this.uiStore.setIsInitialized(!0);
499
500
  });
500
501
  };
502
+ subscribe = (t) => (this.listeners = [...this.listeners, t], () => {
503
+ this.listeners = this.listeners.filter((a) => a !== t);
504
+ });
505
+ getSnapshot = () => this;
501
506
  get sortedTransactions() {
502
- return tt(
507
+ return Q(
503
508
  this.filter,
504
509
  this.uiStore.expandedSplits,
505
510
  this.sortColumn,
@@ -509,7 +514,7 @@ class yt {
509
514
  );
510
515
  }
511
516
  get sortedTransactionsWithSplits() {
512
- return k(this.sortedTransactions, this.transactions);
517
+ return z(this.sortedTransactions, this.transactions);
513
518
  }
514
519
  get transactions() {
515
520
  return this.augmentTransactions(this.rawTransactions);
@@ -545,7 +550,7 @@ class yt {
545
550
  this.globalStore.accountStore.updateAccountBalance(a.account_guid, e);
546
551
  }
547
552
  };
548
- augmentTransactions = (t) => J(
553
+ augmentTransactions = (t) => q(
549
554
  t,
550
555
  this.globalStore.accountStore.visibleAccounts,
551
556
  this.globalStore.categoryStore.categories,
@@ -553,7 +558,7 @@ class yt {
553
558
  );
554
559
  getTransactionData = () => ({});
555
560
  loadAssociatedBeats = async (t, a) => {
556
- const e = t ? Y(t, { representation: "date" }) : void 0, c = a ?? await this.beatApi.getBeatsWithAssociatedTransaction(e);
561
+ const e = t ? B(t, { representation: "date" }) : void 0, c = a ?? await this.beatApi.getBeatsWithAssociatedTransaction(e);
557
562
  d(() => this.associatedBeats = c);
558
563
  };
559
564
  loadTags = async () => {
@@ -607,7 +612,7 @@ class yt {
607
612
  }
608
613
  };
609
614
  setFilter = (t) => {
610
- this.filter = t, t.dateRange && F(t.dateRange.start, this.cachedStartDate) && this.loadTransactions(t.dateRange.start, D()).then(() => {
615
+ this.filter = t, t.dateRange && Y(t.dateRange.start, this.cachedStartDate) && this.loadTransactions(t.dateRange.start, D()).then(() => {
611
616
  t.dateRange && (this.cachedStartDate = t.dateRange.start);
612
617
  });
613
618
  };
@@ -617,11 +622,11 @@ class yt {
617
622
  };
618
623
  splitTransaction = async (t, a) => {
619
624
  const e = await this.api.updateTransaction(t), c = [];
620
- for (let i = 0; i < a.length; i++) {
621
- const A = await this.api.addTransaction(a[i]);
625
+ for (let s = 0; s < a.length; s++) {
626
+ const A = await this.api.addTransaction(a[s]);
622
627
  c.push(A);
623
628
  }
624
- const _ = this.transactions.findIndex((i) => i.guid === t.guid);
629
+ const _ = this.transactions.findIndex((s) => s.guid === t.guid);
625
630
  _ >= 0 && d(
626
631
  () => this.rawTransactions = [
627
632
  ...this.transactions.slice(0, _),
@@ -632,14 +637,14 @@ class yt {
632
637
  );
633
638
  };
634
639
  unSplitTransaction = async (t) => {
635
- const a = this.transactions.filter((i) => i.parent_guid === t);
640
+ const a = this.transactions.filter((s) => s.parent_guid === t);
636
641
  await this.api.removeTransactionSplit(t);
637
642
  const e = [...this.transactions];
638
- a.forEach((i) => {
639
- const A = e.findIndex((s) => s.guid === i.guid);
643
+ a.forEach((s) => {
644
+ const A = e.findIndex((i) => i.guid === s.guid);
640
645
  A >= 0 && e.splice(A, 1);
641
646
  });
642
- const c = e.findIndex((i) => i.guid === t), _ = e[c];
647
+ const c = e.findIndex((s) => s.guid === t), _ = e[c];
643
648
  _.has_been_split = !1, c >= 0 && d(
644
649
  () => this.rawTransactions = [
645
650
  ...e.slice(0, c),
@@ -649,11 +654,11 @@ class yt {
649
654
  );
650
655
  };
651
656
  updateTaggings = async (t, a) => {
652
- const e = this.taggings.filter((i) => i.transaction_guid === a), c = new Set(e.map((i) => i.tag_guid)), _ = new Set(t);
653
- for (const i of t)
654
- c.has(i) || await this.addTagging(i, a);
655
- for (const i of e)
656
- _.has(i.tag_guid) || await this.removeTagging(i.guid);
657
+ const e = this.taggings.filter((s) => s.transaction_guid === a), c = new Set(e.map((s) => s.tag_guid)), _ = new Set(t);
658
+ for (const s of t)
659
+ c.has(s) || await this.addTagging(s, a);
660
+ for (const s of e)
661
+ _.has(s.tag_guid) || await this.removeTagging(s.guid);
657
662
  await this.loadTaggings();
658
663
  };
659
664
  updateTag = async (t) => {
@@ -671,7 +676,7 @@ class yt {
671
676
  };
672
677
  }
673
678
  export {
674
- it as D,
675
- mt as S,
676
- yt as T
679
+ et as D,
680
+ ft as S,
681
+ mt as T
677
682
  };
@@ -18,8 +18,8 @@ import { C as Ys } from "../CurrencyInput-DUsQbkXb.mjs";
18
18
  import { L as zs } from "../Loader-DUaFpDGv.mjs";
19
19
  import { R as js } from "../ResponsiveButton-DZFp78fJ.mjs";
20
20
  import { S as Vs } from "../SearchBox-B2_zLv8-.mjs";
21
- import { T as at } from "../TransactionStore-Dx8hFybD.mjs";
22
- import { S as Js } from "../TransactionStore-Dx8hFybD.mjs";
21
+ import { T as at } from "../TransactionStore-DPdMpf5m.mjs";
22
+ import { S as Js } from "../TransactionStore-DPdMpf5m.mjs";
23
23
  import { T as er } from "../TabContentContainer-j01JYR_7.mjs";
24
24
  import { I as rr } from "../IconBacking-B9oC6uL2.mjs";
25
25
  import { D as ar, F as nr, a as ir, c as cr, R as dr, S as lr } from "../RecurringTransactions-ej39mgA6.mjs";
@@ -1198,6 +1198,7 @@ class Je {
1198
1198
  userStore;
1199
1199
  // UI Stores
1200
1200
  globalUiStore;
1201
+ // listeners = [] as any
1201
1202
  constructor(t = K, e = "/", r) {
1202
1203
  this.appConfig = t, this.endpoint = e, this.sessionToken = t.options.session_token ?? "", this.onError = r, this.accountStore = new ft(this), this.appDataStore = new ie(this), this.analyticsStore = new ee(this), this.beatStore = new St(this), this.budgetsStore = new se(this), this.cashflowStore = new nt(this), this.categoryStore = new et(this), this.connectStore = new ce(this), this.copyStore = new te(this), this.debtsStore = new xt(this), this.finstrongStore = new Ct(this), this.goalStore = new it(this), this.helpStore = new ae(this), this.holdingStore = new ne(this), this.merchantStore = new Tt(this), this.netWorthStore = new Bt(this), this.notificationStore = new st(this), this.recurringTransactionsStore = new mt(this), this.settingsStore = new It(this), this.transactionStore = new at(this), this.trendsStore = new ct(this), this.userStore = new le(this), this.globalUiStore = new de(this), f(this);
1203
1204
  }
@@ -1229,6 +1230,15 @@ class Je {
1229
1230
  })
1230
1231
  ]), this.globalUiStore.setInitialized(!0);
1231
1232
  };
1233
+ // subscribe = (listener: any) => {
1234
+ // this.listeners = [...this.listeners, listener]
1235
+ // return () => {
1236
+ // this.listeners = this.listeners.filter((l: any) => l !== listener)
1237
+ // }
1238
+ // }
1239
+ // getSnapshot = () => {
1240
+ // return this
1241
+ // }
1232
1242
  }
1233
1243
  export {
1234
1244
  vs as ANALYTICS_EVENTS,
@@ -3,8 +3,8 @@ import { u as P, C as Pe, D as $e, M as Ve, c as We, T as Ge, a as Ue } from "..
3
3
  import { B as xa, d as wa, b as Ia } from "../TransactionDetails-BqCr2FTh.mjs";
4
4
  import { T as M } from "../User-BQUxBeZV.mjs";
5
5
  import { O as Da } from "../User-BQUxBeZV.mjs";
6
- import { S as ae, D as Fe } from "../TransactionStore-Dx8hFybD.mjs";
7
- import { T as Ea } from "../TransactionStore-Dx8hFybD.mjs";
6
+ import { S as ae, D as Fe } from "../TransactionStore-DPdMpf5m.mjs";
7
+ import { T as Ea } from "../TransactionStore-DPdMpf5m.mjs";
8
8
  import { e as ze } from "../exportTransactionsToCSV-7bVS7KXf.mjs";
9
9
  import { E as Ma } from "../ExportCsvAction-sX8Rg4Ov.mjs";
10
10
  import { jsxs as _, jsx as e } from "react/jsx-runtime";
@@ -26,6 +26,7 @@ export declare class TransactionStore {
26
26
  taggings: Tagging[];
27
27
  tags: Tag[];
28
28
  transactionRules: TransactionRule[];
29
+ listeners: any;
29
30
  onAnalyticEvent: (event: string, session: import('../analytics').AnalyticSession | null) => Promise<any>;
30
31
  constructor(globalStore: GlobalStore);
31
32
  loadTransactionData: ({ associatedBeats, transactionRules, transactions, }?: {
@@ -35,6 +36,8 @@ export declare class TransactionStore {
35
36
  transactionRules?: TransactionRule[];
36
37
  transactions?: Transaction[];
37
38
  }) => Promise<void>;
39
+ subscribe: (listener: any) => () => void;
40
+ getSnapshot: () => this;
38
41
  get sortedTransactions(): Transaction[];
39
42
  get sortedTransactionsWithSplits(): Transaction[];
40
43
  get transactions(): Transaction[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mx-cartographer/experiences",
3
- "version": "7.2.15-alpha.sms3",
3
+ "version": "7.2.15-alpha.sms5",
4
4
  "description": "Library containing experience widgets",
5
5
  "author": "MX",
6
6
  "license": "MIT",