Implementation:0xranx OpenContext Custom Dialog
| Knowledge Sources | |
|---|---|
| Domains | UI, React |
| Last Updated | 2026-10-24 00:00 GMT |
Overview
Reusable dialog and context menu components for the desktop UI, providing alert, confirm, prompt, and right-click context menu functionality with i18n support.
Description
The Dialogs.jsx component module in src/ui/src/components/ exports two components: CustomDialog and ContextMenu. CustomDialog supports four types: alert, confirm, prompt, and prompt_multiline — each with optional destructive styling, i18n button labels, keyboard ESC handling, and auto-focus for prompt inputs. ContextMenu renders a positioned dropdown menu with icon+label items and click-outside dismissal.
Usage
Import these components in any UI component that needs modal dialogs or context menus.
Code Reference
Source Location
- Repository: 0xranx_OpenContext
- File: src/ui/src/components/Dialogs.jsx
- Lines: 1-157
Signature
export function CustomDialog({
isOpen, onClose, onCancel,
type = 'alert', title, message, placeholder,
initialValue = '', onConfirm,
confirmText, cancelText, isDestructive = false
})
export function ContextMenu({ isOpen, x, y, onClose, items })
Import
import { CustomDialog, ContextMenu } from './components/Dialogs';
I/O Contract
Inputs (CustomDialog)
| Name | Type | Required | Description |
|---|---|---|---|
| isOpen | boolean | Yes | Show/hide the dialog |
| type | string | No | 'alert', 'confirm', 'prompt', 'prompt_multiline' |
| onConfirm | Function | Yes | Called with input value (prompt) or undefined |
| isDestructive | boolean | No | Red styling for destructive actions |
Inputs (ContextMenu)
| Name | Type | Required | Description |
|---|---|---|---|
| isOpen | boolean | Yes | Show/hide menu |
| x, y | number | Yes | Screen position |
| items | Array | Yes | [{ icon, label, onClick, className }] |
Usage Examples
Confirm Dialog
import { CustomDialog } from './components/Dialogs';
const [showDelete, setShowDelete] = useState(false);
<CustomDialog
isOpen={showDelete}
type="confirm"
title="Delete Document"
message="Are you sure?"
isDestructive
onConfirm={() => handleDelete()}
onClose={() => setShowDelete(false)}
/>
Context Menu
import { ContextMenu } from './components/Dialogs';
const [menu, setMenu] = useState({ open: false, x: 0, y: 0 });
<ContextMenu
isOpen={menu.open}
x={menu.x}
y={menu.y}
onClose={() => setMenu({ ...menu, open: false })}
items={[
{ label: 'Rename', onClick: () => handleRename() },
{ label: 'Delete', onClick: () => handleDelete(), className: 'text-red-600' },
]}
/>