@sumit_yewale/angular 1.1.18
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 +93 -0
- package/bundles/sumit_yewale-angular.umd.js +415 -0
- package/bundles/sumit_yewale-angular.umd.js.map +1 -0
- package/bundles/sumit_yewale-angular.umd.min.js +2 -0
- package/bundles/sumit_yewale-angular.umd.min.js.map +1 -0
- package/esm2015/lib/csvbox-angular.module.js +21 -0
- package/esm2015/lib/csvbox-button.component.js +327 -0
- package/esm2015/lib/interfaces/interface.js +14 -0
- package/esm2015/public-api.js +13 -0
- package/esm2015/sumit_yewale-angular.js +10 -0
- package/esm2015/utlis/insertCSS.js +44 -0
- package/esm5/lib/csvbox-angular.module.js +25 -0
- package/esm5/lib/csvbox-button.component.js +344 -0
- package/esm5/lib/interfaces/interface.js +14 -0
- package/esm5/public-api.js +13 -0
- package/esm5/sumit_yewale-angular.js +10 -0
- package/esm5/utlis/insertCSS.js +27 -0
- package/fesm2015/sumit_yewale-angular.js +418 -0
- package/fesm2015/sumit_yewale-angular.js.map +1 -0
- package/fesm5/sumit_yewale-angular.js +420 -0
- package/fesm5/sumit_yewale-angular.js.map +1 -0
- package/lib/csvbox-angular.module.d.ts +2 -0
- package/lib/csvbox-button.component.d.ts +45 -0
- package/lib/interfaces/interface.d.ts +3 -0
- package/package.json +55 -0
- package/public-api.d.ts +3 -0
- package/sumit_yewale-angular.d.ts +4 -0
- package/sumit_yewale-angular.metadata.json +1 -0
- package/utlis/insertCSS.d.ts +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# @csvbox/angular
|
|
2
|
+
|
|
3
|
+
> Angular adapter for csvbox.io
|
|
4
|
+
|
|
5
|
+
## ✅ Only for Angular version 8 to 13
|
|
6
|
+
## ⚠️ For Angular version 14 and above, please use [@csvbox/angular2](https://www.npmjs.com/package/@csvbox/angular2) package
|
|
7
|
+
|
|
8
|
+
[](https://www.npmjs.com/package/@csvbox/angular) [](https://standardjs.com)
|
|
9
|
+
|
|
10
|
+
## Compatibility
|
|
11
|
+
|
|
12
|
+
| Angular Version | Package |
|
|
13
|
+
| ------ | ------ |
|
|
14
|
+
|8 to 13|@csvbox/angular (this package)|
|
|
15
|
+
|14 to 19|[@csvbox/angular2](https://www.npmjs.com/package/@csvbox/angular2)|
|
|
16
|
+
|
|
17
|
+
## Shell
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @csvbox/angular
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Import
|
|
24
|
+
Add `CSVBoxAngularModule` to your module imports
|
|
25
|
+
```ts
|
|
26
|
+
import { CSVBoxAngularModule } from "@csvbox/angular";
|
|
27
|
+
|
|
28
|
+
@NgModule({
|
|
29
|
+
...
|
|
30
|
+
imports: [
|
|
31
|
+
...
|
|
32
|
+
CSVBoxAngularModule
|
|
33
|
+
]
|
|
34
|
+
})
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
```html
|
|
40
|
+
<csvbox-button [licenseKey]="licenseKey" [isImported]="isImported.bind(this)" [user]="user">Import</csvbox-button>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Example
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
|
|
47
|
+
@Component({
|
|
48
|
+
selector: 'app-root',
|
|
49
|
+
template: `
|
|
50
|
+
<csvbox-button
|
|
51
|
+
[licenseKey]="licenseKey"
|
|
52
|
+
[user]="user"
|
|
53
|
+
[isImported]="isImported.bind(this)">
|
|
54
|
+
Import
|
|
55
|
+
</csvbox-button>
|
|
56
|
+
`
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
export class AppComponent {
|
|
60
|
+
|
|
61
|
+
title = 'example';
|
|
62
|
+
licenseKey = 'YOUR_LICENSE_KEY_HERE';
|
|
63
|
+
user = { user_id: 'default123' };
|
|
64
|
+
|
|
65
|
+
isImported(result: boolean, data: any) {
|
|
66
|
+
if(result) {
|
|
67
|
+
console.log("Sheet uploaded successfully");
|
|
68
|
+
console.log(data.row_success + " rows uploaded");
|
|
69
|
+
}else{
|
|
70
|
+
console.log("There was some problem uploading the sheet");
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Events
|
|
78
|
+
|
|
79
|
+
| Event | Description |
|
|
80
|
+
| :---------- | :-------------------------------------------------------------------------|
|
|
81
|
+
| `isReady` | Triggers when the importer is initialized and ready for use by the users. |
|
|
82
|
+
| `isClosed` | Triggers when the importer is closed. |
|
|
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
|
+
| `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
|
+
|
|
86
|
+
## Readme
|
|
87
|
+
|
|
88
|
+
For usage see the guide here - https://help.csvbox.io/getting-started#2-install-code
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
MIT © [csvbox-io](https://github.com/csvbox-io)
|
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/platform-browser'), require('@sumit_yewale/adapter-core')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@sumit_yewale/angular', ['exports', '@angular/core', '@angular/platform-browser', '@sumit_yewale/adapter-core'], factory) :
|
|
4
|
+
(global = global || self, factory((global.sumit_yewale = global.sumit_yewale || {}, global.sumit_yewale.angular = {}), global.ng.core, global.ng.platformBrowser, global.adapterCore));
|
|
5
|
+
}(this, (function (exports, core, platformBrowser, adapterCore) { 'use strict';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @fileoverview added by tsickle
|
|
9
|
+
* Generated from: utlis/insertCSS.ts
|
|
10
|
+
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
11
|
+
*/
|
|
12
|
+
/** @type {?} */
|
|
13
|
+
var styleElement;
|
|
14
|
+
/** @type {?} */
|
|
15
|
+
var GLOBAL_CSS = "\n.csvbox-holder {\n z-index: 2147483647;\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n display: none;\n}\n.csvbox-holder iframe {\n height: 100%;\n width: 100%;\n position: absolute;\n top: 0px;\n left: 0px;\n}\n";
|
|
16
|
+
/** @type {?} */
|
|
17
|
+
var insertCSS = (/**
|
|
18
|
+
* @return {?}
|
|
19
|
+
*/
|
|
20
|
+
function () {
|
|
21
|
+
if (styleElement) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
styleElement = document.createElement('style');
|
|
25
|
+
styleElement.setAttribute('type', 'text/css');
|
|
26
|
+
/** @type {?} */
|
|
27
|
+
var head = document.querySelector('head');
|
|
28
|
+
if (head) {
|
|
29
|
+
head.appendChild(styleElement);
|
|
30
|
+
}
|
|
31
|
+
styleElement.textContent = GLOBAL_CSS;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @fileoverview added by tsickle
|
|
36
|
+
* Generated from: lib/csvbox-button.component.ts
|
|
37
|
+
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
38
|
+
*/
|
|
39
|
+
/** @type {?} */
|
|
40
|
+
var appVersion = '1.1.16';
|
|
41
|
+
var CSVBoxButtonComponent = /** @class */ (function () {
|
|
42
|
+
function CSVBoxButtonComponent(sanitizer) {
|
|
43
|
+
this.sanitizer = sanitizer;
|
|
44
|
+
this.isModalShown = false;
|
|
45
|
+
this.licenseKey = null;
|
|
46
|
+
this.uuid = null;
|
|
47
|
+
this.customDomain = null;
|
|
48
|
+
this.dataLocation = null;
|
|
49
|
+
this.language = null;
|
|
50
|
+
this.theme = null;
|
|
51
|
+
this.isIframeLoaded = false;
|
|
52
|
+
this.openModalOnIframeLoad = false;
|
|
53
|
+
this.lazy = false;
|
|
54
|
+
this.iframe = null;
|
|
55
|
+
this.disabled = true;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @return {?}
|
|
59
|
+
*/
|
|
60
|
+
CSVBoxButtonComponent.prototype.ngOnInit = /**
|
|
61
|
+
* @return {?}
|
|
62
|
+
*/
|
|
63
|
+
function () {
|
|
64
|
+
this.uuid = adapterCore.generateUuid();
|
|
65
|
+
/** @type {?} */
|
|
66
|
+
var iframeUrl = adapterCore.buildImportUrl({
|
|
67
|
+
licenseKey: this.licenseKey,
|
|
68
|
+
customDomain: this.customDomain,
|
|
69
|
+
dataLocation: this.dataLocation,
|
|
70
|
+
language: this.language,
|
|
71
|
+
theme: this.theme,
|
|
72
|
+
environment: this.environment
|
|
73
|
+
}, "angular", appVersion);
|
|
74
|
+
this.safeUrl = this.sanitizer.sanitize(core.SecurityContext.RESOURCE_URL, this.sanitizer.bypassSecurityTrustResourceUrl(iframeUrl));
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* @param {?} changes
|
|
78
|
+
* @return {?}
|
|
79
|
+
*/
|
|
80
|
+
CSVBoxButtonComponent.prototype.ngOnChanges = /**
|
|
81
|
+
* @param {?} changes
|
|
82
|
+
* @return {?}
|
|
83
|
+
*/
|
|
84
|
+
function (changes) {
|
|
85
|
+
if (changes["user"] && changes['user'].currentValue != changes['user'].previousValue) {
|
|
86
|
+
this.updateUserVariabe(changes['user'].currentValue);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* @param {?} data
|
|
91
|
+
* @return {?}
|
|
92
|
+
*/
|
|
93
|
+
CSVBoxButtonComponent.prototype.updateUserVariabe = /**
|
|
94
|
+
* @param {?} data
|
|
95
|
+
* @return {?}
|
|
96
|
+
*/
|
|
97
|
+
function (data) {
|
|
98
|
+
this.user = data;
|
|
99
|
+
if (this.iframe && this.iframe.contentWindow) {
|
|
100
|
+
this.iframe.contentWindow.postMessage({
|
|
101
|
+
"customer": data
|
|
102
|
+
}, "*");
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* @return {?}
|
|
107
|
+
*/
|
|
108
|
+
CSVBoxButtonComponent.prototype.ngAfterContentInit = /**
|
|
109
|
+
* @return {?}
|
|
110
|
+
*/
|
|
111
|
+
function () {
|
|
112
|
+
var _this = this;
|
|
113
|
+
window.addEventListener("message", (/**
|
|
114
|
+
* @param {?} event
|
|
115
|
+
* @return {?}
|
|
116
|
+
*/
|
|
117
|
+
function (event) {
|
|
118
|
+
/** @type {?} */
|
|
119
|
+
var message = adapterCore.classifyStructuredMessage(event.data, (/** @type {?} */ (_this.uuid)));
|
|
120
|
+
if (!message) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (message.type === "data-on-submit") {
|
|
124
|
+
if (_this.onSubmit)
|
|
125
|
+
_this.onSubmit(message.metadata);
|
|
126
|
+
if (_this.isSubmitted)
|
|
127
|
+
_this.isSubmitted(message.metadata);
|
|
128
|
+
if (_this.submitted)
|
|
129
|
+
_this.submitted(message.metadata);
|
|
130
|
+
}
|
|
131
|
+
else if (message.type === "data-push-status") {
|
|
132
|
+
if (!message.success) {
|
|
133
|
+
delete message.metadata["unique_token"];
|
|
134
|
+
}
|
|
135
|
+
if (_this.onImport)
|
|
136
|
+
_this.onImport(message.success, message.metadata);
|
|
137
|
+
if (_this.isImported)
|
|
138
|
+
_this.isImported(message.success, message.metadata);
|
|
139
|
+
if (_this.imported)
|
|
140
|
+
_this.imported(message.success, message.metadata);
|
|
141
|
+
}
|
|
142
|
+
else if (message.type === "csvbox-modal-hidden") {
|
|
143
|
+
_this.handleModalClosed();
|
|
144
|
+
}
|
|
145
|
+
else if (message.type === "csvbox-upload-successful") {
|
|
146
|
+
if (_this.onImport)
|
|
147
|
+
_this.onImport(true);
|
|
148
|
+
if (_this.isImported)
|
|
149
|
+
_this.isImported(true);
|
|
150
|
+
if (_this.imported)
|
|
151
|
+
_this.imported(true);
|
|
152
|
+
}
|
|
153
|
+
else if (message.type === "csvbox-upload-failed") {
|
|
154
|
+
if (_this.onImport)
|
|
155
|
+
_this.onImport(false);
|
|
156
|
+
if (_this.isImported)
|
|
157
|
+
_this.isImported(false);
|
|
158
|
+
if (_this.imported)
|
|
159
|
+
_this.imported(false);
|
|
160
|
+
}
|
|
161
|
+
}), false);
|
|
162
|
+
if (this.lazy) {
|
|
163
|
+
this.disabled = false;
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
this.disabled = true;
|
|
167
|
+
this.initImporter();
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* @return {?}
|
|
172
|
+
*/
|
|
173
|
+
CSVBoxButtonComponent.prototype.handleModalClosed = /**
|
|
174
|
+
* @return {?}
|
|
175
|
+
*/
|
|
176
|
+
function () {
|
|
177
|
+
if (this.holder)
|
|
178
|
+
this.holder.style.display = 'none';
|
|
179
|
+
this.isModalShown = false;
|
|
180
|
+
this.isIframeLoaded = false;
|
|
181
|
+
this.openModalOnIframeLoad = false;
|
|
182
|
+
if (this.holder)
|
|
183
|
+
this.holder.remove();
|
|
184
|
+
this.holder = null;
|
|
185
|
+
this.iframe = null;
|
|
186
|
+
if (this.onClose)
|
|
187
|
+
this.onClose();
|
|
188
|
+
if (this.isClosed)
|
|
189
|
+
this.isClosed();
|
|
190
|
+
if (this.closed)
|
|
191
|
+
this.closed();
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* @return {?}
|
|
195
|
+
*/
|
|
196
|
+
CSVBoxButtonComponent.prototype.initImporter = /**
|
|
197
|
+
* @return {?}
|
|
198
|
+
*/
|
|
199
|
+
function () {
|
|
200
|
+
if (this.loadStarted)
|
|
201
|
+
this.loadStarted();
|
|
202
|
+
this.uuid = adapterCore.generateUuid();
|
|
203
|
+
insertCSS();
|
|
204
|
+
/** @type {?} */
|
|
205
|
+
var iframe = document.createElement("iframe");
|
|
206
|
+
this.iframe = iframe;
|
|
207
|
+
iframe.setAttribute("src", this.safeUrl);
|
|
208
|
+
iframe.frameBorder = "0";
|
|
209
|
+
/** @type {?} */
|
|
210
|
+
var self = this;
|
|
211
|
+
iframe.onload = (/**
|
|
212
|
+
* @return {?}
|
|
213
|
+
*/
|
|
214
|
+
function () {
|
|
215
|
+
if (self.onReady)
|
|
216
|
+
self.onReady();
|
|
217
|
+
if (self.isReady)
|
|
218
|
+
self.isReady();
|
|
219
|
+
if (self.importerReady)
|
|
220
|
+
self.importerReady();
|
|
221
|
+
self.disabled = false;
|
|
222
|
+
self.isIframeLoaded = true;
|
|
223
|
+
if (self.iframe && self.iframe.contentWindow) {
|
|
224
|
+
self.iframe.contentWindow.postMessage(adapterCore.buildInitPayload(self.user, self.dynamicColumns, self.options, (/** @type {?} */ (self.uuid))), "*");
|
|
225
|
+
}
|
|
226
|
+
if (self.openModalOnIframeLoad) {
|
|
227
|
+
self.openModal();
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
this.holder = document.createElement('div');
|
|
231
|
+
this.holder.classList.add('csvbox-holder');
|
|
232
|
+
this.holder.setAttribute('id', "csvbox-embed-" + this.uuid);
|
|
233
|
+
this.holder.appendChild(iframe);
|
|
234
|
+
document.body.insertAdjacentElement('beforeend', this.holder);
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* @return {?}
|
|
238
|
+
*/
|
|
239
|
+
CSVBoxButtonComponent.prototype.openModal = /**
|
|
240
|
+
* @return {?}
|
|
241
|
+
*/
|
|
242
|
+
function () {
|
|
243
|
+
if (!this.iframe) {
|
|
244
|
+
this.openModalOnIframeLoad = true;
|
|
245
|
+
this.initImporter();
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
if (!this.isModalShown) {
|
|
249
|
+
if (this.isIframeLoaded) {
|
|
250
|
+
this.isModalShown = true;
|
|
251
|
+
if (this.holder)
|
|
252
|
+
this.holder.style.display = 'block';
|
|
253
|
+
if (this.iframe && this.iframe.contentWindow) {
|
|
254
|
+
this.iframe.contentWindow.postMessage('openModal', '*');
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
this.openModalOnIframeLoad = true;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
CSVBoxButtonComponent.decorators = [
|
|
263
|
+
{ type: core.Component, args: [{
|
|
264
|
+
selector: 'csvbox-button',
|
|
265
|
+
template: "\n <div>\n <button [disabled]=\"disabled\" #initiator (click)=\"openModal()\" [attr.data-csvbox-token]=\"uuid\">\n <ng-content></ng-content>\n </button>\n </div>\n "
|
|
266
|
+
}] }
|
|
267
|
+
];
|
|
268
|
+
/** @nocollapse */
|
|
269
|
+
CSVBoxButtonComponent.ctorParameters = function () { return [
|
|
270
|
+
{ type: platformBrowser.DomSanitizer }
|
|
271
|
+
]; };
|
|
272
|
+
CSVBoxButtonComponent.propDecorators = {
|
|
273
|
+
initiator: [{ type: core.ViewChild, args: ['initiator', { static: false },] }],
|
|
274
|
+
onImport: [{ type: core.Input }],
|
|
275
|
+
onReady: [{ type: core.Input }],
|
|
276
|
+
onClose: [{ type: core.Input }],
|
|
277
|
+
onSubmit: [{ type: core.Input }],
|
|
278
|
+
isImported: [{ type: core.Input }],
|
|
279
|
+
isReady: [{ type: core.Input }],
|
|
280
|
+
isClosed: [{ type: core.Input }],
|
|
281
|
+
isSubmitted: [{ type: core.Input }],
|
|
282
|
+
importerReady: [{ type: core.Input }],
|
|
283
|
+
closed: [{ type: core.Input }],
|
|
284
|
+
submitted: [{ type: core.Input }],
|
|
285
|
+
imported: [{ type: core.Input }],
|
|
286
|
+
loadStarted: [{ type: core.Input }],
|
|
287
|
+
user: [{ type: core.Input }],
|
|
288
|
+
dynamicColumns: [{ type: core.Input }],
|
|
289
|
+
licenseKey: [{ type: core.Input }],
|
|
290
|
+
options: [{ type: core.Input }],
|
|
291
|
+
uuid: [{ type: core.Input }],
|
|
292
|
+
customDomain: [{ type: core.Input }],
|
|
293
|
+
dataLocation: [{ type: core.Input }],
|
|
294
|
+
language: [{ type: core.Input }],
|
|
295
|
+
environment: [{ type: core.Input }],
|
|
296
|
+
theme: [{ type: core.Input }],
|
|
297
|
+
isIframeLoaded: [{ type: core.Input }],
|
|
298
|
+
openModalOnIframeLoad: [{ type: core.Input }],
|
|
299
|
+
lazy: [{ type: core.Input }],
|
|
300
|
+
disabled: [{ type: core.Input }]
|
|
301
|
+
};
|
|
302
|
+
return CSVBoxButtonComponent;
|
|
303
|
+
}());
|
|
304
|
+
if (false) {
|
|
305
|
+
/** @type {?} */
|
|
306
|
+
CSVBoxButtonComponent.prototype.isModalShown;
|
|
307
|
+
/** @type {?} */
|
|
308
|
+
CSVBoxButtonComponent.prototype.initiator;
|
|
309
|
+
/** @type {?} */
|
|
310
|
+
CSVBoxButtonComponent.prototype.onImport;
|
|
311
|
+
/** @type {?} */
|
|
312
|
+
CSVBoxButtonComponent.prototype.onReady;
|
|
313
|
+
/** @type {?} */
|
|
314
|
+
CSVBoxButtonComponent.prototype.onClose;
|
|
315
|
+
/** @type {?} */
|
|
316
|
+
CSVBoxButtonComponent.prototype.onSubmit;
|
|
317
|
+
/** @type {?} */
|
|
318
|
+
CSVBoxButtonComponent.prototype.isImported;
|
|
319
|
+
/** @type {?} */
|
|
320
|
+
CSVBoxButtonComponent.prototype.isReady;
|
|
321
|
+
/** @type {?} */
|
|
322
|
+
CSVBoxButtonComponent.prototype.isClosed;
|
|
323
|
+
/** @type {?} */
|
|
324
|
+
CSVBoxButtonComponent.prototype.isSubmitted;
|
|
325
|
+
/** @type {?} */
|
|
326
|
+
CSVBoxButtonComponent.prototype.importerReady;
|
|
327
|
+
/** @type {?} */
|
|
328
|
+
CSVBoxButtonComponent.prototype.closed;
|
|
329
|
+
/** @type {?} */
|
|
330
|
+
CSVBoxButtonComponent.prototype.submitted;
|
|
331
|
+
/** @type {?} */
|
|
332
|
+
CSVBoxButtonComponent.prototype.imported;
|
|
333
|
+
/** @type {?} */
|
|
334
|
+
CSVBoxButtonComponent.prototype.loadStarted;
|
|
335
|
+
/** @type {?} */
|
|
336
|
+
CSVBoxButtonComponent.prototype.user;
|
|
337
|
+
/** @type {?} */
|
|
338
|
+
CSVBoxButtonComponent.prototype.dynamicColumns;
|
|
339
|
+
/** @type {?} */
|
|
340
|
+
CSVBoxButtonComponent.prototype.licenseKey;
|
|
341
|
+
/** @type {?} */
|
|
342
|
+
CSVBoxButtonComponent.prototype.options;
|
|
343
|
+
/** @type {?} */
|
|
344
|
+
CSVBoxButtonComponent.prototype.uuid;
|
|
345
|
+
/** @type {?} */
|
|
346
|
+
CSVBoxButtonComponent.prototype.customDomain;
|
|
347
|
+
/** @type {?} */
|
|
348
|
+
CSVBoxButtonComponent.prototype.dataLocation;
|
|
349
|
+
/** @type {?} */
|
|
350
|
+
CSVBoxButtonComponent.prototype.language;
|
|
351
|
+
/** @type {?} */
|
|
352
|
+
CSVBoxButtonComponent.prototype.environment;
|
|
353
|
+
/** @type {?} */
|
|
354
|
+
CSVBoxButtonComponent.prototype.theme;
|
|
355
|
+
/** @type {?} */
|
|
356
|
+
CSVBoxButtonComponent.prototype.isIframeLoaded;
|
|
357
|
+
/** @type {?} */
|
|
358
|
+
CSVBoxButtonComponent.prototype.openModalOnIframeLoad;
|
|
359
|
+
/** @type {?} */
|
|
360
|
+
CSVBoxButtonComponent.prototype.lazy;
|
|
361
|
+
/** @type {?} */
|
|
362
|
+
CSVBoxButtonComponent.prototype.safeUrl;
|
|
363
|
+
/** @type {?} */
|
|
364
|
+
CSVBoxButtonComponent.prototype.iframe;
|
|
365
|
+
/** @type {?} */
|
|
366
|
+
CSVBoxButtonComponent.prototype.disabled;
|
|
367
|
+
/** @type {?} */
|
|
368
|
+
CSVBoxButtonComponent.prototype.holder;
|
|
369
|
+
/** @type {?} */
|
|
370
|
+
CSVBoxButtonComponent.prototype.sanitizer;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* @fileoverview added by tsickle
|
|
375
|
+
* Generated from: lib/csvbox-angular.module.ts
|
|
376
|
+
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
377
|
+
*/
|
|
378
|
+
var CSVBoxAngularModule = /** @class */ (function () {
|
|
379
|
+
function CSVBoxAngularModule() {
|
|
380
|
+
}
|
|
381
|
+
CSVBoxAngularModule.decorators = [
|
|
382
|
+
{ type: core.NgModule, args: [{
|
|
383
|
+
declarations: [
|
|
384
|
+
CSVBoxButtonComponent
|
|
385
|
+
],
|
|
386
|
+
imports: [],
|
|
387
|
+
exports: [
|
|
388
|
+
CSVBoxButtonComponent
|
|
389
|
+
]
|
|
390
|
+
},] }
|
|
391
|
+
];
|
|
392
|
+
return CSVBoxAngularModule;
|
|
393
|
+
}());
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* @fileoverview added by tsickle
|
|
397
|
+
* Generated from: lib/interfaces/interface.ts
|
|
398
|
+
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
399
|
+
*/
|
|
400
|
+
/**
|
|
401
|
+
* @record
|
|
402
|
+
*/
|
|
403
|
+
function CSVBoxMethods() { }
|
|
404
|
+
if (false) {
|
|
405
|
+
/** @type {?|undefined} */
|
|
406
|
+
CSVBoxMethods.prototype.onData;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
exports.CSVBoxAngularModule = CSVBoxAngularModule;
|
|
410
|
+
exports.CSVBoxButtonComponent = CSVBoxButtonComponent;
|
|
411
|
+
|
|
412
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
413
|
+
|
|
414
|
+
})));
|
|
415
|
+
//# sourceMappingURL=sumit_yewale-angular.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sumit_yewale-angular.umd.js","sources":["ng://@sumit_yewale/angular/utlis/insertCSS.ts","ng://@sumit_yewale/angular/lib/csvbox-button.component.ts","ng://@sumit_yewale/angular/lib/csvbox-angular.module.ts","ng://@sumit_yewale/angular/lib/interfaces/interface.ts"],"sourcesContent":["let styleElement: HTMLStyleElement\n\nconst GLOBAL_CSS = `\n.csvbox-holder {\n z-index: 2147483647;\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n display: none;\n}\n.csvbox-holder iframe {\n height: 100%;\n width: 100%;\n position: absolute;\n top: 0px;\n left: 0px;\n}\n`\n\nexport const insertCSS = (): void => {\n if (styleElement) {\n return\n }\n\n styleElement = document.createElement('style')\n styleElement.setAttribute('type', 'text/css')\n const head = document.querySelector('head');\n if (head) {\n head.appendChild(styleElement);\n }\n\n styleElement.textContent = GLOBAL_CSS\n}\n","import {\n Component,\n OnInit,\n ViewChild,\n Input,\n OnChanges,\n SimpleChanges,\n SecurityContext,\n AfterContentInit\n} from '@angular/core';\n\nimport { DomSanitizer, SafeUrl } from '@angular/platform-browser';\nimport { insertCSS } from '../utlis/insertCSS';\nimport { buildImportUrl, generateUuid, buildInitPayload, classifyStructuredMessage } from '@sumit_yewale/adapter-core';\n\nconst appVersion = '1.1.16';\n\n@Component({\n selector: 'csvbox-button',\n template: `\n <div>\n <button [disabled]=\"disabled\" #initiator (click)=\"openModal()\" [attr.data-csvbox-token]=\"uuid\">\n <ng-content></ng-content>\n </button>\n </div>\n `\n})\n\nexport class CSVBoxButtonComponent implements OnInit, OnChanges, AfterContentInit {\n\n isModalShown = false;\n\n @ViewChild('initiator', {static: false}) initiator: any;\n @Input() onImport?: Function;\n @Input() onReady?: Function;\n @Input() onClose?: Function;\n @Input() onSubmit?: Function;\n\n @Input() isImported?: Function;\n @Input() isReady?: Function;\n @Input() isClosed?: Function;\n @Input() isSubmitted?: Function;\n\n @Input() importerReady?: Function;\n @Input() closed?: Function;\n @Input() submitted?: Function;\n @Input() imported?: Function;\n @Input() loadStarted?: Function;\n\n @Input() user?: object;\n @Input() dynamicColumns?: object;\n @Input() licenseKey: string | null = null;\n @Input() options?: object;\n @Input() uuid: string | null = null;\n @Input() customDomain: string | null = null;\n @Input() dataLocation: string | null = null;\n @Input() language: string | null = null;\n @Input() environment?: object;\n\n @Input() theme: string | null = null;\n\n @Input() isIframeLoaded: boolean = false;\n @Input() openModalOnIframeLoad: boolean = false;\n\n @Input() lazy: boolean = false;\n\n safeUrl: any;\n\n iframe: HTMLIFrameElement | null = null;\n\n @Input() disabled: boolean = true;\n\n constructor(public sanitizer:DomSanitizer) {}\n\n holder: any;\n\n ngOnInit(): void {\n this.uuid = generateUuid();\n let iframeUrl = buildImportUrl(\n {\n licenseKey: this.licenseKey,\n customDomain: this.customDomain,\n dataLocation: this.dataLocation,\n language: this.language,\n theme: this.theme,\n environment: this.environment\n },\n \"angular\",\n appVersion\n );\n this.safeUrl = this.sanitizer.sanitize(SecurityContext.RESOURCE_URL, this.sanitizer.bypassSecurityTrustResourceUrl(iframeUrl));\n }\n\n ngOnChanges(changes: SimpleChanges) {\n if(changes[\"user\"] && changes['user'].currentValue != changes['user'].previousValue) {\n this.updateUserVariabe(changes['user'].currentValue);\n }\n }\n\n updateUserVariabe(data: any): void {\n this.user = data;\n if (this.iframe && this.iframe.contentWindow) {\n this.iframe.contentWindow.postMessage({\n \"customer\" : data\n }, \"*\");\n }\n }\n\n ngAfterContentInit(): void {\n window.addEventListener(\"message\", (event) => {\n let message = classifyStructuredMessage(event.data, this.uuid!);\n if (!message) {\n return;\n }\n\n if (message.type === \"data-on-submit\") {\n if (this.onSubmit) this.onSubmit(message.metadata);\n if (this.isSubmitted) this.isSubmitted(message.metadata);\n if (this.submitted) this.submitted(message.metadata);\n } else if (message.type === \"data-push-status\") {\n if (!message.success) {\n delete message.metadata[\"unique_token\"];\n }\n if (this.onImport) this.onImport(message.success, message.metadata);\n if (this.isImported) this.isImported(message.success, message.metadata);\n if (this.imported) this.imported(message.success, message.metadata);\n } else if (message.type === \"csvbox-modal-hidden\") {\n this.handleModalClosed();\n } else if (message.type === \"csvbox-upload-successful\") {\n if (this.onImport) this.onImport(true);\n if (this.isImported) this.isImported(true);\n if (this.imported) this.imported(true);\n } else if (message.type === \"csvbox-upload-failed\") {\n if (this.onImport) this.onImport(false);\n if (this.isImported) this.isImported(false);\n if (this.imported) this.imported(false);\n }\n }, false);\n\n if(this.lazy) {\n this.disabled = false;\n } else {\n this.disabled = true;\n this.initImporter();\n }\n }\n\n handleModalClosed(): void {\n if (this.holder) this.holder.style.display = 'none';\n this.isModalShown = false;\n this.isIframeLoaded = false;\n this.openModalOnIframeLoad = false;\n if (this.holder) this.holder.remove();\n this.holder = null;\n this.iframe = null;\n if (this.onClose) this.onClose();\n if (this.isClosed) this.isClosed();\n if (this.closed) this.closed();\n }\n\n initImporter() {\n if (this.loadStarted) this.loadStarted();\n\n this.uuid = generateUuid();\n\n insertCSS();\n\n let iframe = document.createElement(\"iframe\");\n this.iframe = iframe;\n iframe.setAttribute(\"src\", this.safeUrl);\n iframe.frameBorder = \"0\";\n\n let self = this;\n iframe.onload = function () {\n if (self.onReady) self.onReady();\n if (self.isReady) self.isReady();\n if (self.importerReady) self.importerReady();\n\n self.disabled = false;\n self.isIframeLoaded = true;\n if (self.iframe && self.iframe.contentWindow) {\n self.iframe.contentWindow.postMessage(buildInitPayload(self.user, self.dynamicColumns, self.options, self.uuid!), \"*\");\n }\n if(self.openModalOnIframeLoad) {\n self.openModal();\n }\n }\n\n this.holder = document.createElement('div');\n this.holder.classList.add('csvbox-holder');\n this.holder.setAttribute('id', `csvbox-embed-${this.uuid}`);\n this.holder.appendChild(iframe);\n\n document.body.insertAdjacentElement(\n 'beforeend', this.holder\n );\n }\n\n openModal(): void {\n if(!this.iframe) {\n this.openModalOnIframeLoad = true;\n this.initImporter();\n return;\n }\n if(!this.isModalShown) {\n if(this.isIframeLoaded) {\n this.isModalShown = true;\n if(this.holder) this.holder.style.display = 'block';\n if(this.iframe && this.iframe.contentWindow) {\n this.iframe.contentWindow.postMessage('openModal', '*');\n }\n } else {\n this.openModalOnIframeLoad = true;\n }\n }\n }\n\n}\n","import { NgModule } from '@angular/core';\nimport { CSVBoxButtonComponent } from './csvbox-button.component';\n\n\n\n@NgModule({\n declarations: [\n CSVBoxButtonComponent\n ],\n imports: [\n ],\n exports: [\n CSVBoxButtonComponent\n ]\n})\nexport class CSVBoxAngularModule { }\n","export interface CSVBoxMethods {\n onData?: (result:boolean, data:any) => void;\n}\n"],"names":["generateUuid","buildImportUrl","SecurityContext","classifyStructuredMessage","buildInitPayload","Component","DomSanitizer","ViewChild","Input","NgModule"],"mappings":";;;;;;;;;;;;QAAI,YAA8B;;QAE5B,UAAU,GAAG,wPAiBlB;;IAED,IAAa,SAAS;;;IAAG;QACvB,IAAI,YAAY,EAAE;YAChB,OAAM;SACP;QAED,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;QAC9C,YAAY,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;;YACvC,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC;QAC3C,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;SAChC;QAED,YAAY,CAAC,WAAW,GAAG,UAAU,CAAA;KACtC,CAAA;;;;;;;IClCD;QAeM,UAAU,GAAG,QAAQ;AAE3B;QAuDE,+BAAmB,SAAsB;YAAtB,cAAS,GAAT,SAAS,CAAa;YA1CzC,iBAAY,GAAG,KAAK,CAAC;YAqBZ,eAAU,GAAkB,IAAI,CAAC;YAEjC,SAAI,GAAkB,IAAI,CAAC;YAC3B,iBAAY,GAAkB,IAAI,CAAC;YACnC,iBAAY,GAAkB,IAAI,CAAC;YACnC,aAAQ,GAAkB,IAAI,CAAC;YAG/B,UAAK,GAAkB,IAAI,CAAC;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 +1,2 @@
|
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/platform-browser"),require("@sumit_yewale/adapter-core")):"function"==typeof define&&define.amd?define("@sumit_yewale/angular",["exports","@angular/core","@angular/platform-browser","@sumit_yewale/adapter-core"],e):e(((t=t||self).sumit_yewale=t.sumit_yewale||{},t.sumit_yewale.angular={}),t.ng.core,t.ng.platformBrowser,t.adapterCore)}(this,(function(t,e,o,i){"use strict";var n,s=function(){function t(t){this.sanitizer=t,this.isModalShown=!1,this.licenseKey=null,this.uuid=null,this.customDomain=null,this.dataLocation=null,this.language=null,this.theme=null,this.isIframeLoaded=!1,this.openModalOnIframeLoad=!1,this.lazy=!1,this.iframe=null,this.disabled=!0}return t.prototype.ngOnInit=function(){this.uuid=i.generateUuid();var t=i.buildImportUrl({licenseKey:this.licenseKey,customDomain:this.customDomain,dataLocation:this.dataLocation,language:this.language,theme:this.theme,environment:this.environment},"angular","1.1.16");this.safeUrl=this.sanitizer.sanitize(e.SecurityContext.RESOURCE_URL,this.sanitizer.bypassSecurityTrustResourceUrl(t))},t.prototype.ngOnChanges=function(t){t.user&&t.user.currentValue!=t.user.previousValue&&this.updateUserVariabe(t.user.currentValue)},t.prototype.updateUserVariabe=function(t){this.user=t,this.iframe&&this.iframe.contentWindow&&this.iframe.contentWindow.postMessage({customer:t},"*")},t.prototype.ngAfterContentInit=function(){var t=this;window.addEventListener("message",(function(e){var o=i.classifyStructuredMessage(e.data,t.uuid);o&&("data-on-submit"===o.type?(t.onSubmit&&t.onSubmit(o.metadata),t.isSubmitted&&t.isSubmitted(o.metadata),t.submitted&&t.submitted(o.metadata)):"data-push-status"===o.type?(o.success||delete o.metadata.unique_token,t.onImport&&t.onImport(o.success,o.metadata),t.isImported&&t.isImported(o.success,o.metadata),t.imported&&t.imported(o.success,o.metadata)):"csvbox-modal-hidden"===o.type?t.handleModalClosed():"csvbox-upload-successful"===o.type?(t.onImport&&t.onImport(!0),t.isImported&&t.isImported(!0),t.imported&&t.imported(!0)):"csvbox-upload-failed"===o.type&&(t.onImport&&t.onImport(!1),t.isImported&&t.isImported(!1),t.imported&&t.imported(!1)))}),!1),this.lazy?this.disabled=!1:(this.disabled=!0,this.initImporter())},t.prototype.handleModalClosed=function(){this.holder&&(this.holder.style.display="none"),this.isModalShown=!1,this.isIframeLoaded=!1,this.openModalOnIframeLoad=!1,this.holder&&this.holder.remove(),this.holder=null,this.iframe=null,this.onClose&&this.onClose(),this.isClosed&&this.isClosed(),this.closed&&this.closed()},t.prototype.initImporter=function(){this.loadStarted&&this.loadStarted(),this.uuid=i.generateUuid(),function(){if(!n){(n=document.createElement("style")).setAttribute("type","text/css");var t=document.querySelector("head");t&&t.appendChild(n),n.textContent="\n.csvbox-holder {\n z-index: 2147483647;\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n display: none;\n}\n.csvbox-holder iframe {\n height: 100%;\n width: 100%;\n position: absolute;\n top: 0px;\n left: 0px;\n}\n"}}();var t=document.createElement("iframe");this.iframe=t,t.setAttribute("src",this.safeUrl),t.frameBorder="0";var e=this;t.onload=function(){e.onReady&&e.onReady(),e.isReady&&e.isReady(),e.importerReady&&e.importerReady(),e.disabled=!1,e.isIframeLoaded=!0,e.iframe&&e.iframe.contentWindow&&e.iframe.contentWindow.postMessage(i.buildInitPayload(e.user,e.dynamicColumns,e.options,e.uuid),"*"),e.openModalOnIframeLoad&&e.openModal()},this.holder=document.createElement("div"),this.holder.classList.add("csvbox-holder"),this.holder.setAttribute("id","csvbox-embed-"+this.uuid),this.holder.appendChild(t),document.body.insertAdjacentElement("beforeend",this.holder)},t.prototype.openModal=function(){if(!this.iframe)return this.openModalOnIframeLoad=!0,void this.initImporter();this.isModalShown||(this.isIframeLoaded?(this.isModalShown=!0,this.holder&&(this.holder.style.display="block"),this.iframe&&this.iframe.contentWindow&&this.iframe.contentWindow.postMessage("openModal","*")):this.openModalOnIframeLoad=!0)},t.decorators=[{type:e.Component,args:[{selector:"csvbox-button",template:'\n <div>\n <button [disabled]="disabled" #initiator (click)="openModal()" [attr.data-csvbox-token]="uuid">\n <ng-content></ng-content>\n </button>\n </div>\n '}]}],t.ctorParameters=function(){return[{type:o.DomSanitizer}]},t.propDecorators={initiator:[{type:e.ViewChild,args:["initiator",{static:!1}]}],onImport:[{type:e.Input}],onReady:[{type:e.Input}],onClose:[{type:e.Input}],onSubmit:[{type:e.Input}],isImported:[{type:e.Input}],isReady:[{type:e.Input}],isClosed:[{type:e.Input}],isSubmitted:[{type:e.Input}],importerReady:[{type:e.Input}],closed:[{type:e.Input}],submitted:[{type:e.Input}],imported:[{type:e.Input}],loadStarted:[{type:e.Input}],user:[{type:e.Input}],dynamicColumns:[{type:e.Input}],licenseKey:[{type:e.Input}],options:[{type:e.Input}],uuid:[{type:e.Input}],customDomain:[{type:e.Input}],dataLocation:[{type:e.Input}],language:[{type:e.Input}],environment:[{type:e.Input}],theme:[{type:e.Input}],isIframeLoaded:[{type:e.Input}],openModalOnIframeLoad:[{type:e.Input}],lazy:[{type:e.Input}],disabled:[{type:e.Input}]},t}();var a=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{declarations:[s],imports:[],exports:[s]}]}],t}();t.CSVBoxAngularModule=a,t.CSVBoxButtonComponent=s,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
2
|
+
//# sourceMappingURL=sumit_yewale-angular.umd.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["ng://@sumit_yewale/angular/utlis/insertCSS.ts","ng://@sumit_yewale/angular/lib/csvbox-button.component.ts","ng://@sumit_yewale/angular/lib/csvbox-angular.module.ts"],"names":["styleElement","CSVBoxButtonComponent","sanitizer","this","isModalShown","licenseKey","uuid","customDomain","dataLocation","language","theme","isIframeLoaded","openModalOnIframeLoad","lazy","iframe","disabled","prototype","ngOnInit","generateUuid","iframeUrl","buildImportUrl","environment","safeUrl","sanitize","SecurityContext","RESOURCE_URL","bypassSecurityTrustResourceUrl","ngOnChanges","changes","currentValue","previousValue","updateUserVariabe","data","user","contentWindow","postMessage","customer","ngAfterContentInit","_this","window","addEventListener","event","message","classifyStructuredMessage","type","onSubmit","metadata","isSubmitted","submitted","success","onImport","isImported","imported","handleModalClosed","initImporter","holder","style","display","remove","onClose","isClosed","closed","loadStarted","document","createElement","setAttribute","head","querySelector","appendChild","textContent","insertCSS","frameBorder","self","onload","onReady","isReady","importerReady","buildInitPayload","dynamicColumns","options","openModal","classList","add","body","insertAdjacentElement","Component","args","selector","template","DomSanitizer","ViewChild","static","Input","CSVBoxAngularModule","NgModule","declarations","imports","exports"],"mappings":"kfAAIA,ECiBJC,EAAA,WAuDE,SAAAA,EAAmBC,GAAAC,KAAAD,UAAAA,EA1CnBC,KAAAC,cAAe,EAqBND,KAAAE,WAA4B,KAE5BF,KAAAG,KAAsB,KACtBH,KAAAI,aAA8B,KAC9BJ,KAAAK,aAA8B,KAC9BL,KAAAM,SAA0B,KAG1BN,KAAAO,MAAuB,KAEvBP,KAAAQ,gBAA0B,EAC1BR,KAAAS,uBAAiC,EAEjCT,KAAAU,MAAgB,EAIzBV,KAAAW,OAAmC,KAE1BX,KAAAY,UAAoB,EAmJ/B,OA7IEd,EAAAe,UAAAC,SAAA,WACEd,KAAKG,KAAOY,EAAAA,mBACRC,EAAYC,EAAAA,eACd,CACEf,WAAYF,KAAKE,WACjBE,aAAcJ,KAAKI,aACnBC,aAAcL,KAAKK,aACnBC,SAAUN,KAAKM,SACfC,MAAOP,KAAKO,MACZW,YAAalB,KAAKkB,aAEpB,UAxEa,UA2EflB,KAAKmB,QAAUnB,KAAKD,UAAUqB,SAASC,EAAAA,gBAAgBC,aAActB,KAAKD,UAAUwB,+BAA+BP,KAGrHlB,EAAAe,UAAAW,YAAA,SAAYC,GACPA,EAAc,MAAKA,EAAc,KAAEC,cAAgBD,EAAc,KAAEE,eACpE3B,KAAK4B,kBAAkBH,EAAc,KAAEC,eAI3C5B,EAAAe,UAAAe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KAAKC,cAAe,EACjBD,KAAKoD,SAAQpD,KAAKoD,OAAOC,MAAMC,QAAU,SACzCtD,KAAKW,QAAUX,KAAKW,OAAOoB,eAC5B/B,KAAKW,OAAOoB,cAAcC,YAAY,YAAa,MAGrDhC,KAAKS,uBAAwB,wBAnMtCyE,EAAAA,UAASC,KAAA,CAAC,CACTC,SAAU,gBACVC,SAAU,sOARHC,EAAAA,mDAqBNC,EAAAA,UAASJ,KAAA,CAAC,YAAa,CAACK,QAAQ,sBAChCC,EAAAA,uBACAA,EAAAA,uBACAA,EAAAA,wBACAA,EAAAA,0BAEAA,EAAAA,uBACAA,EAAAA,wBACAA,EAAAA,2BACAA,EAAAA,6BAEAA,EAAAA,sBACAA,EAAAA,yBACAA,EAAAA,wBACAA,EAAAA,2BACAA,EAAAA,oBAEAA,EAAAA,8BACAA,EAAAA,0BACAA,EAAAA,uBACAA,EAAAA,oBACAA,EAAAA,4BACAA,EAAAA,4BACAA,EAAAA,wBACAA,EAAAA,2BACAA,EAAAA,qBAEAA,EAAAA,8BAEAA,EAAAA,qCACAA,EAAAA,oBAEAA,EAAAA,wBAMAA,EAAAA,SAmJH3F,EAxMA,GCjBA,IAAA4F,EAAA,WAKA,SAAAA,KAUmC,2BAVlCC,EAAAA,SAAQR,KAAA,CAAC,CACRS,aAAc,CACZ9F,GAEF+F,QAAS,GAETC,QAAS,CACPhG,OAG+B4F,EAfnC","sourcesContent":["let styleElement: HTMLStyleElement\n\nconst GLOBAL_CSS = `\n.csvbox-holder {\n z-index: 2147483647;\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n display: none;\n}\n.csvbox-holder iframe {\n height: 100%;\n width: 100%;\n position: absolute;\n top: 0px;\n left: 0px;\n}\n`\n\nexport const insertCSS = (): void => {\n if (styleElement) {\n return\n }\n\n styleElement = document.createElement('style')\n styleElement.setAttribute('type', 'text/css')\n const head = document.querySelector('head');\n if (head) {\n head.appendChild(styleElement);\n }\n\n styleElement.textContent = GLOBAL_CSS\n}\n","import {\n Component,\n OnInit,\n ViewChild,\n Input,\n OnChanges,\n SimpleChanges,\n SecurityContext,\n AfterContentInit\n} from '@angular/core';\n\nimport { DomSanitizer, SafeUrl } from '@angular/platform-browser';\nimport { insertCSS } from '../utlis/insertCSS';\nimport { buildImportUrl, generateUuid, buildInitPayload, classifyStructuredMessage } from '@sumit_yewale/adapter-core';\n\nconst appVersion = '1.1.16';\n\n@Component({\n selector: 'csvbox-button',\n template: `\n <div>\n <button [disabled]=\"disabled\" #initiator (click)=\"openModal()\" [attr.data-csvbox-token]=\"uuid\">\n <ng-content></ng-content>\n </button>\n </div>\n `\n})\n\nexport class CSVBoxButtonComponent implements OnInit, OnChanges, AfterContentInit {\n\n isModalShown = false;\n\n @ViewChild('initiator', {static: false}) initiator: any;\n @Input() onImport?: Function;\n @Input() onReady?: Function;\n @Input() onClose?: Function;\n @Input() onSubmit?: Function;\n\n @Input() isImported?: Function;\n @Input() isReady?: Function;\n @Input() isClosed?: Function;\n @Input() isSubmitted?: Function;\n\n @Input() importerReady?: Function;\n @Input() closed?: Function;\n @Input() submitted?: Function;\n @Input() imported?: Function;\n @Input() loadStarted?: Function;\n\n @Input() user?: object;\n @Input() dynamicColumns?: object;\n @Input() licenseKey: string | null = null;\n @Input() options?: object;\n @Input() uuid: string | null = null;\n @Input() customDomain: string | null = null;\n @Input() dataLocation: string | null = null;\n @Input() language: string | null = null;\n @Input() environment?: object;\n\n @Input() theme: string | null = null;\n\n @Input() isIframeLoaded: boolean = false;\n @Input() openModalOnIframeLoad: boolean = false;\n\n @Input() lazy: boolean = false;\n\n safeUrl: any;\n\n iframe: HTMLIFrameElement | null = null;\n\n @Input() disabled: boolean = true;\n\n constructor(public sanitizer:DomSanitizer) {}\n\n holder: any;\n\n ngOnInit(): void {\n this.uuid = generateUuid();\n let iframeUrl = buildImportUrl(\n {\n licenseKey: this.licenseKey,\n customDomain: this.customDomain,\n dataLocation: this.dataLocation,\n language: this.language,\n theme: this.theme,\n environment: this.environment\n },\n \"angular\",\n appVersion\n );\n this.safeUrl = this.sanitizer.sanitize(SecurityContext.RESOURCE_URL, this.sanitizer.bypassSecurityTrustResourceUrl(iframeUrl));\n }\n\n ngOnChanges(changes: SimpleChanges) {\n if(changes[\"user\"] && changes['user'].currentValue != changes['user'].previousValue) {\n this.updateUserVariabe(changes['user'].currentValue);\n }\n }\n\n updateUserVariabe(data: any): void {\n this.user = data;\n if (this.iframe && this.iframe.contentWindow) {\n this.iframe.contentWindow.postMessage({\n \"customer\" : data\n }, \"*\");\n }\n }\n\n ngAfterContentInit(): void {\n window.addEventListener(\"message\", (event) => {\n let message = classifyStructuredMessage(event.data, this.uuid!);\n if (!message) {\n return;\n }\n\n if (message.type === \"data-on-submit\") {\n if (this.onSubmit) this.onSubmit(message.metadata);\n if (this.isSubmitted) this.isSubmitted(message.metadata);\n if (this.submitted) this.submitted(message.metadata);\n } else if (message.type === \"data-push-status\") {\n if (!message.success) {\n delete message.metadata[\"unique_token\"];\n }\n if (this.onImport) this.onImport(message.success, message.metadata);\n if (this.isImported) this.isImported(message.success, message.metadata);\n if (this.imported) this.imported(message.success, message.metadata);\n } else if (message.type === \"csvbox-modal-hidden\") {\n this.handleModalClosed();\n } else if (message.type === \"csvbox-upload-successful\") {\n if (this.onImport) this.onImport(true);\n if (this.isImported) this.isImported(true);\n if (this.imported) this.imported(true);\n } else if (message.type === \"csvbox-upload-failed\") {\n if (this.onImport) this.onImport(false);\n if (this.isImported) this.isImported(false);\n if (this.imported) this.imported(false);\n }\n }, false);\n\n if(this.lazy) {\n this.disabled = false;\n } else {\n this.disabled = true;\n this.initImporter();\n }\n }\n\n handleModalClosed(): void {\n if (this.holder) this.holder.style.display = 'none';\n this.isModalShown = false;\n this.isIframeLoaded = false;\n this.openModalOnIframeLoad = false;\n if (this.holder) this.holder.remove();\n this.holder = null;\n this.iframe = null;\n if (this.onClose) this.onClose();\n if (this.isClosed) this.isClosed();\n if (this.closed) this.closed();\n }\n\n initImporter() {\n if (this.loadStarted) this.loadStarted();\n\n this.uuid = generateUuid();\n\n insertCSS();\n\n let iframe = document.createElement(\"iframe\");\n this.iframe = iframe;\n iframe.setAttribute(\"src\", this.safeUrl);\n iframe.frameBorder = \"0\";\n\n let self = this;\n iframe.onload = function () {\n if (self.onReady) self.onReady();\n if (self.isReady) self.isReady();\n if (self.importerReady) self.importerReady();\n\n self.disabled = false;\n self.isIframeLoaded = true;\n if (self.iframe && self.iframe.contentWindow) {\n self.iframe.contentWindow.postMessage(buildInitPayload(self.user, self.dynamicColumns, self.options, self.uuid!), \"*\");\n }\n if(self.openModalOnIframeLoad) {\n self.openModal();\n }\n }\n\n this.holder = document.createElement('div');\n this.holder.classList.add('csvbox-holder');\n this.holder.setAttribute('id', `csvbox-embed-${this.uuid}`);\n this.holder.appendChild(iframe);\n\n document.body.insertAdjacentElement(\n 'beforeend', this.holder\n );\n }\n\n openModal(): void {\n if(!this.iframe) {\n this.openModalOnIframeLoad = true;\n this.initImporter();\n return;\n }\n if(!this.isModalShown) {\n if(this.isIframeLoaded) {\n this.isModalShown = true;\n if(this.holder) this.holder.style.display = 'block';\n if(this.iframe && this.iframe.contentWindow) {\n this.iframe.contentWindow.postMessage('openModal', '*');\n }\n } else {\n this.openModalOnIframeLoad = true;\n }\n }\n }\n\n}\n","import { NgModule } from '@angular/core';\nimport { CSVBoxButtonComponent } from './csvbox-button.component';\n\n\n\n@NgModule({\n declarations: [\n CSVBoxButtonComponent\n ],\n imports: [\n ],\n exports: [\n CSVBoxButtonComponent\n ]\n})\nexport class CSVBoxAngularModule { }\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview added by tsickle
|
|
3
|
+
* Generated from: lib/csvbox-angular.module.ts
|
|
4
|
+
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
5
|
+
*/
|
|
6
|
+
import { NgModule } from '@angular/core';
|
|
7
|
+
import { CSVBoxButtonComponent } from './csvbox-button.component';
|
|
8
|
+
export class CSVBoxAngularModule {
|
|
9
|
+
}
|
|
10
|
+
CSVBoxAngularModule.decorators = [
|
|
11
|
+
{ type: NgModule, args: [{
|
|
12
|
+
declarations: [
|
|
13
|
+
CSVBoxButtonComponent
|
|
14
|
+
],
|
|
15
|
+
imports: [],
|
|
16
|
+
exports: [
|
|
17
|
+
CSVBoxButtonComponent
|
|
18
|
+
]
|
|
19
|
+
},] }
|
|
20
|
+
];
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3N2Ym94LWFuZ3VsYXIubW9kdWxlLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQHN1bWl0X3lld2FsZS9hbmd1bGFyLyIsInNvdXJjZXMiOlsibGliL2NzdmJveC1hbmd1bGFyLm1vZHVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDekMsT0FBTyxFQUFFLHFCQUFxQixFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFjbEUsTUFBTSxPQUFPLG1CQUFtQjs7O1lBVi9CLFFBQVEsU0FBQztnQkFDUixZQUFZLEVBQUU7b0JBQ1oscUJBQXFCO2lCQUN0QjtnQkFDRCxPQUFPLEVBQUUsRUFDUjtnQkFDRCxPQUFPLEVBQUU7b0JBQ1AscUJBQXFCO2lCQUN0QjthQUNGIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgTmdNb2R1bGUgfSBmcm9tICdAYW5ndWxhci9jb3JlJztcbmltcG9ydCB7IENTVkJveEJ1dHRvbkNvbXBvbmVudCB9IGZyb20gJy4vY3N2Ym94LWJ1dHRvbi5jb21wb25lbnQnO1xuXG5cblxuQE5nTW9kdWxlKHtcbiAgZGVjbGFyYXRpb25zOiBbXG4gICAgQ1NWQm94QnV0dG9uQ29tcG9uZW50XG4gIF0sXG4gIGltcG9ydHM6IFtcbiAgXSxcbiAgZXhwb3J0czogW1xuICAgIENTVkJveEJ1dHRvbkNvbXBvbmVudFxuICBdXG59KVxuZXhwb3J0IGNsYXNzIENTVkJveEFuZ3VsYXJNb2R1bGUgeyB9XG4iXX0=
|