@sumit_yewale/angular 1.1.18 → 1.1.20

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
@@ -83,6 +83,47 @@ export class AppComponent {
83
83
  | `isSubmitted` | Triggers when the user hits the 'Submit' button to upload the validated file. **data** object is available in this event. It contains metadata related to the import.|
84
84
  | `isImported` | Triggers when the data is pushed to the destination.<br>Two objects are available in this event:<br>1. result (boolean): It is true when the import is successful and false when the import fails.<br>2. data (object): Contains metadata related to the import.|
85
85
 
86
+ ## Importing a file you already have
87
+
88
+ `openModalWithFile(file)` opens the importer on a `File` your own page is holding — from your
89
+ own drop target, your own file input, anything — instead of the importer's file picker. The
90
+ file still goes through the importer's extension, worksheet and size checks; this skips the
91
+ picker, not the validation.
92
+
93
+ Call it through a template reference variable:
94
+
95
+ ```html
96
+ <csvbox-button #importer [licenseKey]="licenseKey" [user]="user" [isImported]="isImported.bind(this)">
97
+ Import
98
+ </csvbox-button>
99
+
100
+ <input type="file" (change)="importer.openModalWithFile($any($event.target).files[0])" />
101
+ ```
102
+
103
+ or from the component class with `@ViewChild(CSVBoxButtonComponent) importer: CSVBoxButtonComponent;`
104
+ and `this.importer.openModalWithFile(file)`.
105
+
106
+ The importer can decline a file it is handed, and says why in a console warning
107
+ (`[csvbox] importer declined the supplied file: <reason>`):
108
+
109
+ - `import-in-progress` — the importer is open past its upload step, or is still reading an
110
+ earlier file. An import that is already open stays open.
111
+ - `modal-closing` — the importer was closing when the file arrived.
112
+ - `import-file-url-configured` — the sheet is set up to load its own file from a URL.
113
+
114
+ Pass a `File`, not a `Blob`: a `Blob` has no name to read an extension from, and anything that
115
+ is not a `File` is ignored.
116
+
117
+ When the importer redirects to another host (data-location sheets do this), the file is sent to the host the importer actually ended up on, as long as that host is your importer domain or `<region>-<your domain>` (for example `eu-app.csvbox.io` for `app.csvbox.io`). A file is never sent to any other host.
118
+
119
+ If the importer does not answer a supplied file within about 8 seconds (for example because it redirected to a host that does not follow that naming, or it is too old to know the message), the importer is put away, the other buttons are enabled again, and the console says `[csvbox] the importer did not respond to the supplied file`.
120
+
121
+ ## Several importers on one page
122
+
123
+ While an importer is open (or still loading to open), the button of every other CSVBox instance on the page is disabled until it closes, so two importers are not opened by accident. In React, the second argument of the `render` prop (`isLoading`) is also `true` in that state, so a custom trigger can disable itself the same way.
124
+
125
+ Opening a second importer from code (`openModal()` or `openModalWithFile()`) is still possible. The importer opened last is shown on top of the others, and closing it reveals the one underneath.
126
+
86
127
  ## Readme
87
128
 
88
129
  For usage see the guide here - https://help.csvbox.io/getting-started#2-install-code