@loafmarkets/ui 0.1.130 → 0.1.132
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +73 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +73 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5978,6 +5978,7 @@ var PortfolioEyeButton = styled25.button`
|
|
|
5978
5978
|
justify-content: center;
|
|
5979
5979
|
color: ${(p) => p.$active ? "#D4AF37" : "rgba(255,255,255,0.5)"};
|
|
5980
5980
|
transition: all 0.2s ease;
|
|
5981
|
+
margin-left: 6px;
|
|
5981
5982
|
margin-right: 10px;
|
|
5982
5983
|
|
|
5983
5984
|
&:hover {
|
|
@@ -5987,6 +5988,7 @@ var PortfolioEyeButton = styled25.button`
|
|
|
5987
5988
|
|
|
5988
5989
|
@media (max-width: 768px) {
|
|
5989
5990
|
padding: 4px;
|
|
5991
|
+
margin-left: 4px;
|
|
5990
5992
|
margin-right: 6px;
|
|
5991
5993
|
}
|
|
5992
5994
|
`;
|
|
@@ -11800,6 +11802,42 @@ function PortfolioActivityPanel({
|
|
|
11800
11802
|
const [activeTab, setActiveTab] = useState(resolvedDefaultTab);
|
|
11801
11803
|
const [activityPage, setActivityPage] = useState(0);
|
|
11802
11804
|
const [pendingCancelOrderId, setPendingCancelOrderId] = useState(null);
|
|
11805
|
+
const [posSortKey, setPosSortKey] = useState("asset");
|
|
11806
|
+
const [posSortAsc, setPosSortAsc] = useState(true);
|
|
11807
|
+
const handlePosSort = (key) => {
|
|
11808
|
+
if (posSortKey === key) {
|
|
11809
|
+
setPosSortAsc((v) => !v);
|
|
11810
|
+
} else {
|
|
11811
|
+
setPosSortKey(key);
|
|
11812
|
+
setPosSortAsc(key === "asset");
|
|
11813
|
+
}
|
|
11814
|
+
};
|
|
11815
|
+
const sortedPositions = useMemo(() => {
|
|
11816
|
+
const arr = [...positions];
|
|
11817
|
+
const dir = posSortAsc ? 1 : -1;
|
|
11818
|
+
arr.sort((a, b) => {
|
|
11819
|
+
switch (posSortKey) {
|
|
11820
|
+
case "asset":
|
|
11821
|
+
return dir * a.tokenName.localeCompare(b.tokenName);
|
|
11822
|
+
case "units":
|
|
11823
|
+
return dir * (a.quantity - b.quantity);
|
|
11824
|
+
case "value":
|
|
11825
|
+
return dir * (a.quantity * a.marketPrice - b.quantity * b.marketPrice);
|
|
11826
|
+
case "avgPrice":
|
|
11827
|
+
return dir * (a.averageEntryPrice - b.averageEntryPrice);
|
|
11828
|
+
case "currentPrice":
|
|
11829
|
+
return dir * (a.marketPrice - b.marketPrice);
|
|
11830
|
+
case "pnl": {
|
|
11831
|
+
const pnlA = a.propertyPnlPercent ?? a.percentChange ?? 0;
|
|
11832
|
+
const pnlB = b.propertyPnlPercent ?? b.percentChange ?? 0;
|
|
11833
|
+
return dir * (pnlA - pnlB);
|
|
11834
|
+
}
|
|
11835
|
+
default:
|
|
11836
|
+
return 0;
|
|
11837
|
+
}
|
|
11838
|
+
});
|
|
11839
|
+
return arr;
|
|
11840
|
+
}, [positions, posSortKey, posSortAsc]);
|
|
11803
11841
|
const activeTabTotal = useMemo(() => {
|
|
11804
11842
|
switch (activeTab) {
|
|
11805
11843
|
case "positions":
|
|
@@ -11882,15 +11920,33 @@ function PortfolioActivityPanel({
|
|
|
11882
11920
|
positions.length === 0 && /* @__PURE__ */ jsx(EmptyState, { children: "No positions yet. Subscribe to an offering or buy on the secondary market." }),
|
|
11883
11921
|
positions.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11884
11922
|
/* @__PURE__ */ jsxs(PositionsHeader, { $hasClose: !!onClosePosition, children: [
|
|
11885
|
-
/* @__PURE__ */
|
|
11886
|
-
|
|
11887
|
-
|
|
11888
|
-
|
|
11889
|
-
/* @__PURE__ */
|
|
11890
|
-
|
|
11923
|
+
/* @__PURE__ */ jsxs(SortableHeaderCell, { $active: posSortKey === "asset", onClick: () => handlePosSort("asset"), children: [
|
|
11924
|
+
"Asset ",
|
|
11925
|
+
posSortKey === "asset" && (posSortAsc ? "\u2191" : "\u2193")
|
|
11926
|
+
] }),
|
|
11927
|
+
/* @__PURE__ */ jsxs(SortableHeaderCell, { $active: posSortKey === "units", onClick: () => handlePosSort("units"), children: [
|
|
11928
|
+
"Units ",
|
|
11929
|
+
posSortKey === "units" && (posSortAsc ? "\u2191" : "\u2193")
|
|
11930
|
+
] }),
|
|
11931
|
+
/* @__PURE__ */ jsxs(SortableHeaderCell, { $active: posSortKey === "value", onClick: () => handlePosSort("value"), children: [
|
|
11932
|
+
"Position Value ",
|
|
11933
|
+
posSortKey === "value" && (posSortAsc ? "\u2191" : "\u2193")
|
|
11934
|
+
] }),
|
|
11935
|
+
/* @__PURE__ */ jsxs(SortableHeaderCell, { $active: posSortKey === "avgPrice", onClick: () => handlePosSort("avgPrice"), children: [
|
|
11936
|
+
"Avg Price ",
|
|
11937
|
+
posSortKey === "avgPrice" && (posSortAsc ? "\u2191" : "\u2193")
|
|
11938
|
+
] }),
|
|
11939
|
+
/* @__PURE__ */ jsxs(SortableHeaderCell, { $active: posSortKey === "currentPrice", onClick: () => handlePosSort("currentPrice"), children: [
|
|
11940
|
+
"Current Price ",
|
|
11941
|
+
posSortKey === "currentPrice" && (posSortAsc ? "\u2191" : "\u2193")
|
|
11942
|
+
] }),
|
|
11943
|
+
/* @__PURE__ */ jsxs(SortableHeaderCell, { $active: posSortKey === "pnl", onClick: () => handlePosSort("pnl"), children: [
|
|
11944
|
+
"PNL (%) ",
|
|
11945
|
+
posSortKey === "pnl" && (posSortAsc ? "\u2191" : "\u2193")
|
|
11946
|
+
] }),
|
|
11891
11947
|
onClosePosition && /* @__PURE__ */ jsx(PositionsHeaderCell, { children: "Close" })
|
|
11892
11948
|
] }),
|
|
11893
|
-
pageSlice(
|
|
11949
|
+
pageSlice(sortedPositions).map((pos) => {
|
|
11894
11950
|
const currentValue = pos.quantity * pos.marketPrice;
|
|
11895
11951
|
const costBasis = pos.quantity * pos.averageEntryPrice;
|
|
11896
11952
|
const pnl = pos.propertyPnl ?? currentValue - costBasis;
|
|
@@ -12319,6 +12375,16 @@ var PositionsHeaderCell = styled25.div`
|
|
|
12319
12375
|
text-align: ${(p) => p.$align || "left"};
|
|
12320
12376
|
white-space: nowrap;
|
|
12321
12377
|
`;
|
|
12378
|
+
var SortableHeaderCell = styled25.div`
|
|
12379
|
+
font-size: 0.68rem;
|
|
12380
|
+
font-weight: 500;
|
|
12381
|
+
color: ${(p) => p.$active ? "rgba(255, 255, 255, 0.7)" : "rgba(255, 255, 255, 0.4)"};
|
|
12382
|
+
white-space: nowrap;
|
|
12383
|
+
cursor: pointer;
|
|
12384
|
+
user-select: none;
|
|
12385
|
+
transition: color 0.15s ease;
|
|
12386
|
+
&:hover { color: rgba(255, 255, 255, 0.7); }
|
|
12387
|
+
`;
|
|
12322
12388
|
var PositionsRow = styled25.div`
|
|
12323
12389
|
display: grid;
|
|
12324
12390
|
grid-template-columns: ${(p) => p.$hasClose ? "1.4fr 0.8fr 1fr 1fr 1fr 1.1fr 110px" : "1.2fr 0.8fr 1fr 1fr 1fr 1.2fr"};
|