@mx-cartographer/experiences 9.4.20 → 9.4.21

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.
@@ -1,59 +1,67 @@
1
- import { useAccountStore as te, useGlobalCopyStore as oe, useGlobalUiStore as A, useHoldingStore as G } from "../../common/context/hooks.es.js";
2
- import { useScreenSize as re } from "../../common/hooks/useScreenSize.es.js";
3
- import ie from "../../common/components/Loader.es.js";
4
- import ne from "../../accounts/components/ConnectionsDrawer.es.js";
5
- import { EmptyStateFooterComponent as se } from "./EmptyStateFooterComponent.es.js";
6
- import ae from "./HoldingDrawer.es.js";
7
- import le from "./HoldingTable.es.js";
8
- import ce, { useState as u } from "react";
9
- import { observer as de } from "mobx-react-lite";
10
- import { InstitutionLogo as z, P as me, Text as n } from "@mxenabled/mxui";
11
- import T from "@mui/material/Paper";
1
+ import { useAccountStore as le, useGlobalCopyStore as ce, useGlobalUiStore as M, useHoldingStore as N } from "../../common/context/hooks.es.js";
2
+ import { useScreenSize as de } from "../../common/hooks/useScreenSize.es.js";
3
+ import { getHoldingGainLoss as C, getHoldingMarketValue as me } from "../../core/utils/InvestmentUtil.es.js";
4
+ import ge from "../../common/components/Loader.es.js";
5
+ import ue from "../../accounts/components/ConnectionsDrawer.es.js";
6
+ import { EmptyStateFooterComponent as pe } from "./EmptyStateFooterComponent.es.js";
7
+ import xe from "./HoldingDrawer.es.js";
8
+ import he from "./HoldingTable.es.js";
9
+ import fe, { useState as g } from "react";
10
+ import { observer as ye } from "mobx-react-lite";
11
+ import { InstitutionLogo as V, P as be, Text as i } from "@mxenabled/mxui";
12
+ import O from "@mui/material/Paper";
12
13
  import { Icon as x } from "@mxenabled/mx-icons";
13
- import { jsx as t, jsxs as r } from "react/jsx-runtime";
14
- import { useTheme as ue } from "@mui/material/styles";
14
+ import { Fragment as D, jsx as t, jsxs as r } from "react/jsx-runtime";
15
+ import { useTheme as ve } from "@mui/material/styles";
15
16
  import s from "@mui/system/Stack";
16
- import ge from "@mui/material/Accordion";
17
- import pe from "@mui/material/AccordionDetails";
18
- import xe from "@mui/material/AccordionSummary";
19
- var he = () => {
20
- const { isMobile: b } = re(), [C, j] = u({}), [E, D] = u(!1), { selectedAccountGuids: N } = A(), { visibleHoldings: M, updateHoldings: O } = G(), [P, R] = ce.useState(!1), [w, S] = u({
17
+ import Ce from "@mui/material/Accordion";
18
+ import De from "@mui/material/AccordionDetails";
19
+ import we from "@mui/material/AccordionSummary";
20
+ var Se = () => {
21
+ const { isMobile: w } = de(), [S, P] = g({}), [R, L] = g(!1), { selectedAccountGuids: $ } = M(), { visibleHoldings: q, updateHoldings: K } = N(), [J, Q] = fe.useState(!1), [_, I] = g({
21
22
  accounts: [],
22
23
  holdings: []
23
- }), { accounts: V, investments: m } = oe(), { isCopyLoaded: $ } = A(), [_, h] = u(null), [f, I] = u(""), y = ue().palette.mode === "dark", F = y ? "#0AC295" : "#09A57F", L = y ? "grey.300" : "grey.700", c = (e, o = "lesserThan") => o === "greaterThan" ? e >= 0 ? F : L : e <= 0 ? L : F, k = (e, o) => {
24
- h(e), I(o.toFixed(2));
25
- }, H = (e) => {
24
+ }), { accounts: X, investments: m } = ce(), { isCopyLoaded: Y } = M(), [F, h] = g(null), [f, H] = g(""), y = ve().palette.mode === "dark", B = y ? "#0AC295" : "#09A57F", A = y ? "grey.300" : "grey.700", d = (e, o = "lesserThan") => o === "greaterThan" ? e >= 0 ? B : A : e <= 0 ? A : B, U = (e, o) => {
25
+ h(e), H(o.toFixed(2));
26
+ }, G = (e) => {
26
27
  const o = e.target.value;
27
- /^\d*\.?\d*$/.test(o) && I(o);
28
- }, U = (e, o) => {
29
- e.key === "Enter" ? v(o) : e.key === "Escape" && h(null);
30
- }, v = (e) => {
31
- const o = M.find(({ guid: l }) => l === e);
28
+ /^\d*\.?\d*$/.test(o) && H(o);
29
+ }, k = (e, o) => {
30
+ e.key === "Enter" ? b(o) : e.key === "Escape" && h(null);
31
+ }, b = (e) => {
32
+ const o = q.find(({ guid: l }) => l === e);
32
33
  if (!o) return;
33
- const d = Number(f);
34
- if (O({
34
+ const c = Number(f);
35
+ if (K({
35
36
  ...o,
36
- cost_basis: d
37
- }), b) {
38
- const l = w.holdings.map((i) => i.id === e ? {
39
- ...i,
40
- costBasis: d
41
- } : i);
42
- S((i) => ({
43
- ...i,
37
+ cost_basis: c
38
+ }), w) {
39
+ const l = _.holdings.map((n) => n.id === e ? {
40
+ ...n,
41
+ costBasis: c,
42
+ rawCostBasis: c,
43
+ gainLossBasis: c,
44
+ totalGainLoss: n.marketValue - c,
45
+ gainLossAvailable: !0
46
+ } : n);
47
+ I((n) => ({
48
+ ...n,
44
49
  holdings: l
45
50
  }));
46
51
  }
47
52
  h(null);
48
- }, q = (e) => (o, d) => {
49
- j((l) => ({
53
+ }, Z = (e) => (o, c) => {
54
+ P((l) => ({
50
55
  ...l,
51
- [e]: d
56
+ [e]: c
52
57
  }));
53
- }, { visibleHoldings: B } = G(), { visibleInvestmentAccounts: K } = te(), g = K.filter(({ guid: e }) => N.includes(e)), J = g.reduce((e, o) => e + (o.balance || 0), 0), Q = g.map(({ guid: e }) => e), p = B.filter(({ account_guid: e }) => Q.includes(e)).reduce((e, o) => e + (o.market_value ? o.market_value - (o.cost_basis || 0) : 0), 0), X = () => {
54
- D(!1);
58
+ }, { visibleHoldings: W } = N(), { visibleInvestmentAccounts: ee } = le(), u = ee.filter(({ guid: e }) => $.includes(e)), te = u.reduce((e, o) => e + (o.balance || 0), 0), oe = new Set(u.map(({ guid: e }) => e)), z = W.filter(({ account_guid: e }) => oe.has(e)), p = z.reduce((e, o) => {
59
+ const { available: c, gainLoss: l } = C(o);
60
+ return c ? e + l : e;
61
+ }, 0), ie = z.some((e) => C(e).available), ne = () => {
62
+ L(!1);
55
63
  };
56
- return $ ? /* @__PURE__ */ r(s, {
64
+ return Y ? /* @__PURE__ */ r(s, {
57
65
  sx: {
58
66
  alignItems: "center",
59
67
  gap: 48,
@@ -61,35 +69,35 @@ var he = () => {
61
69
  width: "100%"
62
70
  },
63
71
  children: [
64
- !!g.length && /* @__PURE__ */ r(s, {
72
+ !!u.length && /* @__PURE__ */ r(s, {
65
73
  sx: { alignItems: "center" },
66
74
  children: [
67
- /* @__PURE__ */ t(n, {
75
+ /* @__PURE__ */ t(i, {
68
76
  sx: { color: "text.secondary" },
69
77
  children: m.overview.total_portfolio
70
78
  }),
71
- /* @__PURE__ */ t(me, {
79
+ /* @__PURE__ */ t(be, {
72
80
  variant: "h1",
73
- children: J.toLocaleString("en-US", {
81
+ children: te.toLocaleString("en-US", {
74
82
  currency: "USD",
75
83
  maximumFractionDigits: 2,
76
84
  minimumFractionDigits: 2,
77
85
  style: "currency"
78
86
  })
79
87
  }),
80
- /* @__PURE__ */ r(s, {
88
+ /* @__PURE__ */ t(s, {
81
89
  sx: {
82
90
  alignItems: "center",
83
91
  flexDirection: "row",
84
92
  gap: 8
85
93
  },
86
- children: [/* @__PURE__ */ t(x, {
94
+ children: ie ? /* @__PURE__ */ r(D, { children: [/* @__PURE__ */ t(x, {
87
95
  name: p >= 0 ? "trending_up" : "trending_down",
88
96
  size: 20,
89
- sx: { color: c(p, "greaterThan") }
90
- }), /* @__PURE__ */ t(n, {
97
+ sx: { color: d(p, "greaterThan") }
98
+ }), /* @__PURE__ */ t(i, {
91
99
  sx: {
92
- color: c(p, "greaterThan"),
100
+ color: d(p, "greaterThan"),
93
101
  fontWeight: 700
94
102
  },
95
103
  variant: "body2",
@@ -99,23 +107,36 @@ var he = () => {
99
107
  minimumFractionDigits: 2,
100
108
  style: "currency"
101
109
  })
102
- })]
110
+ })] }) : /* @__PURE__ */ t(i, {
111
+ sx: {
112
+ color: "text.secondary",
113
+ fontWeight: 700
114
+ },
115
+ variant: "body2",
116
+ children: "—"
117
+ })
103
118
  })
104
119
  ]
105
120
  }),
106
- g.map((e) => {
107
- const o = B.filter((a) => a.account_guid === e.guid).map((a) => ({
108
- id: a.guid,
109
- qty: a.shares || 0,
110
- holding: a.symbol || a.description || "Unknown",
111
- costBasis: a.cost_basis || 0,
112
- totalGainLoss: a.market_value ? a.market_value - (a.cost_basis || 0) : 0,
113
- marketValue: a.market_value || 0,
114
- description: a.description || ""
115
- })), d = o.length > 0, l = e.balance, i = o.reduce((a, ee) => ee.totalGainLoss + a, 0), W = l ? i / l * 100 : 0;
116
- if (b) return /* @__PURE__ */ t(T, {
121
+ u.map((e) => {
122
+ const o = W.filter((a) => a.account_guid === e.guid).map((a) => {
123
+ const { available: v, basis: E, gainLoss: ae } = C(a);
124
+ return {
125
+ id: a.guid,
126
+ qty: a.shares || 0,
127
+ holding: a.symbol || a.description || "Unknown",
128
+ costBasis: E,
129
+ rawCostBasis: a.cost_basis || 0,
130
+ totalGainLoss: ae,
131
+ gainLossAvailable: v,
132
+ gainLossBasis: E,
133
+ marketValue: me(a),
134
+ description: a.description || ""
135
+ };
136
+ }), c = o.length > 0, l = e.balance, n = o.reduce((a, v) => v.totalGainLoss + a, 0), T = o.some((a) => a.gainLossAvailable), j = l ? n / l * 100 : 0;
137
+ if (w) return /* @__PURE__ */ t(O, {
117
138
  onClick: o.length ? () => {
118
- D(!0), S({
139
+ L(!0), I({
119
140
  holdings: o,
120
141
  accounts: e
121
142
  });
@@ -144,7 +165,7 @@ var he = () => {
144
165
  pl: 14,
145
166
  pr: 14
146
167
  },
147
- children: [/* @__PURE__ */ t(z, {
168
+ children: [/* @__PURE__ */ t(V, {
148
169
  alt: e.institutionName || "",
149
170
  institutionGuid: e.institution_guid || "",
150
171
  size: 32
@@ -154,11 +175,11 @@ var he = () => {
154
175
  pl: 13,
155
176
  pr: 13
156
177
  },
157
- children: [/* @__PURE__ */ t(n, {
178
+ children: [/* @__PURE__ */ t(i, {
158
179
  sx: { color: "text.secondary" },
159
180
  variant: "caption",
160
181
  children: e.memberName
161
- }), /* @__PURE__ */ t(n, {
182
+ }), /* @__PURE__ */ t(i, {
162
183
  sx: {
163
184
  color: "text.primary",
164
185
  fontWeight: 600
@@ -187,53 +208,57 @@ var he = () => {
187
208
  pr: 7,
188
209
  pt: 14
189
210
  },
190
- children: [/* @__PURE__ */ t(n, {
211
+ children: [/* @__PURE__ */ t(i, {
191
212
  sx: {
192
213
  color: "text.secondary",
193
214
  fontSize: 11
194
215
  },
195
216
  variant: "body2",
196
217
  children: m.overview.total_gain_Loss
197
- }), /* @__PURE__ */ r(s, {
218
+ }), /* @__PURE__ */ t(s, {
198
219
  sx: {
199
220
  alignItems: "center",
200
221
  flexDirection: "row",
201
222
  gap: 2,
202
223
  justifyContent: "flex-end"
203
224
  },
204
- children: [
205
- i !== 0 && /* @__PURE__ */ t(x, {
206
- name: i > 0 ? "trending_up" : "trending_down",
225
+ children: T ? /* @__PURE__ */ r(D, { children: [
226
+ n !== 0 && /* @__PURE__ */ t(x, {
227
+ name: n > 0 ? "trending_up" : "trending_down",
207
228
  size: 20,
208
- sx: { color: c(i) }
229
+ sx: { color: d(n) }
209
230
  }),
210
- /* @__PURE__ */ r(n, {
231
+ /* @__PURE__ */ r(i, {
211
232
  sx: {
212
- color: c(i),
233
+ color: d(n),
213
234
  fontWeight: 600
214
235
  },
215
236
  variant: "body1",
216
- children: [W.toFixed(2), "%"]
237
+ children: [j.toFixed(2), "%"]
217
238
  }),
218
- /* @__PURE__ */ t(n, {
239
+ /* @__PURE__ */ t(i, {
219
240
  sx: { color: "text.secondary" },
220
241
  variant: "caption",
221
242
  children: "|"
222
243
  }),
223
- /* @__PURE__ */ t(n, {
244
+ /* @__PURE__ */ t(i, {
224
245
  sx: {
225
- color: c(i),
246
+ color: d(n),
226
247
  fontWeight: 600
227
248
  },
228
249
  variant: "body1",
229
- children: Math.abs(i).toLocaleString("en-US", {
250
+ children: Math.abs(n).toLocaleString("en-US", {
230
251
  currency: "USD",
231
252
  maximumFractionDigits: 2,
232
253
  minimumFractionDigits: 2,
233
254
  style: "currency"
234
255
  })
235
256
  })
236
- ]
257
+ ] }) : /* @__PURE__ */ t(i, {
258
+ sx: { color: "text.secondary" },
259
+ variant: "body1",
260
+ children: "—"
261
+ })
237
262
  })]
238
263
  }), /* @__PURE__ */ r(s, {
239
264
  sx: {
@@ -245,11 +270,11 @@ var he = () => {
245
270
  pr: 7,
246
271
  pt: 14
247
272
  },
248
- children: [/* @__PURE__ */ t(n, {
273
+ children: [/* @__PURE__ */ t(i, {
249
274
  sx: { color: "text.secondary" },
250
275
  variant: "caption",
251
276
  children: m.overview.total_value
252
- }), /* @__PURE__ */ t(n, {
277
+ }), /* @__PURE__ */ t(i, {
253
278
  sx: {
254
279
  color: "text.primary",
255
280
  fontWeight: 600
@@ -266,10 +291,10 @@ var he = () => {
266
291
  })]
267
292
  })
268
293
  }, e.guid);
269
- const Y = y ? "grey.700" : "grey.400", Z = o.length ? "text.primary" : Y;
270
- return /* @__PURE__ */ r(ge, {
271
- expanded: C[e.guid] === !0,
272
- onChange: d ? q(e.guid) : () => {
294
+ const re = y ? "grey.700" : "grey.400", se = o.length ? "text.primary" : re;
295
+ return /* @__PURE__ */ r(Ce, {
296
+ expanded: S[e.guid] === !0,
297
+ onChange: c ? Z(e.guid) : () => {
273
298
  },
274
299
  sx: {
275
300
  border: 1,
@@ -277,10 +302,10 @@ var he = () => {
277
302
  borderRadius: "4px",
278
303
  width: "100%"
279
304
  },
280
- children: [/* @__PURE__ */ r(xe, {
305
+ children: [/* @__PURE__ */ r(we, {
281
306
  "aria-controls": "panel1a-content",
282
307
  id: "panel1a-header",
283
- sx: [C[e.guid] && {
308
+ sx: [S[e.guid] && {
284
309
  borderBottom: 1,
285
310
  borderColor: "divider",
286
311
  maxHeight: 88
@@ -297,20 +322,20 @@ var he = () => {
297
322
  /* @__PURE__ */ t(x, {
298
323
  name: "expand_more",
299
324
  size: 20,
300
- sx: { color: Z }
325
+ sx: { color: se }
301
326
  }),
302
- /* @__PURE__ */ t(z, {
327
+ /* @__PURE__ */ t(V, {
303
328
  alt: e.institutionName || "",
304
329
  institutionGuid: e.institution_guid || "",
305
330
  size: 32
306
331
  }),
307
332
  /* @__PURE__ */ r(s, {
308
333
  sx: { alignItems: "flex-start" },
309
- children: [/* @__PURE__ */ t(n, {
334
+ children: [/* @__PURE__ */ t(i, {
310
335
  sx: { color: "text.secondary" },
311
336
  variant: "caption",
312
337
  children: e.memberName
313
- }), /* @__PURE__ */ t(n, {
338
+ }), /* @__PURE__ */ t(i, {
314
339
  sx: {
315
340
  color: "text.primary",
316
341
  fontWeight: 600
@@ -330,50 +355,54 @@ var he = () => {
330
355
  pr: 24,
331
356
  pt: 14
332
357
  },
333
- children: [/* @__PURE__ */ t(n, {
358
+ children: [/* @__PURE__ */ t(i, {
334
359
  sx: { color: "text.secondary" },
335
360
  variant: "caption",
336
361
  children: m.overview.total_gain_Loss
337
- }), /* @__PURE__ */ r(s, {
362
+ }), /* @__PURE__ */ t(s, {
338
363
  sx: {
339
364
  alignItems: "center",
340
365
  flexDirection: "row",
341
366
  gap: 2,
342
367
  justifyContent: "flex-end"
343
368
  },
344
- children: [
345
- i !== 0 && /* @__PURE__ */ t(x, {
346
- name: i >= 0 ? "trending_up" : "trending_down",
369
+ children: T ? /* @__PURE__ */ r(D, { children: [
370
+ n !== 0 && /* @__PURE__ */ t(x, {
371
+ name: n >= 0 ? "trending_up" : "trending_down",
347
372
  size: 20,
348
- sx: { color: c(i) }
373
+ sx: { color: d(n) }
349
374
  }),
350
- /* @__PURE__ */ r(n, {
375
+ /* @__PURE__ */ r(i, {
351
376
  sx: {
352
- color: c(i),
377
+ color: d(n),
353
378
  fontWeight: 600
354
379
  },
355
380
  variant: "body1",
356
- children: [W.toFixed(2), "%"]
381
+ children: [j.toFixed(2), "%"]
357
382
  }),
358
- /* @__PURE__ */ t(n, {
383
+ /* @__PURE__ */ t(i, {
359
384
  sx: { color: "text.secondary" },
360
385
  variant: "caption",
361
386
  children: "|"
362
387
  }),
363
- /* @__PURE__ */ t(n, {
388
+ /* @__PURE__ */ t(i, {
364
389
  sx: {
365
- color: c(i),
390
+ color: d(n),
366
391
  fontWeight: 600
367
392
  },
368
393
  variant: "body1",
369
- children: Math.abs(i).toLocaleString("en-US", {
394
+ children: Math.abs(n).toLocaleString("en-US", {
370
395
  currency: "USD",
371
396
  maximumFractionDigits: 2,
372
397
  minimumFractionDigits: 2,
373
398
  style: "currency"
374
399
  })
375
400
  })
376
- ]
401
+ ] }) : /* @__PURE__ */ t(i, {
402
+ sx: { color: "text.secondary" },
403
+ variant: "body1",
404
+ children: "—"
405
+ })
377
406
  })]
378
407
  }), /* @__PURE__ */ t(s, {
379
408
  sx: {
@@ -386,11 +415,11 @@ var he = () => {
386
415
  },
387
416
  children: /* @__PURE__ */ r(s, {
388
417
  sx: { alignItems: "flex-end" },
389
- children: [/* @__PURE__ */ t(n, {
418
+ children: [/* @__PURE__ */ t(i, {
390
419
  sx: { color: "text.secondary" },
391
420
  variant: "caption",
392
421
  children: m.overview.total_value
393
- }), /* @__PURE__ */ t(n, {
422
+ }), /* @__PURE__ */ t(i, {
394
423
  sx: {
395
424
  color: "text.primary",
396
425
  fontWeight: 600
@@ -406,51 +435,51 @@ var he = () => {
406
435
  })
407
436
  })]
408
437
  })]
409
- }), /* @__PURE__ */ t(pe, {
438
+ }), /* @__PURE__ */ t(De, {
410
439
  sx: {
411
440
  bgcolor: "background.default",
412
441
  p: 12
413
442
  },
414
- children: /* @__PURE__ */ t(T, {
443
+ children: /* @__PURE__ */ t(O, {
415
444
  sx: {
416
445
  border: 1,
417
446
  borderColor: "neutral.light"
418
447
  },
419
- children: /* @__PURE__ */ t(le, {
448
+ children: /* @__PURE__ */ t(he, {
420
449
  currentEditedCostBasis: f,
421
450
  data: o,
422
- editingHoldingId: _,
423
- handleCostBasisBlur: v,
424
- handleCostBasisChange: H,
425
- handleCostBasisClick: k,
426
- handleCostBasisKeyDown: U
451
+ editingHoldingId: F,
452
+ handleCostBasisBlur: b,
453
+ handleCostBasisChange: G,
454
+ handleCostBasisClick: U,
455
+ handleCostBasisKeyDown: k
427
456
  })
428
457
  })
429
458
  })]
430
459
  }, e.guid);
431
460
  }),
432
- /* @__PURE__ */ t(se, {}),
433
- /* @__PURE__ */ t(ae, {
434
- accountHoldingsData: w,
461
+ /* @__PURE__ */ t(pe, {}),
462
+ /* @__PURE__ */ t(xe, {
463
+ accountHoldingsData: _,
435
464
  currentEditedCostBasis: f,
436
- editingHoldingId: _,
437
- handleCostBasisBlur: v,
438
- handleCostBasisChange: H,
439
- handleCostBasisClick: k,
440
- handleCostBasisKeyDown: U,
441
- isOpen: E,
442
- onClose: X
465
+ editingHoldingId: F,
466
+ handleCostBasisBlur: b,
467
+ handleCostBasisChange: G,
468
+ handleCostBasisClick: U,
469
+ handleCostBasisKeyDown: k,
470
+ isOpen: R,
471
+ onClose: ne
443
472
  }),
444
- /* @__PURE__ */ t(ne, {
445
- onClose: () => R(!1),
446
- showConnectionsWidget: P,
447
- title: V.manage_connections
473
+ /* @__PURE__ */ t(ue, {
474
+ onClose: () => Q(!1),
475
+ showConnectionsWidget: J,
476
+ title: X.manage_connections
448
477
  })
449
478
  ]
450
- }) : /* @__PURE__ */ t(ie, {});
451
- }, Ge = de(he);
479
+ }) : /* @__PURE__ */ t(ge, {});
480
+ }, Pe = ye(Se);
452
481
  export {
453
- Ge as default
482
+ Pe as default
454
483
  };
455
484
 
456
485
  //# sourceMappingURL=Overview.es.js.map