@locusgraph/blocks 0.1.1 → 0.2.0
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/README.md +2 -1
- package/dist/dates/local-date.d.ts +3 -0
- package/dist/dates/local-date.js +10 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/keys/keys-table.d.ts +2 -1
- package/dist/keys/keys-table.js +6 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -19,7 +19,8 @@ pnpm add @locusgraph/blocks @locusgraph/components
|
|
|
19
19
|
| `WalletPanel` | `balanceMicroUsd`, `debtMicroUsd`, `grants`. A Rule Grid cell |
|
|
20
20
|
| `CreditPacks` | `packs`, `onBuy(packId)`, `pending`. A Rule Grid cell |
|
|
21
21
|
| `PlanOptions` | `plans`, `actionFor(plan)` for plans that are not current |
|
|
22
|
-
| `KeysTable` | `keys`, `actions(key)` |
|
|
22
|
+
| `KeysTable` | `keys`, `actions(key)`, `highlightedId` to flash a just-created key. Dates render in the viewer's time zone after hydration |
|
|
23
|
+
| `LocalDate` | `value` (ISO string): UTC on the server, the viewer's time zone after hydration |
|
|
23
24
|
| `NoKeys` | `newKeyHref` (omit for read-only roles), `linkComponent` |
|
|
24
25
|
|
|
25
26
|
`WalletPanel` and `CreditPacks` are cells, so put them in a `RuleGrid`:
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
const utcFormat = new Intl.DateTimeFormat("en-US", { dateStyle: "medium", timeZone: "UTC" });
|
|
5
|
+
const localFormat = new Intl.DateTimeFormat("en-US", { dateStyle: "medium" });
|
|
6
|
+
export function LocalDate({ value }) {
|
|
7
|
+
const [hydrated, setHydrated] = useState(false);
|
|
8
|
+
useEffect(() => setHydrated(true), []);
|
|
9
|
+
return (_jsx("time", { dateTime: value, children: (hydrated ? localFormat : utcFormat).format(new Date(value)) }));
|
|
10
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { CreditPacks } from "./billing/credit-packs.js";
|
|
2
2
|
export { PlanOptions } from "./billing/plan-options.js";
|
|
3
3
|
export { WalletPanel } from "./billing/wallet-panel.js";
|
|
4
|
+
export { LocalDate } from "./dates/local-date.js";
|
|
4
5
|
export { KeysTable } from "./keys/keys-table.js";
|
|
5
6
|
export { NoKeys } from "./keys/no-keys.js";
|
|
6
7
|
export * from "./types.js";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { CreditPacks } from "./billing/credit-packs.js";
|
|
2
2
|
export { PlanOptions } from "./billing/plan-options.js";
|
|
3
3
|
export { WalletPanel } from "./billing/wallet-panel.js";
|
|
4
|
+
export { LocalDate } from "./dates/local-date.js";
|
|
4
5
|
export { KeysTable } from "./keys/keys-table.js";
|
|
5
6
|
export { NoKeys } from "./keys/no-keys.js";
|
|
6
7
|
export * from "./types.js";
|
|
@@ -3,6 +3,7 @@ import type { ApiKeyRow } from "../types.js";
|
|
|
3
3
|
type KeysTableProps = {
|
|
4
4
|
keys: ApiKeyRow[];
|
|
5
5
|
actions?: (key: ApiKeyRow) => React.ReactNode;
|
|
6
|
+
highlightedId?: string;
|
|
6
7
|
};
|
|
7
|
-
export declare function KeysTable({ keys, actions }: KeysTableProps): React.JSX.Element;
|
|
8
|
+
export declare function KeysTable({ keys, actions, highlightedId }: KeysTableProps): React.JSX.Element;
|
|
8
9
|
export {};
|
package/dist/keys/keys-table.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@locusgraph/components";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
return
|
|
3
|
+
import { LocalDate } from "../dates/local-date.js";
|
|
4
|
+
function dateOr(value, empty) {
|
|
5
|
+
return value ? _jsx(LocalDate, { value: value }) : empty;
|
|
6
|
+
}
|
|
7
|
+
export function KeysTable({ keys, actions, highlightedId }) {
|
|
8
|
+
return (_jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "Name" }), _jsx(TableHead, { className: "hidden md:table-cell", children: "Key" }), _jsx(TableHead, { children: "Product" }), _jsx(TableHead, { className: "hidden md:table-cell", children: "Created by" }), _jsx(TableHead, { className: "hidden sm:table-cell", children: "Created" }), _jsx(TableHead, { children: "Expires" }), actions && _jsx(TableHead, { className: "w-0" })] }) }), _jsx(TableBody, { children: keys.map((key) => (_jsxs(TableRow, { "data-new": key.id === highlightedId ? "" : undefined, className: "transition-colors duration-1000 data-new:bg-accent", children: [_jsx(TableCell, { className: "font-medium", children: key.name ?? "Untitled" }), _jsx(TableCell, { className: "hidden font-mono text-muted-foreground md:table-cell", children: key.maskedKey }), _jsx(TableCell, { children: key.productLabel }), _jsx(TableCell, { className: "hidden md:table-cell", children: key.createdBy }), _jsx(TableCell, { className: "hidden sm:table-cell", children: dateOr(key.createdAt, "") }), _jsx(TableCell, { children: dateOr(key.expiresAt, "Never") }), actions && _jsx(TableCell, { className: "text-right", children: actions(key) })] }, key.id))) })] }));
|
|
6
9
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@locusgraph/blocks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Product sections built from @locusgraph/components: usage meters and alerts, wallet, credit packs, plan options and API keys.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@locusgraph/components": "0.1.1",
|
|
42
|
-
"@locusgraph/config": "0.1.
|
|
42
|
+
"@locusgraph/config": "0.1.1",
|
|
43
43
|
"@types/node": "^22.0.0",
|
|
44
44
|
"@types/react": "^19.2.0",
|
|
45
45
|
"@types/react-dom": "^19.2.0",
|