@medialane/ui 0.246.0 → 0.247.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.
- package/dist/components/asset-comments-dialog.cjs +2 -2
- package/dist/components/asset-comments-dialog.cjs.map +1 -1
- package/dist/components/asset-comments-dialog.d.cts +3 -9
- package/dist/components/asset-comments-dialog.d.ts +3 -9
- package/dist/components/asset-comments-dialog.js +2 -2
- package/dist/components/asset-comments-dialog.js.map +1 -1
- package/dist/components/asset-page.cjs +6 -7
- package/dist/components/asset-page.cjs.map +1 -1
- package/dist/components/asset-page.d.cts +4 -13
- package/dist/components/asset-page.d.ts +4 -13
- package/dist/components/asset-page.js +6 -7
- package/dist/components/asset-page.js.map +1 -1
- package/dist/components/collection-page.cjs +3 -2
- package/dist/components/collection-page.cjs.map +1 -1
- package/dist/components/collection-page.d.cts +0 -5
- package/dist/components/collection-page.d.ts +0 -5
- package/dist/components/collection-page.js +3 -2
- package/dist/components/collection-page.js.map +1 -1
- package/dist/components/comments-section.cjs +304 -0
- package/dist/components/comments-section.cjs.map +1 -0
- package/dist/components/comments-section.d.cts +10 -0
- package/dist/components/comments-section.d.ts +10 -0
- package/dist/components/comments-section.js +270 -0
- package/dist/components/comments-section.js.map +1 -0
- package/dist/components/medialane-app.cjs.map +1 -1
- package/dist/components/medialane-app.d.cts +3 -0
- package/dist/components/medialane-app.d.ts +3 -0
- package/dist/components/medialane-app.js.map +1 -1
- package/dist/components/pop-manage-page.cjs +224 -0
- package/dist/components/pop-manage-page.cjs.map +1 -0
- package/dist/components/pop-manage-page.d.cts +7 -0
- package/dist/components/pop-manage-page.d.ts +7 -0
- package/dist/components/pop-manage-page.js +190 -0
- package/dist/components/pop-manage-page.js.map +1 -0
- package/dist/components/portfolio-sponsorships.cjs +1 -1
- package/dist/components/portfolio-sponsorships.cjs.map +1 -1
- package/dist/components/portfolio-sponsorships.js +1 -1
- package/dist/components/portfolio-sponsorships.js.map +1 -1
- package/dist/components/transfer-collection-ownership.cjs +137 -0
- package/dist/components/transfer-collection-ownership.cjs.map +1 -0
- package/dist/components/transfer-collection-ownership.d.cts +11 -0
- package/dist/components/transfer-collection-ownership.d.ts +11 -0
- package/dist/components/transfer-collection-ownership.js +113 -0
- package/dist/components/transfer-collection-ownership.js.map +1 -0
- package/dist/index.cjs +9 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/use-transaction.cjs +2 -0
- package/dist/utils/use-transaction.cjs.map +1 -1
- package/dist/utils/use-transaction.d.cts +1 -1
- package/dist/utils/use-transaction.d.ts +1 -1
- package/dist/utils/use-transaction.js +2 -0
- package/dist/utils/use-transaction.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,304 @@
|
|
|
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 comments_section_exports = {};
|
|
31
|
+
__export(comments_section_exports, {
|
|
32
|
+
CommentsSection: () => CommentsSection
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(comments_section_exports);
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var import_react = require("react");
|
|
37
|
+
var import_lucide_react = require("lucide-react");
|
|
38
|
+
var import_sdk = require("@medialane/sdk");
|
|
39
|
+
var import_address_display = require("./address-display.js");
|
|
40
|
+
var import_button = require("./button.js");
|
|
41
|
+
var import_link = __toESM(require("./link.js"), 1);
|
|
42
|
+
var import_medialane_app = require("./medialane-app.js");
|
|
43
|
+
var import_reward_earned = require("./rewards/reward-earned.js");
|
|
44
|
+
var import_skeleton = require("./skeleton.js");
|
|
45
|
+
var import_textarea = require("./textarea.js");
|
|
46
|
+
var import_transaction_dialog = require("./transaction-dialog.js");
|
|
47
|
+
var import_transaction_done = require("./transaction-done.js");
|
|
48
|
+
var import_cn = require("../utils/cn.js");
|
|
49
|
+
var import_explorer_url = require("../utils/explorer-url.js");
|
|
50
|
+
var import_run_intent_calls = require("../utils/run-intent-calls.js");
|
|
51
|
+
var import_time = require("../utils/time.js");
|
|
52
|
+
var import_use_comments = require("../utils/use-comments.js");
|
|
53
|
+
var import_use_transaction = require("../utils/use-transaction.js");
|
|
54
|
+
const MAX_LEN = 1e3;
|
|
55
|
+
function CommentsSection({ contract, tokenId, className }) {
|
|
56
|
+
const app = (0, import_medialane_app.useMedialaneApp)();
|
|
57
|
+
const walletAddress = app.walletAddress;
|
|
58
|
+
const hasWallet = !!walletAddress;
|
|
59
|
+
const { ReportDialog } = app;
|
|
60
|
+
const { comments, isLoading, mutate } = (0, import_use_comments.useComments)(contract, tokenId);
|
|
61
|
+
const tx = (0, import_use_transaction.useTransaction)();
|
|
62
|
+
const [text, setText] = (0, import_react.useState)("");
|
|
63
|
+
const [reportTarget, setReportTarget] = (0, import_react.useState)(null);
|
|
64
|
+
const messagesRef = (0, import_react.useRef)(null);
|
|
65
|
+
const bottomRef = (0, import_react.useRef)(null);
|
|
66
|
+
const composeRef = (0, import_react.useRef)(null);
|
|
67
|
+
const byteLen = new TextEncoder().encode(text).length;
|
|
68
|
+
const canSubmit = text.trim().length > 0 && byteLen <= MAX_LEN && !!import_sdk.STARKNET_NFTCOMMENTS_CONTRACT;
|
|
69
|
+
const isProcessing = tx.phase === "preparing" || tx.phase === "submitting" || tx.phase === "confirming";
|
|
70
|
+
const isOwn = (author) => !!walletAddress && (0, import_sdk.normalizeAddress)("STARKNET", author) === (0, import_sdk.normalizeAddress)("STARKNET", walletAddress);
|
|
71
|
+
const isNearBottom = () => {
|
|
72
|
+
const el = messagesRef.current;
|
|
73
|
+
if (!el) return true;
|
|
74
|
+
return el.scrollHeight - el.scrollTop - el.clientHeight < 100;
|
|
75
|
+
};
|
|
76
|
+
(0, import_react.useEffect)(() => {
|
|
77
|
+
if (isNearBottom()) {
|
|
78
|
+
bottomRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
79
|
+
}
|
|
80
|
+
}, [comments.length]);
|
|
81
|
+
const handleTextInput = (e) => {
|
|
82
|
+
setText(e.target.value);
|
|
83
|
+
e.target.style.height = "auto";
|
|
84
|
+
e.target.style.height = Math.min(e.target.scrollHeight, 96) + "px";
|
|
85
|
+
};
|
|
86
|
+
const handleKeyDown = (e) => {
|
|
87
|
+
if (e.key === "Enter" && !e.shiftKey && canSubmit && !isProcessing) {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
post();
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const post = () => {
|
|
93
|
+
const body = text.trim();
|
|
94
|
+
void tx.run(async (signer) => {
|
|
95
|
+
await (0, import_run_intent_calls.runIntentCalls)(
|
|
96
|
+
signer,
|
|
97
|
+
() => app.getClient().api.intents.create("comment", { author: signer.address, nftContract: contract, tokenId, text: body })
|
|
98
|
+
);
|
|
99
|
+
}).then((ok) => {
|
|
100
|
+
if (!ok) return;
|
|
101
|
+
setText("");
|
|
102
|
+
if (composeRef.current) composeRef.current.style.height = "auto";
|
|
103
|
+
void mutate();
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
const handleStartConversation = () => {
|
|
107
|
+
if (hasWallet) composeRef.current?.focus();
|
|
108
|
+
};
|
|
109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_cn.cn)("flex flex-col h-[480px] overflow-hidden", className), children: [
|
|
110
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: messagesRef, className: "flex-1 overflow-y-auto px-4 py-4", children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "space-y-4", children: [
|
|
111
|
+
{ own: false, w: "w-40" },
|
|
112
|
+
{ own: true, w: "w-56" },
|
|
113
|
+
{ own: false, w: "w-48" },
|
|
114
|
+
{ own: true, w: "w-32" }
|
|
115
|
+
].map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: `flex ${item.own ? "justify-end" : "justify-start"} gap-2`, children: [
|
|
116
|
+
!item.own && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_skeleton.Skeleton, { className: "h-8 w-8 rounded-full shrink-0" }),
|
|
117
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
118
|
+
import_skeleton.Skeleton,
|
|
119
|
+
{
|
|
120
|
+
className: `h-10 ${item.w} rounded-2xl ${item.own ? "rounded-tr-sm" : "rounded-tl-sm"}`
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
] }, i)) }) : comments.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col items-center justify-center h-full gap-4 text-center px-4", children: [
|
|
124
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex h-16 w-16 items-center justify-center rounded-full", style: { background: "linear-gradient(135deg, hsl(var(--brand-blue) / 0.15), hsl(var(--brand-purple) / 0.15))" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.MessageCircle, { className: "h-7 w-7", style: { color: "hsl(var(--brand-blue))" } }) }),
|
|
125
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
126
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm font-semibold", children: "Nothing here yet" }),
|
|
127
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs text-muted-foreground mt-1 leading-relaxed max-w-[220px]", children: "Your comment will be minted onchain \u2014 attached to this NFT forever." })
|
|
128
|
+
] }),
|
|
129
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
130
|
+
import_button.Button,
|
|
131
|
+
{
|
|
132
|
+
size: "sm",
|
|
133
|
+
onClick: handleStartConversation,
|
|
134
|
+
className: "rounded-full text-white px-5",
|
|
135
|
+
style: { background: "linear-gradient(135deg, hsl(var(--brand-blue)), hsl(var(--brand-purple)))" },
|
|
136
|
+
children: "Write the first comment"
|
|
137
|
+
}
|
|
138
|
+
)
|
|
139
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-5", children: [
|
|
140
|
+
comments.map((comment) => {
|
|
141
|
+
const own = isOwn(comment.author);
|
|
142
|
+
const avatarSeed = parseInt(comment.author.slice(2, 8), 16) % 360;
|
|
143
|
+
const avatarBg = own ? "linear-gradient(135deg, hsl(var(--brand-blue)), hsl(var(--brand-purple)))" : `linear-gradient(135deg, hsl(${avatarSeed}, 65%, 45%), hsl(${(avatarSeed + 60) % 360}, 65%, 55%))`;
|
|
144
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
145
|
+
"div",
|
|
146
|
+
{
|
|
147
|
+
className: `group flex gap-2.5 ${own ? "flex-row-reverse" : "flex-row"}`,
|
|
148
|
+
children: [
|
|
149
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_link.default, { href: (0, import_sdk.profileHref)({ address: comment.author }), className: "shrink-0 mt-0.5", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
150
|
+
"div",
|
|
151
|
+
{
|
|
152
|
+
className: "h-9 w-9 rounded-full flex items-center justify-center text-2xs font-bold text-white select-none ring-2 ring-background hover:ring-primary/40 transition-all",
|
|
153
|
+
style: { background: avatarBg },
|
|
154
|
+
children: comment.author.slice(2, 5).toUpperCase()
|
|
155
|
+
}
|
|
156
|
+
) }),
|
|
157
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: `flex flex-col max-w-[75%] gap-1 ${own ? "items-end" : "items-start"}`, children: [
|
|
158
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: `flex items-center gap-2 px-1 ${own ? "flex-row-reverse" : "flex-row"}`, children: [
|
|
159
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
160
|
+
import_link.default,
|
|
161
|
+
{
|
|
162
|
+
href: (0, import_sdk.profileHref)({ address: comment.author }),
|
|
163
|
+
className: "text-xs font-semibold text-foreground hover:underline underline-offset-2",
|
|
164
|
+
children: own ? "You" : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_address_display.AddressDisplay, { address: comment.author, chars: 5, showCopy: false })
|
|
165
|
+
}
|
|
166
|
+
),
|
|
167
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-2xs text-muted-foreground", title: comment.postedAt, children: (0, import_time.timeAgo)(comment.postedAt) })
|
|
168
|
+
] }),
|
|
169
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "relative", children: [
|
|
170
|
+
own ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
171
|
+
"div",
|
|
172
|
+
{
|
|
173
|
+
className: "px-3.5 py-2.5 text-sm leading-relaxed break-words rounded-2xl rounded-tr-sm text-white",
|
|
174
|
+
style: { background: "linear-gradient(135deg, hsl(var(--brand-blue)), hsl(var(--brand-purple)))" },
|
|
175
|
+
children: comment.content
|
|
176
|
+
}
|
|
177
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "px-3.5 py-2.5 text-sm leading-relaxed break-words bg-muted rounded-2xl rounded-tl-sm border border-border/50", children: comment.content }),
|
|
178
|
+
!own && hasWallet && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
179
|
+
"button",
|
|
180
|
+
{
|
|
181
|
+
className: "absolute -top-1 -right-5 opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground/40 hover:text-destructive/70",
|
|
182
|
+
title: "Report comment",
|
|
183
|
+
"aria-label": "Report comment",
|
|
184
|
+
onClick: () => setReportTarget({ type: "COMMENT", commentId: comment.id }),
|
|
185
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Flag, { className: "h-3 w-3" })
|
|
186
|
+
}
|
|
187
|
+
)
|
|
188
|
+
] }),
|
|
189
|
+
comment.txHash && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
190
|
+
"a",
|
|
191
|
+
{
|
|
192
|
+
href: `${import_explorer_url.EXPLORER_URL}/tx/${comment.txHash}`,
|
|
193
|
+
target: "_blank",
|
|
194
|
+
rel: "noopener noreferrer",
|
|
195
|
+
className: "flex items-center gap-1 px-1 text-2xs font-medium transition-colors",
|
|
196
|
+
style: { color: "hsl(var(--brand-blue) / 0.55)" },
|
|
197
|
+
onMouseEnter: (e) => e.currentTarget.style.color = "hsl(var(--brand-blue))",
|
|
198
|
+
onMouseLeave: (e) => e.currentTarget.style.color = "hsl(var(--brand-blue) / 0.55)",
|
|
199
|
+
children: [
|
|
200
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u26D3" }),
|
|
201
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "onchain proof" }),
|
|
202
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.ExternalLink, { className: "h-2.5 w-2.5" })
|
|
203
|
+
]
|
|
204
|
+
}
|
|
205
|
+
)
|
|
206
|
+
] })
|
|
207
|
+
]
|
|
208
|
+
},
|
|
209
|
+
comment.id
|
|
210
|
+
);
|
|
211
|
+
}),
|
|
212
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: bottomRef })
|
|
213
|
+
] }) }),
|
|
214
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "border-t border-border/60 shrink-0", children: !hasWallet ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex items-center justify-center px-4 h-16", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", onClick: app.onRequireWallet, className: "text-sm text-primary hover:underline", children: [
|
|
215
|
+
app.connectLabel ?? "Connect",
|
|
216
|
+
" to comment"
|
|
217
|
+
] }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "px-3 pt-2 pb-3 space-y-2", children: [
|
|
218
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
219
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Zap, { className: "h-3 w-3", style: { color: "hsl(var(--brand-blue))" } }),
|
|
220
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-2xs font-semibold", style: { color: "hsl(var(--brand-blue))" }, children: "Mint your message onchain" })
|
|
221
|
+
] }),
|
|
222
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
223
|
+
"div",
|
|
224
|
+
{
|
|
225
|
+
className: "rounded-xl border bg-background/60 transition-all focus-within:ring-2",
|
|
226
|
+
style: {
|
|
227
|
+
borderColor: "hsl(var(--border))"
|
|
228
|
+
},
|
|
229
|
+
onFocusCapture: (e) => {
|
|
230
|
+
e.currentTarget.style.borderColor = "hsl(var(--brand-blue) / 0.6)";
|
|
231
|
+
e.currentTarget.style.boxShadow = "0 0 0 3px hsl(var(--brand-blue) / 0.12)";
|
|
232
|
+
},
|
|
233
|
+
onBlurCapture: (e) => {
|
|
234
|
+
e.currentTarget.style.borderColor = "hsl(var(--border))";
|
|
235
|
+
e.currentTarget.style.boxShadow = "";
|
|
236
|
+
},
|
|
237
|
+
children: [
|
|
238
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
239
|
+
import_textarea.Textarea,
|
|
240
|
+
{
|
|
241
|
+
ref: composeRef,
|
|
242
|
+
placeholder: "Say something onchain\u2026 it's permanent.",
|
|
243
|
+
value: text,
|
|
244
|
+
onChange: handleTextInput,
|
|
245
|
+
onKeyDown: handleKeyDown,
|
|
246
|
+
rows: 2,
|
|
247
|
+
className: "resize-none min-h-[52px] max-h-[120px] w-full border-0 bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 px-3 pt-2.5 pb-1 text-sm rounded-xl",
|
|
248
|
+
disabled: isProcessing
|
|
249
|
+
}
|
|
250
|
+
),
|
|
251
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center justify-between px-3 pb-2.5", children: [
|
|
252
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-2xs text-muted-foreground/40 flex items-center gap-1", children: "Enter \u21B5 to post" }),
|
|
253
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
254
|
+
byteLen > 800 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: `text-2xs ${byteLen > MAX_LEN ? "text-destructive" : "text-muted-foreground"}`, children: [
|
|
255
|
+
byteLen,
|
|
256
|
+
"/",
|
|
257
|
+
MAX_LEN
|
|
258
|
+
] }),
|
|
259
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
260
|
+
"button",
|
|
261
|
+
{
|
|
262
|
+
onClick: post,
|
|
263
|
+
disabled: !canSubmit || isProcessing,
|
|
264
|
+
className: "flex items-center gap-1.5 h-7 px-3 text-xs font-semibold rounded-full text-white transition-all hover:opacity-90 active:scale-95 disabled:opacity-40 disabled:cursor-not-allowed",
|
|
265
|
+
style: { background: "linear-gradient(135deg, hsl(var(--brand-blue)), hsl(var(--brand-purple)))" },
|
|
266
|
+
children: [
|
|
267
|
+
isProcessing ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Loader2, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Send, { className: "h-3 w-3" }),
|
|
268
|
+
"Post onchain"
|
|
269
|
+
]
|
|
270
|
+
}
|
|
271
|
+
)
|
|
272
|
+
] })
|
|
273
|
+
] })
|
|
274
|
+
]
|
|
275
|
+
}
|
|
276
|
+
)
|
|
277
|
+
] }) }),
|
|
278
|
+
reportTarget && ReportDialog && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
279
|
+
ReportDialog,
|
|
280
|
+
{
|
|
281
|
+
target: reportTarget,
|
|
282
|
+
open: !!reportTarget,
|
|
283
|
+
onOpenChange: (open) => {
|
|
284
|
+
if (!open) setReportTarget(null);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
),
|
|
288
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_transaction_dialog.TransactionDialog, { tx, title: "Comment", workingLabel: "Posting your comment\u2026", firstStepLabel: "Prepare comment", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
289
|
+
import_transaction_done.TransactionDone,
|
|
290
|
+
{
|
|
291
|
+
tx,
|
|
292
|
+
name: "Comment",
|
|
293
|
+
title: "Comment posted!",
|
|
294
|
+
description: "Your comment is onchain and will appear here once indexed (~30s).",
|
|
295
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_reward_earned.RewardEarned, { actionType: "comment" })
|
|
296
|
+
}
|
|
297
|
+
) })
|
|
298
|
+
] });
|
|
299
|
+
}
|
|
300
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
301
|
+
0 && (module.exports = {
|
|
302
|
+
CommentsSection
|
|
303
|
+
});
|
|
304
|
+
//# sourceMappingURL=comments-section.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/comments-section.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, useState } from \"react\";\nimport { ExternalLink, Flag, Loader2, MessageCircle, Send, Zap } from \"lucide-react\";\nimport { normalizeAddress, profileHref, STARKNET_NFTCOMMENTS_CONTRACT } from \"@medialane/sdk\";\nimport { AddressDisplay } from \"./address-display.js\";\nimport { Button } from \"./button.js\";\nimport Link from \"./link.js\";\nimport { useMedialaneApp, type ReportTarget } from \"./medialane-app.js\";\nimport { RewardEarned } from \"./rewards/reward-earned.js\";\nimport { Skeleton } from \"./skeleton.js\";\nimport { Textarea } from \"./textarea.js\";\nimport { TransactionDialog } from \"./transaction-dialog.js\";\nimport { TransactionDone } from \"./transaction-done.js\";\nimport { cn } from \"../utils/cn.js\";\nimport { EXPLORER_URL } from \"../utils/explorer-url.js\";\nimport { runIntentCalls } from \"../utils/run-intent-calls.js\";\nimport { timeAgo } from \"../utils/time.js\";\nimport { useComments } from \"../utils/use-comments.js\";\nimport { useTransaction } from \"../utils/use-transaction.js\";\n\nconst MAX_LEN = 1000;\n\nexport interface CommentsSectionProps {\n contract: string;\n tokenId: string;\n className?: string;\n}\n\nexport function CommentsSection({ contract, tokenId, className }: CommentsSectionProps) {\n const app = useMedialaneApp();\n const walletAddress = app.walletAddress;\n const hasWallet = !!walletAddress;\n const { ReportDialog } = app;\n const { comments, isLoading, mutate } = useComments(contract, tokenId);\n const tx = useTransaction();\n\n const [text, setText] = useState(\"\");\n const [reportTarget, setReportTarget] = useState<ReportTarget | null>(null);\n\n const messagesRef = useRef<HTMLDivElement>(null);\n const bottomRef = useRef<HTMLDivElement>(null);\n const composeRef = useRef<HTMLTextAreaElement>(null);\n\n const byteLen = new TextEncoder().encode(text).length;\n const canSubmit = text.trim().length > 0 && byteLen <= MAX_LEN && !!STARKNET_NFTCOMMENTS_CONTRACT;\n const isProcessing = tx.phase === \"preparing\" || tx.phase === \"submitting\" || tx.phase === \"confirming\";\n\n const isOwn = (author: string) =>\n !!walletAddress && normalizeAddress(\"STARKNET\", author) === normalizeAddress(\"STARKNET\", walletAddress);\n\n const isNearBottom = () => {\n const el = messagesRef.current;\n if (!el) return true;\n return el.scrollHeight - el.scrollTop - el.clientHeight < 100;\n };\n\n useEffect(() => {\n if (isNearBottom()) {\n bottomRef.current?.scrollIntoView({ behavior: \"smooth\" });\n }\n\n }, [comments.length]);\n\n const handleTextInput = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n setText(e.target.value);\n e.target.style.height = \"auto\";\n e.target.style.height = Math.min(e.target.scrollHeight, 96) + \"px\";\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === \"Enter\" && !e.shiftKey && canSubmit && !isProcessing) {\n e.preventDefault();\n post();\n }\n };\n\n const post = () => {\n const body = text.trim();\n void tx\n .run(async (signer) => {\n await runIntentCalls(signer, () =>\n app.getClient().api.intents.create(\"comment\", { author: signer.address, nftContract: contract, tokenId, text: body }),\n );\n })\n .then((ok) => {\n if (!ok) return;\n setText(\"\");\n if (composeRef.current) composeRef.current.style.height = \"auto\";\n void mutate();\n });\n };\n\n const handleStartConversation = () => {\n if (hasWallet) composeRef.current?.focus();\n };\n\n return (\n <div className={cn(\"flex flex-col h-[480px] overflow-hidden\", className)}>\n\n <div ref={messagesRef} className=\"flex-1 overflow-y-auto px-4 py-4\">\n {isLoading ? (\n <div className=\"space-y-4\">\n {([\n { own: false, w: \"w-40\" },\n { own: true, w: \"w-56\" },\n { own: false, w: \"w-48\" },\n { own: true, w: \"w-32\" },\n ] as const).map((item, i) => (\n <div key={i} className={`flex ${item.own ? \"justify-end\" : \"justify-start\"} gap-2`}>\n {!item.own && <Skeleton className=\"h-8 w-8 rounded-full shrink-0\" />}\n <Skeleton\n className={`h-10 ${item.w} rounded-2xl ${item.own ? \"rounded-tr-sm\" : \"rounded-tl-sm\"}`}\n />\n </div>\n ))}\n </div>\n ) : comments.length === 0 ? (\n <div className=\"flex flex-col items-center justify-center h-full gap-4 text-center px-4\">\n <div className=\"flex h-16 w-16 items-center justify-center rounded-full\" style={{ background: \"linear-gradient(135deg, hsl(var(--brand-blue) / 0.15), hsl(var(--brand-purple) / 0.15))\" }}>\n <MessageCircle className=\"h-7 w-7\" style={{ color: \"hsl(var(--brand-blue))\" }} />\n </div>\n <div>\n <p className=\"text-sm font-semibold\">Nothing here yet</p>\n <p className=\"text-xs text-muted-foreground mt-1 leading-relaxed max-w-[220px]\">\n Your comment will be minted onchain — attached to this NFT forever.\n </p>\n </div>\n <Button\n size=\"sm\"\n onClick={handleStartConversation}\n className=\"rounded-full text-white px-5\"\n style={{ background: \"linear-gradient(135deg, hsl(var(--brand-blue)), hsl(var(--brand-purple)))\" }}\n >\n Write the first comment\n </Button>\n </div>\n ) : (\n <div className=\"space-y-5\">\n {comments.map((comment) => {\n const own = isOwn(comment.author);\n const avatarSeed = parseInt(comment.author.slice(2, 8), 16) % 360;\n const avatarBg = own\n ? \"linear-gradient(135deg, hsl(var(--brand-blue)), hsl(var(--brand-purple)))\"\n : `linear-gradient(135deg, hsl(${avatarSeed}, 65%, 45%), hsl(${(avatarSeed + 60) % 360}, 65%, 55%))`;\n\n return (\n <div\n key={comment.id}\n className={`group flex gap-2.5 ${own ? \"flex-row-reverse\" : \"flex-row\"}`}\n >\n\n <Link href={profileHref({ address: comment.author })} className=\"shrink-0 mt-0.5\">\n <div\n className=\"h-9 w-9 rounded-full flex items-center justify-center text-2xs font-bold text-white select-none ring-2 ring-background hover:ring-primary/40 transition-all\"\n style={{ background: avatarBg }}\n >\n {comment.author.slice(2, 5).toUpperCase()}\n </div>\n </Link>\n\n <div className={`flex flex-col max-w-[75%] gap-1 ${own ? \"items-end\" : \"items-start\"}`}>\n\n <div className={`flex items-center gap-2 px-1 ${own ? \"flex-row-reverse\" : \"flex-row\"}`}>\n <Link\n href={profileHref({ address: comment.author })}\n className=\"text-xs font-semibold text-foreground hover:underline underline-offset-2\"\n >\n {own ? \"You\" : <AddressDisplay address={comment.author} chars={5} showCopy={false} />}\n </Link>\n <span className=\"text-2xs text-muted-foreground\" title={comment.postedAt}>\n {timeAgo(comment.postedAt)}\n </span>\n </div>\n\n <div className=\"relative\">\n {own ? (\n <div\n className=\"px-3.5 py-2.5 text-sm leading-relaxed break-words rounded-2xl rounded-tr-sm text-white\"\n style={{ background: \"linear-gradient(135deg, hsl(var(--brand-blue)), hsl(var(--brand-purple)))\" }}\n >\n {comment.content}\n </div>\n ) : (\n <div className=\"px-3.5 py-2.5 text-sm leading-relaxed break-words bg-muted rounded-2xl rounded-tl-sm border border-border/50\">\n {comment.content}\n </div>\n )}\n {!own && hasWallet && (\n <button\n className=\"absolute -top-1 -right-5 opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground/40 hover:text-destructive/70\"\n title=\"Report comment\"\n aria-label=\"Report comment\"\n onClick={() => setReportTarget({ type: \"COMMENT\", commentId: comment.id })}\n >\n <Flag className=\"h-3 w-3\" />\n </button>\n )}\n </div>\n\n {comment.txHash && (\n <a\n href={`${EXPLORER_URL}/tx/${comment.txHash}`}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"flex items-center gap-1 px-1 text-2xs font-medium transition-colors\"\n style={{ color: \"hsl(var(--brand-blue) / 0.55)\" }}\n onMouseEnter={(e) => (e.currentTarget.style.color = \"hsl(var(--brand-blue))\")}\n onMouseLeave={(e) => (e.currentTarget.style.color = \"hsl(var(--brand-blue) / 0.55)\")}\n >\n <span>⛓</span>\n <span>onchain proof</span>\n <ExternalLink className=\"h-2.5 w-2.5\" />\n </a>\n )}\n </div>\n </div>\n );\n })}\n <div ref={bottomRef} />\n </div>\n )}\n </div>\n\n <div className=\"border-t border-border/60 shrink-0\">\n {!hasWallet ? (\n <div className=\"flex items-center justify-center px-4 h-16\">\n <button type=\"button\" onClick={app.onRequireWallet} className=\"text-sm text-primary hover:underline\">\n {app.connectLabel ?? \"Connect\"} to comment\n </button>\n </div>\n ) : (\n <div className=\"px-3 pt-2 pb-3 space-y-2\">\n\n <div className=\"flex items-center gap-1.5\">\n <Zap className=\"h-3 w-3\" style={{ color: \"hsl(var(--brand-blue))\" }} />\n <span className=\"text-2xs font-semibold\" style={{ color: \"hsl(var(--brand-blue))\" }}>\n Mint your message onchain\n </span>\n </div>\n\n <div\n className=\"rounded-xl border bg-background/60 transition-all focus-within:ring-2\"\n style={{\n borderColor: \"hsl(var(--border))\",\n }}\n onFocusCapture={(e) => {\n (e.currentTarget as HTMLDivElement).style.borderColor = \"hsl(var(--brand-blue) / 0.6)\";\n (e.currentTarget as HTMLDivElement).style.boxShadow = \"0 0 0 3px hsl(var(--brand-blue) / 0.12)\";\n }}\n onBlurCapture={(e) => {\n (e.currentTarget as HTMLDivElement).style.borderColor = \"hsl(var(--border))\";\n (e.currentTarget as HTMLDivElement).style.boxShadow = \"\";\n }}\n >\n <Textarea\n ref={composeRef}\n placeholder=\"Say something onchain… it's permanent.\"\n value={text}\n onChange={handleTextInput}\n onKeyDown={handleKeyDown}\n rows={2}\n className=\"resize-none min-h-[52px] max-h-[120px] w-full border-0 bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 px-3 pt-2.5 pb-1 text-sm rounded-xl\"\n disabled={isProcessing}\n />\n <div className=\"flex items-center justify-between px-3 pb-2.5\">\n <span className=\"text-2xs text-muted-foreground/40 flex items-center gap-1\">\n Enter ↵ to post\n </span>\n <div className=\"flex items-center gap-2\">\n {byteLen > 800 && (\n <span className={`text-2xs ${byteLen > MAX_LEN ? \"text-destructive\" : \"text-muted-foreground\"}`}>\n {byteLen}/{MAX_LEN}\n </span>\n )}\n <button\n onClick={post}\n disabled={!canSubmit || isProcessing}\n className=\"flex items-center gap-1.5 h-7 px-3 text-xs font-semibold rounded-full text-white transition-all hover:opacity-90 active:scale-95 disabled:opacity-40 disabled:cursor-not-allowed\"\n style={{ background: \"linear-gradient(135deg, hsl(var(--brand-blue)), hsl(var(--brand-purple)))\" }}\n >\n {isProcessing ? <Loader2 className=\"h-3 w-3 animate-spin\" /> : <Send className=\"h-3 w-3\" />}\n Post onchain\n </button>\n </div>\n </div>\n </div>\n </div>\n )}\n </div>\n\n {reportTarget && ReportDialog && (\n <ReportDialog\n target={reportTarget}\n open={!!reportTarget}\n onOpenChange={(open) => { if (!open) setReportTarget(null); }}\n />\n )}\n\n <TransactionDialog tx={tx} title=\"Comment\" workingLabel=\"Posting your comment…\" firstStepLabel=\"Prepare comment\">\n <TransactionDone\n tx={tx}\n name=\"Comment\"\n title=\"Comment posted!\"\n description=\"Your comment is onchain and will appear here once indexed (~30s).\"\n footer={<RewardEarned actionType=\"comment\" />}\n />\n </TransactionDialog>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6Gc;AA3Gd,mBAA4C;AAC5C,0BAAsE;AACtE,iBAA6E;AAC7E,6BAA+B;AAC/B,oBAAuB;AACvB,kBAAiB;AACjB,2BAAmD;AACnD,2BAA6B;AAC7B,sBAAyB;AACzB,sBAAyB;AACzB,gCAAkC;AAClC,8BAAgC;AAChC,gBAAmB;AACnB,0BAA6B;AAC7B,8BAA+B;AAC/B,kBAAwB;AACxB,0BAA4B;AAC5B,6BAA+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1F;AAAA;AAAA,kBAAQ;AAAA,kBAAE;AAAA,mBACb;AAAA,gBAEF;AAAA,kBAAC;AAAA;AAAA,oBACC,SAAS;AAAA,oBACT,UAAU,CAAC,aAAa;AAAA,oBACxB,WAAU;AAAA,oBACV,OAAO,EAAE,YAAY,4EAA4E;AAAA,oBAEhG;AAAA,qCAAe,4CAAC,+BAAQ,WAAU,wBAAuB,IAAK,4CAAC,4BAAK,WAAU,WAAU;AAAA,sBAAG;AAAA;AAAA;AAAA,gBAE9F;AAAA,iBACF;AAAA,eACF;AAAA;AAAA;AAAA,MACF;AAAA,OACF,GAEJ;AAAA,IAEC,gBAAgB,gBACf;AAAA,MAAC;AAAA;AAAA,QACC,QAAQ;AAAA,QACR,MAAM,CAAC,CAAC;AAAA,QACR,cAAc,CAAC,SAAS;AAAE,cAAI,CAAC,KAAM,iBAAgB,IAAI;AAAA,QAAG;AAAA;AAAA,IAC9D;AAAA,IAGF,4CAAC,+CAAkB,IAAQ,OAAM,WAAU,cAAa,8BAAwB,gBAAe,mBAC7F;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,MAAK;AAAA,QACL,OAAM;AAAA,QACN,aAAY;AAAA,QACZ,QAAQ,4CAAC,qCAAa,YAAW,WAAU;AAAA;AAAA,IAC7C,GACF;AAAA,KACF;AAEJ;","names":["Link"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface CommentsSectionProps {
|
|
4
|
+
contract: string;
|
|
5
|
+
tokenId: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
declare function CommentsSection({ contract, tokenId, className }: CommentsSectionProps): react_jsx_runtime.JSX.Element;
|
|
9
|
+
|
|
10
|
+
export { CommentsSection, type CommentsSectionProps };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface CommentsSectionProps {
|
|
4
|
+
contract: string;
|
|
5
|
+
tokenId: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
declare function CommentsSection({ contract, tokenId, className }: CommentsSectionProps): react_jsx_runtime.JSX.Element;
|
|
9
|
+
|
|
10
|
+
export { CommentsSection, type CommentsSectionProps };
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { ExternalLink, Flag, Loader2, MessageCircle, Send, Zap } from "lucide-react";
|
|
5
|
+
import { normalizeAddress, profileHref, STARKNET_NFTCOMMENTS_CONTRACT } from "@medialane/sdk";
|
|
6
|
+
import { AddressDisplay } from "./address-display.js";
|
|
7
|
+
import { Button } from "./button.js";
|
|
8
|
+
import Link from "./link.js";
|
|
9
|
+
import { useMedialaneApp } from "./medialane-app.js";
|
|
10
|
+
import { RewardEarned } from "./rewards/reward-earned.js";
|
|
11
|
+
import { Skeleton } from "./skeleton.js";
|
|
12
|
+
import { Textarea } from "./textarea.js";
|
|
13
|
+
import { TransactionDialog } from "./transaction-dialog.js";
|
|
14
|
+
import { TransactionDone } from "./transaction-done.js";
|
|
15
|
+
import { cn } from "../utils/cn.js";
|
|
16
|
+
import { EXPLORER_URL } from "../utils/explorer-url.js";
|
|
17
|
+
import { runIntentCalls } from "../utils/run-intent-calls.js";
|
|
18
|
+
import { timeAgo } from "../utils/time.js";
|
|
19
|
+
import { useComments } from "../utils/use-comments.js";
|
|
20
|
+
import { useTransaction } from "../utils/use-transaction.js";
|
|
21
|
+
const MAX_LEN = 1e3;
|
|
22
|
+
function CommentsSection({ contract, tokenId, className }) {
|
|
23
|
+
const app = useMedialaneApp();
|
|
24
|
+
const walletAddress = app.walletAddress;
|
|
25
|
+
const hasWallet = !!walletAddress;
|
|
26
|
+
const { ReportDialog } = app;
|
|
27
|
+
const { comments, isLoading, mutate } = useComments(contract, tokenId);
|
|
28
|
+
const tx = useTransaction();
|
|
29
|
+
const [text, setText] = useState("");
|
|
30
|
+
const [reportTarget, setReportTarget] = useState(null);
|
|
31
|
+
const messagesRef = useRef(null);
|
|
32
|
+
const bottomRef = useRef(null);
|
|
33
|
+
const composeRef = useRef(null);
|
|
34
|
+
const byteLen = new TextEncoder().encode(text).length;
|
|
35
|
+
const canSubmit = text.trim().length > 0 && byteLen <= MAX_LEN && !!STARKNET_NFTCOMMENTS_CONTRACT;
|
|
36
|
+
const isProcessing = tx.phase === "preparing" || tx.phase === "submitting" || tx.phase === "confirming";
|
|
37
|
+
const isOwn = (author) => !!walletAddress && normalizeAddress("STARKNET", author) === normalizeAddress("STARKNET", walletAddress);
|
|
38
|
+
const isNearBottom = () => {
|
|
39
|
+
const el = messagesRef.current;
|
|
40
|
+
if (!el) return true;
|
|
41
|
+
return el.scrollHeight - el.scrollTop - el.clientHeight < 100;
|
|
42
|
+
};
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (isNearBottom()) {
|
|
45
|
+
bottomRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
46
|
+
}
|
|
47
|
+
}, [comments.length]);
|
|
48
|
+
const handleTextInput = (e) => {
|
|
49
|
+
setText(e.target.value);
|
|
50
|
+
e.target.style.height = "auto";
|
|
51
|
+
e.target.style.height = Math.min(e.target.scrollHeight, 96) + "px";
|
|
52
|
+
};
|
|
53
|
+
const handleKeyDown = (e) => {
|
|
54
|
+
if (e.key === "Enter" && !e.shiftKey && canSubmit && !isProcessing) {
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
post();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const post = () => {
|
|
60
|
+
const body = text.trim();
|
|
61
|
+
void tx.run(async (signer) => {
|
|
62
|
+
await runIntentCalls(
|
|
63
|
+
signer,
|
|
64
|
+
() => app.getClient().api.intents.create("comment", { author: signer.address, nftContract: contract, tokenId, text: body })
|
|
65
|
+
);
|
|
66
|
+
}).then((ok) => {
|
|
67
|
+
if (!ok) return;
|
|
68
|
+
setText("");
|
|
69
|
+
if (composeRef.current) composeRef.current.style.height = "auto";
|
|
70
|
+
void mutate();
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
const handleStartConversation = () => {
|
|
74
|
+
if (hasWallet) composeRef.current?.focus();
|
|
75
|
+
};
|
|
76
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col h-[480px] overflow-hidden", className), children: [
|
|
77
|
+
/* @__PURE__ */ jsx("div", { ref: messagesRef, className: "flex-1 overflow-y-auto px-4 py-4", children: isLoading ? /* @__PURE__ */ jsx("div", { className: "space-y-4", children: [
|
|
78
|
+
{ own: false, w: "w-40" },
|
|
79
|
+
{ own: true, w: "w-56" },
|
|
80
|
+
{ own: false, w: "w-48" },
|
|
81
|
+
{ own: true, w: "w-32" }
|
|
82
|
+
].map((item, i) => /* @__PURE__ */ jsxs("div", { className: `flex ${item.own ? "justify-end" : "justify-start"} gap-2`, children: [
|
|
83
|
+
!item.own && /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-8 rounded-full shrink-0" }),
|
|
84
|
+
/* @__PURE__ */ jsx(
|
|
85
|
+
Skeleton,
|
|
86
|
+
{
|
|
87
|
+
className: `h-10 ${item.w} rounded-2xl ${item.own ? "rounded-tr-sm" : "rounded-tl-sm"}`
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
|
+
] }, i)) }) : comments.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center h-full gap-4 text-center px-4", children: [
|
|
91
|
+
/* @__PURE__ */ jsx("div", { className: "flex h-16 w-16 items-center justify-center rounded-full", style: { background: "linear-gradient(135deg, hsl(var(--brand-blue) / 0.15), hsl(var(--brand-purple) / 0.15))" }, children: /* @__PURE__ */ jsx(MessageCircle, { className: "h-7 w-7", style: { color: "hsl(var(--brand-blue))" } }) }),
|
|
92
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
93
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-semibold", children: "Nothing here yet" }),
|
|
94
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-1 leading-relaxed max-w-[220px]", children: "Your comment will be minted onchain \u2014 attached to this NFT forever." })
|
|
95
|
+
] }),
|
|
96
|
+
/* @__PURE__ */ jsx(
|
|
97
|
+
Button,
|
|
98
|
+
{
|
|
99
|
+
size: "sm",
|
|
100
|
+
onClick: handleStartConversation,
|
|
101
|
+
className: "rounded-full text-white px-5",
|
|
102
|
+
style: { background: "linear-gradient(135deg, hsl(var(--brand-blue)), hsl(var(--brand-purple)))" },
|
|
103
|
+
children: "Write the first comment"
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: "space-y-5", children: [
|
|
107
|
+
comments.map((comment) => {
|
|
108
|
+
const own = isOwn(comment.author);
|
|
109
|
+
const avatarSeed = parseInt(comment.author.slice(2, 8), 16) % 360;
|
|
110
|
+
const avatarBg = own ? "linear-gradient(135deg, hsl(var(--brand-blue)), hsl(var(--brand-purple)))" : `linear-gradient(135deg, hsl(${avatarSeed}, 65%, 45%), hsl(${(avatarSeed + 60) % 360}, 65%, 55%))`;
|
|
111
|
+
return /* @__PURE__ */ jsxs(
|
|
112
|
+
"div",
|
|
113
|
+
{
|
|
114
|
+
className: `group flex gap-2.5 ${own ? "flex-row-reverse" : "flex-row"}`,
|
|
115
|
+
children: [
|
|
116
|
+
/* @__PURE__ */ jsx(Link, { href: profileHref({ address: comment.author }), className: "shrink-0 mt-0.5", children: /* @__PURE__ */ jsx(
|
|
117
|
+
"div",
|
|
118
|
+
{
|
|
119
|
+
className: "h-9 w-9 rounded-full flex items-center justify-center text-2xs font-bold text-white select-none ring-2 ring-background hover:ring-primary/40 transition-all",
|
|
120
|
+
style: { background: avatarBg },
|
|
121
|
+
children: comment.author.slice(2, 5).toUpperCase()
|
|
122
|
+
}
|
|
123
|
+
) }),
|
|
124
|
+
/* @__PURE__ */ jsxs("div", { className: `flex flex-col max-w-[75%] gap-1 ${own ? "items-end" : "items-start"}`, children: [
|
|
125
|
+
/* @__PURE__ */ jsxs("div", { className: `flex items-center gap-2 px-1 ${own ? "flex-row-reverse" : "flex-row"}`, children: [
|
|
126
|
+
/* @__PURE__ */ jsx(
|
|
127
|
+
Link,
|
|
128
|
+
{
|
|
129
|
+
href: profileHref({ address: comment.author }),
|
|
130
|
+
className: "text-xs font-semibold text-foreground hover:underline underline-offset-2",
|
|
131
|
+
children: own ? "You" : /* @__PURE__ */ jsx(AddressDisplay, { address: comment.author, chars: 5, showCopy: false })
|
|
132
|
+
}
|
|
133
|
+
),
|
|
134
|
+
/* @__PURE__ */ jsx("span", { className: "text-2xs text-muted-foreground", title: comment.postedAt, children: timeAgo(comment.postedAt) })
|
|
135
|
+
] }),
|
|
136
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
137
|
+
own ? /* @__PURE__ */ jsx(
|
|
138
|
+
"div",
|
|
139
|
+
{
|
|
140
|
+
className: "px-3.5 py-2.5 text-sm leading-relaxed break-words rounded-2xl rounded-tr-sm text-white",
|
|
141
|
+
style: { background: "linear-gradient(135deg, hsl(var(--brand-blue)), hsl(var(--brand-purple)))" },
|
|
142
|
+
children: comment.content
|
|
143
|
+
}
|
|
144
|
+
) : /* @__PURE__ */ jsx("div", { className: "px-3.5 py-2.5 text-sm leading-relaxed break-words bg-muted rounded-2xl rounded-tl-sm border border-border/50", children: comment.content }),
|
|
145
|
+
!own && hasWallet && /* @__PURE__ */ jsx(
|
|
146
|
+
"button",
|
|
147
|
+
{
|
|
148
|
+
className: "absolute -top-1 -right-5 opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground/40 hover:text-destructive/70",
|
|
149
|
+
title: "Report comment",
|
|
150
|
+
"aria-label": "Report comment",
|
|
151
|
+
onClick: () => setReportTarget({ type: "COMMENT", commentId: comment.id }),
|
|
152
|
+
children: /* @__PURE__ */ jsx(Flag, { className: "h-3 w-3" })
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
] }),
|
|
156
|
+
comment.txHash && /* @__PURE__ */ jsxs(
|
|
157
|
+
"a",
|
|
158
|
+
{
|
|
159
|
+
href: `${EXPLORER_URL}/tx/${comment.txHash}`,
|
|
160
|
+
target: "_blank",
|
|
161
|
+
rel: "noopener noreferrer",
|
|
162
|
+
className: "flex items-center gap-1 px-1 text-2xs font-medium transition-colors",
|
|
163
|
+
style: { color: "hsl(var(--brand-blue) / 0.55)" },
|
|
164
|
+
onMouseEnter: (e) => e.currentTarget.style.color = "hsl(var(--brand-blue))",
|
|
165
|
+
onMouseLeave: (e) => e.currentTarget.style.color = "hsl(var(--brand-blue) / 0.55)",
|
|
166
|
+
children: [
|
|
167
|
+
/* @__PURE__ */ jsx("span", { children: "\u26D3" }),
|
|
168
|
+
/* @__PURE__ */ jsx("span", { children: "onchain proof" }),
|
|
169
|
+
/* @__PURE__ */ jsx(ExternalLink, { className: "h-2.5 w-2.5" })
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
)
|
|
173
|
+
] })
|
|
174
|
+
]
|
|
175
|
+
},
|
|
176
|
+
comment.id
|
|
177
|
+
);
|
|
178
|
+
}),
|
|
179
|
+
/* @__PURE__ */ jsx("div", { ref: bottomRef })
|
|
180
|
+
] }) }),
|
|
181
|
+
/* @__PURE__ */ jsx("div", { className: "border-t border-border/60 shrink-0", children: !hasWallet ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center px-4 h-16", children: /* @__PURE__ */ jsxs("button", { type: "button", onClick: app.onRequireWallet, className: "text-sm text-primary hover:underline", children: [
|
|
182
|
+
app.connectLabel ?? "Connect",
|
|
183
|
+
" to comment"
|
|
184
|
+
] }) }) : /* @__PURE__ */ jsxs("div", { className: "px-3 pt-2 pb-3 space-y-2", children: [
|
|
185
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
186
|
+
/* @__PURE__ */ jsx(Zap, { className: "h-3 w-3", style: { color: "hsl(var(--brand-blue))" } }),
|
|
187
|
+
/* @__PURE__ */ jsx("span", { className: "text-2xs font-semibold", style: { color: "hsl(var(--brand-blue))" }, children: "Mint your message onchain" })
|
|
188
|
+
] }),
|
|
189
|
+
/* @__PURE__ */ jsxs(
|
|
190
|
+
"div",
|
|
191
|
+
{
|
|
192
|
+
className: "rounded-xl border bg-background/60 transition-all focus-within:ring-2",
|
|
193
|
+
style: {
|
|
194
|
+
borderColor: "hsl(var(--border))"
|
|
195
|
+
},
|
|
196
|
+
onFocusCapture: (e) => {
|
|
197
|
+
e.currentTarget.style.borderColor = "hsl(var(--brand-blue) / 0.6)";
|
|
198
|
+
e.currentTarget.style.boxShadow = "0 0 0 3px hsl(var(--brand-blue) / 0.12)";
|
|
199
|
+
},
|
|
200
|
+
onBlurCapture: (e) => {
|
|
201
|
+
e.currentTarget.style.borderColor = "hsl(var(--border))";
|
|
202
|
+
e.currentTarget.style.boxShadow = "";
|
|
203
|
+
},
|
|
204
|
+
children: [
|
|
205
|
+
/* @__PURE__ */ jsx(
|
|
206
|
+
Textarea,
|
|
207
|
+
{
|
|
208
|
+
ref: composeRef,
|
|
209
|
+
placeholder: "Say something onchain\u2026 it's permanent.",
|
|
210
|
+
value: text,
|
|
211
|
+
onChange: handleTextInput,
|
|
212
|
+
onKeyDown: handleKeyDown,
|
|
213
|
+
rows: 2,
|
|
214
|
+
className: "resize-none min-h-[52px] max-h-[120px] w-full border-0 bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 px-3 pt-2.5 pb-1 text-sm rounded-xl",
|
|
215
|
+
disabled: isProcessing
|
|
216
|
+
}
|
|
217
|
+
),
|
|
218
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-3 pb-2.5", children: [
|
|
219
|
+
/* @__PURE__ */ jsx("span", { className: "text-2xs text-muted-foreground/40 flex items-center gap-1", children: "Enter \u21B5 to post" }),
|
|
220
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
221
|
+
byteLen > 800 && /* @__PURE__ */ jsxs("span", { className: `text-2xs ${byteLen > MAX_LEN ? "text-destructive" : "text-muted-foreground"}`, children: [
|
|
222
|
+
byteLen,
|
|
223
|
+
"/",
|
|
224
|
+
MAX_LEN
|
|
225
|
+
] }),
|
|
226
|
+
/* @__PURE__ */ jsxs(
|
|
227
|
+
"button",
|
|
228
|
+
{
|
|
229
|
+
onClick: post,
|
|
230
|
+
disabled: !canSubmit || isProcessing,
|
|
231
|
+
className: "flex items-center gap-1.5 h-7 px-3 text-xs font-semibold rounded-full text-white transition-all hover:opacity-90 active:scale-95 disabled:opacity-40 disabled:cursor-not-allowed",
|
|
232
|
+
style: { background: "linear-gradient(135deg, hsl(var(--brand-blue)), hsl(var(--brand-purple)))" },
|
|
233
|
+
children: [
|
|
234
|
+
isProcessing ? /* @__PURE__ */ jsx(Loader2, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ jsx(Send, { className: "h-3 w-3" }),
|
|
235
|
+
"Post onchain"
|
|
236
|
+
]
|
|
237
|
+
}
|
|
238
|
+
)
|
|
239
|
+
] })
|
|
240
|
+
] })
|
|
241
|
+
]
|
|
242
|
+
}
|
|
243
|
+
)
|
|
244
|
+
] }) }),
|
|
245
|
+
reportTarget && ReportDialog && /* @__PURE__ */ jsx(
|
|
246
|
+
ReportDialog,
|
|
247
|
+
{
|
|
248
|
+
target: reportTarget,
|
|
249
|
+
open: !!reportTarget,
|
|
250
|
+
onOpenChange: (open) => {
|
|
251
|
+
if (!open) setReportTarget(null);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
),
|
|
255
|
+
/* @__PURE__ */ jsx(TransactionDialog, { tx, title: "Comment", workingLabel: "Posting your comment\u2026", firstStepLabel: "Prepare comment", children: /* @__PURE__ */ jsx(
|
|
256
|
+
TransactionDone,
|
|
257
|
+
{
|
|
258
|
+
tx,
|
|
259
|
+
name: "Comment",
|
|
260
|
+
title: "Comment posted!",
|
|
261
|
+
description: "Your comment is onchain and will appear here once indexed (~30s).",
|
|
262
|
+
footer: /* @__PURE__ */ jsx(RewardEarned, { actionType: "comment" })
|
|
263
|
+
}
|
|
264
|
+
) })
|
|
265
|
+
] });
|
|
266
|
+
}
|
|
267
|
+
export {
|
|
268
|
+
CommentsSection
|
|
269
|
+
};
|
|
270
|
+
//# sourceMappingURL=comments-section.js.map
|