@gaulatti/bleecker 0.1.45 → 0.1.47
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 +4 -0
- package/dist/components/access-panel.d.ts +90 -0
- package/dist/components/access-panel.js +336 -0
- package/dist/components/arm-take.d.ts +17 -0
- package/dist/components/arm-take.js +93 -0
- package/dist/components/button.d.ts +1 -1
- package/dist/components/drawer.d.ts +20 -3
- package/dist/components/drawer.js +14 -2
- package/dist/components/key-cap.d.ts +7 -0
- package/dist/components/key-cap.js +10 -0
- package/dist/components/meter.d.ts +19 -0
- package/dist/components/meter.js +11 -0
- package/dist/components/on-air-strip.d.ts +35 -0
- package/dist/components/on-air-strip.js +16 -0
- package/dist/components/segmented-filter.d.ts +19 -0
- package/dist/components/segmented-filter.js +13 -0
- package/dist/components/state-pill.d.ts +16 -0
- package/dist/components/state-pill.js +19 -0
- package/dist/components/table.d.ts +15 -1
- package/dist/components/table.js +21 -3
- package/dist/components/transport.d.ts +29 -0
- package/dist/components/transport.js +59 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -84,6 +84,10 @@ Individual component entry points are also available:
|
|
|
84
84
|
import { Button } from '@gaulatti/bleecker/components/button';
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
+
## Access management
|
|
88
|
+
|
|
89
|
+
`AccessPanel` renders a service's Access page (personal access tokens, token switch, role holders and history) against the `AccessClient` contract. See [docs/access-panel.md](./docs/access-panel.md).
|
|
90
|
+
|
|
87
91
|
## Design principles
|
|
88
92
|
|
|
89
93
|
- Encode Sans is the primary voice. Use the `font-secondary` utility to opt specific supporting or editorial copy into Libre Franklin.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The access-management contract every service screen implements
|
|
3
|
+
* (gaulatti/pompeii#50, pinned for ariston#230, monitor#193 and alcantara#224).
|
|
4
|
+
* The service backend forwards each call to Pompeii; this panel only renders.
|
|
5
|
+
*/
|
|
6
|
+
export type AccessToken = {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
display_prefix: string;
|
|
10
|
+
permissions: string[];
|
|
11
|
+
created_at: string;
|
|
12
|
+
expires_at: string;
|
|
13
|
+
last_used_at: string;
|
|
14
|
+
created_via_application: string;
|
|
15
|
+
last_used_application: string;
|
|
16
|
+
};
|
|
17
|
+
export type AccessRole = {
|
|
18
|
+
id: number;
|
|
19
|
+
name: string;
|
|
20
|
+
permissions: string[];
|
|
21
|
+
};
|
|
22
|
+
export type AccessGrant = {
|
|
23
|
+
id: number;
|
|
24
|
+
user_id: number;
|
|
25
|
+
user_email: string;
|
|
26
|
+
role_id: number;
|
|
27
|
+
role_name: string;
|
|
28
|
+
team_id: number;
|
|
29
|
+
granted_at: string;
|
|
30
|
+
};
|
|
31
|
+
export type AccessHistoryEntry = {
|
|
32
|
+
at: string;
|
|
33
|
+
action: string;
|
|
34
|
+
actor_email: string;
|
|
35
|
+
target: string;
|
|
36
|
+
via_application: string;
|
|
37
|
+
via_client: string;
|
|
38
|
+
};
|
|
39
|
+
export type AccessErrorCode = 'unauthenticated' | 'forbidden' | 'invalid_request' | 'tokens_off' | 'not_found' | 'access_unavailable';
|
|
40
|
+
export type AccessError = {
|
|
41
|
+
status: number;
|
|
42
|
+
error: AccessErrorCode;
|
|
43
|
+
};
|
|
44
|
+
export interface AccessCreateTokenInput {
|
|
45
|
+
name: string;
|
|
46
|
+
expires_in_days?: number;
|
|
47
|
+
no_expiry?: boolean;
|
|
48
|
+
permissions?: string[];
|
|
49
|
+
all_held_in_application?: boolean;
|
|
50
|
+
}
|
|
51
|
+
export interface AccessClient {
|
|
52
|
+
listMyTokens(): Promise<AccessToken[]>;
|
|
53
|
+
createMyToken(input: AccessCreateTokenInput): Promise<{
|
|
54
|
+
token: AccessToken;
|
|
55
|
+
value: string;
|
|
56
|
+
}>;
|
|
57
|
+
revokeMyToken(id: string): Promise<void>;
|
|
58
|
+
getTokenSwitch(): Promise<boolean>;
|
|
59
|
+
setTokenSwitch(enabled: boolean): Promise<boolean>;
|
|
60
|
+
listRoles(): Promise<AccessRole[]>;
|
|
61
|
+
listGrants(): Promise<AccessGrant[]>;
|
|
62
|
+
grant(input: {
|
|
63
|
+
user_id: number;
|
|
64
|
+
role_id: number;
|
|
65
|
+
}): Promise<AccessGrant>;
|
|
66
|
+
revokeGrant(id: number): Promise<void>;
|
|
67
|
+
listHistory(input?: {
|
|
68
|
+
limit?: number;
|
|
69
|
+
before?: string;
|
|
70
|
+
}): Promise<AccessHistoryEntry[]>;
|
|
71
|
+
/**
|
|
72
|
+
* Optional: the caller's own permission keys in this application (their
|
|
73
|
+
* effective permissions there). When present, "Only these" is a picker of
|
|
74
|
+
* exactly these keys; when absent, keys are typed.
|
|
75
|
+
*/
|
|
76
|
+
listMyPermissions?(): Promise<string[]>;
|
|
77
|
+
}
|
|
78
|
+
export interface AccessPanelProps {
|
|
79
|
+
application: {
|
|
80
|
+
key: string;
|
|
81
|
+
name: string;
|
|
82
|
+
};
|
|
83
|
+
className?: string;
|
|
84
|
+
client: AccessClient;
|
|
85
|
+
/** Copies the new token value; defaults to the browser clipboard. */
|
|
86
|
+
onCopy?: (value: string) => void;
|
|
87
|
+
}
|
|
88
|
+
/** Plain words for a refused change; never Pompeii's own message. */
|
|
89
|
+
export declare function accessErrorMessage(cause: unknown): string;
|
|
90
|
+
export declare function AccessPanel({ application, className, client, onCopy }: AccessPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { Copy, KeyRound, Trash2 } from 'lucide-react';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { AlertDialog } from './alert-dialog.js';
|
|
6
|
+
import { Button } from './button.js';
|
|
7
|
+
import { Card } from './card.js';
|
|
8
|
+
import { Checkbox } from './checkbox.js';
|
|
9
|
+
import { Empty } from './empty.js';
|
|
10
|
+
import { ErrorState } from './error-state.js';
|
|
11
|
+
import { Field } from './field.js';
|
|
12
|
+
import { Input } from './input.js';
|
|
13
|
+
import { Modal } from './modal.js';
|
|
14
|
+
import { RadioGroup } from './radio-group.js';
|
|
15
|
+
import { Select } from './select.js';
|
|
16
|
+
import { Switch } from './switch.js';
|
|
17
|
+
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from './table.js';
|
|
18
|
+
import { Textarea } from './textarea.js';
|
|
19
|
+
import { cn } from '../utils/cn.js';
|
|
20
|
+
const HISTORY_PAGE = 50;
|
|
21
|
+
const EXPIRY_OPTIONS = [
|
|
22
|
+
{ label: '7 days', value: '7' },
|
|
23
|
+
{ label: '30 days', value: '30' },
|
|
24
|
+
{ label: '90 days', value: '90' },
|
|
25
|
+
{ label: '1 year', value: '365' },
|
|
26
|
+
{ label: 'No expiry', value: 'none' }
|
|
27
|
+
];
|
|
28
|
+
function errorCode(cause) {
|
|
29
|
+
const code = cause?.error;
|
|
30
|
+
return typeof code === 'string' ? code : 'unknown';
|
|
31
|
+
}
|
|
32
|
+
/** Plain words for a refused change; never Pompeii's own message. */
|
|
33
|
+
export function accessErrorMessage(cause) {
|
|
34
|
+
switch (errorCode(cause)) {
|
|
35
|
+
case 'unauthenticated':
|
|
36
|
+
return 'Your session has ended. Sign in again to manage access.';
|
|
37
|
+
case 'forbidden':
|
|
38
|
+
return 'You can only change access with permissions you hold yourself.';
|
|
39
|
+
case 'invalid_request':
|
|
40
|
+
return 'That request was not accepted. Check the values and try again.';
|
|
41
|
+
case 'tokens_off':
|
|
42
|
+
return 'Personal access tokens are turned off here.';
|
|
43
|
+
case 'not_found':
|
|
44
|
+
return 'That item no longer exists.';
|
|
45
|
+
case 'access_unavailable':
|
|
46
|
+
return 'Access management is not available yet.';
|
|
47
|
+
default:
|
|
48
|
+
return 'Something went wrong. Try again.';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function personLabel(grant) {
|
|
52
|
+
return grant.user_email || `user ${grant.user_id}`;
|
|
53
|
+
}
|
|
54
|
+
function formatTime(value) {
|
|
55
|
+
if (!value)
|
|
56
|
+
return '—';
|
|
57
|
+
const parsed = new Date(value);
|
|
58
|
+
return Number.isNaN(parsed.getTime()) ? value : parsed.toLocaleString();
|
|
59
|
+
}
|
|
60
|
+
function Section({ title, description, children, actions }) {
|
|
61
|
+
const headingId = React.useId();
|
|
62
|
+
return (_jsxs(Card, { "aria-labelledby": headingId, padding: 'lg', role: 'region', children: [_jsxs("div", { className: 'mb-4 flex flex-wrap items-start justify-between gap-3', children: [_jsxs("div", { className: 'min-w-0', children: [_jsx("h2", { id: headingId, className: 'text-base font-semibold text-text-primary', children: title }), _jsx("p", { className: 'mt-1 text-sm text-text-secondary', children: description })] }), actions] }), children] }));
|
|
63
|
+
}
|
|
64
|
+
function InlineError({ message }) {
|
|
65
|
+
if (!message)
|
|
66
|
+
return null;
|
|
67
|
+
return (_jsx("p", { className: 'mt-3 text-sm text-terracotta', role: 'alert', children: message }));
|
|
68
|
+
}
|
|
69
|
+
export function AccessPanel({ application, className, client, onCopy }) {
|
|
70
|
+
const [state, setState] = React.useState('loading');
|
|
71
|
+
const [tokens, setTokens] = React.useState([]);
|
|
72
|
+
const [tokenSwitch, setTokenSwitchState] = React.useState(false);
|
|
73
|
+
const [canManage, setCanManage] = React.useState(false);
|
|
74
|
+
const [roles, setRoles] = React.useState([]);
|
|
75
|
+
const [grants, setGrants] = React.useState([]);
|
|
76
|
+
const [history, setHistory] = React.useState([]);
|
|
77
|
+
const [historyDone, setHistoryDone] = React.useState(false);
|
|
78
|
+
const unavailable = (cause) => {
|
|
79
|
+
if (errorCode(cause) === 'access_unavailable') {
|
|
80
|
+
setState('unavailable');
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
};
|
|
85
|
+
// A refused change: the whole panel goes "not available" when Pompeii is
|
|
86
|
+
// unreachable; otherwise the section shows the reason in plain words.
|
|
87
|
+
const fail = (cause, show, forbidden) => {
|
|
88
|
+
if (unavailable(cause))
|
|
89
|
+
return;
|
|
90
|
+
show(forbidden && errorCode(cause) === 'forbidden' ? forbidden : accessErrorMessage(cause));
|
|
91
|
+
};
|
|
92
|
+
const load = React.useCallback(async () => {
|
|
93
|
+
setState('loading');
|
|
94
|
+
try {
|
|
95
|
+
const [mine, enabled, recent] = await Promise.all([client.listMyTokens(), client.getTokenSwitch(), client.listHistory({ limit: HISTORY_PAGE })]);
|
|
96
|
+
setTokens(mine);
|
|
97
|
+
setTokenSwitchState(enabled);
|
|
98
|
+
setHistory(recent);
|
|
99
|
+
setHistoryDone(recent.length < HISTORY_PAGE);
|
|
100
|
+
// Holding <app>:access:manage is learned from Pompeii: roles answer 403 otherwise.
|
|
101
|
+
try {
|
|
102
|
+
const [allRoles, allGrants] = await Promise.all([client.listRoles(), client.listGrants()]);
|
|
103
|
+
setRoles(allRoles);
|
|
104
|
+
setGrants(allGrants);
|
|
105
|
+
setCanManage(true);
|
|
106
|
+
}
|
|
107
|
+
catch (cause) {
|
|
108
|
+
if (unavailable(cause))
|
|
109
|
+
return;
|
|
110
|
+
setCanManage(false);
|
|
111
|
+
}
|
|
112
|
+
setState('ready');
|
|
113
|
+
}
|
|
114
|
+
catch (cause) {
|
|
115
|
+
if (!unavailable(cause))
|
|
116
|
+
setState('unavailable');
|
|
117
|
+
}
|
|
118
|
+
}, [client]);
|
|
119
|
+
React.useEffect(() => {
|
|
120
|
+
void load();
|
|
121
|
+
}, [load]);
|
|
122
|
+
if (state === 'unavailable') {
|
|
123
|
+
return (_jsx(ErrorState, { className: className, title: 'Access management is not available yet.', description: `${application.name} cannot reach Pompeii's access service right now.`, onRetry: () => void load(), retryLabel: 'Try again' }));
|
|
124
|
+
}
|
|
125
|
+
if (state === 'loading') {
|
|
126
|
+
return (_jsx("p", { "aria-live": 'polite', className: cn('text-sm text-text-secondary', className), children: "Loading access\u2026" }));
|
|
127
|
+
}
|
|
128
|
+
return (_jsxs("div", { className: cn('flex flex-col gap-6', className), children: [_jsx(MyTokens, { application: application, client: client, onCopy: onCopy, onFailure: fail, setTokens: setTokens, tokenSwitch: tokenSwitch, tokens: tokens }), canManage ? (_jsxs(_Fragment, { children: [_jsx(TokenSwitchSection, { application: application, client: client, enabled: tokenSwitch, onChange: setTokenSwitchState, onFailure: fail }), _jsx(PeopleSection, { application: application, client: client, grants: grants, onFailure: fail, roles: roles, setGrants: setGrants })] })) : null, _jsx(HistorySection, { client: client, done: historyDone, entries: history, onMore: (more) => {
|
|
129
|
+
setHistory((current) => [...current, ...more]);
|
|
130
|
+
setHistoryDone(more.length < HISTORY_PAGE);
|
|
131
|
+
}, onFailure: fail })] }));
|
|
132
|
+
}
|
|
133
|
+
function MyTokens({ application, client, onCopy, onFailure, setTokens, tokenSwitch, tokens }) {
|
|
134
|
+
const [creating, setCreating] = React.useState(false);
|
|
135
|
+
const [revoking, setRevoking] = React.useState(null);
|
|
136
|
+
const [error, setError] = React.useState(null);
|
|
137
|
+
const [busy, setBusy] = React.useState(false);
|
|
138
|
+
// The new value lives only while its dialog is open (gaulatti/bleecker#546).
|
|
139
|
+
const [created, setCreated] = React.useState(null);
|
|
140
|
+
// The confirm dialog is open only while a token is chosen.
|
|
141
|
+
const revoke = async (target) => {
|
|
142
|
+
setBusy(true);
|
|
143
|
+
setError(null);
|
|
144
|
+
try {
|
|
145
|
+
await client.revokeMyToken(target.id);
|
|
146
|
+
setTokens((current) => current.filter((token) => token.id !== target.id));
|
|
147
|
+
setRevoking(null);
|
|
148
|
+
}
|
|
149
|
+
catch (cause) {
|
|
150
|
+
onFailure(cause, setError);
|
|
151
|
+
setRevoking(null);
|
|
152
|
+
}
|
|
153
|
+
finally {
|
|
154
|
+
setBusy(false);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
return (_jsxs(Section, { title: 'Your tokens', description: `Tokens made here reach only ${application.name}'s permissions, and only the ones you hold.`, actions: _jsxs(Button, { disabled: !tokenSwitch, onClick: () => setCreating(true), size: 'sm', children: [_jsx(KeyRound, { size: 15 }), "New token"] }), children: [!tokenSwitch ? _jsx("p", { className: 'mb-3 text-sm text-text-secondary', children: "Personal access tokens are turned off here, so new tokens can't be created." }) : null, tokens.length === 0 ? (_jsx(Empty, { title: 'No tokens yet', description: 'Create a token to let a tool act as you here.' })) : (_jsxs(Table, { "aria-label": 'Your tokens', children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "Name" }), _jsx(TableHead, { children: "Permissions" }), _jsx(TableHead, { children: "Created" }), _jsx(TableHead, { children: "Expires" }), _jsx(TableHead, { children: "Last used" }), _jsx(TableHead, { children: "Created in" }), _jsx(TableHead, { children: "Last used in" }), _jsx(TableHead, { children: _jsx("span", { className: 'sr-only', children: "Actions" }) })] }) }), _jsx(TableBody, { children: tokens.map((token) => (_jsxs(TableRow, { children: [_jsxs(TableCell, { children: [_jsx("div", { className: 'font-medium text-text-primary', children: token.name }), _jsxs("div", { className: 'font-mono text-xs text-text-secondary', children: [token.display_prefix, "\u2026"] })] }), _jsx(TableCell, { className: 'text-xs', children: token.permissions.length === 0 ? 'All of yours' : token.permissions.join(', ') }), _jsx(TableCell, { children: formatTime(token.created_at) }), _jsx(TableCell, { children: token.expires_at ? formatTime(token.expires_at) : 'Never' }), _jsx(TableCell, { children: formatTime(token.last_used_at) }), _jsx(TableCell, { children: token.created_via_application || 'Pompeii' }), _jsx(TableCell, { children: token.last_used_application || '—' }), _jsx(TableCell, { className: 'text-right', children: _jsxs(Button, { "aria-label": `Revoke ${token.name}`, onClick: () => setRevoking(token), size: 'xs', variant: 'ghost', children: [_jsx(Trash2, { size: 14 }), "Revoke"] }) })] }, token.id))) })] })), _jsx(InlineError, { message: error }), _jsx(CreateTokenDialog, { application: application, client: client, isOpen: creating, onClose: () => setCreating(false), onCreated: (token, value) => {
|
|
158
|
+
setTokens((current) => [token, ...current]);
|
|
159
|
+
setCreating(false);
|
|
160
|
+
setCreated({ name: token.name, value });
|
|
161
|
+
}, onFailure: onFailure }), _jsx(Modal, { isOpen: created !== null, onClose: () => setCreated(null), title: 'Copy your new token', children: created ? (_jsxs("div", { className: 'flex flex-col gap-4', children: [_jsxs("p", { className: 'text-sm text-text-secondary', children: ["This is the only time you'll see ", _jsx("strong", { children: created.name }), "'s value. You won't see it again."] }), _jsx("code", { className: 'block break-all rounded-md border border-black/[0.08] bg-light-sand/50 p-3 font-mono text-sm text-text-primary dark:border-white/10 dark:bg-deep-sea/50', "data-testid": 'access-token-value', children: created.value }), _jsxs("div", { className: 'flex justify-end gap-2', children: [_jsxs(Button, { onClick: () => {
|
|
162
|
+
// A click only happens in a browser, where navigator exists.
|
|
163
|
+
if (onCopy)
|
|
164
|
+
onCopy(created.value);
|
|
165
|
+
else
|
|
166
|
+
void navigator.clipboard?.writeText(created.value);
|
|
167
|
+
}, variant: 'secondary', children: [_jsx(Copy, { size: 15 }), "Copy"] }), _jsx(Button, { onClick: () => setCreated(null), children: "Done" })] })] })) : null }), _jsx(AlertDialog, { confirmLabel: 'Revoke', confirmLoading: busy, description: `Tools using ${revoking?.name ?? 'it'} stop working on their next call.`, isOpen: revoking !== null, onCancel: () => setRevoking(null), onConfirm: () => void revoke(revoking), title: `Revoke ${revoking?.name ?? 'token'}?`, variant: 'destructive' })] }));
|
|
168
|
+
}
|
|
169
|
+
function CreateTokenDialog({ application, client, isOpen, onClose, onCreated, onFailure }) {
|
|
170
|
+
const [name, setName] = React.useState('');
|
|
171
|
+
const [expiry, setExpiry] = React.useState('30');
|
|
172
|
+
const [scope, setScope] = React.useState('all');
|
|
173
|
+
const [keys, setKeys] = React.useState('');
|
|
174
|
+
const [error, setError] = React.useState(null);
|
|
175
|
+
const [busy, setBusy] = React.useState(false);
|
|
176
|
+
const picks = typeof client.listMyPermissions === 'function';
|
|
177
|
+
// null while loading; the picker offers only these keys.
|
|
178
|
+
const [held, setHeld] = React.useState(null);
|
|
179
|
+
const [heldError, setHeldError] = React.useState(null);
|
|
180
|
+
const [search, setSearch] = React.useState('');
|
|
181
|
+
const [picked, setPicked] = React.useState([]);
|
|
182
|
+
React.useEffect(() => {
|
|
183
|
+
if (!isOpen) {
|
|
184
|
+
setName('');
|
|
185
|
+
setExpiry('30');
|
|
186
|
+
setScope('all');
|
|
187
|
+
setKeys('');
|
|
188
|
+
setError(null);
|
|
189
|
+
setHeld(null);
|
|
190
|
+
setHeldError(null);
|
|
191
|
+
setSearch('');
|
|
192
|
+
setPicked([]);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (!client.listMyPermissions)
|
|
196
|
+
return;
|
|
197
|
+
let current = true;
|
|
198
|
+
client.listMyPermissions().then((value) => {
|
|
199
|
+
if (current)
|
|
200
|
+
setHeld([...new Set(value)].sort());
|
|
201
|
+
}, (cause) => {
|
|
202
|
+
if (!current)
|
|
203
|
+
return;
|
|
204
|
+
setHeld([]);
|
|
205
|
+
onFailure(cause, setHeldError);
|
|
206
|
+
});
|
|
207
|
+
return () => {
|
|
208
|
+
current = false;
|
|
209
|
+
};
|
|
210
|
+
}, [isOpen, client]);
|
|
211
|
+
const listed = picks
|
|
212
|
+
? picked
|
|
213
|
+
: keys
|
|
214
|
+
.split(/[\s,]+/)
|
|
215
|
+
.map((key) => key.trim())
|
|
216
|
+
.filter(Boolean);
|
|
217
|
+
const valid = name.trim() !== '' && (scope === 'all' || listed.length > 0);
|
|
218
|
+
const shown = (held ?? []).filter((key) => key.toLowerCase().includes(search.trim().toLowerCase()));
|
|
219
|
+
// The submit button is disabled while invalid, which also blocks implicit
|
|
220
|
+
// (Enter) submission.
|
|
221
|
+
const submit = async (event) => {
|
|
222
|
+
event.preventDefault();
|
|
223
|
+
setBusy(true);
|
|
224
|
+
setError(null);
|
|
225
|
+
const input = { name: name.trim() };
|
|
226
|
+
if (expiry === 'none')
|
|
227
|
+
input.no_expiry = true;
|
|
228
|
+
else
|
|
229
|
+
input.expires_in_days = Number(expiry);
|
|
230
|
+
if (scope === 'all')
|
|
231
|
+
input.all_held_in_application = true;
|
|
232
|
+
else
|
|
233
|
+
input.permissions = listed;
|
|
234
|
+
try {
|
|
235
|
+
const { token, value } = await client.createMyToken(input);
|
|
236
|
+
onCreated(token, value);
|
|
237
|
+
}
|
|
238
|
+
catch (cause) {
|
|
239
|
+
onFailure(cause, setError);
|
|
240
|
+
}
|
|
241
|
+
finally {
|
|
242
|
+
setBusy(false);
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
return (_jsx(Modal, { isOpen: isOpen, onClose: onClose, title: 'New token', children: _jsxs("form", { className: 'flex flex-col gap-4', onSubmit: (event) => void submit(event), children: [_jsx(Field, { label: 'Name', required: true, children: _jsx(Input, { autoFocus: true, maxLength: 100, onChange: (event) => setName(event.target.value), placeholder: 'For example, Claude on my laptop', value: name }) }), _jsx(Field, { label: 'Expires', children: _jsx(Select, { "aria-label": 'Expires', onChange: setExpiry, options: EXPIRY_OPTIONS, value: expiry }) }), _jsx(Field, { label: 'Permissions', children: _jsx(RadioGroup, { name: 'access-token-scope', onChange: (value) => setScope(value), options: [
|
|
246
|
+
{ label: `All of mine in ${application.name}`, value: 'all', description: 'Follows what you hold here, now and later.' },
|
|
247
|
+
{
|
|
248
|
+
label: 'Only these',
|
|
249
|
+
value: 'some',
|
|
250
|
+
description: picks ? `Pick from the permissions you hold in ${application.name}.` : `Permission keys of ${application.name} you hold, one per line.`
|
|
251
|
+
}
|
|
252
|
+
], value: scope }) }), scope === 'some' && !picks ? (_jsx(Field, { label: 'Permission keys', required: true, children: _jsx(Textarea, { onChange: (event) => setKeys(event.target.value), placeholder: `${application.key}:read`, rows: 3, value: keys }) })) : null, scope === 'some' && picks ? (_jsxs("fieldset", { className: 'flex flex-col gap-3', children: [_jsx("legend", { className: 'mb-2 text-[13px] font-medium text-text-primary', children: "Permissions you hold here" }), _jsx(Input, { "aria-label": 'Search permissions', onChange: (event) => setSearch(event.target.value), placeholder: 'Search', value: search }), held === null ? (_jsx("p", { "aria-live": 'polite', className: 'text-sm text-text-secondary', children: "Loading your permissions\u2026" })) : heldError ? (_jsx(InlineError, { message: heldError })) : held.length === 0 ? (_jsxs("p", { className: 'text-sm text-text-secondary', children: ["You hold no permissions in ", application.name, "."] })) : (_jsxs("div", { className: 'flex max-h-56 flex-col gap-2 overflow-y-auto', children: [shown.length === 0 ? _jsx("p", { className: 'text-sm text-text-secondary', children: "No permission matches." }) : null, shown.map((key) => (_jsx(Checkbox, { checked: picked.includes(key), label: _jsx("span", { className: 'font-mono text-xs', children: key }), onChange: (event) => {
|
|
253
|
+
const on = event.target.checked;
|
|
254
|
+
setPicked((current) => (on ? [...current, key] : current.filter((item) => item !== key)));
|
|
255
|
+
} }, key)))] }))] })) : null, _jsx(InlineError, { message: error }), _jsxs("div", { className: 'flex justify-end gap-2', children: [_jsx(Button, { onClick: onClose, type: 'button', variant: 'ghost', children: "Cancel" }), _jsx(Button, { disabled: !valid || busy, loading: busy, type: 'submit', children: "Create token" })] })] }) }));
|
|
256
|
+
}
|
|
257
|
+
function TokenSwitchSection({ application, client, enabled, onChange, onFailure }) {
|
|
258
|
+
const [busy, setBusy] = React.useState(false);
|
|
259
|
+
const [error, setError] = React.useState(null);
|
|
260
|
+
const change = async (next) => {
|
|
261
|
+
setBusy(true);
|
|
262
|
+
setError(null);
|
|
263
|
+
try {
|
|
264
|
+
onChange(await client.setTokenSwitch(next));
|
|
265
|
+
}
|
|
266
|
+
catch (cause) {
|
|
267
|
+
onFailure(cause, setError);
|
|
268
|
+
}
|
|
269
|
+
finally {
|
|
270
|
+
setBusy(false);
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
return (_jsxs(Section, { title: 'Token switch', description: `Whether ${application.name} accepts personal access tokens at all. Off refuses every token on its next call.`, children: [_jsx(Switch, { checked: enabled, disabled: busy, label: enabled ? 'Personal access tokens are on' : 'Personal access tokens are off', onCheckedChange: (next) => void change(next) }), _jsx(InlineError, { message: error })] }));
|
|
274
|
+
}
|
|
275
|
+
function PeopleSection({ application, client, grants, onFailure, roles, setGrants }) {
|
|
276
|
+
const [userId, setUserId] = React.useState('');
|
|
277
|
+
const [roleId, setRoleId] = React.useState('');
|
|
278
|
+
const [error, setError] = React.useState(null);
|
|
279
|
+
const [busy, setBusy] = React.useState(false);
|
|
280
|
+
const [revoking, setRevoking] = React.useState(null);
|
|
281
|
+
const people = Array.from(new Map(grants.map((grant) => [grant.user_id, grant.user_email])).entries());
|
|
282
|
+
const parsedUser = Number(userId);
|
|
283
|
+
const valid = Number.isInteger(parsedUser) && parsedUser > 0 && roleId !== '';
|
|
284
|
+
const grant = async (event) => {
|
|
285
|
+
event.preventDefault();
|
|
286
|
+
setBusy(true);
|
|
287
|
+
setError(null);
|
|
288
|
+
try {
|
|
289
|
+
const record = await client.grant({ user_id: parsedUser, role_id: Number(roleId) });
|
|
290
|
+
setGrants((current) => [...current, record]);
|
|
291
|
+
setUserId('');
|
|
292
|
+
setRoleId('');
|
|
293
|
+
}
|
|
294
|
+
catch (cause) {
|
|
295
|
+
onFailure(cause, setError, 'You can only grant a role whose permissions you all hold yourself.');
|
|
296
|
+
}
|
|
297
|
+
finally {
|
|
298
|
+
setBusy(false);
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
const revoke = async (target) => {
|
|
302
|
+
setBusy(true);
|
|
303
|
+
setError(null);
|
|
304
|
+
try {
|
|
305
|
+
await client.revokeGrant(target.id);
|
|
306
|
+
setGrants((current) => current.filter((item) => item.id !== target.id));
|
|
307
|
+
}
|
|
308
|
+
catch (cause) {
|
|
309
|
+
onFailure(cause, setError, 'You can only revoke a role whose permissions you all hold yourself.');
|
|
310
|
+
}
|
|
311
|
+
finally {
|
|
312
|
+
setRevoking(null);
|
|
313
|
+
setBusy(false);
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
return (_jsxs(Section, { title: 'People', description: `Who holds ${application.name}'s roles. You can grant or revoke only a role whose permissions you all hold.`, children: [grants.length === 0 ? (_jsx(Empty, { title: 'Nobody holds a role yet' })) : (_jsxs(Table, { "aria-label": 'Role holders', children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "Person" }), _jsx(TableHead, { children: "Role" }), _jsx(TableHead, { children: "Granted" }), _jsx(TableHead, { children: _jsx("span", { className: 'sr-only', children: "Actions" }) })] }) }), _jsx(TableBody, { children: grants.map((item) => (_jsxs(TableRow, { children: [_jsx(TableCell, { children: personLabel(item) }), _jsx(TableCell, { children: item.role_name }), _jsx(TableCell, { children: formatTime(item.granted_at) }), _jsx(TableCell, { className: 'text-right', children: _jsx(Button, { "aria-label": `Revoke ${item.role_name} from ${personLabel(item)}`, onClick: () => setRevoking(item), size: 'xs', variant: 'ghost', children: "Revoke" }) })] }, item.id))) })] })), _jsxs("form", { "aria-label": 'Grant a role', className: 'mt-5 grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] sm:items-end', onSubmit: (event) => void grant(event), children: [_jsx(Field, { description: 'Their Pompeii user id. They must have signed in once.', label: 'Person', children: _jsx(Input, { inputMode: 'numeric', list: 'access-panel-people', onChange: (event) => setUserId(event.target.value.trim()), placeholder: 'User id', value: userId }) }), _jsx("datalist", { id: 'access-panel-people', children: people.map(([id, email]) => (_jsx("option", { label: email, value: String(id) }, id))) }), _jsx(Field, { label: 'Role', children: _jsx(Select, { "aria-label": 'Role', onChange: setRoleId, options: roles.map((role) => ({ label: role.name, value: String(role.id) })), placeholder: 'Choose a role', value: roleId }) }), _jsx(Button, { disabled: !valid || busy, loading: busy, type: 'submit', children: "Grant" })] }), _jsx(InlineError, { message: error }), _jsx(AlertDialog, { confirmLabel: 'Revoke', confirmLoading: busy, description: 'They lose what this role allows on their next request.', isOpen: revoking !== null, onCancel: () => setRevoking(null), onConfirm: () => void revoke(revoking), title: revoking ? `Revoke ${revoking.role_name} from ${personLabel(revoking)}?` : 'Revoke role?', variant: 'destructive' })] }));
|
|
317
|
+
}
|
|
318
|
+
function HistorySection({ client, done, entries, onMore, onFailure }) {
|
|
319
|
+
const [busy, setBusy] = React.useState(false);
|
|
320
|
+
const [error, setError] = React.useState(null);
|
|
321
|
+
// Offered only while the last page was full, so there is a last entry.
|
|
322
|
+
const more = async () => {
|
|
323
|
+
setBusy(true);
|
|
324
|
+
setError(null);
|
|
325
|
+
try {
|
|
326
|
+
onMore(await client.listHistory({ limit: HISTORY_PAGE, before: entries[entries.length - 1].at }));
|
|
327
|
+
}
|
|
328
|
+
catch (cause) {
|
|
329
|
+
onFailure(cause, setError);
|
|
330
|
+
}
|
|
331
|
+
finally {
|
|
332
|
+
setBusy(false);
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
return (_jsxs(Section, { title: 'History', description: 'Access changes made through this service, from its screen or from an MCP client.', children: [entries.length === 0 ? (_jsx(Empty, { title: 'No access changes yet' })) : (_jsxs(Table, { "aria-label": 'Access history', children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "When" }), _jsx(TableHead, { children: "What" }), _jsx(TableHead, { children: "Who" }), _jsx(TableHead, { children: "On" }), _jsx(TableHead, { children: "Through" })] }) }), _jsx(TableBody, { children: entries.map((entry, index) => (_jsxs(TableRow, { children: [_jsx(TableCell, { children: formatTime(entry.at) }), _jsx(TableCell, { children: entry.action }), _jsx(TableCell, { children: entry.actor_email || '—' }), _jsx(TableCell, { className: 'text-xs', children: entry.target }), _jsxs(TableCell, { children: [entry.via_application || '—', entry.via_client ? ` (${entry.via_client === 'mcp' ? 'MCP' : 'screen'})` : ''] })] }, `${entry.at}-${index}`))) })] })), !done ? (_jsx(Button, { className: 'mt-4', disabled: busy, loading: busy, onClick: () => void more(), size: 'sm', variant: 'secondary', children: "Show older" })) : null, _jsx(InlineError, { message: error })] }));
|
|
336
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface ArmTakeProps {
|
|
2
|
+
className?: string;
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
/** How long a hold takes to confirm. */
|
|
5
|
+
holdMs?: number;
|
|
6
|
+
label: string;
|
|
7
|
+
/** Called when the take is confirmed: a hold of `holdMs`, or a second press while armed. */
|
|
8
|
+
onTake: () => void;
|
|
9
|
+
/** How long an armed control waits for the second press before it disarms itself. */
|
|
10
|
+
armTimeoutMs?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A control that cannot fire by accident: hold it for `holdMs` (a fill shows the progress), or
|
|
14
|
+
* press it twice (the first press arms it, the second takes). A single click never takes. With
|
|
15
|
+
* reduced motion there is no fill and no hold, only the two presses. Esc disarms.
|
|
16
|
+
*/
|
|
17
|
+
export declare function ArmTake({ armTimeoutMs, className, disabled, holdMs, label, onTake }: ArmTakeProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { cn } from '../utils/cn.js';
|
|
4
|
+
function prefersReducedMotion() {
|
|
5
|
+
return typeof window !== 'undefined' && typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A control that cannot fire by accident: hold it for `holdMs` (a fill shows the progress), or
|
|
9
|
+
* press it twice (the first press arms it, the second takes). A single click never takes. With
|
|
10
|
+
* reduced motion there is no fill and no hold, only the two presses. Esc disarms.
|
|
11
|
+
*/
|
|
12
|
+
export function ArmTake({ armTimeoutMs = 5_000, className, disabled = false, holdMs = 800, label, onTake }) {
|
|
13
|
+
const [armed, setArmed] = React.useState(false);
|
|
14
|
+
const [progress, setProgress] = React.useState(0);
|
|
15
|
+
const frame = React.useRef(null);
|
|
16
|
+
const startedAt = React.useRef(null);
|
|
17
|
+
// The click that follows a completed hold must not arm the control again.
|
|
18
|
+
const heldConfirmed = React.useRef(false);
|
|
19
|
+
const armTimer = React.useRef(null);
|
|
20
|
+
const take = React.useRef(onTake);
|
|
21
|
+
take.current = onTake;
|
|
22
|
+
const clearTimer = React.useCallback(() => {
|
|
23
|
+
if (armTimer.current)
|
|
24
|
+
clearTimeout(armTimer.current);
|
|
25
|
+
armTimer.current = null;
|
|
26
|
+
}, []);
|
|
27
|
+
const disarm = React.useCallback(() => {
|
|
28
|
+
clearTimer();
|
|
29
|
+
setArmed(false);
|
|
30
|
+
}, [clearTimer]);
|
|
31
|
+
const stopHold = React.useCallback(() => {
|
|
32
|
+
if (frame.current !== null)
|
|
33
|
+
cancelAnimationFrame(frame.current);
|
|
34
|
+
frame.current = null;
|
|
35
|
+
startedAt.current = null;
|
|
36
|
+
setProgress(0);
|
|
37
|
+
}, []);
|
|
38
|
+
const confirm = React.useCallback(() => {
|
|
39
|
+
clearTimer();
|
|
40
|
+
setArmed(false);
|
|
41
|
+
take.current();
|
|
42
|
+
}, [clearTimer]);
|
|
43
|
+
const arm = React.useCallback(() => {
|
|
44
|
+
clearTimer();
|
|
45
|
+
setArmed(true);
|
|
46
|
+
armTimer.current = setTimeout(() => setArmed(false), armTimeoutMs);
|
|
47
|
+
}, [armTimeoutMs, clearTimer]);
|
|
48
|
+
React.useEffect(() => () => {
|
|
49
|
+
clearTimer();
|
|
50
|
+
if (frame.current !== null)
|
|
51
|
+
cancelAnimationFrame(frame.current);
|
|
52
|
+
}, [clearTimer]);
|
|
53
|
+
const tick = React.useCallback((now) => {
|
|
54
|
+
if (startedAt.current === null)
|
|
55
|
+
return;
|
|
56
|
+
const ratio = Math.min(1, (now - startedAt.current) / holdMs);
|
|
57
|
+
setProgress(ratio);
|
|
58
|
+
if (ratio >= 1) {
|
|
59
|
+
frame.current = null;
|
|
60
|
+
startedAt.current = null;
|
|
61
|
+
setProgress(0);
|
|
62
|
+
heldConfirmed.current = true;
|
|
63
|
+
confirm();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
frame.current = requestAnimationFrame(tick);
|
|
67
|
+
}, [confirm, holdMs]);
|
|
68
|
+
const onPointerDown = () => {
|
|
69
|
+
if (disabled || prefersReducedMotion() || startedAt.current !== null)
|
|
70
|
+
return;
|
|
71
|
+
startedAt.current = performance.now();
|
|
72
|
+
frame.current = requestAnimationFrame(tick);
|
|
73
|
+
};
|
|
74
|
+
const onClick = () => {
|
|
75
|
+
if (heldConfirmed.current) {
|
|
76
|
+
heldConfirmed.current = false;
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (armed)
|
|
80
|
+
confirm();
|
|
81
|
+
else
|
|
82
|
+
arm();
|
|
83
|
+
};
|
|
84
|
+
return (_jsxs("button", { type: 'button', disabled: disabled, "aria-label": armed ? `${label}: armed, press again to take` : label, "data-armed": armed, onPointerDown: onPointerDown, onPointerUp: stopHold, onPointerLeave: stopHold, onPointerCancel: stopHold, onBlur: () => {
|
|
85
|
+
stopHold();
|
|
86
|
+
disarm();
|
|
87
|
+
}, onKeyDown: (event) => {
|
|
88
|
+
if (event.key === 'Escape' && armed) {
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
disarm();
|
|
91
|
+
}
|
|
92
|
+
}, onClick: onClick, className: cn('relative inline-flex h-9 select-none items-center gap-2 overflow-hidden rounded-[var(--radius-button)] border px-4 text-xs font-bold uppercase tracking-wider focus:outline-none focus-visible:ring-2 focus-visible:ring-sea disabled:pointer-events-none disabled:opacity-50 dark:focus-visible:ring-accent-blue', armed ? 'border-accent-red bg-accent-red text-white' : 'border-accent-text text-accent-text dark:border-accent-yellow dark:text-accent-yellow', className), children: [_jsx("span", { "aria-hidden": 'true', "data-arm-fill": true, className: 'absolute inset-y-0 left-0 bg-accent-red/70', style: { width: `${progress * 100}%` } }), _jsx("span", { className: 'relative', children: armed ? 'Press again to take' : label }), _jsx("span", { role: 'status', className: 'sr-only', children: armed ? 'Armed. Press again within the time shown to take.' : '' })] }));
|
|
93
|
+
}
|
|
@@ -5,4 +5,4 @@ export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElemen
|
|
|
5
5
|
as?: 'button' | 'a';
|
|
6
6
|
href?: string;
|
|
7
7
|
}
|
|
8
|
-
export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<
|
|
8
|
+
export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
|
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
interface DrawerBaseProps {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
className?: string;
|
|
5
5
|
description?: string;
|
|
6
|
-
isOpen: boolean;
|
|
7
6
|
onClose: () => void;
|
|
8
7
|
snapPoints?: string[];
|
|
9
8
|
title?: string;
|
|
10
9
|
}
|
|
11
|
-
|
|
10
|
+
/** The bottom sheet (the default): a modal overlay that holds focus. */
|
|
11
|
+
export interface DrawerSheetProps extends DrawerBaseProps {
|
|
12
|
+
variant?: 'sheet';
|
|
13
|
+
isOpen: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* `variant="detail"` (bleecker#549): a panel docked beside a list, with no
|
|
17
|
+
* overlay and no focus trap, so focus stays in the list. `open` (or `isOpen`)
|
|
18
|
+
* shows it; `width` defaults to 22rem.
|
|
19
|
+
*/
|
|
20
|
+
export interface DrawerDetailProps extends DrawerBaseProps {
|
|
21
|
+
variant: 'detail';
|
|
22
|
+
open?: boolean;
|
|
23
|
+
isOpen?: boolean;
|
|
24
|
+
width?: string;
|
|
25
|
+
}
|
|
26
|
+
export type DrawerProps = DrawerSheetProps | DrawerDetailProps;
|
|
27
|
+
export declare function Drawer(props: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export {};
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Minus } from 'lucide-react';
|
|
3
|
+
import { Minus, X } from 'lucide-react';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { createPortal } from 'react-dom';
|
|
6
6
|
import { cn } from '../utils/cn.js';
|
|
7
7
|
import { ModalLayerScope, useModalLayer, usePresence } from '../utils/hooks.js';
|
|
8
|
-
export function Drawer(
|
|
8
|
+
export function Drawer(props) {
|
|
9
|
+
if (props.variant === 'detail')
|
|
10
|
+
return _jsx(DetailDrawer, { ...props });
|
|
11
|
+
return _jsx(SheetDrawer, { ...props });
|
|
12
|
+
}
|
|
13
|
+
function DetailDrawer({ children, className, description, onClose, open, isOpen, title, width = '22rem' }) {
|
|
14
|
+
const titleId = React.useId();
|
|
15
|
+
const descriptionId = React.useId();
|
|
16
|
+
if (!(open ?? isOpen))
|
|
17
|
+
return null;
|
|
18
|
+
return (_jsxs("aside", { "data-bleecker-drawer": 'detail', "aria-label": title ? undefined : 'Details', "aria-labelledby": title ? titleId : undefined, "aria-describedby": description ? descriptionId : undefined, style: { width }, className: cn('flex h-full min-h-0 shrink-0 flex-col border-l border-sand/25 bg-white dark:border-white/10 dark:bg-deep-sea', className), children: [_jsxs("div", { className: 'flex items-start gap-3 border-b border-sand/20 px-5 py-4 dark:border-white/[0.07]', children: [_jsxs("div", { className: 'min-w-0 flex-1', children: [title ? _jsx("h2", { id: titleId, className: 'truncate text-base font-medium text-text-primary dark:text-text-primary', children: title }) : null, description ? _jsx("p", { id: descriptionId, className: 'font-secondary mt-1 text-sm text-text-secondary dark:text-text-secondary', children: description }) : null] }), _jsx("button", { type: 'button', onClick: onClose, "aria-label": 'Close details', className: '-mr-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-[var(--radius-button)] text-text-secondary transition-colors duration-[var(--motion-control)] ease-premium hover:bg-light-sand/60 hover:text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sea/45 dark:hover:bg-white/[0.06]', children: _jsx(X, { size: 16, "aria-hidden": 'true' }) })] }), _jsx("div", { className: 'min-h-0 flex-1 overflow-y-auto px-5 py-4', children: children })] }));
|
|
19
|
+
}
|
|
20
|
+
function SheetDrawer({ children, className, description, isOpen, onClose, title }) {
|
|
9
21
|
const { present, visible } = usePresence(isOpen, 180);
|
|
10
22
|
const startYRef = React.useRef(null);
|
|
11
23
|
const panelRef = useModalLayer(isOpen, onClose);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface KeyCapProps extends React.HTMLAttributes<HTMLElement> {
|
|
3
|
+
/** One cap per key, for a chord: `keys={['⌘', 'K']}`. */
|
|
4
|
+
keys?: string[];
|
|
5
|
+
}
|
|
6
|
+
/** A keyboard key as a cap with a heavier bottom edge. Kbd stays exported; KeyCap is the new styling. */
|
|
7
|
+
export declare function KeyCap({ className, children, keys, ...props }: KeyCapProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../utils/cn.js';
|
|
3
|
+
const capClasses = 'inline-flex h-5 min-w-5 items-center justify-center rounded-[5px] border border-b-2 border-sand/60 bg-white px-1.5 font-mono text-[11px] font-semibold text-text-secondary dark:border-white/20 dark:bg-deep-sea/60 dark:text-text-primary';
|
|
4
|
+
/** A keyboard key as a cap with a heavier bottom edge. Kbd stays exported; KeyCap is the new styling. */
|
|
5
|
+
export function KeyCap({ className, children, keys, ...props }) {
|
|
6
|
+
if (keys && keys.length > 0) {
|
|
7
|
+
return (_jsx("span", { className: 'inline-flex items-center gap-1', role: 'group', "aria-label": keys.join(' '), children: keys.map((key, index) => (_jsx("kbd", { ...props, className: cn(capClasses, className), children: key }, `${key}-${index}`))) }));
|
|
8
|
+
}
|
|
9
|
+
return (_jsx("kbd", { ...props, className: cn(capClasses, className), children: children }));
|
|
10
|
+
}
|