@colveor/admin 0.0.0-stage → 0.5.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/LICENSE.md +106 -0
- package/TAILWINDADMIN-LICENSE +21 -0
- package/dist/account/data.d.ts +1 -0
- package/dist/account/data.js +44 -0
- package/dist/account/profile.d.ts +6 -0
- package/dist/account/profile.js +118 -0
- package/dist/account/sessions.d.ts +1 -0
- package/dist/account/sessions.js +26 -0
- package/dist/account/shared.d.ts +26 -0
- package/dist/account/shared.js +44 -0
- package/dist/account/two-factor.d.ts +5 -0
- package/dist/account/two-factor.js +60 -0
- package/dist/actions.d.ts +39 -0
- package/dist/actions.js +81 -0
- package/dist/api/audit.gen.d.ts +80 -0
- package/dist/api/audit.gen.js +43 -0
- package/dist/api/auth.gen.d.ts +537 -0
- package/dist/api/auth.gen.js +313 -0
- package/dist/api/errors.gen.d.ts +16 -0
- package/dist/api/errors.gen.js +2 -0
- package/dist/api/gormx.gen.d.ts +60 -0
- package/dist/api/gormx.gen.js +16 -0
- package/dist/api/health.gen.d.ts +103 -0
- package/dist/api/health.gen.js +23 -0
- package/dist/api/index.gen.d.ts +21 -0
- package/dist/api/index.gen.js +22 -0
- package/dist/api/invitations.gen.d.ts +128 -0
- package/dist/api/invitations.gen.js +57 -0
- package/dist/api/ledger.gen.d.ts +269 -0
- package/dist/api/ledger.gen.js +113 -0
- package/dist/api/msgtemplate.gen.d.ts +31 -0
- package/dist/api/msgtemplate.gen.js +2 -0
- package/dist/api/notifications.gen.d.ts +66 -0
- package/dist/api/notifications.gen.js +28 -0
- package/dist/api/outbox.gen.d.ts +8 -0
- package/dist/api/outbox.gen.js +2 -0
- package/dist/api/queue.gen.d.ts +112 -0
- package/dist/api/queue.gen.js +15 -0
- package/dist/api/rbac.gen.d.ts +406 -0
- package/dist/api/rbac.gen.js +191 -0
- package/dist/api/reauth.gen.d.ts +289 -0
- package/dist/api/reauth.gen.js +122 -0
- package/dist/api/recorded_payments.gen.d.ts +171 -0
- package/dist/api/recorded_payments.gen.js +79 -0
- package/dist/api/sessions.gen.d.ts +64 -0
- package/dist/api/sessions.gen.js +48 -0
- package/dist/api/settings.gen.d.ts +147 -0
- package/dist/api/settings.gen.js +69 -0
- package/dist/api/storage.gen.d.ts +327 -0
- package/dist/api/storage.gen.js +208 -0
- package/dist/api/support_access.gen.d.ts +155 -0
- package/dist/api/support_access.gen.js +131 -0
- package/dist/api/users.gen.d.ts +407 -0
- package/dist/api/users.gen.js +159 -0
- package/dist/api/verification.gen.d.ts +427 -0
- package/dist/api/verification.gen.js +280 -0
- package/dist/api/webhooks.gen.d.ts +110 -0
- package/dist/api/webhooks.gen.js +45 -0
- package/dist/auth-layout.d.ts +9 -0
- package/dist/auth-layout.js +5 -0
- package/dist/client.d.ts +41 -0
- package/dist/client.js +72 -0
- package/dist/config.d.ts +27 -0
- package/dist/config.js +82 -0
- package/dist/dates.d.ts +4 -0
- package/dist/dates.js +16 -0
- package/dist/header.d.ts +12 -0
- package/dist/header.js +105 -0
- package/dist/icons.d.ts +2 -0
- package/dist/icons.js +15 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +42 -0
- package/dist/kit/avatar.d.ts +5 -0
- package/dist/kit/avatar.js +16 -0
- package/dist/kit/badge.d.ts +10 -0
- package/dist/kit/badge.js +31 -0
- package/dist/kit/card.d.ts +12 -0
- package/dist/kit/card.js +7 -0
- package/dist/kit/code-area.d.ts +15 -0
- package/dist/kit/code-area.js +69 -0
- package/dist/kit/dropdown.d.ts +26 -0
- package/dist/kit/dropdown.js +67 -0
- package/dist/kit/filter-tabs.d.ts +9 -0
- package/dist/kit/filter-tabs.js +7 -0
- package/dist/kit/modal.d.ts +8 -0
- package/dist/kit/modal.js +15 -0
- package/dist/kit/page-header.d.ts +13 -0
- package/dist/kit/page-header.js +13 -0
- package/dist/kit/search.d.ts +4 -0
- package/dist/kit/search.js +16 -0
- package/dist/kit/tooltip.d.ts +17 -0
- package/dist/kit/tooltip.js +52 -0
- package/dist/message-editor.d.ts +9 -0
- package/dist/message-editor.js +80 -0
- package/dist/money.d.ts +10 -0
- package/dist/money.js +17 -0
- package/dist/next.d.ts +6 -0
- package/dist/next.js +19 -0
- package/dist/pages/account.d.ts +1 -0
- package/dist/pages/account.js +47 -0
- package/dist/pages/audit.d.ts +1 -0
- package/dist/pages/audit.js +88 -0
- package/dist/pages/forgot-password.d.ts +1 -0
- package/dist/pages/forgot-password.js +73 -0
- package/dist/pages/ledger.d.ts +1 -0
- package/dist/pages/ledger.js +132 -0
- package/dist/pages/roles.d.ts +1 -0
- package/dist/pages/roles.js +102 -0
- package/dist/pages/settings.d.ts +1 -0
- package/dist/pages/settings.js +86 -0
- package/dist/pages/sign-in.d.ts +5 -0
- package/dist/pages/sign-in.js +117 -0
- package/dist/pages/status.d.ts +1 -0
- package/dist/pages/status.js +122 -0
- package/dist/pages/support.d.ts +1 -0
- package/dist/pages/support.js +90 -0
- package/dist/pages/teams.d.ts +1 -0
- package/dist/pages/teams.js +94 -0
- package/dist/pages/users.d.ts +1 -0
- package/dist/pages/users.js +158 -0
- package/dist/pages/webhooks.d.ts +1 -0
- package/dist/pages/webhooks.js +88 -0
- package/dist/permissions.d.ts +5 -0
- package/dist/permissions.js +31 -0
- package/dist/proof.d.ts +10 -0
- package/dist/proof.js +78 -0
- package/dist/proxy.d.ts +10 -0
- package/dist/proxy.js +166 -0
- package/dist/retry.d.ts +8 -0
- package/dist/retry.js +30 -0
- package/dist/router.d.ts +13 -0
- package/dist/router.js +14 -0
- package/dist/setting-fields.d.ts +12 -0
- package/dist/setting-fields.js +102 -0
- package/dist/setting-list.d.ts +22 -0
- package/dist/setting-list.js +78 -0
- package/dist/shell.d.ts +40 -0
- package/dist/shell.js +97 -0
- package/dist/support.d.ts +37 -0
- package/dist/support.js +76 -0
- package/dist/table.d.ts +40 -0
- package/dist/table.js +73 -0
- package/dist/ui.d.ts +39 -0
- package/dist/ui.js +56 -0
- package/dist/user-actions.d.ts +30 -0
- package/dist/user-actions.js +129 -0
- package/dist/user-roles.d.ts +4 -0
- package/dist/user-roles.js +51 -0
- package/dist/user-row-menu.d.ts +14 -0
- package/dist/user-row-menu.js +45 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +3 -0
- package/package.json +59 -4
- package/README.md +0 -3
package/dist/support.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
// Support grants (docs/support-access.md) shown in a table, and the team's
|
|
4
|
+
// side: <TeamSupportGrants> approves, denies and revokes the grants on one
|
|
5
|
+
// team. It is for the project's own app, where team owners are (they hold
|
|
6
|
+
// support.manage through their team role, not as platform admins).
|
|
7
|
+
import { useState } from "react";
|
|
8
|
+
import { Cancelled, useAction } from "./actions";
|
|
9
|
+
import * as support from "./api/support_access.gen";
|
|
10
|
+
import { api } from "./client";
|
|
11
|
+
import { formatDateTime } from "./dates";
|
|
12
|
+
import { DataTable } from "./table";
|
|
13
|
+
import { Alert } from "./ui";
|
|
14
|
+
const small = "rounded-lg border border-gray-300 px-3 py-1.5 text-xs text-gray-700 hover:bg-gray-50 disabled:opacity-40 dark:border-gray-700 dark:text-gray-300";
|
|
15
|
+
const TONE = {
|
|
16
|
+
[support.StatusPending]: "bg-amber-50 text-amber-700 dark:bg-amber-500/15 dark:text-amber-400",
|
|
17
|
+
[support.StatusActive]: "bg-green-50 text-green-700 dark:bg-green-500/15 dark:text-green-500",
|
|
18
|
+
};
|
|
19
|
+
export function GrantStatus({ grant }) {
|
|
20
|
+
return (_jsx("span", { className: `rounded-full px-2 py-0.5 text-xs ${TONE[grant.status] ?? "bg-gray-100 text-gray-600 dark:bg-white/5 dark:text-gray-400"}`, children: grant.status }));
|
|
21
|
+
}
|
|
22
|
+
/** The columns every grant table shows; extra ones go after. */
|
|
23
|
+
export function grantColumns(extra = []) {
|
|
24
|
+
return [
|
|
25
|
+
{
|
|
26
|
+
header: "Team",
|
|
27
|
+
cell: (g) => (_jsxs("span", { className: "font-mono text-xs", children: [g.team.kind, "/", g.team.id] })),
|
|
28
|
+
},
|
|
29
|
+
{ header: "Role", cell: (g) => g.role },
|
|
30
|
+
{ header: "Status", cell: (g) => _jsx(GrantStatus, { grant: g }) },
|
|
31
|
+
{ header: "Reason", cell: (g) => g.reason },
|
|
32
|
+
{
|
|
33
|
+
header: "Until",
|
|
34
|
+
cell: (g) => formatDateTime(g.ends_at),
|
|
35
|
+
},
|
|
36
|
+
...extra,
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
/** Runs a change on a grant, showing its error; bumps reload after. */
|
|
40
|
+
export function useGrantChange() {
|
|
41
|
+
const { run, dialogs } = useAction();
|
|
42
|
+
const [error, setError] = useState("");
|
|
43
|
+
const [reload, setReload] = useState(0);
|
|
44
|
+
const change = async (send) => {
|
|
45
|
+
setError("");
|
|
46
|
+
try {
|
|
47
|
+
await run(send);
|
|
48
|
+
setReload((n) => n + 1);
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
if (!(err instanceof Cancelled)) {
|
|
52
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const refresh = () => setReload((n) => n + 1);
|
|
57
|
+
return { change, error, reload, refresh, dialogs };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The support grants on team and the teams below it, with Approve and Deny
|
|
61
|
+
* for a pending one and Revoke for an open one. Needs support.manage in the
|
|
62
|
+
* team, from the user's own role.
|
|
63
|
+
*/
|
|
64
|
+
export function TeamSupportGrants({ team }) {
|
|
65
|
+
const { change, error, reload, dialogs } = useGrantChange();
|
|
66
|
+
const base = `/v1/teams/${encodeURIComponent(team.kind)}/${encodeURIComponent(team.id)}/support-grants`;
|
|
67
|
+
const act = (g, what) => change((o) => api.post(`${base}/${g.id}/${what}`, undefined, o));
|
|
68
|
+
const open = (g) => (g.status === support.StatusPending || g.status === support.StatusActive) &&
|
|
69
|
+
Date.parse(g.ends_at) > Date.now();
|
|
70
|
+
return (_jsxs("div", { className: "space-y-3", children: [error !== "" && _jsx(Alert, { children: error }), _jsx(DataTable, { path: base, reload: reload, empty: "No one from support has asked for access.", columns: grantColumns([
|
|
71
|
+
{
|
|
72
|
+
header: "",
|
|
73
|
+
cell: (g) => (_jsxs("span", { className: "flex gap-2", children: [g.status === support.StatusPending && open(g) && (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: small, onClick: () => act(g, "approve"), children: "Approve" }), _jsx("button", { type: "button", className: small, onClick: () => act(g, "deny"), children: "Deny" })] })), g.status === support.StatusActive && open(g) && (_jsx("button", { type: "button", className: small, onClick: () => act(g, "revoke"), children: "Revoke" }))] })),
|
|
74
|
+
},
|
|
75
|
+
]) }), dialogs] }));
|
|
76
|
+
}
|
package/dist/table.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type * as gormx from "./api/gormx.gen";
|
|
3
|
+
export interface Column<T> {
|
|
4
|
+
header: string;
|
|
5
|
+
cell(row: T): ReactNode;
|
|
6
|
+
/**
|
|
7
|
+
* The column the API sorts the whole list by (?sort=<key>&dir=asc|desc):
|
|
8
|
+
* its header becomes a button. Only for columns the endpoint sorts by.
|
|
9
|
+
*/
|
|
10
|
+
sortKey?: string;
|
|
11
|
+
/** The CSV's text, when cell isn't plain text. */
|
|
12
|
+
text?(row: T): string;
|
|
13
|
+
}
|
|
14
|
+
export interface DataTableProps<T> {
|
|
15
|
+
/** The list endpoint ("/v1/audit"). */
|
|
16
|
+
path: string;
|
|
17
|
+
columns: Column<T>[];
|
|
18
|
+
/** Filters, sent as the query; a change starts again at the first page. */
|
|
19
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
20
|
+
/** Rows per page. Default: the API's (pagination.default_limit). */
|
|
21
|
+
limit?: number;
|
|
22
|
+
/** A row's key. Default: its id. */
|
|
23
|
+
rowKey?(row: T): string;
|
|
24
|
+
/** Changing it loads the page again (after a change to a row). */
|
|
25
|
+
reload?: unknown;
|
|
26
|
+
empty?: ReactNode;
|
|
27
|
+
/** A click anywhere on a row (opens it). */
|
|
28
|
+
onRowClick?(row: T): void;
|
|
29
|
+
/** Changes each page after it loads: joins what other endpoints know. */
|
|
30
|
+
transform?(page: gormx.Page<unknown>): Promise<gormx.Page<T>>;
|
|
31
|
+
/** Shows the table in a Card with this title. */
|
|
32
|
+
title?: string;
|
|
33
|
+
/** In the card's header, before the download button. */
|
|
34
|
+
actions?: ReactNode;
|
|
35
|
+
/** Above the rows, in the card: FilterTabs. */
|
|
36
|
+
toolbar?: ReactNode;
|
|
37
|
+
/** The CSV's file name: shows the download button. */
|
|
38
|
+
download?: string;
|
|
39
|
+
}
|
|
40
|
+
export declare function DataTable<T>(props: DataTableProps<T>): import("react").JSX.Element;
|
package/dist/table.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
// A table of one list endpoint, a page at a time: the standard pagination
|
|
4
|
+
// (gormx.Page: items, next_page, previous_page; ?limit and ?page). With a
|
|
5
|
+
// title it sits in a Card, with a CSV download of the page shown. Use it
|
|
6
|
+
// for every list, so they all look and work the same.
|
|
7
|
+
import { useEffect, useState } from "react";
|
|
8
|
+
import { api } from "./client";
|
|
9
|
+
import { Card } from "./kit/card";
|
|
10
|
+
import { iconButton } from "./kit/dropdown";
|
|
11
|
+
import { Alert } from "./ui";
|
|
12
|
+
export function DataTable(props) {
|
|
13
|
+
const { path, columns, query, limit, rowKey, reload, empty, transform } = props;
|
|
14
|
+
// The page token: "" is the first page.
|
|
15
|
+
const [page, setPage] = useState("");
|
|
16
|
+
const [data, setData] = useState(null);
|
|
17
|
+
const [error, setError] = useState("");
|
|
18
|
+
// Until a header is clicked, the API's own order.
|
|
19
|
+
const [sort, setSort] = useState(null);
|
|
20
|
+
const filters = JSON.stringify({
|
|
21
|
+
...query,
|
|
22
|
+
...(sort && { sort: sort.key, dir: sort.desc ? "desc" : "asc" }),
|
|
23
|
+
});
|
|
24
|
+
// New filters: back to the first page.
|
|
25
|
+
useEffect(() => setPage(""), [filters, path]);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
let current = true;
|
|
28
|
+
setError("");
|
|
29
|
+
api
|
|
30
|
+
.get(path, { ...JSON.parse(filters), limit, page: page || undefined })
|
|
31
|
+
.then((res) => transform?.(res) ?? res)
|
|
32
|
+
.then((res) => current && setData(res))
|
|
33
|
+
.catch((err) => current && setError(err.message));
|
|
34
|
+
return () => {
|
|
35
|
+
current = false;
|
|
36
|
+
};
|
|
37
|
+
// transform is left out: a new function each render would loop.
|
|
38
|
+
}, [path, filters, limit, page, reload]);
|
|
39
|
+
const key = rowKey ?? ((row) => String(row.id));
|
|
40
|
+
const total = data === null ? "" : `${data.total.toLocaleString()}${data.total_capped ? "+" : ""}`;
|
|
41
|
+
const rows = data?.items ?? [];
|
|
42
|
+
const csv = () => {
|
|
43
|
+
const text = (c, row) => {
|
|
44
|
+
const v = c.text?.(row) ?? c.cell(row);
|
|
45
|
+
return typeof v === "string" || typeof v === "number" ? String(v) : "";
|
|
46
|
+
};
|
|
47
|
+
const quote = (v) => `"${v.replaceAll('"', '""')}"`;
|
|
48
|
+
const lines = [columns.map((c) => quote(c.header))];
|
|
49
|
+
for (const row of rows) {
|
|
50
|
+
lines.push(columns.map((c) => quote(text(c, row))));
|
|
51
|
+
}
|
|
52
|
+
const a = document.createElement("a");
|
|
53
|
+
a.href = URL.createObjectURL(new Blob([lines.join("\n")], { type: "text/csv" }));
|
|
54
|
+
a.download = `${props.download}.csv`;
|
|
55
|
+
a.click();
|
|
56
|
+
URL.revokeObjectURL(a.href);
|
|
57
|
+
};
|
|
58
|
+
const inCard = props.title !== undefined;
|
|
59
|
+
const table = (_jsxs(_Fragment, { children: [props.toolbar && _jsx("div", { className: "pb-5", children: props.toolbar }), error !== "" && _jsx(Alert, { children: error }), _jsxs("div", { className: inCard ? "overflow-hidden rounded-xl border border-gray-200 dark:border-gray-800" : "", children: [_jsx("div", { className: "overflow-x-auto", children: _jsxs("table", { className: "min-w-full text-left text-sm", children: [_jsx("thead", { className: "border-b border-gray-200 bg-gray-50/50 dark:bg-white/[0.02] text-gray-500 dark:border-gray-800 dark:text-gray-400", children: _jsx("tr", { children: columns.map((c) => (_jsx("th", { className: "px-5 py-3 font-medium", children: c.sortKey === undefined ? (c.header) : (_jsxs("button", { type: "button", onClick: () => setSort({
|
|
60
|
+
key: c.sortKey ?? "",
|
|
61
|
+
desc: sort?.key === c.sortKey && !sort?.desc,
|
|
62
|
+
}), className: "inline-flex items-center gap-1 hover:text-gray-800 dark:hover:text-white/90", children: [c.header, _jsx("span", { className: "text-xs", "aria-hidden": "true", children: sort?.key === c.sortKey ? (sort.desc ? "↓" : "↑") : "↕" })] })) }, c.header))) }) }), _jsx("tbody", { className: "divide-y divide-gray-100 text-gray-800 dark:divide-gray-800 dark:text-white/90", children: rows.map((row) => (_jsx("tr", { onClick: props.onRowClick && (() => props.onRowClick?.(row)), className: props.onRowClick
|
|
63
|
+
? "cursor-pointer transition-colors hover:bg-gray-50 dark:hover:bg-white/[0.03]"
|
|
64
|
+
: undefined, children: columns.map((c) => (_jsx("td", { className: "px-5 py-3.5", children: c.cell(row) }, c.header))) }, key(row)))) })] }) }), data !== null && data.items.length === 0 && (_jsx("p", { className: "px-5 py-5 text-sm text-gray-500 dark:text-gray-400", children: empty ?? "Nothing here yet." })), data !== null && (_jsxs("div", { className: "flex items-center justify-between border-t border-gray-100 px-5 py-3 text-sm text-gray-500 dark:border-gray-800 dark:text-gray-400", children: [_jsxs("span", { children: ["Page ", data.page, " of ", data.total_pages, data.total_capped ? "+" : "", " \u00B7 ", total, " in all"] }), _jsxs("span", { className: "space-x-4", children: [_jsx(PageLink, { token: data.previous_page, onPage: setPage, children: "Previous" }), _jsx(PageLink, { token: data.next_page, onPage: setPage, children: "Next" })] })] }))] })] }));
|
|
65
|
+
if (props.title === undefined) {
|
|
66
|
+
return (_jsx("div", { className: "overflow-hidden rounded-2xl border border-gray-200 bg-white dark:border-gray-800 dark:bg-white/[0.03]", children: table }));
|
|
67
|
+
}
|
|
68
|
+
return (_jsx(Card, { title: props.title, actions: _jsxs(_Fragment, { children: [props.actions, props.download !== undefined && (_jsx("button", { type: "button", "aria-label": "Download CSV", title: "Download CSV", onClick: csv, className: iconButton, children: _jsx("svg", { width: 20, height: 20, viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "M12 4v11m0 0l-4-4m4 4l4-4M5 19h14", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round" }) }) }))] }), children: table }));
|
|
69
|
+
}
|
|
70
|
+
function PageLink(props) {
|
|
71
|
+
const { token } = props;
|
|
72
|
+
return (_jsx("button", { type: "button", disabled: token == null, onClick: () => token != null && props.onPage(token), className: "hover:text-gray-800 disabled:opacity-40 dark:hover:text-white/90", children: props.children }));
|
|
73
|
+
}
|
package/dist/ui.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export declare function Alert({ children }: {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
}): import("react").JSX.Element;
|
|
5
|
+
export declare function Field(props: {
|
|
6
|
+
label: string;
|
|
7
|
+
name: string;
|
|
8
|
+
type?: string;
|
|
9
|
+
autoComplete?: string;
|
|
10
|
+
multiline?: boolean;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
12
|
+
export declare function Button(props: {
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
type?: "submit" | "button";
|
|
15
|
+
busy?: boolean;
|
|
16
|
+
quiet?: boolean;
|
|
17
|
+
onClick?: () => void;
|
|
18
|
+
}): import("react").JSX.Element;
|
|
19
|
+
/** A centred box: the sign-in page's frame, and a dialog's. */
|
|
20
|
+
export declare function Panel({ title, children }: {
|
|
21
|
+
title: string;
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
}): import("react").JSX.Element;
|
|
24
|
+
/** A modal over the page. */
|
|
25
|
+
export declare function Dialog({ title, children }: {
|
|
26
|
+
title: string;
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
}): import("react").JSX.Element;
|
|
29
|
+
/**
|
|
30
|
+
* A one-time code, one box per digit: typing moves on, backspace moves
|
|
31
|
+
* back, pasting fills them all. onComplete runs once every box is filled.
|
|
32
|
+
*/
|
|
33
|
+
export declare function CodeInput(props: {
|
|
34
|
+
length?: number;
|
|
35
|
+
value: string;
|
|
36
|
+
onChange(value: string): void;
|
|
37
|
+
onComplete?(value: string): void;
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
}): import("react").JSX.Element;
|
package/dist/ui.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// Small pieces the package's pages share, in the template's Tailwind
|
|
4
|
+
// classes (TailAdmin's theme: brand-*, and Tailwind's gray-* and red-*).
|
|
5
|
+
import { useEffect, useId, useRef } from "react";
|
|
6
|
+
export function Alert({ children }) {
|
|
7
|
+
return (_jsx("p", { role: "alert", className: "mb-4 rounded-lg bg-red-50 px-4 py-3 text-sm text-red-600", children: children }));
|
|
8
|
+
}
|
|
9
|
+
export function Field(props) {
|
|
10
|
+
const id = useId();
|
|
11
|
+
const className = "w-full rounded-lg border border-gray-300 bg-transparent px-4 text-sm text-gray-800 focus:border-brand-300 focus:outline-none focus:ring-3 focus:ring-brand-500/10 dark:border-gray-700 dark:text-white/90";
|
|
12
|
+
return (_jsxs("div", { children: [_jsx("label", { htmlFor: id, className: "mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-400", children: props.label }), props.multiline === true ? (_jsx("textarea", { id: id, required: true, name: props.name, rows: 3, className: `${className} py-3` })) : (_jsx("input", { id: id, required: true, name: props.name, type: props.type ?? "text", autoComplete: props.autoComplete, className: `${className} h-11` }))] }));
|
|
13
|
+
}
|
|
14
|
+
export function Button(props) {
|
|
15
|
+
return (_jsx("button", { type: props.type ?? "button", disabled: props.busy, onClick: props.onClick, className: props.quiet === true
|
|
16
|
+
? "h-11 w-full rounded-lg text-sm text-gray-500 hover:text-gray-700 disabled:opacity-50 dark:text-gray-400"
|
|
17
|
+
: "h-11 w-full rounded-lg bg-brand-500 text-sm font-medium text-white hover:bg-brand-600 disabled:opacity-50", children: props.children }));
|
|
18
|
+
}
|
|
19
|
+
/** A centred box: the sign-in page's frame, and a dialog's. */
|
|
20
|
+
export function Panel({ title, children }) {
|
|
21
|
+
return (_jsxs("div", { className: "w-full max-w-md rounded-2xl border border-gray-200 bg-white p-8 dark:border-gray-800 dark:bg-gray-900", children: [_jsx("h2", { className: "mb-6 text-xl font-medium text-gray-800 dark:text-white/90", children: title }), children] }));
|
|
22
|
+
}
|
|
23
|
+
/** A modal over the page. */
|
|
24
|
+
export function Dialog({ title, children }) {
|
|
25
|
+
return (_jsx("div", { role: "dialog", "aria-modal": "true", className: "fixed inset-0 z-50 flex animate-fade-in items-center justify-center bg-gray-900/50 p-6 backdrop-blur-sm", children: _jsx("div", { className: "w-full max-w-md animate-pop-in", children: _jsx(Panel, { title: title, children: children }) }) }));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A one-time code, one box per digit: typing moves on, backspace moves
|
|
29
|
+
* back, pasting fills them all. onComplete runs once every box is filled.
|
|
30
|
+
*/
|
|
31
|
+
export function CodeInput(props) {
|
|
32
|
+
const length = props.length ?? 6;
|
|
33
|
+
const refs = useRef([]);
|
|
34
|
+
const digits = Array.from({ length }, (_, i) => props.value[i] ?? "");
|
|
35
|
+
// The first box takes the typing as the code is asked for.
|
|
36
|
+
useEffect(() => refs.current[0]?.focus(), []);
|
|
37
|
+
const set = (next) => {
|
|
38
|
+
const v = next.replace(/\D/g, "").slice(0, length);
|
|
39
|
+
props.onChange(v);
|
|
40
|
+
refs.current[Math.min(v.length, length - 1)]?.focus();
|
|
41
|
+
if (v.length === length) {
|
|
42
|
+
props.onComplete?.(v);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
return (_jsx("div", { className: "flex justify-between gap-2", children: digits.map((d, i) => (_jsx("input", { ref: (el) => {
|
|
46
|
+
refs.current[i] = el;
|
|
47
|
+
}, "aria-label": `Digit ${i + 1}`, inputMode: "numeric", autoComplete: i === 0 ? "one-time-code" : "off", maxLength: length, value: d, disabled: props.disabled, onChange: (e) => set(props.value.slice(0, i) + e.target.value), onKeyDown: (e) => {
|
|
48
|
+
if (e.key === "Backspace" && d === "" && i > 0) {
|
|
49
|
+
props.onChange(props.value.slice(0, i - 1));
|
|
50
|
+
refs.current[i - 1]?.focus();
|
|
51
|
+
}
|
|
52
|
+
}, onPaste: (e) => {
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
set(e.clipboardData.getData("text"));
|
|
55
|
+
}, className: "h-12 w-12 rounded-lg border border-gray-300 bg-transparent text-center text-lg font-medium text-gray-800 transition focus:border-brand-300 focus:outline-none focus:ring-3 focus:ring-brand-500/10 disabled:opacity-60 dark:border-gray-700 dark:text-white/90" }, i))) }));
|
|
56
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as users from "./api/users.gen";
|
|
2
|
+
type User = users.UserResponse;
|
|
3
|
+
export interface UserAction {
|
|
4
|
+
label: string;
|
|
5
|
+
run(): void;
|
|
6
|
+
/** Red in a menu: it takes something away. */
|
|
7
|
+
danger?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The admin's actions on a user, each shown only with its permission: the
|
|
11
|
+
* preview's buttons and the users list's row menu are both made from it.
|
|
12
|
+
* Render dialogs, and show error and done (the last outcome).
|
|
13
|
+
*/
|
|
14
|
+
export declare function useUserActions(user: User, onChange: (u: User) => void): {
|
|
15
|
+
actions: UserAction[];
|
|
16
|
+
error: string;
|
|
17
|
+
done: string;
|
|
18
|
+
busy: boolean;
|
|
19
|
+
dialogs: import("react").ReactNode;
|
|
20
|
+
clear: () => void;
|
|
21
|
+
};
|
|
22
|
+
export declare function UserActions({ user, onChange }: {
|
|
23
|
+
user: User;
|
|
24
|
+
onChange(u: User): void;
|
|
25
|
+
}): import("react").JSX.Element | null;
|
|
26
|
+
/** The user's active sessions (users.read_sessions): they show IPs. */
|
|
27
|
+
export declare function UserSessions({ userId }: {
|
|
28
|
+
userId: string;
|
|
29
|
+
}): import("react").JSX.Element | null;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// An admin's actions on one user, and their sessions (docs/user-admin.md).
|
|
4
|
+
// Each action shows for its permission; the API also checks the admin
|
|
5
|
+
// outranks the user and isn't them. Every change asks for a reason
|
|
6
|
+
// (useAction), and resetting 2FA for re-authentication.
|
|
7
|
+
import { useEffect, useState } from "react";
|
|
8
|
+
import { Cancelled, useAction } from "./actions";
|
|
9
|
+
import * as auth from "./api/auth.gen";
|
|
10
|
+
import * as reauth from "./api/reauth.gen";
|
|
11
|
+
import * as sessions from "./api/sessions.gen";
|
|
12
|
+
import * as users from "./api/users.gen";
|
|
13
|
+
import { api } from "./client";
|
|
14
|
+
import { formatDate, formatDateTime } from "./dates";
|
|
15
|
+
import { useCan } from "./shell";
|
|
16
|
+
import { Alert } from "./ui";
|
|
17
|
+
const button = "rounded-lg border border-gray-300 px-3 py-1.5 text-xs text-gray-700 hover:bg-gray-50 disabled:opacity-40 dark:border-gray-700 dark:text-gray-300";
|
|
18
|
+
/**
|
|
19
|
+
* The admin's actions on a user, each shown only with its permission: the
|
|
20
|
+
* preview's buttons and the users list's row menu are both made from it.
|
|
21
|
+
* Render dialogs, and show error and done (the last outcome).
|
|
22
|
+
*/
|
|
23
|
+
export function useUserActions(user, onChange) {
|
|
24
|
+
const canSuspend = useCan(auth.PermissionSuspendUsers);
|
|
25
|
+
const canSignOut = useCan(auth.PermissionSignOutUsers);
|
|
26
|
+
const canReset = useCan(reauth.PermissionResetTwoFactor);
|
|
27
|
+
const canUnlock = useCan(reauth.PermissionUnlockPIN);
|
|
28
|
+
const { run, dialogs } = useAction();
|
|
29
|
+
const [error, setError] = useState("");
|
|
30
|
+
const [done, setDone] = useState("");
|
|
31
|
+
const [busy, setBusy] = useState(false);
|
|
32
|
+
const path = `/v1/users/${user.uid}`;
|
|
33
|
+
const act = async (message, send, confirm) => {
|
|
34
|
+
if (confirm !== undefined && !window.confirm(confirm)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
setError("");
|
|
38
|
+
setDone("");
|
|
39
|
+
setBusy(true);
|
|
40
|
+
try {
|
|
41
|
+
const res = await run(send);
|
|
42
|
+
if (res !== undefined && res !== null && typeof res === "object" && "uid" in res) {
|
|
43
|
+
onChange(res);
|
|
44
|
+
}
|
|
45
|
+
setDone(message);
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
if (!(err instanceof Cancelled)) {
|
|
49
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
setBusy(false);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const actions = [];
|
|
57
|
+
if (canSuspend && user.status === users.UserStatusActive) {
|
|
58
|
+
actions.push({
|
|
59
|
+
label: "Suspend",
|
|
60
|
+
danger: true,
|
|
61
|
+
run: () => act("Suspended: their sessions have ended.", (o) => api.post(`${path}/suspend`, undefined, o), "Suspend this user? They are signed out everywhere at once."),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (canSuspend && user.status === users.UserStatusSuspended) {
|
|
65
|
+
actions.push({
|
|
66
|
+
label: "Reactivate",
|
|
67
|
+
run: () => act("Reactivated: they can sign in again.", (o) => api.post(`${path}/reactivate`, undefined, o)),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (canSignOut) {
|
|
71
|
+
actions.push({
|
|
72
|
+
label: "Sign out everywhere",
|
|
73
|
+
run: () => act("Signed out of every session.", (o) => api.post(`${path}/sign-out`, undefined, o)),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (canReset && user.mfa_enabled) {
|
|
77
|
+
actions.push({
|
|
78
|
+
label: "Reset two-factor",
|
|
79
|
+
danger: true,
|
|
80
|
+
run: () => act("Two-factor sign-in reset: they sign in with their password and set it up again.", (o) => api.delete(`${path}/2fa`, o), "Reset this user's two-factor sign-in? Only do this once you are sure it is them."),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (canUnlock) {
|
|
84
|
+
for (const t of [reauth.PINAuth, reauth.PINTransaction]) {
|
|
85
|
+
actions.push({
|
|
86
|
+
label: `Unlock ${t} PIN`,
|
|
87
|
+
run: () => act(`The ${t} PIN works again.`, (o) => api.post(`${path}/pins/${t}/unlock`, undefined, o)),
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
actions,
|
|
93
|
+
error,
|
|
94
|
+
done,
|
|
95
|
+
busy,
|
|
96
|
+
dialogs,
|
|
97
|
+
clear: () => {
|
|
98
|
+
setError("");
|
|
99
|
+
setDone("");
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export function UserActions({ user, onChange }) {
|
|
104
|
+
const { actions, error, done, busy, dialogs } = useUserActions(user, onChange);
|
|
105
|
+
if (actions.length === 0) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
return (_jsxs("div", { className: "space-y-3", children: [_jsx("h3", { className: "font-medium text-gray-800 dark:text-white/90", children: "Actions" }), error !== "" && _jsx(Alert, { children: error }), done !== "" && _jsx("p", { className: "text-sm text-green-700 dark:text-green-500", children: done }), _jsx("div", { className: "flex flex-wrap gap-2", children: actions.map((a) => (_jsx("button", { type: "button", disabled: busy, className: button, onClick: a.run, children: a.label }, a.label))) }), dialogs] }));
|
|
109
|
+
}
|
|
110
|
+
/** The user's active sessions (users.read_sessions): they show IPs. */
|
|
111
|
+
export function UserSessions({ userId }) {
|
|
112
|
+
const can = useCan(sessions.PermissionReadUserSessions);
|
|
113
|
+
const [list, setList] = useState(null);
|
|
114
|
+
const [error, setError] = useState("");
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
if (!can) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
// Small by design (one user's sessions): not paged.
|
|
120
|
+
api
|
|
121
|
+
.get(`/v1/users/${userId}/sessions`)
|
|
122
|
+
.then((r) => setList(r.sessions))
|
|
123
|
+
.catch((err) => setError(err.message));
|
|
124
|
+
}, [can, userId]);
|
|
125
|
+
if (!can) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
return (_jsxs("div", { className: "space-y-2", children: [_jsx("h3", { className: "font-medium text-gray-800 dark:text-white/90", children: "Sessions" }), error !== "" && _jsx(Alert, { children: error }), list?.length === 0 && (_jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: "No active session." })), _jsx("ul", { className: "space-y-2 text-sm", children: list?.map((s) => (_jsxs("li", { className: "rounded-lg border border-gray-100 p-3 dark:border-gray-800", children: [_jsx("span", { className: "text-gray-800 dark:text-white/90", children: s.device_name || s.device_type || "Unknown device" }), s.app_version !== "" && _jsxs("span", { className: "text-gray-500", children: [" \u00B7 ", s.app_version] }), _jsxs("span", { className: "block text-xs text-gray-500 dark:text-gray-400", children: [s.last_ip, " \u00B7 last seen ", formatDateTime(s.last_seen_at), " \u00B7 since", " ", formatDate(s.created_at)] })] }, s.id))) })] }));
|
|
129
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// One user's roles: shown, and changed by users with rbac.manage. The
|
|
4
|
+
// users page shows it on each user (A4.6). The seeded super admin's roles
|
|
5
|
+
// never change (protected).
|
|
6
|
+
import { useEffect, useState } from "react";
|
|
7
|
+
import { Cancelled, useAction } from "./actions";
|
|
8
|
+
import * as rbac from "./api/rbac.gen";
|
|
9
|
+
import { api } from "./client";
|
|
10
|
+
import { useCan } from "./shell";
|
|
11
|
+
import { Alert } from "./ui";
|
|
12
|
+
export function UserRoles({ userId, onChange }) {
|
|
13
|
+
const [current, setCurrent] = useState(null);
|
|
14
|
+
const [roles, setRoles] = useState([]);
|
|
15
|
+
const [picked, setPicked] = useState([]);
|
|
16
|
+
const [error, setError] = useState("");
|
|
17
|
+
const [busy, setBusy] = useState(false);
|
|
18
|
+
const { run, dialogs } = useAction();
|
|
19
|
+
const editable = useCan(rbac.PermissionManage) && current?.protected === false;
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
Promise.all([
|
|
22
|
+
api.get(`/v1/rbac/users/${userId}/roles`),
|
|
23
|
+
api.get("/v1/rbac/roles"),
|
|
24
|
+
])
|
|
25
|
+
.then(([user, all]) => {
|
|
26
|
+
setCurrent(user);
|
|
27
|
+
setPicked(user.roles);
|
|
28
|
+
setRoles(all.sort((a, b) => b.level - a.level));
|
|
29
|
+
})
|
|
30
|
+
.catch((err) => setError(err.message));
|
|
31
|
+
}, [userId]);
|
|
32
|
+
const save = async () => {
|
|
33
|
+
setError("");
|
|
34
|
+
setBusy(true);
|
|
35
|
+
try {
|
|
36
|
+
setCurrent(await run((o) => api.put(`/v1/rbac/users/${userId}/roles`, { roles: picked }, o)));
|
|
37
|
+
onChange?.();
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
if (!(err instanceof Cancelled)) {
|
|
41
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
setBusy(false);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const changed = current !== null &&
|
|
49
|
+
(picked.length !== current.roles.length || picked.some((r) => !current.roles.includes(r)));
|
|
50
|
+
return (_jsxs("div", { className: "space-y-3", children: [error !== "" && _jsx(Alert, { children: error }), current?.protected && (_jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: "The super admin's roles can't be changed." })), _jsx("div", { className: "space-y-2", children: roles.map((r) => (_jsxs("label", { className: "flex items-center gap-2 text-sm text-gray-800 dark:text-white/90", children: [_jsx("input", { type: "checkbox", checked: picked.includes(r.slug), disabled: !editable, onChange: (e) => setPicked(e.target.checked ? [...picked, r.slug] : picked.filter((s) => s !== r.slug)), className: "size-4 rounded border-gray-300 text-brand-500" }), r.name, _jsx("span", { className: "font-mono text-xs text-gray-500", children: r.slug })] }, r.slug))) }), editable && (_jsx("button", { type: "button", disabled: busy || !changed, onClick: save, className: "rounded-lg bg-brand-500 px-4 py-2 text-sm font-medium text-white hover:bg-brand-600 disabled:opacity-40", children: "Save roles" })), dialogs] }));
|
|
51
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type * as users from "./api/users.gen";
|
|
2
|
+
type User = users.UserResponse;
|
|
3
|
+
/** The name a user goes by: their profile's, else their email or phone. */
|
|
4
|
+
export declare function userName(u: User): string;
|
|
5
|
+
/**
|
|
6
|
+
* A row's "…" menu: view, the roles in a dialog, and the same actions as
|
|
7
|
+
* the preview (useUserActions), with their outcome in a dialog.
|
|
8
|
+
*/
|
|
9
|
+
export declare function UserRowMenu(props: {
|
|
10
|
+
user: User;
|
|
11
|
+
onView(): void;
|
|
12
|
+
onChange(): void;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// The users list's row menu, and the name a user goes by.
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import * as rbac from "./api/rbac.gen";
|
|
6
|
+
import { RowMenu } from "./kit/dropdown";
|
|
7
|
+
import { useCan } from "./shell";
|
|
8
|
+
import { Dialog } from "./ui";
|
|
9
|
+
import { useUserActions } from "./user-actions";
|
|
10
|
+
import { UserRoles } from "./user-roles";
|
|
11
|
+
/** The name a user goes by: their profile's, else their email or phone. */
|
|
12
|
+
export function userName(u) {
|
|
13
|
+
const p = u.details;
|
|
14
|
+
return (p?.display_name ||
|
|
15
|
+
[p?.first_name, p?.last_name].filter(Boolean).join(" ") ||
|
|
16
|
+
u.email ||
|
|
17
|
+
u.phone ||
|
|
18
|
+
u.uid);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A row's "…" menu: view, the roles in a dialog, and the same actions as
|
|
22
|
+
* the preview (useUserActions), with their outcome in a dialog.
|
|
23
|
+
*/
|
|
24
|
+
export function UserRowMenu(props) {
|
|
25
|
+
const canReadRoles = useCan(rbac.PermissionRead);
|
|
26
|
+
const canManageRoles = useCan(rbac.PermissionManage);
|
|
27
|
+
const [roles, setRoles] = useState(false);
|
|
28
|
+
const { actions, error, done, dialogs, clear } = useUserActions(props.user, props.onChange);
|
|
29
|
+
return (
|
|
30
|
+
// Clicks in the menu and its dialogs don't open the row.
|
|
31
|
+
// biome-ignore lint/a11y/noStaticElementInteractions: only stops the row's click
|
|
32
|
+
// biome-ignore lint/a11y/useKeyWithClickEvents: only stops the row's click
|
|
33
|
+
_jsxs("div", { onClick: (e) => e.stopPropagation(), children: [_jsx(RowMenu, { items: [
|
|
34
|
+
{ label: "View", onSelect: props.onView },
|
|
35
|
+
...(canReadRoles
|
|
36
|
+
? [
|
|
37
|
+
{
|
|
38
|
+
label: canManageRoles ? "Assign or change role" : "Roles",
|
|
39
|
+
onSelect: () => setRoles(true),
|
|
40
|
+
},
|
|
41
|
+
]
|
|
42
|
+
: []),
|
|
43
|
+
...actions.map((a) => ({ label: a.label, onSelect: a.run, danger: a.danger })),
|
|
44
|
+
] }), roles && (_jsxs(Dialog, { title: `Roles of ${userName(props.user)}`, children: [_jsx(UserRoles, { userId: props.user.uid, onChange: props.onChange }), _jsx("button", { type: "button", onClick: () => setRoles(false), className: "mt-4 w-full rounded-lg border border-gray-300 px-4 py-2 text-sm text-gray-700 hover:bg-gray-50 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-white/5", children: "Close" })] })), (error !== "" || done !== "") && (_jsxs(Dialog, { title: error !== "" ? "That didn't work" : "Done", children: [_jsx("p", { className: `text-sm ${error !== "" ? "text-red-600" : "text-gray-700 dark:text-gray-300"}`, children: error || done }), _jsx("button", { type: "button", onClick: clear, className: "mt-6 w-full rounded-lg bg-brand-500 px-4 py-2 text-sm font-medium text-white hover:bg-brand-600", children: "OK" })] })), dialogs] }));
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const version = "0.5.2";
|
package/dist/version.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colveor/admin",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.5.2",
|
|
4
|
+
"description": "The admin panel pages for apps built on colveor-go.",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./proxy": {
|
|
13
|
+
"types": "./dist/proxy.d.ts",
|
|
14
|
+
"default": "./dist/proxy.js"
|
|
15
|
+
},
|
|
16
|
+
"./next": {
|
|
17
|
+
"types": "./dist/next.d.ts",
|
|
18
|
+
"default": "./dist/next.js"
|
|
19
|
+
},
|
|
20
|
+
"./pages/*": {
|
|
21
|
+
"types": "./dist/pages/*.d.ts",
|
|
22
|
+
"default": "./dist/pages/*.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"LICENSE.md",
|
|
28
|
+
"TAILWINDADMIN-LICENSE"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsc",
|
|
32
|
+
"typecheck": "tsc --noEmit",
|
|
33
|
+
"test": "node --test test/*.test.ts",
|
|
34
|
+
"check": "npm run typecheck && npm test && npm run build",
|
|
35
|
+
"dev": "tsc --watch --preserveWatchOutput"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"next": ">=16",
|
|
39
|
+
"react": ">=19",
|
|
40
|
+
"react-dom": ">=19"
|
|
41
|
+
},
|
|
42
|
+
"peerDependenciesMeta": {
|
|
43
|
+
"next": {
|
|
44
|
+
"optional": true
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/node": "^24.19.4",
|
|
49
|
+
"@types/react": "^19.3.3",
|
|
50
|
+
"@types/react-dom": "^19.3.0",
|
|
51
|
+
"next": "^16.4.6",
|
|
52
|
+
"react": "^19.3.1",
|
|
53
|
+
"react-dom": "^19.3.1"
|
|
54
|
+
},
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"access": "public"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"qrcode-generator": "^2.0.4"
|
|
60
|
+
}
|
|
61
|
+
}
|
package/README.md
DELETED