# cjm-fasthtml-interactions
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
## Install
``` bash
pip install cjm_fasthtml_interactions
```
## Project Structure
nbs/
├── core/ (2)
│ ├── context.ipynb # Context management for interaction patterns providing access to state, request, and custom data
│ └── html_ids.ipynb # Centralized HTML ID constants for interaction pattern components
└── patterns/ (3)
├── master_detail.ipynb # Sidebar navigation pattern with master list and detail content area
├── step_flow.ipynb # Multi-step wizard pattern with state management, navigation, and route generation
└── tabbed_interface.ipynb # Multi-tab interface pattern with automatic routing, state management, and DaisyUI styling
Total: 5 notebooks across 2 directories
## Module Dependencies
``` mermaid
graph LR
core_context[core.context<br/>Interaction Context]
core_html_ids[core.html_ids<br/>HTML IDs]
patterns_master_detail[patterns.master_detail<br/>Master-Detail]
patterns_step_flow[patterns.step_flow<br/>Step Flow]
patterns_tabbed_interface[patterns.tabbed_interface<br/>Tabbed Interface]
patterns_master_detail --> core_context
patterns_master_detail --> core_html_ids
patterns_step_flow --> core_context
patterns_step_flow --> core_html_ids
patterns_tabbed_interface --> core_context
patterns_tabbed_interface --> core_html_ids
```
*6 cross-module dependencies detected*
## CLI Reference
No CLI commands found in this project.
## Module Overview
Detailed documentation for each module in the project:
### Interaction Context (`context.ipynb`)
> Context management for interaction patterns providing access to state,
> request, and custom data
#### Import
``` python
from cjm_fasthtml_interactions.core.context import (
InteractionContext
)
```
#### Classes
``` python
@dataclass
class InteractionContext:
"Context for interaction patterns providing access to state, request, and custom data."
state: Dict[str, Any] = field(...) # Workflow state
request: Optional[Any] # FastHTML request object
session: Optional[Any] # FastHTML session object
data: Dict[str, Any] = field(...) # Custom data from data loaders
metadata: Dict[str, Any] = field(...) # Additional metadata
def get(self,
key: str, # Key to retrieve from state
default: Any = None # Default value if key not found
) -> Any: # Value from state or default
"Get value from workflow state."
def get_data(self,
key: str, # Key to retrieve from data
default: Any = None # Default value if key not found
) -> Any: # Value from data or default
"Get value from custom data."
def has(self,
key: str # Key to check in state
) -> bool: # True if key exists in state
"Check if key exists in workflow state."
def set(self,
key: str, # Key to set in state
value: Any # Value to store
) -> None
"Set value in workflow state."
def get_all_state(self) -> Dict[str, Any]: # All workflow state
"""Get all workflow state as dictionary."""
return self.state.copy()
def update_state(self,
updates: Dict[str, Any] # State updates to apply
) -> None
"Get all workflow state as dictionary."
def update_state(self,
updates: Dict[str, Any] # State updates to apply
) -> None
"Update multiple state values at once."
```
### HTML IDs (`html_ids.ipynb`)
> Centralized HTML ID constants for interaction pattern components
#### Import
``` python
from cjm_fasthtml_interactions.core.html_ids import (
InteractionHtmlIds
)
```
#### Classes
``` python
class InteractionHtmlIds(AppHtmlIds):
"""
HTML ID constants for interaction pattern components.
Inherits from AppHtmlIds:
- MAIN_CONTENT = "main-content"
- ALERT_CONTAINER = "alert-container"
- as_selector(id_str) - static method
"""
def step_content(step_id: str # Step identifier
) -> str: # HTML ID for step content
"Generate HTML ID for a specific step's content."
def step_indicator(step_id: str # Step identifier
) -> str: # HTML ID for step indicator
"Generate HTML ID for a specific step's progress indicator."
def tab_radio(tab_id: str # Tab identifier
) -> str: # HTML ID for tab radio input
"Generate HTML ID for a specific tab's radio input."
def tab_content(tab_id: str # Tab identifier
) -> str: # HTML ID for tab content
"Generate HTML ID for a specific tab's content."
def master_item(item_id: str # Item identifier
) -> str: # HTML ID for master list item
"Generate HTML ID for a master list item."
def master_group(group_id: str # Group identifier
) -> str: # HTML ID for master list group
"Generate HTML ID for a master list group."
def detail_content(item_id: str # Item identifier
) -> str: # HTML ID for detail content
"Generate HTML ID for detail content area."
```
### Master-Detail (`master_detail.ipynb`)
> Sidebar navigation pattern with master list and detail content area
#### Import
``` python
from cjm_fasthtml_interactions.patterns.master_detail import (
DetailItem,
DetailItemGroup,
MasterDetail
)
```
#### Functions
``` python
@patch
def get_item(self:MasterDetail,
item_id: str # Item identifier
) -> Optional[DetailItem]: # DetailItem or None
"Get item by ID."
```
``` python
@patch
def create_context(self:MasterDetail,
request: Any, # FastHTML request object
sess: Any, # FastHTML session object
item: DetailItem # Current item
) -> InteractionContext: # Interaction context for rendering
"Create interaction context for an item."
```
``` python
@patch
def render_master(self:MasterDetail,
active_item_id: str, # Currently active item ID
item_route_func: Callable[[str], str], # Function to generate item route
include_wrapper: bool = True # Whether to include outer wrapper div
) -> FT: # Master list element
"Render master list (sidebar) with items and groups."
```
``` python
@patch
def render_master_oob(self:MasterDetail,
active_item_id: str, # Currently active item ID
item_route_func: Callable[[str], str] # Function to generate item route
) -> FT: # Master list with OOB swap attribute
"Render master list with OOB swap attribute for coordinated updates."
```
``` python
@patch
def render_detail(self:MasterDetail,
item: DetailItem, # Item to render
ctx: InteractionContext # Interaction context
) -> FT: # Detail content
"Render detail content for an item."
```
``` python
@patch
def render_full_interface(self:MasterDetail,
active_item_id: str, # Currently active item ID
item_route_func: Callable[[str], str], # Function to generate item route
request: Any, # FastHTML request object
sess: Any # FastHTML session object
) -> FT: # Complete master-detail interface
"Render complete master-detail interface with master list and detail area."
```
``` python
@patch
def create_router(self:MasterDetail,
prefix: str = "" # URL prefix for routes (e.g., "/media")
) -> APIRouter: # APIRouter with generated routes
"Create FastHTML router with generated routes for this master-detail interface."
```
#### Classes
``` python
@dataclass
class DetailItem:
"Definition of a single item in the master-detail pattern."
id: str # Unique identifier
label: str # Display text in master list
render: Callable[[InteractionContext], Any] # Function to render detail view
badge_text: Optional[str] # Optional badge text (e.g., "configured", "3 items")
badge_color: Optional[str] # Badge color class (e.g., badge_colors.success)
icon: Optional[Any] # Optional icon element
data_loader: Optional[Callable[[Any], Dict[str, Any]]] # Data loading function
load_on_demand: bool = True # Whether to load content only when item is selected
```
``` python
@dataclass
class DetailItemGroup:
"Group of related detail items in a collapsible section."
id: str # Group identifier
title: str # Group display title
items: List[DetailItem] # Items in this group
default_open: bool = True # Whether group is expanded by default
icon: Optional[Any] # Optional group icon
badge_text: Optional[str] # Optional badge for the group
badge_color: Optional[str] # Badge color for the group
```
``` python
class MasterDetail:
def __init__(
self,
interface_id: str, # Unique identifier for this interface
items: List[Union[DetailItem, DetailItemGroup]], # List of items/groups
default_item: Optional[str] = None, # Default item ID (defaults to first item)
container_id: str = InteractionHtmlIds.MASTER_DETAIL_CONTAINER, # HTML ID for container
master_id: str = InteractionHtmlIds.MASTER_DETAIL_MASTER, # HTML ID for master list
detail_id: str = InteractionHtmlIds.MASTER_DETAIL_DETAIL, # HTML ID for detail area
master_width: str = "w-64", # Tailwind width class for master list
master_title: Optional[str] = None, # Optional title for master list
show_on_htmx_only: bool = False # Whether to show full interface for non-HTMX requests
)
"Manage master-detail interfaces with sidebar navigation and detail content area."
def __init__(
self,
interface_id: str, # Unique identifier for this interface
items: List[Union[DetailItem, DetailItemGroup]], # List of items/groups
default_item: Optional[str] = None, # Default item ID (defaults to first item)
container_id: str = InteractionHtmlIds.MASTER_DETAIL_CONTAINER, # HTML ID for container
master_id: str = InteractionHtmlIds.MASTER_DETAIL_MASTER, # HTML ID for master list
detail_id: str = InteractionHtmlIds.MASTER_DETAIL_DETAIL, # HTML ID for detail area
master_width: str = "w-64", # Tailwind width class for master list
master_title: Optional[str] = None, # Optional title for master list
show_on_htmx_only: bool = False # Whether to show full interface for non-HTMX requests
)
"Initialize master-detail manager."
```
### Step Flow (`step_flow.ipynb`)
> Multi-step wizard pattern with state management, navigation, and route
> generation
#### Import
``` python
from cjm_fasthtml_interactions.patterns.step_flow import (
Step,
StepFlow
)
```
#### Functions
``` python
@patch
def get_step(self:StepFlow,
step_id: str # Step identifier
) -> Optional[Step]: # Step object or None
"Get step by ID."
```
``` python
@patch
def get_step_index(self:StepFlow,
step_id: str # Step identifier
) -> Optional[int]: # Step index or None
"Get step index by ID."
```
``` python
@patch
def get_current_step_id(self:StepFlow,
sess: Any # FastHTML session object
) -> str: # Current step ID
"Get current step ID from session."
```
``` python
@patch
def set_current_step(self:StepFlow,
sess: Any, # FastHTML session object
step_id: str # Step ID to set as current
) -> None
"Set current step in session."
```
``` python
@patch
def get_next_step_id(self:StepFlow,
current_step_id: str # Current step ID
) -> Optional[str]: # Next step ID or None if last step
"Get the ID of the next step."
```
``` python
@patch
def get_previous_step_id(self:StepFlow,
current_step_id: str # Current step ID
) -> Optional[str]: # Previous step ID or None if first step
"Get the ID of the previous step."
```
``` python
@patch
def is_last_step(self:StepFlow,
step_id: str # Step ID to check
) -> bool: # True if this is the last step
"Check if step is the last step."
```
``` python
@patch
def is_first_step(self:StepFlow,
step_id: str # Step ID to check
) -> bool: # True if this is the first step
"Check if step is the first step."
```
``` python
@patch
def get_workflow_state(self:StepFlow,
sess: Any # FastHTML session object
) -> Dict[str, Any]: # All workflow state
"Get all workflow state from session."
```
``` python
@patch
def update_workflow_state(self:StepFlow,
sess: Any, # FastHTML session object
updates: Dict[str, Any] # State updates
) -> None
"Update workflow state with new values."
```
``` python
@patch
def clear_workflow(self:StepFlow,
sess: Any # FastHTML session object
) -> None
"Clear all workflow state."
```
``` python
@patch
def create_context(self:StepFlow,
request: Any, # FastHTML request object
sess: Any, # FastHTML session object
step: Step # Current step
) -> InteractionContext: # Interaction context for rendering
"Create interaction context for a step."
```
``` python
@patch
def render_progress(self:StepFlow,
sess: Any # FastHTML session object
) -> FT: # Progress indicator or empty Div
"Render progress indicator showing all steps."
```
``` python
@patch
def render_step_content(self:StepFlow,
step_obj: Step, # Step to render
ctx: InteractionContext, # Interaction context
next_route: str, # Route for next/submit
back_route: Optional[str] = None, # Route for back
cancel_route: Optional[str] = None # Route for cancel
) -> FT: # Complete step content with optional progress and navigation
"Render step content with optional progress indicator and navigation."
```
``` python
@patch
def render_navigation(self:StepFlow,
step_id: str, # Current step ID
next_route: str, # Route for next/submit action
back_route: Optional[str] = None, # Route for back action
cancel_route: Optional[str] = None, # Route for cancel action
) -> FT: # Navigation button container
"Render navigation buttons for a step."
```
``` python
@patch
def create_router(self:StepFlow,
prefix: str = "" # URL prefix for routes (e.g., "/transcription")
) -> APIRouter: # APIRouter with generated routes
"Create FastHTML router with generated routes for this flow."
```
#### Classes
``` python
@dataclass
class Step:
"Definition of a single step in a multi-step workflow."
id: str # Unique step identifier (used in URLs)
title: str # Display title for the step
render: Callable[[InteractionContext], Any] # Function to render step UI
validate: Optional[Callable[[Dict[str, Any]], bool]] # Validation function
data_loader: Optional[Callable[[Any], Dict[str, Any]]] # Data loading function
data_keys: List[str] = field(...) # State keys managed by this step
can_skip: bool = False # Whether this step can be skipped
show_back: bool = True # Whether to show back button
show_cancel: bool = True # Whether to show cancel button
next_button_text: str = 'Continue' # Text for next/submit button
def is_valid(self, state: Dict[str, Any] # Current workflow state
) -> bool: # True if step is complete and valid
"Check if step has valid data in state."
```
``` python
class StepFlow:
def __init__(
self,
flow_id: str, # Unique identifier for this workflow
steps: List[Step], # List of step definitions
container_id: str = InteractionHtmlIds.STEP_FLOW_CONTAINER, # HTML ID for content container
on_complete: Optional[Callable[[Dict[str, Any], Any], Any]] = None, # Completion handler
show_progress: bool = False, # Whether to show progress indicator
wrap_in_form: bool = True # Whether to wrap content + navigation in a form
)
"Manage multi-step workflows with automatic route generation and state management."
def __init__(
self,
flow_id: str, # Unique identifier for this workflow
steps: List[Step], # List of step definitions
container_id: str = InteractionHtmlIds.STEP_FLOW_CONTAINER, # HTML ID for content container
on_complete: Optional[Callable[[Dict[str, Any], Any], Any]] = None, # Completion handler
show_progress: bool = False, # Whether to show progress indicator
wrap_in_form: bool = True # Whether to wrap content + navigation in a form
)
"Initialize step flow manager."
```
### Tabbed Interface (`tabbed_interface.ipynb`)
> Multi-tab interface pattern with automatic routing, state management,
> and DaisyUI styling
#### Import
``` python
from cjm_fasthtml_interactions.patterns.tabbed_interface import (
Tab,
TabbedInterface
)
```
#### Functions
``` python
@patch
def get_tab(self:TabbedInterface,
tab_id: str # Tab identifier
) -> Optional[Tab]: # Tab object or None
"Get tab by ID."
```
``` python
@patch
def get_tab_index(self:TabbedInterface,
tab_id: str # Tab identifier
) -> Optional[int]: # Tab index or None
"Get tab index by ID."
```
``` python
@patch
def create_context(self:TabbedInterface,
request: Any, # FastHTML request object
sess: Any, # FastHTML session object
tab: Tab # Current tab
) -> InteractionContext: # Interaction context for rendering
"Create interaction context for a tab."
```
``` python
@patch
def render_tabs(self:TabbedInterface,
current_tab_id: str, # Currently active tab ID
tab_route_func: Callable[[str], str] # Function to generate tab route
) -> FT: # Tab navigation element
"Render tab navigation using DaisyUI radio-based tabs."
```
``` python
@patch
def render_tab_content(self:TabbedInterface,
tab_obj: Tab, # Tab to render
ctx: InteractionContext # Interaction context
) -> FT: # Tab content
"Render tab content."
```
``` python
@patch
def render_full_interface(self:TabbedInterface,
current_tab_id: str, # Currently active tab ID
tab_route_func: Callable[[str], str], # Function to generate tab route
request: Any, # FastHTML request object
sess: Any # FastHTML session object
) -> FT: # Complete tabbed interface
"Render complete tabbed interface with tabs and content area."
```
``` python
@patch
def create_router(self:TabbedInterface,
prefix: str = "" # URL prefix for routes (e.g., "/dashboard")
) -> APIRouter: # APIRouter with generated routes
"Create FastHTML router with generated routes for this tabbed interface."
```
#### Classes
``` python
@dataclass
class Tab:
"Definition of a single tab in a tabbed interface."
id: str # Unique tab identifier (used in URLs)
label: str # Display label for the tab
render: Callable[[InteractionContext], Any] # Function to render tab content
title: Optional[str] # Optional title/tooltip for the tab
data_loader: Optional[Callable[[Any], Dict[str, Any]]] # Data loading function
load_on_demand: bool = True # Whether to load content only when tab is selected
```
``` python
class TabbedInterface:
def __init__(
self,
interface_id: str, # Unique identifier for this interface
tabs_list: List[Tab], # List of tab definitions
default_tab: Optional[str] = None, # Default tab ID (defaults to first tab)
container_id: str = InteractionHtmlIds.TABBED_INTERFACE_CONTAINER, # HTML ID for container
tabs_id: str = InteractionHtmlIds.TABBED_INTERFACE_TABS, # HTML ID for tabs element
content_id: str = InteractionHtmlIds.TABBED_INTERFACE_CONTENT, # HTML ID for content area
tab_style: Optional[str] = None, # DaisyUI tab style (lift, bordered, boxed)
show_on_htmx_only: bool = False # Whether to show full page layout for non-HTMX requests
)
"Manage multi-tab interfaces with automatic route generation and HTMX content loading."
def __init__(
self,
interface_id: str, # Unique identifier for this interface
tabs_list: List[Tab], # List of tab definitions
default_tab: Optional[str] = None, # Default tab ID (defaults to first tab)
container_id: str = InteractionHtmlIds.TABBED_INTERFACE_CONTAINER, # HTML ID for container
tabs_id: str = InteractionHtmlIds.TABBED_INTERFACE_TABS, # HTML ID for tabs element
content_id: str = InteractionHtmlIds.TABBED_INTERFACE_CONTENT, # HTML ID for content area
tab_style: Optional[str] = None, # DaisyUI tab style (lift, bordered, boxed)
show_on_htmx_only: bool = False # Whether to show full page layout for non-HTMX requests
)
"Initialize tabbed interface manager."
```
Raw data
{
"_id": null,
"home_page": "https://github.com/cj-mills/cjm-fasthtml-interactions",
"name": "cjm-fasthtml-interactions",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "nbdev jupyter notebook python",
"author": "Christian J. Mills",
"author_email": "9126128+cj-mills@users.noreply.github.com",
"download_url": "https://files.pythonhosted.org/packages/21/c8/c647e53d834055b1b07d1f3cdcd0887c55a9d58273e69b21b558af64cbb8/cjm_fasthtml_interactions-0.0.10.tar.gz",
"platform": null,
"description": "# cjm-fasthtml-interactions\n\n\n<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->\n\n## Install\n\n``` bash\npip install cjm_fasthtml_interactions\n```\n\n## Project Structure\n\n nbs/\n \u251c\u2500\u2500 core/ (2)\n \u2502 \u251c\u2500\u2500 context.ipynb # Context management for interaction patterns providing access to state, request, and custom data\n \u2502 \u2514\u2500\u2500 html_ids.ipynb # Centralized HTML ID constants for interaction pattern components\n \u2514\u2500\u2500 patterns/ (3)\n \u251c\u2500\u2500 master_detail.ipynb # Sidebar navigation pattern with master list and detail content area\n \u251c\u2500\u2500 step_flow.ipynb # Multi-step wizard pattern with state management, navigation, and route generation\n \u2514\u2500\u2500 tabbed_interface.ipynb # Multi-tab interface pattern with automatic routing, state management, and DaisyUI styling\n\nTotal: 5 notebooks across 2 directories\n\n## Module Dependencies\n\n``` mermaid\ngraph LR\n core_context[core.context<br/>Interaction Context]\n core_html_ids[core.html_ids<br/>HTML IDs]\n patterns_master_detail[patterns.master_detail<br/>Master-Detail]\n patterns_step_flow[patterns.step_flow<br/>Step Flow]\n patterns_tabbed_interface[patterns.tabbed_interface<br/>Tabbed Interface]\n\n patterns_master_detail --> core_context\n patterns_master_detail --> core_html_ids\n patterns_step_flow --> core_context\n patterns_step_flow --> core_html_ids\n patterns_tabbed_interface --> core_context\n patterns_tabbed_interface --> core_html_ids\n```\n\n*6 cross-module dependencies detected*\n\n## CLI Reference\n\nNo CLI commands found in this project.\n\n## Module Overview\n\nDetailed documentation for each module in the project:\n\n### Interaction Context (`context.ipynb`)\n\n> Context management for interaction patterns providing access to state,\n> request, and custom data\n\n#### Import\n\n``` python\nfrom cjm_fasthtml_interactions.core.context import (\n InteractionContext\n)\n```\n\n#### Classes\n\n``` python\n@dataclass\nclass InteractionContext:\n \"Context for interaction patterns providing access to state, request, and custom data.\"\n \n state: Dict[str, Any] = field(...) # Workflow state\n request: Optional[Any] # FastHTML request object\n session: Optional[Any] # FastHTML session object\n data: Dict[str, Any] = field(...) # Custom data from data loaders\n metadata: Dict[str, Any] = field(...) # Additional metadata\n \n def get(self,\n key: str, # Key to retrieve from state\n default: Any = None # Default value if key not found\n ) -> Any: # Value from state or default\n \"Get value from workflow state.\"\n \n def get_data(self,\n key: str, # Key to retrieve from data\n default: Any = None # Default value if key not found\n ) -> Any: # Value from data or default\n \"Get value from custom data.\"\n \n def has(self,\n key: str # Key to check in state\n ) -> bool: # True if key exists in state\n \"Check if key exists in workflow state.\"\n \n def set(self,\n key: str, # Key to set in state\n value: Any # Value to store\n ) -> None\n \"Set value in workflow state.\"\n \n def get_all_state(self) -> Dict[str, Any]: # All workflow state\n \"\"\"Get all workflow state as dictionary.\"\"\"\n return self.state.copy()\n \n def update_state(self, \n updates: Dict[str, Any] # State updates to apply\n ) -> None\n \"Get all workflow state as dictionary.\"\n \n def update_state(self,\n updates: Dict[str, Any] # State updates to apply\n ) -> None\n \"Update multiple state values at once.\"\n```\n\n### HTML IDs (`html_ids.ipynb`)\n\n> Centralized HTML ID constants for interaction pattern components\n\n#### Import\n\n``` python\nfrom cjm_fasthtml_interactions.core.html_ids import (\n InteractionHtmlIds\n)\n```\n\n#### Classes\n\n``` python\nclass InteractionHtmlIds(AppHtmlIds):\n \"\"\"\n HTML ID constants for interaction pattern components.\n \n Inherits from AppHtmlIds:\n - MAIN_CONTENT = \"main-content\"\n - ALERT_CONTAINER = \"alert-container\"\n - as_selector(id_str) - static method\n \"\"\"\n \n def step_content(step_id: str # Step identifier\n ) -> str: # HTML ID for step content\n \"Generate HTML ID for a specific step's content.\"\n \n def step_indicator(step_id: str # Step identifier\n ) -> str: # HTML ID for step indicator\n \"Generate HTML ID for a specific step's progress indicator.\"\n \n def tab_radio(tab_id: str # Tab identifier\n ) -> str: # HTML ID for tab radio input\n \"Generate HTML ID for a specific tab's radio input.\"\n \n def tab_content(tab_id: str # Tab identifier\n ) -> str: # HTML ID for tab content\n \"Generate HTML ID for a specific tab's content.\"\n \n def master_item(item_id: str # Item identifier\n ) -> str: # HTML ID for master list item\n \"Generate HTML ID for a master list item.\"\n \n def master_group(group_id: str # Group identifier\n ) -> str: # HTML ID for master list group\n \"Generate HTML ID for a master list group.\"\n \n def detail_content(item_id: str # Item identifier\n ) -> str: # HTML ID for detail content\n \"Generate HTML ID for detail content area.\"\n```\n\n### Master-Detail (`master_detail.ipynb`)\n\n> Sidebar navigation pattern with master list and detail content area\n\n#### Import\n\n``` python\nfrom cjm_fasthtml_interactions.patterns.master_detail import (\n DetailItem,\n DetailItemGroup,\n MasterDetail\n)\n```\n\n#### Functions\n\n``` python\n@patch\ndef get_item(self:MasterDetail, \n item_id: str # Item identifier\n ) -> Optional[DetailItem]: # DetailItem or None\n \"Get item by ID.\"\n```\n\n``` python\n@patch\ndef create_context(self:MasterDetail, \n request: Any, # FastHTML request object\n sess: Any, # FastHTML session object\n item: DetailItem # Current item\n ) -> InteractionContext: # Interaction context for rendering\n \"Create interaction context for an item.\"\n```\n\n``` python\n@patch\ndef render_master(self:MasterDetail,\n active_item_id: str, # Currently active item ID\n item_route_func: Callable[[str], str], # Function to generate item route\n include_wrapper: bool = True # Whether to include outer wrapper div\n ) -> FT: # Master list element\n \"Render master list (sidebar) with items and groups.\"\n```\n\n``` python\n@patch\ndef render_master_oob(self:MasterDetail,\n active_item_id: str, # Currently active item ID\n item_route_func: Callable[[str], str] # Function to generate item route\n ) -> FT: # Master list with OOB swap attribute\n \"Render master list with OOB swap attribute for coordinated updates.\"\n```\n\n``` python\n@patch\ndef render_detail(self:MasterDetail,\n item: DetailItem, # Item to render\n ctx: InteractionContext # Interaction context\n ) -> FT: # Detail content\n \"Render detail content for an item.\"\n```\n\n``` python\n@patch\ndef render_full_interface(self:MasterDetail,\n active_item_id: str, # Currently active item ID\n item_route_func: Callable[[str], str], # Function to generate item route\n request: Any, # FastHTML request object\n sess: Any # FastHTML session object\n ) -> FT: # Complete master-detail interface\n \"Render complete master-detail interface with master list and detail area.\"\n```\n\n``` python\n@patch\ndef create_router(self:MasterDetail,\n prefix: str = \"\" # URL prefix for routes (e.g., \"/media\")\n ) -> APIRouter: # APIRouter with generated routes\n \"Create FastHTML router with generated routes for this master-detail interface.\"\n```\n\n#### Classes\n\n``` python\n@dataclass\nclass DetailItem:\n \"Definition of a single item in the master-detail pattern.\"\n \n id: str # Unique identifier\n label: str # Display text in master list\n render: Callable[[InteractionContext], Any] # Function to render detail view\n badge_text: Optional[str] # Optional badge text (e.g., \"configured\", \"3 items\")\n badge_color: Optional[str] # Badge color class (e.g., badge_colors.success)\n icon: Optional[Any] # Optional icon element\n data_loader: Optional[Callable[[Any], Dict[str, Any]]] # Data loading function\n load_on_demand: bool = True # Whether to load content only when item is selected\n```\n\n``` python\n@dataclass\nclass DetailItemGroup:\n \"Group of related detail items in a collapsible section.\"\n \n id: str # Group identifier\n title: str # Group display title\n items: List[DetailItem] # Items in this group\n default_open: bool = True # Whether group is expanded by default\n icon: Optional[Any] # Optional group icon\n badge_text: Optional[str] # Optional badge for the group\n badge_color: Optional[str] # Badge color for the group\n```\n\n``` python\nclass MasterDetail:\n def __init__(\n self,\n interface_id: str, # Unique identifier for this interface\n items: List[Union[DetailItem, DetailItemGroup]], # List of items/groups\n default_item: Optional[str] = None, # Default item ID (defaults to first item)\n container_id: str = InteractionHtmlIds.MASTER_DETAIL_CONTAINER, # HTML ID for container\n master_id: str = InteractionHtmlIds.MASTER_DETAIL_MASTER, # HTML ID for master list\n detail_id: str = InteractionHtmlIds.MASTER_DETAIL_DETAIL, # HTML ID for detail area\n master_width: str = \"w-64\", # Tailwind width class for master list\n master_title: Optional[str] = None, # Optional title for master list\n show_on_htmx_only: bool = False # Whether to show full interface for non-HTMX requests\n )\n \"Manage master-detail interfaces with sidebar navigation and detail content area.\"\n \n def __init__(\n self,\n interface_id: str, # Unique identifier for this interface\n items: List[Union[DetailItem, DetailItemGroup]], # List of items/groups\n default_item: Optional[str] = None, # Default item ID (defaults to first item)\n container_id: str = InteractionHtmlIds.MASTER_DETAIL_CONTAINER, # HTML ID for container\n master_id: str = InteractionHtmlIds.MASTER_DETAIL_MASTER, # HTML ID for master list\n detail_id: str = InteractionHtmlIds.MASTER_DETAIL_DETAIL, # HTML ID for detail area\n master_width: str = \"w-64\", # Tailwind width class for master list\n master_title: Optional[str] = None, # Optional title for master list\n show_on_htmx_only: bool = False # Whether to show full interface for non-HTMX requests\n )\n \"Initialize master-detail manager.\"\n```\n\n### Step Flow (`step_flow.ipynb`)\n\n> Multi-step wizard pattern with state management, navigation, and route\n> generation\n\n#### Import\n\n``` python\nfrom cjm_fasthtml_interactions.patterns.step_flow import (\n Step,\n StepFlow\n)\n```\n\n#### Functions\n\n``` python\n@patch\ndef get_step(self:StepFlow, \n step_id: str # Step identifier\n ) -> Optional[Step]: # Step object or None\n \"Get step by ID.\"\n```\n\n``` python\n@patch\ndef get_step_index(self:StepFlow, \n step_id: str # Step identifier\n ) -> Optional[int]: # Step index or None\n \"Get step index by ID.\"\n```\n\n``` python\n@patch\ndef get_current_step_id(self:StepFlow, \n sess: Any # FastHTML session object\n ) -> str: # Current step ID\n \"Get current step ID from session.\"\n```\n\n``` python\n@patch\ndef set_current_step(self:StepFlow, \n sess: Any, # FastHTML session object\n step_id: str # Step ID to set as current\n ) -> None\n \"Set current step in session.\"\n```\n\n``` python\n@patch\ndef get_next_step_id(self:StepFlow, \n current_step_id: str # Current step ID\n ) -> Optional[str]: # Next step ID or None if last step\n \"Get the ID of the next step.\"\n```\n\n``` python\n@patch\ndef get_previous_step_id(self:StepFlow, \n current_step_id: str # Current step ID\n ) -> Optional[str]: # Previous step ID or None if first step\n \"Get the ID of the previous step.\"\n```\n\n``` python\n@patch\ndef is_last_step(self:StepFlow, \n step_id: str # Step ID to check\n ) -> bool: # True if this is the last step\n \"Check if step is the last step.\"\n```\n\n``` python\n@patch\ndef is_first_step(self:StepFlow, \n step_id: str # Step ID to check\n ) -> bool: # True if this is the first step\n \"Check if step is the first step.\"\n```\n\n``` python\n@patch\ndef get_workflow_state(self:StepFlow, \n sess: Any # FastHTML session object\n ) -> Dict[str, Any]: # All workflow state\n \"Get all workflow state from session.\"\n```\n\n``` python\n@patch\ndef update_workflow_state(self:StepFlow, \n sess: Any, # FastHTML session object\n updates: Dict[str, Any] # State updates\n ) -> None\n \"Update workflow state with new values.\"\n```\n\n``` python\n@patch\ndef clear_workflow(self:StepFlow, \n sess: Any # FastHTML session object\n ) -> None\n \"Clear all workflow state.\"\n```\n\n``` python\n@patch\ndef create_context(self:StepFlow, \n request: Any, # FastHTML request object\n sess: Any, # FastHTML session object\n step: Step # Current step\n ) -> InteractionContext: # Interaction context for rendering\n \"Create interaction context for a step.\"\n```\n\n``` python\n@patch\ndef render_progress(self:StepFlow, \n sess: Any # FastHTML session object\n ) -> FT: # Progress indicator or empty Div\n \"Render progress indicator showing all steps.\"\n```\n\n``` python\n@patch\ndef render_step_content(self:StepFlow,\n step_obj: Step, # Step to render\n ctx: InteractionContext, # Interaction context\n next_route: str, # Route for next/submit\n back_route: Optional[str] = None, # Route for back\n cancel_route: Optional[str] = None # Route for cancel\n ) -> FT: # Complete step content with optional progress and navigation\n \"Render step content with optional progress indicator and navigation.\"\n```\n\n``` python\n@patch\ndef render_navigation(self:StepFlow,\n step_id: str, # Current step ID\n next_route: str, # Route for next/submit action\n back_route: Optional[str] = None, # Route for back action\n cancel_route: Optional[str] = None, # Route for cancel action\n ) -> FT: # Navigation button container\n \"Render navigation buttons for a step.\"\n```\n\n``` python\n@patch\ndef create_router(self:StepFlow,\n prefix: str = \"\" # URL prefix for routes (e.g., \"/transcription\")\n ) -> APIRouter: # APIRouter with generated routes\n \"Create FastHTML router with generated routes for this flow.\"\n```\n\n#### Classes\n\n``` python\n@dataclass\nclass Step:\n \"Definition of a single step in a multi-step workflow.\"\n \n id: str # Unique step identifier (used in URLs)\n title: str # Display title for the step\n render: Callable[[InteractionContext], Any] # Function to render step UI\n validate: Optional[Callable[[Dict[str, Any]], bool]] # Validation function\n data_loader: Optional[Callable[[Any], Dict[str, Any]]] # Data loading function\n data_keys: List[str] = field(...) # State keys managed by this step\n can_skip: bool = False # Whether this step can be skipped\n show_back: bool = True # Whether to show back button\n show_cancel: bool = True # Whether to show cancel button\n next_button_text: str = 'Continue' # Text for next/submit button\n \n def is_valid(self, state: Dict[str, Any] # Current workflow state\n ) -> bool: # True if step is complete and valid\n \"Check if step has valid data in state.\"\n```\n\n``` python\nclass StepFlow:\n def __init__(\n self,\n flow_id: str, # Unique identifier for this workflow\n steps: List[Step], # List of step definitions\n container_id: str = InteractionHtmlIds.STEP_FLOW_CONTAINER, # HTML ID for content container\n on_complete: Optional[Callable[[Dict[str, Any], Any], Any]] = None, # Completion handler\n show_progress: bool = False, # Whether to show progress indicator\n wrap_in_form: bool = True # Whether to wrap content + navigation in a form\n )\n \"Manage multi-step workflows with automatic route generation and state management.\"\n \n def __init__(\n self,\n flow_id: str, # Unique identifier for this workflow\n steps: List[Step], # List of step definitions\n container_id: str = InteractionHtmlIds.STEP_FLOW_CONTAINER, # HTML ID for content container\n on_complete: Optional[Callable[[Dict[str, Any], Any], Any]] = None, # Completion handler\n show_progress: bool = False, # Whether to show progress indicator\n wrap_in_form: bool = True # Whether to wrap content + navigation in a form\n )\n \"Initialize step flow manager.\"\n```\n\n### Tabbed Interface (`tabbed_interface.ipynb`)\n\n> Multi-tab interface pattern with automatic routing, state management,\n> and DaisyUI styling\n\n#### Import\n\n``` python\nfrom cjm_fasthtml_interactions.patterns.tabbed_interface import (\n Tab,\n TabbedInterface\n)\n```\n\n#### Functions\n\n``` python\n@patch\ndef get_tab(self:TabbedInterface, \n tab_id: str # Tab identifier\n ) -> Optional[Tab]: # Tab object or None\n \"Get tab by ID.\"\n```\n\n``` python\n@patch\ndef get_tab_index(self:TabbedInterface, \n tab_id: str # Tab identifier\n ) -> Optional[int]: # Tab index or None\n \"Get tab index by ID.\"\n```\n\n``` python\n@patch\ndef create_context(self:TabbedInterface, \n request: Any, # FastHTML request object\n sess: Any, # FastHTML session object\n tab: Tab # Current tab\n ) -> InteractionContext: # Interaction context for rendering\n \"Create interaction context for a tab.\"\n```\n\n``` python\n@patch\ndef render_tabs(self:TabbedInterface,\n current_tab_id: str, # Currently active tab ID\n tab_route_func: Callable[[str], str] # Function to generate tab route\n ) -> FT: # Tab navigation element\n \"Render tab navigation using DaisyUI radio-based tabs.\"\n```\n\n``` python\n@patch\ndef render_tab_content(self:TabbedInterface,\n tab_obj: Tab, # Tab to render\n ctx: InteractionContext # Interaction context\n ) -> FT: # Tab content\n \"Render tab content.\"\n```\n\n``` python\n@patch\ndef render_full_interface(self:TabbedInterface,\n current_tab_id: str, # Currently active tab ID\n tab_route_func: Callable[[str], str], # Function to generate tab route\n request: Any, # FastHTML request object\n sess: Any # FastHTML session object\n ) -> FT: # Complete tabbed interface\n \"Render complete tabbed interface with tabs and content area.\"\n```\n\n``` python\n@patch\ndef create_router(self:TabbedInterface,\n prefix: str = \"\" # URL prefix for routes (e.g., \"/dashboard\")\n ) -> APIRouter: # APIRouter with generated routes\n \"Create FastHTML router with generated routes for this tabbed interface.\"\n```\n\n#### Classes\n\n``` python\n@dataclass\nclass Tab:\n \"Definition of a single tab in a tabbed interface.\"\n \n id: str # Unique tab identifier (used in URLs)\n label: str # Display label for the tab\n render: Callable[[InteractionContext], Any] # Function to render tab content\n title: Optional[str] # Optional title/tooltip for the tab\n data_loader: Optional[Callable[[Any], Dict[str, Any]]] # Data loading function\n load_on_demand: bool = True # Whether to load content only when tab is selected\n```\n\n``` python\nclass TabbedInterface:\n def __init__(\n self,\n interface_id: str, # Unique identifier for this interface\n tabs_list: List[Tab], # List of tab definitions\n default_tab: Optional[str] = None, # Default tab ID (defaults to first tab)\n container_id: str = InteractionHtmlIds.TABBED_INTERFACE_CONTAINER, # HTML ID for container\n tabs_id: str = InteractionHtmlIds.TABBED_INTERFACE_TABS, # HTML ID for tabs element\n content_id: str = InteractionHtmlIds.TABBED_INTERFACE_CONTENT, # HTML ID for content area\n tab_style: Optional[str] = None, # DaisyUI tab style (lift, bordered, boxed)\n show_on_htmx_only: bool = False # Whether to show full page layout for non-HTMX requests\n )\n \"Manage multi-tab interfaces with automatic route generation and HTMX content loading.\"\n \n def __init__(\n self,\n interface_id: str, # Unique identifier for this interface\n tabs_list: List[Tab], # List of tab definitions\n default_tab: Optional[str] = None, # Default tab ID (defaults to first tab)\n container_id: str = InteractionHtmlIds.TABBED_INTERFACE_CONTAINER, # HTML ID for container\n tabs_id: str = InteractionHtmlIds.TABBED_INTERFACE_TABS, # HTML ID for tabs element\n content_id: str = InteractionHtmlIds.TABBED_INTERFACE_CONTENT, # HTML ID for content area\n tab_style: Optional[str] = None, # DaisyUI tab style (lift, bordered, boxed)\n show_on_htmx_only: bool = False # Whether to show full page layout for non-HTMX requests\n )\n \"Initialize tabbed interface manager.\"\n```\n",
"bugtrack_url": null,
"license": "Apache Software License 2.0",
"summary": "Reusable user interaction patterns for FastHTML applications including multi-step wizards, master-detail views, modal workflows, and other stateful UI orchestration patterns.",
"version": "0.0.10",
"project_urls": {
"Homepage": "https://github.com/cj-mills/cjm-fasthtml-interactions"
},
"split_keywords": [
"nbdev",
"jupyter",
"notebook",
"python"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "af692553edcc5deecdf194800d0d6a975888613f16abd92d333736813e3b2b29",
"md5": "d9c3d3404101cef2e8e7a03046167545",
"sha256": "985bba5aaa8c751762058a2ca0a65cea6267871e9d20dd369813e749a9f5e8e7"
},
"downloads": -1,
"filename": "cjm_fasthtml_interactions-0.0.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d9c3d3404101cef2e8e7a03046167545",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 26257,
"upload_time": "2025-10-30T21:26:47",
"upload_time_iso_8601": "2025-10-30T21:26:47.936009Z",
"url": "https://files.pythonhosted.org/packages/af/69/2553edcc5deecdf194800d0d6a975888613f16abd92d333736813e3b2b29/cjm_fasthtml_interactions-0.0.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "21c8c647e53d834055b1b07d1f3cdcd0887c55a9d58273e69b21b558af64cbb8",
"md5": "ff1743e267c7553b3289d85c2540388c",
"sha256": "ecbe6bdc1172f54b7ef9dcb25289b6626dd259055926247f01fe85f14c52d58d"
},
"downloads": -1,
"filename": "cjm_fasthtml_interactions-0.0.10.tar.gz",
"has_sig": false,
"md5_digest": "ff1743e267c7553b3289d85c2540388c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 27375,
"upload_time": "2025-10-30T21:26:49",
"upload_time_iso_8601": "2025-10-30T21:26:49.308415Z",
"url": "https://files.pythonhosted.org/packages/21/c8/c647e53d834055b1b07d1f3cdcd0887c55a9d58273e69b21b558af64cbb8/cjm_fasthtml_interactions-0.0.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-30 21:26:49",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "cj-mills",
"github_project": "cjm-fasthtml-interactions",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "cjm-fasthtml-interactions"
}