@goodwidget/ai-credits-widget 0.1.9 → 0.1.11
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/{chunk-ZDHB2OZ5.js → chunk-3QY3YZDH.js} +109 -24
- package/dist/chunk-3QY3YZDH.js.map +1 -0
- package/dist/element.cjs +103 -23
- package/dist/element.cjs.map +1 -1
- package/dist/element.js +1 -1
- package/dist/index.cjs +103 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/mocked/index.cjs +103 -23
- package/dist/mocked/index.cjs.map +1 -1
- package/dist/mocked/index.js +1 -1
- package/dist/register.cjs +103 -23
- package/dist/register.cjs.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-ZDHB2OZ5.js.map +0 -1
package/dist/element.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -4212,14 +4212,43 @@ var WITHDRAW_TOOLTIP = "Withdraws principal to your payer wallet (not bonus). Re
|
|
|
4212
4212
|
|
|
4213
4213
|
// src/components/manage/CreditsManagementCard.tsx
|
|
4214
4214
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
4215
|
-
function StatCell({
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4215
|
+
function StatCell({
|
|
4216
|
+
label,
|
|
4217
|
+
icon: Glyph,
|
|
4218
|
+
children
|
|
4219
|
+
}) {
|
|
4220
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
4221
|
+
import_ui9.Card,
|
|
4222
|
+
{
|
|
4223
|
+
raised: true,
|
|
4224
|
+
borderWidth: 0,
|
|
4225
|
+
flexGrow: 1,
|
|
4226
|
+
flexBasis: 0,
|
|
4227
|
+
padding: "$3",
|
|
4228
|
+
gap: "$1",
|
|
4229
|
+
children: [
|
|
4230
|
+
Glyph ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4231
|
+
import_ui9.XStack,
|
|
4232
|
+
{
|
|
4233
|
+
width: 28,
|
|
4234
|
+
height: 28,
|
|
4235
|
+
borderRadius: "$2",
|
|
4236
|
+
backgroundColor: "$background",
|
|
4237
|
+
alignItems: "center",
|
|
4238
|
+
justifyContent: "center",
|
|
4239
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Glyph, { size: 16, color: "$colorSoft" })
|
|
4240
|
+
}
|
|
4241
|
+
) : null,
|
|
4242
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { children: [
|
|
4243
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize: "$1", tone: "soft", children: label }),
|
|
4244
|
+
children
|
|
4245
|
+
] })
|
|
4246
|
+
]
|
|
4247
|
+
}
|
|
4248
|
+
);
|
|
4220
4249
|
}
|
|
4221
4250
|
function StatRow({ children }) {
|
|
4222
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.XStack, { gap: "$
|
|
4251
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.XStack, { gap: "$1", width: "100%", alignItems: "stretch", children });
|
|
4223
4252
|
}
|
|
4224
4253
|
function StatValueText({
|
|
4225
4254
|
children,
|
|
@@ -4228,12 +4257,30 @@ function StatValueText({
|
|
|
4228
4257
|
}) {
|
|
4229
4258
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize, fontWeight: "700", color, children });
|
|
4230
4259
|
}
|
|
4260
|
+
function StatValue({
|
|
4261
|
+
value,
|
|
4262
|
+
unit,
|
|
4263
|
+
unitPosition,
|
|
4264
|
+
fontSize = "$2",
|
|
4265
|
+
unitFontSize = "$1",
|
|
4266
|
+
color
|
|
4267
|
+
}) {
|
|
4268
|
+
const hoistMarker = unitPosition === "prefix" && value.startsWith("<");
|
|
4269
|
+
const unitLabel = hoistMarker ? `<${unit}` : unit;
|
|
4270
|
+
const digits = hoistMarker ? value.slice(1) : value;
|
|
4271
|
+
const unitText = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize: unitFontSize, fontWeight: "700", tone: "soft", children: unitLabel });
|
|
4272
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.XStack, { alignItems: "baseline", gap: "$1", children: [
|
|
4273
|
+
unitPosition === "prefix" ? unitText : null,
|
|
4274
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValueText, { fontSize, color, children: digits }),
|
|
4275
|
+
unitPosition === "suffix" ? unitText : null
|
|
4276
|
+
] });
|
|
4277
|
+
}
|
|
4231
4278
|
function CompactGStatValue({ amount }) {
|
|
4232
4279
|
const [open, setOpen] = (0, import_react8.useState)(false);
|
|
4233
4280
|
const display = formatGValue(amount);
|
|
4234
4281
|
const exact = formatExactGAmount(amount);
|
|
4235
4282
|
if (!isGValueCompacted(amount)) {
|
|
4236
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4283
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValue, { value: display, unit: "G$", unitPosition: "suffix" });
|
|
4237
4284
|
}
|
|
4238
4285
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
4239
4286
|
import_ui9.XStack,
|
|
@@ -4249,7 +4296,7 @@ function CompactGStatValue({ amount }) {
|
|
|
4249
4296
|
onBlur: () => setOpen(false),
|
|
4250
4297
|
onPress: () => setOpen((prev) => !prev),
|
|
4251
4298
|
children: [
|
|
4252
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4299
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValue, { value: display, unit: "G$", unitPosition: "suffix" }),
|
|
4253
4300
|
open && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4254
4301
|
import_ui9.YStack,
|
|
4255
4302
|
{
|
|
@@ -4274,6 +4321,43 @@ function CompactGStatValue({ amount }) {
|
|
|
4274
4321
|
function formatUsdAmount2(usdMicro) {
|
|
4275
4322
|
return formatUsdMicroValue(usdMicro);
|
|
4276
4323
|
}
|
|
4324
|
+
function CreditBalanceCard({
|
|
4325
|
+
balance,
|
|
4326
|
+
monthlyCredit
|
|
4327
|
+
}) {
|
|
4328
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Card, { raised: true, borderWidth: 0, width: "100%", gap: "$2", children: [
|
|
4329
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize: "$1", tone: "soft", children: "Credit balance" }),
|
|
4330
|
+
balance !== null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4331
|
+
StatValue,
|
|
4332
|
+
{
|
|
4333
|
+
value: balance,
|
|
4334
|
+
unit: "US$",
|
|
4335
|
+
unitPosition: "prefix",
|
|
4336
|
+
fontSize: "$8",
|
|
4337
|
+
unitFontSize: "$5"
|
|
4338
|
+
}
|
|
4339
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Spinner, { size: "sm" }),
|
|
4340
|
+
monthlyCredit ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
4341
|
+
import_ui9.XStack,
|
|
4342
|
+
{
|
|
4343
|
+
alignSelf: "flex-start",
|
|
4344
|
+
alignItems: "center",
|
|
4345
|
+
gap: "$1",
|
|
4346
|
+
paddingHorizontal: "$2",
|
|
4347
|
+
paddingVertical: "$1",
|
|
4348
|
+
borderRadius: "$full",
|
|
4349
|
+
backgroundColor: "$infoMuted",
|
|
4350
|
+
children: [
|
|
4351
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.TrendingUp, { size: 14, color: "$primary" }),
|
|
4352
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Text, { fontSize: "$1", fontWeight: "700", color: "$primary", children: [
|
|
4353
|
+
monthlyCredit.startsWith("<") ? monthlyCredit : `~${monthlyCredit}`,
|
|
4354
|
+
" / month"
|
|
4355
|
+
] })
|
|
4356
|
+
]
|
|
4357
|
+
}
|
|
4358
|
+
) : null
|
|
4359
|
+
] });
|
|
4360
|
+
}
|
|
4277
4361
|
function CreditsManagementCard({ state, actions }) {
|
|
4278
4362
|
const [isClosing, setIsClosing] = (0, import_react8.useState)(false);
|
|
4279
4363
|
const [isWithdrawing, setIsWithdrawing] = (0, import_react8.useState)(false);
|
|
@@ -4298,7 +4382,7 @@ function CreditsManagementCard({ state, actions }) {
|
|
|
4298
4382
|
streamBonusPercent: state.streamBonusPercent
|
|
4299
4383
|
});
|
|
4300
4384
|
if (usdMicro <= 0n) return null;
|
|
4301
|
-
return
|
|
4385
|
+
return formatUsdMicroAmount(usdMicro.toString());
|
|
4302
4386
|
}, [
|
|
4303
4387
|
monthlyStreamG,
|
|
4304
4388
|
gdUsdPerToken,
|
|
@@ -4314,20 +4398,16 @@ function CreditsManagementCard({ state, actions }) {
|
|
|
4314
4398
|
const canWithdraw = Boolean(signerPrvKey) && hasWithdrawableBalance && Boolean(withdrawAmount.trim()) && !isWithdrawing;
|
|
4315
4399
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Card, { children: [
|
|
4316
4400
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Heading, { level: 6, children: "AI Credits" }),
|
|
4317
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
4318
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4319
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.
|
|
4320
|
-
"
|
|
4321
|
-
|
|
4322
|
-
] })
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
] }),
|
|
4328
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
|
|
4329
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Bonus (US$)", children: totalBonusDisplay !== null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValueText, { children: totalBonusDisplay }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Spinner, { size: "sm" }) }),
|
|
4330
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Withdrawable (US$)", children: withdrawableDisplay !== null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValueText, { children: withdrawableDisplay }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Spinner, { size: "sm" }) })
|
|
4401
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { gap: "$2", width: "100%", children: [
|
|
4402
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CreditBalanceCard, { balance: totalCreditDisplay, monthlyCredit: monthlyStreamUsdDisplay }),
|
|
4403
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
|
|
4404
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Deposited", icon: import_ui9.Coins, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CompactGStatValue, { amount: totalGdDepositedG ?? "0.00" }) }),
|
|
4405
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Monthly Streaming", icon: import_ui9.Repeat, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CompactGStatValue, { amount: monthlyStreamG ?? "0.00" }) })
|
|
4406
|
+
] }),
|
|
4407
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
|
|
4408
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Bonus", icon: import_ui9.Gift, children: totalBonusDisplay !== null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValue, { value: totalBonusDisplay, unit: "US$", unitPosition: "prefix" }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Spinner, { size: "sm" }) }),
|
|
4409
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Withdrawable", icon: import_ui9.Wallet, children: withdrawableDisplay !== null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValue, { value: withdrawableDisplay, unit: "US$", unitPosition: "prefix" }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Spinner, { size: "sm" }) })
|
|
4410
|
+
] })
|
|
4331
4411
|
] }),
|
|
4332
4412
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { gap: "$1", width: "100%", children: [
|
|
4333
4413
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.XStack, { gap: "$1", alignItems: "center", children: [
|