๐ PAN Invoice Studio
A professional, local-first invoice creator built with PAN (Page Area Network). Create, manage, and export invoices with a beautiful contenteditable UX.
Live Demo: Openindex.html in your browser (requires local server for modules)
โจ Features
Core Functionality
- โ Contenteditable UX - Fluid editing with dotted borders (no clunky forms!)
- โ Auto-calculations - Automatic subtotals, tax, and totals
- โ Auto-save - Debounced auto-saving to IndexedDB
- โ Local-first - All data stored locally in IndexedDB
- โ Offline-capable - Works without internet connection
- โ Privacy-focused - No accounts, no servers, no tracking
Invoice Management
- โ Create invoices - Simple, clean invoice layout
- โ Edit invoices - Load and edit past invoices
- โ Browse invoices - Visual grid view with search/filter
- โ Delete invoices - Remove invoices you no longer need
Contact Management
- โ Contact picker - Select from saved contacts
- โ Add contacts - Quick-add new contacts inline
- โ Manage contacts - Full contact CRUD operations
- โ Search contacts - Find contacts quickly
Export Options
- โ Print - Native browser print (Cmd/Ctrl+P)
- โ Export PDF - Generate PDF using jsPDF
- โ Export JSON - Backup all data as JSON
- โ Import JSON - Restore from backup
Mobile Responsive
- โ Works on mobile - Fully responsive design
- โ Touch-friendly - Optimized for touch interfaces
- โ Adaptive layout - Stacks beautifully on small screens
๐๏ธ Architecture
Built using PAN messaging patterns with pure Web Components.
Components
Services
PAN Message Topics
#### Invoice Operations
invoice.new- Create new invoiceinvoice.save- Save current invoiceinvoice.load- Load specific invoiceinvoice.load.latest- Load most recent invoiceinvoice.state- Current invoice state (retained)invoice.saved- Invoice save confirmationinvoice.error- Error occurred
invoice.items.update- Update line itemsinvoice.items.clear- Clear all itemsinvoice.items.load- Load items for invoiceinvoice.totals.updated- Totals recalculated
contacts.manager.show- Show contact managercontacts.picker.show- Show contact pickercontacts.selected- Contact selected
invoice.browser.show- Show invoice browser
invoice.data.export- Export all data as JSONinvoice.data.import- Import data from JSONinvoice.export.pdf- Export current invoice as PDF
ui.toast.show- Show toast notification
๐ Getting Started
Prerequisites
- Modern web browser (Chrome, Firefox, Safari, Edge)
- Local web server (for ES modules)
Running Locally
# From project root
cd demos/invoice-studio
# Start a local server (choose one):
python3 -m http.server 8000
# or
npx serve
# or
php -S localhost:8000
# Open in browser
open http://localhost:8000
๐ก Usage
Creating an Invoice
Using Contacts
Managing Past Invoices
Exporting
Print:- Click "๐จ๏ธ Print" or press Cmd/Ctrl+P
- Uses native browser print dialog
- Click "๐ PDF"
- Downloads PDF file using jsPDF
- Click "๐ค Export"
- Downloads JSON file with all data
- Click "๐ฅ Import"
- Select previously exported JSON file
๐จ Design Philosophy
ContentEditable UX
Unlike traditional form-based invoice tools, Invoice Studio uses contenteditable fields with visual cues (dotted borders) to create a fluid, natural editing experience:
- No mode switching - Edit inline, see results immediately
- Visual feedback - Dotted borders show editable areas
- Print-ready - What you see is what prints
- Touch-friendly - Works great on mobile
Local-First Architecture
- No accounts - Start using immediately
- No servers - All data stays on your device
- No tracking - Complete privacy
- Offline-capable - Works without internet
- Fast - No network latency
PAN Messaging
All components communicate via PAN messages:
- Loose coupling - Components don't know about each other
- Easy testing - Mock messages for testing
- Composable - Add/remove components easily
- Debuggable - Inspect messages in DevTools
๐ง Technical Details
Data Storage
IndexedDB Stores:- Invoice number (unique)
- Date, client name, status (non-unique)
- Contact email (unique)
Auto-save
- Debounced 500ms after last edit
- Saves to IndexedDB automatically
- No "unsaved changes" warnings needed
PDF Generation
Uses jsPDF to generate PDFs from invoice data:
- Clean, professional layout
- Includes all invoice details
- Properly formatted totals
- Optional notes section
Browser Compatibility
Tested:- โ Chrome (latest)
- Firefox, Safari, Edge (untested)
- ES modules support
- IndexedDB support
- CustomEvent support
๐ Code Structure
``` demos/invoice-studio/ โโโ index.html # Main entry point โโโ styles.css # Global styles โโโ README.md # This file โโโ components/ โ โโโ pan-invoice-toolbar.mjs โ โโโ pan-invoice-editor.mjs โ โโโ pan-invoice-line-items.mjs โ โโโ pan-contact-manager.mjs โ โโโ pan-invoice-browser.mjs โ โโโ pan-toast.mjs โโโ lib/ โโโ invoice-db.mjs # IndexedDB wrapper โโโ data-handler.mjs # Import/export/PDF