@piserve-tech/octa-form-submission-webcomponent 1.0.25 → 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 CHANGED
@@ -1,27 +1,144 @@
1
- # AngularFormSubmissionComponent
1
+ # 🧩 Octa Form Submission Web Component
2
2
 
3
- This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 16.1.8.
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
- ## Development server
5
+ ---
6
6
 
7
- Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.
7
+ ## 🚀 Installation
8
8
 
9
- ## Code scaffolding
9
+ ### Step 1: Install the package
10
10
 
11
- Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
11
+ ```bash
12
+ npm i @piserve-tech/octa-form-submission-webcomponent
13
+ ```
12
14
 
13
- ## Build
15
+ ---
14
16
 
15
- Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
17
+ ## ⚙️ Setup Guide
16
18
 
17
- ## Running unit tests
19
+ ### Step 2: Copy Required Assets
18
20
 
19
- Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
21
+ Run the following command to copy the assets (bundle.js and bundle.css) into your project’s `assets` folder.
20
22
 
21
- ## Running end-to-end tests
23
+ ```bash
24
+ node .\node_modules\@piserve-tech\octa-form-submission-webcomponent\copy-assets.js
25
+ ```
22
26
 
23
- Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
27
+ This script will copy files into:
28
+ ```
29
+ /src/assets/octa-form-submission-webcomponent/
30
+ ```
24
31
 
25
- ## Further help
32
+ ---
26
33
 
27
- To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
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/copy-assets.js ADDED
@@ -0,0 +1,47 @@
1
+ // Script to copy assets for web component distribution
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+
5
+ function copyRecursiveSync(src, dest) {
6
+ if (!fs.existsSync(src)) return;
7
+ const stats = fs.statSync(src);
8
+ if (stats.isDirectory()) {
9
+ if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
10
+ fs.readdirSync(src).forEach(child => {
11
+ copyRecursiveSync(path.join(src, child), path.join(dest, child));
12
+ });
13
+ } else {
14
+ fs.copyFileSync(src, dest);
15
+ }
16
+ }
17
+
18
+
19
+ // Determine source: local dist or node_modules
20
+ let srcAssets, srcBundleJs, srcBundleCss;
21
+ if (fs.existsSync(path.join(__dirname, 'dist', 'assets'))) {
22
+ srcAssets = path.join(__dirname, 'dist', 'assets');
23
+ srcBundleJs = path.join(__dirname, 'dist', 'bundle.js');
24
+ srcBundleCss = path.join(__dirname, 'dist', 'bundle.css');
25
+ } else {
26
+ srcAssets = path.join(__dirname, 'node_modules', '@piserve-tech', 'octa-form-submission-webcomponent', 'dist', 'assets');
27
+ srcBundleJs = path.join(__dirname, 'node_modules', '@piserve-tech', 'octa-form-submission-webcomponent', 'dist', 'bundle.js');
28
+ srcBundleCss = path.join(__dirname, 'node_modules', '@piserve-tech', 'octa-form-submission-webcomponent', 'dist', 'bundle.css');
29
+ }
30
+ const destAssets = path.join(process.cwd(), 'src', 'assets', 'octa-form-submission-webcomponent');
31
+
32
+ copyRecursiveSync(srcAssets, destAssets);
33
+
34
+ // Also copy bundle.js and bundle.css
35
+ const destBundleJs = path.join(destAssets, 'bundle.js');
36
+ const destBundleCss = path.join(destAssets, 'bundle.css');
37
+
38
+ if (fs.existsSync(srcBundleJs)) {
39
+ fs.copyFileSync(srcBundleJs, destBundleJs);
40
+ console.log('bundle.js copied to src/assets/octa-form-submission-webcomponent');
41
+ }
42
+ if (fs.existsSync(srcBundleCss)) {
43
+ fs.copyFileSync(srcBundleCss, destBundleCss);
44
+ console.log('bundle.css copied to src/assets/octa-form-submission-webcomponent');
45
+ }
46
+
47
+ console.log('Assets and bundles copied to src/assets/octa-form-submission-webcomponent');
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,6 @@
1
+ <svg width="38" height="36" viewBox="0 0 38 36" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect x="0.5" y="0.5" width="37" height="35" rx="5.5" fill="white" stroke="#D8D8D8"/>
3
+ <rect x="13.998" y="13.9922" width="14.0058" height="14.0058" rx="2" stroke="#084FFF" stroke-linecap="round" stroke-linejoin="round"/>
4
+ <path d="M13.9982 23.998H11.9974C10.8924 23.998 9.99658 23.1022 9.99658 21.9972V11.993C9.99658 10.888 10.8924 9.99219 11.9974 9.99219H22.0016C23.1066 9.99219 24.0024 10.888 24.0024 11.993V13.9939" stroke="#084FFF" stroke-linecap="round" stroke-linejoin="round"/>
5
+ </svg>
6
+
@@ -0,0 +1,8 @@
1
+ <svg viewBox="0 0 38 36" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect width="35px" height="35px" stroke="#D8D8D8" fill="white" x="0.5" y="0.5" rx="5.5"/>
3
+ <path d="M11.4165 12.2142H26.5832" stroke="#084FFF" stroke-linecap="round" stroke-linejoin="round"/>
4
+ <path stroke="#084FFF" stroke-linecap="round" stroke-linejoin="round" d="M25.5 12.2139V23.597C25.5 24.7404 24.5304 25.6666 23.3333 25.6666H14.6667C13.4696 25.6666 12.5 24.7404 12.5 23.597V12.2139"/>
5
+ <path stroke="#084FFF" stroke-linecap="round" stroke-linejoin="round" d="M22.25 8.85091H15.75"/>
6
+ <path stroke="#084FFF" stroke-linecap="round" stroke-linejoin="round" d="M16.8332 16.3535V21.5276"/>
7
+ <path stroke="#084FFF" stroke-linecap="round" stroke-linejoin="round" d="M21.1667 16.3535V21.5276"/>
8
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="7" height="9" viewBox="0 0 7 9" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M5.61426 0.769531L1.72218 4.41345L5.67398 7.99251" stroke="#8E9AA0" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="7" height="9" viewBox="0 0 7 9" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M1.7666 8.03125L5.64422 4.37194L1.67827 0.808564" stroke="#8E9AA0" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
3
+ </svg>