@locusgraph/blocks 0.2.0 → 0.3.1
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/README.md +11 -11
- package/dist/billing/plan-price.d.ts +4 -0
- package/dist/billing/plan-price.js +70 -0
- package/dist/billing/{plan-options.d.ts → plans.d.ts} +2 -2
- package/dist/billing/plans.js +74 -0
- package/dist/billing/top-up.d.ts +11 -0
- package/dist/billing/top-up.js +108 -0
- package/dist/billing/wallet.d.ts +8 -0
- package/dist/billing/wallet.js +217 -0
- package/dist/dates/local-date.js +51 -7
- package/dist/index.d.ts +13 -8
- package/dist/index.js +13 -8
- package/dist/keys/{no-keys.d.ts → keys-empty.d.ts} +2 -2
- package/dist/keys/keys-empty.js +73 -0
- package/dist/keys/{keys-table.d.ts → keys.d.ts} +2 -2
- package/dist/keys/keys.js +151 -0
- package/dist/skeletons/keys-skeleton.d.ts +6 -0
- package/dist/skeletons/keys-skeleton.js +170 -0
- package/dist/skeletons/plans-skeleton.d.ts +7 -0
- package/dist/skeletons/plans-skeleton.js +94 -0
- package/dist/skeletons/top-up-skeleton.d.ts +5 -0
- package/dist/skeletons/top-up-skeleton.js +73 -0
- package/dist/skeletons/usage-skeleton.d.ts +6 -0
- package/dist/skeletons/usage-skeleton.js +88 -0
- package/dist/skeletons/wallet-skeleton.d.ts +5 -0
- package/dist/skeletons/wallet-skeleton.js +84 -0
- package/dist/types.d.ts +5 -1
- package/dist/types.js +1 -1
- package/dist/usage/quota.d.ts +4 -0
- package/dist/usage/quota.js +203 -0
- package/dist/usage/usage-alert.d.ts +11 -0
- package/dist/usage/usage-alert.js +222 -0
- package/dist/usage/usage.d.ts +8 -0
- package/dist/usage/usage.js +57 -0
- package/package.json +6 -6
- package/dist/billing/credit-packs.d.ts +0 -9
- package/dist/billing/credit-packs.js +0 -6
- package/dist/billing/plan-options.js +0 -8
- package/dist/billing/wallet-panel.d.ts +0 -8
- package/dist/billing/wallet-panel.js +0 -16
- package/dist/keys/keys-table.js +0 -9
- package/dist/keys/no-keys.js +0 -8
- package/dist/usage/quota-meter.d.ts +0 -4
- package/dist/usage/quota-meter.js +0 -13
- package/dist/usage/usage-attention.d.ts +0 -11
- package/dist/usage/usage-attention.js +0 -20
- package/dist/usage/usage-summary.d.ts +0 -8
- package/dist/usage/usage-summary.js +0 -6
package/README.md
CHANGED
|
@@ -13,22 +13,22 @@ pnpm add @locusgraph/blocks @locusgraph/components
|
|
|
13
13
|
|
|
14
14
|
| Block | Props |
|
|
15
15
|
|---|---|
|
|
16
|
-
| `
|
|
17
|
-
| `
|
|
18
|
-
| `
|
|
19
|
-
| `
|
|
20
|
-
| `
|
|
21
|
-
| `
|
|
22
|
-
| `
|
|
16
|
+
| `Usage` | `quotas`, optional `label`, `emptyText` |
|
|
17
|
+
| `Quota` | `quota`, a `QuotaData` (`key`, `period`, `used`, `included`) |
|
|
18
|
+
| `UsageAlert` | `balanceMicroUsd`, `quotas`, `paidPlan`, `buyCreditsHref`, `upgradeHref`, `linkComponent`. Renders nothing when credits are fine and no quota is over |
|
|
19
|
+
| `Wallet` | `balanceMicroUsd`, `debtMicroUsd`, `grants`. A Rule Grid cell |
|
|
20
|
+
| `TopUp` | `packs`, `onBuy(packId)`, `pending`. A Rule Grid cell |
|
|
21
|
+
| `Plans` | `plans`, `actionFor(plan)` for plans that are not current |
|
|
22
|
+
| `Keys` | `keys`, `actions(key)`, `highlightedId` to flash a just-created key. Dates render in the viewer's time zone after hydration |
|
|
23
23
|
| `LocalDate` | `value` (ISO string): UTC on the server, the viewer's time zone after hydration |
|
|
24
|
-
| `
|
|
24
|
+
| `KeysEmpty` | `newKeyHref` (omit for read-only roles), `linkComponent` |
|
|
25
25
|
|
|
26
|
-
`
|
|
26
|
+
`Wallet` and `TopUp` are cells, so put them in a `RuleGrid`:
|
|
27
27
|
|
|
28
28
|
```tsx
|
|
29
29
|
<RuleGrid columns={2}>
|
|
30
|
-
<
|
|
31
|
-
<
|
|
30
|
+
<Wallet balanceMicroUsd={wallet.balanceMicroUsd} grants={grants} />
|
|
31
|
+
<TopUp packs={wallet.packs} onBuy={buy} pending={pending} />
|
|
32
32
|
</RuleGrid>
|
|
33
33
|
```
|
|
34
34
|
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { formatCents } from "@locusgraph/utils";
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
const intervalLabel = {
|
|
5
|
+
month: "/month",
|
|
6
|
+
year: "/year"
|
|
7
|
+
};
|
|
8
|
+
export function PlanPrice(t0) {
|
|
9
|
+
const $ = _c(11);
|
|
10
|
+
const {
|
|
11
|
+
plan
|
|
12
|
+
} = t0;
|
|
13
|
+
if (plan.amountCents === undefined) {
|
|
14
|
+
let t1;
|
|
15
|
+
if ($[0] !== plan.price) {
|
|
16
|
+
t1 = /*#__PURE__*/_jsx("span", {
|
|
17
|
+
className: "font-heading text-xl font-semibold tracking-[-0.02em] tabular-nums",
|
|
18
|
+
children: plan.price
|
|
19
|
+
});
|
|
20
|
+
$[0] = plan.price;
|
|
21
|
+
$[1] = t1;
|
|
22
|
+
} else {
|
|
23
|
+
t1 = $[1];
|
|
24
|
+
}
|
|
25
|
+
return t1;
|
|
26
|
+
}
|
|
27
|
+
let t1;
|
|
28
|
+
if ($[2] !== plan.amountCents) {
|
|
29
|
+
t1 = formatCents(plan.amountCents);
|
|
30
|
+
$[2] = plan.amountCents;
|
|
31
|
+
$[3] = t1;
|
|
32
|
+
} else {
|
|
33
|
+
t1 = $[3];
|
|
34
|
+
}
|
|
35
|
+
let t2;
|
|
36
|
+
if ($[4] !== t1) {
|
|
37
|
+
t2 = /*#__PURE__*/_jsx("span", {
|
|
38
|
+
className: "font-heading text-2xl font-semibold tracking-[-0.02em] tabular-nums",
|
|
39
|
+
children: t1
|
|
40
|
+
});
|
|
41
|
+
$[4] = t1;
|
|
42
|
+
$[5] = t2;
|
|
43
|
+
} else {
|
|
44
|
+
t2 = $[5];
|
|
45
|
+
}
|
|
46
|
+
let t3;
|
|
47
|
+
if ($[6] !== plan.interval) {
|
|
48
|
+
t3 = plan.interval && /*#__PURE__*/_jsx("span", {
|
|
49
|
+
className: "text-sm text-muted-foreground",
|
|
50
|
+
children: intervalLabel[plan.interval]
|
|
51
|
+
});
|
|
52
|
+
$[6] = plan.interval;
|
|
53
|
+
$[7] = t3;
|
|
54
|
+
} else {
|
|
55
|
+
t3 = $[7];
|
|
56
|
+
}
|
|
57
|
+
let t4;
|
|
58
|
+
if ($[8] !== t2 || $[9] !== t3) {
|
|
59
|
+
t4 = /*#__PURE__*/_jsxs("span", {
|
|
60
|
+
className: "flex items-baseline gap-1",
|
|
61
|
+
children: [t2, t3]
|
|
62
|
+
});
|
|
63
|
+
$[8] = t2;
|
|
64
|
+
$[9] = t3;
|
|
65
|
+
$[10] = t4;
|
|
66
|
+
} else {
|
|
67
|
+
t4 = $[10];
|
|
68
|
+
}
|
|
69
|
+
return t4;
|
|
70
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type * as React from "react";
|
|
2
2
|
import type { PlanOffer } from "../types.js";
|
|
3
|
-
type
|
|
3
|
+
type PlansProps = {
|
|
4
4
|
plans: PlanOffer[];
|
|
5
5
|
actionFor?: (plan: PlanOffer) => React.ReactNode;
|
|
6
6
|
};
|
|
7
|
-
export declare function
|
|
7
|
+
export declare function Plans({ plans, actionFor }: PlansProps): React.JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { Badge, RuleGrid, RuleGridCell, RuleGridFooter, RuleGridTitle } from "@locusgraph/components";
|
|
3
|
+
import { PlanPrice } from "./plan-price.js";
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
export function Plans(t0) {
|
|
6
|
+
const $ = _c(8);
|
|
7
|
+
const {
|
|
8
|
+
plans,
|
|
9
|
+
actionFor
|
|
10
|
+
} = t0;
|
|
11
|
+
const t1 = plans.length >= 3 ? 3 : 2;
|
|
12
|
+
let t2;
|
|
13
|
+
if ($[0] !== actionFor || $[1] !== plans) {
|
|
14
|
+
let t3;
|
|
15
|
+
if ($[3] !== actionFor) {
|
|
16
|
+
t3 = plan => {
|
|
17
|
+
const action = plan.current ? null : actionFor?.(plan);
|
|
18
|
+
return /*#__PURE__*/_jsxs(RuleGridCell, {
|
|
19
|
+
"data-current": plan.current || undefined,
|
|
20
|
+
className: "gap-4",
|
|
21
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
22
|
+
className: "flex flex-col gap-2",
|
|
23
|
+
children: [/*#__PURE__*/_jsxs(RuleGridTitle, {
|
|
24
|
+
className: "flex min-h-6 items-center gap-2",
|
|
25
|
+
children: [plan.name, plan.current && /*#__PURE__*/_jsx(Badge, {
|
|
26
|
+
variant: "secondary",
|
|
27
|
+
children: "Current"
|
|
28
|
+
})]
|
|
29
|
+
}), /*#__PURE__*/_jsx(PlanPrice, {
|
|
30
|
+
plan: plan
|
|
31
|
+
})]
|
|
32
|
+
}), /*#__PURE__*/_jsx("ul", {
|
|
33
|
+
className: "flex flex-col gap-1.5 text-sm text-muted-foreground",
|
|
34
|
+
children: plan.points.map(_temp)
|
|
35
|
+
}), /*#__PURE__*/_jsx(RuleGridFooter, {
|
|
36
|
+
className: "mt-auto",
|
|
37
|
+
children: plan.current ? /*#__PURE__*/_jsx("p", {
|
|
38
|
+
className: "flex min-h-8 items-center text-sm text-muted-foreground",
|
|
39
|
+
children: "Your plan"
|
|
40
|
+
}) : action
|
|
41
|
+
})]
|
|
42
|
+
}, plan.name);
|
|
43
|
+
};
|
|
44
|
+
$[3] = actionFor;
|
|
45
|
+
$[4] = t3;
|
|
46
|
+
} else {
|
|
47
|
+
t3 = $[4];
|
|
48
|
+
}
|
|
49
|
+
t2 = plans.map(t3);
|
|
50
|
+
$[0] = actionFor;
|
|
51
|
+
$[1] = plans;
|
|
52
|
+
$[2] = t2;
|
|
53
|
+
} else {
|
|
54
|
+
t2 = $[2];
|
|
55
|
+
}
|
|
56
|
+
let t3;
|
|
57
|
+
if ($[5] !== t1 || $[6] !== t2) {
|
|
58
|
+
t3 = /*#__PURE__*/_jsx(RuleGrid, {
|
|
59
|
+
columns: t1,
|
|
60
|
+
children: t2
|
|
61
|
+
});
|
|
62
|
+
$[5] = t1;
|
|
63
|
+
$[6] = t2;
|
|
64
|
+
$[7] = t3;
|
|
65
|
+
} else {
|
|
66
|
+
t3 = $[7];
|
|
67
|
+
}
|
|
68
|
+
return t3;
|
|
69
|
+
}
|
|
70
|
+
function _temp(point) {
|
|
71
|
+
return /*#__PURE__*/_jsx("li", {
|
|
72
|
+
children: point
|
|
73
|
+
}, point);
|
|
74
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CreditPack } from "../types.js";
|
|
2
|
+
type TopUpProps = {
|
|
3
|
+
packs: CreditPack[];
|
|
4
|
+
onBuy: (packId: string) => void;
|
|
5
|
+
pending?: boolean;
|
|
6
|
+
pendingPackId?: string;
|
|
7
|
+
highlightedPackId?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function TopUp({ packs, onBuy, pending, pendingPackId, highlightedPackId, description, }: TopUpProps): import("react").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { Button, RuleGridCell, RuleGridDescription, RuleGridLabel, Spinner } from "@locusgraph/components";
|
|
3
|
+
import { centsToMicroUsd, formatCents, formatMicroUsd } from "@locusgraph/utils";
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
function hasBonus(pack) {
|
|
6
|
+
return centsToMicroUsd(pack.priceCents) !== pack.amountMicroUsd;
|
|
7
|
+
}
|
|
8
|
+
export function TopUp(t0) {
|
|
9
|
+
const $ = _c(19);
|
|
10
|
+
const {
|
|
11
|
+
packs,
|
|
12
|
+
onBuy,
|
|
13
|
+
pending: t1,
|
|
14
|
+
pendingPackId,
|
|
15
|
+
highlightedPackId,
|
|
16
|
+
description: t2
|
|
17
|
+
} = t0;
|
|
18
|
+
const pending = t1 === undefined ? false : t1;
|
|
19
|
+
const description = t2 === undefined ? "Pay once with Stripe. Credits never expire and never renew on their own." : t2;
|
|
20
|
+
const busy = pending || pendingPackId !== undefined;
|
|
21
|
+
let t3;
|
|
22
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
23
|
+
t3 = /*#__PURE__*/_jsx("span", {
|
|
24
|
+
className: "flex min-h-6 items-center",
|
|
25
|
+
children: /*#__PURE__*/_jsx(RuleGridLabel, {
|
|
26
|
+
children: "Buy credits"
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
$[0] = t3;
|
|
30
|
+
} else {
|
|
31
|
+
t3 = $[0];
|
|
32
|
+
}
|
|
33
|
+
let t4;
|
|
34
|
+
if ($[1] !== description) {
|
|
35
|
+
t4 = /*#__PURE__*/_jsxs("div", {
|
|
36
|
+
className: "flex flex-col gap-1.5",
|
|
37
|
+
children: [t3, /*#__PURE__*/_jsx(RuleGridDescription, {
|
|
38
|
+
children: description
|
|
39
|
+
})]
|
|
40
|
+
});
|
|
41
|
+
$[1] = description;
|
|
42
|
+
$[2] = t4;
|
|
43
|
+
} else {
|
|
44
|
+
t4 = $[2];
|
|
45
|
+
}
|
|
46
|
+
let t5;
|
|
47
|
+
if ($[3] !== busy || $[4] !== highlightedPackId || $[5] !== onBuy || $[6] !== packs || $[7] !== pendingPackId) {
|
|
48
|
+
let t6;
|
|
49
|
+
if ($[9] !== busy || $[10] !== highlightedPackId || $[11] !== onBuy || $[12] !== pendingPackId) {
|
|
50
|
+
t6 = pack => /*#__PURE__*/_jsxs(Button, {
|
|
51
|
+
variant: pack.id === highlightedPackId ? "default" : "outline",
|
|
52
|
+
disabled: busy,
|
|
53
|
+
"aria-busy": pack.id === pendingPackId || undefined,
|
|
54
|
+
onClick: () => onBuy(pack.id),
|
|
55
|
+
children: [pack.id === pendingPackId && /*#__PURE__*/_jsx(Spinner, {
|
|
56
|
+
"aria-hidden": "true",
|
|
57
|
+
role: undefined
|
|
58
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
59
|
+
className: "tabular-nums",
|
|
60
|
+
children: formatMicroUsd(pack.amountMicroUsd)
|
|
61
|
+
}), hasBonus(pack) && /*#__PURE__*/_jsxs("span", {
|
|
62
|
+
className: pack.id === highlightedPackId ? "tabular-nums opacity-75" : "font-medium text-good tabular-nums",
|
|
63
|
+
children: ["for ", formatCents(pack.priceCents)]
|
|
64
|
+
})]
|
|
65
|
+
}, pack.id);
|
|
66
|
+
$[9] = busy;
|
|
67
|
+
$[10] = highlightedPackId;
|
|
68
|
+
$[11] = onBuy;
|
|
69
|
+
$[12] = pendingPackId;
|
|
70
|
+
$[13] = t6;
|
|
71
|
+
} else {
|
|
72
|
+
t6 = $[13];
|
|
73
|
+
}
|
|
74
|
+
t5 = packs.map(t6);
|
|
75
|
+
$[3] = busy;
|
|
76
|
+
$[4] = highlightedPackId;
|
|
77
|
+
$[5] = onBuy;
|
|
78
|
+
$[6] = packs;
|
|
79
|
+
$[7] = pendingPackId;
|
|
80
|
+
$[8] = t5;
|
|
81
|
+
} else {
|
|
82
|
+
t5 = $[8];
|
|
83
|
+
}
|
|
84
|
+
let t6;
|
|
85
|
+
if ($[14] !== t5) {
|
|
86
|
+
t6 = /*#__PURE__*/_jsx("div", {
|
|
87
|
+
className: "flex flex-wrap gap-2",
|
|
88
|
+
children: t5
|
|
89
|
+
});
|
|
90
|
+
$[14] = t5;
|
|
91
|
+
$[15] = t6;
|
|
92
|
+
} else {
|
|
93
|
+
t6 = $[15];
|
|
94
|
+
}
|
|
95
|
+
let t7;
|
|
96
|
+
if ($[16] !== t4 || $[17] !== t6) {
|
|
97
|
+
t7 = /*#__PURE__*/_jsxs(RuleGridCell, {
|
|
98
|
+
className: "gap-4",
|
|
99
|
+
children: [t4, t6]
|
|
100
|
+
});
|
|
101
|
+
$[16] = t4;
|
|
102
|
+
$[17] = t6;
|
|
103
|
+
$[18] = t7;
|
|
104
|
+
} else {
|
|
105
|
+
t7 = $[18];
|
|
106
|
+
}
|
|
107
|
+
return t7;
|
|
108
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { WalletGrant } from "../types.js";
|
|
2
|
+
type WalletProps = {
|
|
3
|
+
balanceMicroUsd: number;
|
|
4
|
+
debtMicroUsd?: number;
|
|
5
|
+
grants: WalletGrant[];
|
|
6
|
+
};
|
|
7
|
+
export declare function Wallet({ balanceMicroUsd, debtMicroUsd, grants }: WalletProps): import("react").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { Badge, RuleGridCell, RuleGridLabel } from "@locusgraph/components";
|
|
3
|
+
import { balanceLevel, formatDate, formatMicroUsd } from "@locusgraph/utils";
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
const levelHint = {
|
|
6
|
+
low: {
|
|
7
|
+
badge: "Low",
|
|
8
|
+
text: "Add credits before usage stops.",
|
|
9
|
+
tone: "text-warn"
|
|
10
|
+
},
|
|
11
|
+
empty: {
|
|
12
|
+
badge: "Empty",
|
|
13
|
+
text: "Paid usage is paused until you add credits.",
|
|
14
|
+
tone: "text-destructive"
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
function GrantList(t0) {
|
|
18
|
+
const $ = _c(4);
|
|
19
|
+
const {
|
|
20
|
+
grants
|
|
21
|
+
} = t0;
|
|
22
|
+
let t1;
|
|
23
|
+
if ($[0] !== grants) {
|
|
24
|
+
t1 = grants.map(_temp);
|
|
25
|
+
$[0] = grants;
|
|
26
|
+
$[1] = t1;
|
|
27
|
+
} else {
|
|
28
|
+
t1 = $[1];
|
|
29
|
+
}
|
|
30
|
+
let t2;
|
|
31
|
+
if ($[2] !== t1) {
|
|
32
|
+
t2 = /*#__PURE__*/_jsx("ul", {
|
|
33
|
+
className: "flex flex-col divide-y divide-line",
|
|
34
|
+
children: t1
|
|
35
|
+
});
|
|
36
|
+
$[2] = t1;
|
|
37
|
+
$[3] = t2;
|
|
38
|
+
} else {
|
|
39
|
+
t2 = $[3];
|
|
40
|
+
}
|
|
41
|
+
return t2;
|
|
42
|
+
}
|
|
43
|
+
function _temp(grant) {
|
|
44
|
+
return /*#__PURE__*/_jsxs("li", {
|
|
45
|
+
className: "flex justify-between gap-4 py-2",
|
|
46
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
47
|
+
children: grant.label
|
|
48
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
49
|
+
className: "flex items-baseline gap-2 tabular-nums",
|
|
50
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
51
|
+
className: "font-medium text-foreground",
|
|
52
|
+
children: formatMicroUsd(grant.remainingMicroUsd)
|
|
53
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
54
|
+
className: "text-muted-foreground",
|
|
55
|
+
children: grant.expiresAt ? `expires ${formatDate(grant.expiresAt)}` : "never expires"
|
|
56
|
+
})]
|
|
57
|
+
})]
|
|
58
|
+
}, `${grant.label}:${grant.expiresAt}`);
|
|
59
|
+
}
|
|
60
|
+
export function Wallet(t0) {
|
|
61
|
+
const $ = _c(34);
|
|
62
|
+
const {
|
|
63
|
+
balanceMicroUsd,
|
|
64
|
+
debtMicroUsd: t1,
|
|
65
|
+
grants
|
|
66
|
+
} = t0;
|
|
67
|
+
const debtMicroUsd = t1 === undefined ? 0 : t1;
|
|
68
|
+
let t2;
|
|
69
|
+
if ($[0] !== balanceMicroUsd) {
|
|
70
|
+
t2 = balanceLevel(balanceMicroUsd);
|
|
71
|
+
$[0] = balanceMicroUsd;
|
|
72
|
+
$[1] = t2;
|
|
73
|
+
} else {
|
|
74
|
+
t2 = $[1];
|
|
75
|
+
}
|
|
76
|
+
const level = t2;
|
|
77
|
+
const hint = level === "fine" ? null : levelHint[level];
|
|
78
|
+
let t3;
|
|
79
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
80
|
+
t3 = /*#__PURE__*/_jsx(RuleGridLabel, {
|
|
81
|
+
children: "Prepaid credits"
|
|
82
|
+
});
|
|
83
|
+
$[2] = t3;
|
|
84
|
+
} else {
|
|
85
|
+
t3 = $[2];
|
|
86
|
+
}
|
|
87
|
+
let t4;
|
|
88
|
+
if ($[3] !== hint || $[4] !== level) {
|
|
89
|
+
t4 = hint && /*#__PURE__*/_jsx(Badge, {
|
|
90
|
+
variant: level === "empty" ? "destructive" : "secondary",
|
|
91
|
+
className: level === "low" ? "text-warn" : undefined,
|
|
92
|
+
children: hint.badge
|
|
93
|
+
});
|
|
94
|
+
$[3] = hint;
|
|
95
|
+
$[4] = level;
|
|
96
|
+
$[5] = t4;
|
|
97
|
+
} else {
|
|
98
|
+
t4 = $[5];
|
|
99
|
+
}
|
|
100
|
+
let t5;
|
|
101
|
+
if ($[6] !== t4) {
|
|
102
|
+
t5 = /*#__PURE__*/_jsxs("span", {
|
|
103
|
+
className: "flex min-h-6 items-center justify-between",
|
|
104
|
+
children: [t3, t4]
|
|
105
|
+
});
|
|
106
|
+
$[6] = t4;
|
|
107
|
+
$[7] = t5;
|
|
108
|
+
} else {
|
|
109
|
+
t5 = $[7];
|
|
110
|
+
}
|
|
111
|
+
const t6 = `font-heading text-3xl font-semibold tracking-[-0.02em] tabular-nums ${hint?.tone ?? ""}`;
|
|
112
|
+
let t7;
|
|
113
|
+
if ($[8] !== balanceMicroUsd) {
|
|
114
|
+
t7 = formatMicroUsd(balanceMicroUsd);
|
|
115
|
+
$[8] = balanceMicroUsd;
|
|
116
|
+
$[9] = t7;
|
|
117
|
+
} else {
|
|
118
|
+
t7 = $[9];
|
|
119
|
+
}
|
|
120
|
+
let t8;
|
|
121
|
+
if ($[10] !== t6 || $[11] !== t7) {
|
|
122
|
+
t8 = /*#__PURE__*/_jsx("span", {
|
|
123
|
+
className: t6,
|
|
124
|
+
children: t7
|
|
125
|
+
});
|
|
126
|
+
$[10] = t6;
|
|
127
|
+
$[11] = t7;
|
|
128
|
+
$[12] = t8;
|
|
129
|
+
} else {
|
|
130
|
+
t8 = $[12];
|
|
131
|
+
}
|
|
132
|
+
let t9;
|
|
133
|
+
if ($[13] !== hint) {
|
|
134
|
+
t9 = hint && /*#__PURE__*/_jsx("p", {
|
|
135
|
+
className: "text-sm text-muted-foreground",
|
|
136
|
+
children: hint.text
|
|
137
|
+
});
|
|
138
|
+
$[13] = hint;
|
|
139
|
+
$[14] = t9;
|
|
140
|
+
} else {
|
|
141
|
+
t9 = $[14];
|
|
142
|
+
}
|
|
143
|
+
let t10;
|
|
144
|
+
if ($[15] !== t8 || $[16] !== t9) {
|
|
145
|
+
t10 = /*#__PURE__*/_jsxs("div", {
|
|
146
|
+
className: "flex flex-col gap-1",
|
|
147
|
+
children: [t8, t9]
|
|
148
|
+
});
|
|
149
|
+
$[15] = t8;
|
|
150
|
+
$[16] = t9;
|
|
151
|
+
$[17] = t10;
|
|
152
|
+
} else {
|
|
153
|
+
t10 = $[17];
|
|
154
|
+
}
|
|
155
|
+
let t11;
|
|
156
|
+
if ($[18] !== grants) {
|
|
157
|
+
t11 = grants.length > 0 && /*#__PURE__*/_jsx(GrantList, {
|
|
158
|
+
grants: grants
|
|
159
|
+
});
|
|
160
|
+
$[18] = grants;
|
|
161
|
+
$[19] = t11;
|
|
162
|
+
} else {
|
|
163
|
+
t11 = $[19];
|
|
164
|
+
}
|
|
165
|
+
let t12;
|
|
166
|
+
if ($[20] !== grants.length || $[21] !== level) {
|
|
167
|
+
t12 = grants.length === 0 && level !== "empty" && /*#__PURE__*/_jsx("p", {
|
|
168
|
+
className: "text-muted-foreground",
|
|
169
|
+
children: "No credit grants to show."
|
|
170
|
+
});
|
|
171
|
+
$[20] = grants.length;
|
|
172
|
+
$[21] = level;
|
|
173
|
+
$[22] = t12;
|
|
174
|
+
} else {
|
|
175
|
+
t12 = $[22];
|
|
176
|
+
}
|
|
177
|
+
let t13;
|
|
178
|
+
if ($[23] !== debtMicroUsd) {
|
|
179
|
+
t13 = debtMicroUsd > 0 && /*#__PURE__*/_jsxs("p", {
|
|
180
|
+
className: "text-destructive",
|
|
181
|
+
children: [formatMicroUsd(debtMicroUsd), " owed. It comes out of the next credits you add."]
|
|
182
|
+
});
|
|
183
|
+
$[23] = debtMicroUsd;
|
|
184
|
+
$[24] = t13;
|
|
185
|
+
} else {
|
|
186
|
+
t13 = $[24];
|
|
187
|
+
}
|
|
188
|
+
let t14;
|
|
189
|
+
if ($[25] !== t11 || $[26] !== t12 || $[27] !== t13) {
|
|
190
|
+
t14 = /*#__PURE__*/_jsxs("div", {
|
|
191
|
+
className: "flex flex-col gap-3 text-sm",
|
|
192
|
+
children: [t11, t12, t13]
|
|
193
|
+
});
|
|
194
|
+
$[25] = t11;
|
|
195
|
+
$[26] = t12;
|
|
196
|
+
$[27] = t13;
|
|
197
|
+
$[28] = t14;
|
|
198
|
+
} else {
|
|
199
|
+
t14 = $[28];
|
|
200
|
+
}
|
|
201
|
+
let t15;
|
|
202
|
+
if ($[29] !== level || $[30] !== t10 || $[31] !== t14 || $[32] !== t5) {
|
|
203
|
+
t15 = /*#__PURE__*/_jsxs(RuleGridCell, {
|
|
204
|
+
"data-level": level,
|
|
205
|
+
className: "gap-4",
|
|
206
|
+
children: [t5, t10, t14]
|
|
207
|
+
});
|
|
208
|
+
$[29] = level;
|
|
209
|
+
$[30] = t10;
|
|
210
|
+
$[31] = t14;
|
|
211
|
+
$[32] = t5;
|
|
212
|
+
$[33] = t15;
|
|
213
|
+
} else {
|
|
214
|
+
t15 = $[33];
|
|
215
|
+
}
|
|
216
|
+
return t15;
|
|
217
|
+
}
|
package/dist/dates/local-date.js
CHANGED
|
@@ -1,10 +1,54 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { c as _c } from "react/compiler-runtime";
|
|
3
4
|
import { useEffect, useState } from "react";
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
const utcFormat = new Intl.DateTimeFormat("en-US", {
|
|
7
|
+
dateStyle: "medium",
|
|
8
|
+
timeZone: "UTC"
|
|
9
|
+
});
|
|
10
|
+
const localFormat = new Intl.DateTimeFormat("en-US", {
|
|
11
|
+
dateStyle: "medium"
|
|
12
|
+
});
|
|
13
|
+
export function LocalDate(t0) {
|
|
14
|
+
const $ = _c(8);
|
|
15
|
+
const {
|
|
16
|
+
value
|
|
17
|
+
} = t0;
|
|
18
|
+
const [hydrated, setHydrated] = useState(false);
|
|
19
|
+
let t1;
|
|
20
|
+
let t2;
|
|
21
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
22
|
+
t1 = () => setHydrated(true);
|
|
23
|
+
t2 = [];
|
|
24
|
+
$[0] = t1;
|
|
25
|
+
$[1] = t2;
|
|
26
|
+
} else {
|
|
27
|
+
t1 = $[0];
|
|
28
|
+
t2 = $[1];
|
|
29
|
+
}
|
|
30
|
+
useEffect(t1, t2);
|
|
31
|
+
const t3 = hydrated ? localFormat : utcFormat;
|
|
32
|
+
let t4;
|
|
33
|
+
if ($[2] !== t3 || $[3] !== value) {
|
|
34
|
+
t4 = t3.format(new Date(value));
|
|
35
|
+
$[2] = t3;
|
|
36
|
+
$[3] = value;
|
|
37
|
+
$[4] = t4;
|
|
38
|
+
} else {
|
|
39
|
+
t4 = $[4];
|
|
40
|
+
}
|
|
41
|
+
let t5;
|
|
42
|
+
if ($[5] !== t4 || $[6] !== value) {
|
|
43
|
+
t5 = /*#__PURE__*/_jsx("time", {
|
|
44
|
+
dateTime: value,
|
|
45
|
+
children: t4
|
|
46
|
+
});
|
|
47
|
+
$[5] = t4;
|
|
48
|
+
$[6] = value;
|
|
49
|
+
$[7] = t5;
|
|
50
|
+
} else {
|
|
51
|
+
t5 = $[7];
|
|
52
|
+
}
|
|
53
|
+
return t5;
|
|
10
54
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
export { Plans } from "./billing/plans.js";
|
|
2
|
+
export { TopUp } from "./billing/top-up.js";
|
|
3
|
+
export { Wallet } from "./billing/wallet.js";
|
|
4
4
|
export { LocalDate } from "./dates/local-date.js";
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
5
|
+
export { Keys } from "./keys/keys.js";
|
|
6
|
+
export { KeysEmpty } from "./keys/keys-empty.js";
|
|
7
|
+
export { KeysSkeleton } from "./skeletons/keys-skeleton.js";
|
|
8
|
+
export { PlansSkeleton } from "./skeletons/plans-skeleton.js";
|
|
9
|
+
export { TopUpSkeleton } from "./skeletons/top-up-skeleton.js";
|
|
10
|
+
export { UsageSkeleton } from "./skeletons/usage-skeleton.js";
|
|
11
|
+
export { WalletSkeleton } from "./skeletons/wallet-skeleton.js";
|
|
7
12
|
export * from "./types.js";
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
13
|
+
export { Quota } from "./usage/quota.js";
|
|
14
|
+
export { Usage } from "./usage/usage.js";
|
|
15
|
+
export { UsageAlert } from "./usage/usage-alert.js";
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
export { Plans } from "./billing/plans.js";
|
|
2
|
+
export { TopUp } from "./billing/top-up.js";
|
|
3
|
+
export { Wallet } from "./billing/wallet.js";
|
|
4
4
|
export { LocalDate } from "./dates/local-date.js";
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
5
|
+
export { Keys } from "./keys/keys.js";
|
|
6
|
+
export { KeysEmpty } from "./keys/keys-empty.js";
|
|
7
|
+
export { KeysSkeleton } from "./skeletons/keys-skeleton.js";
|
|
8
|
+
export { PlansSkeleton } from "./skeletons/plans-skeleton.js";
|
|
9
|
+
export { TopUpSkeleton } from "./skeletons/top-up-skeleton.js";
|
|
10
|
+
export { UsageSkeleton } from "./skeletons/usage-skeleton.js";
|
|
11
|
+
export { WalletSkeleton } from "./skeletons/wallet-skeleton.js";
|
|
7
12
|
export * from "./types.js";
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
13
|
+
export { Quota } from "./usage/quota.js";
|
|
14
|
+
export { Usage } from "./usage/usage.js";
|
|
15
|
+
export { UsageAlert } from "./usage/usage-alert.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { LinkComponent } from "../types.js";
|
|
2
|
-
type
|
|
2
|
+
type KeysEmptyProps = {
|
|
3
3
|
newKeyHref?: string;
|
|
4
4
|
description?: string;
|
|
5
5
|
linkComponent?: LinkComponent | "a";
|
|
6
6
|
};
|
|
7
|
-
export declare function
|
|
7
|
+
export declare function KeysEmpty({ newKeyHref, description, linkComponent: Link, }: KeysEmptyProps): import("react").JSX.Element;
|
|
8
8
|
export {};
|