@nice2dev/licensing 1.2.1 → 1.2.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.
- package/CHANGELOG.md +39 -0
- package/dist/index.cjs +356 -269
- package/dist/index.mjs +357 -270
- package/dist/marks-BxZztzfi.cjs +1466 -0
- package/dist/marks-C_PSZQ9M.js +1467 -0
- package/dist/react.cjs +109 -90
- package/dist/react.mjs +109 -90
- package/package.json +6 -2
package/dist/react.mjs
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useNiceTranslation } from "@nice2dev/ui-core";
|
|
2
3
|
import { useState, useCallback, useEffect, useContext, createContext } from "react";
|
|
3
|
-
import { c as checkFeatureAccess, k as getAllPlans, C as CheckMark, L as LicenseValidator, E as normalizeLicenseKey, y as hasFeature, D as maskLicenseKey,
|
|
4
|
+
import { c as checkFeatureAccess, k as getAllPlans, M as isBuiltInEntry, C as CheckMark, L as LicenseValidator, E as normalizeLicenseKey, y as hasFeature, D as maskLicenseKey, N as ChevronMark, r as getMissingFeatures } from "./marks-C_PSZQ9M.js";
|
|
5
|
+
const TIER_NAMES = {
|
|
6
|
+
trial: "Trial",
|
|
7
|
+
personal: "Personal",
|
|
8
|
+
team: "Team",
|
|
9
|
+
enterprise: "Enterprise",
|
|
10
|
+
site: "Site License",
|
|
11
|
+
oem: "OEM"
|
|
12
|
+
};
|
|
13
|
+
const TIER_ORDER = ["trial", "personal", "team", "enterprise", "site", "oem"];
|
|
4
14
|
const LicenseContext = /* @__PURE__ */ createContext(null);
|
|
5
15
|
function LicenseProvider({
|
|
6
16
|
serverUrl = "https://license.nice2dev.com/api/v1",
|
|
@@ -14,6 +24,7 @@ function LicenseProvider({
|
|
|
14
24
|
children
|
|
15
25
|
}) {
|
|
16
26
|
var _a;
|
|
27
|
+
const { t } = useNiceTranslation();
|
|
17
28
|
const [state, setState] = useState({
|
|
18
29
|
license: null,
|
|
19
30
|
validation: null,
|
|
@@ -67,7 +78,7 @@ function LicenseProvider({
|
|
|
67
78
|
}
|
|
68
79
|
return result;
|
|
69
80
|
} catch (error) {
|
|
70
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
81
|
+
const errorMessage = error instanceof Error ? error.message : t("licensing.unknownError", "Unknown error");
|
|
71
82
|
setState((s) => ({
|
|
72
83
|
...s,
|
|
73
84
|
loading: false,
|
|
@@ -87,7 +98,7 @@ function LicenseProvider({
|
|
|
87
98
|
};
|
|
88
99
|
}
|
|
89
100
|
},
|
|
90
|
-
[validator, onLicenseChange]
|
|
101
|
+
[validator, onLicenseChange, t]
|
|
91
102
|
);
|
|
92
103
|
const activate = useCallback(
|
|
93
104
|
async (key) => {
|
|
@@ -205,6 +216,7 @@ function FeatureGate({
|
|
|
205
216
|
return /* @__PURE__ */ jsx(Fragment, { children: fallback });
|
|
206
217
|
}
|
|
207
218
|
function LicenseStatus({ detailed = false, style, className }) {
|
|
219
|
+
const { t } = useNiceTranslation();
|
|
208
220
|
const { license, validation, loading, error } = useLicense();
|
|
209
221
|
const baseStyle = {
|
|
210
222
|
padding: "8px 12px",
|
|
@@ -221,7 +233,7 @@ function LicenseStatus({ detailed = false, style, className }) {
|
|
|
221
233
|
{
|
|
222
234
|
style: { ...baseStyle, backgroundColor: "#f0f0f0", color: "#666" },
|
|
223
235
|
className,
|
|
224
|
-
children: /* @__PURE__ */ jsx("span", { children: "Checking license..." })
|
|
236
|
+
children: /* @__PURE__ */ jsx("span", { children: t("licensing.checkingLicense", "Checking license...") })
|
|
225
237
|
}
|
|
226
238
|
);
|
|
227
239
|
}
|
|
@@ -233,7 +245,7 @@ function LicenseStatus({ detailed = false, style, className }) {
|
|
|
233
245
|
className,
|
|
234
246
|
children: [
|
|
235
247
|
/* @__PURE__ */ jsx("span", { style: { fontWeight: 700 }, "aria-hidden": "true", children: "!" }),
|
|
236
|
-
/* @__PURE__ */ jsx("span", { children: error || "No license" })
|
|
248
|
+
/* @__PURE__ */ jsx("span", { children: error || t("licensing.noLicense", "No license") })
|
|
237
249
|
]
|
|
238
250
|
}
|
|
239
251
|
);
|
|
@@ -259,11 +271,11 @@ function LicenseStatus({ detailed = false, style, className }) {
|
|
|
259
271
|
return /* @__PURE__ */ jsxs("div", { style: { ...baseStyle, backgroundColor: bgColor, color: textColor }, className, children: [
|
|
260
272
|
/* @__PURE__ */ jsx(CheckMark, {}),
|
|
261
273
|
/* @__PURE__ */ jsx("span", { style: { fontWeight: 600 }, children: license.tier.charAt(0).toUpperCase() + license.tier.slice(1) }),
|
|
262
|
-
(validation == null ? void 0 : validation.inGracePeriod) && /* @__PURE__ */ jsx("span", { style: { color: "#dc2626", fontSize: "12px" }, children: "(Grace period)" }),
|
|
263
|
-
detailed && (validation == null ? void 0 : validation.daysRemaining) !== void 0 && validation.daysRemaining > 0 && /* @__PURE__ */
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
274
|
+
(validation == null ? void 0 : validation.inGracePeriod) && /* @__PURE__ */ jsx("span", { style: { color: "#dc2626", fontSize: "12px" }, children: t("licensing.gracePeriod", "(Grace period)") }),
|
|
275
|
+
detailed && (validation == null ? void 0 : validation.daysRemaining) !== void 0 && validation.daysRemaining > 0 && /* @__PURE__ */ jsx("span", { style: { fontSize: "12px", opacity: 0.8 }, children: t("licensing.daysRemaining", "{daysRemaining} days remaining").replace(
|
|
276
|
+
"{daysRemaining}",
|
|
277
|
+
String(validation.daysRemaining)
|
|
278
|
+
) }),
|
|
267
279
|
detailed && /* @__PURE__ */ jsx("span", { style: { fontSize: "12px", opacity: 0.6 }, children: maskLicenseKey(license.key) })
|
|
268
280
|
] });
|
|
269
281
|
}
|
|
@@ -273,6 +285,7 @@ function LicenseActivator({
|
|
|
273
285
|
style,
|
|
274
286
|
className
|
|
275
287
|
}) {
|
|
288
|
+
const { t } = useNiceTranslation();
|
|
276
289
|
const { activate, loading } = useLicense();
|
|
277
290
|
const [key, setKey] = useState("");
|
|
278
291
|
const [localError, setLocalError] = useState(null);
|
|
@@ -290,7 +303,7 @@ function LicenseActivator({
|
|
|
290
303
|
setKey("");
|
|
291
304
|
onActivated == null ? void 0 : onActivated(result.license);
|
|
292
305
|
} else {
|
|
293
|
-
setLocalError(result.errorMessage || "Activation failed");
|
|
306
|
+
setLocalError(result.errorMessage || t("licensing.activationFailed", "Activation failed"));
|
|
294
307
|
onError == null ? void 0 : onError(result.errorMessage || "Activation failed");
|
|
295
308
|
}
|
|
296
309
|
} finally {
|
|
@@ -327,7 +340,7 @@ function LicenseActivator({
|
|
|
327
340
|
cursor: isActivating || loading ? "not-allowed" : "pointer"
|
|
328
341
|
};
|
|
329
342
|
return /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, style: containerStyle, className, children: [
|
|
330
|
-
/* @__PURE__ */ jsx("label", { style: { fontWeight: 500, color: "#374151" }, children: "Enter License Key" }),
|
|
343
|
+
/* @__PURE__ */ jsx("label", { style: { fontWeight: 500, color: "#374151" }, children: t("licensing.enterLicenseKey", "Enter License Key") }),
|
|
331
344
|
/* @__PURE__ */ jsx(
|
|
332
345
|
"input",
|
|
333
346
|
{
|
|
@@ -340,7 +353,7 @@ function LicenseActivator({
|
|
|
340
353
|
}
|
|
341
354
|
),
|
|
342
355
|
localError && /* @__PURE__ */ jsx("div", { style: { color: "#dc2626", fontSize: "13px" }, children: localError }),
|
|
343
|
-
/* @__PURE__ */ jsx("button", { type: "submit", style: buttonStyle, disabled: isActivating || loading || !key.trim(), children: isActivating ? "Activating..." : "Activate License" })
|
|
356
|
+
/* @__PURE__ */ jsx("button", { type: "submit", style: buttonStyle, disabled: isActivating || loading || !key.trim(), children: isActivating ? t("licensing.activating", "Activating...") : t("licensing.activateLicense", "Activate License") })
|
|
344
357
|
] });
|
|
345
358
|
}
|
|
346
359
|
function UpgradePrompt({
|
|
@@ -350,6 +363,7 @@ function UpgradePrompt({
|
|
|
350
363
|
style,
|
|
351
364
|
compact = false
|
|
352
365
|
}) {
|
|
366
|
+
const { t } = useNiceTranslation();
|
|
353
367
|
const { license } = useLicense();
|
|
354
368
|
const missingFeatures = getMissingFeatures(license, targetTier);
|
|
355
369
|
const handleUpgrade = () => {
|
|
@@ -383,19 +397,18 @@ function UpgradePrompt({
|
|
|
383
397
|
marginTop: "12px"
|
|
384
398
|
};
|
|
385
399
|
return /* @__PURE__ */ jsxs("div", { style: containerStyle, children: [
|
|
386
|
-
/* @__PURE__ */
|
|
387
|
-
"
|
|
388
|
-
|
|
389
|
-
|
|
400
|
+
/* @__PURE__ */ jsx("div", { style: titleStyle, children: t("licensing.upgradeTo", "Upgrade to {targetTier}").replace(
|
|
401
|
+
"{targetTier}",
|
|
402
|
+
t(`licensing.tier.${targetTier}`, TIER_NAMES[targetTier] ?? targetTier)
|
|
403
|
+
) }),
|
|
390
404
|
!compact && missingFeatures.length > 0 && /* @__PURE__ */ jsxs("ul", { style: { margin: "8px 0", paddingLeft: "20px", color: "#374151", fontSize: "14px" }, children: [
|
|
391
|
-
missingFeatures.slice(0, 3).map((f) => /* @__PURE__ */ jsx("li", { children: f.name }, f.id)),
|
|
392
|
-
missingFeatures.length > 3 && /* @__PURE__ */
|
|
393
|
-
"
|
|
394
|
-
missingFeatures.length - 3
|
|
395
|
-
|
|
396
|
-
] })
|
|
405
|
+
missingFeatures.slice(0, 3).map((f) => /* @__PURE__ */ jsx("li", { children: isBuiltInEntry(f) ? t(`licensing.feature.${f.id}`, f.name) : f.name }, f.id)),
|
|
406
|
+
missingFeatures.length > 3 && /* @__PURE__ */ jsx("li", { children: t("licensing.moreFeatures", "+{missingFeatures} more features").replace(
|
|
407
|
+
"{missingFeatures}",
|
|
408
|
+
String(missingFeatures.length - 3)
|
|
409
|
+
) })
|
|
397
410
|
] }),
|
|
398
|
-
/* @__PURE__ */ jsx("button", { onClick: handleUpgrade, style: buttonStyle, children: "Upgrade Now" })
|
|
411
|
+
/* @__PURE__ */ jsx("button", { onClick: handleUpgrade, style: buttonStyle, children: t("licensing.upgradeNow", "Upgrade Now") })
|
|
399
412
|
] });
|
|
400
413
|
}
|
|
401
414
|
function LicenseComparison({
|
|
@@ -404,18 +417,21 @@ function LicenseComparison({
|
|
|
404
417
|
onSelect,
|
|
405
418
|
showPrices = true
|
|
406
419
|
}) {
|
|
420
|
+
const { t } = useNiceTranslation();
|
|
407
421
|
const { license } = useLicense();
|
|
408
422
|
const tier = currentTier || (license == null ? void 0 : license.tier);
|
|
409
423
|
const plans = customPlans || getAllPlans().filter((p) => p.priceMonthly > 0 || p.id === "trial");
|
|
410
424
|
const formatPrice = (cents) => {
|
|
411
425
|
if (cents === 0) {
|
|
412
|
-
return "Free";
|
|
426
|
+
return t("licensing.free", "Free");
|
|
413
427
|
}
|
|
414
428
|
return `$${(cents / 100).toFixed(0)}`;
|
|
415
429
|
};
|
|
416
430
|
return /* @__PURE__ */ jsx("div", { style: { display: "flex", gap: "16px", flexWrap: "wrap", justifyContent: "center" }, children: plans.map((plan) => {
|
|
417
431
|
const isCurrent = plan.id === tier;
|
|
418
432
|
const isRecommended = plan.recommended;
|
|
433
|
+
const builtIn = isBuiltInEntry(plan);
|
|
434
|
+
const planText = (field, text) => builtIn ? t(`licensing.plan.${plan.id}.${field}`, text) : text;
|
|
419
435
|
return /* @__PURE__ */ jsxs(
|
|
420
436
|
"div",
|
|
421
437
|
{
|
|
@@ -444,19 +460,19 @@ function LicenseComparison({
|
|
|
444
460
|
fontSize: "12px",
|
|
445
461
|
fontWeight: 600
|
|
446
462
|
},
|
|
447
|
-
children: "Recommended"
|
|
463
|
+
children: t("licensing.recommended", "Recommended")
|
|
448
464
|
}
|
|
449
465
|
),
|
|
450
|
-
/* @__PURE__ */ jsx("h3", { style: { margin: "0 0 4px", fontSize: "20px", color: "#111" }, children: plan.name }),
|
|
451
|
-
/* @__PURE__ */ jsx("p", { style: { margin: "0 0 16px", fontSize: "14px", color: "#6b7280" }, children: plan.description }),
|
|
466
|
+
/* @__PURE__ */ jsx("h3", { style: { margin: "0 0 4px", fontSize: "20px", color: "#111" }, children: planText("name", plan.name) }),
|
|
467
|
+
/* @__PURE__ */ jsx("p", { style: { margin: "0 0 16px", fontSize: "14px", color: "#6b7280" }, children: planText("description", plan.description) }),
|
|
452
468
|
showPrices && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "16px" }, children: [
|
|
453
469
|
/* @__PURE__ */ jsx("span", { style: { fontSize: "32px", fontWeight: 700, color: "#111" }, children: formatPrice(plan.priceMonthly) }),
|
|
454
|
-
plan.priceMonthly > 0 && /* @__PURE__ */ jsx("span", { style: { fontSize: "14px", color: "#6b7280" }, children: "/month" })
|
|
470
|
+
plan.priceMonthly > 0 && /* @__PURE__ */ jsx("span", { style: { fontSize: "14px", color: "#6b7280" }, children: t("licensing.perMonth", "/month") })
|
|
455
471
|
] }),
|
|
456
472
|
/* @__PURE__ */ jsx("ul", { style: { listStyle: "none", padding: 0, margin: "0 0 16px" }, children: plan.highlights.map((h, i) => /* @__PURE__ */ jsxs("li", { style: { padding: "6px 0", fontSize: "14px", color: "#374151" }, children: [
|
|
457
473
|
/* @__PURE__ */ jsx(CheckMark, {}),
|
|
458
474
|
" ",
|
|
459
|
-
h
|
|
475
|
+
planText(`highlight${i}`, h)
|
|
460
476
|
] }, i)) }),
|
|
461
477
|
/* @__PURE__ */ jsx(
|
|
462
478
|
"button",
|
|
@@ -474,7 +490,7 @@ function LicenseComparison({
|
|
|
474
490
|
borderRadius: "6px",
|
|
475
491
|
cursor: isCurrent ? "default" : "pointer"
|
|
476
492
|
},
|
|
477
|
-
children: isCurrent ? "Current Plan" : "Select"
|
|
493
|
+
children: isCurrent ? t("licensing.currentPlan", "Current Plan") : t("licensing.select", "Select")
|
|
478
494
|
}
|
|
479
495
|
)
|
|
480
496
|
]
|
|
@@ -524,6 +540,7 @@ function LicensePortal({
|
|
|
524
540
|
style,
|
|
525
541
|
className
|
|
526
542
|
}) {
|
|
543
|
+
const { t } = useNiceTranslation();
|
|
527
544
|
const {
|
|
528
545
|
license,
|
|
529
546
|
validation: _validation,
|
|
@@ -548,11 +565,11 @@ function LicensePortal({
|
|
|
548
565
|
onDeactivate == null ? void 0 : onDeactivate();
|
|
549
566
|
};
|
|
550
567
|
const tabLabels = {
|
|
551
|
-
overview: "Overview",
|
|
552
|
-
activation: "Activation",
|
|
553
|
-
seats: "Seats",
|
|
554
|
-
features: "Features",
|
|
555
|
-
plans: "Plans"
|
|
568
|
+
overview: t("licensing.overview", "Overview"),
|
|
569
|
+
activation: t("licensing.activation", "Activation"),
|
|
570
|
+
seats: t("licensing.seats", "Seats"),
|
|
571
|
+
features: t("licensing.features", "Features"),
|
|
572
|
+
plans: t("licensing.plans", "Plans")
|
|
556
573
|
};
|
|
557
574
|
const containerStyle = {
|
|
558
575
|
border: "1px solid #e5e7eb",
|
|
@@ -580,21 +597,21 @@ function LicensePortal({
|
|
|
580
597
|
return /* @__PURE__ */ jsxs("div", { style: containerStyle, className, children: [
|
|
581
598
|
/* @__PURE__ */ jsx("div", { style: tabBarStyle, children: tabs.map((tab) => /* @__PURE__ */ jsx("button", { style: getTabStyle(tab), onClick: () => setActiveTab(tab), children: tabLabels[tab] }, tab)) }),
|
|
582
599
|
/* @__PURE__ */ jsxs("div", { style: panelStyle, children: [
|
|
583
|
-
loading && /* @__PURE__ */ jsx("p", { style: { color: "#6b7280" }, children: "Loading license information..." }),
|
|
600
|
+
loading && /* @__PURE__ */ jsx("p", { style: { color: "#6b7280" }, children: t("licensing.loadingLicenseInformation", "Loading license information...") }),
|
|
584
601
|
!loading && activeTab === "overview" && /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "16px" }, children: [
|
|
585
602
|
/* @__PURE__ */ jsx(LicenseStatus, { detailed: true }),
|
|
586
603
|
license && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
587
604
|
/* @__PURE__ */ jsxs("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: "12px" }, children: [
|
|
588
605
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
589
|
-
/* @__PURE__ */ jsx("span", { style: { fontSize: "12px", color: "#6b7280" }, children: "Licensee" }),
|
|
606
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: "12px", color: "#6b7280" }, children: t("licensing.licensee", "Licensee") }),
|
|
590
607
|
/* @__PURE__ */ jsx("p", { style: { margin: "2px 0 0", fontWeight: 500 }, children: license.licensee })
|
|
591
608
|
] }),
|
|
592
609
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
593
|
-
/* @__PURE__ */ jsx("span", { style: { fontSize: "12px", color: "#6b7280" }, children: "Email" }),
|
|
610
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: "12px", color: "#6b7280" }, children: t("licensing.email", "Email") }),
|
|
594
611
|
/* @__PURE__ */ jsx("p", { style: { margin: "2px 0 0", fontWeight: 500 }, children: license.email })
|
|
595
612
|
] }),
|
|
596
613
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
597
|
-
/* @__PURE__ */ jsx("span", { style: { fontSize: "12px", color: "#6b7280" }, children: "Seats" }),
|
|
614
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: "12px", color: "#6b7280" }, children: t("licensing.seats", "Seats") }),
|
|
598
615
|
/* @__PURE__ */ jsxs("p", { style: { margin: "2px 0 0", fontWeight: 500 }, children: [
|
|
599
616
|
license.activeSeats,
|
|
600
617
|
" / ",
|
|
@@ -602,8 +619,8 @@ function LicensePortal({
|
|
|
602
619
|
] })
|
|
603
620
|
] }),
|
|
604
621
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
605
|
-
/* @__PURE__ */ jsx("span", { style: { fontSize: "12px", color: "#6b7280" }, children: "Expires" }),
|
|
606
|
-
/* @__PURE__ */ jsx("p", { style: { margin: "2px 0 0", fontWeight: 500 }, children: license.expiresAt ? new Date(license.expiresAt).toLocaleDateString() : "Perpetual" })
|
|
622
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: "12px", color: "#6b7280" }, children: t("licensing.expires", "Expires") }),
|
|
623
|
+
/* @__PURE__ */ jsx("p", { style: { margin: "2px 0 0", fontWeight: 500 }, children: license.expiresAt ? new Date(license.expiresAt).toLocaleDateString() : t("licensing.perpetual", "Perpetual") })
|
|
607
624
|
] })
|
|
608
625
|
] }),
|
|
609
626
|
/* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
@@ -620,7 +637,7 @@ function LicensePortal({
|
|
|
620
637
|
backgroundColor: "#fff",
|
|
621
638
|
cursor: refreshing ? "not-allowed" : "pointer"
|
|
622
639
|
},
|
|
623
|
-
children: refreshing ? "Refreshing..." : "Refresh"
|
|
640
|
+
children: refreshing ? t("licensing.refreshing", "Refreshing...") : t("licensing.refresh", "Refresh")
|
|
624
641
|
}
|
|
625
642
|
),
|
|
626
643
|
/* @__PURE__ */ jsx(
|
|
@@ -636,26 +653,33 @@ function LicensePortal({
|
|
|
636
653
|
backgroundColor: "#fff",
|
|
637
654
|
cursor: "pointer"
|
|
638
655
|
},
|
|
639
|
-
children: "Deactivate"
|
|
656
|
+
children: t("licensing.deactivate", "Deactivate")
|
|
640
657
|
}
|
|
641
658
|
)
|
|
642
659
|
] })
|
|
643
660
|
] }),
|
|
644
|
-
!license && !error && /* @__PURE__ */ jsx("p", { style: { color: "#6b7280" }, children:
|
|
661
|
+
!license && !error && /* @__PURE__ */ jsx("p", { style: { color: "#6b7280" }, children: t(
|
|
662
|
+
"licensing.noActiveLicenseGoTo",
|
|
663
|
+
"No active license. Go to the Activation tab to enter your license key."
|
|
664
|
+
) }),
|
|
645
665
|
error && /* @__PURE__ */ jsx("p", { style: { color: "#dc2626" }, children: error })
|
|
646
666
|
] }),
|
|
647
667
|
!loading && activeTab === "activation" && /* @__PURE__ */ jsx(LicenseActivator, { onActivated: () => setActiveTab("overview") }),
|
|
648
668
|
!loading && activeTab === "seats" && /* @__PURE__ */ jsx("div", { children: license ? /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "12px" }, children: [
|
|
649
669
|
/* @__PURE__ */ jsxs("div", { style: { fontSize: "14px", color: "#374151" }, children: [
|
|
650
670
|
/* @__PURE__ */ jsx("strong", { children: license.activeSeats }),
|
|
651
|
-
"
|
|
671
|
+
" ",
|
|
672
|
+
t("licensing.of", "of"),
|
|
652
673
|
" ",
|
|
653
674
|
/* @__PURE__ */ jsx("strong", { children: license.maxSeats ?? "∞" }),
|
|
654
|
-
"
|
|
675
|
+
" ",
|
|
676
|
+
t("licensing.seatsInUse", "seats in use"),
|
|
655
677
|
license.floatingSeats != null && /* @__PURE__ */ jsxs("span", { children: [
|
|
656
|
-
"
|
|
657
|
-
|
|
658
|
-
|
|
678
|
+
" ",
|
|
679
|
+
t("licensing.floating", "({floatingSeats} floating)").replace(
|
|
680
|
+
"{floatingSeats}",
|
|
681
|
+
String(license.floatingSeats)
|
|
682
|
+
)
|
|
659
683
|
] })
|
|
660
684
|
] }),
|
|
661
685
|
/* @__PURE__ */ jsx(
|
|
@@ -681,13 +705,11 @@ function LicensePortal({
|
|
|
681
705
|
)
|
|
682
706
|
}
|
|
683
707
|
),
|
|
684
|
-
/* @__PURE__ */
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
] })
|
|
690
|
-
] }) : /* @__PURE__ */ jsx("p", { style: { color: "#6b7280" }, children: "Activate a license to view seat information." }) }),
|
|
708
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: "12px", color: "#9ca3af" }, children: t("licensing.machinesBound", "Machines bound: {boundMachines} / {maxMachines}").replace("{boundMachines}", String(license.boundMachines.length)).replace("{maxMachines}", String(license.maxMachines)) })
|
|
709
|
+
] }) : /* @__PURE__ */ jsx("p", { style: { color: "#6b7280" }, children: t(
|
|
710
|
+
"licensing.activateALicenseToView",
|
|
711
|
+
"Activate a license to view seat information."
|
|
712
|
+
) }) }),
|
|
691
713
|
!loading && activeTab === "features" && /* @__PURE__ */ jsx("div", { children: license ? /* @__PURE__ */ jsxs(
|
|
692
714
|
"ul",
|
|
693
715
|
{
|
|
@@ -718,10 +740,13 @@ function LicensePortal({
|
|
|
718
740
|
},
|
|
719
741
|
f
|
|
720
742
|
)),
|
|
721
|
-
license.features.length === 0 && /* @__PURE__ */ jsx("li", { style: { color: "#6b7280", fontSize: "14px" }, children:
|
|
743
|
+
license.features.length === 0 && /* @__PURE__ */ jsx("li", { style: { color: "#6b7280", fontSize: "14px" }, children: t(
|
|
744
|
+
"licensing.noExplicitFeaturesTierBased",
|
|
745
|
+
"No explicit features — tier-based access applies."
|
|
746
|
+
) })
|
|
722
747
|
]
|
|
723
748
|
}
|
|
724
|
-
) : /* @__PURE__ */ jsx("p", { style: { color: "#6b7280" }, children: "Activate a license to view features." }) }),
|
|
749
|
+
) : /* @__PURE__ */ jsx("p", { style: { color: "#6b7280" }, children: t("licensing.activateALicenseToView2", "Activate a license to view features.") }) }),
|
|
725
750
|
!loading && activeTab === "plans" && /* @__PURE__ */ jsx(
|
|
726
751
|
LicenseComparison,
|
|
727
752
|
{
|
|
@@ -743,6 +768,7 @@ function NiceLicenseManager({
|
|
|
743
768
|
style,
|
|
744
769
|
className
|
|
745
770
|
}) {
|
|
771
|
+
const { t } = useNiceTranslation();
|
|
746
772
|
const [search, setSearch] = useState("");
|
|
747
773
|
const [expandedKey, setExpandedKey] = useState(null);
|
|
748
774
|
const handleSearch = (value) => {
|
|
@@ -778,7 +804,7 @@ function NiceLicenseManager({
|
|
|
778
804
|
backgroundColor: "#f9fafb"
|
|
779
805
|
},
|
|
780
806
|
children: [
|
|
781
|
-
/* @__PURE__ */ jsx("h3", { style: { margin: 0, fontSize: "16px", color: "#111" }, children: "License Manager" }),
|
|
807
|
+
/* @__PURE__ */ jsx("h3", { style: { margin: 0, fontSize: "16px", color: "#111" }, children: t("licensing.licenseManager", "License Manager") }),
|
|
782
808
|
/* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
783
809
|
/* @__PURE__ */ jsx(
|
|
784
810
|
"input",
|
|
@@ -786,7 +812,7 @@ function NiceLicenseManager({
|
|
|
786
812
|
type: "text",
|
|
787
813
|
value: search,
|
|
788
814
|
onChange: (e) => handleSearch(e.target.value),
|
|
789
|
-
placeholder: "Search licenses...",
|
|
815
|
+
placeholder: t("licensing.searchLicenses", "Search licenses..."),
|
|
790
816
|
style: {
|
|
791
817
|
padding: "6px 12px",
|
|
792
818
|
fontSize: "13px",
|
|
@@ -811,7 +837,7 @@ function NiceLicenseManager({
|
|
|
811
837
|
borderRadius: "6px",
|
|
812
838
|
cursor: "pointer"
|
|
813
839
|
},
|
|
814
|
-
children: "+ Generate"
|
|
840
|
+
children: t("licensing.generate", "+ Generate")
|
|
815
841
|
}
|
|
816
842
|
)
|
|
817
843
|
] })
|
|
@@ -819,7 +845,7 @@ function NiceLicenseManager({
|
|
|
819
845
|
}
|
|
820
846
|
),
|
|
821
847
|
/* @__PURE__ */ jsxs("div", { style: { maxHeight: "500px", overflow: "auto" }, children: [
|
|
822
|
-
filtered.length === 0 && /* @__PURE__ */ jsx("p", { style: { padding: "20px", textAlign: "center", color: "#6b7280" }, children: search ? "No licenses match your search." : "No licenses found." }),
|
|
848
|
+
filtered.length === 0 && /* @__PURE__ */ jsx("p", { style: { padding: "20px", textAlign: "center", color: "#6b7280" }, children: search ? t("licensing.noLicensesMatchYourSearch", "No licenses match your search.") : t("licensing.noLicensesFound", "No licenses found.") }),
|
|
823
849
|
filtered.map((lic) => {
|
|
824
850
|
const isExpanded = expandedKey === lic.key;
|
|
825
851
|
return /* @__PURE__ */ jsxs(
|
|
@@ -887,15 +913,15 @@ function NiceLicenseManager({
|
|
|
887
913
|
},
|
|
888
914
|
children: [
|
|
889
915
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
890
|
-
/* @__PURE__ */ jsx("span", { style: { fontSize: "11px", color: "#9ca3af" }, children: "Issued" }),
|
|
916
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: "11px", color: "#9ca3af" }, children: t("licensing.issued", "Issued") }),
|
|
891
917
|
/* @__PURE__ */ jsx("div", { style: { fontSize: "13px" }, children: new Date(lic.issuedAt).toLocaleDateString() })
|
|
892
918
|
] }),
|
|
893
919
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
894
|
-
/* @__PURE__ */ jsx("span", { style: { fontSize: "11px", color: "#9ca3af" }, children: "Expires" }),
|
|
895
|
-
/* @__PURE__ */ jsx("div", { style: { fontSize: "13px" }, children: lic.expiresAt ? new Date(lic.expiresAt).toLocaleDateString() : "Perpetual" })
|
|
920
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: "11px", color: "#9ca3af" }, children: t("licensing.expires", "Expires") }),
|
|
921
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: "13px" }, children: lic.expiresAt ? new Date(lic.expiresAt).toLocaleDateString() : t("licensing.perpetual", "Perpetual") })
|
|
896
922
|
] }),
|
|
897
923
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
898
|
-
/* @__PURE__ */ jsx("span", { style: { fontSize: "11px", color: "#9ca3af" }, children: "Seats" }),
|
|
924
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: "11px", color: "#9ca3af" }, children: t("licensing.seats", "Seats") }),
|
|
899
925
|
/* @__PURE__ */ jsxs("div", { style: { fontSize: "13px" }, children: [
|
|
900
926
|
lic.activeSeats,
|
|
901
927
|
" / ",
|
|
@@ -903,11 +929,11 @@ function NiceLicenseManager({
|
|
|
903
929
|
] })
|
|
904
930
|
] }),
|
|
905
931
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
906
|
-
/* @__PURE__ */ jsx("span", { style: { fontSize: "11px", color: "#9ca3af" }, children: "Features" }),
|
|
907
|
-
/* @__PURE__ */
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
932
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: "11px", color: "#9ca3af" }, children: t("licensing.features", "Features") }),
|
|
933
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: "13px" }, children: t("licensing.enabled", "{features} enabled").replace(
|
|
934
|
+
"{features}",
|
|
935
|
+
String(lic.features.length)
|
|
936
|
+
) })
|
|
911
937
|
] })
|
|
912
938
|
]
|
|
913
939
|
}
|
|
@@ -928,7 +954,7 @@ function NiceLicenseManager({
|
|
|
928
954
|
backgroundColor: "#fff",
|
|
929
955
|
cursor: "pointer"
|
|
930
956
|
},
|
|
931
|
-
children: "Extend 1 Year"
|
|
957
|
+
children: t("licensing.extend1Year", "Extend 1 Year")
|
|
932
958
|
}
|
|
933
959
|
),
|
|
934
960
|
onAddSeats && lic.status !== "revoked" && /* @__PURE__ */ jsx(
|
|
@@ -946,10 +972,10 @@ function NiceLicenseManager({
|
|
|
946
972
|
backgroundColor: "#fff",
|
|
947
973
|
cursor: "pointer"
|
|
948
974
|
},
|
|
949
|
-
children: "+5 Seats"
|
|
975
|
+
children: t("licensing.n5Seats", "+5 Seats")
|
|
950
976
|
}
|
|
951
977
|
),
|
|
952
|
-
onChangeTier && lic.status !== "revoked" && /* @__PURE__ */
|
|
978
|
+
onChangeTier && lic.status !== "revoked" && /* @__PURE__ */ jsx(
|
|
953
979
|
"select",
|
|
954
980
|
{
|
|
955
981
|
onClick: (e) => e.stopPropagation(),
|
|
@@ -962,14 +988,7 @@ function NiceLicenseManager({
|
|
|
962
988
|
borderRadius: "4px",
|
|
963
989
|
cursor: "pointer"
|
|
964
990
|
},
|
|
965
|
-
children: [
|
|
966
|
-
/* @__PURE__ */ jsx("option", { value: "trial", children: "Trial" }),
|
|
967
|
-
/* @__PURE__ */ jsx("option", { value: "personal", children: "Personal" }),
|
|
968
|
-
/* @__PURE__ */ jsx("option", { value: "team", children: "Team" }),
|
|
969
|
-
/* @__PURE__ */ jsx("option", { value: "enterprise", children: "Enterprise" }),
|
|
970
|
-
/* @__PURE__ */ jsx("option", { value: "site", children: "Site" }),
|
|
971
|
-
/* @__PURE__ */ jsx("option", { value: "oem", children: "OEM" })
|
|
972
|
-
]
|
|
991
|
+
children: TIER_ORDER.map((tier) => /* @__PURE__ */ jsx("option", { value: tier, children: t(`licensing.tier.${tier}`, TIER_NAMES[tier]) }, tier))
|
|
973
992
|
}
|
|
974
993
|
),
|
|
975
994
|
onRevoke && lic.status !== "revoked" && /* @__PURE__ */ jsx(
|
|
@@ -988,7 +1007,7 @@ function NiceLicenseManager({
|
|
|
988
1007
|
backgroundColor: "#fff",
|
|
989
1008
|
cursor: "pointer"
|
|
990
1009
|
},
|
|
991
|
-
children: "Revoke"
|
|
1010
|
+
children: t("licensing.revoke", "Revoke")
|
|
992
1011
|
}
|
|
993
1012
|
)
|
|
994
1013
|
] })
|
|
@@ -1010,13 +1029,13 @@ function NiceLicenseManager({
|
|
|
1010
1029
|
color: "#6b7280"
|
|
1011
1030
|
},
|
|
1012
1031
|
children: [
|
|
1013
|
-
filtered.length,
|
|
1014
|
-
"
|
|
1015
|
-
filtered.length !== 1 ? "s" : "",
|
|
1016
|
-
search && ` matching "${search}"`,
|
|
1032
|
+
(filtered.length === 1 ? t("licensing.licenseCountOne", "{count} license") : t("licensing.licenseCountMany", "{count} licenses")).replace("{count}", String(filtered.length)),
|
|
1033
|
+
search && t("licensing.matching", ' matching "{search}"').replace("{search}", String(search)),
|
|
1017
1034
|
" · ",
|
|
1018
|
-
|
|
1019
|
-
|
|
1035
|
+
t("licensing.activeCount", "{count} active").replace(
|
|
1036
|
+
"{count}",
|
|
1037
|
+
String(licenses.filter((l) => l.status === "valid").length)
|
|
1038
|
+
)
|
|
1020
1039
|
]
|
|
1021
1040
|
}
|
|
1022
1041
|
)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nice2dev/licensing",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Nice2Dev Enterprise Licensing System — license key generation, validation, hardware fingerprinting, seat management and feature gating",
|
|
5
5
|
"author": "NiceToDev <contact@nicetodev.com>",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
],
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@nice2dev/icons": "^1.2.0",
|
|
61
|
+
"@nice2dev/ui-core": "^1.2.0",
|
|
61
62
|
"react": ">=17.0.0",
|
|
62
63
|
"react-dom": ">=17.0.0"
|
|
63
64
|
},
|
|
@@ -67,12 +68,15 @@
|
|
|
67
68
|
}
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
|
70
|
-
"@nice2dev/icons": "^1.2.
|
|
71
|
+
"@nice2dev/icons": "^1.2.2",
|
|
72
|
+
"@nice2dev/ui-core": "^1.2.2",
|
|
71
73
|
"@stripe/stripe-js": "^9.15.0",
|
|
74
|
+
"@testing-library/react": "^16.3.3",
|
|
72
75
|
"@types/node": "^22.10.0",
|
|
73
76
|
"@types/react": "^19.2.18",
|
|
74
77
|
"@types/react-dom": "^19.2.7",
|
|
75
78
|
"@vitejs/plugin-react": "^4.7.0",
|
|
79
|
+
"jsdom": "^29.0.0",
|
|
76
80
|
"react": "^19.2.8",
|
|
77
81
|
"react-dom": "^19.2.8",
|
|
78
82
|
"typescript": "^5.9.3",
|