@locusgraph/blocks 0.3.1 → 0.3.2

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.
@@ -1,4 +1,3 @@
1
- import { c as _c } from "react/compiler-runtime";
2
1
  import { Warning as CircleAlertIcon } from "@carbon/icons-react";
3
2
  import { Alert, AlertDescription, AlertTitle, Button } from "@locusgraph/components";
4
3
  import { balanceLevel, formatCount, formatMicroUsd, quotaStatus } from "@locusgraph/utils";
@@ -13,210 +12,55 @@ const toneClasses = {
13
12
  warn: "bg-warn/5 [&>svg]:text-warn",
14
13
  destructive: "bg-destructive/5 text-card-foreground [&>svg]:text-destructive"
15
14
  };
16
- export function UsageAlert(t0) {
17
- const $ = _c(49);
18
- const {
19
- balanceMicroUsd,
20
- quotas,
21
- paidPlan,
22
- buyCreditsHref,
23
- upgradeHref,
24
- linkComponent: t1
25
- } = t0;
26
- const Link = t1 === undefined ? "a" : t1;
27
- let T0;
28
- let T1;
29
- let empty;
30
- let level;
31
- let t2;
32
- let t3;
33
- let t4;
34
- let t5;
35
- let t6;
36
- let t7;
37
- let t8;
38
- let upgradeFirst;
39
- if ($[0] !== balanceMicroUsd || $[1] !== paidPlan || $[2] !== quotas) {
40
- t8 = Symbol.for("react.early_return_sentinel");
41
- bb0: {
42
- level = balanceMicroUsd === null ? "fine" : balanceLevel(balanceMicroUsd);
43
- const over = quotas.filter(_temp);
44
- if (level === "fine" && over.length === 0) {
45
- t8 = null;
46
- break bb0;
47
- }
48
- empty = level === "empty";
49
- upgradeFirst = !paidPlan && over.length > 0;
50
- T1 = Alert;
51
- t5 = toneClasses[empty ? "destructive" : "warn"];
52
- if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
53
- t6 = /*#__PURE__*/_jsx(CircleAlertIcon, {});
54
- $[15] = t6;
55
- } else {
56
- t6 = $[15];
57
- }
58
- t7 = /*#__PURE__*/_jsx(AlertTitle, {
59
- children: attentionTitle(level, over.length)
60
- });
61
- T0 = AlertDescription;
62
- t4 = "flex flex-col items-start gap-3";
63
- t2 = "flex flex-col gap-1";
64
- t3 = over.map(_temp2);
65
- }
66
- $[0] = balanceMicroUsd;
67
- $[1] = paidPlan;
68
- $[2] = quotas;
69
- $[3] = T0;
70
- $[4] = T1;
71
- $[5] = empty;
72
- $[6] = level;
73
- $[7] = t2;
74
- $[8] = t3;
75
- $[9] = t4;
76
- $[10] = t5;
77
- $[11] = t6;
78
- $[12] = t7;
79
- $[13] = t8;
80
- $[14] = upgradeFirst;
81
- } else {
82
- T0 = $[3];
83
- T1 = $[4];
84
- empty = $[5];
85
- level = $[6];
86
- t2 = $[7];
87
- t3 = $[8];
88
- t4 = $[9];
89
- t5 = $[10];
90
- t6 = $[11];
91
- t7 = $[12];
92
- t8 = $[13];
93
- upgradeFirst = $[14];
94
- }
95
- if (t8 !== Symbol.for("react.early_return_sentinel")) {
96
- return t8;
97
- }
98
- let t9;
99
- if ($[16] !== balanceMicroUsd || $[17] !== empty || $[18] !== level) {
100
- t9 = balanceMicroUsd !== null && level !== "fine" && /*#__PURE__*/_jsx("li", {
101
- children: empty ? "Paid usage is paused until you add credits." : `${formatMicroUsd(balanceMicroUsd)} of credits left.`
102
- });
103
- $[16] = balanceMicroUsd;
104
- $[17] = empty;
105
- $[18] = level;
106
- $[19] = t9;
107
- } else {
108
- t9 = $[19];
109
- }
110
- let t10;
111
- if ($[20] !== t2 || $[21] !== t3 || $[22] !== t9) {
112
- t10 = /*#__PURE__*/_jsxs("ul", {
113
- className: t2,
114
- children: [t3, t9]
115
- });
116
- $[20] = t2;
117
- $[21] = t3;
118
- $[22] = t9;
119
- $[23] = t10;
120
- } else {
121
- t10 = $[23];
122
- }
123
- let t11;
124
- if ($[24] !== Link || $[25] !== paidPlan || $[26] !== upgradeFirst || $[27] !== upgradeHref) {
125
- t11 = !paidPlan && /*#__PURE__*/_jsx(Button, {
126
- asChild: true,
127
- size: "sm",
128
- variant: upgradeFirst ? "default" : "ghost",
129
- children: /*#__PURE__*/_jsx(Link, {
130
- href: upgradeHref,
131
- children: "Upgrade to Pro"
132
- })
133
- });
134
- $[24] = Link;
135
- $[25] = paidPlan;
136
- $[26] = upgradeFirst;
137
- $[27] = upgradeHref;
138
- $[28] = t11;
139
- } else {
140
- t11 = $[28];
141
- }
142
- const t12 = upgradeFirst ? "ghost" : "default";
143
- let t13;
144
- if ($[29] !== Link || $[30] !== buyCreditsHref) {
145
- t13 = /*#__PURE__*/_jsx(Link, {
146
- href: buyCreditsHref,
147
- children: "Buy credits"
148
- });
149
- $[29] = Link;
150
- $[30] = buyCreditsHref;
151
- $[31] = t13;
152
- } else {
153
- t13 = $[31];
154
- }
155
- let t14;
156
- if ($[32] !== t12 || $[33] !== t13) {
157
- t14 = /*#__PURE__*/_jsx(Button, {
158
- asChild: true,
159
- size: "sm",
160
- variant: t12,
161
- children: t13
162
- });
163
- $[32] = t12;
164
- $[33] = t13;
165
- $[34] = t14;
166
- } else {
167
- t14 = $[34];
168
- }
169
- let t15;
170
- if ($[35] !== t11 || $[36] !== t14) {
171
- t15 = /*#__PURE__*/_jsxs("div", {
172
- className: "flex flex-wrap items-center gap-2",
173
- children: [t11, t14]
174
- });
175
- $[35] = t11;
176
- $[36] = t14;
177
- $[37] = t15;
178
- } else {
179
- t15 = $[37];
180
- }
181
- let t16;
182
- if ($[38] !== T0 || $[39] !== t10 || $[40] !== t15 || $[41] !== t4) {
183
- t16 = /*#__PURE__*/_jsxs(T0, {
184
- className: t4,
185
- children: [t10, t15]
186
- });
187
- $[38] = T0;
188
- $[39] = t10;
189
- $[40] = t15;
190
- $[41] = t4;
191
- $[42] = t16;
192
- } else {
193
- t16 = $[42];
194
- }
195
- let t17;
196
- if ($[43] !== T1 || $[44] !== t16 || $[45] !== t5 || $[46] !== t6 || $[47] !== t7) {
197
- t17 = /*#__PURE__*/_jsxs(T1, {
198
- className: t5,
199
- children: [t6, t7, t16]
200
- });
201
- $[43] = T1;
202
- $[44] = t16;
203
- $[45] = t5;
204
- $[46] = t6;
205
- $[47] = t7;
206
- $[48] = t17;
207
- } else {
208
- t17 = $[48];
209
- }
210
- return t17;
211
- }
212
- function _temp2(quota_0) {
213
- return /*#__PURE__*/_jsxs("li", {
214
- children: [/*#__PURE__*/_jsx("span", {
215
- className: quota_0.label ? undefined : "font-mono",
216
- children: quota_0.label ?? quota_0.key
217
- }), " ", "is at ", formatCount(quota_0.used), " of ", formatCount(quota_0.included), " ", periodLabel(quota_0.period), "."]
218
- }, quota_0.key);
219
- }
220
- function _temp(quota) {
221
- return quotaStatus(quota) === "over";
15
+ export function UsageAlert({
16
+ balanceMicroUsd,
17
+ quotas,
18
+ paidPlan,
19
+ buyCreditsHref,
20
+ upgradeHref,
21
+ linkComponent: Link = "a"
22
+ }) {
23
+ const level = balanceMicroUsd === null ? "fine" : balanceLevel(balanceMicroUsd);
24
+ const over = quotas.filter(quota => quotaStatus(quota) === "over");
25
+ if (level === "fine" && over.length === 0) return null;
26
+ const empty = level === "empty";
27
+ const upgradeFirst = !paidPlan && over.length > 0;
28
+ return /*#__PURE__*/_jsxs(Alert, {
29
+ className: toneClasses[empty ? "destructive" : "warn"],
30
+ children: [/*#__PURE__*/_jsx(CircleAlertIcon, {}), /*#__PURE__*/_jsx(AlertTitle, {
31
+ children: attentionTitle(level, over.length)
32
+ }), /*#__PURE__*/_jsxs(AlertDescription, {
33
+ className: "flex flex-col items-start gap-3",
34
+ children: [/*#__PURE__*/_jsxs("ul", {
35
+ className: "flex flex-col gap-1",
36
+ children: [over.map(quota => /*#__PURE__*/_jsxs("li", {
37
+ children: [/*#__PURE__*/_jsx("span", {
38
+ className: quota.label ? undefined : "font-mono",
39
+ children: quota.label ?? quota.key
40
+ }), " ", "is at ", formatCount(quota.used), " of ", formatCount(quota.included), " ", periodLabel(quota.period), "."]
41
+ }, quota.key)), balanceMicroUsd !== null && level !== "fine" && /*#__PURE__*/_jsx("li", {
42
+ children: empty ? "Paid usage is paused until you add credits." : `${formatMicroUsd(balanceMicroUsd)} of credits left.`
43
+ })]
44
+ }), /*#__PURE__*/_jsxs("div", {
45
+ className: "flex flex-wrap items-center gap-2",
46
+ children: [!paidPlan && /*#__PURE__*/_jsx(Button, {
47
+ asChild: true,
48
+ size: "sm",
49
+ variant: upgradeFirst ? "default" : "ghost",
50
+ children: /*#__PURE__*/_jsx(Link, {
51
+ href: upgradeHref,
52
+ children: "Upgrade to Pro"
53
+ })
54
+ }), /*#__PURE__*/_jsx(Button, {
55
+ asChild: true,
56
+ size: "sm",
57
+ variant: upgradeFirst ? "ghost" : "default",
58
+ children: /*#__PURE__*/_jsx(Link, {
59
+ href: buyCreditsHref,
60
+ children: "Buy credits"
61
+ })
62
+ })]
63
+ })]
64
+ })]
65
+ });
222
66
  }
@@ -1,57 +1,23 @@
1
- import { c as _c } from "react/compiler-runtime";
2
1
  import { RuleGrid, RuleGridCell, RuleGridLabel } from "@locusgraph/components";
3
2
  import { Quota } from "./quota.js";
4
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
- export function Usage(t0) {
6
- const $ = _c(8);
7
- const {
8
- quotas,
9
- label: t1,
10
- emptyText: t2
11
- } = t0;
12
- const label = t1 === undefined ? "Usage" : t1;
13
- const emptyText = t2 === undefined ? "No plan includes metered usage yet." : t2;
14
- let t3;
15
- if ($[0] !== label) {
16
- t3 = /*#__PURE__*/_jsx(RuleGridLabel, {
17
- children: label
18
- });
19
- $[0] = label;
20
- $[1] = t3;
21
- } else {
22
- t3 = $[1];
23
- }
24
- let t4;
25
- if ($[2] !== emptyText || $[3] !== quotas) {
26
- t4 = quotas.length > 0 ? quotas.map(_temp) : /*#__PURE__*/_jsx("p", {
27
- className: "text-sm text-muted-foreground",
28
- children: emptyText
29
- });
30
- $[2] = emptyText;
31
- $[3] = quotas;
32
- $[4] = t4;
33
- } else {
34
- t4 = $[4];
35
- }
36
- let t5;
37
- if ($[5] !== t3 || $[6] !== t4) {
38
- t5 = /*#__PURE__*/_jsx(RuleGrid, {
39
- columns: 1,
40
- children: /*#__PURE__*/_jsxs(RuleGridCell, {
41
- className: "gap-5",
42
- children: [t3, t4]
43
- })
44
- });
45
- $[5] = t3;
46
- $[6] = t4;
47
- $[7] = t5;
48
- } else {
49
- t5 = $[7];
50
- }
51
- return t5;
52
- }
53
- function _temp(quota) {
54
- return /*#__PURE__*/_jsx(Quota, {
55
- quota: quota
56
- }, quota.key);
4
+ export function Usage({
5
+ quotas,
6
+ label = "Usage",
7
+ emptyText = "No plan includes metered usage yet."
8
+ }) {
9
+ return /*#__PURE__*/_jsx(RuleGrid, {
10
+ columns: 1,
11
+ children: /*#__PURE__*/_jsxs(RuleGridCell, {
12
+ className: "gap-5",
13
+ children: [/*#__PURE__*/_jsx(RuleGridLabel, {
14
+ children: label
15
+ }), quotas.length > 0 ? quotas.map(quota => /*#__PURE__*/_jsx(Quota, {
16
+ quota: quota
17
+ }, quota.key)) : /*#__PURE__*/_jsx("p", {
18
+ className: "text-sm text-muted-foreground",
19
+ children: emptyText
20
+ })]
21
+ })
22
+ });
57
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@locusgraph/blocks",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Product sections built from @locusgraph/components: usage meters and alerts, wallet, credit packs, plan options and API keys.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -29,7 +29,7 @@
29
29
  "provenance": true
30
30
  },
31
31
  "peerDependencies": {
32
- "@locusgraph/components": "^0.2.1",
32
+ "@locusgraph/components": "^0.2.2",
33
33
  "react": "^19.2.0",
34
34
  "react-dom": "^19.2.0"
35
35
  },
@@ -38,7 +38,7 @@
38
38
  "@locusgraph/utils": "0.1.1"
39
39
  },
40
40
  "devDependencies": {
41
- "@locusgraph/components": "0.2.1",
41
+ "@locusgraph/components": "0.2.2",
42
42
  "@locusgraph/config": "0.1.1",
43
43
  "@types/node": "^22.0.0",
44
44
  "@types/react": "^19.2.0",