diff --git a/README.md b/README.md index 22c205ab..692d2a75 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,8 @@ For quick prototyping or simple projects, you can use a CDN: ``` +This exposes the `window.FormeoEditor` and `window.FormeoRenderer` globals. For production, pin a version (e.g. `formeo@5.13.1`) instead of `@latest` and add an `integrity` hash with `crossorigin="anonymous"` — see [Installation](docs/renderer/renderer.md#installation) in the renderer docs. + ## Usage ### Basic Setup @@ -171,7 +173,7 @@ editor.whenReady().then(() => { Formeo can be integrated with popular frontend frameworks: - **[React Integration Guide](https://github.com/Draggable/formeo/blob/main/docs/react-integration.md)** - Custom hooks, functional components, and Context API patterns -- **[Angular Integration Guide](https://github.com/Draggable/formeo/blob/main/docs/angular-integration.md)** - Services, components, and standalone patterns +- **[Angular Integration Guide](https://github.com/Draggable/formeo/blob/main/docs/angular-integration.md)** - A standalone component, SSR-safe setup, and reading submitted answers ## Theming @@ -214,6 +216,7 @@ Comprehensive documentation is available in the [docs](https://github.com/Dragga - **[Actions](https://github.com/Draggable/formeo/blob/main/docs/options/actions/README.md)** - Action handlers - **[Editor API](https://github.com/Draggable/formeo/blob/main/docs/editor/README.md)** - Editor methods and properties - **[TypeScript](https://github.com/Draggable/formeo/blob/main/docs/typescript.md)** - Shipped type definitions and typed events +- **[Using a CSS Framework](https://github.com/Draggable/formeo/blob/main/docs/css-frameworks.md)** - Style rendered forms with Bootstrap or any framework - **[Build Tools](https://github.com/Draggable/formeo/blob/main/docs/tools/README.md)** - Development and build utilities ## Development diff --git a/docs/README.md b/docs/README.md index 338330f9..198f0c7e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -124,4 +124,12 @@ Remove the rendered form from the page and stop its pagination (the page navigat Type definitions ship with the package; this page lists what is typed and how to narrow the before-hook details. +## [Using a CSS Framework](css-frameworks.md) + +The rendered markup and its classes, adding framework classes with `className`, and editor theming. + +## [Migrating from formBuilder](migrating-from-formbuilder.md) + +Batch-converting formBuilder form exports to Formeo's `formData` shape with `formBuilder2Formeo`. + ## [Build Tools](tools/) diff --git a/docs/angular-integration-example/README.md b/docs/angular-integration-example/README.md deleted file mode 100644 index 23fe94aa..00000000 --- a/docs/angular-integration-example/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Angular + Formeo Integration Example - -This directory holds only this README — there is no runnable Angular project here. - -The code samples referenced below (a standalone component, an injectable service, and module/config -wiring) live inline in `src/demo/js/frameworks/angular.js`, which the demo's "Angular" tab displays and -syntax-highlights. That file also explains why the demo simulates Angular patterns instead of loading -the real framework. - -For the full picture — the reasoning behind the simulation, and how to build a real Angular project -against Formeo — see [`docs/angular-integration.md`](../angular-integration.md). diff --git a/docs/angular-integration.md b/docs/angular-integration.md index 5357f898..e0b4c4b7 100644 --- a/docs/angular-integration.md +++ b/docs/angular-integration.md @@ -1,145 +1,147 @@ -# Angular + Formeo Integration Guide +# Angular + Formeo Integration -## Why the Demo Doesn't Load Real Angular v20 +A standalone Angular component that builds a form with `FormeoEditor`, previews it with `FormeoRenderer`, and +cleans up both on destroy. Verified against `formeo` 5.13.1; Angular 17+ syntax (standalone components, +`afterNextRender`). -The current Angular demo in `src/demo/js/frameworks/angular.js` simulates Angular patterns rather than loading the actual Angular framework for several technical reasons: - -### Technical Limitations - -1. **Dynamic ES Module Loading Complexity** - - Angular v20 requires complex module resolution - - Dependencies between @angular/core, @angular/common, @angular/platform-browser - - Browser ES module loading limitations - -2. **Bundle Size Impact** - - Angular v20 with dependencies is ~200KB+ minified - - Would significantly slow down demo loading - - Not suitable for quick demonstrations - -3. **Build Tool Requirements** - - Angular typically requires compilation (TypeScript → JavaScript) - - Template compilation and bundling - - Zone.js and other runtime dependencies - -4. **Runtime Environment Mismatch** - - Demo runs in vanilla browser environment - - Angular expects Node.js tooling ecosystem - -## Recommended Alternatives - -### Option 1: Complete Angular Project Example (Recommended) - -Create a separate Angular project that demonstrates real integration: +## Install ```bash -# Create new Angular project -ng new formeo-angular-example --routing --style=scss -cd formeo-angular-example - -# Install Formeo npm install formeo - -# Run development server -ng serve ``` -**Benefits:** -- Real Angular v20 environment -- Proper TypeScript support -- Full Angular CLI tooling -- Production-ready patterns - -### Option 2: Improved CDN Loading (Experimental) - -Update the demo to use Angular's standalone CDN bundles: - -```javascript -// Load Angular via CDN (Angular v20 standalone) -async function loadAngularFromCDN() { - const scripts = [ - 'https://unpkg.com/@angular/core@20/bundles/core.umd.js', - 'https://unpkg.com/@angular/common@20/bundles/common.umd.js', - 'https://unpkg.com/@angular/platform-browser@20/bundles/platform-browser.umd.js' - ]; - - for (const src of scripts) { - await loadScript(src); +Add the stylesheet in `angular.json`: + +```json +{ + "projects": { + "my-app": { + "architect": { + "build": { + "options": { + "styles": ["node_modules/formeo/dist/formeo.min.css", "src/styles.scss"] + } + } + } + } } } ``` -**Limitations:** -- Still complex dependency management -- Large download size -- Limited TypeScript support -- Not recommended for production +(Or `@import 'formeo/dist/formeo.min.css';` from a global stylesheet instead, if you'd rather not touch +`angular.json`.) -### Option 3: Web Components Approach - -Use Angular Elements to create a web component: +## The component ```typescript -// Create Angular Element -import { createCustomElement } from '@angular/elements'; -import { FormBuilderComponent } from './form-builder.component'; +import { Component, ElementRef, OnDestroy, ViewChild, afterNextRender } from '@angular/core' +import { FormeoEditor, FormeoRenderer } from 'formeo' + +@Component({ + selector: 'app-form-builder', + standalone: true, + template: ` +
+ + + `, +}) +export class FormBuilderComponent implements OnDestroy { + @ViewChild('editorRef', { static: true }) editorRef!: ElementRef