@tutti-os/commerce 0.0.213
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/LICENSE +201 -0
- package/README.md +30 -0
- package/dist/assets/registration-credits-bg.png +0 -0
- package/dist/assets/registration-credits-bg.png.d.ts +2 -0
- package/dist/assets/star-free.png +0 -0
- package/dist/assets/star-free.png.d.ts +2 -0
- package/dist/assets/star-lite.png +0 -0
- package/dist/assets/star-lite.png.d.ts +2 -0
- package/dist/assets/star-pro.png +0 -0
- package/dist/assets/star-pro.png.d.ts +2 -0
- package/dist/assets/star-ultra.png +0 -0
- package/dist/assets/star-ultra.png.d.ts +2 -0
- package/dist/chunk-L6YQE3QG.js +46 -0
- package/dist/chunk-L6YQE3QG.js.map +1 -0
- package/dist/contracts-I0M2ZTJA.d.ts +26 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/react/index.d.ts +46 -0
- package/dist/react/index.js +231 -0
- package/dist/react/index.js.map +1 -0
- package/dist/runtime-assets/registration-credits-bg-url.d.ts +3 -0
- package/dist/runtime-assets/registration-credits-bg-url.js +6 -0
- package/dist/runtime-assets/registration-credits-bg-url.js.map +1 -0
- package/dist/runtime-assets/star-free-url.d.ts +3 -0
- package/dist/runtime-assets/star-free-url.js +6 -0
- package/dist/runtime-assets/star-free-url.js.map +1 -0
- package/dist/runtime-assets/star-lite-url.d.ts +3 -0
- package/dist/runtime-assets/star-lite-url.js +6 -0
- package/dist/runtime-assets/star-lite-url.js.map +1 -0
- package/dist/runtime-assets/star-pro-url.d.ts +3 -0
- package/dist/runtime-assets/star-pro-url.js +6 -0
- package/dist/runtime-assets/star-pro-url.js.map +1 -0
- package/dist/runtime-assets/star-ultra-url.d.ts +3 -0
- package/dist/runtime-assets/star-ultra-url.js +6 -0
- package/dist/runtime-assets/star-ultra-url.js.map +1 -0
- package/package.json +95 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025-2026 The Tutti Authors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# `@tutti-os/commerce`
|
|
2
|
+
|
|
3
|
+
Host-neutral Commerce contracts, policies, visual assets, and React
|
|
4
|
+
presentation for Tutti products.
|
|
5
|
+
|
|
6
|
+
The package does not fetch APIs or own authentication, feature flags,
|
|
7
|
+
navigation, clipboard, notifications, Electron, or VM state. Product hosts
|
|
8
|
+
provide normalized data, labels, links, and callbacks.
|
|
9
|
+
|
|
10
|
+
The Account shell (avatar, popover, sign-in/out, settings, and UID copy)
|
|
11
|
+
belongs to each Host. `CommerceMenuContent` renders only membership, credits,
|
|
12
|
+
and account-center rows.
|
|
13
|
+
|
|
14
|
+
Host actions may be asynchronous. `CommerceMenuContent` catches rejected
|
|
15
|
+
external-link actions and forwards them to the optional `onActionError`
|
|
16
|
+
callback; the Host owns user-facing failure notification.
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import {
|
|
20
|
+
resolveInsufficientCreditsSemantic,
|
|
21
|
+
resolveMembershipAction
|
|
22
|
+
} from "@tutti-os/commerce";
|
|
23
|
+
import {
|
|
24
|
+
CommerceMenuContent,
|
|
25
|
+
MembershipTierIcon
|
|
26
|
+
} from "@tutti-os/commerce/react";
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`basic` is the canonical tier key for the Basic plan. It intentionally maps to
|
|
30
|
+
the existing Lite visual asset for parity with the Tutti desktop product.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// src/core/membershipPolicy.ts
|
|
2
|
+
function resolveMembershipAction(membershipAccess) {
|
|
3
|
+
switch (membershipAccess) {
|
|
4
|
+
case "free":
|
|
5
|
+
case "inactive":
|
|
6
|
+
return "upgrade-membership";
|
|
7
|
+
case "active":
|
|
8
|
+
return "recharge-credits";
|
|
9
|
+
default:
|
|
10
|
+
return "view-credit-plans";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function resolveInsufficientCreditsSemantic(membershipAccess) {
|
|
14
|
+
const action = resolveMembershipAction(membershipAccess);
|
|
15
|
+
switch (action) {
|
|
16
|
+
case "upgrade-membership":
|
|
17
|
+
return { message: "upgrade-membership", action };
|
|
18
|
+
case "recharge-credits":
|
|
19
|
+
return { message: "recharge-credits", action };
|
|
20
|
+
default:
|
|
21
|
+
return { message: "credits-unavailable", action };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// src/core/tierVisual.ts
|
|
26
|
+
var TIER_VISUALS = {
|
|
27
|
+
basic: "lite",
|
|
28
|
+
lite: "lite",
|
|
29
|
+
pro: "pro",
|
|
30
|
+
ultra: "ultra",
|
|
31
|
+
free: "free"
|
|
32
|
+
};
|
|
33
|
+
function resolveMembershipTierVisual(tierKey) {
|
|
34
|
+
const canonicalKey = tierKey?.trim().toLowerCase();
|
|
35
|
+
if (!canonicalKey) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return TIER_VISUALS[canonicalKey] ?? null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
resolveMembershipAction,
|
|
43
|
+
resolveInsufficientCreditsSemantic,
|
|
44
|
+
resolveMembershipTierVisual
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=chunk-L6YQE3QG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/membershipPolicy.ts","../src/core/tierVisual.ts"],"sourcesContent":["import type {\n CommerceMembershipAction,\n MembershipAccessState\n} from \"./contracts\";\n\nexport interface InsufficientCreditsSemantic {\n message: \"upgrade-membership\" | \"recharge-credits\" | \"credits-unavailable\";\n action: CommerceMembershipAction;\n}\n\nexport function resolveMembershipAction(\n membershipAccess: MembershipAccessState | null | undefined\n): CommerceMembershipAction {\n switch (membershipAccess) {\n case \"free\":\n case \"inactive\":\n return \"upgrade-membership\";\n case \"active\":\n return \"recharge-credits\";\n default:\n return \"view-credit-plans\";\n }\n}\n\nexport function resolveInsufficientCreditsSemantic(\n membershipAccess: MembershipAccessState | null | undefined\n): InsufficientCreditsSemantic {\n const action = resolveMembershipAction(membershipAccess);\n switch (action) {\n case \"upgrade-membership\":\n return { message: \"upgrade-membership\", action };\n case \"recharge-credits\":\n return { message: \"recharge-credits\", action };\n default:\n return { message: \"credits-unavailable\", action };\n }\n}\n","import type { MembershipTierVisual } from \"./contracts\";\n\nconst TIER_VISUALS: Readonly<Record<string, MembershipTierVisual>> = {\n basic: \"lite\",\n lite: \"lite\",\n pro: \"pro\",\n ultra: \"ultra\",\n free: \"free\"\n};\n\nexport function resolveMembershipTierVisual(\n tierKey: string | null | undefined\n): MembershipTierVisual | null {\n const canonicalKey = tierKey?.trim().toLowerCase();\n if (!canonicalKey) {\n return null;\n }\n return TIER_VISUALS[canonicalKey] ?? null;\n}\n"],"mappings":";AAUO,SAAS,wBACd,kBAC0B;AAC1B,UAAQ,kBAAkB;AAAA,IACxB,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAEO,SAAS,mCACd,kBAC6B;AAC7B,QAAM,SAAS,wBAAwB,gBAAgB;AACvD,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO,EAAE,SAAS,sBAAsB,OAAO;AAAA,IACjD,KAAK;AACH,aAAO,EAAE,SAAS,oBAAoB,OAAO;AAAA,IAC/C;AACE,aAAO,EAAE,SAAS,uBAAuB,OAAO;AAAA,EACpD;AACF;;;AClCA,IAAM,eAA+D;AAAA,EACnE,OAAO;AAAA,EACP,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;AACR;AAEO,SAAS,4BACd,SAC6B;AAC7B,QAAM,eAAe,SAAS,KAAK,EAAE,YAAY;AACjD,MAAI,CAAC,cAAc;AACjB,WAAO;AAAA,EACT;AACA,SAAO,aAAa,YAAY,KAAK;AACvC;","names":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
type MembershipAccessState = "free" | "active" | "inactive" | "unknown";
|
|
2
|
+
type CommerceMembershipAction = "upgrade-membership" | "recharge-credits" | "view-credit-plans";
|
|
3
|
+
type MembershipTierVisual = "free" | "lite" | "pro" | "ultra";
|
|
4
|
+
interface RegistrationCreditsToastState {
|
|
5
|
+
id: string;
|
|
6
|
+
creditsLabel: string;
|
|
7
|
+
visible: boolean;
|
|
8
|
+
autoDismissMs?: number;
|
|
9
|
+
onDismiss(): void;
|
|
10
|
+
}
|
|
11
|
+
interface CommerceMenuState {
|
|
12
|
+
membershipLabel: string;
|
|
13
|
+
membershipAccess?: MembershipAccessState;
|
|
14
|
+
creditsLabel: string | null;
|
|
15
|
+
loading: boolean;
|
|
16
|
+
dataUnavailable: boolean;
|
|
17
|
+
links: {
|
|
18
|
+
planUrl: string;
|
|
19
|
+
usageUrl: string;
|
|
20
|
+
settingsUrl: string;
|
|
21
|
+
};
|
|
22
|
+
onOpenExternal(url: string): void | Promise<void>;
|
|
23
|
+
onActionError?(error: unknown): void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type { CommerceMembershipAction as C, MembershipAccessState as M, RegistrationCreditsToastState as R, CommerceMenuState as a, MembershipTierVisual as b };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { C as CommerceMembershipAction, M as MembershipAccessState, b as MembershipTierVisual } from './contracts-I0M2ZTJA.js';
|
|
2
|
+
export { a as CommerceMenuState, R as RegistrationCreditsToastState } from './contracts-I0M2ZTJA.js';
|
|
3
|
+
|
|
4
|
+
interface InsufficientCreditsSemantic {
|
|
5
|
+
message: "upgrade-membership" | "recharge-credits" | "credits-unavailable";
|
|
6
|
+
action: CommerceMembershipAction;
|
|
7
|
+
}
|
|
8
|
+
declare function resolveMembershipAction(membershipAccess: MembershipAccessState | null | undefined): CommerceMembershipAction;
|
|
9
|
+
declare function resolveInsufficientCreditsSemantic(membershipAccess: MembershipAccessState | null | undefined): InsufficientCreditsSemantic;
|
|
10
|
+
|
|
11
|
+
declare function resolveMembershipTierVisual(tierKey: string | null | undefined): MembershipTierVisual | null;
|
|
12
|
+
|
|
13
|
+
export { CommerceMembershipAction, type InsufficientCreditsSemantic, MembershipAccessState, MembershipTierVisual, resolveInsufficientCreditsSemantic, resolveMembershipAction, resolveMembershipTierVisual };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveInsufficientCreditsSemantic,
|
|
3
|
+
resolveMembershipAction,
|
|
4
|
+
resolveMembershipTierVisual
|
|
5
|
+
} from "./chunk-L6YQE3QG.js";
|
|
6
|
+
export {
|
|
7
|
+
resolveInsufficientCreditsSemantic,
|
|
8
|
+
resolveMembershipAction,
|
|
9
|
+
resolveMembershipTierVisual
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { a as CommerceMenuState, R as RegistrationCreditsToastState } from '../contracts-I0M2ZTJA.js';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
|
|
4
|
+
interface CommerceMenuLabels {
|
|
5
|
+
member: string;
|
|
6
|
+
upgradeMembership: string;
|
|
7
|
+
rechargeCredits: string;
|
|
8
|
+
viewCreditPlans: string;
|
|
9
|
+
creditsBalance: string;
|
|
10
|
+
accountCenter: string;
|
|
11
|
+
loading: string;
|
|
12
|
+
unavailable: string;
|
|
13
|
+
dataUnavailable: string;
|
|
14
|
+
}
|
|
15
|
+
interface CommerceMenuContentProps {
|
|
16
|
+
state: CommerceMenuState;
|
|
17
|
+
labels: CommerceMenuLabels;
|
|
18
|
+
}
|
|
19
|
+
declare function CommerceMenuContent({ state, labels }: CommerceMenuContentProps): React.JSX.Element;
|
|
20
|
+
|
|
21
|
+
interface MembershipBadgeProps {
|
|
22
|
+
label: string;
|
|
23
|
+
tierKey?: string | null;
|
|
24
|
+
className?: string;
|
|
25
|
+
}
|
|
26
|
+
declare function MembershipBadge({ label, tierKey, className }: MembershipBadgeProps): React.JSX.Element;
|
|
27
|
+
|
|
28
|
+
interface MembershipTierIconProps {
|
|
29
|
+
tierKey: string | null | undefined;
|
|
30
|
+
className?: string;
|
|
31
|
+
}
|
|
32
|
+
declare function MembershipTierIcon({ tierKey, className }: MembershipTierIconProps): React.JSX.Element | null;
|
|
33
|
+
|
|
34
|
+
interface RegistrationCreditsToastLabels {
|
|
35
|
+
title: string;
|
|
36
|
+
creditsUnit: string;
|
|
37
|
+
description: string;
|
|
38
|
+
close: string;
|
|
39
|
+
}
|
|
40
|
+
interface RegistrationCreditsToastProps {
|
|
41
|
+
toast: RegistrationCreditsToastState;
|
|
42
|
+
labels: RegistrationCreditsToastLabels;
|
|
43
|
+
}
|
|
44
|
+
declare const RegistrationCreditsToast: react.NamedExoticComponent<RegistrationCreditsToastProps>;
|
|
45
|
+
|
|
46
|
+
export { CommerceMenuContent, type CommerceMenuContentProps, type CommerceMenuLabels, MembershipBadge, type MembershipBadgeProps, MembershipTierIcon, type MembershipTierIconProps, RegistrationCreditsToast, type RegistrationCreditsToastLabels, type RegistrationCreditsToastProps };
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveMembershipAction,
|
|
3
|
+
resolveMembershipTierVisual
|
|
4
|
+
} from "../chunk-L6YQE3QG.js";
|
|
5
|
+
|
|
6
|
+
// src/react/CommerceMenuContent.tsx
|
|
7
|
+
import { useCallback } from "react";
|
|
8
|
+
import {
|
|
9
|
+
BillingIcon,
|
|
10
|
+
CreditsIcon,
|
|
11
|
+
LaunchIcon,
|
|
12
|
+
SettingsIcon
|
|
13
|
+
} from "@tutti-os/ui-system";
|
|
14
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
function CommerceMenuContent({
|
|
16
|
+
state,
|
|
17
|
+
labels
|
|
18
|
+
}) {
|
|
19
|
+
const creditsLabel = state.loading && !state.creditsLabel ? labels.loading : state.creditsLabel ?? labels.unavailable;
|
|
20
|
+
const openExternal = useCallback(
|
|
21
|
+
(url) => {
|
|
22
|
+
if (!url.trim()) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const result = state.onOpenExternal(url);
|
|
27
|
+
if (result) {
|
|
28
|
+
void result.catch((error) => {
|
|
29
|
+
state.onActionError?.(error);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
} catch (error) {
|
|
33
|
+
state.onActionError?.(error);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
[state]
|
|
37
|
+
);
|
|
38
|
+
const membershipActionLabel = resolveMembershipActionLabel(state, labels);
|
|
39
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col", "data-testid": "commerce-menu-content", children: [
|
|
40
|
+
/* @__PURE__ */ jsxs(
|
|
41
|
+
"button",
|
|
42
|
+
{
|
|
43
|
+
type: "button",
|
|
44
|
+
className: "nodrag flex h-8 items-center gap-2 rounded-[6px] px-2 text-[13px] text-[var(--text-primary)] hover:bg-[var(--transparency-hover)] disabled:cursor-not-allowed disabled:opacity-50 [-webkit-app-region:no-drag]",
|
|
45
|
+
disabled: !state.links.planUrl.trim(),
|
|
46
|
+
onClick: () => openExternal(state.links.planUrl),
|
|
47
|
+
children: [
|
|
48
|
+
/* @__PURE__ */ jsx(BillingIcon, { "aria-hidden": "true", size: 15 }),
|
|
49
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-left", children: labels.member }),
|
|
50
|
+
/* @__PURE__ */ jsx("span", { className: "shrink-0 text-[12px] text-[var(--tutti-purple)]", children: membershipActionLabel })
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
),
|
|
54
|
+
/* @__PURE__ */ jsxs(
|
|
55
|
+
"button",
|
|
56
|
+
{
|
|
57
|
+
type: "button",
|
|
58
|
+
className: "nodrag flex h-8 items-center gap-2 rounded-[6px] px-2 text-[13px] text-[var(--text-primary)] hover:bg-[var(--transparency-hover)] disabled:cursor-not-allowed disabled:opacity-50 [-webkit-app-region:no-drag]",
|
|
59
|
+
disabled: !state.links.usageUrl.trim(),
|
|
60
|
+
onClick: () => openExternal(state.links.usageUrl),
|
|
61
|
+
children: [
|
|
62
|
+
/* @__PURE__ */ jsx(CreditsIcon, { "aria-hidden": "true", size: 15 }),
|
|
63
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-left", children: labels.creditsBalance }),
|
|
64
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-[var(--text-secondary)]", children: creditsLabel })
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
),
|
|
68
|
+
/* @__PURE__ */ jsxs(
|
|
69
|
+
"button",
|
|
70
|
+
{
|
|
71
|
+
type: "button",
|
|
72
|
+
className: "nodrag flex h-8 items-center gap-2 rounded-[6px] px-2 text-[13px] text-[var(--text-primary)] hover:bg-[var(--transparency-hover)] disabled:cursor-not-allowed disabled:opacity-50 [-webkit-app-region:no-drag]",
|
|
73
|
+
disabled: !state.links.settingsUrl.trim(),
|
|
74
|
+
onClick: () => openExternal(state.links.settingsUrl),
|
|
75
|
+
children: [
|
|
76
|
+
/* @__PURE__ */ jsx(SettingsIcon, { "aria-hidden": "true", size: 15 }),
|
|
77
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-left", children: labels.accountCenter }),
|
|
78
|
+
/* @__PURE__ */ jsx(LaunchIcon, { "aria-hidden": "true", size: 14 })
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
state.dataUnavailable ? /* @__PURE__ */ jsx("span", { className: "px-2 py-1 text-[11px] leading-4 text-[var(--text-danger)]", children: labels.dataUnavailable }) : null
|
|
83
|
+
] });
|
|
84
|
+
}
|
|
85
|
+
function resolveMembershipActionLabel(state, labels) {
|
|
86
|
+
switch (resolveMembershipAction(state.membershipAccess)) {
|
|
87
|
+
case "upgrade-membership":
|
|
88
|
+
return labels.upgradeMembership;
|
|
89
|
+
case "recharge-credits":
|
|
90
|
+
return labels.rechargeCredits;
|
|
91
|
+
case "view-credit-plans":
|
|
92
|
+
return labels.viewCreditPlans;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// src/react/MembershipBadge.tsx
|
|
97
|
+
import { BillingIcon as BillingIcon2 } from "@tutti-os/ui-system";
|
|
98
|
+
|
|
99
|
+
// src/react/MembershipTierIcon.tsx
|
|
100
|
+
import freeIconUrl from "@tutti-os/commerce/assets/star-free.png";
|
|
101
|
+
import liteIconUrl from "@tutti-os/commerce/assets/star-lite.png";
|
|
102
|
+
import proIconUrl from "@tutti-os/commerce/assets/star-pro.png";
|
|
103
|
+
import ultraIconUrl from "@tutti-os/commerce/assets/star-ultra.png";
|
|
104
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
105
|
+
var ICON_URLS = {
|
|
106
|
+
free: freeIconUrl,
|
|
107
|
+
lite: liteIconUrl,
|
|
108
|
+
pro: proIconUrl,
|
|
109
|
+
ultra: ultraIconUrl
|
|
110
|
+
};
|
|
111
|
+
function MembershipTierIcon({
|
|
112
|
+
tierKey,
|
|
113
|
+
className = ""
|
|
114
|
+
}) {
|
|
115
|
+
const visual = resolveMembershipTierVisual(tierKey);
|
|
116
|
+
if (!visual) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
return /* @__PURE__ */ jsx2(
|
|
120
|
+
"img",
|
|
121
|
+
{
|
|
122
|
+
alt: "",
|
|
123
|
+
"aria-hidden": "true",
|
|
124
|
+
draggable: false,
|
|
125
|
+
src: ICON_URLS[visual],
|
|
126
|
+
className,
|
|
127
|
+
"data-membership-tier-visual": visual
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// src/react/MembershipBadge.tsx
|
|
133
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
134
|
+
function MembershipBadge({
|
|
135
|
+
label,
|
|
136
|
+
tierKey = null,
|
|
137
|
+
className = ""
|
|
138
|
+
}) {
|
|
139
|
+
return /* @__PURE__ */ jsxs2(
|
|
140
|
+
"span",
|
|
141
|
+
{
|
|
142
|
+
className: `inline-flex max-w-full items-center gap-1 rounded-[5px] bg-[color-mix(in_srgb,var(--tutti-purple)_18%,transparent)] px-1.5 py-0.5 text-[11px] font-semibold leading-3 text-[var(--tutti-purple)] ${className}`,
|
|
143
|
+
"data-commerce-membership-badge": "true",
|
|
144
|
+
children: [
|
|
145
|
+
tierKey ? /* @__PURE__ */ jsx3(
|
|
146
|
+
MembershipTierIcon,
|
|
147
|
+
{
|
|
148
|
+
className: "size-3.5 shrink-0 object-contain",
|
|
149
|
+
tierKey
|
|
150
|
+
}
|
|
151
|
+
) : /* @__PURE__ */ jsx3(BillingIcon2, { "aria-hidden": "true", size: 11 }),
|
|
152
|
+
/* @__PURE__ */ jsx3("span", { className: "min-w-0 truncate", children: label })
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// src/react/RegistrationCreditsToast.tsx
|
|
159
|
+
import { memo, useEffect } from "react";
|
|
160
|
+
import registrationCreditsBackgroundUrl from "@tutti-os/commerce/assets/registration-credits-bg.png";
|
|
161
|
+
import { CloseIcon, CreditsIcon as CreditsIcon2 } from "@tutti-os/ui-system";
|
|
162
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
163
|
+
var defaultAutoDismissMs = 12e4;
|
|
164
|
+
var RegistrationCreditsToast = memo(function RegistrationCreditsToast2({
|
|
165
|
+
toast,
|
|
166
|
+
labels
|
|
167
|
+
}) {
|
|
168
|
+
"use memo";
|
|
169
|
+
useEffect(() => {
|
|
170
|
+
if (!toast.visible) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const timeout = window.setTimeout(
|
|
174
|
+
toast.onDismiss,
|
|
175
|
+
toast.autoDismissMs ?? defaultAutoDismissMs
|
|
176
|
+
);
|
|
177
|
+
return () => window.clearTimeout(timeout);
|
|
178
|
+
}, [toast.autoDismissMs, toast.onDismiss, toast.visible]);
|
|
179
|
+
if (!toast.visible) {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
return /* @__PURE__ */ jsxs3(
|
|
183
|
+
"div",
|
|
184
|
+
{
|
|
185
|
+
className: "nodrag relative mx-3 mb-1 w-[calc(100%-24px)] max-w-[calc(100%-24px)] overflow-hidden rounded-[14px] border border-[rgba(218,233,255,0.62)] p-2.5 pr-9 text-white shadow-[0_14px_28px_rgba(0,0,0,0.2),inset_0_0_0_1px_rgba(255,255,255,0.24)] [-webkit-app-region:no-drag]",
|
|
186
|
+
"data-testid": "commerce-registration-credits-toast",
|
|
187
|
+
role: "status",
|
|
188
|
+
style: {
|
|
189
|
+
backgroundImage: `linear-gradient(90deg, rgba(18, 60, 142, 0.08), rgba(20, 66, 160, 0.2) 58%, rgba(12, 32, 92, 0.34)), url(${JSON.stringify(
|
|
190
|
+
registrationCreditsBackgroundUrl
|
|
191
|
+
)})`,
|
|
192
|
+
backgroundPosition: "center",
|
|
193
|
+
backgroundRepeat: "no-repeat",
|
|
194
|
+
backgroundSize: "cover"
|
|
195
|
+
},
|
|
196
|
+
children: [
|
|
197
|
+
/* @__PURE__ */ jsx4("div", { className: "pointer-events-none absolute inset-x-0 top-0 h-px bg-gradient-to-r from-transparent via-white/90 to-transparent" }),
|
|
198
|
+
/* @__PURE__ */ jsxs3("div", { className: "relative flex min-w-0 items-center gap-2.5", children: [
|
|
199
|
+
/* @__PURE__ */ jsx4("span", { className: "grid h-10 w-10 shrink-0 place-items-center rounded-[12px] bg-[rgba(250,255,236,0.78)] text-emerald-400 shadow-[0_9px_18px_rgba(20,184,166,0.18),0_0_0_1px_rgba(255,255,255,0.5)_inset]", children: /* @__PURE__ */ jsx4(CreditsIcon2, { "aria-hidden": "true", size: 23 }) }),
|
|
200
|
+
/* @__PURE__ */ jsxs3("span", { className: "min-w-0 flex-1", children: [
|
|
201
|
+
/* @__PURE__ */ jsx4("span", { className: "block truncate text-[12px] font-semibold leading-4 text-white", children: labels.title }),
|
|
202
|
+
/* @__PURE__ */ jsxs3("span", { className: "block truncate text-[20px] font-semibold leading-6 text-white", children: [
|
|
203
|
+
"+",
|
|
204
|
+
toast.creditsLabel,
|
|
205
|
+
" ",
|
|
206
|
+
labels.creditsUnit
|
|
207
|
+
] }),
|
|
208
|
+
/* @__PURE__ */ jsx4("span", { className: "block truncate text-[11px] font-medium leading-4 text-white/88", children: labels.description })
|
|
209
|
+
] })
|
|
210
|
+
] }),
|
|
211
|
+
/* @__PURE__ */ jsx4(
|
|
212
|
+
"button",
|
|
213
|
+
{
|
|
214
|
+
type: "button",
|
|
215
|
+
"aria-label": labels.close,
|
|
216
|
+
className: "nodrag absolute right-2.5 top-2.5 grid h-6 w-6 place-items-center rounded-[7px] text-white/85 hover:bg-white/18 hover:text-white [-webkit-app-region:no-drag]",
|
|
217
|
+
onClick: toast.onDismiss,
|
|
218
|
+
children: /* @__PURE__ */ jsx4(CloseIcon, { "aria-hidden": "true", size: 16 })
|
|
219
|
+
}
|
|
220
|
+
)
|
|
221
|
+
]
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
});
|
|
225
|
+
export {
|
|
226
|
+
CommerceMenuContent,
|
|
227
|
+
MembershipBadge,
|
|
228
|
+
MembershipTierIcon,
|
|
229
|
+
RegistrationCreditsToast
|
|
230
|
+
};
|
|
231
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/react/CommerceMenuContent.tsx","../../src/react/MembershipBadge.tsx","../../src/react/MembershipTierIcon.tsx","../../src/react/RegistrationCreditsToast.tsx"],"sourcesContent":["import { useCallback } from \"react\";\nimport {\n BillingIcon,\n CreditsIcon,\n LaunchIcon,\n SettingsIcon\n} from \"@tutti-os/ui-system\";\nimport { resolveMembershipAction, type CommerceMenuState } from \"../index\";\n\nexport interface CommerceMenuLabels {\n member: string;\n upgradeMembership: string;\n rechargeCredits: string;\n viewCreditPlans: string;\n creditsBalance: string;\n accountCenter: string;\n loading: string;\n unavailable: string;\n dataUnavailable: string;\n}\n\nexport interface CommerceMenuContentProps {\n state: CommerceMenuState;\n labels: CommerceMenuLabels;\n}\n\nexport function CommerceMenuContent({\n state,\n labels\n}: CommerceMenuContentProps): React.JSX.Element {\n const creditsLabel =\n state.loading && !state.creditsLabel\n ? labels.loading\n : (state.creditsLabel ?? labels.unavailable);\n const openExternal = useCallback(\n (url: string) => {\n if (!url.trim()) {\n return;\n }\n try {\n const result = state.onOpenExternal(url);\n if (result) {\n void result.catch((error: unknown) => {\n state.onActionError?.(error);\n });\n }\n } catch (error) {\n state.onActionError?.(error);\n }\n },\n [state]\n );\n const membershipActionLabel = resolveMembershipActionLabel(state, labels);\n\n return (\n <div className=\"flex min-w-0 flex-col\" data-testid=\"commerce-menu-content\">\n <button\n type=\"button\"\n className=\"nodrag flex h-8 items-center gap-2 rounded-[6px] px-2 text-[13px] text-[var(--text-primary)] hover:bg-[var(--transparency-hover)] disabled:cursor-not-allowed disabled:opacity-50 [-webkit-app-region:no-drag]\"\n disabled={!state.links.planUrl.trim()}\n onClick={() => openExternal(state.links.planUrl)}\n >\n <BillingIcon aria-hidden=\"true\" size={15} />\n <span className=\"min-w-0 flex-1 truncate text-left\">\n {labels.member}\n </span>\n <span className=\"shrink-0 text-[12px] text-[var(--tutti-purple)]\">\n {membershipActionLabel}\n </span>\n </button>\n <button\n type=\"button\"\n className=\"nodrag flex h-8 items-center gap-2 rounded-[6px] px-2 text-[13px] text-[var(--text-primary)] hover:bg-[var(--transparency-hover)] disabled:cursor-not-allowed disabled:opacity-50 [-webkit-app-region:no-drag]\"\n disabled={!state.links.usageUrl.trim()}\n onClick={() => openExternal(state.links.usageUrl)}\n >\n <CreditsIcon aria-hidden=\"true\" size={15} />\n <span className=\"min-w-0 flex-1 truncate text-left\">\n {labels.creditsBalance}\n </span>\n <span className=\"truncate text-[var(--text-secondary)]\">\n {creditsLabel}\n </span>\n </button>\n <button\n type=\"button\"\n className=\"nodrag flex h-8 items-center gap-2 rounded-[6px] px-2 text-[13px] text-[var(--text-primary)] hover:bg-[var(--transparency-hover)] disabled:cursor-not-allowed disabled:opacity-50 [-webkit-app-region:no-drag]\"\n disabled={!state.links.settingsUrl.trim()}\n onClick={() => openExternal(state.links.settingsUrl)}\n >\n <SettingsIcon aria-hidden=\"true\" size={15} />\n <span className=\"min-w-0 flex-1 truncate text-left\">\n {labels.accountCenter}\n </span>\n <LaunchIcon aria-hidden=\"true\" size={14} />\n </button>\n {state.dataUnavailable ? (\n <span className=\"px-2 py-1 text-[11px] leading-4 text-[var(--text-danger)]\">\n {labels.dataUnavailable}\n </span>\n ) : null}\n </div>\n );\n}\n\nfunction resolveMembershipActionLabel(\n state: CommerceMenuState,\n labels: Pick<\n CommerceMenuLabels,\n \"upgradeMembership\" | \"rechargeCredits\" | \"viewCreditPlans\"\n >\n): string {\n switch (resolveMembershipAction(state.membershipAccess)) {\n case \"upgrade-membership\":\n return labels.upgradeMembership;\n case \"recharge-credits\":\n return labels.rechargeCredits;\n case \"view-credit-plans\":\n return labels.viewCreditPlans;\n }\n}\n","import { BillingIcon } from \"@tutti-os/ui-system\";\nimport { MembershipTierIcon } from \"./MembershipTierIcon\";\n\nexport interface MembershipBadgeProps {\n label: string;\n tierKey?: string | null;\n className?: string;\n}\n\nexport function MembershipBadge({\n label,\n tierKey = null,\n className = \"\"\n}: MembershipBadgeProps): React.JSX.Element {\n return (\n <span\n className={`inline-flex max-w-full items-center gap-1 rounded-[5px] bg-[color-mix(in_srgb,var(--tutti-purple)_18%,transparent)] px-1.5 py-0.5 text-[11px] font-semibold leading-3 text-[var(--tutti-purple)] ${className}`}\n data-commerce-membership-badge=\"true\"\n >\n {tierKey ? (\n <MembershipTierIcon\n className=\"size-3.5 shrink-0 object-contain\"\n tierKey={tierKey}\n />\n ) : (\n <BillingIcon aria-hidden=\"true\" size={11} />\n )}\n <span className=\"min-w-0 truncate\">{label}</span>\n </span>\n );\n}\n","import freeIconUrl from \"@tutti-os/commerce/assets/star-free.png\";\nimport liteIconUrl from \"@tutti-os/commerce/assets/star-lite.png\";\nimport proIconUrl from \"@tutti-os/commerce/assets/star-pro.png\";\nimport ultraIconUrl from \"@tutti-os/commerce/assets/star-ultra.png\";\nimport {\n resolveMembershipTierVisual,\n type MembershipTierVisual\n} from \"../index\";\n\nconst ICON_URLS: Readonly<Record<MembershipTierVisual, string>> = {\n free: freeIconUrl,\n lite: liteIconUrl,\n pro: proIconUrl,\n ultra: ultraIconUrl\n};\n\nexport interface MembershipTierIconProps {\n tierKey: string | null | undefined;\n className?: string;\n}\n\nexport function MembershipTierIcon({\n tierKey,\n className = \"\"\n}: MembershipTierIconProps): React.JSX.Element | null {\n const visual = resolveMembershipTierVisual(tierKey);\n if (!visual) {\n return null;\n }\n return (\n <img\n alt=\"\"\n aria-hidden=\"true\"\n draggable={false}\n src={ICON_URLS[visual]}\n className={className}\n data-membership-tier-visual={visual}\n />\n );\n}\n","import { memo, useEffect } from \"react\";\nimport registrationCreditsBackgroundUrl from \"@tutti-os/commerce/assets/registration-credits-bg.png\";\nimport { CloseIcon, CreditsIcon } from \"@tutti-os/ui-system\";\nimport type { RegistrationCreditsToastState } from \"../index\";\n\nexport interface RegistrationCreditsToastLabels {\n title: string;\n creditsUnit: string;\n description: string;\n close: string;\n}\n\nexport interface RegistrationCreditsToastProps {\n toast: RegistrationCreditsToastState;\n labels: RegistrationCreditsToastLabels;\n}\n\nconst defaultAutoDismissMs = 120_000;\n\nexport const RegistrationCreditsToast = memo(function RegistrationCreditsToast({\n toast,\n labels\n}: RegistrationCreditsToastProps): React.JSX.Element | null {\n \"use memo\";\n useEffect(() => {\n if (!toast.visible) {\n return;\n }\n const timeout = window.setTimeout(\n toast.onDismiss,\n toast.autoDismissMs ?? defaultAutoDismissMs\n );\n return () => window.clearTimeout(timeout);\n }, [toast.autoDismissMs, toast.onDismiss, toast.visible]);\n\n if (!toast.visible) {\n return null;\n }\n\n return (\n <div\n className=\"nodrag relative mx-3 mb-1 w-[calc(100%-24px)] max-w-[calc(100%-24px)] overflow-hidden rounded-[14px] border border-[rgba(218,233,255,0.62)] p-2.5 pr-9 text-white shadow-[0_14px_28px_rgba(0,0,0,0.2),inset_0_0_0_1px_rgba(255,255,255,0.24)] [-webkit-app-region:no-drag]\"\n data-testid=\"commerce-registration-credits-toast\"\n role=\"status\"\n style={{\n backgroundImage: `linear-gradient(90deg, rgba(18, 60, 142, 0.08), rgba(20, 66, 160, 0.2) 58%, rgba(12, 32, 92, 0.34)), url(${JSON.stringify(\n registrationCreditsBackgroundUrl\n )})`,\n backgroundPosition: \"center\",\n backgroundRepeat: \"no-repeat\",\n backgroundSize: \"cover\"\n }}\n >\n <div className=\"pointer-events-none absolute inset-x-0 top-0 h-px bg-gradient-to-r from-transparent via-white/90 to-transparent\" />\n <div className=\"relative flex min-w-0 items-center gap-2.5\">\n <span className=\"grid h-10 w-10 shrink-0 place-items-center rounded-[12px] bg-[rgba(250,255,236,0.78)] text-emerald-400 shadow-[0_9px_18px_rgba(20,184,166,0.18),0_0_0_1px_rgba(255,255,255,0.5)_inset]\">\n <CreditsIcon aria-hidden=\"true\" size={23} />\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate text-[12px] font-semibold leading-4 text-white\">\n {labels.title}\n </span>\n <span className=\"block truncate text-[20px] font-semibold leading-6 text-white\">\n +{toast.creditsLabel} {labels.creditsUnit}\n </span>\n <span className=\"block truncate text-[11px] font-medium leading-4 text-white/88\">\n {labels.description}\n </span>\n </span>\n </div>\n <button\n type=\"button\"\n aria-label={labels.close}\n className=\"nodrag absolute right-2.5 top-2.5 grid h-6 w-6 place-items-center rounded-[7px] text-white/85 hover:bg-white/18 hover:text-white [-webkit-app-region:no-drag]\"\n onClick={toast.onDismiss}\n >\n <CloseIcon aria-hidden=\"true\" size={16} />\n </button>\n </div>\n );\n});\n"],"mappings":";;;;;;AAAA,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAkDD,SAME,KANF;AA9BC,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AACF,GAAgD;AAC9C,QAAM,eACJ,MAAM,WAAW,CAAC,MAAM,eACpB,OAAO,UACN,MAAM,gBAAgB,OAAO;AACpC,QAAM,eAAe;AAAA,IACnB,CAAC,QAAgB;AACf,UAAI,CAAC,IAAI,KAAK,GAAG;AACf;AAAA,MACF;AACA,UAAI;AACF,cAAM,SAAS,MAAM,eAAe,GAAG;AACvC,YAAI,QAAQ;AACV,eAAK,OAAO,MAAM,CAAC,UAAmB;AACpC,kBAAM,gBAAgB,KAAK;AAAA,UAC7B,CAAC;AAAA,QACH;AAAA,MACF,SAAS,OAAO;AACd,cAAM,gBAAgB,KAAK;AAAA,MAC7B;AAAA,IACF;AAAA,IACA,CAAC,KAAK;AAAA,EACR;AACA,QAAM,wBAAwB,6BAA6B,OAAO,MAAM;AAExE,SACE,qBAAC,SAAI,WAAU,yBAAwB,eAAY,yBACjD;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,WAAU;AAAA,QACV,UAAU,CAAC,MAAM,MAAM,QAAQ,KAAK;AAAA,QACpC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sToast"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// src/runtime-assets/registration-credits-bg-url.ts
|
|
2
|
+
var registration_credits_bg_url_default = new URL("../assets/registration-credits-bg.png", import.meta.url).href;
|
|
3
|
+
export {
|
|
4
|
+
registration_credits_bg_url_default as default
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=registration-credits-bg-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/runtime-assets/registration-credits-bg-url.ts"],"sourcesContent":["export default new URL(\"../assets/registration-credits-bg.png\", import.meta.url)\n .href;\n"],"mappings":";AAAA,IAAO,sCAAQ,IAAI,IAAI,yCAAyC,YAAY,GAAG,EAC5E;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/runtime-assets/star-free-url.ts"],"sourcesContent":["export default new URL(\"../assets/star-free.png\", import.meta.url).href;\n"],"mappings":";AAAA,IAAO,wBAAQ,IAAI,IAAI,2BAA2B,YAAY,GAAG,EAAE;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/runtime-assets/star-lite-url.ts"],"sourcesContent":["export default new URL(\"../assets/star-lite.png\", import.meta.url).href;\n"],"mappings":";AAAA,IAAO,wBAAQ,IAAI,IAAI,2BAA2B,YAAY,GAAG,EAAE;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/runtime-assets/star-pro-url.ts"],"sourcesContent":["export default new URL(\"../assets/star-pro.png\", import.meta.url).href;\n"],"mappings":";AAAA,IAAO,uBAAQ,IAAI,IAAI,0BAA0B,YAAY,GAAG,EAAE;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/runtime-assets/star-ultra-url.ts"],"sourcesContent":["export default new URL(\"../assets/star-ultra.png\", import.meta.url).href;\n"],"mappings":";AAAA,IAAO,yBAAQ,IAAI,IAAI,4BAA4B,YAAY,GAAG,EAAE;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tutti-os/commerce",
|
|
3
|
+
"version": "0.0.213",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./react": {
|
|
13
|
+
"types": "./dist/react/index.d.ts",
|
|
14
|
+
"import": "./dist/react/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./assets/star-free.png": {
|
|
17
|
+
"types": "./dist/assets/star-free.png.d.ts",
|
|
18
|
+
"browser": "./dist/assets/star-free.png",
|
|
19
|
+
"node": "./dist/runtime-assets/star-free-url.js",
|
|
20
|
+
"default": "./dist/assets/star-free.png"
|
|
21
|
+
},
|
|
22
|
+
"./assets/star-lite.png": {
|
|
23
|
+
"types": "./dist/assets/star-lite.png.d.ts",
|
|
24
|
+
"browser": "./dist/assets/star-lite.png",
|
|
25
|
+
"node": "./dist/runtime-assets/star-lite-url.js",
|
|
26
|
+
"default": "./dist/assets/star-lite.png"
|
|
27
|
+
},
|
|
28
|
+
"./assets/star-pro.png": {
|
|
29
|
+
"types": "./dist/assets/star-pro.png.d.ts",
|
|
30
|
+
"browser": "./dist/assets/star-pro.png",
|
|
31
|
+
"node": "./dist/runtime-assets/star-pro-url.js",
|
|
32
|
+
"default": "./dist/assets/star-pro.png"
|
|
33
|
+
},
|
|
34
|
+
"./assets/star-ultra.png": {
|
|
35
|
+
"types": "./dist/assets/star-ultra.png.d.ts",
|
|
36
|
+
"browser": "./dist/assets/star-ultra.png",
|
|
37
|
+
"node": "./dist/runtime-assets/star-ultra-url.js",
|
|
38
|
+
"default": "./dist/assets/star-ultra.png"
|
|
39
|
+
},
|
|
40
|
+
"./assets/registration-credits-bg.png": {
|
|
41
|
+
"types": "./dist/assets/registration-credits-bg.png.d.ts",
|
|
42
|
+
"browser": "./dist/assets/registration-credits-bg.png",
|
|
43
|
+
"node": "./dist/runtime-assets/registration-credits-bg-url.js",
|
|
44
|
+
"default": "./dist/assets/registration-credits-bg.png"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"files": [
|
|
48
|
+
"dist",
|
|
49
|
+
"README.md"
|
|
50
|
+
],
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "git+https://github.com/tutti-os/tutti.git",
|
|
54
|
+
"directory": "packages/commerce/web"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@tutti-os/ui-system": "0.0.213"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
61
|
+
"@testing-library/react": "^16.3.0",
|
|
62
|
+
"@types/node": "^24.0.1",
|
|
63
|
+
"@types/react": "^19.1.6",
|
|
64
|
+
"@types/react-dom": "^19.1.5",
|
|
65
|
+
"jsdom": "^27.2.0",
|
|
66
|
+
"react": "^19.1.0",
|
|
67
|
+
"react-dom": "^19.1.0",
|
|
68
|
+
"tsup": "8.5.1",
|
|
69
|
+
"typescript": "^5.8.3",
|
|
70
|
+
"vitest": "^4.0.13",
|
|
71
|
+
"@tutti-os/config-tsconfig": "0.0.0"
|
|
72
|
+
},
|
|
73
|
+
"peerDependencies": {
|
|
74
|
+
"react": "^19.1.0",
|
|
75
|
+
"react-dom": "^19.1.0"
|
|
76
|
+
},
|
|
77
|
+
"tutti": {
|
|
78
|
+
"tailwindSourceRoot": "src"
|
|
79
|
+
},
|
|
80
|
+
"publishConfig": {
|
|
81
|
+
"access": "public"
|
|
82
|
+
},
|
|
83
|
+
"scripts": {
|
|
84
|
+
"build": "tsup --config tsup.config.ts && node ../../../tools/scripts/copy-package-assets.mjs src/assets dist/assets",
|
|
85
|
+
"test": "vitest run --environment jsdom",
|
|
86
|
+
"typecheck": "node ../../../tools/scripts/run-tsgo-typecheck.mjs"
|
|
87
|
+
},
|
|
88
|
+
"typesVersions": {
|
|
89
|
+
"*": {
|
|
90
|
+
"react": [
|
|
91
|
+
"./dist/react/index.d.ts"
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|