@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,70 +1,26 @@
1
- import { c as _c } from "react/compiler-runtime";
2
1
  import { formatCents } from "@locusgraph/utils";
3
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
3
  const intervalLabel = {
5
4
  month: "/month",
6
5
  year: "/year"
7
6
  };
8
- export function PlanPrice(t0) {
9
- const $ = _c(11);
10
- const {
11
- plan
12
- } = t0;
7
+ export function PlanPrice({
8
+ plan
9
+ }) {
13
10
  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
11
+ return /*#__PURE__*/_jsx("span", {
12
+ className: "font-heading text-xl font-semibold tracking-[-0.02em] tabular-nums",
13
+ children: plan.price
40
14
  });
41
- $[4] = t1;
42
- $[5] = t2;
43
- } else {
44
- t2 = $[5];
45
15
  }
46
- let t3;
47
- if ($[6] !== plan.interval) {
48
- t3 = plan.interval && /*#__PURE__*/_jsx("span", {
16
+ return /*#__PURE__*/_jsxs("span", {
17
+ className: "flex items-baseline gap-1",
18
+ children: [/*#__PURE__*/_jsx("span", {
19
+ className: "font-heading text-2xl font-semibold tracking-[-0.02em] tabular-nums",
20
+ children: formatCents(plan.amountCents)
21
+ }), plan.interval && /*#__PURE__*/_jsx("span", {
49
22
  className: "text-sm text-muted-foreground",
50
23
  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;
24
+ })]
25
+ });
70
26
  }
@@ -1,74 +1,41 @@
1
- import { c as _c } from "react/compiler-runtime";
2
1
  import { Badge, RuleGrid, RuleGridCell, RuleGridFooter, RuleGridTitle } from "@locusgraph/components";
3
2
  import { PlanPrice } from "./plan-price.js";
4
3
  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
4
+ export function Plans({
5
+ plans,
6
+ actionFor
7
+ }) {
8
+ return /*#__PURE__*/_jsx(RuleGrid, {
9
+ columns: plans.length >= 3 ? 3 : 2,
10
+ children: plans.map(plan => {
11
+ const action = plan.current ? null : actionFor?.(plan);
12
+ return /*#__PURE__*/_jsxs(RuleGridCell, {
13
+ "data-current": plan.current || undefined,
14
+ className: "gap-4",
15
+ children: [/*#__PURE__*/_jsxs("div", {
16
+ className: "flex flex-col gap-2",
17
+ children: [/*#__PURE__*/_jsxs(RuleGridTitle, {
18
+ className: "flex min-h-6 items-center gap-2",
19
+ children: [plan.name, plan.current && /*#__PURE__*/_jsx(Badge, {
20
+ variant: "secondary",
21
+ children: "Current"
31
22
  })]
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
23
+ }), /*#__PURE__*/_jsx(PlanPrice, {
24
+ plan: plan
41
25
  })]
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);
26
+ }), /*#__PURE__*/_jsx("ul", {
27
+ className: "flex flex-col gap-1.5 text-sm text-muted-foreground",
28
+ children: plan.points.map(point => /*#__PURE__*/_jsx("li", {
29
+ children: point
30
+ }, point))
31
+ }), /*#__PURE__*/_jsx(RuleGridFooter, {
32
+ className: "mt-auto",
33
+ children: plan.current ? /*#__PURE__*/_jsx("p", {
34
+ className: "flex min-h-8 items-center text-sm text-muted-foreground",
35
+ children: "Your plan"
36
+ }) : action
37
+ })]
38
+ }, plan.name);
39
+ })
40
+ });
74
41
  }
@@ -1,53 +1,33 @@
1
- import { c as _c } from "react/compiler-runtime";
2
1
  import { Button, RuleGridCell, RuleGridDescription, RuleGridLabel, Spinner } from "@locusgraph/components";
3
2
  import { centsToMicroUsd, formatCents, formatMicroUsd } from "@locusgraph/utils";
4
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
4
  function hasBonus(pack) {
6
5
  return centsToMicroUsd(pack.priceCents) !== pack.amountMicroUsd;
7
6
  }
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;
7
+ export function TopUp({
8
+ packs,
9
+ onBuy,
10
+ pending = false,
11
+ pendingPackId,
12
+ highlightedPackId,
13
+ description = "Pay once with Stripe. Credits never expire and never renew on their own."
14
+ }) {
20
15
  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", {
16
+ return /*#__PURE__*/_jsxs(RuleGridCell, {
17
+ className: "gap-4",
18
+ children: [/*#__PURE__*/_jsxs("div", {
36
19
  className: "flex flex-col gap-1.5",
37
- children: [t3, /*#__PURE__*/_jsx(RuleGridDescription, {
20
+ children: [/*#__PURE__*/_jsx("span", {
21
+ className: "flex min-h-6 items-center",
22
+ children: /*#__PURE__*/_jsx(RuleGridLabel, {
23
+ children: "Buy credits"
24
+ })
25
+ }), /*#__PURE__*/_jsx(RuleGridDescription, {
38
26
  children: description
39
27
  })]
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, {
28
+ }), /*#__PURE__*/_jsx("div", {
29
+ className: "flex flex-wrap gap-2",
30
+ children: packs.map(pack => /*#__PURE__*/_jsxs(Button, {
51
31
  variant: pack.id === highlightedPackId ? "default" : "outline",
52
32
  disabled: busy,
53
33
  "aria-busy": pack.id === pendingPackId || undefined,
@@ -62,47 +42,7 @@ export function TopUp(t0) {
62
42
  className: pack.id === highlightedPackId ? "tabular-nums opacity-75" : "font-medium text-good tabular-nums",
63
43
  children: ["for ", formatCents(pack.priceCents)]
64
44
  })]
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;
45
+ }, pack.id))
46
+ })]
47
+ });
108
48
  }
@@ -1,4 +1,3 @@
1
- import { c as _c } from "react/compiler-runtime";
2
1
  import { Badge, RuleGridCell, RuleGridLabel } from "@locusgraph/components";
3
2
  import { balanceLevel, formatDate, formatMicroUsd } from "@locusgraph/utils";
4
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -14,204 +13,67 @@ const levelHint = {
14
13
  tone: "text-destructive"
15
14
  }
16
15
  };
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",
16
+ function GrantList({
17
+ grants
18
+ }) {
19
+ return /*#__PURE__*/_jsx("ul", {
20
+ className: "flex flex-col divide-y divide-line",
21
+ children: grants.map(grant => /*#__PURE__*/_jsxs("li", {
22
+ className: "flex justify-between gap-4 py-2",
50
23
  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"
24
+ children: grant.label
25
+ }), /*#__PURE__*/_jsxs("span", {
26
+ className: "flex items-baseline gap-2 tabular-nums",
27
+ children: [/*#__PURE__*/_jsx("span", {
28
+ className: "font-medium text-foreground",
29
+ children: formatMicroUsd(grant.remainingMicroUsd)
30
+ }), /*#__PURE__*/_jsx("span", {
31
+ className: "text-muted-foreground",
32
+ children: grant.expiresAt ? `expires ${formatDate(grant.expiresAt)}` : "never expires"
33
+ })]
56
34
  })]
57
- })]
58
- }, `${grant.label}:${grant.expiresAt}`);
35
+ }, `${grant.label}:${grant.expiresAt}`))
36
+ });
59
37
  }
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;
38
+ export function Wallet({
39
+ balanceMicroUsd,
40
+ debtMicroUsd = 0,
41
+ grants
42
+ }) {
43
+ const level = balanceLevel(balanceMicroUsd);
77
44
  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", {
45
+ return /*#__PURE__*/_jsxs(RuleGridCell, {
46
+ "data-level": level,
47
+ className: "gap-4",
48
+ children: [/*#__PURE__*/_jsxs("span", {
103
49
  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", {
50
+ children: [/*#__PURE__*/_jsx(RuleGridLabel, {
51
+ children: "Prepaid credits"
52
+ }), hint && /*#__PURE__*/_jsx(Badge, {
53
+ variant: level === "empty" ? "destructive" : "secondary",
54
+ className: level === "low" ? "text-warn" : undefined,
55
+ children: hint.badge
56
+ })]
57
+ }), /*#__PURE__*/_jsxs("div", {
146
58
  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", {
59
+ children: [/*#__PURE__*/_jsx("span", {
60
+ className: `font-heading text-3xl font-semibold tracking-[-0.02em] tabular-nums ${hint?.tone ?? ""}`,
61
+ children: formatMicroUsd(balanceMicroUsd)
62
+ }), hint && /*#__PURE__*/_jsx("p", {
63
+ className: "text-sm text-muted-foreground",
64
+ children: hint.text
65
+ })]
66
+ }), /*#__PURE__*/_jsxs("div", {
191
67
  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;
68
+ children: [grants.length > 0 && /*#__PURE__*/_jsx(GrantList, {
69
+ grants: grants
70
+ }), grants.length === 0 && level !== "empty" && /*#__PURE__*/_jsx("p", {
71
+ className: "text-muted-foreground",
72
+ children: "No credit grants to show."
73
+ }), debtMicroUsd > 0 && /*#__PURE__*/_jsxs("p", {
74
+ className: "text-destructive",
75
+ children: [formatMicroUsd(debtMicroUsd), " owed. It comes out of the next credits you add."]
76
+ })]
77
+ })]
78
+ });
217
79
  }