A comprehensive React UI component library for AWS Amplify applications, providing CRUD operations, data visualization, auto-save forms, search & filtering, and address lookup with TypeScript support.
npm install anton-bakker-amplify-componentsA comprehensive React UI component library for AWS Amplify applications, providing CRUD operations, data visualization, and enhanced user experience features.
``bash`
npm install anton-bakker-amplify-components
`bash`
npm install aws-amplify@^6 react@^18 react-dom@^18 @aws-amplify/ui-react@^6 @tanstack/react-query@^5
`typescript
import { DefaultListPage, DefaultCreatePage, DefaultUpdatePage } from 'anton-bakker-amplify-components';
// List page with auto-detected columns
columns="auto"
/>
// Create page with auto-detected fields
fields="auto"
/>
// Update page with custom field overrides
fields="auto"
fieldOverrides={{
price: { type: 'number', info: 'Price in USD' },
email: { info: 'Valid email address required' }
}}
/>
`
`typescript
import { KPIDashboard, SimpleBarChart, SimplePieChart } from 'anton-bakker-amplify-components';
// KPI Dashboard
{ title: 'Total Sales', value: 125000, format: 'currency' },
{ title: 'Active Users', value: 1250, format: 'number' },
{ title: 'Growth Rate', value: 15.5, format: 'percentage' }
]}
/>
// Bar Chart
{ label: 'Q1', value: 100 },
{ label: 'Q2', value: 150 },
{ label: 'Q3', value: 200 }
]}
title="Quarterly Sales"
/>
`
`typescript
import { HybridSearchModal, SearchModal } from 'anton-bakker-amplify-components';
// Hybrid search with filters
searchFields={['name', 'description']}
filters={[
{ field: 'category', type: 'select', options: categoryOptions },
{ field: 'price', type: 'range', min: 0, max: 1000 }
]}
onSelect={handleProductSelect}
/>
`
`typescript
import { AutoSaveProvider, AutoSaveTextField } from 'anton-bakker-amplify-components';
label="Product Title"
saveEndpoint="/api/products/123"
/>
`
| Component | Purpose | Key Props |
|-----------|---------|-----------|
| DefaultListPage | Data table with pagination, sorting, filtering | modelName, columns, filters |DefaultCreatePage
| | Form for creating new records | modelName, fields, fieldOverrides |DefaultUpdatePage
| | Form for editing existing records | modelName, fields, recordId |DefaultRetrievePage
| | Read-only record display | modelName, recordId, fields |GenericCrudPage
| | All-in-one CRUD interface | modelName, mode |GenericCrudModal
| | Modal-based CRUD operations | modelName, isOpen, mode |
| Component | Purpose | Key Props |
|-----------|---------|-----------|
| KPICard | Single metric display | title, value, format, trend |KPIDashboard
| | Multiple KPI cards layout | kpis, columns |SimpleBarChart
| | Bar chart visualization | data, title, xAxisLabel |SimplePieChart
| | Pie chart visualization | data, title, showLegend |
| Component | Purpose | Key Props |
|-----------|---------|-----------|
| SearchModal | Basic search interface | modelName, searchFields, onSelect |HybridSearchModal
| | Advanced search with filters | modelName, searchFields, filters |FieldFilter
| | Individual field filter | field, type, options, onChange |
| Component | Purpose | Key Props |
|-----------|---------|-----------|
| AutoSaveProvider | Context for auto-save functionality | debounceMs, onSave |AutoSaveTextField
| | Text field with auto-save | name, saveEndpoint, debounceMs |AutoSaveIndicator
| | Visual feedback for save status | status, lastSaved |
| Component | Purpose | Key Props |
|-----------|---------|-----------|
| AddressLookup | Location search and selection | onSelect, placeholder, region |ProtectedRoute
| | Route-based access control | children, requiredPermissions |DefaultDarkMode
| | Theme toggle component | defaultTheme |Tooltip
| | Information tooltips | content, children |FieldLabel
| | Enhanced form labels | label, required, info |
The library can automatically detect fields from your Amplify schema:
`typescript
// Auto-detect all fields
fields="auto"
/>
// Auto-detect with exclusions
fields="auto"
excludeFields={['internalNotes', 'createdAt']}
/>
// Auto-detect with overrides
fields="auto"
fieldOverrides={{
email: {
type: 'email',
info: 'Valid email address required',
placeholder: 'user@example.com'
},
phone: {
type: 'tel',
info: 'International format recommended',
placeholder: '+1 (555) 123-4567'
}
}}
/>
`
Add custom actions to list pages:
`typescript`
customActions={[
{
label: 'Export CSV',
icon:
onClick: handleExport,
variant: 'primary'
},
{
label: 'Bulk Import',
icon:
onClick: handleImport,
variant: 'secondary'
}
]}
/>
Configure advanced filtering:
`typescript`
filters={[
{
field: 'category',
type: 'select',
label: 'Category',
options: [
{ value: 'electronics', label: 'Electronics' },
{ value: 'clothing', label: 'Clothing' }
]
},
{
field: 'price',
type: 'range',
label: 'Price Range',
min: 0,
max: 1000
},
{
field: 'name',
type: 'text',
label: 'Product Name',
placeholder: 'Search by name...'
}
]}
filterLayout="sidebar" // or "toolbar" or "auto"
/>
The library uses AWS Amplify UI React components and inherits your application's theme:
`typescript
import { ThemeProvider } from '@aws-amplify/ui-react';
import { myCustomTheme } from './theme';
`
The library includes comprehensive tests and supports testing in your application:
`bashRun tests
npm test
$3
`typescript
import { render, screen } from '@testing-library/react';
import { DefaultCreatePage } from 'anton-bakker-amplify-components';test('renders create form', () => {
render(
modelName="Product"
fields={[
{ name: 'name', label: 'Name', type: 'text', required: true }
]}
/>
);
expect(screen.getByLabelText(/Name/)).toBeInTheDocument();
});
`๐ Publishing
For maintainers, the library uses automated publishing with AWS Secrets Manager:
`bash
One-time setup
aws --profile BeyondAmbition secretsmanager create-secret \
--name npm/automation-token/anton-bakker-amplify-components \
--secret-string ''Publish new version
AWS_PROFILE=BeyondAmbition npm run release:publish
`๐ Documentation
- Implementation Guide - Detailed implementation examples
- API Design Decisions - Architecture and design rationale
- Enhancement Proposals - Future roadmap
๐ Changelog
$3
- Enhanced HybridSearchModal with improved filtering
- Updated DefaultListPage with better pagination
- Added comprehensive TypeScript types
- Improved auto-save functionality$3
- BREAKING: Removed console logging from all components
- BREAKING: Error handling now uses alerts instead of thrown exceptions
- BREAKING: Moved aws-amplify to peerDependencies
- Added auto-detection for fields and columns
- Introduced data visualization components
- Enhanced search and filtering capabilities๐ค Contributing
1. Fork the repository
2. Create a feature branch:
git checkout -b feature/amazing-feature
3. Make your changes and add tests
4. Run tests: npm test
5. Commit using conventional commits: git commit -m "feat: add amazing feature"
6. Push to the branch: git push origin feature/amazing-feature
7. Open a Pull Request๐ License
MIT License - see LICENSE file for details.
๐ Support
- Create an issue for bug reports or feature requests
- Check existing documentation in the
/docs folder
- Review test files in /src/__tests__` for usage examples