@arun-s-aot/formsflow-webembed 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +347 -0
  2. package/package.json +79 -0
package/README.md ADDED
@@ -0,0 +1,347 @@
1
+ # Forms Flow AI Web Components
2
+
3
+ > **Hybrid Form Embedding** - Seamlessly embed both authenticated and anonymous forms in your application.
4
+
5
+ ## 📋 Table of Contents
6
+
7
+ - [Overview](#overview)
8
+ - [Installation](#installation)
9
+ - [Required CSS Dependencies](#required-css-dependencies)
10
+ - [Usage Scenarios](#usage-scenarios)
11
+ - [1. Anonymous Forms](#1-anonymous-forms)
12
+ - [2. Authenticated Forms (Internal)](#2-authenticated-forms-internal)
13
+ - [3. Authenticated Forms (External)](#3-authenticated-forms-external)
14
+ - [Custom Components](#custom-components)
15
+ - [API Reference](#api-reference)
16
+ - [Additional Resources](#additional-resources)
17
+
18
+ ## 🎯 Overview
19
+
20
+ Forms Flow AI Web Components provides a powerful hybrid form embedding solution that allows you to integrate both authenticated and anonymous forms seamlessly into your application. Users can submit forms directly from your application without being redirected to external pages.
21
+
22
+ The main component `<formsflow-webembed></formsflow-webembed>` is a flexible web component that adapts to different authentication scenarios and can be easily integrated into any frontend framework.
23
+
24
+ ## 📦 Installation
25
+
26
+ You can integrate the web component using either CDN or NPM:
27
+
28
+ ### CDN Installation
29
+ ```html
30
+ <script src="https://dm3cs41qneo90.cloudfront.net/forms-flow-webcomponent.js"></script>
31
+ ```
32
+
33
+ ### NPM Installation
34
+ ```bash
35
+ npm i formsflow-webembed
36
+ ```
37
+
38
+ ```javascript
39
+ // Import in your component
40
+ import 'formsflow-webembed'
41
+ ```
42
+
43
+ ## 🎨 Required CSS Dependencies
44
+
45
+ Include these stylesheets for proper component styling:
46
+
47
+ ### Bootstrap CSS
48
+ ```html
49
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css">
50
+ ```
51
+ > **Note:** Skip this if your application already uses Bootstrap.
52
+
53
+ ### Form.io CSS (Required)
54
+ ```html
55
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/formiojs@4.13.1/dist/formio.full.min.css">
56
+ ```
57
+
58
+ ## 🚀 Usage Scenarios
59
+
60
+ The component supports three main scenarios based on your authentication requirements:
61
+
62
+ ---
63
+
64
+ ## 1. Anonymous Forms
65
+
66
+ Use this scenario when you want to embed forms that don't require user authentication.
67
+
68
+ ### Implementation
69
+
70
+ ```html
71
+ <formsflow-webembed
72
+ configFile
73
+ anonymousUrl="https://sample.com/form/formio/test-form"
74
+ message="Thank you for your response"
75
+ >
76
+ </formsflow-webembed>
77
+ ```
78
+
79
+ ### Configuration
80
+
81
+ The component accepts three parameters:
82
+
83
+ #### 1. configFile (Object)
84
+
85
+ | Property | Type | Description | Example |
86
+ |----------|------|-------------|---------|
87
+ | `authenticationType` | String | Authentication type | `"anonymous"` |
88
+ | `formioUrl` | String | Form.io URL (must end with `/form`) | `"https://sample.com/formio/form"` |
89
+ | `webApiUrl` | String | API URL | `"https://sample.com/api"` |
90
+
91
+ #### 2. anonymousUrl (String)
92
+
93
+ | Property | Type | Description | Example |
94
+ |----------|------|-------------|---------|
95
+ | `anonymousUrl` | String | The anonymous form URL from Form.io | `"https://sample.com/formio/formname"` |
96
+
97
+ #### 3. message (String)
98
+
99
+ | Property | Type | Description | Example |
100
+ |----------|------|-------------|---------|
101
+ | `message` | String | Success message after form submission | `"Thank you for your response"` |
102
+
103
+ ### JavaScript Configuration
104
+
105
+ ```javascript
106
+ const configFile = {
107
+ authenticationType: "anonymous",
108
+ formioUrl: 'https://sample.com/formio/form',
109
+ webApiUrl: 'https://sample.com/api'
110
+ }
111
+
112
+ document.querySelector('formsflow-webembed')
113
+ .setAttribute('configFile', JSON.stringify(configFile));
114
+ ```
115
+
116
+ ---
117
+
118
+ ## 2. Authenticated Forms (Internal)
119
+
120
+ Use this scenario when your parent application uses Keycloak for authentication.
121
+
122
+ ### Implementation
123
+
124
+ ```html
125
+ <formsflow-webembed
126
+ configFile
127
+ formName="test-form"
128
+ message="Thank you for your response"
129
+ >
130
+ </formsflow-webembed>
131
+ ```
132
+
133
+ ### Configuration
134
+
135
+ #### 1. configFile (Object)
136
+
137
+ | Property | Type | Description | Example |
138
+ |----------|------|-------------|---------|
139
+ | `keycloakUrl` | String | Keycloak server URL | `"https://sample.com/auth"` |
140
+ | `realm` | String | Keycloak realm name | `"sample"` |
141
+ | `clientId` | String | Keycloak client ID | `"tenant-clientId"` |
142
+ | `authenticationType` | String | Authentication type | `"internal"` |
143
+ | `webApiUrl` | String | API URL | `"https://sample.com/api"` |
144
+
145
+ #### 2. formName (String)
146
+
147
+ | Property | Type | Description | Example |
148
+ |----------|------|-------------|---------|
149
+ | `formName` | String | Form pathname | `"testform"` |
150
+
151
+ > **Note:** For multitenancy, use format: `"tenantkey-pathname"`
152
+
153
+ #### 3. message (String)
154
+
155
+ | Property | Type | Description | Example |
156
+ |----------|------|-------------|---------|
157
+ | `message` | String | Success message after form submission | `"Thank you for your response"` |
158
+
159
+ ### JavaScript Configuration
160
+
161
+ ```javascript
162
+ const configFile = {
163
+ keycloakUrl: 'https://sample.com/auth',
164
+ realm: 'test',
165
+ clientId: 'testId',
166
+ authenticationType: 'internal',
167
+ webApiUrl: 'https://sample.com/api'
168
+ };
169
+
170
+ document.querySelector('formsflow-webembed')
171
+ .setAttribute('configFile', JSON.stringify(configFile));
172
+ ```
173
+
174
+ ---
175
+
176
+ ## 3. Authenticated Forms (External)
177
+
178
+ Use this scenario when your parent application does NOT use Keycloak for authentication.
179
+
180
+ ### Implementation
181
+
182
+ ```html
183
+ <formsflow-webembed
184
+ configFile
185
+ formName="test-form"
186
+ token="your-jwt-token-here"
187
+ message="Thank you for your response"
188
+ >
189
+ </formsflow-webembed>
190
+ ```
191
+
192
+ ### Configuration
193
+
194
+ #### 1. configFile (Object)
195
+
196
+ | Property | Type | Description | Example |
197
+ |----------|------|-------------|---------|
198
+ | `authenticationType` | String | Authentication type | `"external"` |
199
+ | `webApiUrl` | String | API URL | `"https://sample.com/api"` |
200
+
201
+ #### 2. formName (String)
202
+
203
+ | Property | Type | Description | Example |
204
+ |----------|------|-------------|---------|
205
+ | `formName` | String | Form pathname | `"testform"` |
206
+
207
+ > **Note:** For multitenancy, use format: `"tenantkey-pathname"`
208
+
209
+ #### 3. token (String)
210
+
211
+ | Property | Type | Description | Example |
212
+ |----------|------|-------------|---------|
213
+ | `token` | String | JWT token created using Forms Flow shared secret | `"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."` |
214
+
215
+ #### Token Payload Requirements
216
+
217
+ **Standard Case:**
218
+ ```json
219
+ {
220
+ "preferred_username": "sample",
221
+ "email": "sample@gmail.com"
222
+ }
223
+ ```
224
+
225
+ **Multitenancy Case:**
226
+ ```json
227
+ {
228
+ "preferred_username": "sample",
229
+ "email": "sample@gmail.com",
230
+ "tenantKey": "tenant1"
231
+ }
232
+ ```
233
+
234
+ #### 4. message (String)
235
+
236
+ | Property | Type | Description | Example |
237
+ |----------|------|-------------|---------|
238
+ | `message` | String | Success message after form submission | `"Thank you for your response"` |
239
+
240
+ ### JavaScript Configuration
241
+
242
+ ```javascript
243
+ const configFile = {
244
+ authenticationType: 'external',
245
+ webApiUrl: 'https://sample.com/api'
246
+ };
247
+
248
+ document.querySelector('formsflow-webembed')
249
+ .setAttribute('configFile', JSON.stringify(configFile));
250
+ ```
251
+
252
+ ---
253
+
254
+ ## 🔧 Custom Components
255
+
256
+ To add custom components to your form embedding solution:
257
+
258
+ ### Step 1: Clone the Repository
259
+
260
+ ```bash
261
+ git clone https://github.com/AOT-Technologies/forms-flow-ai-web-components.git
262
+ cd forms-flow-ai-web-components
263
+ ```
264
+
265
+ ### Step 2: Install Dependencies
266
+
267
+ ```bash
268
+ npm install
269
+ ```
270
+
271
+ > **Optional:** Remove default Forms Flow custom components if not needed:
272
+ > ```bash
273
+ > npm uninstall formsflow-formio-custom-elements
274
+ > ```
275
+
276
+ ### Step 3: Install Your Custom Component Package
277
+
278
+ ```bash
279
+ npm install your-custom-component-package
280
+ ```
281
+
282
+ ### Step 4: Import Custom Component
283
+
284
+ ```javascript
285
+ import yourCustomComponent from 'your-custom-component-package';
286
+ ```
287
+
288
+ ### Step 5: Register with Form.io
289
+
290
+ ```javascript
291
+ import { Formio } from 'formiojs';
292
+
293
+ Formio.use(yourCustomComponent);
294
+ ```
295
+
296
+ ### Step 6: Build and Deploy
297
+
298
+ ```bash
299
+ # Create production build
300
+ npm run build
301
+
302
+ # The build files will be in the /build directory
303
+ # Host these files as a CDN for form embedding
304
+ ```
305
+
306
+ ---
307
+
308
+ ## 📚 API Reference
309
+
310
+ ### Component Properties
311
+
312
+ | Property | Required | Type | Scenarios | Description |
313
+ |----------|----------|------|-----------|-------------|
314
+ | `configFile` | ✅ | Object | All | Configuration object (as JSON string) |
315
+ | `anonymousUrl` | ✅ | String | Anonymous only | Form.io anonymous form URL |
316
+ | `formName` | ✅ | String | Internal, External | Form pathname |
317
+ | `token` | ✅ | String | External only | JWT authentication token |
318
+ | `message` | ✅ | String | All | Success message after submission |
319
+
320
+ ### Authentication Types
321
+
322
+ | Type | Description | Use Case |
323
+ |------|-------------|----------|
324
+ | `anonymous` | No authentication required | Public forms |
325
+ | `internal` | Keycloak authentication | Applications using Keycloak |
326
+ | `external` | Custom JWT authentication | Applications with custom auth |
327
+
328
+ ---
329
+
330
+ ## 🔗 Additional Resources
331
+
332
+ - **GitHub Repository:** [forms-flow-ai-web-components](https://github.com/AOT-Technologies/forms-flow-ai-web-components)
333
+ - **CDN Distribution:** https://dm3cs41qneo90.cloudfront.net/
334
+ - **Form.io Documentation:** [formio.github.io](https://formio.github.io/)
335
+
336
+ ---
337
+
338
+ ## 📝 Notes
339
+
340
+ - Ensure all URLs are properly configured for your environment
341
+ - Convert configuration objects to JSON strings when setting attributes
342
+ - For multitenancy support, include tenant keys in form names and tokens
343
+ - Test authentication flows in development before deploying to production
344
+
345
+ ---
346
+
347
+ **Need help?** Check out our [GitHub repository](https://github.com/AOT-Technologies/forms-flow-ai-web-components) for more examples and community support.
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "@arun-s-aot/formsflow-webembed",
3
+ "version": "1.0.0",
4
+ "private": false,
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "files": [
9
+ "dist/forms-flow-webcomponent.js",
10
+ "dist/forms-flow-webcomponent.js.gz",
11
+ "dist/forms-flow-webcomponent.js.LICENSE.txt",
12
+ "README.md",
13
+ "LICENSE"
14
+ ],
15
+ "main": "dist/forms-flow-webcomponent.js",
16
+ "dependencies": {
17
+ "@aot-technologies/formio-react": "^1.0.5",
18
+ "axios": "^1.11.0",
19
+ "@aot-technologies/formsflow-formio-custom-elements": "^1.0.2",
20
+ "keycloak-js": "^26.1.2",
21
+ "react": "^18.1.0",
22
+ "react-dom": "^18.1.0",
23
+ "react-scripts": "5.0.1",
24
+ "react-to-webcomponent": "^1.5.1",
25
+ "web-vitals": "^5.1.0"
26
+ },
27
+ "scripts": {
28
+ "start": "react-scripts start",
29
+ "build": "npm run build:react && npm run build:bundle && npm run copy:license",
30
+ "build:bundle": "webpack --config webpack.config.js",
31
+ "build:react": "react-scripts build",
32
+ "copy:license": "cp LICENSE dist/ 2>/dev/null || echo 'LICENSE file not found'",
33
+ "test": "react-scripts test",
34
+ "eject": "react-scripts eject"
35
+ },
36
+ "eslintConfig": {
37
+ "extends": [
38
+ "react-app",
39
+ "react-app/jest"
40
+ ]
41
+ },
42
+ "browserslist": {
43
+ "production": [
44
+ ">0.2%",
45
+ "not dead",
46
+ "not op_mini all"
47
+ ],
48
+ "development": [
49
+ "last 1 chrome version",
50
+ "last 1 firefox version",
51
+ "last 1 safari version"
52
+ ]
53
+ },
54
+ "devDependencies": {
55
+ "@babel/core": "^7.26.0",
56
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
57
+ "@babel/preset-env": "^7.26.0",
58
+ "@babel/preset-react": "^7.26.0",
59
+ "@testing-library/jest-dom": "^6.6.3",
60
+ "@testing-library/react": "^16.2.0",
61
+ "@testing-library/user-event": "^14.6.1",
62
+ "babel-loader": "^9.2.1",
63
+ "compression-webpack-plugin": "^11.1.0",
64
+ "html-webpack-plugin": "^5.6.3",
65
+ "parcel": "^2.13.3",
66
+ "path": "^0.12.7",
67
+ "webpack": "^5.95.0",
68
+ "webpack-bundle-analyzer": "^4.10.2",
69
+ "webpack-cli": "^5.1.4",
70
+ "webpack-dev-server": "^5.2.2"
71
+ },
72
+ "description": "Hybrid form embedding",
73
+ "repository": {
74
+ "type": "git",
75
+ "url": "https://github.com/abilpraju-aot/forms-flow-ai-web-components.git"
76
+ },
77
+ "author": "Abil P Raju",
78
+ "license": "MIT"
79
+ }