@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
|
@@ -4167,10 +4167,15 @@ import {
|
|
|
4167
4167
|
Button as Button4,
|
|
4168
4168
|
ButtonText as ButtonText4,
|
|
4169
4169
|
Card as Card6,
|
|
4170
|
+
Coins,
|
|
4171
|
+
Gift,
|
|
4170
4172
|
Heading as Heading4,
|
|
4171
4173
|
Input as Input2,
|
|
4174
|
+
Repeat,
|
|
4172
4175
|
Spinner as Spinner4,
|
|
4173
4176
|
Text as Text7,
|
|
4177
|
+
TrendingUp,
|
|
4178
|
+
Wallet,
|
|
4174
4179
|
XStack as XStack7,
|
|
4175
4180
|
YStack as YStack7
|
|
4176
4181
|
} from "@goodwidget/ui";
|
|
@@ -4182,14 +4187,43 @@ var WITHDRAW_TOOLTIP = "Withdraws principal to your payer wallet (not bonus). Re
|
|
|
4182
4187
|
|
|
4183
4188
|
// src/components/manage/CreditsManagementCard.tsx
|
|
4184
4189
|
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
4185
|
-
function StatCell({
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
+
function StatCell({
|
|
4191
|
+
label,
|
|
4192
|
+
icon: Glyph,
|
|
4193
|
+
children
|
|
4194
|
+
}) {
|
|
4195
|
+
return /* @__PURE__ */ jsxs7(
|
|
4196
|
+
Card6,
|
|
4197
|
+
{
|
|
4198
|
+
raised: true,
|
|
4199
|
+
borderWidth: 0,
|
|
4200
|
+
flexGrow: 1,
|
|
4201
|
+
flexBasis: 0,
|
|
4202
|
+
padding: "$3",
|
|
4203
|
+
gap: "$1",
|
|
4204
|
+
children: [
|
|
4205
|
+
Glyph ? /* @__PURE__ */ jsx7(
|
|
4206
|
+
XStack7,
|
|
4207
|
+
{
|
|
4208
|
+
width: 28,
|
|
4209
|
+
height: 28,
|
|
4210
|
+
borderRadius: "$2",
|
|
4211
|
+
backgroundColor: "$background",
|
|
4212
|
+
alignItems: "center",
|
|
4213
|
+
justifyContent: "center",
|
|
4214
|
+
children: /* @__PURE__ */ jsx7(Glyph, { size: 16, color: "$colorSoft" })
|
|
4215
|
+
}
|
|
4216
|
+
) : null,
|
|
4217
|
+
/* @__PURE__ */ jsxs7(YStack7, { children: [
|
|
4218
|
+
/* @__PURE__ */ jsx7(Text7, { fontSize: "$1", tone: "soft", children: label }),
|
|
4219
|
+
children
|
|
4220
|
+
] })
|
|
4221
|
+
]
|
|
4222
|
+
}
|
|
4223
|
+
);
|
|
4190
4224
|
}
|
|
4191
4225
|
function StatRow({ children }) {
|
|
4192
|
-
return /* @__PURE__ */ jsx7(XStack7, { gap: "$
|
|
4226
|
+
return /* @__PURE__ */ jsx7(XStack7, { gap: "$1", width: "100%", alignItems: "stretch", children });
|
|
4193
4227
|
}
|
|
4194
4228
|
function StatValueText({
|
|
4195
4229
|
children,
|
|
@@ -4198,12 +4232,30 @@ function StatValueText({
|
|
|
4198
4232
|
}) {
|
|
4199
4233
|
return /* @__PURE__ */ jsx7(Text7, { fontSize, fontWeight: "700", color, children });
|
|
4200
4234
|
}
|
|
4235
|
+
function StatValue({
|
|
4236
|
+
value,
|
|
4237
|
+
unit,
|
|
4238
|
+
unitPosition,
|
|
4239
|
+
fontSize = "$2",
|
|
4240
|
+
unitFontSize = "$1",
|
|
4241
|
+
color
|
|
4242
|
+
}) {
|
|
4243
|
+
const hoistMarker = unitPosition === "prefix" && value.startsWith("<");
|
|
4244
|
+
const unitLabel = hoistMarker ? `<${unit}` : unit;
|
|
4245
|
+
const digits = hoistMarker ? value.slice(1) : value;
|
|
4246
|
+
const unitText = /* @__PURE__ */ jsx7(Text7, { fontSize: unitFontSize, fontWeight: "700", tone: "soft", children: unitLabel });
|
|
4247
|
+
return /* @__PURE__ */ jsxs7(XStack7, { alignItems: "baseline", gap: "$1", children: [
|
|
4248
|
+
unitPosition === "prefix" ? unitText : null,
|
|
4249
|
+
/* @__PURE__ */ jsx7(StatValueText, { fontSize, color, children: digits }),
|
|
4250
|
+
unitPosition === "suffix" ? unitText : null
|
|
4251
|
+
] });
|
|
4252
|
+
}
|
|
4201
4253
|
function CompactGStatValue({ amount }) {
|
|
4202
4254
|
const [open, setOpen] = useState8(false);
|
|
4203
4255
|
const display = formatGValue(amount);
|
|
4204
4256
|
const exact = formatExactGAmount(amount);
|
|
4205
4257
|
if (!isGValueCompacted(amount)) {
|
|
4206
|
-
return /* @__PURE__ */ jsx7(
|
|
4258
|
+
return /* @__PURE__ */ jsx7(StatValue, { value: display, unit: "G$", unitPosition: "suffix" });
|
|
4207
4259
|
}
|
|
4208
4260
|
return /* @__PURE__ */ jsxs7(
|
|
4209
4261
|
XStack7,
|
|
@@ -4219,7 +4271,7 @@ function CompactGStatValue({ amount }) {
|
|
|
4219
4271
|
onBlur: () => setOpen(false),
|
|
4220
4272
|
onPress: () => setOpen((prev) => !prev),
|
|
4221
4273
|
children: [
|
|
4222
|
-
/* @__PURE__ */ jsx7(
|
|
4274
|
+
/* @__PURE__ */ jsx7(StatValue, { value: display, unit: "G$", unitPosition: "suffix" }),
|
|
4223
4275
|
open && /* @__PURE__ */ jsx7(
|
|
4224
4276
|
YStack7,
|
|
4225
4277
|
{
|
|
@@ -4244,6 +4296,43 @@ function CompactGStatValue({ amount }) {
|
|
|
4244
4296
|
function formatUsdAmount2(usdMicro) {
|
|
4245
4297
|
return formatUsdMicroValue(usdMicro);
|
|
4246
4298
|
}
|
|
4299
|
+
function CreditBalanceCard({
|
|
4300
|
+
balance,
|
|
4301
|
+
monthlyCredit
|
|
4302
|
+
}) {
|
|
4303
|
+
return /* @__PURE__ */ jsxs7(Card6, { raised: true, borderWidth: 0, width: "100%", gap: "$2", children: [
|
|
4304
|
+
/* @__PURE__ */ jsx7(Text7, { fontSize: "$1", tone: "soft", children: "Credit balance" }),
|
|
4305
|
+
balance !== null ? /* @__PURE__ */ jsx7(
|
|
4306
|
+
StatValue,
|
|
4307
|
+
{
|
|
4308
|
+
value: balance,
|
|
4309
|
+
unit: "US$",
|
|
4310
|
+
unitPosition: "prefix",
|
|
4311
|
+
fontSize: "$8",
|
|
4312
|
+
unitFontSize: "$5"
|
|
4313
|
+
}
|
|
4314
|
+
) : /* @__PURE__ */ jsx7(Spinner4, { size: "sm" }),
|
|
4315
|
+
monthlyCredit ? /* @__PURE__ */ jsxs7(
|
|
4316
|
+
XStack7,
|
|
4317
|
+
{
|
|
4318
|
+
alignSelf: "flex-start",
|
|
4319
|
+
alignItems: "center",
|
|
4320
|
+
gap: "$1",
|
|
4321
|
+
paddingHorizontal: "$2",
|
|
4322
|
+
paddingVertical: "$1",
|
|
4323
|
+
borderRadius: "$full",
|
|
4324
|
+
backgroundColor: "$infoMuted",
|
|
4325
|
+
children: [
|
|
4326
|
+
/* @__PURE__ */ jsx7(TrendingUp, { size: 14, color: "$primary" }),
|
|
4327
|
+
/* @__PURE__ */ jsxs7(Text7, { fontSize: "$1", fontWeight: "700", color: "$primary", children: [
|
|
4328
|
+
monthlyCredit.startsWith("<") ? monthlyCredit : `~${monthlyCredit}`,
|
|
4329
|
+
" / month"
|
|
4330
|
+
] })
|
|
4331
|
+
]
|
|
4332
|
+
}
|
|
4333
|
+
) : null
|
|
4334
|
+
] });
|
|
4335
|
+
}
|
|
4247
4336
|
function CreditsManagementCard({ state, actions }) {
|
|
4248
4337
|
const [isClosing, setIsClosing] = useState8(false);
|
|
4249
4338
|
const [isWithdrawing, setIsWithdrawing] = useState8(false);
|
|
@@ -4268,7 +4357,7 @@ function CreditsManagementCard({ state, actions }) {
|
|
|
4268
4357
|
streamBonusPercent: state.streamBonusPercent
|
|
4269
4358
|
});
|
|
4270
4359
|
if (usdMicro <= 0n) return null;
|
|
4271
|
-
return
|
|
4360
|
+
return formatUsdMicroAmount(usdMicro.toString());
|
|
4272
4361
|
}, [
|
|
4273
4362
|
monthlyStreamG,
|
|
4274
4363
|
gdUsdPerToken,
|
|
@@ -4284,20 +4373,16 @@ function CreditsManagementCard({ state, actions }) {
|
|
|
4284
4373
|
const canWithdraw = Boolean(signerPrvKey) && hasWithdrawableBalance && Boolean(withdrawAmount.trim()) && !isWithdrawing;
|
|
4285
4374
|
return /* @__PURE__ */ jsxs7(Card6, { children: [
|
|
4286
4375
|
/* @__PURE__ */ jsx7(Heading4, { level: 6, children: "AI Credits" }),
|
|
4287
|
-
/* @__PURE__ */ jsxs7(
|
|
4288
|
-
/* @__PURE__ */ jsx7(
|
|
4289
|
-
/* @__PURE__ */
|
|
4290
|
-
"
|
|
4291
|
-
|
|
4292
|
-
] })
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
] }),
|
|
4298
|
-
/* @__PURE__ */ jsxs7(StatRow, { children: [
|
|
4299
|
-
/* @__PURE__ */ jsx7(StatCell, { label: "Bonus (US$)", children: totalBonusDisplay !== null ? /* @__PURE__ */ jsx7(StatValueText, { children: totalBonusDisplay }) : /* @__PURE__ */ jsx7(Spinner4, { size: "sm" }) }),
|
|
4300
|
-
/* @__PURE__ */ jsx7(StatCell, { label: "Withdrawable (US$)", children: withdrawableDisplay !== null ? /* @__PURE__ */ jsx7(StatValueText, { children: withdrawableDisplay }) : /* @__PURE__ */ jsx7(Spinner4, { size: "sm" }) })
|
|
4376
|
+
/* @__PURE__ */ jsxs7(YStack7, { gap: "$2", width: "100%", children: [
|
|
4377
|
+
/* @__PURE__ */ jsx7(CreditBalanceCard, { balance: totalCreditDisplay, monthlyCredit: monthlyStreamUsdDisplay }),
|
|
4378
|
+
/* @__PURE__ */ jsxs7(StatRow, { children: [
|
|
4379
|
+
/* @__PURE__ */ jsx7(StatCell, { label: "Deposited", icon: Coins, children: /* @__PURE__ */ jsx7(CompactGStatValue, { amount: totalGdDepositedG ?? "0.00" }) }),
|
|
4380
|
+
/* @__PURE__ */ jsx7(StatCell, { label: "Monthly Streaming", icon: Repeat, children: /* @__PURE__ */ jsx7(CompactGStatValue, { amount: monthlyStreamG ?? "0.00" }) })
|
|
4381
|
+
] }),
|
|
4382
|
+
/* @__PURE__ */ jsxs7(StatRow, { children: [
|
|
4383
|
+
/* @__PURE__ */ jsx7(StatCell, { label: "Bonus", icon: Gift, children: totalBonusDisplay !== null ? /* @__PURE__ */ jsx7(StatValue, { value: totalBonusDisplay, unit: "US$", unitPosition: "prefix" }) : /* @__PURE__ */ jsx7(Spinner4, { size: "sm" }) }),
|
|
4384
|
+
/* @__PURE__ */ jsx7(StatCell, { label: "Withdrawable", icon: Wallet, children: withdrawableDisplay !== null ? /* @__PURE__ */ jsx7(StatValue, { value: withdrawableDisplay, unit: "US$", unitPosition: "prefix" }) : /* @__PURE__ */ jsx7(Spinner4, { size: "sm" }) })
|
|
4385
|
+
] })
|
|
4301
4386
|
] }),
|
|
4302
4387
|
/* @__PURE__ */ jsxs7(YStack7, { gap: "$1", width: "100%", children: [
|
|
4303
4388
|
/* @__PURE__ */ jsxs7(XStack7, { gap: "$1", alignItems: "center", children: [
|
|
@@ -6826,4 +6911,4 @@ export {
|
|
|
6826
6911
|
useAiCreditsAdapter,
|
|
6827
6912
|
AiCreditsWidget
|
|
6828
6913
|
};
|
|
6829
|
-
//# sourceMappingURL=chunk-
|
|
6914
|
+
//# sourceMappingURL=chunk-3QY3YZDH.js.map
|