@unvired/turboforms-embed-sdk 1.0.10 β†’ 1.0.12

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
@@ -231,6 +231,10 @@ document.addEventListener('deviceready', function() {
231
231
  | `userData` | object | User context data |
232
232
  | `appData` | object | Application data |
233
233
  | `environmentVariable` | array | Environment variables |
234
+ | `privateExternal` | boolean/string | Controls form visibility logic (Private/Public) |
235
+ | `permission` | string | Access permission ('writesingle', 'writemultiple', 'read') |
236
+ | `controlData` | object | Data for initial control values |
237
+ | `showLoader` | boolean | Show/hide initial SDK loading spinner |
234
238
 
235
239
  ### Event Types
236
240
 
@@ -247,6 +251,64 @@ document.addEventListener('deviceready', function() {
247
251
  | `GET_ATTACHMENT` | Attachment request |
248
252
  | `ERROR` | Error occurred |
249
253
 
254
+ ## βœ… Button Visibility & Enablement
255
+
256
+ | privateExternal | Permission | Main Toolbar Button | More Options (Dropdown) | Enable / Disable Rule |
257
+ | ------------------ | --------------- | -------------------------- | ------------------------------- | -------------------------------------------------- |
258
+ | **false (Public)** | `writesingle` | **Submit** (`submitBtn`) | None | Enabled when **any field is filled** |
259
+ | **false (Public)** | `writemultiple` | **Submit** (`submitBtn`) | None | Enabled when **any field is filled** |
260
+ | **true (Private)** | `writemultiple` | **Save** (`saveBtn`) | **Complete** (`completeOption`) | Save enabled when **any field is filled** |
261
+ | **true (Private)** | `writesingle` | **Complete** (`submitBtn`) | **Save** (`saveOption`) | Complete enabled **ONLY when form is 100% filled** |
262
+ | **Any** | `read` | None | None | N/A (Read-only mode) |
263
+
264
+ ## 🧭 β€œMore Options” Dropdown Logic
265
+
266
+ ### β–Ά **Complete appears in More Options**
267
+
268
+ * **Condition:**
269
+ `privateExternal = true` **AND** `permission = writemultiple`
270
+ * **Reason:**
271
+ Allows **partial saves** via main **Save** button
272
+ Final submission (**Complete**) is optional and secondary
273
+
274
+ ### β–Ά **Save appears in More Options**
275
+
276
+ * **Condition:**
277
+ `privateExternal = true` **AND** `permission = writesingle`
278
+ * **Reason:**
279
+ Forces **100% completion** via main **Complete** button
280
+ Save is available only as a fallback action
281
+
282
+ ## πŸ”‘ Core Behavioral Rules
283
+
284
+ * **Public forms** β†’ Always **Submit**, enabled after any input
285
+ * **Private + writemultiple** β†’ **Save first**, Complete optional
286
+ * **Private + writesingle** β†’ **Complete mandatory**, Save optional
287
+ * **Read permission** β†’ No actions shown
288
+
289
+ ## πŸ“‚ File Attachment Architecture & Modes
290
+
291
+ The SDK employs a robust local-first strategy using **IndexedDB** for offline storage and persistence. To track the exact state of every file or image across its entire lifecycle (from server to local device to edits to deletion), the SDK uniquely assigns a synchronization `mode` to each file.
292
+
293
+ ### Mode Classification
294
+
295
+ | Mode | Name | Description |
296
+ |---|---|---|
297
+ | **`"A"`** | **Added (New)** | Represents a brand new file uploaded locally. Newly taken photos, selected files from the gallery, or newly cropped/edited images default to this state. |
298
+ | **`"G"`** | **Got (Downloaded)** | Represents a file that previously existed and was downloaded from the server API. The API dictates this mode, and the SDK recognizes it. By default, any file reconstructed from IndexedDB that lacks a mode tag assumes `"G"`. |
299
+ | **`"D"`** | **Deleted** | Represents an attachment that was marked as deleted by the user clicking the trash icon. The system physically flags the file in the database rather than removing the row entirely, permitting the host app to notify the server of the deletion upon final sync. |
300
+
301
+ ### Working Flow: Cropping or Editing an Image
302
+
303
+ When a user crops or annotates an existing server image or local image, the SDK executes the following sequence:
304
+
305
+ 1. **In-Memory Capture**: The crop/annotation tool creates a brand new physical `Blob` containing the updated image metadata safely in RAM.
306
+ 2. **New DB Entry Created**: The SDK assigns a fresh UUID to the newly cropped image and stores it inside the IndexedDB as a completely individual brand new file with `mode: "A"`.
307
+ 3. **Original File Deleted**: To preserve device storage and state integrity, the SDK locates the original file's UUID corresponding to the un-cropped image and physically deletes it out of the IndexedDB via a `deleteOriginalFileFromDB` listener event.
308
+ 4. **Memory Re-linking**: The form component's memory immediately reflects the presence of the new file object bearing mode `"A"` substituted into the form submission pipeline.
309
+
310
+ This process simplifies the architecture: edits simply generate brand new files, offloading any complex diffing logic to the main application server layer.
311
+
250
312
  ## πŸ”§ Form Instance Methods
251
313
 
252
314
  The `loadUnviredForms` function returns a FormInstance object with the following methods:
@@ -321,7 +383,7 @@ loadUnviredForms({
321
383
  eventCallback: function(event) {
322
384
  if (event.type === 'ERROR') {
323
385
  switch (event.errorMessage) {
324
- case 'Error Code 001 contact your admin':
386
+ case 'Error Code 001 contact your admin or tech team':
325
387
  console.error('Invalid formsData JSON');
326
388
  break;
327
389
  case 'Error Code 004 contact your admin':
@@ -364,6 +426,17 @@ loadUnviredForms({
364
426
  - Use HTTPS in production environments
365
427
  - Sanitize user inputs to prevent XSS attacks
366
428
 
429
+ ## πŸ§ͺ Platform Compatibility
430
+
431
+ | Platform | Version | Status |
432
+ |----------|---------|--------|
433
+ | React.js | 16.8+ | βœ… Fully Supported |
434
+ | Angular | 12+ | βœ… Fully Supported |
435
+ | Vue.js | 3.0+ | βœ… Fully Supported |
436
+ | Ionic | 5+ | βœ… Fully Supported |
437
+ | Cordova | 9+ | βœ… Fully Supported |
438
+ | Vanilla JS | ES6+ | βœ… Fully Supported |
439
+
367
440
  ## πŸ›  Build Process
368
441
 
369
442
  ### Development Setup
@@ -395,18 +468,4 @@ The build process generates:
395
468
  - `dist/index.d.ts` - TypeScript definitions
396
469
  - `dist/assets/` - FormIO library and UI assets
397
470
 
398
- ## πŸ§ͺ Platform Compatibility
399
-
400
- | Platform | Version | Status |
401
- |----------|---------|--------|
402
- | React.js | 16.8+ | βœ… Fully Supported |
403
- | Angular | 12+ | βœ… Fully Supported |
404
- | Vue.js | 3.0+ | βœ… Fully Supported |
405
- | Ionic | 5+ | βœ… Fully Supported |
406
- | Cordova | 9+ | βœ… Fully Supported |
407
- | Vanilla JS | ES6+ | βœ… Fully Supported |
408
-
409
-
410
471
  ## πŸ“ License
411
-
412
- [MIT](LICENSE) - See LICENSE file for details.