@medialane/ui 0.202.0 → 0.203.0

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.
Files changed (51) hide show
  1. package/dist/components/badge.d.cts +1 -1
  2. package/dist/components/badge.d.ts +1 -1
  3. package/dist/components/button.d.cts +1 -1
  4. package/dist/components/button.d.ts +1 -1
  5. package/dist/components/medialane-app.cjs.map +1 -1
  6. package/dist/components/medialane-app.d.cts +1 -0
  7. package/dist/components/medialane-app.d.ts +1 -0
  8. package/dist/components/medialane-app.js.map +1 -1
  9. package/dist/components/portfolio-assets.cjs +117 -0
  10. package/dist/components/portfolio-assets.cjs.map +1 -0
  11. package/dist/components/portfolio-assets.d.cts +19 -0
  12. package/dist/components/portfolio-assets.d.ts +19 -0
  13. package/dist/components/portfolio-assets.js +93 -0
  14. package/dist/components/portfolio-assets.js.map +1 -0
  15. package/dist/components/portfolio-orders.cjs +205 -0
  16. package/dist/components/portfolio-orders.cjs.map +1 -0
  17. package/dist/components/portfolio-orders.d.cts +23 -0
  18. package/dist/components/portfolio-orders.d.ts +23 -0
  19. package/dist/components/portfolio-orders.js +171 -0
  20. package/dist/components/portfolio-orders.js.map +1 -0
  21. package/dist/components/portfolio-shell.cjs +106 -0
  22. package/dist/components/portfolio-shell.cjs.map +1 -0
  23. package/dist/components/portfolio-shell.d.cts +18 -0
  24. package/dist/components/portfolio-shell.d.ts +18 -0
  25. package/dist/components/portfolio-shell.js +81 -0
  26. package/dist/components/portfolio-shell.js.map +1 -0
  27. package/dist/components/router.cjs +2 -0
  28. package/dist/components/router.cjs.map +1 -1
  29. package/dist/components/router.d.cts +1 -1
  30. package/dist/components/router.d.ts +1 -1
  31. package/dist/components/router.js +2 -1
  32. package/dist/components/router.js.map +1 -1
  33. package/dist/index.cjs +16 -0
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +4 -0
  36. package/dist/index.d.ts +4 -0
  37. package/dist/index.js +10 -0
  38. package/dist/index.js.map +1 -1
  39. package/dist/utils/portfolio-counts.cjs +8 -2
  40. package/dist/utils/portfolio-counts.cjs.map +1 -1
  41. package/dist/utils/portfolio-counts.d.cts +9 -3
  42. package/dist/utils/portfolio-counts.d.ts +9 -3
  43. package/dist/utils/portfolio-counts.js +8 -2
  44. package/dist/utils/portfolio-counts.js.map +1 -1
  45. package/dist/utils/seen-offers.cjs +52 -0
  46. package/dist/utils/seen-offers.cjs.map +1 -0
  47. package/dist/utils/seen-offers.d.cts +4 -0
  48. package/dist/utils/seen-offers.d.ts +4 -0
  49. package/dist/utils/seen-offers.js +27 -0
  50. package/dist/utils/seen-offers.js.map +1 -0
  51. package/package.json +1 -1
@@ -4,7 +4,7 @@ import * as React from 'react';
4
4
  import { VariantProps } from 'class-variance-authority';
5
5
 
6
6
  declare const badgeVariants: (props?: ({
7
- variant?: "outline" | "default" | "destructive" | "secondary" | null | undefined;
7
+ variant?: "default" | "destructive" | "outline" | "secondary" | null | undefined;
8
8
  } & class_variance_authority_types.ClassProp) | undefined) => string;
9
9
  interface BadgeProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {
10
10
  }
@@ -4,7 +4,7 @@ import * as React from 'react';
4
4
  import { VariantProps } from 'class-variance-authority';
5
5
 
6
6
  declare const badgeVariants: (props?: ({
7
- variant?: "outline" | "default" | "destructive" | "secondary" | null | undefined;
7
+ variant?: "default" | "destructive" | "outline" | "secondary" | null | undefined;
8
8
  } & class_variance_authority_types.ClassProp) | undefined) => string;
9
9
  interface BadgeProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {
10
10
  }
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import { VariantProps } from 'class-variance-authority';
4
4
 
5
5
  declare const buttonVariants: (props?: ({
6
- variant?: "outline" | "link" | "default" | "destructive" | "ghost" | "secondary" | "premium" | "tonal" | "gradient-border" | "gradient-fill" | null | undefined;
6
+ variant?: "default" | "link" | "destructive" | "outline" | "ghost" | "secondary" | "premium" | "tonal" | "gradient-border" | "gradient-fill" | null | undefined;
7
7
  size?: "default" | "icon" | "sm" | "lg" | null | undefined;
8
8
  } & class_variance_authority_types.ClassProp) | undefined) => string;
9
9
  interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import { VariantProps } from 'class-variance-authority';
4
4
 
5
5
  declare const buttonVariants: (props?: ({
6
- variant?: "outline" | "link" | "default" | "destructive" | "ghost" | "secondary" | "premium" | "tonal" | "gradient-border" | "gradient-fill" | null | undefined;
6
+ variant?: "default" | "link" | "destructive" | "outline" | "ghost" | "secondary" | "premium" | "tonal" | "gradient-border" | "gradient-fill" | null | undefined;
7
7
  size?: "default" | "icon" | "sm" | "lg" | null | undefined;
8
8
  } & class_variance_authority_types.ClassProp) | undefined) => string;
9
9
  interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/medialane-app.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext, type ComponentType, type ElementType, type ReactNode } from \"react\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport type { FastMintSigner } from \"./fast-mint/types.js\";\nimport type { ApiToken } from \"@medialane/sdk\";\nimport type { ImageResolver } from \"../utils/ipfs.js\";\n\nexport type AssetRef = Pick<ApiToken, \"chain\" | \"contractAddress\" | \"tokenId\">;\n\nexport interface CompanionApp {\n title: string;\n description: string;\n icon: ElementType;\n origin: string;\n}\n\nexport type ReportTarget =\n | { type: \"TOKEN\"; contract: string; tokenId: string; name?: string }\n | { type: \"COLLECTION\"; contract: string; name?: string };\n\nexport type ReportDialogSlot = ComponentType<{ open: boolean; onOpenChange: (open: boolean) => void; target: ReportTarget }>;\n\nexport interface MedialaneApp {\n getClient: () => MedialaneClient;\n getSigner: () => Promise<FastMintSigner> | FastMintSigner;\n walletAddress: string | null;\n onRequireWallet: () => void;\n connectLabel?: string;\n connectDescription?: string;\n companion?: CompanionApp;\n ReportDialog?: ReportDialogSlot;\n resolveImage?: ImageResolver;\n}\n\nexport const MedialaneAppContext = createContext<MedialaneApp | null>(null);\n\nexport function MedialaneAppProvider({ value, children }: { value: MedialaneApp; children: ReactNode }) {\n return <MedialaneAppContext.Provider value={value}>{children}</MedialaneAppContext.Provider>;\n}\n\nexport function useMedialaneApp(): MedialaneApp {\n const app = useContext(MedialaneAppContext);\n if (!app) throw new Error(\"MedialaneAppProvider missing\");\n return app;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsCS;AApCT,mBAAgG;AAiCzF,MAAM,0BAAsB,4BAAmC,IAAI;AAEnE,SAAS,qBAAqB,EAAE,OAAO,SAAS,GAAiD;AACtG,SAAO,4CAAC,oBAAoB,UAApB,EAA6B,OAAe,UAAS;AAC/D;AAEO,SAAS,kBAAgC;AAC9C,QAAM,UAAM,yBAAW,mBAAmB;AAC1C,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,8BAA8B;AACxD,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/components/medialane-app.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext, type ComponentType, type ElementType, type ReactNode } from \"react\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport type { FastMintSigner } from \"./fast-mint/types.js\";\nimport type { ApiToken } from \"@medialane/sdk\";\nimport type { ImageResolver } from \"../utils/ipfs.js\";\n\nexport type AssetRef = Pick<ApiToken, \"chain\" | \"contractAddress\" | \"tokenId\">;\n\nexport interface CompanionApp {\n title: string;\n description: string;\n icon: ElementType;\n origin: string;\n}\n\nexport type ReportTarget =\n | { type: \"TOKEN\"; contract: string; tokenId: string; name?: string }\n | { type: \"COLLECTION\"; contract: string; name?: string };\n\nexport type ReportDialogSlot = ComponentType<{ open: boolean; onOpenChange: (open: boolean) => void; target: ReportTarget }>;\n\nexport interface MedialaneApp {\n getClient: () => MedialaneClient;\n getSigner: () => Promise<FastMintSigner> | FastMintSigner;\n walletAddress: string | null;\n walletLoading?: boolean;\n onRequireWallet: () => void;\n connectLabel?: string;\n connectDescription?: string;\n companion?: CompanionApp;\n ReportDialog?: ReportDialogSlot;\n resolveImage?: ImageResolver;\n}\n\nexport const MedialaneAppContext = createContext<MedialaneApp | null>(null);\n\nexport function MedialaneAppProvider({ value, children }: { value: MedialaneApp; children: ReactNode }) {\n return <MedialaneAppContext.Provider value={value}>{children}</MedialaneAppContext.Provider>;\n}\n\nexport function useMedialaneApp(): MedialaneApp {\n const app = useContext(MedialaneAppContext);\n if (!app) throw new Error(\"MedialaneAppProvider missing\");\n return app;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuCS;AArCT,mBAAgG;AAkCzF,MAAM,0BAAsB,4BAAmC,IAAI;AAEnE,SAAS,qBAAqB,EAAE,OAAO,SAAS,GAAiD;AACtG,SAAO,4CAAC,oBAAoB,UAApB,EAA6B,OAAe,UAAS;AAC/D;AAEO,SAAS,kBAAgC;AAC9C,QAAM,UAAM,yBAAW,mBAAmB;AAC1C,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,8BAA8B;AACxD,SAAO;AACT;","names":[]}
@@ -33,6 +33,7 @@ interface MedialaneApp {
33
33
  getClient: () => MedialaneClient;
34
34
  getSigner: () => Promise<FastMintSigner> | FastMintSigner;
35
35
  walletAddress: string | null;
36
+ walletLoading?: boolean;
36
37
  onRequireWallet: () => void;
37
38
  connectLabel?: string;
38
39
  connectDescription?: string;
@@ -33,6 +33,7 @@ interface MedialaneApp {
33
33
  getClient: () => MedialaneClient;
34
34
  getSigner: () => Promise<FastMintSigner> | FastMintSigner;
35
35
  walletAddress: string | null;
36
+ walletLoading?: boolean;
36
37
  onRequireWallet: () => void;
37
38
  connectLabel?: string;
38
39
  connectDescription?: string;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/medialane-app.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext, type ComponentType, type ElementType, type ReactNode } from \"react\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport type { FastMintSigner } from \"./fast-mint/types.js\";\nimport type { ApiToken } from \"@medialane/sdk\";\nimport type { ImageResolver } from \"../utils/ipfs.js\";\n\nexport type AssetRef = Pick<ApiToken, \"chain\" | \"contractAddress\" | \"tokenId\">;\n\nexport interface CompanionApp {\n title: string;\n description: string;\n icon: ElementType;\n origin: string;\n}\n\nexport type ReportTarget =\n | { type: \"TOKEN\"; contract: string; tokenId: string; name?: string }\n | { type: \"COLLECTION\"; contract: string; name?: string };\n\nexport type ReportDialogSlot = ComponentType<{ open: boolean; onOpenChange: (open: boolean) => void; target: ReportTarget }>;\n\nexport interface MedialaneApp {\n getClient: () => MedialaneClient;\n getSigner: () => Promise<FastMintSigner> | FastMintSigner;\n walletAddress: string | null;\n onRequireWallet: () => void;\n connectLabel?: string;\n connectDescription?: string;\n companion?: CompanionApp;\n ReportDialog?: ReportDialogSlot;\n resolveImage?: ImageResolver;\n}\n\nexport const MedialaneAppContext = createContext<MedialaneApp | null>(null);\n\nexport function MedialaneAppProvider({ value, children }: { value: MedialaneApp; children: ReactNode }) {\n return <MedialaneAppContext.Provider value={value}>{children}</MedialaneAppContext.Provider>;\n}\n\nexport function useMedialaneApp(): MedialaneApp {\n const app = useContext(MedialaneAppContext);\n if (!app) throw new Error(\"MedialaneAppProvider missing\");\n return app;\n}\n"],"mappings":";AAsCS;AApCT,SAAS,eAAe,kBAAwE;AAiCzF,MAAM,sBAAsB,cAAmC,IAAI;AAEnE,SAAS,qBAAqB,EAAE,OAAO,SAAS,GAAiD;AACtG,SAAO,oBAAC,oBAAoB,UAApB,EAA6B,OAAe,UAAS;AAC/D;AAEO,SAAS,kBAAgC;AAC9C,QAAM,MAAM,WAAW,mBAAmB;AAC1C,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,8BAA8B;AACxD,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/components/medialane-app.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext, type ComponentType, type ElementType, type ReactNode } from \"react\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport type { FastMintSigner } from \"./fast-mint/types.js\";\nimport type { ApiToken } from \"@medialane/sdk\";\nimport type { ImageResolver } from \"../utils/ipfs.js\";\n\nexport type AssetRef = Pick<ApiToken, \"chain\" | \"contractAddress\" | \"tokenId\">;\n\nexport interface CompanionApp {\n title: string;\n description: string;\n icon: ElementType;\n origin: string;\n}\n\nexport type ReportTarget =\n | { type: \"TOKEN\"; contract: string; tokenId: string; name?: string }\n | { type: \"COLLECTION\"; contract: string; name?: string };\n\nexport type ReportDialogSlot = ComponentType<{ open: boolean; onOpenChange: (open: boolean) => void; target: ReportTarget }>;\n\nexport interface MedialaneApp {\n getClient: () => MedialaneClient;\n getSigner: () => Promise<FastMintSigner> | FastMintSigner;\n walletAddress: string | null;\n walletLoading?: boolean;\n onRequireWallet: () => void;\n connectLabel?: string;\n connectDescription?: string;\n companion?: CompanionApp;\n ReportDialog?: ReportDialogSlot;\n resolveImage?: ImageResolver;\n}\n\nexport const MedialaneAppContext = createContext<MedialaneApp | null>(null);\n\nexport function MedialaneAppProvider({ value, children }: { value: MedialaneApp; children: ReactNode }) {\n return <MedialaneAppContext.Provider value={value}>{children}</MedialaneAppContext.Provider>;\n}\n\nexport function useMedialaneApp(): MedialaneApp {\n const app = useContext(MedialaneAppContext);\n if (!app) throw new Error(\"MedialaneAppProvider missing\");\n return app;\n}\n"],"mappings":";AAuCS;AArCT,SAAS,eAAe,kBAAwE;AAkCzF,MAAM,sBAAsB,cAAmC,IAAI;AAEnE,SAAS,qBAAqB,EAAE,OAAO,SAAS,GAAiD;AACtG,SAAO,oBAAC,oBAAoB,UAApB,EAA6B,OAAe,UAAS;AAC/D;AAEO,SAAS,kBAAgC;AAC9C,QAAM,MAAM,WAAW,mBAAmB;AAC1C,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,8BAA8B;AACxD,SAAO;AACT;","names":[]}
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var portfolio_assets_exports = {};
21
+ __export(portfolio_assets_exports, {
22
+ PortfolioAssets: () => PortfolioAssets
23
+ });
24
+ module.exports = __toCommonJS(portfolio_assets_exports);
25
+ var import_jsx_runtime = require("react/jsx-runtime");
26
+ var import_react = require("react");
27
+ var import_lucide_react = require("lucide-react");
28
+ var import_empty_or_error = require("./empty-or-error.js");
29
+ var import_load_more_sentinel = require("./load-more-sentinel.js");
30
+ var import_token_card = require("./token-card.js");
31
+ var import_medialane_app = require("./medialane-app.js");
32
+ var import_format = require("../utils/format.js");
33
+ var import_use_usd_prices = require("../utils/use-usd-prices.js");
34
+ var import_use_tokens = require("../utils/use-tokens.js");
35
+ const PAGE_SIZE = 20;
36
+ const GRID = "grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4";
37
+ function usdFor(token, prices) {
38
+ const order = token.activeOrders?.find((o) => o.offer.itemType === "ERC721" || o.offer.itemType === "ERC1155");
39
+ const currency = order?.price.currency;
40
+ const amount = order?.price.formatted ? parseFloat(order.price.formatted) : NaN;
41
+ const rate = currency ? (0, import_use_usd_prices.usdPriceFor)(prices, currency.toUpperCase()) : void 0;
42
+ return rate == null || isNaN(amount) ? null : (0, import_format.formatUsd)(amount * rate);
43
+ }
44
+ function PortfolioAssets({ address, useActions }) {
45
+ const { ReportDialog } = (0, import_medialane_app.useMedialaneApp)();
46
+ const [page, setPage] = (0, import_react.useState)(1);
47
+ const [all, setAll] = (0, import_react.useState)([]);
48
+ const [reportToken, setReportToken] = (0, import_react.useState)(null);
49
+ const { tokens, meta, isLoading, error, mutate } = (0, import_use_tokens.useTokensByOwner)(address, page, PAGE_SIZE);
50
+ const prices = (0, import_use_usd_prices.useUsdPrices)();
51
+ (0, import_react.useEffect)(() => setAll((prev) => page === 1 ? tokens : [...prev, ...tokens]), [tokens, page]);
52
+ (0, import_react.useEffect)(() => {
53
+ setPage(1);
54
+ setAll([]);
55
+ }, [address]);
56
+ const actions = useActions({ refresh: () => {
57
+ setPage(1);
58
+ setAll([]);
59
+ void mutate();
60
+ } });
61
+ const shown = page === 1 ? tokens : all;
62
+ const hasMore = meta ? (meta.total ?? 0) > shown.length : false;
63
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
64
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
65
+ import_empty_or_error.EmptyOrError,
66
+ {
67
+ isLoading: isLoading && page === 1,
68
+ error,
69
+ isEmpty: shown.length === 0 && !isLoading,
70
+ onRetry: () => void mutate(),
71
+ emptyTitle: "No assets yet",
72
+ emptyDescription: "Create your first asset to get started.",
73
+ emptyCta: { label: "Create your first asset", href: "/launchpad/single-editions" },
74
+ emptyIcon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.ImageIcon, { className: "h-7 w-7 text-muted-foreground" }),
75
+ skeletonNode: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: GRID, children: Array.from({ length: 10 }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "animate-pulse overflow-hidden rounded-xl bg-muted", children: [
76
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "aspect-square w-full bg-muted-foreground/10" }),
77
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-2 p-3", children: [
78
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "h-4 w-3/4 rounded bg-muted-foreground/10" }),
79
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "h-3 w-1/2 rounded bg-muted-foreground/10" })
80
+ ] })
81
+ ] }, i)) }),
82
+ children: [
83
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: GRID, children: shown.map((token) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
84
+ import_token_card.TokenCard,
85
+ {
86
+ token,
87
+ isOwner: true,
88
+ usdValue: usdFor(token, prices),
89
+ onList: actions.list,
90
+ onTransfer: actions.transfer,
91
+ onCancel: actions.cancel,
92
+ onReport: ReportDialog ? setReportToken : void 0
93
+ },
94
+ `${token.contractAddress}-${token.tokenId}`
95
+ )) }),
96
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_load_more_sentinel.LoadMoreSentinel, { hasMore, isLoading, onLoadMore: () => setPage((p) => p + 1) })
97
+ ]
98
+ }
99
+ ),
100
+ actions.dialogs,
101
+ ReportDialog && reportToken && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
102
+ ReportDialog,
103
+ {
104
+ open: !!reportToken,
105
+ onOpenChange: (open) => {
106
+ if (!open) setReportToken(null);
107
+ },
108
+ target: { type: "TOKEN", contract: reportToken.contractAddress, tokenId: reportToken.tokenId, name: reportToken.metadata?.name ?? void 0 }
109
+ }
110
+ )
111
+ ] });
112
+ }
113
+ // Annotate the CommonJS export names for ESM import in node:
114
+ 0 && (module.exports = {
115
+ PortfolioAssets
116
+ });
117
+ //# sourceMappingURL=portfolio-assets.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/portfolio-assets.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useState, type ReactNode } from \"react\";\nimport type { ApiToken } from \"@medialane/sdk\";\nimport { ImageIcon } from \"lucide-react\";\nimport { EmptyOrError } from \"./empty-or-error.js\";\nimport { LoadMoreSentinel } from \"./load-more-sentinel.js\";\nimport { TokenCard } from \"./token-card.js\";\nimport { useMedialaneApp } from \"./medialane-app.js\";\nimport { formatUsd } from \"../utils/format.js\";\nimport { usdPriceFor, useUsdPrices } from \"../utils/use-usd-prices.js\";\nimport { useTokensByOwner } from \"../utils/use-tokens.js\";\n\nexport interface PortfolioAssetActions {\n list: (token: ApiToken) => void;\n transfer: (token: ApiToken) => void;\n cancel: (token: ApiToken) => void;\n dialogs?: ReactNode;\n}\n\nexport type UsePortfolioAssetActions = (context: { refresh: () => void }) => PortfolioAssetActions;\n\nconst PAGE_SIZE = 20;\nconst GRID = \"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4\";\n\nfunction usdFor(token: ApiToken, prices: ReturnType<typeof useUsdPrices>): string | null {\n const order = token.activeOrders?.find((o) => o.offer.itemType === \"ERC721\" || o.offer.itemType === \"ERC1155\");\n const currency = order?.price.currency;\n const amount = order?.price.formatted ? parseFloat(order.price.formatted) : NaN;\n const rate = currency ? usdPriceFor(prices, currency.toUpperCase()) : undefined;\n return rate == null || isNaN(amount) ? null : formatUsd(amount * rate);\n}\n\nexport function PortfolioAssets({ address, useActions }: { address: string; useActions: UsePortfolioAssetActions }) {\n const { ReportDialog } = useMedialaneApp();\n const [page, setPage] = useState(1);\n const [all, setAll] = useState<ApiToken[]>([]);\n const [reportToken, setReportToken] = useState<ApiToken | null>(null);\n const { tokens, meta, isLoading, error, mutate } = useTokensByOwner(address, page, PAGE_SIZE);\n const prices = useUsdPrices();\n\n useEffect(() => setAll((prev) => (page === 1 ? tokens : [...prev, ...tokens])), [tokens, page]);\n useEffect(() => { setPage(1); setAll([]); }, [address]);\n\n const actions = useActions({ refresh: () => { setPage(1); setAll([]); void mutate(); } });\n const shown = page === 1 ? tokens : all;\n const hasMore = meta ? (meta.total ?? 0) > shown.length : false;\n\n return (\n <>\n <EmptyOrError\n isLoading={isLoading && page === 1}\n error={error}\n isEmpty={shown.length === 0 && !isLoading}\n onRetry={() => void mutate()}\n emptyTitle=\"No assets yet\"\n emptyDescription=\"Create your first asset to get started.\"\n emptyCta={{ label: \"Create your first asset\", href: \"/launchpad/single-editions\" }}\n emptyIcon={<ImageIcon className=\"h-7 w-7 text-muted-foreground\" />}\n skeletonNode={\n <div className={GRID}>\n {Array.from({ length: 10 }).map((_, i) => (\n <div key={i} className=\"animate-pulse overflow-hidden rounded-xl bg-muted\">\n <div className=\"aspect-square w-full bg-muted-foreground/10\" />\n <div className=\"space-y-2 p-3\">\n <div className=\"h-4 w-3/4 rounded bg-muted-foreground/10\" />\n <div className=\"h-3 w-1/2 rounded bg-muted-foreground/10\" />\n </div>\n </div>\n ))}\n </div>\n }\n >\n <div className={GRID}>\n {shown.map((token) => (\n <TokenCard\n key={`${token.contractAddress}-${token.tokenId}`}\n token={token}\n isOwner\n usdValue={usdFor(token, prices)}\n onList={actions.list}\n onTransfer={actions.transfer}\n onCancel={actions.cancel}\n onReport={ReportDialog ? setReportToken : undefined}\n />\n ))}\n </div>\n <LoadMoreSentinel hasMore={hasMore} isLoading={isLoading} onLoadMore={() => setPage((p) => p + 1)} />\n </EmptyOrError>\n {actions.dialogs}\n {ReportDialog && reportToken && (\n <ReportDialog\n open={!!reportToken}\n onOpenChange={(open) => { if (!open) setReportToken(null); }}\n target={{ type: \"TOKEN\", contract: reportToken.contractAddress, tokenId: reportToken.tokenId, name: reportToken.metadata?.name ?? undefined }}\n />\n )}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiD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MAAC;AAAA;AAAA,QACC,MAAM,CAAC,CAAC;AAAA,QACR,cAAc,CAAC,SAAS;AAAE,cAAI,CAAC,KAAM,gBAAe,IAAI;AAAA,QAAG;AAAA,QAC3D,QAAQ,EAAE,MAAM,SAAS,UAAU,YAAY,iBAAiB,SAAS,YAAY,SAAS,MAAM,YAAY,UAAU,QAAQ,OAAU;AAAA;AAAA,IAC9I;AAAA,KAEJ;AAEJ;","names":[]}
@@ -0,0 +1,19 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+ import { ApiToken } from '@medialane/sdk';
4
+
5
+ interface PortfolioAssetActions {
6
+ list: (token: ApiToken) => void;
7
+ transfer: (token: ApiToken) => void;
8
+ cancel: (token: ApiToken) => void;
9
+ dialogs?: ReactNode;
10
+ }
11
+ type UsePortfolioAssetActions = (context: {
12
+ refresh: () => void;
13
+ }) => PortfolioAssetActions;
14
+ declare function PortfolioAssets({ address, useActions }: {
15
+ address: string;
16
+ useActions: UsePortfolioAssetActions;
17
+ }): react_jsx_runtime.JSX.Element;
18
+
19
+ export { type PortfolioAssetActions, PortfolioAssets, type UsePortfolioAssetActions };
@@ -0,0 +1,19 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+ import { ApiToken } from '@medialane/sdk';
4
+
5
+ interface PortfolioAssetActions {
6
+ list: (token: ApiToken) => void;
7
+ transfer: (token: ApiToken) => void;
8
+ cancel: (token: ApiToken) => void;
9
+ dialogs?: ReactNode;
10
+ }
11
+ type UsePortfolioAssetActions = (context: {
12
+ refresh: () => void;
13
+ }) => PortfolioAssetActions;
14
+ declare function PortfolioAssets({ address, useActions }: {
15
+ address: string;
16
+ useActions: UsePortfolioAssetActions;
17
+ }): react_jsx_runtime.JSX.Element;
18
+
19
+ export { type PortfolioAssetActions, PortfolioAssets, type UsePortfolioAssetActions };
@@ -0,0 +1,93 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useState } from "react";
4
+ import { ImageIcon } from "lucide-react";
5
+ import { EmptyOrError } from "./empty-or-error.js";
6
+ import { LoadMoreSentinel } from "./load-more-sentinel.js";
7
+ import { TokenCard } from "./token-card.js";
8
+ import { useMedialaneApp } from "./medialane-app.js";
9
+ import { formatUsd } from "../utils/format.js";
10
+ import { usdPriceFor, useUsdPrices } from "../utils/use-usd-prices.js";
11
+ import { useTokensByOwner } from "../utils/use-tokens.js";
12
+ const PAGE_SIZE = 20;
13
+ const GRID = "grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4";
14
+ function usdFor(token, prices) {
15
+ const order = token.activeOrders?.find((o) => o.offer.itemType === "ERC721" || o.offer.itemType === "ERC1155");
16
+ const currency = order?.price.currency;
17
+ const amount = order?.price.formatted ? parseFloat(order.price.formatted) : NaN;
18
+ const rate = currency ? usdPriceFor(prices, currency.toUpperCase()) : void 0;
19
+ return rate == null || isNaN(amount) ? null : formatUsd(amount * rate);
20
+ }
21
+ function PortfolioAssets({ address, useActions }) {
22
+ const { ReportDialog } = useMedialaneApp();
23
+ const [page, setPage] = useState(1);
24
+ const [all, setAll] = useState([]);
25
+ const [reportToken, setReportToken] = useState(null);
26
+ const { tokens, meta, isLoading, error, mutate } = useTokensByOwner(address, page, PAGE_SIZE);
27
+ const prices = useUsdPrices();
28
+ useEffect(() => setAll((prev) => page === 1 ? tokens : [...prev, ...tokens]), [tokens, page]);
29
+ useEffect(() => {
30
+ setPage(1);
31
+ setAll([]);
32
+ }, [address]);
33
+ const actions = useActions({ refresh: () => {
34
+ setPage(1);
35
+ setAll([]);
36
+ void mutate();
37
+ } });
38
+ const shown = page === 1 ? tokens : all;
39
+ const hasMore = meta ? (meta.total ?? 0) > shown.length : false;
40
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
41
+ /* @__PURE__ */ jsxs(
42
+ EmptyOrError,
43
+ {
44
+ isLoading: isLoading && page === 1,
45
+ error,
46
+ isEmpty: shown.length === 0 && !isLoading,
47
+ onRetry: () => void mutate(),
48
+ emptyTitle: "No assets yet",
49
+ emptyDescription: "Create your first asset to get started.",
50
+ emptyCta: { label: "Create your first asset", href: "/launchpad/single-editions" },
51
+ emptyIcon: /* @__PURE__ */ jsx(ImageIcon, { className: "h-7 w-7 text-muted-foreground" }),
52
+ skeletonNode: /* @__PURE__ */ jsx("div", { className: GRID, children: Array.from({ length: 10 }).map((_, i) => /* @__PURE__ */ jsxs("div", { className: "animate-pulse overflow-hidden rounded-xl bg-muted", children: [
53
+ /* @__PURE__ */ jsx("div", { className: "aspect-square w-full bg-muted-foreground/10" }),
54
+ /* @__PURE__ */ jsxs("div", { className: "space-y-2 p-3", children: [
55
+ /* @__PURE__ */ jsx("div", { className: "h-4 w-3/4 rounded bg-muted-foreground/10" }),
56
+ /* @__PURE__ */ jsx("div", { className: "h-3 w-1/2 rounded bg-muted-foreground/10" })
57
+ ] })
58
+ ] }, i)) }),
59
+ children: [
60
+ /* @__PURE__ */ jsx("div", { className: GRID, children: shown.map((token) => /* @__PURE__ */ jsx(
61
+ TokenCard,
62
+ {
63
+ token,
64
+ isOwner: true,
65
+ usdValue: usdFor(token, prices),
66
+ onList: actions.list,
67
+ onTransfer: actions.transfer,
68
+ onCancel: actions.cancel,
69
+ onReport: ReportDialog ? setReportToken : void 0
70
+ },
71
+ `${token.contractAddress}-${token.tokenId}`
72
+ )) }),
73
+ /* @__PURE__ */ jsx(LoadMoreSentinel, { hasMore, isLoading, onLoadMore: () => setPage((p) => p + 1) })
74
+ ]
75
+ }
76
+ ),
77
+ actions.dialogs,
78
+ ReportDialog && reportToken && /* @__PURE__ */ jsx(
79
+ ReportDialog,
80
+ {
81
+ open: !!reportToken,
82
+ onOpenChange: (open) => {
83
+ if (!open) setReportToken(null);
84
+ },
85
+ target: { type: "TOKEN", contract: reportToken.contractAddress, tokenId: reportToken.tokenId, name: reportToken.metadata?.name ?? void 0 }
86
+ }
87
+ )
88
+ ] });
89
+ }
90
+ export {
91
+ PortfolioAssets
92
+ };
93
+ //# sourceMappingURL=portfolio-assets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/portfolio-assets.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useState, type ReactNode } from \"react\";\nimport type { ApiToken } from \"@medialane/sdk\";\nimport { ImageIcon } from \"lucide-react\";\nimport { EmptyOrError } from \"./empty-or-error.js\";\nimport { LoadMoreSentinel } from \"./load-more-sentinel.js\";\nimport { TokenCard } from \"./token-card.js\";\nimport { useMedialaneApp } from \"./medialane-app.js\";\nimport { formatUsd } from \"../utils/format.js\";\nimport { usdPriceFor, useUsdPrices } from \"../utils/use-usd-prices.js\";\nimport { useTokensByOwner } from \"../utils/use-tokens.js\";\n\nexport interface PortfolioAssetActions {\n list: (token: ApiToken) => void;\n transfer: (token: ApiToken) => void;\n cancel: (token: ApiToken) => void;\n dialogs?: ReactNode;\n}\n\nexport type UsePortfolioAssetActions = (context: { refresh: () => void }) => PortfolioAssetActions;\n\nconst PAGE_SIZE = 20;\nconst GRID = \"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4\";\n\nfunction usdFor(token: ApiToken, prices: ReturnType<typeof useUsdPrices>): string | null {\n const order = token.activeOrders?.find((o) => o.offer.itemType === \"ERC721\" || o.offer.itemType === \"ERC1155\");\n const currency = order?.price.currency;\n const amount = order?.price.formatted ? parseFloat(order.price.formatted) : NaN;\n const rate = currency ? usdPriceFor(prices, currency.toUpperCase()) : undefined;\n return rate == null || isNaN(amount) ? null : formatUsd(amount * rate);\n}\n\nexport function PortfolioAssets({ address, useActions }: { address: string; useActions: UsePortfolioAssetActions }) {\n const { ReportDialog } = useMedialaneApp();\n const [page, setPage] = useState(1);\n const [all, setAll] = useState<ApiToken[]>([]);\n const [reportToken, setReportToken] = useState<ApiToken | null>(null);\n const { tokens, meta, isLoading, error, mutate } = useTokensByOwner(address, page, PAGE_SIZE);\n const prices = useUsdPrices();\n\n useEffect(() => setAll((prev) => (page === 1 ? tokens : [...prev, ...tokens])), [tokens, page]);\n useEffect(() => { setPage(1); setAll([]); }, [address]);\n\n const actions = useActions({ refresh: () => { setPage(1); setAll([]); void mutate(); } });\n const shown = page === 1 ? tokens : all;\n const hasMore = meta ? (meta.total ?? 0) > shown.length : false;\n\n return (\n <>\n <EmptyOrError\n isLoading={isLoading && page === 1}\n error={error}\n isEmpty={shown.length === 0 && !isLoading}\n onRetry={() => void mutate()}\n emptyTitle=\"No assets yet\"\n emptyDescription=\"Create your first asset to get started.\"\n emptyCta={{ label: \"Create your first asset\", href: \"/launchpad/single-editions\" }}\n emptyIcon={<ImageIcon className=\"h-7 w-7 text-muted-foreground\" />}\n skeletonNode={\n <div className={GRID}>\n {Array.from({ length: 10 }).map((_, i) => (\n <div key={i} className=\"animate-pulse overflow-hidden rounded-xl bg-muted\">\n <div className=\"aspect-square w-full bg-muted-foreground/10\" />\n <div className=\"space-y-2 p-3\">\n <div className=\"h-4 w-3/4 rounded bg-muted-foreground/10\" />\n <div className=\"h-3 w-1/2 rounded bg-muted-foreground/10\" />\n </div>\n </div>\n ))}\n </div>\n }\n >\n <div className={GRID}>\n {shown.map((token) => (\n <TokenCard\n key={`${token.contractAddress}-${token.tokenId}`}\n token={token}\n isOwner\n usdValue={usdFor(token, prices)}\n onList={actions.list}\n onTransfer={actions.transfer}\n onCancel={actions.cancel}\n onReport={ReportDialog ? setReportToken : undefined}\n />\n ))}\n </div>\n <LoadMoreSentinel hasMore={hasMore} isLoading={isLoading} onLoadMore={() => setPage((p) => p + 1)} />\n </EmptyOrError>\n {actions.dialogs}\n {ReportDialog && reportToken && (\n <ReportDialog\n open={!!reportToken}\n onOpenChange={(open) => { if (!open) setReportToken(null); }}\n target={{ type: \"TOKEN\", contract: reportToken.contractAddress, tokenId: reportToken.tokenId, name: reportToken.metadata?.name ?? undefined }}\n />\n )}\n </>\n );\n}\n"],"mappings":";AAiDI,mBASe,KAMH,Y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AAA,IACrG;AAAA,IACC,QAAQ;AAAA,IACR,gBAAgB,eACf;AAAA,MAAC;AAAA;AAAA,QACC,MAAM,CAAC,CAAC;AAAA,QACR,cAAc,CAAC,SAAS;AAAE,cAAI,CAAC,KAAM,gBAAe,IAAI;AAAA,QAAG;AAAA,QAC3D,QAAQ,EAAE,MAAM,SAAS,UAAU,YAAY,iBAAiB,SAAS,YAAY,SAAS,MAAM,YAAY,UAAU,QAAQ,OAAU;AAAA;AAAA,IAC9I;AAAA,KAEJ;AAEJ;","names":[]}
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var portfolio_orders_exports = {};
31
+ __export(portfolio_orders_exports, {
32
+ PortfolioOrders: () => PortfolioOrders
33
+ });
34
+ module.exports = __toCommonJS(portfolio_orders_exports);
35
+ var import_jsx_runtime = require("react/jsx-runtime");
36
+ var import_sdk = require("@medialane/sdk");
37
+ var import_lucide_react = require("lucide-react");
38
+ var import_image = __toESM(require("./image.js"), 1);
39
+ var import_link = __toESM(require("./link.js"), 1);
40
+ var import_badge = require("./badge.js");
41
+ var import_button = require("./button.js");
42
+ var import_empty_or_error = require("./empty-or-error.js");
43
+ var import_cn = require("../utils/cn.js");
44
+ var import_explorer_url = require("../utils/explorer-url.js");
45
+ var import_format = require("../utils/format.js");
46
+ var import_time = require("../utils/time.js");
47
+ var import_same_address = require("../utils/same-address.js");
48
+ var import_seen_offers = require("../utils/seen-offers.js");
49
+ var import_use_image_url = require("../utils/use-image-url.js");
50
+ var import_use_orders = require("../utils/use-orders.js");
51
+ const VIEWS = {
52
+ listings: {
53
+ emptyTitle: "No active listings",
54
+ emptyDescription: "List an asset to start selling.",
55
+ emptyCta: { label: "Browse assets", href: "/portfolio/assets" },
56
+ emptyIcon: import_lucide_react.Tag,
57
+ priceLabel: "Price",
58
+ count: (n) => `${n} active listing${n === 1 ? "" : "s"}`
59
+ },
60
+ offers: {
61
+ emptyTitle: "No offers sent yet",
62
+ emptyDescription: "Browse the marketplace to make offers on assets.",
63
+ emptyCta: { label: "Browse marketplace", href: "/marketplace" },
64
+ emptyIcon: import_lucide_react.HandCoins,
65
+ priceLabel: "Offer price",
66
+ count: (n) => `${n} active offer${n === 1 ? "" : "s"}`
67
+ },
68
+ received: {
69
+ emptyTitle: "No offers received yet",
70
+ emptyDescription: "When someone makes an offer on your asset, it will appear here.",
71
+ emptyCta: void 0,
72
+ emptyIcon: import_lucide_react.Inbox,
73
+ priceLabel: "Offer price",
74
+ count: null
75
+ },
76
+ "counter-offers": {
77
+ emptyTitle: "No counter-offers yet",
78
+ emptyDescription: "When a seller responds to your bid with a counter-offer, it will appear here.",
79
+ emptyCta: void 0,
80
+ emptyIcon: import_lucide_react.Inbox,
81
+ priceLabel: "Their price / Your bid",
82
+ count: null
83
+ }
84
+ };
85
+ const isNft = (o) => o.offer.itemType === "ERC721" || o.offer.itemType === "ERC1155";
86
+ function expiryOf(order) {
87
+ const expired = (0, import_time.isExpired)(order.endTime);
88
+ const urgent = !expired && Number(order.endTime) * 1e3 - Date.now() < 864e5;
89
+ return { label: (0, import_time.timeUntil)(order.endTime), expired, urgent };
90
+ }
91
+ function price(o) {
92
+ return `${(0, import_format.formatDisplayPrice)(o.price.formatted)} ${o.price.currency ?? ""}`.trim();
93
+ }
94
+ function OrderRow({ order, subtitle, from, priceCell, actions, isNew }) {
95
+ const resolveImage = (0, import_use_image_url.useImageUrl)();
96
+ const name = order.token?.name || `#${order.nftTokenId}`;
97
+ const image = resolveImage(order.token?.image, { width: 96 });
98
+ const expiry = expiryOf(order);
99
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { "data-new": isNew ? "true" : void 0, className: (0, import_cn.cn)("flex items-center gap-4 px-4 py-3 transition-colors hover:bg-muted/40", isNew && "border-l-2 border-primary"), children: [
100
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "relative h-12 w-12 shrink-0 overflow-hidden rounded-lg border border-border bg-muted", children: image && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_image.default, { src: image, alt: name, fill: true, sizes: "48px", unoptimized: true, className: "object-cover" }) }),
101
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "min-w-0 flex-1", children: [
102
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_link.default, { href: (0, import_sdk.assetHref)("STARKNET", order.nftContract, order.nftTokenId), className: "block truncate text-sm font-medium transition-colors hover:text-primary", children: name }),
103
+ subtitle
104
+ ] }),
105
+ from && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "hidden shrink-0 sm:block", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_link.default, { href: (0, import_sdk.profileHref)({ address: from }), className: "text-xs tabular-nums text-muted-foreground transition-colors hover:text-foreground", children: [
106
+ from.slice(0, 6),
107
+ "\u2026",
108
+ from.slice(-4)
109
+ ] }) }),
110
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "hidden shrink-0 text-right sm:block", children: priceCell }),
111
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "hidden shrink-0 md:block", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: (0, import_cn.cn)("text-sm", expiry.expired && "text-muted-foreground", expiry.urgent && "font-medium text-destructive"), children: expiry.label }) }),
112
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex shrink-0 items-center gap-2", children: [
113
+ order.txHash?.created && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: `${import_explorer_url.EXPLORER_URL}/tx/${order.txHash.created}`, target: "_blank", rel: "noopener noreferrer", "aria-label": "View on explorer", className: "inline-flex h-7 w-7 items-center justify-center rounded-md transition-colors hover:bg-muted", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.ExternalLink, { className: "h-3.5 w-3.5 text-muted-foreground" }) }),
114
+ actions
115
+ ] })
116
+ ] });
117
+ }
118
+ function PriceText({ order }) {
119
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "text-sm font-semibold", children: [
120
+ (0, import_format.formatDisplayPrice)(order.price.formatted),
121
+ " ",
122
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-xs font-normal text-muted-foreground", children: order.price.currency })
123
+ ] });
124
+ }
125
+ function CounterOfferRow({ bid, actions }) {
126
+ const { counterOffers } = (0, import_use_orders.useCounterOffers)({ originalOrderHash: bid.orderHash });
127
+ const counter = counterOffers[0];
128
+ if (!counter) return null;
129
+ const closed = counter.status !== "ACTIVE" || (0, import_time.isExpired)(counter.endTime);
130
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
131
+ OrderRow,
132
+ {
133
+ order: counter,
134
+ subtitle: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_badge.Badge, { variant: "secondary", className: "mt-0.5 h-4 px-1.5 text-[10px]", children: [
135
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.ArrowLeftRight, { className: "mr-1 h-2.5 w-2.5" }),
136
+ "Counter-offer"
137
+ ] }),
138
+ priceCell: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col items-end gap-0.5", children: [
139
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs text-muted-foreground line-through", children: price(bid) }),
140
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm font-semibold", children: counter.price.formatted ? price(counter) : "\u2014" })
141
+ ] }),
142
+ actions: closed ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-xs text-muted-foreground", children: counter.status !== "ACTIVE" ? counter.status.toLowerCase() : "Expired" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { size: "sm", className: "h-8 text-xs", disabled: actions.isProcessing, onClick: () => actions.accept?.(counter, bid), children: "Accept" })
143
+ }
144
+ );
145
+ }
146
+ function PortfolioOrders({ view, address, useActions }) {
147
+ const mine = (0, import_use_orders.useUserOrders)(view === "received" ? null : address);
148
+ const received = (0, import_use_orders.useReceivedOffers)(view === "received" ? address : null);
149
+ const source = view === "received" ? received : mine;
150
+ const actions = useActions({ view, refresh: () => void source.mutate() });
151
+ const config = VIEWS[view];
152
+ const orders = view === "listings" ? mine.orders.filter((o) => isNft(o) && o.status === "ACTIVE") : view === "offers" ? mine.orders.filter((o) => o.offer.itemType === "ERC20" && o.status === "ACTIVE") : view === "counter-offers" ? mine.orders.filter((o) => o.offer.itemType === "ERC20" && (0, import_same_address.isSameAddress)(o.offerer, address) && o.hasActiveCounterOffer === true) : received.orders;
153
+ const seen = view === "received" ? (0, import_seen_offers.getSeenOffers)() : null;
154
+ const EmptyIcon = config.emptyIcon;
155
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
156
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
157
+ import_empty_or_error.EmptyOrError,
158
+ {
159
+ isLoading: source.isLoading,
160
+ error: source.error,
161
+ isEmpty: orders.length === 0,
162
+ onRetry: () => void source.mutate(),
163
+ emptyTitle: config.emptyTitle,
164
+ emptyDescription: config.emptyDescription,
165
+ emptyCta: config.emptyCta,
166
+ emptyIcon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmptyIcon, { className: "h-7 w-7 text-muted-foreground" }),
167
+ skeletonCount: 3,
168
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-1", children: [
169
+ config.count && orders.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "pb-2 text-sm text-muted-foreground", children: config.count(orders.length) }),
170
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "overflow-hidden rounded-lg border border-border", children: [
171
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-4 border-b border-border bg-muted/30 px-4 py-2 text-xs uppercase tracking-wide text-muted-foreground", children: [
172
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "w-12 shrink-0" }),
173
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex-1", children: "Asset" }),
174
+ view === "received" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "hidden w-28 sm:block", children: "From" }),
175
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_cn.cn)("hidden text-right sm:block", view === "counter-offers" ? "w-40" : "w-24"), children: config.priceLabel }),
176
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "hidden w-28 md:block", children: "Expires" }),
177
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "w-24 text-right", children: "Actions" })
178
+ ] }),
179
+ view === "counter-offers" ? orders.map((bid) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CounterOfferRow, { bid, actions }, bid.orderHash)) : orders.map((order) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
180
+ OrderRow,
181
+ {
182
+ order,
183
+ isNew: seen ? !seen.has(order.orderHash) : false,
184
+ from: view === "received" ? order.offerer : void 0,
185
+ subtitle: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-xs text-muted-foreground", children: view === "received" ? "Received offer" : view === "offers" ? "Offer" : "Active" }),
186
+ priceCell: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PriceText, { order }),
187
+ actions: view === "received" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
188
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { size: "sm", variant: "outline", className: "h-8 text-xs", disabled: actions.isProcessing, onClick: () => actions.counter?.(order), children: "Counter" }),
189
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { size: "sm", className: "h-8 text-xs", disabled: actions.isProcessing, onClick: () => actions.accept?.(order), children: "Accept" })
190
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { size: "sm", variant: "outline", className: "h-8 text-xs text-destructive hover:text-destructive", disabled: actions.isProcessing, onClick: () => actions.cancel?.(order), children: "Cancel" })
191
+ },
192
+ order.orderHash
193
+ ))
194
+ ] })
195
+ ] })
196
+ }
197
+ ),
198
+ actions.dialogs
199
+ ] });
200
+ }
201
+ // Annotate the CommonJS export names for ESM import in node:
202
+ 0 && (module.exports = {
203
+ PortfolioOrders
204
+ });
205
+ //# sourceMappingURL=portfolio-orders.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/portfolio-orders.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ReactNode } from \"react\";\nimport { assetHref, profileHref, type ApiOrder } from \"@medialane/sdk\";\nimport { ArrowLeftRight, ExternalLink, HandCoins, Inbox, Tag } from \"lucide-react\";\nimport Image from \"./image.js\";\nimport Link from \"./link.js\";\nimport { Badge } from \"./badge.js\";\nimport { Button } from \"./button.js\";\nimport { EmptyOrError } from \"./empty-or-error.js\";\nimport { cn } from \"../utils/cn.js\";\nimport { EXPLORER_URL } from \"../utils/explorer-url.js\";\nimport { formatDisplayPrice } from \"../utils/format.js\";\nimport { isExpired, timeUntil } from \"../utils/time.js\";\nimport { isSameAddress } from \"../utils/same-address.js\";\nimport { getSeenOffers } from \"../utils/seen-offers.js\";\nimport { useImageUrl } from \"../utils/use-image-url.js\";\nimport { useCounterOffers, useReceivedOffers, useUserOrders } from \"../utils/use-orders.js\";\n\nexport type PortfolioOrdersView = \"listings\" | \"offers\" | \"received\" | \"counter-offers\";\n\nexport interface PortfolioOrderActions {\n isProcessing: boolean;\n cancel?: (order: ApiOrder) => void;\n accept?: (order: ApiOrder, original?: ApiOrder) => void;\n counter?: (order: ApiOrder) => void;\n dialogs?: ReactNode;\n}\n\nexport type UsePortfolioOrderActions = (context: { view: PortfolioOrdersView; refresh: () => void }) => PortfolioOrderActions;\n\nconst VIEWS = {\n listings: {\n emptyTitle: \"No active listings\",\n emptyDescription: \"List an asset to start selling.\",\n emptyCta: { label: \"Browse assets\", href: \"/portfolio/assets\" },\n emptyIcon: Tag,\n priceLabel: \"Price\",\n count: (n: number) => `${n} active listing${n === 1 ? \"\" : \"s\"}`,\n },\n offers: {\n emptyTitle: \"No offers sent yet\",\n emptyDescription: \"Browse the marketplace to make offers on assets.\",\n emptyCta: { label: \"Browse marketplace\", href: \"/marketplace\" },\n emptyIcon: HandCoins,\n priceLabel: \"Offer price\",\n count: (n: number) => `${n} active offer${n === 1 ? \"\" : \"s\"}`,\n },\n received: {\n emptyTitle: \"No offers received yet\",\n emptyDescription: \"When someone makes an offer on your asset, it will appear here.\",\n emptyCta: undefined,\n emptyIcon: Inbox,\n priceLabel: \"Offer price\",\n count: null,\n },\n \"counter-offers\": {\n emptyTitle: \"No counter-offers yet\",\n emptyDescription: \"When a seller responds to your bid with a counter-offer, it will appear here.\",\n emptyCta: undefined,\n emptyIcon: Inbox,\n priceLabel: \"Their price / Your bid\",\n count: null,\n },\n} as const;\n\nconst isNft = (o: ApiOrder) => o.offer.itemType === \"ERC721\" || o.offer.itemType === \"ERC1155\";\n\nfunction expiryOf(order: ApiOrder) {\n const expired = isExpired(order.endTime);\n const urgent = !expired && Number(order.endTime) * 1000 - Date.now() < 86400000;\n return { label: timeUntil(order.endTime), expired, urgent };\n}\n\nfunction price(o: ApiOrder) {\n return `${formatDisplayPrice(o.price.formatted)} ${o.price.currency ?? \"\"}`.trim();\n}\n\nfunction OrderRow({ order, subtitle, from, priceCell, actions, isNew }: {\n order: ApiOrder;\n subtitle: ReactNode;\n from?: string;\n priceCell: ReactNode;\n actions: ReactNode;\n isNew?: boolean;\n}) {\n const resolveImage = useImageUrl();\n const name = order.token?.name || `#${order.nftTokenId}`;\n const image = resolveImage(order.token?.image, { width: 96 });\n const expiry = expiryOf(order);\n return (\n <div data-new={isNew ? \"true\" : undefined} className={cn(\"flex items-center gap-4 px-4 py-3 transition-colors hover:bg-muted/40\", isNew && \"border-l-2 border-primary\")}>\n <div className=\"relative h-12 w-12 shrink-0 overflow-hidden rounded-lg border border-border bg-muted\">\n {image && <Image src={image} alt={name} fill sizes=\"48px\" unoptimized className=\"object-cover\" />}\n </div>\n <div className=\"min-w-0 flex-1\">\n <Link href={assetHref(\"STARKNET\", order.nftContract, order.nftTokenId)} className=\"block truncate text-sm font-medium transition-colors hover:text-primary\">\n {name}\n </Link>\n {subtitle}\n </div>\n {from && (\n <div className=\"hidden shrink-0 sm:block\">\n <Link href={profileHref({ address: from })} className=\"text-xs tabular-nums text-muted-foreground transition-colors hover:text-foreground\">\n {from.slice(0, 6)}…{from.slice(-4)}\n </Link>\n </div>\n )}\n <div className=\"hidden shrink-0 text-right sm:block\">{priceCell}</div>\n <div className=\"hidden shrink-0 md:block\">\n <p className={cn(\"text-sm\", expiry.expired && \"text-muted-foreground\", expiry.urgent && \"font-medium text-destructive\")}>{expiry.label}</p>\n </div>\n <div className=\"flex shrink-0 items-center gap-2\">\n {order.txHash?.created && (\n <a href={`${EXPLORER_URL}/tx/${order.txHash.created}`} target=\"_blank\" rel=\"noopener noreferrer\" aria-label=\"View on explorer\" className=\"inline-flex h-7 w-7 items-center justify-center rounded-md transition-colors hover:bg-muted\">\n <ExternalLink className=\"h-3.5 w-3.5 text-muted-foreground\" />\n </a>\n )}\n {actions}\n </div>\n </div>\n );\n}\n\nfunction PriceText({ order }: { order: ApiOrder }) {\n return (\n <p className=\"text-sm font-semibold\">\n {formatDisplayPrice(order.price.formatted)} <span className=\"text-xs font-normal text-muted-foreground\">{order.price.currency}</span>\n </p>\n );\n}\n\nfunction CounterOfferRow({ bid, actions }: { bid: ApiOrder; actions: PortfolioOrderActions }) {\n const { counterOffers } = useCounterOffers({ originalOrderHash: bid.orderHash });\n const counter = counterOffers[0];\n if (!counter) return null;\n const closed = counter.status !== \"ACTIVE\" || isExpired(counter.endTime);\n return (\n <OrderRow\n order={counter}\n subtitle={\n <Badge variant=\"secondary\" className=\"mt-0.5 h-4 px-1.5 text-[10px]\">\n <ArrowLeftRight className=\"mr-1 h-2.5 w-2.5\" />\n Counter-offer\n </Badge>\n }\n priceCell={\n <div className=\"flex flex-col items-end gap-0.5\">\n <p className=\"text-xs text-muted-foreground line-through\">{price(bid)}</p>\n <p className=\"text-sm font-semibold\">{counter.price.formatted ? price(counter) : \"—\"}</p>\n </div>\n }\n actions={\n closed ? (\n <span className=\"text-xs text-muted-foreground\">{counter.status !== \"ACTIVE\" ? counter.status.toLowerCase() : \"Expired\"}</span>\n ) : (\n <Button size=\"sm\" className=\"h-8 text-xs\" disabled={actions.isProcessing} onClick={() => actions.accept?.(counter, bid)}>\n Accept\n </Button>\n )\n }\n />\n );\n}\n\nexport function PortfolioOrders({ view, address, useActions }: {\n view: PortfolioOrdersView;\n address: string;\n useActions: UsePortfolioOrderActions;\n}) {\n const mine = useUserOrders(view === \"received\" ? null : address);\n const received = useReceivedOffers(view === \"received\" ? address : null);\n const source = view === \"received\" ? received : mine;\n const actions = useActions({ view, refresh: () => void source.mutate() });\n const config = VIEWS[view];\n\n const orders =\n view === \"listings\" ? mine.orders.filter((o) => isNft(o) && o.status === \"ACTIVE\")\n : view === \"offers\" ? mine.orders.filter((o) => o.offer.itemType === \"ERC20\" && o.status === \"ACTIVE\")\n : view === \"counter-offers\" ? mine.orders.filter((o) => o.offer.itemType === \"ERC20\" && isSameAddress(o.offerer, address) && o.hasActiveCounterOffer === true)\n : received.orders;\n\n const seen = view === \"received\" ? getSeenOffers() : null;\n const EmptyIcon = config.emptyIcon;\n\n return (\n <>\n <EmptyOrError\n isLoading={source.isLoading}\n error={source.error}\n isEmpty={orders.length === 0}\n onRetry={() => void source.mutate()}\n emptyTitle={config.emptyTitle}\n emptyDescription={config.emptyDescription}\n emptyCta={config.emptyCta}\n emptyIcon={<EmptyIcon className=\"h-7 w-7 text-muted-foreground\" />}\n skeletonCount={3}\n >\n <div className=\"space-y-1\">\n {config.count && orders.length > 0 && <p className=\"pb-2 text-sm text-muted-foreground\">{config.count(orders.length)}</p>}\n <div className=\"overflow-hidden rounded-lg border border-border\">\n <div className=\"flex items-center gap-4 border-b border-border bg-muted/30 px-4 py-2 text-xs uppercase tracking-wide text-muted-foreground\">\n <div className=\"w-12 shrink-0\" />\n <div className=\"flex-1\">Asset</div>\n {view === \"received\" && <div className=\"hidden w-28 sm:block\">From</div>}\n <div className={cn(\"hidden text-right sm:block\", view === \"counter-offers\" ? \"w-40\" : \"w-24\")}>{config.priceLabel}</div>\n <div className=\"hidden w-28 md:block\">Expires</div>\n <div className=\"w-24 text-right\">Actions</div>\n </div>\n {view === \"counter-offers\"\n ? orders.map((bid) => <CounterOfferRow key={bid.orderHash} bid={bid} actions={actions} />)\n : orders.map((order) => (\n <OrderRow\n key={order.orderHash}\n order={order}\n isNew={seen ? !seen.has(order.orderHash) : false}\n from={view === \"received\" ? order.offerer : undefined}\n subtitle={<span className=\"text-xs text-muted-foreground\">{view === \"received\" ? \"Received offer\" : view === \"offers\" ? \"Offer\" : \"Active\"}</span>}\n priceCell={<PriceText order={order} />}\n actions={\n view === \"received\" ? (\n <>\n <Button size=\"sm\" variant=\"outline\" className=\"h-8 text-xs\" disabled={actions.isProcessing} onClick={() => actions.counter?.(order)}>Counter</Button>\n <Button size=\"sm\" className=\"h-8 text-xs\" disabled={actions.isProcessing} onClick={() => actions.accept?.(order)}>Accept</Button>\n </>\n ) : (\n <Button size=\"sm\" variant=\"outline\" className=\"h-8 text-xs text-destructive hover:text-destructive\" disabled={actions.isProcessing} onClick={() => actions.cancel?.(order)}>Cancel</Button>\n )\n }\n />\n ))}\n </div>\n </div>\n </EmptyOrError>\n {actions.dialogs}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6FkB;AA1FlB,iBAAsD;AACtD,0BAAoE;AACpE,mBAAkB;AAClB,kBAAiB;AACjB,mBAAsB;AACtB,oBAAuB;AACvB,4BAA6B;AAC7B,gBAAmB;AACnB,0BAA6B;AAC7B,oBAAmC;AACnC,kBAAqC;AACrC,0BAA8B;AAC9B,yBAA8B;AAC9B,2BAA4B;AAC5B,wBAAmE;AAcnE,MAAM,QAAQ;AAAA,EACZ,UAAU;AAAA,IACR,YAAY;AAAA,IACZ,kBAAkB;AAAA,IAClB,UAAU,EAAE,OAAO,iBAAiB,MAAM,oBAAoB;AAAA,IAC9D,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,OAAO,CAAC,MAAc,GAAG,CAAC,kBAAkB,MAAM,IAAI,KAAK,GAAG;AAAA,EAChE;AAAA,EACA,QAAQ;AAAA,IACN,YAAY;AAAA,IACZ,kBAAkB;AAAA,IAClB,UAAU,EAAE,OAAO,sBAAsB,MAAM,eAAe;A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