@goodwidget/ai-credits-widget 0.1.9 → 0.1.10
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/mocked/index.js
CHANGED
package/dist/register.cjs
CHANGED
|
@@ -4322,14 +4322,43 @@ var init_constants = __esm({
|
|
|
4322
4322
|
});
|
|
4323
4323
|
|
|
4324
4324
|
// src/components/manage/CreditsManagementCard.tsx
|
|
4325
|
-
function StatCell({
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4325
|
+
function StatCell({
|
|
4326
|
+
label,
|
|
4327
|
+
icon: Glyph,
|
|
4328
|
+
children
|
|
4329
|
+
}) {
|
|
4330
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
4331
|
+
import_ui9.Card,
|
|
4332
|
+
{
|
|
4333
|
+
raised: true,
|
|
4334
|
+
borderWidth: 0,
|
|
4335
|
+
flexGrow: 1,
|
|
4336
|
+
flexBasis: 0,
|
|
4337
|
+
padding: "$3",
|
|
4338
|
+
gap: "$1",
|
|
4339
|
+
children: [
|
|
4340
|
+
Glyph ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4341
|
+
import_ui9.XStack,
|
|
4342
|
+
{
|
|
4343
|
+
width: 28,
|
|
4344
|
+
height: 28,
|
|
4345
|
+
borderRadius: "$2",
|
|
4346
|
+
backgroundColor: "$background",
|
|
4347
|
+
alignItems: "center",
|
|
4348
|
+
justifyContent: "center",
|
|
4349
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Glyph, { size: 16, color: "$colorSoft" })
|
|
4350
|
+
}
|
|
4351
|
+
) : null,
|
|
4352
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { children: [
|
|
4353
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize: "$1", tone: "soft", children: label }),
|
|
4354
|
+
children
|
|
4355
|
+
] })
|
|
4356
|
+
]
|
|
4357
|
+
}
|
|
4358
|
+
);
|
|
4330
4359
|
}
|
|
4331
4360
|
function StatRow({ children }) {
|
|
4332
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.XStack, { gap: "$
|
|
4361
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.XStack, { gap: "$1", width: "100%", alignItems: "stretch", children });
|
|
4333
4362
|
}
|
|
4334
4363
|
function StatValueText({
|
|
4335
4364
|
children,
|
|
@@ -4338,12 +4367,30 @@ function StatValueText({
|
|
|
4338
4367
|
}) {
|
|
4339
4368
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize, fontWeight: "700", color, children });
|
|
4340
4369
|
}
|
|
4370
|
+
function StatValue({
|
|
4371
|
+
value,
|
|
4372
|
+
unit,
|
|
4373
|
+
unitPosition,
|
|
4374
|
+
fontSize = "$2",
|
|
4375
|
+
unitFontSize = "$1",
|
|
4376
|
+
color
|
|
4377
|
+
}) {
|
|
4378
|
+
const hoistMarker = unitPosition === "prefix" && value.startsWith("<");
|
|
4379
|
+
const unitLabel = hoistMarker ? `<${unit}` : unit;
|
|
4380
|
+
const digits = hoistMarker ? value.slice(1) : value;
|
|
4381
|
+
const unitText = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize: unitFontSize, fontWeight: "700", tone: "soft", children: unitLabel });
|
|
4382
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.XStack, { alignItems: "baseline", gap: "$1", children: [
|
|
4383
|
+
unitPosition === "prefix" ? unitText : null,
|
|
4384
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValueText, { fontSize, color, children: digits }),
|
|
4385
|
+
unitPosition === "suffix" ? unitText : null
|
|
4386
|
+
] });
|
|
4387
|
+
}
|
|
4341
4388
|
function CompactGStatValue({ amount }) {
|
|
4342
4389
|
const [open, setOpen] = (0, import_react8.useState)(false);
|
|
4343
4390
|
const display = formatGValue(amount);
|
|
4344
4391
|
const exact = formatExactGAmount(amount);
|
|
4345
4392
|
if (!isGValueCompacted(amount)) {
|
|
4346
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4393
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValue, { value: display, unit: "G$", unitPosition: "suffix" });
|
|
4347
4394
|
}
|
|
4348
4395
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
4349
4396
|
import_ui9.XStack,
|
|
@@ -4359,7 +4406,7 @@ function CompactGStatValue({ amount }) {
|
|
|
4359
4406
|
onBlur: () => setOpen(false),
|
|
4360
4407
|
onPress: () => setOpen((prev) => !prev),
|
|
4361
4408
|
children: [
|
|
4362
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4409
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValue, { value: display, unit: "G$", unitPosition: "suffix" }),
|
|
4363
4410
|
open && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4364
4411
|
import_ui9.YStack,
|
|
4365
4412
|
{
|
|
@@ -4384,6 +4431,43 @@ function CompactGStatValue({ amount }) {
|
|
|
4384
4431
|
function formatUsdAmount2(usdMicro) {
|
|
4385
4432
|
return formatUsdMicroValue(usdMicro);
|
|
4386
4433
|
}
|
|
4434
|
+
function CreditBalanceCard({
|
|
4435
|
+
balance,
|
|
4436
|
+
monthlyCredit
|
|
4437
|
+
}) {
|
|
4438
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Card, { raised: true, borderWidth: 0, width: "100%", gap: "$2", children: [
|
|
4439
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize: "$1", tone: "soft", children: "Credit balance" }),
|
|
4440
|
+
balance !== null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4441
|
+
StatValue,
|
|
4442
|
+
{
|
|
4443
|
+
value: balance,
|
|
4444
|
+
unit: "US$",
|
|
4445
|
+
unitPosition: "prefix",
|
|
4446
|
+
fontSize: "$8",
|
|
4447
|
+
unitFontSize: "$5"
|
|
4448
|
+
}
|
|
4449
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Spinner, { size: "sm" }),
|
|
4450
|
+
monthlyCredit ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
4451
|
+
import_ui9.XStack,
|
|
4452
|
+
{
|
|
4453
|
+
alignSelf: "flex-start",
|
|
4454
|
+
alignItems: "center",
|
|
4455
|
+
gap: "$1",
|
|
4456
|
+
paddingHorizontal: "$2",
|
|
4457
|
+
paddingVertical: "$1",
|
|
4458
|
+
borderRadius: "$full",
|
|
4459
|
+
backgroundColor: "$infoMuted",
|
|
4460
|
+
children: [
|
|
4461
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.TrendingUp, { size: 14, color: "$primary" }),
|
|
4462
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Text, { fontSize: "$1", fontWeight: "700", color: "$primary", children: [
|
|
4463
|
+
monthlyCredit.startsWith("<") ? monthlyCredit : `~${monthlyCredit}`,
|
|
4464
|
+
" / month"
|
|
4465
|
+
] })
|
|
4466
|
+
]
|
|
4467
|
+
}
|
|
4468
|
+
) : null
|
|
4469
|
+
] });
|
|
4470
|
+
}
|
|
4387
4471
|
function CreditsManagementCard({ state, actions }) {
|
|
4388
4472
|
const [isClosing, setIsClosing] = (0, import_react8.useState)(false);
|
|
4389
4473
|
const [isWithdrawing, setIsWithdrawing] = (0, import_react8.useState)(false);
|
|
@@ -4408,7 +4492,7 @@ function CreditsManagementCard({ state, actions }) {
|
|
|
4408
4492
|
streamBonusPercent: state.streamBonusPercent
|
|
4409
4493
|
});
|
|
4410
4494
|
if (usdMicro <= 0n) return null;
|
|
4411
|
-
return
|
|
4495
|
+
return formatUsdMicroAmount(usdMicro.toString());
|
|
4412
4496
|
}, [
|
|
4413
4497
|
monthlyStreamG,
|
|
4414
4498
|
gdUsdPerToken,
|
|
@@ -4424,20 +4508,16 @@ function CreditsManagementCard({ state, actions }) {
|
|
|
4424
4508
|
const canWithdraw = Boolean(signerPrvKey) && hasWithdrawableBalance && Boolean(withdrawAmount.trim()) && !isWithdrawing;
|
|
4425
4509
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Card, { children: [
|
|
4426
4510
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Heading, { level: 6, children: "AI Credits" }),
|
|
4427
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
4428
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4429
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.
|
|
4430
|
-
"
|
|
4431
|
-
|
|
4432
|
-
] })
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
] }),
|
|
4438
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
|
|
4439
|
-
/* @__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" }) }),
|
|
4440
|
-
/* @__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" }) })
|
|
4511
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { gap: "$2", width: "100%", children: [
|
|
4512
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CreditBalanceCard, { balance: totalCreditDisplay, monthlyCredit: monthlyStreamUsdDisplay }),
|
|
4513
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
|
|
4514
|
+
/* @__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" }) }),
|
|
4515
|
+
/* @__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" }) })
|
|
4516
|
+
] }),
|
|
4517
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
|
|
4518
|
+
/* @__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" }) }),
|
|
4519
|
+
/* @__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" }) })
|
|
4520
|
+
] })
|
|
4441
4521
|
] }),
|
|
4442
4522
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { gap: "$1", width: "100%", children: [
|
|
4443
4523
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.XStack, { gap: "$1", alignItems: "center", children: [
|