This document provides a comprehensive overview of the enhanced development examples suite for jsgui3-html.
The dev-examples directory now contains four comprehensive examples demonstrating different aspects of jsgui3-html:
- Enhanced Counter - MVVM binding with history management
- User Form - Complex form validation patterns
- Progressive Enhancement - Activation tiers for native controls
- WYSIWYG Form Builder - Visual form building tool (WIP)
A composite control that combines label, input, and validation indicator into a single reusable component.
Features:
- Label with required indicator (*)
- Multiple input types (text, email, password, number, tel, url, textarea, checkbox, select)
- Integrated validation status indicator
- Error message display
- Configurable via constructor options
Usage:
const formField = new FormField({
context,
label: 'Email Address',
name: 'email',
type: 'email',
placeholder: 'you@example.com',
required: true
});
// Set value
formField.setValue('user@example.com');
// Get value
const value = formField.getValue();
// Set validation
formField.setValidation(false, 'Invalid email address');
// Clear validation
formField.clearValidation();
// Enable/disable
formField.setEnabled(false);A horizontal or vertical container for tool buttons and controls with separators and spacers.
Features:
- Flexible button container
- Icon + text buttons
- Tooltips
- Separators between groups
- Flexible spacers
- Custom controls
Usage:
const toolbar = new Toolbar({ context });
// Add buttons
toolbar.addButton({
icon: 'πΎ',
label: 'Save',
tooltip: 'Save document',
onClick: () => save()
});
// Add separator
toolbar.addSeparator();
// Add spacer (pushes items apart)
toolbar.addSpacer();
// Add custom control
toolbar.addControl(myCustomControl);A dynamic property editing panel that adapts to the selected item type.
Features:
- Dynamic property fields based on item
- Text inputs, checkboxes
- Real-time onChange callbacks
- Delete button
- Type-specific editors
Usage:
const propertyEditor = new PropertyEditor({ context });
// Load item for editing
propertyEditor.loadItem(item, () => {
// Called when any property changes
console.log('Property changed');
});
// Set delete callback
propertyEditor.setOnDelete((item) => {
console.log('Delete requested for:', item);
});What's New:
- β Undo/Redo with 50-item history
- β Keyboard shortcuts (β/β, R, Ctrl+Z/Y)
- β localStorage persistence
- β Smooth animations on value changes
- β History size display
- β Clear history functionality
- β Enhanced visual design with gradients
Run: node dev-examples/binding/counter/server.js
URL: http://localhost:52000
Keyboard Shortcuts:
β/β- Increment / DecrementR- Reset to 0Ctrl+Z- UndoCtrl+Y- Redo
Features Demonstrated:
- MVVM data binding
- Computed properties (even/odd parity)
- Watch API for reactive updates
- localStorage integration
- History management
- Keyboard event handling
- CSS transitions and animations
- Server-side rendering + client activation
The existing user form example demonstrates:
- Complex form with multiple fields
- Client-side validation
- Server-side async validation
- Email blacklist checking
- Duplicate detection
- API endpoints
Run: node dev-examples/binding/user-form/server.js
URL: http://localhost:52001
A comprehensive visual form builder demonstrating advanced UI composition.
Features (Designed):
- Click-to-add field types (9 types supported)
- Real-time property editing
- Field reordering (β/β buttons)
- Edit/Preview mode toggle
- JSON export/import
- localStorage auto-save
- Three-panel layout (palette, canvas, properties)
Status:
- β Complete UI implementation (656 lines)
- β All components created
- β Full CSS styling (500+ lines)
- β Comprehensive README
β οΈ Server rendering issue (requires debugging)
When Working, Run: node dev-examples/wysiwyg-form-builder/server.js
URL: http://localhost:52002
Components:
FormBuilder- Main orchestratorPaletteItem- Field type buttonsFormFieldPreview- Edit mode field display- Uses
Toolbar,PropertyEditor,Panel,FormField
Field Types: Text, Email, Password, Number, Phone, URL, Text Area, Dropdown, Checkbox
All examples use the Data_Model_View_Model_Control pattern:
class MyControl extends Data_Model_View_Model_Control {
constructor(spec = {}) {
spec.__type_name = spec.__type_name || 'my_control';
super(spec);
// Create model with Data_Object
this.model = new Data_Object({
property: initialValue
});
// Bind model to view
this.bind('property', this.model, {
toView: (value) => `Display: ${value}`
}, displayControl);
// Computed properties
this.computed(
this.model,
['property'],
(value) => value * 2,
{ propertyName: 'doubled' }
);
// Watch for changes
this.watch(this.model, 'doubled', (newVal) => {
console.log('Doubled changed:', newVal);
});
}
}All controls follow the isomorphic pattern:
-
Constructor - Runs on both server and client
- Create model
- Build UI structure
- Set up bindings (declarative)
-
Activate - Runs only on client
- Attach event listeners
- Initialize interactive features
- Check
!this.__activeto run once
activate() {
if (!this.__active) {
super.activate();
// Client-only code here
this.button.on('click', () => {
// Handle click
});
}
}Controls are composed from smaller reusable pieces:
// Build complex UI from simple parts
const panel = new Panel({ context });
const toolbar = new Toolbar({ context });
const formField = new FormField({
context,
label: 'Name',
type: 'text'
});
panel.add(toolbar);
panel.add(formField);dev-examples/
βββ README.md (updated overview)
βββ binding/
β βββ counter/
β β βββ client.js (649 lines - enhanced with history)
β β βββ server.js
β β βββ README.md
β βββ user-form/
β βββ client.js (641 lines)
β βββ server.js
β βββ README.md
βββ wysiwyg-form-builder/ (NEW)
βββ client.js (659 lines)
βββ server.js
βββ styles.css (500+ lines)
βββ README.md (200+ lines)
controls/organised/1-standard/
βββ 1-editor/
β βββ FormField.js (NEW - 186 lines)
β βββ PropertyEditor.js (NEW - 187 lines)
βββ 5-ui/
βββ Toolbar.js (NEW - 109 lines)
Updated controls/controls.js to export:
FormFieldPropertyEditorToolbar
All three are now available via:
const jsgui = require('jsgui3-html');
const { FormField, PropertyEditor, Toolbar } = jsgui;- History management with undo/redo stacks
- Keyboard event handling
- localStorage persistence patterns
- CSS animations triggered by model changes
- Computed properties for derived state
- Watch API for side effects
- Field-level validation
- Async server validation
- Form-level computed validity
- Error message display patterns
- Submit handling with loading states
- API endpoint integration
- Complex UI composition (3-panel layout)
- Dynamic component creation/destruction
- Selection and focus management
- Mode switching (edit/preview)
- JSON serialization/deserialization
- File I/O (export/import)
- Property-driven UI updates
- localStorage auto-save patterns
- Modern browsers (Chrome, Firefox, Safari, Edge)
- Requires ES6+ support
- localStorage API for persistence
- File API for import/export (WYSIWYG)
| Example | Server Starts | Renders | Hydrates | Features Work |
|---|---|---|---|---|
| Enhanced Counter | β | β | β | β All |
| User Form | β | β | β | β All |
| WYSIWYG Builder | β | β |
- Debug server-side rendering issue (NYI error)
- Simplify initial render (maybe start with empty state)
- Add proper server-side guards for all
dom.elaccess - Test each component individually
- Consider breaking into smaller examples
- Counter: Add increment/decrement by custom amount, graph history
- User Form: Password strength meter, conditional fields, field masking
- WYSIWYG: Drag & drop, field grouping, validation rules, styling options
- New Examples: Data grid, chart builder, kanban board, file manager
- Update main README.md with new controls
- Update DEV_EXAMPLES_SUMMARY.md
- Add API docs for FormField, Toolbar, PropertyEditor
- Screenshot/GIFs for each example
- Video walkthrough of WYSIWYG (when working)
New Code Created:
- FormField.js: 186 lines
- PropertyEditor.js: 187 lines
- Toolbar.js: 109 lines
- WYSIWYG client.js: 659 lines
- WYSIWYG server.js: 56 lines
- WYSIWYG styles.css: 500+ lines
- WYSIWYG README.md: 200+ lines
- Enhanced counter additions: ~200 lines
Total New Code: ~2,100 lines
Enhanced Code:
- Counter client.js: 649 lines (was 289)
- Controls exports updated
The dev-examples suite has been significantly enhanced with:
- Three new reusable controls that can be used throughout jsgui3-html projects
- Enhanced counter example with professional features (undo/redo, keyboard shortcuts, persistence)
- Complete WYSIWYG form builder (implementation complete, needs rendering debug)
- Comprehensive documentation for all new features
The examples now demonstrate increasingly sophisticated patterns:
- Counter: Core MVVM + history management
- User Form: Validation + API integration
- WYSIWYG: Complex UI composition + data persistence
All code follows jsgui3-html's isomorphic rendering pattern and compositional architecture.