@piserve-tech/octa-form-submission-webcomponent 1.0.26 → 1.0.27
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.
- package/README.md +131 -14
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -1,27 +1,144 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 🧩 Octa Form Submission Web Component
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The **Octa Form Submission Web Component** is a fully framework-independent, reusable UI component that enables developers to dynamically create, edit, and manage forms. It can be used seamlessly in **Angular**, **React**, **Vue**, or **pure HTML/JavaScript** environments.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
---
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## 🚀 Installation
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
### Step 1: Install the package
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
```bash
|
|
12
|
+
npm i @piserve-tech/octa-form-submission-webcomponent
|
|
13
|
+
```
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
---
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
## ⚙️ Setup Guide
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
### Step 2: Copy Required Assets
|
|
18
20
|
|
|
19
|
-
Run
|
|
21
|
+
Run the following command to copy the assets (bundle.js and bundle.css) into your project’s `assets` folder.
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
```bash
|
|
24
|
+
node .\node_modules\@piserve-tech\octa-form-submission-webcomponent\copy-assets.js
|
|
25
|
+
```
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
This script will copy files into:
|
|
28
|
+
```
|
|
29
|
+
/src/assets/octa-form-submission-webcomponent/
|
|
30
|
+
```
|
|
24
31
|
|
|
25
|
-
|
|
32
|
+
---
|
|
26
33
|
|
|
27
|
-
|
|
34
|
+
### Step 3: Add Component in HTML
|
|
35
|
+
|
|
36
|
+
Use the web component directly in your HTML file or within any framework template:
|
|
37
|
+
|
|
38
|
+
```html
|
|
39
|
+
<octa-form-submission-webcomponent
|
|
40
|
+
formData='{"apiurl":"http://192.168.2.189:8080","modulename":"b673ddd3-066e-4261-aa32-41ccfe6e1864","headers":{"contentType":"application/json","auth-user":"John","acceptedLanguage":"en"},"skipMargin":false}'
|
|
41
|
+
submissionid="4a76519a-78aa-4d2c-8abf-52e1bb081ab5"
|
|
42
|
+
[edit]="edit"
|
|
43
|
+
(submitForm) = "submitForm($event)"
|
|
44
|
+
(apiCalled)="getFormApiCalled($event)"
|
|
45
|
+
></octa-form-submission-webcomponent>
|
|
46
|
+
```
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
### Step 4: Load JS & CSS (Optional for Frameworks)
|
|
50
|
+
|
|
51
|
+
If your environment doesn’t automatically include the assets, load them dynamically in your code.
|
|
52
|
+
|
|
53
|
+
#### Example (JavaScript or Angular):
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
loadScript(src: string): Promise<void> {
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
if (document.querySelector(`script[src="${src}"]`)) {
|
|
59
|
+
resolve();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const script = document.createElement('script');
|
|
63
|
+
script.src = src;
|
|
64
|
+
script.onload = () => resolve();
|
|
65
|
+
script.onerror = () => reject();
|
|
66
|
+
document.body.appendChild(script);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
loadStyle(href: string): Promise<void> {
|
|
71
|
+
return new Promise((resolve, reject) => {
|
|
72
|
+
if (document.querySelector(`link[href="${href}"]`)) {
|
|
73
|
+
resolve();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const link = document.createElement('link');
|
|
77
|
+
link.rel = 'stylesheet';
|
|
78
|
+
link.href = href;
|
|
79
|
+
link.onload = () => resolve();
|
|
80
|
+
link.onerror = () => reject();
|
|
81
|
+
document.head.appendChild(link);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async ngAfterViewInit() {
|
|
86
|
+
await this.loadStyle('./assets/octa-form-submission-webcomponent/bundle.css');
|
|
87
|
+
await this.loadScript('./assets/octa-form-submission-webcomponent/bundle.js');
|
|
88
|
+
const el = document.querySelector('octa-form-submission-webcomponent') as any;
|
|
89
|
+
if (el) {
|
|
90
|
+
el.formId = this.id;
|
|
91
|
+
el.edit = true;
|
|
92
|
+
el.showModifyInfo = false;
|
|
93
|
+
el.formData = this.formData;
|
|
94
|
+
el.top = '0';
|
|
95
|
+
el.createDuplicate = false;
|
|
96
|
+
el.formElements = this.formElements;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
### Step 5 (Angular Only): Add `CUSTOM_ELEMENTS_SCHEMA`
|
|
104
|
+
|
|
105
|
+
If you are using Angular, include `CUSTOM_ELEMENTS_SCHEMA` in your module file (e.g. `app.module.ts`).
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
109
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
110
|
+
import { AppComponent } from './app.component';
|
|
111
|
+
|
|
112
|
+
@NgModule({
|
|
113
|
+
declarations: [AppComponent],
|
|
114
|
+
imports: [BrowserModule],
|
|
115
|
+
bootstrap: [AppComponent],
|
|
116
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA] // 👈 Important for Web Components
|
|
117
|
+
})
|
|
118
|
+
export class AppModule {}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
### Step 6 (Optional): Add Bundle in `angular.json`
|
|
124
|
+
|
|
125
|
+
If you prefer referencing the bundle directly via Angular CLI build options, include the following line:
|
|
126
|
+
|
|
127
|
+
```json
|
|
128
|
+
"scripts": [
|
|
129
|
+
"node_modules/@piserve-tech/octa-form-submission-webcomponent/dist/bundle.js"
|
|
130
|
+
]
|
|
131
|
+
```
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## 🛠️ Tech Stack
|
|
135
|
+
- **Web Components (Custom Elements API)**
|
|
136
|
+
- **Angular 16+ Compatible**
|
|
137
|
+
- **TypeScript**
|
|
138
|
+
- **Node.js (for asset copy script)**
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## 📄 License
|
|
143
|
+
**© 2025 Piserve Technologies Pvt Ltd**
|
|
144
|
+
Licensed under the **MIT License**.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@piserve-tech/octa-form-submission-webcomponent",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.27",
|
|
4
4
|
"description": "Distributable web component build for form submission (bundle.js, bundle.css, fonts, icons)",
|
|
5
5
|
"main": "dist/bundle.js",
|
|
6
6
|
"style": "dist/bundle.css",
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
"copy-assets.js",
|
|
13
13
|
"sample.html"
|
|
14
14
|
],
|
|
15
|
-
|
|
16
15
|
"scripts": {
|
|
17
16
|
"ng": "ng",
|
|
18
17
|
"start": "ng serve",
|