GitHub - dev-ignis/forge

@nexcraft/forge

npm version Bundle Size Test Coverage WCAG 2.1 AA AI-Native Performance Monitored Figma Tokens MIT License

"Write Once, Use Forever" - A future-proof UI component library built on web standards that will outlive framework trends.

The FIRST AI-Native component library with built-in AI metadata, design token bridge, and real-time performance dashboard. Every component can explain its state to AI systems, monitor its own performance, and integrate seamlessly with AI coding tools like Cursor, GitHub Copilot, and Claude. Import design tokens from any system (Figma, Tailwind, Material Design) with zero configuration - built for the age of AI-assisted development.

๐Ÿค– FOR AI ASSISTANTS & LLMs

AI Context: @nexcraft/forge is an AI-native web component library with 26+ components and React/Vue/Angular integrations.

Quick AI Reference:

  • ๐Ÿ“ฆ React: import { ForgeButton, ForgeInput } from '@nexcraft/forge-react'
  • ๐ŸŒฒ Selective: import { ForgeButton } from '@nexcraft/forge/button'
  • ๐ŸŽจ Tailwind: import forgePlugin from '@nexcraft/forge/plugin'
  • ๐Ÿ“ Forms: import { RHFForgeInput } from '@nexcraft/forge-rhf'

๐Ÿ“š AI Documentation:

๐Ÿค– AI Manifest Files - Machine-Readable Component Metadata

Forge provides comprehensive, machine-readable metadata files that AI assistants and build tools can consume programmatically:

๐Ÿ“‹ Available Files

1. ai-index.json - Fast component discovery (465 lines)

  • Quick component lookup by tag/description
  • Framework usage examples (React, Vue, Angular, vanilla)
  • Component metrics (props count, events, slots, a11y)
  • Navigation to detailed resources

2. ai-manifest.json - Complete API reference (2000+ lines)

  • Full component metadata (props, events, slots with types)
  • Accessibility details (ARIA, keyboard nav, screen reader behavior)
  • AI method documentation (getPossibleActions, explainState, aiState)
  • SSR fallback HTML templates
  • Framework-specific examples

3. ai-manifest.schema.json - Schema validation

  • JSON Schema for validating manifest structure
  • Use in CI/CD pipelines to ensure quality

๐Ÿ’ป Programmatic Access

// Import manifest files directly from the package
import aiIndex from '@nexcraft/forge/ai-index.json';
import aiManifest from '@nexcraft/forge/ai-manifest.json';

// Quick discovery: Find components by capability
const selectComponents = aiIndex.components.filter(c =>
  c.tag.includes('select')
);
// [{ tag: 'forge-select', props: 39, ... },
//  { tag: 'forge-multi-select', props: 32, ... }]

// Detailed API: Get full component metadata
const buttonMeta = aiManifest.components.find(c =>
  c.tag === 'forge-button'
);
console.log(buttonMeta.props);     // All props with types
console.log(buttonMeta.a11y);      // Accessibility requirements
console.log(buttonMeta.aiMethods); // AI integration methods

๐Ÿค– AI Agent Usage Examples

AI assistants use these files to provide accurate code generation:

Scenario 1: Component Discovery

User: "I need a component for notifications"
AI: [Reads ai-index.json] โ†’ Finds forge-toast and forge-alert
AI: "Use forge-toast for temporary notifications or forge-alert for persistent messages"

Scenario 2: Code Generation

User: "Create a primary button that's disabled"
AI: [Reads ai-manifest.json] โ†’ Gets forge-button props
AI: Generates: <forge-button variant="primary" disabled>Submit</forge-button>

Scenario 3: Accessibility Verification

User: "Is my table accessible?"
AI: [Reads ai-manifest.json] โ†’ Checks forge-data-table a11y requirements
AI: "Add aria-label: <forge-data-table aria-label='User accounts'>..."

๐Ÿ› ๏ธ Build Tool Integration

// Use in build scripts, documentation generators, or testing tools
import { components } from '@nexcraft/forge/ai-index.json';

// Generate component documentation
components.forEach(comp => {
  generateDocs(comp.tag, comp.description, comp.examples);
});

// Validate component usage
function validateComponent(tagName, props) {
  const manifest = getComponentFromManifest(tagName);
  const validProps = manifest.props.map(p => p.name);
  const invalidProps = Object.keys(props).filter(p => !validProps.includes(p));
  if (invalidProps.length) {
    throw new Error(`Invalid props: ${invalidProps.join(', ')}`);
  }
}

๐Ÿ“– Learn More

๐ŸŽฏ Why Choose @nexcraft/forge?

โœจ What Makes @nexcraft/forge Special:

// @nexcraft/forge: Intelligent Components Built for the AI Era
const button = document.querySelector('forge-button');

// ๐Ÿค– AI Integration Built-In
button.explainState()  // "Button is primary variant, enabled, ready for interaction"
button.getPossibleActions()  // [{name: 'click', available: true, description: '...'}]
button.aiState  // {variant: 'primary', disabled: false, renderTime: 0.8ms}

// ๐ŸŽจ Design System Integration (Industry First!)
import { TokenBridge } from '@nexcraft/forge/utils';
const bridge = TokenBridge.fromFigma(figmaTokens);  // Import from ANY design system!
const css = bridge.toCSSProperties();  // Automatic CSS generation
// Works with Figma, Tailwind, Material Design, and more!

// โšก Performance Self-Monitoring
button.setAttribute('max-render-ms', '2');  // Auto-optimizes if slow!
button.performanceMode = 'auto';  // Degrades gracefully on slow devices

// ๐ŸŽจ True Style Isolation (Shadow DOM)
// Your styles NEVER conflict, GUARANTEED

๐Ÿ’ก Real-World Benefits:

  • AI Apps: Components provide context to LLMs automatically
  • Design Systems: Import tokens from Figma, Tailwind, Material Design automatically
  • Performance: Self-optimizing components that never slow down
  • Migration: Move from React to Vue to Angular without changing components
  • Micro-frontends: Multiple versions coexist without conflicts
  • Future-proof: Built on web standards, not framework trends

๐Ÿš€ Quick Start (30 Seconds!)

Option 1: Zero-Config CDN (Instant!)

<!-- Just add and use - no build required -->
<script type="module" src="https://cdn.jsdelivr.net/npm/@nexcraft/forge"></script>

<!-- Your AI-ready component with performance monitoring! -->
<forge-button 
  variant="primary" 
  ai-context="submit-form"
  max-render-ms="2">
  Click Me
</forge-button>

Option 2: NPM Installation

npm install @nexcraft/forge

Works with EVERY Framework (Same Code!)

// Import once, use everywhere
import '@nexcraft/forge';

// React Example
function App() {
  const button = useRef();
  
  useEffect(() => {
    // Access AI features!
    console.log(button.current.explainState());
  }, []);
  
  return <forge-button ref={button} onClick={handleClick}>Click</forge-button>
}

// Vue Example (with dedicated package)
npm install @nexcraft/forge-vue
<template>
  <forge-button @click="handleClick" :ai-context="context">Click</forge-button>
</template>

// Angular Example (with dedicated package)
npm install @nexcraft/forge-angular
// In Angular templates
<forge-button forgeComponent (click)="handleClick()" [aiContext]="context">Click</forge-button>

// Vanilla JS - Full Power!
const btn = document.querySelector('forge-button');
console.log(btn.getPossibleActions()); // AI-ready!

Development Setup

# Clone and setup
git clone https://github.com/nexcraft/forge.git
cd forge
npm install

# Start development
npm run dev        # Component development
npm run storybook  # Interactive documentation
npm run test       # Run tests

๐Ÿ“ฆ Framework Packages

Core Package

  • @nexcraft/forge - Pure web components (truly framework-agnostic)

Optional Framework Extensions

  • @nexcraft/forge-react - React wrappers, hooks & SSR support
  • @nexcraft/forge-vue - Vue composables, directives & plugin
  • @nexcraft/forge-angular - Angular directives, services & reactive forms
  • @nexcraft/forge-rhf - React Hook Form adapters
# Install what you need
npm install @nexcraft/forge                    # Pure web components
npm install @nexcraft/forge-react             # + React integration
npm install @nexcraft/forge-vue               # + Vue composables & plugin
npm install @nexcraft/forge-angular           # + Angular integration  
npm install @nexcraft/forge-rhf               # + React Hook Form

๐Ÿ“– View Integration Guides โ†’ โ€” React: docs/integrations/react.md โ€ข Angular: docs/integrations/angular.md โ€ข Vue: docs/integrations/vue.md

๐Ÿ“‹ Component Index

Quick reference to all 26 components with HTML tag names:

Organisms (6 components)

<forge-tabs> โ€ข <forge-pagination> โ€ข <forge-navigation-bar> โ€ข <forge-data-table> โ€ข <forge-accordion> โ€ข <forge-tree-view>

Molecules (8 components)

<forge-tooltip> โ€ข <forge-date-picker> โ€ข <forge-dropdown> โ€ข <forge-form-field> โ€ข <forge-modal> โ€ข <forge-multi-select> โ€ข <forge-card> โ€ข <forge-toast>

Atoms (12 components)

<forge-button> โ€ข <forge-input> โ€ข <forge-icon> โ€ข <forge-alert> โ€ข <forge-checkbox> โ€ข <forge-badge> โ€ข <forge-switch> โ€ข <forge-radio-group> โ€ข <forge-select> โ€ข <forge-progress> โ€ข <forge-skeleton> โ€ข <forge-aspect-ratio>

Plus supporting components: <forge-progress-circle> โ€ข <forge-toast-container> โ€ข <forge-performance-dashboard>

๐Ÿ’ก Can't find what you're looking for? Try searching for keywords like "progress", "toast", "skeleton" in the Component Showcase section below.

๐Ÿ“š Documentation

Getting Started

Core Features

Architecture & Planning

โœจ The "Shiny" Stuff - What Makes Us Special

๐Ÿค– AI-Native Components (Industry First!)

The FIRST component library built for AI agents - every component can communicate with AI systems out of the box:

const button = document.querySelector('forge-button');

// Ask component to explain itself
console.log(button.explainState());
// "Button is enabled and primary variant. Not loading. Ready for click interaction."

// Get possible actions for AI agents
console.log(button.getPossibleActions());
// [{ name: 'click', description: 'Trigger button action', available: true }]

// Access real-time state for AI context
console.log(button.aiState);
// { variant: 'primary', disabled: false, loading: false, renderTime: 0.8ms }

๐ŸŽจ Design Token Bridge (Industry First!)

Import design tokens from ANY design system with zero configuration:

import { TokenBridge } from '@nexcraft/forge/utils';

// Import from Figma, Tailwind, Material Design, or any design system
const bridge = TokenBridge.fromFigma(figmaTokens);
const css = bridge.toCSSProperties();

// Automatic CSS generation - always in sync with your design system!
// :root { --forge-brand-primary-500: #3b82f6; }

โšก Performance Dashboard (Unique Feature!)

Real-time performance monitoring with visual dashboard:

<!-- Instant performance dashboard - no setup required -->
<forge-performance-dashboard auto-refresh="true" show-violations="true">
</forge-performance-dashboard>

<!-- Components auto-monitor their performance -->
<forge-tooltip max-render-ms="2" performance-mode="auto">
  Self-optimizing tooltip with real-time metrics!
</forge-tooltip>
// Programmatic access to performance data
import { performanceDashboard } from '@nexcraft/forge/utils';

const metrics = performanceDashboard.getAllMetrics();
const slowComponents = performanceDashboard.getSlowComponents(16);
// Real-time performance insights for every component!

๐ŸŽฏ Core Differentiators

Feature Description Benefits
๐Ÿค– AI-Native Metadata First library built for AI agents Components communicate with Cursor, Copilot, Claude automatically
๐Ÿง  AI Code Generation Context-aware component suggestions Faster development with AI-powered assistance
๐ŸŽจ Design Token Bridge Import from any design system Zero-config integration with Figma, Tailwind, Material Design
โšก Performance Dashboard Real-time visual monitoring + auto-degradation Self-optimizing components with performance insights
๐ŸŒ Framework Independence True Web Components Use with React, Vue, Angular, or vanilla JS
๐Ÿ›ก๏ธ Style Isolation Shadow DOM guaranteed Complete style encapsulation, zero CSS conflicts
๐Ÿ“ฆ Optimized Bundle <10KB per component Lightweight, tree-shakeable, production-ready
๐Ÿ”ฎ Future Proof Built on web standards Will work in browsers for decades to come

๐Ÿš€ Zero-Config Magic

<!-- Works instantly - no build, no config, no dependencies -->
<script type="module" src="https://cdn.jsdelivr.net/npm/@nexcraft/forge"></script>
<forge-button variant="primary" ai-context="submit-form">
  Click Me
</forge-button>

๐Ÿ—๏ธ Architecture

Core Technologies

Key Principles

  1. Web Standards First - Built on Custom Elements, Shadow DOM, and CSS Custom Properties
  2. True Encapsulation - Shadow DOM ensures style isolation
  3. Properties Down, Events Up - Unidirectional data flow
  4. Composition Over Configuration - Small, focused, composable components

๐Ÿ“ฆ Components Showcase

๐Ÿ›๏ธ Organism Components (Phase 3 - Production Ready!)

Complex, full-featured components built from atoms and molecules:

Component AI Features Performance Features Unique Capabilities Documentation
๐Ÿ“ Tabs Tab prediction Lazy panel loading Drag-to-reorder, closeable tabs, keyboard nav ๐Ÿ“š Docs
๐Ÿ”ข Pagination Page suggestion Optimized renders Multiple modes, customizable sizes ๐Ÿ“š Docs
๐Ÿฆญ Navigation Bar Smart menus Responsive modes Mobile drawer, user actions, search ๐Ÿ“š Docs
๐Ÿ“Š Data Table Sort prediction Virtual scrolling Multi-sort, selection, expandable rows ๐Ÿ“š Docs
๐Ÿ—๏ธ Data Grid Cell editing AI Advanced virtual scrolling Inline editing, export, multi-column sort, filtering ๐Ÿ“š Docs
๐ŸŽต Accordion Panel management Lazy content Multi-expand, animations, icons ๐Ÿ“š Docs
๐ŸŒณ Tree View Node navigation Lazy loading Drag-drop, checkboxes, search ๐Ÿ“š Docs

๐ŸŒŸ Molecule Components (Advanced & Feature-Rich)

Advanced components that combine atoms:

Component AI Features Performance Features Unique Capabilities Documentation
๐ŸŽฏ Tooltip Self-positioning AI <1ms render Smart viewport detection, auto-repositioning ๐Ÿ“š Docs
๐Ÿ“… DatePicker Date prediction Lazy calendar i18n support, range selection, constraints ๐Ÿ“š Docs
๐Ÿ”ฝ Dropdown Action suggestions Virtual scrolling Nested menus, keyboard nav, groups ๐Ÿ“š Docs
๐Ÿ“ FormField Validation AI Input optimization Floating labels, inline variants ๐Ÿ“š Docs
๐ŸŽญ Modal Focus management Stacking optimization Focus trap, backdrop blur, size variants ๐Ÿ“š Docs
๐Ÿ—‚๏ธ MultiSelect Smart filtering Bulk operations Tag display, search highlighting ๐Ÿ“š Docs
๐Ÿƒ Card Content analysis Elevation shadows 6 levels, media support, skeleton states ๐Ÿ“š Docs
๐Ÿ†• ๐Ÿ”” Toast State analysis Queue management Auto-dismiss, progress bars, global helpers ๐Ÿ“š Docs

โš™๏ธ Atomic Components (Foundation + Essential)

Foundation components with comprehensive test coverage:

Component Test Coverage Key Features Documentation
Button 92.38% 5 variants, ripple effect, loading states ๐Ÿ“š Docs
Input 84.56% 7 types, validation, clearable ๐Ÿ“š Docs
Icon 78.38% Registry system, lazy loading ๐Ÿ“š Docs
Alert 97.02% Auto-dismiss, animations ๐Ÿ“š Docs
Checkbox 98.50% Indeterminate state ๐Ÿ“š Docs
Badge 100% Count/dot modes, positions ๐Ÿ“š Docs
Switch 98.50% Loading state, custom labels ๐Ÿ“š Docs
RadioGroup 93.79% Group management, keyboard nav ๐Ÿ“š Docs
Select 84.69% Search/filter, groups ๐Ÿ“š Docs
๐Ÿ†• Progress 100% Linear & circular variants, indeterminate states ๐Ÿ“š Docs
๐Ÿ†• Skeleton 100% Shimmer animations, shape variants, accessibility ๐Ÿ“š Docs
๐Ÿ†• AspectRatio 100% Responsive containers, preset ratios, constraints ๐Ÿ“š Docs

๐Ÿ“Š Component Stats

  • Total Components: 27 production-ready (12 atoms + 8 molecules + 7 organisms)
  • Overall Test Coverage: 87.2%
  • Total Tests: 1140+ passing (99% pass rate)
  • Performance: All components <2ms render
  • Accessibility: 100% WCAG 2.1 AA compliant
  • AI Coverage: 100% metadata implementation
  • ADR Compliance: 100% compliant with all 16 ADRs
  • ๐ŸŽฏ Phase 7 Complete: Essential modern UI components for any application!

Roadmap

See our Implementation Roadmap for the complete component timeline.

๐Ÿงช Testing

# Unit tests
npm run test

# E2E tests
npm run test:e2e

# Visual regression
npm run test:visual

# All tests
npm run test:all

Our comprehensive testing strategy includes:

  • โœ… Unit tests (90%+ coverage)
  • โœ… Visual regression (Chromatic)
  • โœ… Cross-framework E2E tests
  • โœ… Accessibility audits
  • โœ… Performance benchmarks

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guide for details.

Quick Commands

# Generate a new component
npm run generate:component MyComponent atoms

# Run linting
npm run lint

# Run type checking
npm run type-check

# Run all tests
npm run test:all

๐Ÿ“Š Performance & Quality Metrics

๐Ÿ† Phase 8 Started - Enterprise Data Grid Delivered!

Metric Target Current Status
ForgeDataGrid Implementation Full-featured โœ… Complete ๐ŸŽ‰ NEW!
Virtual Scrolling Architecture 10,000+ rows โœ… Implemented ๐Ÿš€ ACHIEVED
Advanced Data Management Editing, Export, Filtering โœ… Complete ๐Ÿ’ช DELIVERED
AI Metadata Coverage 100% 100% โœ… MAINTAINED
Performance Monitoring Built-in Fully Implemented โœ… MAINTAINED
Total Tests 1000+ 1140+ passing ๐Ÿ†™ IMPROVED
Component Count 26 โ†’ 27 27 components ๐Ÿ“ˆ EXPANDED

๐Ÿ† Phase 7 Complete - Essential Components Foundation!

Metric Target Current Status
Atom Components 12 essential 12/12 โœ… COMPLETED
Molecule Components 8 advanced 8/8 โœ… COMPLETED
Organism Components 6 planned 7/7 ๐Ÿ†™ EXCEEDED
Test Coverage >85% 87.2% โœ… ACHIEVED
Bundle Size (per component) <10KB <10KB โœ… ACHIEVED
Component Render <2ms <1ms โœ… EXCEEDED
Accessibility WCAG 2.1 AA 100% Compliant โœ… ACHIEVED
ADR Compliance Full 100% Compliant โœ… ACHIEVED

๐Ÿš€ Why This Matters

  • ๐Ÿ—๏ธ Enterprise Data Grid: ForgeDataGrid handles 10,000+ rows with virtual scrolling
  • โšก Advanced Features: Inline editing, multi-column sorting, export, filtering
  • 87.2% Test Coverage: Your components won't break in production
  • <1ms Render Time: Faster than the human eye can perceive
  • 100% AI Coverage: Every component can talk to ChatGPT, Claude, Copilot
  • 1140+ Tests: More comprehensive testing than enterprise libraries
  • 27 Production Components: 12 atoms, 8 molecules, 7 organisms - enterprise-ready toolkit
  • ๐Ÿ† Phase 8 Started: Advanced data management components for complex applications

๐Ÿ“„ License

MIT ยฉ Nexcraft Team

๐Ÿ”— Links

๐Ÿ’ก Philosophy & Vision

"Write Once, Use Forever"

In 2034, React might be legacy, Vue could be vintage, and Angular may be ancient. But your @nexcraft/forge components? They'll still be running perfectly.

๐ŸŽญ The Problem We Solve

Every 3-5 years, teams rewrite their UI components for the latest framework. It's a $100B industry problem.

๐Ÿ›ก๏ธ Our Solution

Build on web standards that browsers will support forever. Add AI intelligence and performance monitoring that no other library offers.

๐Ÿ“ˆ The Business Case

// Traditional Approach (2019-2034)
Year 2019: Build components in React 16      // Cost: $500K
Year 2022: Migrate to React 18                // Cost: $200K  
Year 2025: Rewrite for React Server Components // Cost: $400K
Year 2028: Migrate to NewFramework.js         // Cost: $500K
Year 2031: Rewrite again...                   // Cost: $500K
// Total: $2.1M + maintenance

// @nexcraft/forge Approach
Year 2024: Build components once              // Cost: $500K
Year 2034: Still working perfectly            // Cost: $0
// Total: $500K + minimal maintenance

// ROI: 320% cost savings + no technical debt

๐Ÿš€ Join the Revolution

Stop rewriting. Start building components that outlive frameworks.