NAME
Chandra::Modal - Custom modal dialogs
SYNOPSIS
use Chandra::Modal;
# Confirmation dialog
Chandra::Modal->confirm($app,
title => 'Delete Item',
message => 'This action cannot be undone.',
on_ok => sub { delete_item() },
);
# Text prompt
Chandra::Modal->prompt($app,
title => 'Rename',
label => 'New name:',
value => $current_name,
on_submit => sub { my ($value) = @_; rename_item($value) },
);
# Custom modal
my $id = Chandra::Modal->show($app,
title => 'Settings',
content => '<p>Custom HTML content here</p>',
width => 500,
buttons => [
{ label => 'Cancel', class => 'secondary', action => 'close' },
{ label => 'Save', class => 'primary', action => sub { save() } },
],
);
# Close programmatically
Chandra::Modal->close($app, $id);
DESCRIPTION
HTML-based modal dialogs with backdrop, buttons, and optional text input. All methods are implemented in XS.
METHODS
show($app, %opts)
Show a custom modal. Options:
- title - dialog title
- content - raw HTML for the body
- message - plain text message (alternative to content)
- width - max width in pixels (default 400)
- backdrop - click backdrop to close (default true)
- input - hashref with
labelandvaluefor text input
Returns modal ID string.
close($app, $id)
Close a modal by ID.
confirm($app, %opts)
Convenience for OK/Cancel confirmation. Options: title, message, on_ok, on_cancel.
prompt($app, %opts)
Convenience for text input. Options: title, label, value, on_submit. The on_submit handler receives the input value.
reset()
Reset internal state (for testing).