hazo_auth 10.26.1 → 10.26.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/dist/components/layouts/user_management/components/user_signup_stats_cards.d.ts +1 -8
- package/dist/components/layouts/user_management/components/user_signup_stats_cards.d.ts.map +1 -1
- package/dist/components/layouts/user_management/components/user_signup_stats_cards.js +8 -90
- package/dist/locales/en.json +1 -0
- package/package.json +5 -5
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
export interface UserSignupStatsCardsProps {
|
|
3
2
|
users: ReadonlyArray<{
|
|
4
3
|
created_at?: string | null;
|
|
@@ -7,11 +6,5 @@ export interface UserSignupStatsCardsProps {
|
|
|
7
6
|
now?: Date;
|
|
8
7
|
className?: string;
|
|
9
8
|
}
|
|
10
|
-
|
|
11
|
-
* Total + rolling-window signup cards (All time, 7d, 30d, 3mo, 6mo, YTD) each
|
|
12
|
-
* with % change vs the prior equal period, plus a larger interactive YTD
|
|
13
|
-
* monthly bar chart with axes, gridlines, and hover tooltips.
|
|
14
|
-
* Computes everything client-side from the already-loaded users list.
|
|
15
|
-
*/
|
|
16
|
-
export declare function UserSignupStatsCards({ users, now, className }: UserSignupStatsCardsProps): React.JSX.Element;
|
|
9
|
+
export declare function UserSignupStatsCards({ users, now, className }: UserSignupStatsCardsProps): import("react").JSX.Element;
|
|
17
10
|
//# sourceMappingURL=user_signup_stats_cards.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user_signup_stats_cards.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/user_management/components/user_signup_stats_cards.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user_signup_stats_cards.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/user_management/components/user_signup_stats_cards.tsx"],"names":[],"mappings":"AAQA,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,aAAa,CAAC;QAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;IACrD,8DAA8D;IAC9D,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,oBAAoB,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,yBAAyB,+BAexF"}
|
|
@@ -1,94 +1,12 @@
|
|
|
1
|
-
// file_description:
|
|
2
|
-
//
|
|
3
|
-
// signups bar chart (axes, gridlines, hover tooltip) for the top of the Manage
|
|
4
|
-
// Users tab. Pure/dependency-free (inline SVG chart, no chart library).
|
|
1
|
+
// file_description: User signup trend summary for the Manage Users tab.
|
|
2
|
+
// Wraps hazo_ui's TrendSummary with user-specific stat computation.
|
|
5
3
|
"use client";
|
|
6
|
-
import { jsx as _jsx
|
|
7
|
-
import { useMemo
|
|
8
|
-
import {
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
import { useMemo } from "react";
|
|
6
|
+
import { computeTrendStats, TrendSummary } from "hazo_ui";
|
|
9
7
|
import { useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
10
|
-
function DeltaBadge({ pct }) {
|
|
11
|
-
const t = useAuthT();
|
|
12
|
-
if (pct === null) {
|
|
13
|
-
return _jsx("span", { className: "text-xs text-muted-foreground", children: "\u2014" });
|
|
14
|
-
}
|
|
15
|
-
const up = pct >= 0;
|
|
16
|
-
const cls = up ? "text-emerald-600" : "text-red-600";
|
|
17
|
-
const arrow = up ? "▲" : "▼";
|
|
18
|
-
return (_jsxs("span", { className: `text-xs font-medium ${cls}`, title: t("user_management.signup_stats.vs_previous"), children: [arrow, " ", up ? "+" : "", pct, "%"] }));
|
|
19
|
-
}
|
|
20
|
-
const STAT_CARD_HEIGHT_PX = 168;
|
|
21
|
-
function StatCard({ w }) {
|
|
22
|
-
const t = useAuthT();
|
|
23
|
-
return (_jsxs("div", { className: "cls_user_signup_stat_card flex min-w-0 flex-col justify-between rounded-lg border bg-card p-4", style: { height: STAT_CARD_HEIGHT_PX }, children: [_jsx("div", { className: "truncate text-xs text-muted-foreground", children: w.label }), _jsxs("div", { className: "flex items-baseline justify-between gap-1", children: [_jsx("span", { className: "text-3xl font-bold tabular-nums", children: w.count.toLocaleString() }), w.key !== "all" && _jsx(DeltaBadge, { pct: w.pctChange })] }), w.key !== "all" && w.prevCount !== null && (_jsx("div", { className: "truncate text-xs text-muted-foreground", children: t("user_management.signup_stats.prev_count", { count: w.prevCount.toLocaleString() }) })), w.key === "all" && (_jsx("div", { className: "truncate text-xs text-muted-foreground", children: t("user_management.signup_stats.total_users") }))] }));
|
|
24
|
-
}
|
|
25
|
-
/** Round a value up to a "nice" axis maximum (1/2/5 * 10^n steps). */
|
|
26
|
-
function niceMax(n) {
|
|
27
|
-
if (n <= 0)
|
|
28
|
-
return 1;
|
|
29
|
-
const exp = Math.floor(Math.log10(n));
|
|
30
|
-
const base = Math.pow(10, exp);
|
|
31
|
-
const frac = n / base;
|
|
32
|
-
let niceFrac;
|
|
33
|
-
if (frac <= 1)
|
|
34
|
-
niceFrac = 1;
|
|
35
|
-
else if (frac <= 2)
|
|
36
|
-
niceFrac = 2;
|
|
37
|
-
else if (frac <= 5)
|
|
38
|
-
niceFrac = 5;
|
|
39
|
-
else
|
|
40
|
-
niceFrac = 10;
|
|
41
|
-
return niceFrac * base;
|
|
42
|
-
}
|
|
43
|
-
function YtdMiniChart({ data }) {
|
|
44
|
-
const t = useAuthT();
|
|
45
|
-
const [hoverIndex, setHoverIndex] = useState(null);
|
|
46
|
-
const total = data.reduce((n, d) => n + d.count, 0);
|
|
47
|
-
const rawMax = Math.max(1, ...data.map((d) => d.count));
|
|
48
|
-
const max = niceMax(rawMax);
|
|
49
|
-
const mid = Math.round(max / 2);
|
|
50
|
-
// Chart geometry. H mirrors the plot area left after the header row + padding
|
|
51
|
-
// are subtracted from STAT_CARD_HEIGHT_PX, so the rendered SVG (stretched via
|
|
52
|
-
// preserveAspectRatio="none") stays close to a 1 viewBox-unit : 1px scale.
|
|
53
|
-
const W = 480;
|
|
54
|
-
const H = 120;
|
|
55
|
-
const marginLeft = 34;
|
|
56
|
-
const marginRight = 8;
|
|
57
|
-
const marginTop = 16;
|
|
58
|
-
const marginBottom = 20;
|
|
59
|
-
const plotW = W - marginLeft - marginRight;
|
|
60
|
-
const plotH = H - marginTop - marginBottom;
|
|
61
|
-
const gap = 6;
|
|
62
|
-
const n = Math.max(1, data.length);
|
|
63
|
-
const colW = plotW / n;
|
|
64
|
-
const bw = Math.max(1, colW - gap);
|
|
65
|
-
const yFor = (value) => marginTop + plotH - (value / max) * plotH;
|
|
66
|
-
const hovered = hoverIndex !== null ? data[hoverIndex] : null;
|
|
67
|
-
return (_jsxs("div", { className: "cls_user_signup_ytd_chart col-span-6 flex min-w-0 flex-col rounded-lg border bg-card p-3", style: { height: STAT_CARD_HEIGHT_PX }, children: [_jsxs("div", { className: "flex shrink-0 items-baseline justify-between", children: [_jsx("div", { className: "truncate text-[11px] text-muted-foreground", children: t("user_management.signup_stats.ytd_title") }), _jsx("div", { className: "text-sm font-semibold tabular-nums", children: total.toLocaleString() })] }), _jsxs("div", { className: "relative mt-2 min-h-0 flex-1", children: [_jsxs("svg", { role: "img", "aria-label": t("user_management.signup_stats.ytd_aria", {
|
|
68
|
-
list: data.map((d) => `${d.label} ${d.count}`).join(", "),
|
|
69
|
-
}), viewBox: `0 0 ${W} ${H}`, preserveAspectRatio: "none", className: "h-full w-full", children: [[0, mid, max].map((tick) => {
|
|
70
|
-
const y = yFor(tick);
|
|
71
|
-
return (_jsxs("g", { children: [_jsx("line", { x1: marginLeft, x2: W - marginRight, y1: y, y2: y, stroke: "currentColor", strokeOpacity: 0.1 }), _jsx("text", { x: marginLeft - 6, y: y, dy: 3, textAnchor: "end", fontSize: 9, className: "fill-muted-foreground", children: tick.toLocaleString() })] }, tick));
|
|
72
|
-
}), _jsx("line", { x1: marginLeft, x2: W - marginRight, y1: marginTop + plotH, y2: marginTop + plotH, stroke: "currentColor", strokeOpacity: 0.2 }), data.map((d, i) => {
|
|
73
|
-
const barH = Math.round((d.count / max) * plotH);
|
|
74
|
-
const colX = marginLeft + i * colW;
|
|
75
|
-
const barX = colX + (colW - bw) / 2;
|
|
76
|
-
const barY = marginTop + plotH - barH;
|
|
77
|
-
const centerX = colX + colW / 2;
|
|
78
|
-
const isDimmed = hoverIndex !== null && hoverIndex !== i;
|
|
79
|
-
return (_jsxs("g", { onMouseEnter: () => setHoverIndex(i), onMouseLeave: () => setHoverIndex(null), children: [_jsx("rect", { x: colX, y: marginTop, width: colW, height: plotH, fill: "transparent" }), _jsx("rect", { x: barX, y: barY, width: bw, height: Math.max(0, barH), rx: 2, className: "fill-primary", fillOpacity: isDimmed ? 0.45 : 1, children: _jsx("title", { children: `${d.label}: ${d.count} ${t("user_management.signup_stats.tooltip_suffix")}` }) }), _jsx("text", { x: centerX, y: barY - 4, textAnchor: "middle", fontSize: 10, fontWeight: 600, className: "fill-foreground", children: d.count }), _jsx("text", { x: centerX, y: marginTop + plotH + 14, textAnchor: "middle", fontSize: 9, className: "fill-muted-foreground", children: d.label })] }, d.label));
|
|
80
|
-
})] }), hovered && hoverIndex !== null && (_jsxs("div", { className: "pointer-events-none absolute z-10 -translate-x-1/2 -translate-y-full rounded-md border bg-popover px-2 py-1 text-[10px] font-medium text-popover-foreground shadow-sm", style: {
|
|
81
|
-
left: `${Math.min(92, Math.max(8, ((marginLeft + hoverIndex * (plotW / n) + plotW / n / 2) / W) * 100))}%`,
|
|
82
|
-
top: `${((marginTop + plotH - (hovered.count / max) * plotH) / H) * 100}%`,
|
|
83
|
-
}, children: [hovered.label, ": ", hovered.count, " ", t("user_management.signup_stats.tooltip_suffix")] }))] })] }));
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Total + rolling-window signup cards (All time, 7d, 30d, 3mo, 6mo, YTD) each
|
|
87
|
-
* with % change vs the prior equal period, plus a larger interactive YTD
|
|
88
|
-
* monthly bar chart with axes, gridlines, and hover tooltips.
|
|
89
|
-
* Computes everything client-side from the already-loaded users list.
|
|
90
|
-
*/
|
|
91
8
|
export function UserSignupStatsCards({ users, now, className }) {
|
|
92
|
-
const
|
|
93
|
-
|
|
9
|
+
const t = useAuthT();
|
|
10
|
+
const stats = useMemo(() => computeTrendStats(users, now), [users, now]);
|
|
11
|
+
return (_jsx(TrendSummary, { windows: stats.windows, chartData: stats.ytdMonthly, chartTitle: t("user_management.signup_stats.ytd_title"), chartTooltipSuffix: t("user_management.signup_stats.tooltip_suffix"), totalLabel: t("user_management.signup_stats.total_users"), prevTemplate: t("user_management.signup_stats.prev_template"), className: className }));
|
|
94
12
|
}
|
package/dist/locales/en.json
CHANGED
|
@@ -594,6 +594,7 @@
|
|
|
594
594
|
"app_user_data.clear_dialog.confirming": "Clearing...",
|
|
595
595
|
"user_management.signup_stats.vs_previous": "vs. previous equal period",
|
|
596
596
|
"user_management.signup_stats.prev_count": "prev {{count}}",
|
|
597
|
+
"user_management.signup_stats.prev_template": "prev {count}",
|
|
597
598
|
"user_management.signup_stats.total_users": "total users",
|
|
598
599
|
"user_management.signup_stats.ytd_title": "Signups by month (YTD)",
|
|
599
600
|
"user_management.signup_stats.ytd_aria": "Year-to-date signups by month: {{list}}",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hazo_auth",
|
|
3
|
-
"version": "10.26.
|
|
3
|
+
"version": "10.26.2",
|
|
4
4
|
"description": "Zero-config authentication UI components for Next.js with RBAC, OAuth, scope-based multi-tenancy, and invitations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"authentication",
|
|
@@ -363,11 +363,11 @@
|
|
|
363
363
|
"eslint-plugin-storybook": "^10.0.6",
|
|
364
364
|
"hazo_api": "^2.9.0",
|
|
365
365
|
"hazo_config": "^2.6.0",
|
|
366
|
-
"hazo_connect": "^4.3.
|
|
366
|
+
"hazo_connect": "^4.3.5",
|
|
367
367
|
"hazo_core": "^2.5.0",
|
|
368
|
-
"hazo_logs": "^2.3.
|
|
369
|
-
"hazo_notify": "^6.8.
|
|
370
|
-
"hazo_theme": "^1.4.
|
|
368
|
+
"hazo_logs": "^2.3.1",
|
|
369
|
+
"hazo_notify": "^6.8.1",
|
|
370
|
+
"hazo_theme": "^1.4.2",
|
|
371
371
|
"hazo_ui": "^6.18.0",
|
|
372
372
|
"input-otp": "^1.4.0",
|
|
373
373
|
"jest": "^30.2.0",
|