@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/index.js
CHANGED
package/dist/mocked/index.cjs
CHANGED
|
@@ -4163,14 +4163,43 @@ var WITHDRAW_TOOLTIP = "Withdraws principal to your payer wallet (not bonus). Re
|
|
|
4163
4163
|
|
|
4164
4164
|
// src/components/manage/CreditsManagementCard.tsx
|
|
4165
4165
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
4166
|
-
function StatCell({
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4166
|
+
function StatCell({
|
|
4167
|
+
label,
|
|
4168
|
+
icon: Glyph,
|
|
4169
|
+
children
|
|
4170
|
+
}) {
|
|
4171
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
4172
|
+
import_ui9.Card,
|
|
4173
|
+
{
|
|
4174
|
+
raised: true,
|
|
4175
|
+
borderWidth: 0,
|
|
4176
|
+
flexGrow: 1,
|
|
4177
|
+
flexBasis: 0,
|
|
4178
|
+
padding: "$3",
|
|
4179
|
+
gap: "$1",
|
|
4180
|
+
children: [
|
|
4181
|
+
Glyph ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4182
|
+
import_ui9.XStack,
|
|
4183
|
+
{
|
|
4184
|
+
width: 28,
|
|
4185
|
+
height: 28,
|
|
4186
|
+
borderRadius: "$2",
|
|
4187
|
+
backgroundColor: "$background",
|
|
4188
|
+
alignItems: "center",
|
|
4189
|
+
justifyContent: "center",
|
|
4190
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Glyph, { size: 16, color: "$colorSoft" })
|
|
4191
|
+
}
|
|
4192
|
+
) : null,
|
|
4193
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { children: [
|
|
4194
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize: "$1", tone: "soft", children: label }),
|
|
4195
|
+
children
|
|
4196
|
+
] })
|
|
4197
|
+
]
|
|
4198
|
+
}
|
|
4199
|
+
);
|
|
4171
4200
|
}
|
|
4172
4201
|
function StatRow({ children }) {
|
|
4173
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.XStack, { gap: "$
|
|
4202
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.XStack, { gap: "$1", width: "100%", alignItems: "stretch", children });
|
|
4174
4203
|
}
|
|
4175
4204
|
function StatValueText({
|
|
4176
4205
|
children,
|
|
@@ -4179,12 +4208,30 @@ function StatValueText({
|
|
|
4179
4208
|
}) {
|
|
4180
4209
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize, fontWeight: "700", color, children });
|
|
4181
4210
|
}
|
|
4211
|
+
function StatValue({
|
|
4212
|
+
value,
|
|
4213
|
+
unit,
|
|
4214
|
+
unitPosition,
|
|
4215
|
+
fontSize = "$2",
|
|
4216
|
+
unitFontSize = "$1",
|
|
4217
|
+
color
|
|
4218
|
+
}) {
|
|
4219
|
+
const hoistMarker = unitPosition === "prefix" && value.startsWith("<");
|
|
4220
|
+
const unitLabel = hoistMarker ? `<${unit}` : unit;
|
|
4221
|
+
const digits = hoistMarker ? value.slice(1) : value;
|
|
4222
|
+
const unitText = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize: unitFontSize, fontWeight: "700", tone: "soft", children: unitLabel });
|
|
4223
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.XStack, { alignItems: "baseline", gap: "$1", children: [
|
|
4224
|
+
unitPosition === "prefix" ? unitText : null,
|
|
4225
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValueText, { fontSize, color, children: digits }),
|
|
4226
|
+
unitPosition === "suffix" ? unitText : null
|
|
4227
|
+
] });
|
|
4228
|
+
}
|
|
4182
4229
|
function CompactGStatValue({ amount }) {
|
|
4183
4230
|
const [open, setOpen] = (0, import_react8.useState)(false);
|
|
4184
4231
|
const display = formatGValue(amount);
|
|
4185
4232
|
const exact = formatExactGAmount(amount);
|
|
4186
4233
|
if (!isGValueCompacted(amount)) {
|
|
4187
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4234
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValue, { value: display, unit: "G$", unitPosition: "suffix" });
|
|
4188
4235
|
}
|
|
4189
4236
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
4190
4237
|
import_ui9.XStack,
|
|
@@ -4200,7 +4247,7 @@ function CompactGStatValue({ amount }) {
|
|
|
4200
4247
|
onBlur: () => setOpen(false),
|
|
4201
4248
|
onPress: () => setOpen((prev) => !prev),
|
|
4202
4249
|
children: [
|
|
4203
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4250
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValue, { value: display, unit: "G$", unitPosition: "suffix" }),
|
|
4204
4251
|
open && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4205
4252
|
import_ui9.YStack,
|
|
4206
4253
|
{
|
|
@@ -4225,6 +4272,43 @@ function CompactGStatValue({ amount }) {
|
|
|
4225
4272
|
function formatUsdAmount2(usdMicro) {
|
|
4226
4273
|
return formatUsdMicroValue(usdMicro);
|
|
4227
4274
|
}
|
|
4275
|
+
function CreditBalanceCard({
|
|
4276
|
+
balance,
|
|
4277
|
+
monthlyCredit
|
|
4278
|
+
}) {
|
|
4279
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Card, { raised: true, borderWidth: 0, width: "100%", gap: "$2", children: [
|
|
4280
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize: "$1", tone: "soft", children: "Credit balance" }),
|
|
4281
|
+
balance !== null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4282
|
+
StatValue,
|
|
4283
|
+
{
|
|
4284
|
+
value: balance,
|
|
4285
|
+
unit: "US$",
|
|
4286
|
+
unitPosition: "prefix",
|
|
4287
|
+
fontSize: "$8",
|
|
4288
|
+
unitFontSize: "$5"
|
|
4289
|
+
}
|
|
4290
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Spinner, { size: "sm" }),
|
|
4291
|
+
monthlyCredit ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
4292
|
+
import_ui9.XStack,
|
|
4293
|
+
{
|
|
4294
|
+
alignSelf: "flex-start",
|
|
4295
|
+
alignItems: "center",
|
|
4296
|
+
gap: "$1",
|
|
4297
|
+
paddingHorizontal: "$2",
|
|
4298
|
+
paddingVertical: "$1",
|
|
4299
|
+
borderRadius: "$full",
|
|
4300
|
+
backgroundColor: "$infoMuted",
|
|
4301
|
+
children: [
|
|
4302
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.TrendingUp, { size: 14, color: "$primary" }),
|
|
4303
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Text, { fontSize: "$1", fontWeight: "700", color: "$primary", children: [
|
|
4304
|
+
monthlyCredit.startsWith("<") ? monthlyCredit : `~${monthlyCredit}`,
|
|
4305
|
+
" / month"
|
|
4306
|
+
] })
|
|
4307
|
+
]
|
|
4308
|
+
}
|
|
4309
|
+
) : null
|
|
4310
|
+
] });
|
|
4311
|
+
}
|
|
4228
4312
|
function CreditsManagementCard({ state, actions }) {
|
|
4229
4313
|
const [isClosing, setIsClosing] = (0, import_react8.useState)(false);
|
|
4230
4314
|
const [isWithdrawing, setIsWithdrawing] = (0, import_react8.useState)(false);
|
|
@@ -4249,7 +4333,7 @@ function CreditsManagementCard({ state, actions }) {
|
|
|
4249
4333
|
streamBonusPercent: state.streamBonusPercent
|
|
4250
4334
|
});
|
|
4251
4335
|
if (usdMicro <= 0n) return null;
|
|
4252
|
-
return
|
|
4336
|
+
return formatUsdMicroAmount(usdMicro.toString());
|
|
4253
4337
|
}, [
|
|
4254
4338
|
monthlyStreamG,
|
|
4255
4339
|
gdUsdPerToken,
|
|
@@ -4265,20 +4349,16 @@ function CreditsManagementCard({ state, actions }) {
|
|
|
4265
4349
|
const canWithdraw = Boolean(signerPrvKey) && hasWithdrawableBalance && Boolean(withdrawAmount.trim()) && !isWithdrawing;
|
|
4266
4350
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Card, { children: [
|
|
4267
4351
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Heading, { level: 6, children: "AI Credits" }),
|
|
4268
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
4269
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4270
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.
|
|
4271
|
-
"
|
|
4272
|
-
|
|
4273
|
-
] })
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
] }),
|
|
4279
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
|
|
4280
|
-
/* @__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" }) }),
|
|
4281
|
-
/* @__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" }) })
|
|
4352
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { gap: "$2", width: "100%", children: [
|
|
4353
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CreditBalanceCard, { balance: totalCreditDisplay, monthlyCredit: monthlyStreamUsdDisplay }),
|
|
4354
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
|
|
4355
|
+
/* @__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" }) }),
|
|
4356
|
+
/* @__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" }) })
|
|
4357
|
+
] }),
|
|
4358
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
|
|
4359
|
+
/* @__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" }) }),
|
|
4360
|
+
/* @__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" }) })
|
|
4361
|
+
] })
|
|
4282
4362
|
] }),
|
|
4283
4363
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { gap: "$1", width: "100%", children: [
|
|
4284
4364
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.XStack, { gap: "$1", alignItems: "center", children: [
|