# ScopeGrant

Permissions that stay in place, with their scope, expiry, how often they were used, and a way to revoke them.

- **Use it for**: Standing permissions with expiry, use counts and revoke.
- **Not for**: A single pending request. Try [PermissionRequest](https://unseenui.com/components/permission-request/).

## Good to know

- An expired grant says so in its badge only.
- Uses the server does not count read "Uses not counted", with the reason.

## Installation

```bash
npm install @stackunseen/ui
```

## Usage

```tsx
import { ScopeGrant } from '@stackunseen/ui/conversation-flow';
import '@stackunseen/ui/styles.css';
import '@stackunseen/ui/conversation-flow.css';

<ScopeGrant variant="list"List grants={grants} now={clock} onRevoke={revoke} />
```

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `emptyMessage` | `string` |  |
| `grants` (required) | `readonly ScopeGrant[]` |  |
| `label` | `string` |  |
| `locale` | `string` |  |
| `now` | `string` | The host clock, so expiry is derived deterministically. |
| `onRevoke` | `((request: ScopeGrantRevokeRequest) => void)` |  |
| `receipts` | `readonly CommandReceipt[]` | Receipts keyed by grant id; a submitting receipt shows the grant as revoking. |
| `timeZone` | `string` |  |
| `variant` | `"list" \| "compact"` |  |

## Keyboard

Tab reaches controls; Enter or Space activates buttons. Accordions use arrow keys, Home and End. Select menus support arrows and typeahead; Escape closes menus and dialogs and restores focus.

## Works with

[ApprovalCard](https://unseenui.com/components/approval-card/), [PermissionRequest](https://unseenui.com/components/permission-request/), [ReviewChanges](https://unseenui.com/components/review-changes/), [DryRunPreview](https://unseenui.com/components/dry-run-preview/), [ApprovalBatch](https://unseenui.com/components/approval-batch/), [AccessModeSelector](https://unseenui.com/components/access-mode-selector/), [ClarificationRequest](https://unseenui.com/components/clarification-request/)

Page: https://unseenui.com/components/scope-grant/
