@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 CHANGED
@@ -6004,6 +6004,7 @@ var PortfolioEyeButton = styled25__default.default.button`
6004
6004
  justify-content: center;
6005
6005
  color: ${(p) => p.$active ? "#D4AF37" : "rgba(255,255,255,0.5)"};
6006
6006
  transition: all 0.2s ease;
6007
+ margin-left: 6px;
6007
6008
  margin-right: 10px;
6008
6009
 
6009
6010
  &:hover {
@@ -6013,6 +6014,7 @@ var PortfolioEyeButton = styled25__default.default.button`
6013
6014
 
6014
6015
  @media (max-width: 768px) {
6015
6016
  padding: 4px;
6017
+ margin-left: 4px;
6016
6018
  margin-right: 6px;
6017
6019
  }
6018
6020
  `;
@@ -11826,6 +11828,42 @@ function PortfolioActivityPanel({
11826
11828
  const [activeTab, setActiveTab] = React5.useState(resolvedDefaultTab);
11827
11829
  const [activityPage, setActivityPage] = React5.useState(0);
11828
11830
  const [pendingCancelOrderId, setPendingCancelOrderId] = React5.useState(null);
11831
+ const [posSortKey, setPosSortKey] = React5.useState("asset");
11832
+ const [posSortAsc, setPosSortAsc] = React5.useState(true);
11833
+ const handlePosSort = (key) => {
11834
+ if (posSortKey === key) {
11835
+ setPosSortAsc((v) => !v);
11836
+ } else {
11837
+ setPosSortKey(key);
11838
+ setPosSortAsc(key === "asset");
11839
+ }
11840
+ };
11841
+ const sortedPositions = React5.useMemo(() => {
11842
+ const arr = [...positions];
11843
+ const dir = posSortAsc ? 1 : -1;
11844
+ arr.sort((a, b) => {
11845
+ switch (posSortKey) {
11846
+ case "asset":
11847
+ return dir * a.tokenName.localeCompare(b.tokenName);
11848
+ case "units":
11849
+ return dir * (a.quantity - b.quantity);
11850
+ case "value":
11851
+ return dir * (a.quantity * a.marketPrice - b.quantity * b.marketPrice);
11852
+ case "avgPrice":
11853
+ return dir * (a.averageEntryPrice - b.averageEntryPrice);
11854
+ case "currentPrice":
11855
+ return dir * (a.marketPrice - b.marketPrice);
11856
+ case "pnl": {
11857
+ const pnlA = a.propertyPnlPercent ?? a.percentChange ?? 0;
11858
+ const pnlB = b.propertyPnlPercent ?? b.percentChange ?? 0;
11859
+ return dir * (pnlA - pnlB);
11860
+ }
11861
+ default:
11862
+ return 0;
11863
+ }
11864
+ });
11865
+ return arr;
11866
+ }, [positions, posSortKey, posSortAsc]);
11829
11867
  const activeTabTotal = React5.useMemo(() => {
11830
11868
  switch (activeTab) {
11831
11869
  case "positions":
@@ -11908,15 +11946,33 @@ function PortfolioActivityPanel({
11908
11946
  positions.length === 0 && /* @__PURE__ */ jsxRuntime.jsx(EmptyState, { children: "No positions yet. Subscribe to an offering or buy on the secondary market." }),
11909
11947
  positions.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
11910
11948
  /* @__PURE__ */ jsxRuntime.jsxs(PositionsHeader, { $hasClose: !!onClosePosition, children: [
11911
- /* @__PURE__ */ jsxRuntime.jsx(PositionsHeaderCell, { children: "Asset" }),
11912
- /* @__PURE__ */ jsxRuntime.jsx(PositionsHeaderCell, { children: "Units" }),
11913
- /* @__PURE__ */ jsxRuntime.jsx(PositionsHeaderCell, { children: "Position Value" }),
11914
- /* @__PURE__ */ jsxRuntime.jsx(PositionsHeaderCell, { children: "Avg Price" }),
11915
- /* @__PURE__ */ jsxRuntime.jsx(PositionsHeaderCell, { children: "Current Price" }),
11916
- /* @__PURE__ */ jsxRuntime.jsx(PositionsHeaderCell, { children: "PNL (%)" }),
11949
+ /* @__PURE__ */ jsxRuntime.jsxs(SortableHeaderCell, { $active: posSortKey === "asset", onClick: () => handlePosSort("asset"), children: [
11950
+ "Asset ",
11951
+ posSortKey === "asset" && (posSortAsc ? "\u2191" : "\u2193")
11952
+ ] }),
11953
+ /* @__PURE__ */ jsxRuntime.jsxs(SortableHeaderCell, { $active: posSortKey === "units", onClick: () => handlePosSort("units"), children: [
11954
+ "Units ",
11955
+ posSortKey === "units" && (posSortAsc ? "\u2191" : "\u2193")
11956
+ ] }),
11957
+ /* @__PURE__ */ jsxRuntime.jsxs(SortableHeaderCell, { $active: posSortKey === "value", onClick: () => handlePosSort("value"), children: [
11958
+ "Position Value ",
11959
+ posSortKey === "value" && (posSortAsc ? "\u2191" : "\u2193")
11960
+ ] }),
11961
+ /* @__PURE__ */ jsxRuntime.jsxs(SortableHeaderCell, { $active: posSortKey === "avgPrice", onClick: () => handlePosSort("avgPrice"), children: [
11962
+ "Avg Price ",
11963
+ posSortKey === "avgPrice" && (posSortAsc ? "\u2191" : "\u2193")
11964
+ ] }),
11965
+ /* @__PURE__ */ jsxRuntime.jsxs(SortableHeaderCell, { $active: posSortKey === "currentPrice", onClick: () => handlePosSort("currentPrice"), children: [
11966
+ "Current Price ",
11967
+ posSortKey === "currentPrice" && (posSortAsc ? "\u2191" : "\u2193")
11968
+ ] }),
11969
+ /* @__PURE__ */ jsxRuntime.jsxs(SortableHeaderCell, { $active: posSortKey === "pnl", onClick: () => handlePosSort("pnl"), children: [
11970
+ "PNL (%) ",
11971
+ posSortKey === "pnl" && (posSortAsc ? "\u2191" : "\u2193")
11972
+ ] }),
11917
11973
  onClosePosition && /* @__PURE__ */ jsxRuntime.jsx(PositionsHeaderCell, { children: "Close" })
11918
11974
  ] }),
11919
- pageSlice(positions).map((pos) => {
11975
+ pageSlice(sortedPositions).map((pos) => {
11920
11976
  const currentValue = pos.quantity * pos.marketPrice;
11921
11977
  const costBasis = pos.quantity * pos.averageEntryPrice;
11922
11978
  const pnl = pos.propertyPnl ?? currentValue - costBasis;
@@ -12345,6 +12401,16 @@ var PositionsHeaderCell = styled25__default.default.div`
12345
12401
  text-align: ${(p) => p.$align || "left"};
12346
12402
  white-space: nowrap;
12347
12403
  `;
12404
+ var SortableHeaderCell = styled25__default.default.div`
12405
+ font-size: 0.68rem;
12406
+ font-weight: 500;
12407
+ color: ${(p) => p.$active ? "rgba(255, 255, 255, 0.7)" : "rgba(255, 255, 255, 0.4)"};
12408
+ white-space: nowrap;
12409
+ cursor: pointer;
12410
+ user-select: none;
12411
+ transition: color 0.15s ease;
12412
+ &:hover { color: rgba(255, 255, 255, 0.7); }
12413
+ `;
12348
12414
  var PositionsRow = styled25__default.default.div`
12349
12415
  display: grid;
12350
12416
  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"};